public function searchUser()
 {
     $token = I('token');
     if ($token) {
         $user_id = false;
         $data = M("device_token");
         $query['token'] = $token;
         $result = $data->where($query)->find();
         if (!$result) {
             // 如果不存在
             $Form = D('user');
             // 新增一个用户
             $user = array('');
             $user_id = $Form->add($user);
             if ($user_id) {
                 // 新增一个设备id
                 $token_form = D('device_token');
                 $token_info = array('user_id' => $user_id, 'token' => $token, 'addtime' => getMillisecond());
                 $token_form->add($token_info);
             }
         } else {
             $user_id = $result['user_id'];
         }
         if ($user_id) {
             // 如果该设备号已经存在
             $user_from = D('user');
             $result = $user_from->find($user_id);
             echo json_encode($result);
         }
     }
 }
Example #2
0
 public function __construct($model = '')
 {
     if ($model) {
         $this->model = $model;
     }
     $this->appKey = sha1(session('app_id') . "UZ" . session('app_key') . "UZ" . getMillisecond()) . "." . getMillisecond();
     session('appKey', $this->appKey);
 }
Example #3
0
 function saveexpect_action()
 {
     $path = "uploads_resume_file/";
     if (!empty($_FILES)) {
         //得到上传的临时文件流
         $tempFile = $_FILES['Filedata']['tmp_name'];
         //允许的文件后缀
         $fileTypes = array('doc');
         //得到文件原名
         //$fileName = iconv("UTF-8","GB2312",$_FILES["Filedata"]["name"]);
         //重命名上传文件名
         function getMillisecond()
         {
             list($t1, $t2) = explode(' ', microtime());
             return (double) sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
         }
         $uname = getMillisecond();
         $fileName = iconv("UTF-8", "GB2312", $uname . ".doc");
         $fileParts = pathinfo($_FILES['Filedata']['name']);
         //接受动态传值
         $files = $_POST['typeCode'];
         //上传文件
         move_uploaded_file($tempFile, $path . $fileName);
         $name = @explode('.', $_FILES['Filedata']['name']);
         //最后保存到mysql数据库字段
         $data = array();
         $data["picurl"] = "../uploads_resume_file/" . $fileName;
         $data['title'] = $this->stringfilter($name[0]);
         $data["ctime"] = time();
         $data['uid'] = (int) $_POST['uid'];
         $id = $this->obj->insert_into("resume_file", $data);
         if ($id) {
             echo $name[0] . "||" . $picurl . "||" . $id;
             die;
         } else {
             echo "2";
             die;
         }
     }
 }
Example #4
0
<?php

include 'file_util.php';
error_reporting(0);
date_default_timezone_set("PRC");
$token = $_POST['token'];
$folder = "images/";
$dir = date("Y/m/d/");
$extension = strtolower(substr(strrchr($_FILES["file"]["name"], '.'), 1));
$filename = date("Ymd") . getMillisecond() . rand(1000, 9999) . "." . $extension;
$allow_filetype = explode("|", "gif|jpg|png|jpeg|bmp|pjpeg|ppt|rar|zip|doc|pdf|docx|xls|xlsx|pptx|txt");
$result = "";
if ($token != "989h8u9fas8d979s8d9u9asdXXX") {
    $result = json_encode(array('code' => 9, 'message' => "Token非法!"));
    echo $result;
} elseif (!in_array($extension, $allow_filetype)) {
    $result = json_encode(array('code' => 9, 'message' => "禁止上传此类文件!"));
    echo $result;
} elseif ($_FILES["file"]["error"] > 0) {
    switch ($_FILES[$file]['error']) {
        case 1:
            // 文件大小超出了服务器的空间大小
            $result = json_encode(array('code' => 1, 'message' => "文件大小超出了服务器的空间大小"));
            break;
        case 2:
            // 要上传的文件大小超出浏览器限制
            $result = json_encode(array('code' => 2, 'message' => "要上传的文件大小超出浏览器限制"));
            break;
        case 3:
            // 文件仅部分被上传
            $result = json_encode(array('code' => 3, 'message' => "文件仅部分被上传"));
Example #5
0
<?php

include 'config.php';
include 'db.php';
include 'utils.php';
if (empty($_FILES["mypic"])) {
    exit;
}
$names = $_FILES["mypic"]["name"];
$tmp_names = $_FILES["mypic"]["tmp_name"];
for ($i = 0; $i < count($names); $i++) {
    $picname = $names[$i];
    $tmp_name = $tmp_names[$i];
    $type = strstr($picname, '.');
    $pics = getMillisecond() . $type;
    // 上传路径
    $pic_path = "upload/" . $pics;
    move_uploaded_file($tmp_name, $pic_path);
    $result = db::insert(UPLOAD_FILE_TABLE, array("name" => $picname, "localpath" => $pic_path, "type" => $type));
    var_dump($result);
}
?>
 
 public function add_resume_save()
 {
     $userinfo = $_SESSION['userinfo'];
     if (empty($userinfo)) {
         setcookie("gourl", "/index.php?s=/Job/add_resume", time() + 3600, "/");
         echo json_encode(array("code" => "400", "msg" => "未登录"));
         die;
     }
     $uid = $userinfo['userid'];
     setcookie("gourl", "", time() - 1, "/");
     foreach ($_POST as $k => $v) {
         $_POST[$k] = I("post." . $k, '', 'htmlspecialchars');
     }
     if (empty($_POST['username']) || empty($_POST['mobile']) || empty($_POST['exper']) || empty($_POST['age']) || empty($_POST['email']) || empty($_POST['qqnum']) || empty($_POST['because']) || empty($_POST['personal']) || empty($_POST['edu']) || empty($_POST['zige'])) {
         echo json_encode(array("code" => "500", "msg" => "请完善简历信息"));
         die;
     }
     if (!is_numeric($_POST['age'])) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的年龄"));
         die;
     }
     $rule = "/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+\$/";
     preg_match($rule, $_POST['email'], $result);
     if (!$result) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的邮箱"));
         die;
     }
     if (!is_numeric($_POST['qqnum'])) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的qq号码"));
         die;
     }
     $rule1 = "/^1[0-9]{10}\$/A";
     preg_match($rule1, $_POST['mobile'], $result1);
     if (!$result1) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的手机号码"));
         die;
     }
     if ($_POST['type']) {
         $data['type'] = $_POST['type'];
     } else {
         if ($_COOKIE['upload']) {
             $data['type'] = 5;
         }
     }
     $data['username'] = $_POST['username'];
     $data['sex'] = $_POST['sex'];
     $data['age'] = $_POST['age'];
     $data['state'] = $_POST['state'];
     $data['mobile'] = $_POST['mobile'];
     $data['email'] = $_POST['email'];
     $data['qqnum'] = $_POST['qqnum'];
     $data['because'] = $_POST['because'];
     $data['personal'] = $_POST['personal'];
     $data['keyword'] = $_POST['keyword'];
     $data['job_id'] = 0;
     $data['t_id'] = $uid;
     $data['keyid'] = getMillisecond();
     $data['audreason'] = 0;
     $data['posttime'] = time();
     $resumeOb = M("resume");
     $resumeOb->add($data);
     $iResumeid = $resumeOb->getLastInsID();
     //最后插入的简历id
     //echo $resumeOb -> getLastSql();
     if ($_POST['edu']) {
         $education = array();
         $education['keyid'] = $data['keyid'];
         $education['starttime'] = 0;
         $education['endtime'] = 0;
         $education['schoolname'] = 0;
         $education['profess'] = 0;
         $education['academic'] = 0;
         $education['checkinfo'] = true;
         $education['content'] = $_POST['edu'];
         M("education")->add($education);
     }
     if ($_POST['exper']) {
         $workexper = array();
         $workexper['keyid'] = $data['keyid'];
         $workexper['starttime'] = 0;
         $workexper['endtime'] = 0;
         $workexper['pname'] = 0;
         $workexper['salary'] = 0;
         $workexper['releaving'] = 0;
         $workexper['checkinfo'] = true;
         $workexper['intro'] = $_POST['exper'];
         M("workexper")->add($workexper);
     }
     if ($_POST['zige']) {
         $cercate = array();
         $cercate['keyid'] = $data['keyid'];
         $cercate['ceaname'] = 0;
         $cercate['zhengshu'] = $_POST['zige'];
         M("cercate")->add($cercate);
     }
     /*                 * **************【增加候选人】操作日志 begin************************* */
     $username = $userinfo['username'];
     $arNoticeInfo = getTNoticeInfo(0, $data['username']);
     $sLogtitle = $arNoticeInfo[0];
     $sLogContent = $arNoticeInfo[1];
     $arNotice = array("uid" => $uid, "username" => $username, "bt_id" => $iResumeid, "title" => $sLogtitle, "content" => $sLogContent, "created_at" => time(), "updated_at" => time());
     M("notice_log")->add($arNotice);
     /*                 * **************【增加候选人】操作日志 end************************* */
     if (!$_POST['type']) {
         //判断该简历有多少能匹配的职位
         $where = "title like '%" . $data['keyword'] . "%' and stj_job.employ>(select count(*) from stj_record where stj_record.j_id = stj_job.id and audstart=6) and checkinfo='true' and endtime>unix_timestamp(now()) and is_deleted=0";
         $jobCount = M("job")->where($where)->count();
         if ($jobCount > 0) {
             echo json_encode(array("code" => "300", "msg" => $jobCount . "," . $data['keyword']));
             die;
         } else {
             echo json_encode(array("code" => "200", "msg" => "增加成功"));
             die;
         }
     }
     echo json_encode(array("code" => "200", "msg" => $iResumeid));
     die;
 }
 public function add_resume_save()
 {
     $userinfo = unserialize($_COOKIE['userinfo']);
     if (empty($userinfo)) {
         setcookie("gourl", "/Home/Webchatnew/add_resume", time() + 3600, "/");
         echo json_encode(array("code" => "400", "msg" => "未登录"));
         die;
     }
     setcookie("gourl", "", time() - 1, "/");
     $uid = $userinfo['userid'];
     foreach ($_POST as $k => $v) {
         $_POST[$k] = I("post." . $k, '', 'htmlspecialchars');
     }
     if (empty($_POST['username']) || empty($_POST['mobile']) || empty($_POST['keyword']) || empty($_POST['exper']) || empty($_POST['because']) || empty($_POST['edu'])) {
         echo json_encode(array("code" => "500", "msg" => "请完善简历信息"));
         die;
     }
     $rule1 = "/^1[0-9]{10}\$/A";
     preg_match($rule1, $_POST['mobile'], $result1);
     if (!$result1) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的手机号码"));
         die;
     }
     $arAllResume = M("resume")->query("select *  from stj_resume where mobile='{$_POST['mobile']}' and isshow=1 ");
     if (!empty($arAllResume)) {
         echo json_encode("该候选人简历在系统中已存在");
         die;
     }
     $data['username'] = $_POST['username'];
     $data['sex'] = $_POST['sex'];
     $data['state'] = $_POST['state'];
     $data['mobile'] = $_POST['mobile'];
     $data['keyword'] = $_POST['keyword'];
     $data['because'] = $_POST['because'];
     $data['job_id'] = 0;
     $data['t_id'] = $uid;
     $data['keyid'] = getMillisecond();
     $data['audreason'] = 0;
     $data['posttime'] = time();
     $data['type'] = 5;
     $resumeOb = M("resume");
     $resumeOb->add($data);
     $iResumeid = $resumeOb->getLastInsID();
     //最后插入的简历id
     //echo $resumeOb -> getLastSql();
     if ($_POST['edu']) {
         $education = array();
         $education['keyid'] = $data['keyid'];
         $education['starttime'] = 0;
         $education['endtime'] = 0;
         $education['schoolname'] = 0;
         $education['profess'] = 0;
         $education['academic'] = 0;
         $education['checkinfo'] = true;
         $education['content'] = $_POST['edu'];
         M("education")->add($education);
     }
     if ($_POST['exper']) {
         $workexper = array();
         $workexper['keyid'] = $data['keyid'];
         $workexper['starttime'] = 0;
         $workexper['endtime'] = 0;
         $workexper['pname'] = 0;
         $workexper['salary'] = 0;
         $workexper['releaving'] = 0;
         $workexper['checkinfo'] = true;
         $workexper['intro'] = $_POST['exper'];
         M("workexper")->add($workexper);
     }
     /*                 * **************【增加候选人】操作日志 begin************************* */
     $username = $userinfo['username'];
     $arNoticeInfo = getTNoticeInfo(0, $data['username']);
     $sLogtitle = $arNoticeInfo[0];
     $sLogContent = $arNoticeInfo[1];
     $arNotice = array("uid" => $uid, "username" => $username, "bt_id" => $iResumeid, "title" => $sLogtitle, "content" => $sLogContent, "created_at" => time(), "updated_at" => time());
     M("notice_log")->add($arNotice);
     /*                 * **************【增加候选人】操作日志 end************************* */
     echo json_encode(array("code" => "200", "msg" => $iResumeid));
     die;
 }
Example #8
0
	}
*  必备参数:
*	$hostUrl  http://c.zhiboyun.com
*  $timestamp 当前时间戳
* $service_code 应用服务码
* $key 服务码对应的共享密钥
* $apiUrl 请求api。 "/api/20140928/task_list";
*/
//获取当前时间的毫秒值
function getMillisecond()
{
    list($s1, $s2) = explode(' ', microtime());
    return (double) sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}
//获取当前时间
$timestamp = getMillisecond();
//服务码
$service_code = "TESTING";
//服务码对应的密钥
$key = "abc";
$apiUrl = "/api/20140928/management";
$data = array("function" => "list_users", "params" => array("service_code" => "TESTING", "fields" => "id,service_code,user_name", "page_index" => 0, "per_page" => 5));
$data_string = json_encode($data);
$signatureUrl = $apiUrl . "service_code=" . $service_code . $data_string . $timestamp;
//计算签名
$xvs_signature = hash_hmac("sha256", utf8_encode($signatureUrl), utf8_encode($key));
//需要发送请求的api url
$url = "http://c.zhiboyun.com" . $apiUrl . "?service_code=" . $service_code;
//初始化curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
Example #9
0
});
$app->get('/api/menu', function () use($app) {
    try {
        $result = array();
        $result = file_get_contents("./static/config_data/menu.json");
        if (preg_match('/^\\xEF\\xBB\\xBF/', $result)) {
            $result = substr($result, 3);
        }
        echo $result;
    } catch (Exception $e) {
        $app->flash('error', $e->getMessage());
    }
});
$app->post('/api/image', function () use($app) {
    $result = "";
    $targetDir = "./upload/images/" . getMillisecond();
    try {
        $file = array_pop($_FILES);
        if ($file["error"] > 0) {
            $result = "Error: " . $file["error"] . "<br />";
        } else {
            $targetFile = $targetDir . str_replace(".", "", $file["name"]);
            move_uploaded_file($file["tmp_name"], $targetFile);
            $result = $targetFile;
        }
        echo json_encode(array("result" => $result));
    } catch (Exception $e) {
        throw $e;
        $app->flash('error', $e->getMessage());
    }
});
 function info_save()
 {
     //判断传过来的信息是否合法,包括验证码是否正确
     foreach ($_POST as $k => $v) {
         $data[$k] = I("post." . $k);
     }
     //                echo "<pre>";var_dump($data);echo "</pre>";
     if (empty($data['name']) || empty($data['mobile']) || empty($data['able_time']) || empty($data['verify']) || empty($data['want'])) {
         echo json_encode(array("code" => "500", "msg" => "参数异常"));
         die;
     }
     if ($_SESSION['up_' . $data['mobile']] != $data['verify']) {
         echo json_encode(array("code" => "500", "msg" => "验证码不正确"));
         die;
     }
     //判断是否是已有账号用户,不是则为其注册新用户,发送账号短信息
     $memberOb = M("member");
     $arMember = $memberOb->query("select * from stj_member  m join stj_userinfo u where m.username=u.username and mobile='{$_POST['mobile']}' and flag=0");
     if (empty($arMember)) {
         //创建用户
         $userOb = M("userinfo");
         $username = $this->create_username($userOb);
         $pwd = substr($_POST['mobile'], 5);
         $user['password'] = md5(md5($pwd));
         $user['username'] = $username;
         $user['status'] = '1';
         $user['flag'] = '0';
         $card['username'] = $user['username'];
         $card['cnname'] = $data['name'];
         $card['password'] = $user['password'];
         $card['pwd'] = $pwd;
         $card['mobile'] = $_POST['mobile'];
         $card['activation'] = 1;
         $card['checkinfo'] = 'true';
         $card['regip'] = $_SERVER["REMOTE_ADDR"];
         $card['regtime'] = time();
         $card['logintime'] = time();
         $card['loginip'] = $_SERVER["REMOTE_ADDR"];
         $card['fromwhere'] = "upresume";
         $userOb->add($user);
         $memberOb->add($card);
         $memberId = $memberOb->getLastInsID();
         //发送短信
         $content = "您成功参与了人人猎上传简历坐等收钱活动,请用手机号登录,密码为手机号末六位。如有疑问,请联系010-57188076。";
         $tag = "uploadresume";
         $comment = "上传简历坐等收钱";
         $linkid = $memberId;
         sendMessageOld($_POST['mobile'], $content, $linkid, $tag, $comment);
     } else {
         echo json_encode(array("code" => "500", "msg" => "您已是系统用户,请登陆后,上传简历。"));
         die;
     }
     //保存信息到简历表中
     $resume['username'] = $data['name'];
     $resume['mobile'] = $data['mobile'];
     $resume['contact_time'] = $data['able_time'];
     $resume['keyword'] = $data['want'];
     $resume['t_id'] = $memberId;
     $resume['keyid'] = getMillisecond();
     $resume['type'] = 5;
     $resume['other'] = $data['other'];
     $resume['posttime'] = time();
     $_SESSION['up_' . $data['mobile']] = null;
     $re = M("resume")->add($resume);
     //                var_dump($re);
     //                echo M("customized")->getLastSql();
     echo json_encode(array("code" => "200", "msg" => "参与成功"));
     die;
 }
Example #11
0
File: Http.php Project: Honvid/HCMS
 /**
  * 发起一个HTTP/HTTPS的请求
  * @param String $url 接口的URL
  * @param $params 接口参数   array('content'=>'test', 'format'=>'json');
  * @param $method 请求类型,GET|POST|JSON|DELETE
  * @param $headers 扩展的包头信息
  * @param $multi 图片信息
  * @return string
  */
 public static function request($url, $params = array(), $method = 'GET', $headers = array(), $multi = false)
 {
     if (!function_exists('curl_init')) {
         exit('Need to open the curl extension');
     }
     $showLog = C("OPEN_HTTP_LOG");
     try {
         $httpStartTime = getMillisecond();
         $method = strtoupper($method);
         $ci = curl_init();
         curl_setopt($ci, CURLOPT_USERAGENT, 'myfmvc php client');
         curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30);
         curl_setopt($ci, CURLOPT_TIMEOUT, 30);
         curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, false);
         curl_setopt($ci, CURLOPT_HEADER, false);
         switch ($method) {
             case 'POST':
                 curl_setopt($ci, CURLOPT_POST, TRUE);
                 if (!empty($params)) {
                     if ($multi) {
                         foreach ($multi as $key => $file) {
                             $params[$key] = '@' . $file;
                         }
                         curl_setopt($ci, CURLOPT_POSTFIELDS, $params);
                         $headers[] = 'Expect: ';
                     } else {
                         curl_setopt($ci, CURLOPT_POSTFIELDS, http_build_query($params));
                     }
                 }
                 break;
             case 'DELETE':
             case 'GET':
                 $method == 'DELETE' && curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
                 if (!empty($params)) {
                     $url = $url . (strpos($url, '?') ? '&' : '?') . (is_array($params) ? http_build_query($params) : $params);
                 }
                 break;
             case 'JSON':
                 if (!empty($params)) {
                     $data = json_encode($params);
                     curl_setopt($ci, CURLOPT_POSTFIELDS, $data);
                     curl_setopt($ci, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data)));
                     curl_setopt($ci, CURLOPT_CUSTOMREQUEST, "POST");
                 }
                 break;
         }
         curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE);
         curl_setopt($ci, CURLOPT_URL, $url);
         if ($headers) {
             curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
         }
         $response = curl_exec($ci);
         curl_close($ci);
         $httpEndTime = getMillisecond();
         if ($showLog) {
             Log::write(sprintf("HTTP COSTTIME=【%s】ms, URL=【%s】,RESPONSE=【%s】", $httpEndTime - $httpStartTime, $url, $response));
         }
         return $response;
     } catch (Exception $ex) {
         if ($showLog) {
             Log::write(sprintf("HTTP URL=【%s】,ERRORS=【%s】", $url, $ex->getMessage()));
         }
     }
 }
 /**
  * 创建事务
  */
 public function addTransaction()
 {
     $information = I('post.');
     if (!$this->produceTransaction($information)) {
         returnJson(404, $this->error);
     }
     $user = M('users')->where("stunum='%s'", $information['stuNum'])->find();
     if (!$user) {
         returnJson(404, '没有完善信息,无法添加事务');
     }
     $user_id = $user['id'];
     if (!$this->derepeat($user_id, $information, $information['date'], $this->error)) {
         returnJson(404, $this->error);
     }
     $id = empty($information['id']) ? getMillisecond() . sprintf("%04.0f", mt_rand(00, 9999)) : $information['id'];
     $current_time = date("Y-m-d H:i:s");
     $term = $this->getTerm();
     $data = array("time" => $information['time'], 'title' => $information['title'], 'content' => $information['content'], 'id' => $id, 'updated_time' => $current_time, 'user_id' => $user_id, 'term' => $term);
     $result = M('transaction')->add($data);
     if (!$result) {
         returnJson(500, 'error');
     }
     $transaction_time = M('transaction_time');
     foreach ($information['date'] as $date) {
         $data = $date;
         $data['transaction_id'] = $id;
         $data['updated_time'] = $current_time;
         if (!$transaction_time->add($data)) {
             returnJson(500, 'error');
         }
     }
     returnJson(200, '', array('id' => $id));
 }
Example #13
0
function generateUserID()
{
    date_default_timezone_set('Asia/Shanghai');
    //代码中设定时区,防止开发环境和生产环境默认时区不一致
    $currentTime = date("YmdHis");
    //取14位当前时间YYYYMMDDHHMMSS
    $microTime = getMillisecond(3);
    //取3位毫秒值
    $randomValue = getRandChar(5);
    // 取5位随机数
    $userID = "{$currentTime}{$microTime}{$randomValue}";
    return $userID;
}
Example #14
0
File: db.php Project: Honvid/HCMS
 /**
  * 执行全局sql
  * @param $sql
  * @param array $bindArray
  * @param null $action
  * @return array|int|mixed|null|string
  */
 public function execute($sql, $bindArray = array(), $action = null)
 {
     $sqlStartTime = getMillisecond();
     $stmt = $this->link->prepare($sql);
     $ok = $stmt->execute($bindArray);
     $res = null;
     switch ($action) {
         case "select":
             $res = $stmt->fetch(\PDO::FETCH_ASSOC);
             break;
         case "selectAll":
             $res = $stmt->fetchAll(\PDO::FETCH_ASSOC);
             break;
         case "update":
         case "delete":
             $res = $stmt->rowCount();
             break;
         case "insert":
             $res = $this->link->lastInsertId();
             break;
         case "count":
             $res = $stmt->rowCount();
             break;
     }
     $this->options = array();
     $sqlEndTime = getMillisecond();
     $showLog = C("SQL_LOG");
     if ($showLog) {
         Log::write(sprintf("SQL COSETIME=【%s】ms,ERRORCODE=【%s】,SQL=【%s】,BIND=【%s】", $sqlEndTime - $sqlStartTime, $ok, $sql, json_encode($bindArray)), Log::SQL);
     }
     if (!$ok) {
         Log::write("SQL ERROR=" . json_encode($stmt->errorInfo()), Log::ERROR);
         throw new Exception(json_encode($stmt->errorInfo()));
     }
     return $res;
 }
Example #15
0
 /**
  * 执行一个sql更新
  **/
 public function update($sql)
 {
     interface_log(INFO, EC_OK, "SQL[{$sql}]");
     if (!$this->_conn || $this->ping($this->_conn)) {
         if ($this->_autoCommitTime) {
             throw new Exception('auto commit time is not zero when reconnect to db');
         } else {
             $this->connect();
         }
     }
     $startTime = getMillisecond();
     $urs = mysqli_query($this->_conn, $sql);
     if (!$urs) {
         throw new Exception('跟新失败:' . mysqli_error($this->_conn));
     } else {
         interface_log(INFO, EC_OK, "excute time:" . getMillisecond($startTime) . "(ms) SQL[{$sql}]");
         return $urs;
     }
 }
Example #16
0
            // return $contents;
        } elseif ($website == 'amazon') {
            $AmazonIp = array('72.21.214.50', '205.251.242.50', '207.171.162.173');
            $url = 'http://' . $AmazonIp[mt_rand(0, 2)] . '/search/complete?mkt=1&search-alias=aps&q=' . rawurlencode($keywords);
            $contents = file_get_contents($url);
            $contents = json_decode($contents);
            print 'amazon';
            $contents = $contents[1];
            // return $contents;
        }
        $ret['randkeywords'] = $RandKeyword;
        $ret['contents'] = $contents;
        return $ret;
    }
}
$data = getMillisecond();
//先获取10条最新外链。
$select = "SELECT * FROM linkurl ORDER BY linkurl.time DESC LIMIT 0, 10";
//获取最新10条外链
$ReturnKey = $pdo->query($select);
$retrun_linkurl = $ReturnKey->fetchAll(PDO::FETCH_ASSOC);
$ret['link_keywords'] = $retrun_linkurl;
$ret = return_keywords($type);
var_dump($ret);
//显示为json格式
print json_encode($ret);
//再写入新的外链
// $pdo->exec("INSERT INTO `$dbname`.`linkurl` (`url`, `keywords`, `time`, `click`) VALUES ('$lailu', '$keywords', '$data', '');");//插入新外链
//获取13位时间戳
function getMillisecond()
{