<?php /** * Created by PhpStorm. * User: john * Date: 2015/9/22 * Time: 15:05 */ include_once "utils/Tables.php"; include_once "utils/MySql.php"; define("SET_READ", "UPDATE " . TABLE_HISTORY . " SET `isRead` = '1' WHERE `id`="); if (is_array($_GET) && count($_GET) > 0) { if (isset($_GET["id"])) { $id = $_GET["id"]; } } $mysql = new MySql(); if (isset($id) && $id > 0) { $mysql->query(SET_READ . $id); echo $mysql->affectedrows(); } else { echo "参数错误"; }
include_once "utils/MySql.php"; define("REGISTER", "INSERT INTO " . TABLE_USER . " (`name`, `password`) VALUE "); define("QUERY_ALL", "SELECT `id` FROM " . TABLE_USER . " WHERE name="); if (is_array($_GET) && count($_GET) > 0) { if (isset($_GET["name"])) { $name = $_GET["name"]; } if (isset($_GET["password"])) { $password = $_GET["password"]; } } if (!isset($name)) { echo "用户名不能为空"; return; } if (!isset($password)) { echo "密码不能为空"; return; } $mysql = new MySql(); $sql = QUERY_ALL . "'" . $name . "'"; $mysql->query($sql); $result = $mysql->affectedrows(); if ($result >= 1) { echo "该用户名已被注册"; return; } $sql = REGISTER . "('" . $name . "', '" . $password . "')"; $mysql->query($sql); $result = $mysql->affectedrows(); echo $result;
mkdir($target_path); //如果不存在目录,则建立 } $img_path = $img_path . $_FILES['file']['name']; $target_path = ".." . $img_path; $target_path = iconv("UTF-8", "gb2312", $target_path); if (!move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { echo $target_path; echo "服务器保存文件失败"; } else { chmod($target_path, 511); $mysql = new MySql(); if (isset($name)) { $sql = "SELECT `id` FROM " . TABLE_LOGO . " WHERE `name`='{$name}'"; $result = $mysql->query($sql); if ($mysql->affectedrows() > 0) { $value = $mysql->fetcharray($result); $id = $value["id"]; } } if (isset($id)) { /** * 获取 */ $sql = "SELECT `moreImg` FROM " . TABLE_LOGO . " WHERE `id`=" . $id; $result = $mysql->query($sql); $value = $mysql->fetcharray($result); $moreImg = $value["moreImg"]; if ($moreImg) { $moreImg = $moreImg . "," . $img_path; } else {
define("QUERY_USER", "SELECT * FROM " . TABLE_USER . " WHERE name="); if (is_array($_GET) && count($_GET) > 0) { if (isset($_GET["name"])) { $name = $_GET["name"]; } if (isset($_GET["password"])) { $password = $_GET["password"]; } } if (!isset($name)) { echo "用户名不能为空"; return; } if (!isset($password)) { echo "密码不能为空"; return; } $mysql = new MySql(); $sql = QUERY_USER . "'" . $name . "'"; $result = $mysql->query($sql); $value = $mysql->fetcharray($result); $user = User::getUser($value); if ($mysql->affectedrows() <= 0) { echo "该用户名不存在"; return; } if ($user->password != $password) { echo "密码错误"; return; } echo "";
if ($file) { $logoName = fgets($file); if ($logoName) { $logoName = trim(substr($logoName, 2)); //根据logoName获取logoId $sql = "select * from " . TABLE_LOGO . " where `img`='{$logoName}' OR `moreImg` LIKE '{$logoName}'"; $result = $mysql->query($sql); $value = $mysql->fetcharray($result); $logo = Logo::getLogo($value); } else { $logo = new Logo(-1, null, null, null, null, null); } if ($logo) { $sql = "UPDATE `" . TABLE_HISTORY . "` SET `logoId`={$logo->id},`isProcessing`=0 WHERE `id`={$history->id}"; $mysql->query($sql); $affetctRows = $mysql->affectedrows(); if ($affetctRows > 0) { $history->logoId = $logo->id; $history->processing = 0; } } } fclose($file); /** * 删除文件 */ chmod($filePath, 511); // unlink($filePath); } } if ($history->logoId) {