if ((DEBUG_MODE & 2) != 2) { $smarty->caching = true; } /*------------------------------------------------------ */ //-- INPUT /*------------------------------------------------------ */ $smarty->assign('shop_logo', htmlspecialchars($_CFG['shop_logo'])); $_REQUEST['id'] = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $article_id = $_REQUEST['id']; if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] < 0) { $article_id = $db->getOne("SELECT article_id FROM " . $ecs->table('article') . " WHERE cat_id = '" . intval($_REQUEST['cat_id']) . "' "); } $ip_type = $_REQUEST['ip_type']; if ($ip_type == "1") { $ip = $_REQUEST['ip']; insertInto($ip); } /*------------------------------------------------------ */ //-- PROCESSOR /*------------------------------------------------------ */ $cache_id = sprintf('%X', crc32($_REQUEST['id'] . '-' . $_CFG['lang'])); if (!$smarty->is_cached('article.dwt', $cache_id)) { /* 文章详情 */ if ($_REQUEST['type'] == 'sjs') { $article = get_article_info_sjs($article_id); } else { if ($_REQUEST['type'] == 'fu') { $article = get_article_info0($article_id); } else { $article = get_article_info($article_id); }
<?php require_once '../../php/db/connection.php'; require_once '../../php/submit_helper.php'; $json_return['status'] = "NA"; $json_return['message'] = "Could not add ability."; try { // variables $table = 'ability'; $unique_id = 'name'; $original_unique_id = 'original_' . $unique_id; $exceptions = array($original_unique_id); $primary_key = array($unique_id, 'rpg'); checkDataUnique($database, $_POST, $table, $unique_id, $json_return); checkDataValid($database, $_POST, 'abilityType', 'type', $json_return); checkDataValid($database, $_POST, 'target', 'target', $json_return); if (inputExists($_POST, 'radiusType')) { checkDataValid($database, $_POST, 'radiusType', 'radiusType', $json_return); } checkInputExists($_POST, 'description', $json_return); if ($json_return['status'] === "OK") { $_POST['rpg'] = 'dales'; insertInto($table, $_POST, $exceptions, $primary_key, $database, $json_return); } } catch (PDOException $e) { $json_return['status'] = "FAILED"; $json_return['message'] = $e->getMessage(); } // send json header("Content-Type: application/json", true); echo json_encode($json_return);
function signUp($user) { $user = validateFixProfile($user); if (is_string($user)) { # error msg: invalid info return $user; } if (userExists($user["email"])) { return ACCOUNT_ALREADY_EXISTS_ERR; } $user["password"] = trim($user["password"]); $checkPassword = checkPassword($user["password"], $user["confirm_password"]); if (is_string($checkPassword)) { return $checkPassword; } $account_type = $user["account_type"]; if ($account_type !== "Tutor" && $account_type !== "Student") { return INVALID_ACCOUNT_TYPE_ERR; } $gender = $user["gender"]; if ($gender !== "Male" && $gender !== "Female") { return INVALID_GENDER_ERR; } if (is_uploaded_file($_FILES["profile_pic"]["tmp_name"]) && isValidImg("profile_pic") !== true) { return INVALID_IMG_ERR; } $user_id = insertUser($user); if (isNum($user_id)) { insertInto($account_type, $user_id); if (file_exists($_FILES["profile_pic"]["tmp_name"])) { $path = getProfilePicPath($user_id); moveFile("profile_pic", getTempPath($user_id), $path); changeProfilePic($user_id, $path); } # else { # changeProfilePic($user_id, DEFAULT_PROFILE_PIC); # } $u = getFullUserById($user_id); if (sendActivationMail($u["email"], $user_id, $u["activation_code"])) { return true; } else { return " Account successfully created but could not send you a verification email. Please request another one. "; } } else { return UNKNOWN_ERR . RETRY_MSG; } }
} else { if ($_POST['primaryType'] === 'Gear' || $_POST['primaryType'] === 'Miscellaneous' || $_POST['primaryType'] === 'Tool') { // do nothing more } else { $json_return['status'] = "FAILED"; $json_return['message'] = 'Not a recognized type.'; } } } } } } } // if everything is still ok after primaryType pass, add to item's table. if ($json_return['status'] === "OK") { $items_data['rpg'] = $_POST['rpg']; $items_data['name'] = $_POST['name']; $items_data['weight'] = $_POST['weight']; $items_data['value'] = $_POST['value']; $items_data['primaryType'] = $_POST['primaryType']; $items_data['secondaryType'] = $_POST['secondaryType']; $items_data['description'] = $_POST['description']; insertInto($table, $items_data, NULL, $primary_key, $database, $json_return); } } catch (PDOException $e) { $json_return['status'] = "FAILED"; $json_return['message'] = $e->getMessage(); } // send json header("Content-Type: application/json", true); echo json_encode($json_return);