function pageIdExists($page_id) { return valueExists('pages', 'id', $page_id); }
function dbUpdateActionPermit($action_id, $permits, $type) { try { global $db_table_prefix; $db = pdoConnect(); $table = ""; if ($type == "user") { $table = "user_action_permits"; } else { if ($type == "group") { $table = "group_action_permits"; } else { addAlert("danger", "Action type must be 'user' or 'group'."); return false; } } // Check that action_id exists if (!valueExists($table, "id", $action_id)) { addAlert("danger", "Invalid action_id specified."); return false; } $stmt = $db->prepare("UPDATE " . $db_table_prefix . $table . " SET permits = :permits\n WHERE \n id = :action_id\n LIMIT 1"); $sqlVars = array(":action_id" => $action_id, ":permits" => $permits); $stmt->execute($sqlVars); return true; } catch (PDOException $e) { addAlert("danger", "Oops, looks like our database encountered an error."); error_log("Error in " . $e->getFile() . " on line " . $e->getLine() . ": " . $e->getMessage()); return false; } catch (ErrorException $e) { addAlert("danger", "Oops, looks like our server might have goofed. If you're an admin, please check the PHP error logs."); return false; } }
<?php include_once 'functions.php'; include_once '../includes/configure.php'; include_once '../includes/database_tables.php'; include_once '../includes/functions/database.php'; if (!postNotEmpty('id')) { die('Product Id not given'); } $products_id = $_POST['id']; if (postOK('category')) { $category = explode('/', $_POST['category']); $option = $category[0]; $value = $category[1]; $optionId = optionExists($option); $valueId = valueExists($value); if (!$optionId) { $optionId = createOption($option); } if (!$valueId) { $valueId = createValue($value); } if (!isOptionLinkedToValue($optionId, $valueId)) { createLink($optionId, $valueId); } if (!isProductLinked($optionId, $valueId, $products_id)) { createLinkToProduct($optionId, $valueId, $products_id); } die; } tep_db_connect() or die('Unable to connect to database');