Beispiel #1
0
	$value = array(array("order_id"=>$order_id,"information"=>$information,"stamp"=>$stamp,"time"=>$time));
	if(SaeMemcacheSet($key,$value)===false){
		MyError("Memcache写入失败");
	}
}
else{
	$value[] = array("order_id"=>$order_id,"information"=>$information,"stamp"=>$stamp,"time"=>$time);
	if(SaeMemcacheSet($key,$value)===false){
		MyError("Memcache写入失败");
	}
}
*/
//写法2:
$value = array(array("order_id" => $order_id, "information" => $information, "stamp" => $stamp, "time" => $time));
if (SaeMemcacheAdd($key, $value) === false) {
    $value = array("order_id" => $order_id, "information" => $information, "stamp" => $stamp, "time" => $time);
    if (SaeMemcacheAppendArray($key, $value) === false) {
        MyError("Memcache写入失败");
    }
}
$login_stamp = time();
$login_time = "'" . date("Y-m-d H:i:s", $login_stamp) . "'";
if (SaeMySQLConnect() === false) {
    MyError("数据库连接失败");
}
$SQL = "UPDATE `user_info`\nSET `user_info`.`last_login_time` = {$login_time}, `user_info`.`last_login_stamp` = {$login_stamp}\nWHERE `user_info`.`id` = {$user_id}\n";
if (SaeMySQLTryUpdate($SQL) === false) {
    MyError("数据库更新失败");
}
SaeMySQLDisconnect();
MySuccess("信息发送完成");
Beispiel #2
0
include '../SAE/SaeMySQL.php';
include '../SAE/SaeMemcache.php';
include '../My.php';
header('Content-Type:text/html;charset=utf-8');
if (MySetParameterInteger("user_id") === false) {
    MyException("缺少user_id参数");
}
$key = 'pc_to_phone【' . $user_id . '】';
$wait = 100 * 1000;
for ($i = 0; $i < 300; $i++) {
    $value = SaeMemcacheRead($key);
    if ($value !== false) {
        break;
    }
    usleep($wait);
}
if ($value === false) {
    MySuccess($value, '没有任何信息');
} else {
    if (SaeMemcacheDelete($key) === false) {
        MyError("Memcache删除失败");
    }
    $checked_value = array();
    $login_stamp = time() - 60 * 5;
    foreach ($value as $v) {
        if ($v['stamp'] > $login_stamp) {
            $checked_value[] = $v;
        }
    }
    MySuccess($checked_value, '信息收取完成');
}
Beispiel #3
0
function ExceptionHandler($exception)
{
    //var_dump($exception);
    //echo "code:";var_dump($exception->getCode());
    //echo "message:";var_dump($exception->getMessage());
    //echo "file:";var_dump($exception->getFile());
    //echo "line:";var_dump($exception->getLine());
    //echo "trace:";var_dump($exception->getTrace());
    MyError('全局异常捕捉', $exception->getFile() . "[行号" . $exception->getLine() . "]" . $exception->getMessage());
    //示例:
    //(手动创建异常)throw new Exception('Uncaught Exception');
    //注意:
    //在这个异常处理程序被调用后,脚本会停止执行
}
Beispiel #4
0
include 'MyPHP/My.php';
include 'MyPHP/MySQLi.php';
//参数
$user_id = MySessionGet('user_id');
if ($user_id === false) {
    MySuccess(1, '用户未登录');
}
if (MySetParameterInteger("group_id") === false) {
    MyException("缺少group_id参数或group_id不是整数");
}
if (MySetParameter("path") === false) {
    $path = '';
    //MyException("缺少path参数");
}
//权限验证
if (MySQLConnect() === false) {
    MyError('数据库连接错误');
}
$authority = MySQLSelectCell("SELECT `authority` FROM `user_group_info` WHERE `user_id` = {$user_id} and `group_id` = {$group_id}");
MySQLDisconnect();
if ((int) $authority < 2048) {
    MySuccess(2, '用户权限不足');
}
//文件保存
if (!isset($_FILES) || !isset($_FILES["file"])) {
    MyException("缺少file文件参数");
}
if (move_uploaded_file($_FILES["file"]["tmp_name"], ".../CloudDisk/{$group_id}/" . $path . $_FILES["file"]["name"]) === false) {
    MyError('文件移动失败');
}
MySuccess("http://115.159.106.238/CloudDisk/{$group_id}/" . $_FILES["file"]["name"], '文件上传成功');
Beispiel #5
0
<?php 
//示例(用户注册)
include '../SAE/SaeMySQL.php';
include '../My.php';
header('Content-Type:text/html;charset=utf-8');
if (MySetParameter("username") === false) {
    MyException("缺少username参数");
}
if (MySetParameter("password") === false) {
    MyException("缺少password参数");
}
$register_stamp = time();
$register_time = "'" . date("Y-m-d H:i:s", $register_stamp) . "'";
if (SaeMySQLConnect() === false) {
    MyError("数据库连接失败");
}
$username = SaeMySQLCheck($username);
$password = SaeMySQLCheck($password);
$SQL = "INSERT INTO `user_info` (`name`, `password`, `register_time`, `last_login_time`, `last_login_stamp`)\nVALUES ({$username} , {$password}, {$register_time}, {$register_time}, {$register_stamp})\n";
$Result = SaeMySQLInsert($SQL);
if ($Result === false) {
    MySuccess("0", "账号已存在");
}
SaeMySQLDisconnect();
MySuccess($Result, "注册成功");
Beispiel #6
0
if (MySetParameterInteger("user_id") === false) {
    MyException("缺少user_id参数");
}
$stamp = time();
$time = date("Y-m-d H:i:s", $stamp);
$key = 'pc_to_phone【' . $user_id . '】';
//写法1:
/*
$value = SaeMemcacheRead($key);
if($value===false){
	$value = array(array("order_id"=>$order_id,"information"=>$information,"stamp"=>$stamp,"time"=>$time));
	if(SaeMemcacheSet($key,$value)===false){
		MyError("Memcache写入失败");
	}
}
else{
	$value[] = array("order_id"=>$order_id,"information"=>$information,"stamp"=>$stamp,"time"=>$time);
	if(SaeMemcacheSet($key,$value)===false){
		MyError("Memcache写入失败");
	}
}
*/
//写法2:
$value = array(array("order_id" => $order_id, "information" => $information, "stamp" => $stamp, "time" => $time));
if (SaeMemcacheAdd($key, $value) === false) {
    $value = array("order_id" => $order_id, "information" => $information, "stamp" => $stamp, "time" => $time);
    if (SaeMemcacheAppendArray($key, $value) === false) {
        MyError("Memcache写入失败");
    }
}
MySuccess("信息发送完成");
Beispiel #7
0
include 'MyPHP/My.php';
include 'MyPHP/MySQLi.php';
//参数
$user_id = MySessionGet('user_id');
if ($user_id === false) {
    MySuccess(1, '用户未登录');
}
if (MySetParameterInteger("group_id") === false) {
    MyException("缺少group_id参数或group_id不是整数");
}
if (MySetParameter("path") === false) {
    $path = '';
    //MyException("缺少path参数");
}
if (MySetParameter("file") === false) {
    MyException("缺少file参数");
}
//权限验证
if (MySQLConnect() === false) {
    MyError('数据库连接错误');
}
$authority = MySQLSelectCell("SELECT `authority` FROM `user_group_info` WHERE `user_id` = {$user_id} and `group_id` = {$group_id}");
MySQLDisconnect();
if ((int) $authority < 2048) {
    MySuccess(2, '用户权限不足');
}
//文件删除
if (@unlink(".../CloudDisk/{$group_id}/" . $path . $file) === false) {
    MyError('文件删除失败');
}
MySuccess(0, '文件删除成功');
Beispiel #8
0
    MyError('数据库连接错误');
}
$authority = MySQLSelectCell("SELECT `authority` FROM `user_group_info` WHERE `user_id` = {$user_id} and `group_id` = {$group_id}");
MySQLDisconnect();
if ((int) $authority < 2048) {
    MySuccess(2, '用户权限不足');
}
//文件列表
$handle = @opendir($path);
if ($handle === false) {
    MyError('文件夹打开错误');
}
$list = array();
while (($file = readdir($handle)) !== false) {
    if ($file !== '.' && $file !== '..') {
        $stat = @stat($file);
        if ($stat === false) {
            MyError('文件信息获取失败');
        }
        //var_dump($stat);
        $list[] = array('name' => $file, 'size' => $stat['size'], 'time' => date("Y-m-d H:i:s", $stat['mtime']));
        if (strpos($file, '.') !== false) {
            $list['type'] = 'file';
        } else {
            $list['type'] = 'path';
        }
    }
}
closedir($handle);
return $list;
MySuccess($list, '获取文件列表成功');