if (CHECK_ADMIN_PERMISSION) { $result = checkAdminPermisson(); if (!$result) { operation_fail("你没有管理员权限"); } } if (GIANT_LOCK) { giant_lock(); } $__script_start_time = microtime(true); if (CHECK_IMEI) { $ban_imeis = apcfetch("BAN_IMEIS"); if (!$ban_imeis) { $ban_imeis = array(); $data = db_fetch_all("select imei from ban_phone"); foreach ($data as $e) { $imei = $e["imei"]; $ban_imeis[$imei] = 1; } } $_imei = imei(); $_ip = getIp(); if (isset($ban_imeis[$_imei]) || isset($ban_imeis[$_ip])) { operation_fail("hello" . $_imei . language_message("ban_imei")); } } if (FORBID_VIRTUAL_MACHINE) { if (!isset($iamgod) && $_imei == "000000000000000") { operation_fail(language_message("forbid_virtual_machine")); } }
function db_execute($sql) { $_lock_fp = fopen("/tmp/task_db_lock", "w+"); flock($_lock_fp, LOCK_EX); try { require_once 'connectdb.php'; if (SQL_PROFILE_ENABLE) { profile_sql_start($sql); } $r = mysql_query($sql); if (SQL_PROFILE_ENABLE) { profile_sql_end(); } if (!$r) { operation_fail($sql); throw new DBQueryError($sql); } fclose($_lock_fp); return $r; } catch (Exception $ex) { fclose($_lock_fp); throw $ex; } }
<?php require_once '../common/__html__.php'; require_once '../common/common.php'; require_once '../common/page.php'; //url $code = param("code"); if ($code == null) { operation_fail("登陆失败"); } $weixinAPI = new WeixinAPI(); $json = $weixinAPI->getOpenid($code); session_start(); // 记录用户信息 $_SESSION['openid'] = $json['openid']; $_SESSION['access_token'] = $json; $openid = $json['openid']; $home_url = '../index.php'; $account = Account::getAccount($json['openid']); if ($account != null) { $_SESSION['account'] = $account; $extra = AccountExtra::getInfo($json['openid']); if ($extra != null) { $_SESSION['account_extra'] = $extra; } } else { $weixinAPI = new WeixinAPI(); $userInfo = $weixinAPI->getUserInfo($json['access_token'], $openid); Account::createAccount($openid, $userInfo['nickname']); $account = Account::getAccount($json['openid']); $_SESSION['account'] = $account;
} $now = date("Y-m-d H:i:s", time()); //date_default_timezone_set('PRC'); if ($endTime != null && strtotime($now) > strtotime($endTime)) { operation_fail("任务的送达时间" . $endTime . "不能小于当前时间" . $now); } else { if ($endTime == null) { $endTime = $now; } } //if ($verifyCode == null) { // operation_fail("验证码不能为空"); //} //$r = VerifyCodeModel::getCodeByPhone($phone); //if ($r == null || $r['status'] != 0 || strtotime($r['time']) + VERIFY_CODE_VALID_TIME*60 < time() || $verifyCode != $r['code']) { // operation_fail('验证码不正确或者已失效'); //} if ($reward < 0) { operation_fail('任务奖励不能为负数'); } // 转成分 $reward = intval(100 * $reward); //$r = TaskModel::publishTask($openId, $phone, $title, $desc, $reward, $now, $endTime, $address, $fromAddress, $lng, $lat); $r = TaskModel::publishTask($publisher, $openId, $phone, $title, $desc, $reward, $now, $endTime, $address, '', $lng, $lat); //VerifyCodeModel::deleteVerifyCode($phone); if ($r) { json_put("result", $r); } else { json_put("result", '发布任务失败'); } json_output();
<?php require_once '../common/common.php'; $lng = param('lng'); // 传入用户的经度 $lat = param('lat'); // 纬度 if ($lng == null || $lat == null) { operation_fail("经纬度错误"); } $distance = param("distance", 50); $page = param("page", 1); $tasks = TaskModel::getValidTasks($lng, $lat, $distance, $page); $tasksTotalCount = TaskModel::getValidTasksCount(); json_put("tasks", $tasks); json_put("total", $tasksTotalCount); json_output(); ?>
//$card_pic = param("cardPic"); $inviter = param('inviter'); $accountExtra = AccountExtra::getInfo($openid); if ($accountExtra == null) { $r = AccountExtra::applyDelivery($openid, $icon, $address, $fullname, $idcard, $contact, $contact_phone, $card_pic, $inviter); if ($r) { $extra = AccountExtra::getInfo($openid); if ($extra != null) { $_SESSION['account_extra'] = $extra; } json_put("result", $r); json_output(); } else { operation_fail("申请失败,请重试"); } } else { if ($accountExtra['status'] == AccountExtra::STATUS_APPLYING) { operation_fail("你的快递资格已在申请中,请耐心等待审核"); } else { if ($accountExtra['status'] == AccountExtra::STATUS_ACCEPT) { operation_fail("你已经有快递资格了"); } } $r = AccountExtra::updateDelivery($openid, $icon, $address, $fullname, $idcard, $contact, $contact_phone, $card_pic, $inviter); if ($r) { json_put("result", "申请成功"); json_output(); } else { operation_fail("申请失败,请重试"); } }
} $account = Account::getAccount($openId); if ($account["user_scheme"] != 1) { operation_fail("请先去认证快递资格,然后才能接单"); } $accountExtra = AccountExtra::getInfo($openId); $acceptPhone = $accountExtra["contact_phone"]; $task = TaskModel::getTaskById($taskId); if ($task == null) { operation_fail("任务不存在"); } if ($task['status'] != TaskModel::STATUS_PUBLISHING) { operation_fail("任务不是发布中,不能接单"); } if ($task['publisher_openid'] == $openId) { operation_fail("不能接自己发布的单"); } //if ($verifyCode == null) { // operation_fail("验证码不能为空"); //} /*$r = VerifyCodeModel::getCodeByPhone($acceptPhone); if ($r == null || $r['status'] != 0 || strtotime($r['time']) + VERIFY_CODE_VALID_TIME*60 < time() || $verifyCode != $r['code']) { operation_fail('验证码不正确或者已失效'); } VerifyCodeModel::deleteVerifyCode($acceptPhone); */ $r = TaskModel::acceptTask($taskId, $openId, $acceptPhone);
<?php require_once '../common/common.php'; $openId = $_SESSION['openid']; $taskId = param('taskId'); if ($taskId == null) { operation_fail('任务ID不能为空'); } $task = TaskModel::getTaskById($taskId); if ($task == null) { operation_fail("任务不存在"); } if ($task['publisher_openid'] != $openId) { operation_fail("只有任务发布者才能取消任务"); } if ($task['status'] != TaskModel::STATUS_PUBLISHING) { operation_fail("当前任务状态不对,不能取消"); } $r = TaskModel::closeTask($taskId, $openId); if ($r) { json_put("result", "关闭成功"); } else { json_put("result", '关闭任务失败'); } json_output(); ?>
<?php require_once '../common/common.php'; $openId = $_SESSION['openid']; $taskId = param('taskId'); if ($taskId == null) { operation_fail('任务ID不能为空'); } $task = TaskModel::getTaskById($taskId); if ($task == null) { operation_fail("任务不存在"); } if ($task['publisher_openid'] != $openId) { operation_fail("只有任务发布者才能结束任务"); } if ($task['status'] != TaskModel::STATUS_ACCEPTED) { operation_fail("当前任务状态不对,不能结束"); } $r = TaskModel::finishTask($taskId, $openId); if ($r) { json_put("result", "结束成功"); } else { json_put("result", '结束任务失败'); } json_output(); ?>
//if ($code != $_SESSION["code"]) { // operation_fail("验证码验证失败:". $_SESSION["code"]); //} $phone = param("phone"); if ($phone == null || strlen($phone) < 8) { operation_fail("手机号码不能为空或者位数不对"); } $r = VerifyCodeModel::getCodeByPhone($phone); if ($r != null) { // 如果已有验证码,并且还未超过1分钟 if ($r['status'] == 0 && strtotime($r[time]) + 60 > time()) { operation_fail("验证码请间隔1分钟再重试"); } } $code = rand(1000, 9999); $timeout = 1; //json_put("code", $code); $result = sendTemplateSMS($phone, array($code, $timeout), "1"); if ($result == FALSE) { operation_fail("发送验证码失败,请重试"); } else { $r = VerifyCodeModel::updateOrInsertVerifyCode($phone, $code); if ($r == FALSE) { operation_fail("发送验证码失败,请重试"); } } json_put("result", "验证码已下发,请查收"); json_output(); ?>
function uploadFile($fileName, $type) { $openId = $_SESSION['openid']; $filePath = $type . "_" . $openId; $imageType = array("image/gif" => "gif", "image/jpeg" => "jpg", "image/pjpeg" => "jpg"); //operation_fail($_FILES[$fileName]["type"]); if (($_FILES[$fileName]["type"] == "image/gif" || $_FILES[$fileName]["type"] == "image/jpeg" || $_FILES[$fileName]["type"] == "image/pjpeg") && $_FILES[$fileName]["size"] < 5000000) { $filePath .= "." . $imageType[$_FILES[$fileName]["type"]]; if ($_FILES[$fileName]["error"] > 0) { operation_fail($_FILES[$fileName]["error"]); } else { //echo "Upload: " . $_FILES["file"]["name"] . "<br />"; //echo "Type: " . $_FILES["file"]["type"] . "<br />"; //echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; $moveResult = move_uploaded_file($_FILES[$fileName]["tmp_name"], "../upload/" . $filePath); //echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; if (!$moveResult) { operation_fail("save file failed." . $_FILES[$fileName]["tmp_name"] . "new path:" . "../upload/" . $filePath); } return "upload/" . $filePath; } } else { operation_fail("无效的图片, 图片必须是gif、jpeg、pjpeg、大小小于5MB"); } }
<?php require_once '../common/common.php'; $openId = $_SESSION['openid']; $taskId = param('taskId'); if ($taskId == null) { operation_fail('任务ID不能为空'); } $publisher = param('user'); $phone = param('phone'); //$title = param('title'); $desc = param('desc'); $endTime = param('endTime'); $reward = param('tip'); $address = param('address'); //$fromAddress = param('fromAddress'); $lng = param('lng'); //经度 $lat = param('lat'); //续度 $reward = intval(100 * $reward); $r = TaskModel::updateTask($taskId, $publisher, $openId, $phone, $desc, $reward, $endTime, $address, $lng, $lat); if ($r) { json_put("result", $r); } else { json_put("result", '更新任务失败'); } json_output(); ?>
<?php // 获取验证码 require_once '../common/common.php'; $openid = $_SESSION['openid']; $phone = param("phone"); if ($phone == null || strlen($phone) < 8) { operation_fail("手机号码不能为空或者位数不对"); } $code = param("code"); if ($code == null || strlen($code) < 4) { operation_fail("手机号码不能为空或者位数不对"); } $r = VerifyCodeModel::getCodeByPhone($phone); if ($r == null || $code != $r["code"]) { operation_fail("验证码不对"); } Account::updatePhone($phone, $openid); VerifyCodeModel::deleteVerifyCode($phone); $account = Account::getAccount($openid); $_SESSION['account'] = $account; json_put("result", "认证成功"); json_output(); ?>