File manager - Edit - /home/custbahd/irungikitchen.com/admin/products/edit/index.php
Back
<?php session_start(); include_once('../../db/saucerer.php'); // Define variables and initialize with empty values $id = $name = $token = $access = ""; $id_err = $name_err = $token_err = $access = ""; //IP Address Protocol $ip_address = $_SERVER["REMOTE_ADDR"]; // Check if the "mobile" word exists in User-Agent $isMob = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "mobile")); // Check if the "tablet" word exists in User-Agent $isTab = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "tablet")); // Platform check $isWin = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "windows")); $isAndroid = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "android")); $isIPhone = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "iphone")); $isIPad = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "ipad")); $isIOS = $isIPhone || $isIPad; if($isTab){ if ($isIPad) { $device = 'iPad'; } else { $device = 'Tablet'; } } elseif($isMob){ if ($isIPhone) { $device = 'iPhone'; } else { $device = 'Phone'; } } else{ $device = 'Desktop'; } if($isIOS){ $system = 'iOS'; }elseif($isAndroid){ $system = 'ANDROID'; }elseif($isWin){ $system = 'WINDOWS'; } $user = $_SESSION['name']; $token = $_SESSION['token']; $access = $_SESSION['access']; if(isset($_POST['submit'])){ //POST Details $id = $_POST['id']; $name = $_POST['name']; $cat = $_POST['cat']; $type = $_POST['type']; $price = $_POST['price']; $ingredients = $_POST['ingredients']; $recipe = $_POST['recipe']; $handler = $_POST['handler']; $author = $_POST['author']; $token = $_POST['token']; $access = $_POST['access']; $nav = $_POST['id']; $x=" "; $y="_"; $image_title = str_replace($x, $y, strtolower($name)); if ($_FILES['image']['name']=='') { $image = $_POST['image']; } else { $ext = substr($_FILES['image']['name'], strrpos($_FILES['image']['name'], '.')+1); $image = 'irungi_'.$image_title.'.'.$ext.''; if(is_file('../../images/'. $image)) unlink('../../images/'. $image); move_uploaded_file($_FILES['image']['tmp_name'],'../../images/'. $image); } //If no update $sql = mysqli_query($conn, "SELECT * FROM shop WHERE id = '$id'"); if(mysqli_num_rows($sql) > 0){ $row = mysqli_fetch_assoc($sql); } if ($name == $row['name'] & $cat == $row['cat'] & $image == $row['image'] & $type == $row['type'] & $price == $row['price'] & $ingredients == $row['ingredients'] & $recipe == $row['recipe']) { $_SESSION['success'] = 'No change detected!'; $result = "Fail"; $channel = "Hidden"; $link = "#!"; $summary = "No change detected for ".$name." by ".$user.""; } else { $sql = "UPDATE shop SET name='$name', cat='$cat', type='$type', price='$price', image='$image', ingredients='$ingredients', recipe='$recipe' WHERE id = '$id'"; //use for MySQLi OOP if($conn->query($sql)){ $_SESSION['success'] = ''.$name.' updated successfully'; $result = "Success"; $channel = "Notifications"; $link = "products"; $summary = "".$name." has been edited by ".$user.""; } else{ $_SESSION['error'] = 'Something went wrong in updating '.$name.''; $result = "Error"; $channel = "System"; $link = "#!"; $summary = "System error editing ".$name." by ".$user.""; } } $attempt = "Edit"; $action = "Edit"; $filter = "Admin"; $category = "Product"; $sql = "INSERT INTO secure (name, token, access, attempt, action, user, handler, result, filter, category, channel, summary, link, ip_address, device_name, system_name) VALUES ('$name', '$token', '$access', '$attempt', '$action', '$user', 'Admin', '$result', '$filter', '$category', '$channel', '$summary', '$link', '$ip_address', '$device', '$system')"; } header('location: ../#nav_'.$nav.''); ?>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 2.39 |
proxy
|
phpinfo
|
Settings