Complete security audit fixes
This commit is contained in:
@@ -235,7 +235,12 @@ function ajax_request(options) {
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
// These two settings are only triggered when sending files
|
// These two settings are only triggered when sending files
|
||||||
processData: isSendingFiles ? false : true,
|
processData: isSendingFiles ? false : true,
|
||||||
contentType: isSendingFiles ? false : "application/x-www-form-urlencoded; charset=UTF-8"
|
contentType: isSendingFiles ? false : "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
// for CSRF validation
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,94 @@
|
|||||||
require_once __DIR__."/../../config.php";
|
require_once __DIR__."/../../config.php";
|
||||||
require_once __DIR__."/../../dbconn.php";
|
require_once __DIR__."/../../dbconn.php";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check PDO statement for errors
|
||||||
|
* Logs full error server-side, returns generic message to client
|
||||||
|
*
|
||||||
|
* @param PDOStatement $sth - The executed PDO statement
|
||||||
|
* @param array &$answer - Response array passed by reference
|
||||||
|
* @param array $options - Optional settings:
|
||||||
|
* 'message' => Custom client-facing error message
|
||||||
|
* 'log' => Custom server log label
|
||||||
|
* 'code' => HTTP response code (default: 500)
|
||||||
|
* 'before_exit' => Callback function before exit
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Simple — use all defaults
|
||||||
|
* db_check($sth, $answer);
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Custom client message
|
||||||
|
* db_check($sth, $answer, [
|
||||||
|
* 'message' => "Contact not found."
|
||||||
|
* ]);
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Custom log label + message
|
||||||
|
* db_check($sth, $answer, [
|
||||||
|
* 'log' => "Failed to fetch contact",
|
||||||
|
* 'message' => "Could not load contact. Please try again."
|
||||||
|
* ]);
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Custom HTTP status code
|
||||||
|
* db_check($sth, $answer, [
|
||||||
|
* 'code' => 403,
|
||||||
|
* 'message' => "Access denied."
|
||||||
|
* ]);
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Cleanup callback before exit
|
||||||
|
* db_check($sth, $answer, [
|
||||||
|
* 'message' => "Upload failed.",
|
||||||
|
* 'before_exit' => function() use ($tmp_file) {
|
||||||
|
* if(file_exists($tmp_file)) unlink($tmp_file);
|
||||||
|
* }
|
||||||
|
* ]);
|
||||||
|
*/
|
||||||
|
function db_check($sth, &$answer, $options = []) {
|
||||||
|
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
||||||
|
|
||||||
|
$trace = debug_backtrace()[0];
|
||||||
|
|
||||||
|
$log_message = $options['log'] ?? "DB Error";
|
||||||
|
error_log($log_message . " in " . $trace['file'] . " line " . $trace['line'] . ": " . $sth->errorInfo()[2]);
|
||||||
|
|
||||||
|
$answer["message"] = $options['message'] ?? "A server error occurred. Please try again.";
|
||||||
|
|
||||||
|
http_response_code($options['code'] ?? 500);
|
||||||
|
|
||||||
|
if(isset($options['before_exit'])) {
|
||||||
|
call_user_func($options['before_exit']);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(json_encode($answer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!empty($_SESSION["login_company_id"])){
|
if(!empty($_SESSION["login_company_id"])){
|
||||||
|
|
||||||
|
// CSRF Validation — add right at the top of the logged-in block
|
||||||
|
if($_SERVER['REQUEST_METHOD'] === 'POST'){
|
||||||
|
$csrf_token = $_SERVER['HTTP_X_CSRF_TOKEN'] ?? '';
|
||||||
|
if(empty($csrf_token) || $csrf_token !== $_SESSION['csrf_token']){
|
||||||
|
http_response_code(403);
|
||||||
|
exit(json_encode(["message" => "Invalid request"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// validate otp
|
// validate otp
|
||||||
$sql = "SELECT `password`
|
$sql = "SELECT `password`
|
||||||
FROM user
|
FROM user
|
||||||
WHERE user_id = {$_SESSION["login_user_id"]}";
|
WHERE user_id = :company_id";
|
||||||
$sth = $pdo1->prepare($sql);
|
$sth = $pdo1->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $_SESSION["login_user_id"]
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
]);
|
||||||
exit(json_encode($answer));
|
db_check($sth, $answer);
|
||||||
}
|
|
||||||
$password = $sth->fetchColumn();
|
$password = $sth->fetchColumn();
|
||||||
/** Generate OTP */
|
/** Generate OTP */
|
||||||
function generateOTP($sercet_key, $time_step = 180, $length = 6){
|
function generateOTP($sercet_key, $time_step = 180, $length = 6){
|
||||||
@@ -35,13 +111,13 @@ if(!empty($_SESSION["login_company_id"])){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check company accessibily
|
// check company accessibily
|
||||||
$sql = "SELECT * FROM company_map_user WHERE company_id = {$_SESSION["login_company_id"]} and user_id = {$_SESSION["login_user_id"]}";
|
$sql = "SELECT * FROM company_map_user WHERE company_id = :login_company_id and user_id = :login_user_id";
|
||||||
$sth = $pdo1->prepare($sql);
|
$sth = $pdo1->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":login_company_id" => $_SESSION["login_company_id"],
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":login_user_id" => $_SESSION["login_user_id"]
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
$map = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$map = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if( count($map)==0 ){
|
if( count($map)==0 ){
|
||||||
@@ -51,10 +127,6 @@ if(!empty($_SESSION["login_company_id"])){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// set up ANSWER
|
// set up ANSWER
|
||||||
$answer = array("success"=>0, "message"=>"");
|
$answer = array("success"=>0, "message"=>"");
|
||||||
|
|
||||||
@@ -86,10 +158,4 @@ if(!empty($_SESSION["login_company_id"])){
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class db_auth{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ class mailer{
|
|||||||
return $input["smtp"];
|
return $input["smtp"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM smtp_setting WHERE company_id = '{$revise["company_id"]}'";
|
$sql = "SELECT * FROM smtp_setting WHERE company_id = :company_id ";
|
||||||
|
|
||||||
$sth = $this->pdo2->prepare("$sql");
|
$sth = $this->pdo2->prepare("$sql");
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
|
":company_id" => $revise["company_id"]
|
||||||
|
]);
|
||||||
|
|
||||||
$res = $sth->fetch(PDO::FETCH_ASSOC);
|
$res = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_contact
|
FROM md_contact
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id}";
|
company_id = :company_id ";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
]);
|
||||||
exit(json_encode($answer));
|
db_check($sth, $answer);
|
||||||
}
|
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_contact_type
|
FROM md_contact_type
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id}";
|
company_id = :company_id ";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
]);
|
||||||
exit(json_encode($answer));
|
db_check($sth, $answer);
|
||||||
}
|
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -67,21 +66,52 @@
|
|||||||
/** 3. PROCESSING NEW UPLOADS **/
|
/** 3. PROCESSING NEW UPLOADS **/
|
||||||
$uploaded_names = [];
|
$uploaded_names = [];
|
||||||
|
|
||||||
|
// Allowed MIME types whitelist
|
||||||
|
$allowed_mimes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'application/pdf'];
|
||||||
|
|
||||||
|
// Allowed extensions whitelist
|
||||||
|
$allowed_extensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'pdf'];
|
||||||
|
|
||||||
|
// Max file size: 5MB
|
||||||
|
$max_size = 5 * 1024 * 1024;
|
||||||
|
|
||||||
if (isset($_FILES['contact_files'])) {
|
if (isset($_FILES['contact_files'])) {
|
||||||
foreach ($_FILES['contact_files']['name'] as $key => $name) {
|
foreach ($_FILES['contact_files']['name'] as $key => $name) {
|
||||||
if ($_FILES['contact_files']['error'][$key] === UPLOAD_ERR_OK) {
|
if ($_FILES['contact_files']['error'][$key] === UPLOAD_ERR_OK) {
|
||||||
|
|
||||||
$tmp_name = $_FILES['contact_files']['tmp_name'][$key];
|
$tmp_name = $_FILES['contact_files']['tmp_name'][$key];
|
||||||
$extension = pathinfo($name, PATHINFO_EXTENSION);
|
$file_size = $_FILES['contact_files']['size'][$key];
|
||||||
|
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
|
||||||
// Assign a unique ID to prevent filename collisions on the server
|
|
||||||
$file_id = uniqid() . "_" . time() . "." . $extension;
|
// Check 1: File size
|
||||||
|
if ($file_size > $max_size) {
|
||||||
|
error_log("Rejected oversized file: " . $name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check 2: Extension whitelist
|
||||||
|
if (!in_array($extension, $allowed_extensions)) {
|
||||||
|
error_log("Rejected extension: " . $name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check 3: Real MIME type (reads actual file bytes, not filename)
|
||||||
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||||
|
$mime = finfo_file($finfo, $tmp_name);
|
||||||
|
finfo_close($finfo);
|
||||||
|
|
||||||
|
if (!in_array($mime, $allowed_mimes)) {
|
||||||
|
error_log("Rejected MIME type: " . $mime . " for file: " . $name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Safe unique filename — no original extension trusted
|
||||||
|
$file_id = uniqid() . "_" . time() . "." . $extension;
|
||||||
$destination = $target_dir . $file_id;
|
$destination = $target_dir . $file_id;
|
||||||
|
|
||||||
if (move_uploaded_file($tmp_name, $destination)) {
|
if (move_uploaded_file($tmp_name, $destination)) {
|
||||||
$uploaded_names[] = $file_id;
|
$uploaded_names[] = $file_id;
|
||||||
// Standard readable permission
|
chmod($destination, 0644);
|
||||||
chmod($destination, 0644);
|
|
||||||
} else {
|
} else {
|
||||||
error_log("Failed to move uploaded file: " . $name);
|
error_log("Failed to move uploaded file: " . $name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -9,15 +8,15 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_contact
|
FROM md_contact
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$target_dir = $include_url."uploads/contact/";
|
$target_dir = $include_url."uploads/contact/";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -9,15 +8,15 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_contact_type
|
FROM md_contact_type
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_product
|
FROM md_product
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
sku like '%{$data["keyword"]}%'
|
sku like :keyword
|
||||||
LIMIT 50
|
LIMIT 50
|
||||||
";
|
";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":keyword" => '%'.$data["keyword"].'%'
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$answer["result"] = $result;
|
$answer["result"] = $result;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -10,17 +9,18 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_storage
|
FROM md_storage
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
warehouse = {$warehouse} and
|
warehouse = :warehouse and
|
||||||
`zone` = '{$data["zone"]}'
|
`zone` = :zone
|
||||||
";
|
";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":warehouse" => $warehouse,
|
||||||
exit(json_encode($answer));
|
":zone" => $data["zone"]
|
||||||
}
|
]);
|
||||||
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$pre = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$pre = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -10,18 +9,20 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_storage
|
FROM md_storage
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
warehouse = {$warehouse} and
|
warehouse = :warehouse and
|
||||||
`zone` = '{$data["zone"]}' and
|
`zone` = :zone and
|
||||||
'{$data["aisle"]}' between aisle_from and aisle_to
|
:aisle between aisle_from and aisle_to
|
||||||
";
|
";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":warehouse" => $warehouse,
|
||||||
exit(json_encode($answer));
|
":zone" => $data["zone"],
|
||||||
}
|
":aisle" => $data["aisle"]
|
||||||
|
]);
|
||||||
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$pre = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$pre = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -14,11 +13,11 @@
|
|||||||
warehouse = {$warehouse}";
|
warehouse = {$warehouse}";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":warehouse" => $warehouse
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>ThreeWMS</title>
|
<title>ThreeWMS</title>
|
||||||
|
<meta name="csrf-token" content="<?= htmlspecialchars($_SESSION['csrf_token'] ?? '') ?>">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo $server_url?>assets/images/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo $server_url?>assets/images/apple-touch-icon.png">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="<?php echo $server_url?>assets/images/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="<?php echo $server_url?>assets/images/favicon-32x32.png">
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -10,14 +9,15 @@
|
|||||||
$sql = "SELECT `log`
|
$sql = "SELECT `log`
|
||||||
FROM md_product_category
|
FROM md_product_category
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$table_log = json_decode($row['log'] ?? '[]', true);
|
$table_log = json_decode($row['log'] ?? '[]', true);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -10,14 +9,15 @@
|
|||||||
$sql = "SELECT `log`
|
$sql = "SELECT `log`
|
||||||
FROM md_product
|
FROM md_product
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$table_log = json_decode($row['log'] ?? '[]', true);
|
$table_log = json_decode($row['log'] ?? '[]', true);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)($data['id'] ?? 0);
|
$id = (int)($data['id'] ?? 0);
|
||||||
@@ -17,10 +16,8 @@ $sth->execute([
|
|||||||
':id' => $id,
|
':id' => $id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
db_check($sth, $answer);
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
|
||||||
exit(json_encode($answer));
|
|
||||||
}
|
|
||||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$table_log = json_decode($row['log'] ?? '[]', true);
|
$table_log = json_decode($row['log'] ?? '[]', true);
|
||||||
@@ -89,10 +86,7 @@ if ($id > 0) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
db_check($sth, $answer);
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
|
||||||
exit(json_encode($answer));
|
|
||||||
}
|
|
||||||
|
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
exit(json_encode($answer));
|
exit(json_encode($answer));
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)($data['id'] ?? 0);
|
$id = (int)($data['id'] ?? 0);
|
||||||
@@ -17,10 +16,8 @@ $sth->execute([
|
|||||||
':id' => $id,
|
':id' => $id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
db_check($sth, $answer);
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
|
||||||
exit(json_encode($answer));
|
|
||||||
}
|
|
||||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$table_log = json_decode($row['log'] ?? '[]', true);
|
$table_log = json_decode($row['log'] ?? '[]', true);
|
||||||
@@ -76,10 +73,7 @@ if ($id > 0) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
db_check($sth, $answer);
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
|
||||||
exit(json_encode($answer));
|
|
||||||
}
|
|
||||||
|
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
exit(json_encode($answer));
|
exit(json_encode($answer));
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM user
|
FROM user
|
||||||
WHERE
|
WHERE
|
||||||
username not in ('support','extra')";
|
username not in ('support','extra')";
|
||||||
$sth = $pdo1->prepare($sql);
|
$sth = $pdo1->query($sql);
|
||||||
$sth->execute();
|
db_check($sth, $answer);
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
|
||||||
exit(json_encode($answer));
|
|
||||||
}
|
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
@@ -9,11 +8,10 @@
|
|||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id}";
|
company_id = {$company_id}";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
]);
|
||||||
exit(json_encode($answer));
|
db_check($sth, $answer);
|
||||||
}
|
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
@@ -9,11 +8,10 @@
|
|||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id}";
|
company_id = {$company_id}";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
]);
|
||||||
exit(json_encode($answer));
|
db_check($sth, $answer);
|
||||||
}
|
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -10,14 +9,14 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_product_category
|
FROM md_product_category
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
$json = $sth->fetch(PDO::FETCH_ASSOC);
|
$json = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$json = json_encode($json);
|
$json = json_encode($json);
|
||||||
|
|
||||||
@@ -26,25 +25,26 @@
|
|||||||
// delete data
|
// delete data
|
||||||
$sql = "DELETE FROM md_product_category
|
$sql = "DELETE FROM md_product_category
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// insert into archive
|
// insert into archive
|
||||||
$sql = "INSERT INTO archive (`company_id`,`user_id`,`date`,`json`) VALUES ({$company_id},{$user_id},NOW(),'{$jsona}')";
|
$sql = "INSERT INTO archive (`company_id`,`user_id`,`date`,`json`) VALUES (:company_id,:user_id,NOW(),:json)";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":user_id" => $user_id,
|
||||||
exit(json_encode($answer));
|
":json" => $json
|
||||||
}
|
]);
|
||||||
|
db_check($sth, $answer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -9,15 +8,15 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_product_category
|
FROM md_product_category
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -9,15 +8,15 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_product
|
FROM md_product
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -9,15 +8,15 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_storage
|
FROM md_storage
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$id = (int)$data['id'];
|
$id = (int)$data['id'];
|
||||||
@@ -9,15 +8,15 @@
|
|||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM md_warehouse
|
FROM md_warehouse
|
||||||
WHERE
|
WHERE
|
||||||
company_id = {$company_id} and
|
company_id = :company_id and
|
||||||
id = {$id}";
|
id = :id ";
|
||||||
|
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id,
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
":id" => $id
|
||||||
exit(json_encode($answer));
|
]);
|
||||||
}
|
db_check($sth, $answer);
|
||||||
|
|
||||||
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
$answer["success"] = 1;
|
$answer["success"] = 1;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT a.*, b.warehouse_name
|
$sql = "SELECT a.*, b.warehouse_name
|
||||||
@@ -10,13 +9,12 @@
|
|||||||
a.company_id = b.company_id and
|
a.company_id = b.company_id and
|
||||||
a.warehouse = b.id
|
a.warehouse = b.id
|
||||||
WHERE
|
WHERE
|
||||||
a.company_id = {$company_id}";
|
a.company_id = :company_id ";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
]);
|
||||||
exit(json_encode($answer));
|
db_check($sth, $answer);
|
||||||
}
|
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$sql = "SELECT a.*
|
$sql = "SELECT a.*
|
||||||
FROM md_warehouse a
|
FROM md_warehouse a
|
||||||
WHERE
|
WHERE
|
||||||
a.company_id = {$company_id}";
|
a.company_id = :company_id";
|
||||||
$sth = $pdo2->prepare($sql);
|
$sth = $pdo2->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
|
":company_id" => $company_id
|
||||||
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
|
]);
|
||||||
exit(json_encode($answer));
|
db_check($sth, $answer);
|
||||||
}
|
|
||||||
|
|
||||||
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require '../../../preset.php';
|
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
require '../../../config.php';
|
||||||
require '../../../preset.php';
|
require '../../../preset.php';
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$data["username"] = $_SESSION["login_data"]['username'];
|
$data["username"] = $_SESSION["login_data"]['username'];
|
||||||
$data["password"] = $_SESSION["login_data"]['password'];
|
$data["password"] = $_SESSION["login_data"]['password'];
|
||||||
$user_id = $_SESSION["login_user_id"];
|
$user_id = $_SESSION["login_user_id"];
|
||||||
$password = md5(trim(strtolower($data["password"])));
|
|
||||||
$salt_password = md5($user_id."_".trim(strtolower($data["password"])));
|
// get password
|
||||||
|
$sth = $pdo1->prepare("select * from user where user_id = :user_id limit 1;");
|
||||||
|
$sth->execute([
|
||||||
|
":user_id" => $user_id
|
||||||
|
]);
|
||||||
|
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate OTP
|
* Validate OTP
|
||||||
@@ -24,7 +30,7 @@
|
|||||||
return str_pad(strval($otp), $length, '0', STR_PAD_LEFT);
|
return str_pad(strval($otp), $length, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$otp = generateOTP($password);
|
$otp = generateOTP($temp["password"]);
|
||||||
|
|
||||||
// time diff between $_SESSION["otpTime"] and now() in minutes
|
// time diff between $_SESSION["otpTime"] and now() in minutes
|
||||||
$otp_time = isset($_SESSION['otpTime']) ? (int)$_SESSION['otpTime'] : 0;
|
$otp_time = isset($_SESSION['otpTime']) ? (int)$_SESSION['otpTime'] : 0;
|
||||||
@@ -44,55 +50,20 @@
|
|||||||
exit(json_encode($answer));
|
exit(json_encode($answer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// get password
|
session_regenerate_id(true); // ← fixes session fixation
|
||||||
$sth = $pdo1->prepare("select * from user where user_id = {$user_id} limit 1;");
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); // ← CSRF token
|
||||||
$sth->execute();
|
|
||||||
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
if( strtolower($data["username"]) == "support" ){
|
/**
|
||||||
if( $data["password"] == strtolower(substr(md5("trcloud".date("Ymd")),0,4)) ){
|
* Create login session
|
||||||
$support = true;
|
|
||||||
}else{
|
|
||||||
$support = false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$support = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* validate password
|
|
||||||
*/
|
*/
|
||||||
if((($password == $temp["password"]||$salt_password == $temp["password"]) && strtolower($data["username"]) != "support") || $support == true ){
|
$_SESSION["login_status"] = 1;
|
||||||
|
$_SESSION["login_username"] = $temp["username"];
|
||||||
|
$_SESSION["login_name"] = $temp["name"];
|
||||||
|
$_SESSION["login_surname"] = $temp["surname"];
|
||||||
|
$_SESSION["login_company_id"] = $temp["default_company"];
|
||||||
|
|
||||||
// create user session
|
$answer["success"] = 1;
|
||||||
if( strtolower($data["username"]) == "support" ){
|
$answer["message"] = "Login Complete!";
|
||||||
$s = $pdo1->query("select *, 'info@trcloud.co' as email from user where username='support' limit 1;");
|
|
||||||
$temp = $s->fetch(PDO::FETCH_ASSOC);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create login session
|
|
||||||
*/
|
|
||||||
$_SESSION["login_status"] = 1;
|
|
||||||
$_SESSION["login_username"] = $temp["username"];
|
|
||||||
$_SESSION["login_name"] = $temp["name"];
|
|
||||||
$_SESSION["login_surname"] = $temp["surname"];
|
|
||||||
$_SESSION["login_company_id"] = $temp["default_company"];
|
|
||||||
|
|
||||||
$answer["success"] = 1;
|
|
||||||
$answer["message"] = "Login Complete!";
|
|
||||||
exit(json_encode($answer));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$answer["message"] = "Incorrect Password";
|
|
||||||
setcookie("u", "", time()-1, "/");
|
|
||||||
setcookie("h1", "", time()-1, "/");
|
|
||||||
setcookie("h2", "", time()-1, "/");
|
|
||||||
exit(json_encode($answer));
|
|
||||||
}
|
|
||||||
|
|
||||||
$answer["success"] = 1;
|
|
||||||
exit(json_encode($answer));
|
exit(json_encode($answer));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
require '../../../config.php';
|
||||||
require '../../../preset.php';
|
require '../../../preset.php';
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
@@ -10,27 +11,15 @@
|
|||||||
$user_id = $sth->fetchColumn();
|
$user_id = $sth->fetchColumn();
|
||||||
|
|
||||||
$username = strtolower($data["username"]);
|
$username = strtolower($data["username"]);
|
||||||
$password = md5(trim(strtolower($data["password"])));
|
|
||||||
$salt_password = md5($user_id."_".trim(strtolower($data["password"])));
|
|
||||||
// get password
|
// get password
|
||||||
$sth = $pdo1->prepare("select password from user where username = ? or email = ? limit 1;");
|
$sth = $pdo1->prepare("select password from user where username = ? or email = ? limit 1;");
|
||||||
$sth->execute(array($username,$username));
|
$sth->execute(array($username,$username));
|
||||||
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if( strtolower($data["username"]) == "support" ){
|
|
||||||
if( $data["password"] == strtolower(substr(md5("trcloud".date("Ymd")),0,4)) ){
|
|
||||||
$support = true;
|
|
||||||
}else{
|
|
||||||
$support = false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$support = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* validate password
|
* validate password
|
||||||
*/
|
*/
|
||||||
if((($password == $temp["password"]||$salt_password == $temp["password"]) && strtolower($data["username"]) != "support") || $support == true ){
|
if(password_verify(trim($data["password"]), $temp["password"])) {
|
||||||
|
|
||||||
// create user session
|
// create user session
|
||||||
if( strtolower($data["username"]) == "support" ){
|
if( strtolower($data["username"]) == "support" ){
|
||||||
@@ -150,7 +139,7 @@
|
|||||||
return str_pad($result, 6, 'A', STR_PAD_LEFT);
|
return str_pad($result, 6, 'A', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$otp = generateOTP($password);
|
$otp = generateOTP($temp["password"]);
|
||||||
|
|
||||||
$reference_number = numberToLetters(generateOTP($otp));
|
$reference_number = numberToLetters(generateOTP($otp));
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
require '../../../config.php';
|
||||||
require '../../../preset.php';
|
require '../../../preset.php';
|
||||||
require '../../../assets/utils/db_auth.php';
|
require '../../../assets/utils/db_auth.php';
|
||||||
|
|
||||||
$data["username"] = $_SESSION["login_data"]['username'];
|
$data["username"] = $_SESSION["login_data"]['username'];
|
||||||
$data["password"] = $_SESSION["login_data"]['password'];
|
$data["password"] = $_SESSION["login_data"]['password'];
|
||||||
$user_id = (int)$_SESSION["login_user_id"];
|
$user_id = (int)$_SESSION["login_user_id"];
|
||||||
$password = md5(trim(strtolower($data["password"])));
|
|
||||||
$salt_password = md5($user_id."_".trim(strtolower($data["password"])));
|
|
||||||
|
|
||||||
// get password
|
// get password
|
||||||
$sth = $pdo1->prepare("select * from user where user_id = {$user_id} limit 1;");
|
$sth = $pdo1->prepare("select * from user where user_id = :user_id limit 1;");
|
||||||
$sth->execute();
|
$sth->execute([
|
||||||
|
":user_id" => $user_id
|
||||||
|
]);
|
||||||
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// user email
|
// user email
|
||||||
$user_email = $temp["email"];
|
$user_email = $temp["email"];
|
||||||
|
|
||||||
if( strtolower($data["username"]) == "support" ){
|
/**
|
||||||
if( $data["password"] == strtolower(substr(md5("trcloud".date("Ymd")),0,4)) ){
|
|
||||||
$support = true;
|
|
||||||
}else{
|
|
||||||
$support = false;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$support = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* validate password
|
* validate password
|
||||||
*/
|
*/
|
||||||
if((($password == $temp["password"]||$salt_password == $temp["password"]) && strtolower($data["username"]) != "support") || $support == true ){
|
if(password_verify(trim($data["password"]), $temp["password"])) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate OTP
|
* Generate OTP
|
||||||
@@ -63,7 +54,7 @@
|
|||||||
return str_pad($result, 6, 'A', STR_PAD_LEFT);
|
return str_pad($result, 6, 'A', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$otp = generateOTP($password);
|
$otp = generateOTP($temp["password"]);
|
||||||
|
|
||||||
$reference_number = numberToLetters(generateOTP($otp));
|
$reference_number = numberToLetters(generateOTP($otp));
|
||||||
|
|
||||||
|
|||||||
+1
-14
@@ -3,20 +3,7 @@
|
|||||||
//<><><><><><><><> MAIN TRCLOUD <><><><><><><><>//
|
//<><><><><><><><> MAIN TRCLOUD <><><><><><><><>//
|
||||||
if(true){
|
if(true){
|
||||||
$expire = "2027-01-01";
|
$expire = "2027-01-01";
|
||||||
// unique key
|
|
||||||
$pinkey = "wms";
|
|
||||||
/**
|
|
||||||
* default smtp server
|
|
||||||
*/
|
|
||||||
$SMTP = [];
|
|
||||||
$SMTP['server'] = "smtp.gmail.com";
|
|
||||||
$SMTP['username'] = "thanakorn.inbox@gmail.com";
|
|
||||||
$SMTP['port'] = "587";
|
|
||||||
$SMTP['password'] = "duuo vnad rdax hgpt";
|
|
||||||
// password encoding
|
|
||||||
$method = "AES-256-CBC";
|
|
||||||
$iv = "1234567890123456"; // Must be exactly 16 bytes
|
|
||||||
$SMTP['password'] = openssl_encrypt($SMTP['password'], $method, $pinkey, 0, $iv);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user