本文整理汇总了PHP中sqlexec函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlexec函数的具体用法?PHP sqlexec怎么用?PHP sqlexec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlexec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: usepin
function usepin()
{
global $PIN_EXPIRE_TIME;
if (!isset($_COOKIE["username"]) || !isset($_COOKIE["device"])) {
return False;
}
$user = $_COOKIE["username"];
$device = $_COOKIE["device"];
if ($user == "" || $device == "") {
return False;
}
$link = sqllink();
if (!$link) {
return False;
}
$sql = "SELECT id FROM `pwdusrrecord` WHERE `username`= ?";
$res = sqlexec($sql, array($user), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
return False;
}
$id = $record['id'];
$sql = "DELETE FROM `pin` WHERE `errortimes` >= 3 OR UNIX_TIMESTAMP( NOW( ) ) - UNIX_TIMESTAMP(`createtime`) > ?";
$res = sqlexec($sql, array($PIN_EXPIRE_TIME), $link);
$sql = "SELECT * FROM `pin` WHERE `userid`= ? AND `device`= ?";
$res = sqlexec($sql, array($id, $device), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
return False;
}
return True;
}
示例2: checksession
function checksession($link)
{
global $SERVER_TIMEOUT;
session_start();
if (!isset($_SESSION['loginok']) || $_SESSION['loginok'] != 1) {
session_destroy();
return FALSE;
}
if (!$link || !isset($_SESSION['create_time']) || $_SESSION['create_time'] + $SERVER_TIMEOUT < time()) {
session_destroy();
return FALSE;
}
$usr = $_SESSION['user'];
$pw = $_SESSION['pwd'];
$id = $_SESSION['userid'];
if ($usr == '' || $pw == '' || $id == '') {
session_destroy();
return FALSE;
}
$sql = "SELECT * FROM `pwdusrrecord` WHERE `username`= ? AND `password`= ? AND `id`= ?";
$res = sqlexec($sql, array($usr, $pw, $id), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
session_destroy();
return FALSE;
}
$_SESSION['create_time'] = time();
setcookie("ServerRenew", "1");
return TRUE;
}
示例3: viewrecord
function viewrecord($pagename)
{
$reIP = $_SERVER["REMOTE_ADDR"];
$updatetime = date('Y-m-d H:i:s');
$sql = "insert into t_viewrecord(ip,updatetime,viewpage) values('" . $reIP . "','" . $updatetime . "','" . $pagename . "')";
sqlexec($sql);
}
示例4: loghistory
function loghistory($link, $userid, $ip, $ua, $outcome)
{
$sql = "SELECT max(`id`) AS `m` FROM `history`";
$res = sqlquery($sql, $link);
$r = $res->fetch(PDO::FETCH_ASSOC);
$i = $r == FALSE ? 0 : (int) $r['m'] + 1;
$sql = "INSERT INTO `history` VALUES (?,?,?,?,?,CURRENT_TIMESTAMP)";
$res = sqlexec($sql, array($i, $userid, $ip, $ua, $outcome), $link);
}
示例5: delete_old_process
function delete_old_process($link)
{
$ret = sqlquery('SELECT * FROM `process` where 1', $link);
while ($i = $ret->fetch(PDO::FETCH_ASSOC)) {
if (!pstatus($i['pid'])) {
sqlexec('DELETE FROM `process` where pid=?', array($i['pid']), $link);
deldir('qqbot/' . $i['id']);
}
}
}
示例6: deleteexpire
function deleteexpire($link)
{
$e = date('Y-m-d');
$sql = "SELECT COUNT(`id`) FROM `talkrecord` WHERE ? >= `expire`";
$res = sqlexec($sql, array($e), $link);
$num = $res->fetch(PDO::FETCH_NUM);
$num = $num[0];
$sql = "DELETE FROM `talkrecord` WHERE ? >= `expire`";
$res = sqlexec($sql, array($e), $link);
return $num;
}
示例7: pstatus
<?php
function pstatus($pid)
{
$command = 'ps -p ' . $pid;
exec($command, $op);
if (!isset($op[1])) {
return false;
} else {
return true;
}
}
require_once 'function/sqllink.php';
if (!isset($_POST['id'])) {
die('{"retcode":999,"msg":"CAN NOT FIND ID IN THE PARAMETER"}');
}
$link = sqllink();
if (!$link) {
die('{"retcode":99,"msg":"DATABASE ERROR"}');
}
$res = sqlexec('SELECT * FROM `process` where `sid`=?', array($_POST['id']), $link);
$result = $res->fetch(PDO::FETCH_ASSOC);
if ($result == FALSE) {
die('{"retcode":0,"msg":"SUCC"}');
}
//don't tell malicious person the id does not exist
if (pstatus($result['pid'])) {
shell_exec("kill " . $result['pid']);
}
die('{"retcode":0,"msg":"SUCC"}');
示例8: session_start
<?php
require_once "function/encryption.php";
require_once "function/sqllink.php";
session_start();
$usr = $_POST['user'];
$pw = $_POST['pwd'];
if ($pw == "" || $usr == "") {
die("0");
}
$link = sqllink();
if (!$link) {
die('4');
}
$sql = "SELECT * FROM `pwdusrrecord` WHERE `username`= ?";
$res = sqlexec($sql, array($usr), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
die('0');
}
if (strcmp(decrypt($record["password"], $GLOBAL_SALT_3), $pw) != 0) {
die("1");
}
$_SESSION['loginok'] = 1;
$_SESSION['user'] = $usr;
$_SESSION['userid'] = $record['id'];
$_SESSION['pwd'] = $record['password'];
echo "9";
示例9: random_str
function random_str($length)
{
$arr = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
$str = '';
$arr_len = count($arr);
for ($i = 0; $i < $length; $i++) {
$rand = mt_rand(0, $arr_len - 1);
$str .= $arr[$rand];
}
return $str;
}
require_once "function/sqllink.php";
require_once "function/encryption.php";
$link = sqllink();
if (!checksession($link)) {
die("0");
}
$id = $_SESSION['userid'];
$usr = $_SESSION['user'];
$username = $_POST['user'];
$device = $_POST['device'];
$sig = $_POST['sig'];
if ($username != $usr) {
die('0');
}
$sql = "DELETE FROM `pin` WHERE `userid`= ? AND `device`= ?";
$res = sqlexec($sql, array($id, $device), $link);
$pinpk = random_str(29);
$sql = "INSERT INTO `pin` (`userid`,`device`,`pinsig`,`pinpk`,`ua`) VALUES (?,?,?,?,?)";
$res = sqlexec($sql, array($id, $device, $sig, $pinpk, $_SERVER['HTTP_USER_AGENT']), $link);
echo $pinpk;
示例10: die
die('0');
}
$sql = "SELECT * FROM `password` WHERE `userid`= ? AND `index`= ? ";
$res = sqlexec($sql, array($id, (int) $index), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
$link->commit();
die("0");
}
$ppwd = $_POST['newpwd'];
$pubkey = mt_rand(10000000, 99999999);
$newpw = encrypt($ppwd, $pubkey);
$changedCols = "`key` = ? ,`pwd` = ?";
$values = array($pubkey, $newpw);
if (isset($_POST["name"])) {
$changedCols .= " ,`name` = ?";
array_push($values, $_POST["name"]);
}
if (isset($_POST["other"])) {
$changedCols .= " ,`other` = ?";
array_push($values, $_POST["other"]);
}
array_push($values, $id, (int) $index);
$sql = "UPDATE `password` SET " . $changedCols . " WHERE `userid` = ? AND `index`= ?";
$res = sqlexec($sql, $values, $link);
if ($res == NULL) {
$link->rollBack();
die("0");
}
$link->commit();
echo "1";
示例11: die
die(0);
}
$user = $_POST['user'];
$device = $_POST['device'];
if ($user == "" || $device == "") {
die("0");
}
$sql = "SELECT `id` FROM `pwdusrrecord` WHERE `username`= ?";
$res = sqlexec($sql, array($user), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
die("0");
}
$id = $record['id'];
$sql = "DELETE FROM `pin` WHERE `errortimes` >= 3 OR UNIX_TIMESTAMP( NOW( ) ) - UNIX_TIMESTAMP(`createtime`) > ?";
$res = sqlexec($sql, array($PIN_EXPIRE_TIME), $link);
$sql = "SELECT `pinsig`,`pinpk` FROM `pin` WHERE `userid`= ? AND `device`=?";
$res = sqlexec($sql, array($id, $device), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
die("0");
}
$sig = $record['pinsig'];
if (strcmp(hash('sha512', (string) $sig . (string) $_SESSION['random_login_stamp']), (string) $_POST['sig']) == 0) {
$sql = "UPDATE `pin` SET `errortimes`=0 WHERE `userid`= ? AND `device`=?";
$res = sqlexec($sql, array($id, $device), $link);
die($record['pinpk']);
}
$sql = "UPDATE `pin` SET `errortimes`=`errortimes`+1 WHERE `userid`= ? AND `device`=?";
$res = sqlexec($sql, array($id, $device), $link);
die('1');
示例12: sqllink
$link = sqllink();
if (checksession($link) == FALSE) {
die('0');
}
$id = $_SESSION['userid'];
$arr = array();
$sql = "SELECT * FROM `password` WHERE `userid`= ?";
$res = sqlexec($sql, array($id), $link);
while ($i = $res->fetch(PDO::FETCH_ASSOC)) {
$index = $i['index'];
$name = $i['name'];
$other = $i['other'];
$kss = decrypt($i['pwd'], $i['key']);
$arr[(int) $index] = array($name, $kss, $other);
}
$farray = array('status' => 'NO', 'random' => mt_rand(10000, 50000));
if ($_POST['a'] == 'farray') {
$tmparr = array();
$sql = "select * from `files` WHERE `userid`=?";
$res = sqlexec($sql, array($id), $link);
while ($i = $res->fetch(PDO::FETCH_ASSOC)) {
$index = $i['index'];
$fname = $i['fname'];
$key = $i['key'];
$files = $i['files'];
$tmparr[(int) $index] = array($fname, $key, $files);
}
$farray = array('status' => 'OK', 'data' => $tmparr);
}
$ret = array('status' => 'OK', 'VERSION' => $VERSION, 'JSsalt' => $GLOBAL_SALT_1, 'PWsalt' => $GLOBAL_SALT_2, 'ALPHABET' => $DEFAULT_LETTER_USED, 'data' => $arr, 'fdata' => $farray);
echo json_encode($ret);
示例13: sqlexec
}
$sql = "SELECT * FROM `pwdusrrecord` WHERE `username`= ? AND `password`= ? AND `id`= ?";
$res = sqlexec($sql, array($usr, $pw, $id), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
session_destroy();
die("0");
}
$ppwd = $_POST['newpwd'];
$pubkey = mt_rand(10000000, 99999999);
$newpw = encrypt($ppwd, $pubkey);
$name = $_POST['name'];
if (!$link->beginTransaction()) {
die('0');
}
$sql = "SELECT max(`index`) FROM `password` WHERE `userid`= ?";
$res = sqlexec($sql, array($id), $link);
$record = $res->fetch(PDO::FETCH_NUM);
if ($record == FALSE) {
$nid = 1;
} else {
$nid = (int) $record[0] + 1;
}
$sql = "INSERT INTO `password` VALUES (?, ?, ?, ?,?)";
$res = sqlexec($sql, array($nid, $id, $name, $newpw, $pubkey), $link);
if ($record == NULL) {
$link->rollBack();
die(0);
}
$link->commit();
echo "1";
示例14: updatewxuserid
private function updatewxuserid($object, $keyword)
{
//更新wxid操作
$wxid = $object->FromUserName;
$updatetime = date('Y-m-d H:i:s');
$sqlstr = "select * from t_wxreguser where wxid='" . $wxid . "'";
if (get_mydata($sqlstr) == false) {
$sqlstr = "insert into t_wxreguser (wxid,regtime,keyword,updatetime) values ('" . $wxid . "','" . $updatetime . "','" . $keyword . "','" . $updatetime . "')";
sqlexec($sqlstr);
} else {
$sqlstr = "update t_wxreguser set keyword='" . $keyword . "',updatetime ='" . $updatetime . "' where wxid='" . $wxid . "'";
sqlexec($sqlstr);
}
return true;
}
示例15: die
die("0");
}
$sql = "SELECT * FROM `pwdusrrecord` WHERE `username`= ? AND `password`= ? AND `id`= ?";
$res = sqlexec($sql, array($usr, $pw, $id), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
session_destroy();
die("0");
}
$index = $_POST['index'];
if (!$link->beginTransaction()) {
die('0');
}
$sql = "SELECT * FROM `password` WHERE `userid`= ? AND `index`= ? ";
$res = sqlexec($sql, array($id, (int) $index), $link);
$record = $res->fetch(PDO::FETCH_ASSOC);
if ($record == FALSE) {
$link->commit();
die("0");
}
$ppwd = $_POST['newpwd'];
$pubkey = mt_rand(10000000, 99999999);
$newpw = encrypt($ppwd, $pubkey);
$sql = "UPDATE `password` SET `key` = ? ,`pwd` = ? WHERE `userid` = ? AND `index`= ?";
$res = sqlexec($sql, array($pubkey, $newpw, $id, (int) $index), $link);
if ($res == NULL) {
$link->rollBack();
die("0");
}
$link->commit();
echo "1";