Esempio n. 1
0
 protected function ValidateForSpam(&$fieldsbuilder)
 {
     // Message text to check
     $message = "";
     // Add text area fields to the message
     foreach ($fieldsbuilder->Fields as $key => $field) {
         $test = strpos($field['Type'], "textarea");
         if (strpos($field['Type'], "textarea") !== 0) {
             continue;
         }
         $message .= $field['Value'];
     }
     // If it was a spammer, just log this attempt, drop the email, and of course notify the user with a false return value
     $spam_words = $this->Params->get("spam_words", "");
     // Spam check disabled and copy to submitter disabled. No need to perform spam check
     if (!(bool) $this->Params->get("spam_check", 0) && !(bool) $this->Params->get("copy_to_submitter", 0)) {
         return true;
     }
     // No spam words issued to antispam system
     if (empty($spam_words)) {
         return true;
     }
     $arr_spam_words = explode(",", $spam_words);
     foreach ($arr_spam_words as $word) {
         if (stripos($message, $word) !== false) {
             $logger = new FLogger();
             $logger->Write("Spam attempt blocked:" . PHP_EOL . print_r($fieldsbuilder->Fields, true) . "-----------------------------------------");
             // this is a spam message
             return false;
         }
     }
     // Spam ckeck successful
     return true;
 }
Esempio n. 2
0
 /**
  * 初始化avatar的md5值
  * 文件字段名为file_name
  */
 public function initAvatarAction()
 {
     $log2 = new FLogger("images_log");
     $t = new FTable("user_detail");
     $t->fields(array("uid", "avatar", "avatarlevel"))->where(array("avatarlevel" => array('neq', '-1'), "uid" => array('gt' => '5000000')))->order(array("uid" => "asc"));
     //$data = $t->limit(10)->select();
     $data = $t->select();
     echo json_encode($data);
     // $log2->append(json_encode($data));
     foreach ($data as $ud) {
         $url = $ud["avatar"];
         $md5 = self::downAndGetMd5($url);
         if ($md5 != "") {
             self::addDb($url, $md5, $ud["avatarlevel"]);
         }
         $log2->append("---" . $ud["uid"] . "--" . $ud["avatar"]);
     }
     /*  echo json_encode($data);
             if(count($data)<=0) return false;
     
             $hArr = array();//handle array
     
             foreach($data as $pic){
     
                 $h = curl_init();
                 curl_setopt($h,CURLOPT_URL,$pic['avatar']);
                 curl_setopt($h,CURLOPT_HEADER,0);
                 curl_setopt($h,CURLOPT_RETURNTRANSFER,1);//return the image value
     
                 array_push($hArr,$h);
             }
     
             $mh = curl_multi_init();
             foreach($hArr as $k => $h){
                 curl_multi_add_handle($mh,$h);
             }
             $running = null;
             do{
                 curl_multi_exec($mh,$running);
             }while($running > 0);
     
             // get the result and save it in the result ARRAY
            // $picsArr = array();
             foreach($hArr as $k => $h){
                 $r = curl_multi_getcontent($h);
                 $picsArr[$k]['data']  = $r;
                 echo $k."--".json_encode($picsArr)."<br>";
             }
     
             //close all the connections
             foreach($hArr as $k => $h){
                 $info = curl_getinfo($h);
                 preg_match("/^image/(.*)$/",$info['content_type'],$matches);
               //  echo($info);
               echo $k."--".md5_file($info)."<br>";
                 curl_multi_remove_handle($mh,$h);
             }
             curl_multi_close($mh);*/
     return true;
 }
Esempio n. 3
0
 /**
  * @param $e Exception
  */
 public function traceError($e)
 {
     global $_F;
     $error_code = 0;
     if (!is_array($e)) {
         $error_code = $e->getCode();
     }
     if (is_array($e)) {
         $error_message = $e['message'];
         $error_file = $e['file'];
         $error_line = $e['line'];
     } else {
         $error_message = $e->getMessage();
         $error_file = $e->getFile();
         $error_line = $e->getLine();
         $exception_trace = nl2br($e->__toString());
     }
     $fLogger = new FLogger('error');
     $exception_message = $error_message . '<br /> 异常出现在:' . $error_file . ' 第 ' . $error_line . ' 行';
     $fLogger->append($exception_message);
     if (!$_F['debug']) {
         if ($error_code == 404) {
             FResponse::sendStatusHeader(404);
             $this->view->displaySysPage('404.tpl');
             //                echo "<strong>404 NOT FOUND</strong>";
         } else {
             FResponse::sendStatusHeader(500);
             $this->view->displaySysPage('500.tpl');
         }
         exit;
     }
     if ($_F['in_ajax']) {
         if ($_F['debug']) {
             FResponse::output(array('result' => 'exception', 'content' => $exception_message));
             exit;
         } else {
             if ($error_code == 404) {
                 FResponse::sendStatusHeader(404);
             } else {
                 FResponse::sendStatusHeader(500);
             }
             exit;
         }
     }
     header('HTTP/1.1 500 FLib Error');
     header('status: 500 FLib Error');
     $exception_message = str_replace(APP_ROOT, '', $exception_message);
     $exception_trace = str_replace(APP_ROOT, '', $exception_trace);
     $this->view->set('exception_message', str_replace(APP_ROOT, '', $exception_message));
     $this->view->set('exception_trace', preg_replace('#[\\w\\d \\#]+?/f.php.+?$#si', ' Flib 引导入口', $exception_trace));
     $this->view->displaySysPage('exception.tpl');
 }
Esempio n. 4
0
File: FDB.php Progetto: jiatower/php
 /**
  * @return PDO
  * @throws Exception
  */
 public static function connect($db = "mumu", $type = "w")
 {
     $log = new FLogger("db_log");
     global $_F;
     $gConfig = FConfig::get('db');
     $curConfig = null;
     if ($db == self::$DB_MUMU) {
         // mumu库
         if ($type == self::$DB_WRITE) {
             $curConfig = $gConfig['mumu_write']['default'];
         } else {
             $curConfig = $gConfig['mumu_read']['default'];
         }
     } elseif ($db == self::$DB_MUMU_STAT) {
         // 统计库
         if ($type == self::$DB_WRITE) {
             $curConfig = $gConfig['stats_write']['default'];
         } else {
             $curConfig = $gConfig['stats_read']['default'];
         }
     } elseif ($db == self::$DB_MUMU_MESSAGE) {
         // 消息库
         if ($type == self::$DB_WRITE) {
             $curConfig = $gConfig['message_read']['default'];
         } else {
             $curConfig = $gConfig['message_read']['default'];
         }
     } elseif ($db == self::$DB_MUMU_SORT) {
         // 消息库
         if ($type == self::$DB_WRITE) {
             $curConfig = $gConfig['sort_write']['default'];
         } else {
             $curConfig = $gConfig['sort_read']['default'];
         }
     } elseif ($db == self::$DB_DSTAT) {
         // Dstat 库
         if ($type == self::$DB_WRITE) {
             $curConfig = $gConfig['dstat_write']['default'];
         } else {
             $curConfig = $gConfig['dstat_read']['default'];
         }
     } else {
         throw new Exception("DB Connect Config [" . $db . "] not found!");
     }
     $dsn = $curConfig['dsn'];
     if (isset(self::$_connects[$dsn])) {
         return self::$_connects[$dsn];
     }
     $attr = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_PERSISTENT => false);
     $attr[PDO::ATTR_TIMEOUT] = 5;
     try {
         $dbh = new PDO($curConfig['dsn'], $curConfig['user'], $curConfig['password'], $attr);
         $dbh->exec("SET NAMES '" . $gConfig['charset'] . "'");
     } catch (PDOException $e) {
         $log->append("---cache----" . $e->getMessage());
         throw new Exception("连接数据库[" . $db . "-" . $type . "]失败:" . $e->getMessage());
     }
     self::$_connects[$dsn] = $dbh;
     return $dbh;
 }
Esempio n. 5
0
 public function uploadOSS($input_file_field = 'pic', $save_dir = 'pic', $ext = 'jpg')
 {
     $file_path = $_FILES[$input_file_field]["tmp_name"];
     if (!$file_path) {
         FLogger::write('tmp_name为空', 'update_mumu');
         return '';
     }
     $file_md5 = md5_file($file_path);
     $_file_path_info = pathinfo($_FILES[$input_file_field]['name']);
     $file_ext = strtolower($_file_path_info['extension']);
     if (!$file_ext) {
         $this->get_extension($file_path);
     }
     if (!$file_ext) {
         $file_ext = $ext;
     }
     $content_type = MimeTypes::get_mimetype(strtolower($file_ext));
     $object = 'oss/' . $save_dir . '/' . date('Ym/d/His') . rand(10000, 99999) . '.' . $file_ext;
     $flag = $this->oss->upload_by_file($this->bucket, 'uploads/' . $object, $file_path, $content_type);
     if (!$flag) {
         $object = '';
     }
     $data = array('object' => $object, 'md5' => $file_md5);
     return $data;
 }
Esempio n. 6
0
 /**
  * 用户资料首审
  */
 function verifyUserFirstAction()
 {
     $uid = FRequest::getInt("uid");
     $status = FRequest::getInt("status");
     $reason = FRequest::getString("reason");
     if (CommonUtil::parmIsEmpty($uid) || CommonUtil::parmIsEmpty($status)) {
         FResponse::output(CommonUtil::GetDefRes(201, "参数错误"));
         return;
     }
     // 检测如果已经存在需要复审记录,则直接返回
     $table2 = new FTable("verify_user");
     $n = $table2->where(array("uid" => $uid, "flag" => 0))->count();
     if ($n > 0) {
         FResponse::output(CommonUtil::GetDefRes(200, "操作成功"));
         return;
     }
     // 原子操作,开启事务处理
     FDB::begin();
     try {
         // 修改用户资料修改记录状态
         $table = new FTable("update_record");
         $table->where(array("uid" => $uid, "status" => 0))->update(array("status" => 1));
         // 插入到复审的表里
         $table2 = new FTable("verify_user");
         $id = $table2->insert(array("uid" => $uid, "status" => $status, "reason" => $reason, "aid" => FSession::get('user_id')));
         FDB::commit();
     } catch (Exception $e) {
         FDB::rollBack();
         //写入日志
         $log = new FLogger("user_log");
         $log->append("verifyUserFirstAction:" . $e);
         FResponse::output(CommonUtil::GetDefRes(201, "操作失败"));
         return;
     }
     // FResponse::output(CommonUtil::GetDefRes(200,"操作成功"));
     //下面是一审完了,走二审接口
     /*$table2 = new FTable("verify_user","vu");
       $verify_user = $table2->fields(array("vu.id")) ->where(array("vu.uid"=>$uid,"vu.flag"=>0))->find();*/
     $url = FConfig::get('global.service_mumu_url') . "/s/user/IUserInfoVerify";
     $res = Service_Common::secPost($url, array("id" => $id, "uid" => $uid, "level" => $status));
     FResponse::output($res);
 }
Esempio n. 7
0
 public static function logSql($sql, $param = null)
 {
     global $_F;
     $fLogger = new FLogger('sql');
     $sql_new = '';
     if (!count($param)) {
         $sql_new = $sql;
     } else {
         foreach ($param as $item) {
             if (is_string($item) || $item === null) {
                 $item = '\'' . $item . '\'';
             }
             $pos = strpos($sql, '?');
             $sql_new .= substr($sql, 0, $pos) . $item;
             $sql = substr($sql, $pos + 1);
         }
         $sql_new .= $sql;
     }
     $fLogger->append($sql_new);
     $_F['debug_info']['sql'][] = $sql_new;
 }
Esempio n. 8
0
 /**
  * 根据时间进行统计
  */
 public function doReportByTimeAction()
 {
     global $_F;
     $_F["debug"] = true;
     $report_log = new FLogger("report_log");
     // 获取统计的日期
     $time_str = FRequest::getString('time');
     $report_log->append("~~~~~统计开始 by time,时间:" . $time_str);
     echo "~~~~~统计开始 by time,时间:" . $time_str . "<br>";
     $tm = date("Y-m-d 00:00:00", strtotime($time_str));
     echo $tm . "<br>";
     $b = time();
     for ($i = 0; $i < 24; $i++) {
         $stm = date("Y-m-d H:00:00", strtotime($tm) + $i * 3600);
         $etm = date("Y-m-d H:00:00", strtotime($tm) + ($i + 1) * 3600);
         //  echo($stm."----".$etm."<br>");
         Service_Edit::statistics($stm, $etm);
     }
     $e = time();
     $report_log->append("~~~~~统计结束,时间:" . $time_str . "---- cost : " . ($e - $b));
     echo "~~~~~统计结束,时间:" . $time_str . "---- cost : " . ($e - $b);
 }
Esempio n. 9
0
 /**
  * @return FMongoDB
  */
 public static function getInstance($db_conf = 'default')
 {
     static $mongo = array();
     if (!FConfig::get('global.mongoDB.enable')) {
         FLogger::write('调用了 FMongoDB,但是 配置中没有启用 global.mongoDB.enable', 'error');
         return new FMongoDBNull();
     }
     if (isset($mongo[$db_conf])) {
         return $mongo[$db_conf];
     } else {
         $mongo[$db_conf] = new FMongoDB(FConfig::get('db.mongoDB.' . $db_conf . '.dsn'));
         $mongo[$db_conf]->selectDb(FConfig::get('db.mongoDB.' . $db_conf . '.db'));
         return $mongo[$db_conf];
     }
 }
Esempio n. 10
0
 /**
  * 执行图片检测任务
  * @return string
  */
 public static function doCheckImages($images, $item)
 {
     $log = new FLogger("images_log");
     $secretid = "";
     //你的secretid
     $timestamp = time();
     //当前时间
     $nonce = rand(100, 999999);
     //随机数
     $taskUrl = "";
     //任务链接
     if ($item == self::$SEXY_AND_HUMAN) {
         $secretid = self::$SEXY_AND_HUMAN_SECRET_ID;
         //你的secretid
         $taskUrl = self::$SEXY_AND_HUMAN_TASK_URL;
         //任务链接
     } else {
         if ($item == self::$SEXY_AND_AD) {
             $secretid = self::$SEXY_AND_AD_SECRET_ID;
             //你的secretid
             $taskUrl = self::$SEXY_AND_AD_TASK_URL;
             //任务链接
         }
     }
     //得到参与签名的参数
     $sign_string = $secretid . "," . $timestamp . "," . $nonce;
     //读取私钥,并得到base64格式的签名$signature
     $private_key_pem = file_get_contents(APP_ROOT . '/lib/tuputech/rsa_private_key.pem');
     $pkeyid = openssl_get_privatekey($private_key_pem);
     openssl_sign($sign_string, $signature, $pkeyid, OPENSSL_ALGO_SHA256);
     $signature = base64_encode($signature);
     //添加上传参数
     $data = array('secretId' => $secretid, 'image' => $images, 'timestamp' => $timestamp, 'nonce' => $nonce, 'signature' => $signature);
     // $log->append("doCheckImages data 1 -".json_encode($data));
     //以post方式提交参数
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $taskUrl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 15);
     self::curl_setopt_custom_postfields($ch, $data);
     $output = curl_exec($ch);
     curl_close($ch);
     //解析返回的数据
     $data = json_decode($output, true);
     $log->append("doCheckImages data end -" . json_encode($data));
     if ($data) {
         $signature = $data['signature'];
         $json = $data['json'];
         $public_key_pem = file_get_contents(APP_ROOT . '/lib/tuputech/open_tuputech_com_public_key.pem');
         $pkeyid2 = openssl_get_publickey($public_key_pem);
         //利用openssl_verify进行验证,结果1表示验证成功,0表示验证失败
         $result = openssl_verify($json, base64_decode($signature), $pkeyid2, "sha256WithRSAEncryption");
         if ($result == 1) {
             return $json;
         } else {
             return array("code" => 10, "message" => " 签名失败");
         }
     }
     return array("code" => 10, "message" => "data is " . json_encode($data));
 }
Esempio n. 11
0
 /**
  * 查询统计数据
  */
 public static function statistics($stm = "", $etm = "")
 {
     $report_log = new FLogger("report_log");
     $date = date("Y-m-d");
     $hours = date("H");
     if ($stm != "") {
         $date = date("Y-m-d", strtotime($stm));
         $hours = date("H", strtotime($stm));
     }
     if ($stm == "" || $etm == "") {
         $stm = date("Y-m-d H:00:00");
         $etm = date("Y-m-d H:00:00", strtotime($stm . "+1 hours"));
     }
     $report_log->append("--------statistics is begin-----" . $stm . "--" . $etm . "--" . $date . "--" . $hours);
     echo "--------statistics is begin-----" . $stm . "--" . $etm . "--" . $date . "--" . $hours;
     // 获取所有子渠道,用户类型
     $spm_list = self::getAllSpm();
     // 统计用户
     $user_m = self::getUserByTm($stm, $etm);
     // 统计充值
     $charge_m = self::getAllChargeSum($stm, $etm);
     $new_spm = self::getAllUserNewSpm();
     echo json_encode($new_spm);
     echo "<br>";
     //stats_date | hours | c_uid | c_sid | user_type | reg_cnt | charge_user_cnt | charge_sum | gived_sum
     $data_arr = array();
     foreach ($new_spm as $spm_item) {
         foreach (self::$USER_TYPE as $type_item) {
             $data = array();
             $c_uid = $spm_item["c_uid"];
             $c_sid = $spm_item["c_sid"];
             $user_type = $type_item["user_type"];
             $key = "" . $user_type . "-" . $c_sid;
             $data["stats_date"] = $date;
             $data["hours"] = intval($hours);
             $data["c_uid"] = $c_uid;
             $data["c_sid"] = $c_sid;
             $data["user_type"] = $user_type;
             // 注册用户
             $data["reg_cnt"] = 0;
             if (array_key_exists($key, $user_m)) {
                 $data["reg_cnt"] = intval($user_m[$key]["reg_cnt"]);
             }
             // 充值
             $data["charge_user_cnt"] = 0;
             $data["charge_sum"] = 0;
             if (array_key_exists($key, $charge_m)) {
                 $data["charge_user_cnt"] = intval($charge_m[$key]["charge_user_cnt"]);
                 $data["charge_sum"] = intval($charge_m[$key]["charge_sum"]);
             }
             if ($data["c_uid"] == "") {
                 $data["c_uid"] = "default";
             }
             if ($data["c_sid"] == "") {
                 $data["c_sid"] = "default";
             }
             array_push($data_arr, $data);
         }
     }
     echo json_encode($data_arr);
     self::insertTjData($data_arr);
     $report_log->append("--------statistics is end-----" . $stm . "--" . $etm);
 }
Esempio n. 12
0
 /**
  * 进行上传操作
  *
  * @param string $aliyunPath          //阿里云的上传目录
  * @param string $uploadFileTypeLimit //上传的文件类型限制
  * @param int    $uploadFileSizeLimit //上传的文件大小限制,大小单位为KB
  *
  * @return string
  */
 public function upload($aliyunPath = "upload/", $uploadFileTypeLimit = "img", $uploadFileSizeLimit = 3072)
 {
     //获取文件参数
     $error = $_FILES[$this->fileName]["error"];
     $size = $_FILES[$this->fileName]["size"];
     $name = $_FILES[$this->fileName]["name"];
     $tmp_name = $_FILES[$this->fileName]["tmp_name"];
     //获取文件后缀
     $temp_arr = explode(".", $name);
     $file_ext = array_pop($temp_arr);
     $file_ext = trim($file_ext);
     $file_ext = strtolower($file_ext);
     $type = $file_ext;
     //判断上传类型和上传文件大小
     if ($this->isNorm_uploadType($uploadFileTypeLimit, $type) == false) {
         $retData = array('status' => 500, 'msg' => "file type no norm , type : " . join(",", $this->getLimitTypeList($uploadFileTypeLimit)));
         return $retData;
     } elseif ($this->isNorm_uploadSize($uploadFileSizeLimit, $size) == false) {
         $retData = array('status' => 500, 'msg' => "file size no norm , size : " . $uploadFileSizeLimit . "kb");
         return $retData;
     } else {
         if ($error > 0) {
             $retData = array('status' => '10' . $error, 'msg' => "upload error");
             return $retData;
         } else {
             //生成文件名
             $saveFileName = date('YmdHis') . '_' . rand(10000, 90000) . '.' . $file_ext;
             //调用阿里云上传文件
             $aliyunUploadInfo = $this->aliyun_upload($tmp_name, $aliyunPath . $saveFileName);
             $fLogger = new FLogger('debug');
             $fLogger->append('uploadding...');
             $retData = array('status' => 200, 'url' => $aliyunUploadInfo);
             return $retData;
         }
     }
 }
Esempio n. 13
0
 /**
  * @param $e Exception | array
  */
 public function traceError($e)
 {
     global $_F;
     $error_code = 0;
     $exception_trace = '';
     if (!is_array($e)) {
         $error_code = $e->getCode();
     }
     if (is_array($e)) {
         $error_message = $e['message'];
         $error_file = $e['file'];
         $error_line = $e['line'];
     } else {
         $error_message = $e->getMessage();
         $error_file = $e->getFile();
         $error_line = $e->getLine();
         $exception_trace = nl2br($e->__toString());
     }
     $exception_message = $error_message . '<br /> 异常出现在:' . $error_file . ' 第 ' . $error_line . ' 行';
     $log_text = "\n--------------------------------------------------------\n";
     if (isset($_F['current_sql'])) {
         $log_text .= "SQL: " . $_F['current_sql'] . "\n";
         $log_text .= "--------------------------------------------------------\n";
     }
     if (is_object($e)) {
         $log_text .= $e->__toString() . "\n";
         $log_text .= "--------------------------------------------------------\n";
     } else {
         $log_text .= $error_message . "\n";
         $log_text .= "--------------------------------------------------------\n";
     }
     if ($_F['run_in'] == 'shell') {
         $log_text_header = "\n\n          ==========================================\n                         ERROR FOUND\n          ========================================== \n";
         die($log_text_header . $log_text);
     }
     FLogger::write($log_text, 'error');
     if (!$_F['debug']) {
         if ($error_code == 404) {
             FResponse::sendStatusHeader(404);
             $this->view->displaySysPage('404.tpl');
         } else {
             FResponse::sendStatusHeader(500);
             $this->view->displaySysPage('500.tpl');
         }
         exit;
     }
     $exception_message = str_replace(F_APP_ROOT, '', $exception_message);
     if ($_F['in_ajax']) {
         if ($_F['debug']) {
             $ajaxError = preg_replace('/<br.+?>/i', "\n", $exception_message);
             FResponse::output(array('result' => 'error', 'msg' => $ajaxError));
             exit;
         } else {
             if ($error_code == 404) {
                 FResponse::sendStatusHeader(404);
             } else {
                 FResponse::sendStatusHeader(500);
             }
             exit;
         }
     }
     $exception_trace = str_replace(F_APP_ROOT, '', $exception_trace);
     $this->view->assign('exception_message', $exception_message);
     $this->view->assign('exception_trace', preg_replace('#[\\w\\d \\#]+?/f.php.+?$#si', ' Flib 引导入口', $exception_trace));
     $this->view->displaySysPage('exception.tpl');
 }
Esempio n. 14
0
 /**
  * 检验签名
  */
 public function checkSignature()
 {
     $signature = FRequest::getString('signature');
     $timestamp = FRequest::getString('timestamp');
     $nonce = FRequest::getString('nonce');
     $token = $this->token;
     $tmpArr = array($token, $timestamp, $nonce);
     sort($tmpArr);
     $tmpStr = implode($tmpArr);
     $tmpStr = sha1($tmpStr);
     $logger = new FLogger("weixn");
     $logger->append('$token:' . $token);
     $logger->append('$tmpStr:' . $tmpStr . '|$signature:' . $signature);
     return $tmpStr == $signature ? true : false;
 }
Esempio n. 15
0
 /**
 * @param $images 图片map
 * @param $type 检测类型
 * @return array
 * 对图片结果进行判断
 *  `sexy_rate` double DEFAULT '0' COMMENT '色情识别概率',
    `sexy_flag` tinyint(1) DEFAULT '0' COMMENT '色情等级, 0:色情; 1:性感; 2:正常;',
    `sexy_review` tinyint(1) DEFAULT 0 COMMENT '是否需要人工复审 0 无 1 需要',
    `ad_rate` double DEFAULT '0' COMMENT '广告识别概率',
    `ad_flag` tinyint(1) DEFAULT '0' COMMENT '广告兴致 0:正常; 1:二维码; 2:带文字图片;',
    `ad_review` tinyint(1) DEFAULT 0 COMMENT '是否需要人工复审 0 无 1 需要',
 *  `status` tinyint(1) not null DEFAULT 1 COMMENT '图片检查状态 -1 待处理 0 正常 1 不正常 2 待扩展',
 *  `human_flag` 是否任务, 0:男人; 1:女人; 2:其他; 3:多人;
 */
 private static function doCheck($images, $type)
 {
     $log = new FLogger("images_log");
     $res = array();
     if ($images && count($images) > 0) {
         foreach ($images as $url => $img) {
             $sexy_flag = $img["sexy_flag"];
             $ad_flag = $img["ad_flag"];
             $human_flag = $img["human_flag"];
             $item = $img;
             $item["url"] = $url;
             if (!$url || $url == "") {
                 $log->append("[ERROR]--doCheck--url is empty " . $url . "img:" . json_encode($img));
                 continue;
             }
             $item["status"] = 1;
             // 不正常
             if ($type == Service_TupuTech::$SEXY_AND_AD && $sexy_flag != 0 && $ad_flag == 0) {
                 // 色情 + 广告
                 $item["status"] = 0;
                 //正常
             }
             if ($type == Service_TupuTech::$SEXY_AND_HUMAN && $sexy_flag != 0 && $human_flag != 2) {
                 // 色情 + 人物
                 $item["status"] = 0;
                 //正常
             }
             array_push($res, $item);
         }
     }
     return $res;
 }
Esempio n. 16
0
 /**
  * 获得表结构
  * @return array|null
  * @throws Exception
  */
 private function getTableInfo()
 {
     $tableInfo = FCache::get($this->_table);
     if ($tableInfo) {
         return $tableInfo;
     }
     try {
         $sql = "desc {$this->_table}";
         $this->connect(FDB::$DB_READ);
         $stmt = $this->_dbh->prepare($sql);
         $stmt->execute();
         $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $tableInfo = array('pri' => null, 'fields' => null);
         foreach ($rows as $row) {
             if ($row['Key'] == 'PRI') {
                 $tableInfo['pri'] = $row['Field'];
             }
         }
         $tableInfo['fields'] = $rows;
         FCache::set($this->_table, $tableInfo, 8640000);
     } catch (PDOException $e) {
         FLogger::write("获取表信息失败: " . $this->_table . "\t" . $e->getMessage());
         throw new Exception("获取表信息失败。");
     }
     return $tableInfo;
 }
Esempio n. 17
0
 /**
  * 获得表结构
  * @return array|null
  * @throws Exception
  */
 public function getTableInfo()
 {
     $tableInfo = FCache::get($this->_table);
     if ($tableInfo) {
         return $tableInfo;
     }
     $sql = "desc {$this->config['table_pre']}{$this->table_raw}";
     try {
         $this->connect('r');
         $stmt = $this->_dbh->prepare($sql);
         $stmt->execute();
         $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $tableInfo = array('pri' => null, 'fields' => null);
         foreach ($rows as $row) {
             if ($row['Key'] == 'PRI') {
                 $tableInfo['pri'] = $row['Field'];
             }
             $tableInfo['fields'][$row['Field']] = $row;
         }
         FCache::set($this->_table, $tableInfo, 8640000);
     } catch (PDOException $e) {
         FLogger::write("获取表信息失败: " . $this->_table . "\t{$sql}\t" . $e->getMessage(), 'error');
         throw new Exception("获取表信息失败。");
     }
     return $tableInfo;
 }
Esempio n. 18
0
 /**
  *处理微信服务器消息
  */
 public function defaultAction()
 {
     global $_F;
     $this->openDebug();
     require_once APP_ROOT . 'lib/weixin/WeixinChat.class.php';
     $options = array('token' => 'mumu2015api', 'appid' => 'wxe3ae7e3cf42d0825', 'appsecret' => '2d7b39fcb0813e7b07830683cc3caa50');
     $weixin = new WeixinChat($options);
     //        $weixin->valid();
     $logger = new FLogger("weixn");
     $logger->append('==============开始:===============');
     $getRev = $weixin->getRev();
     $logger->append($getRev->getRevText());
     if ($weixin->getRevType()) {
         $logger->append('getRevType:' . $weixin->getRevType());
         $eventData = $weixin->getRevEvent();
         $logger->append('eventData:' . var_export($eventData, true));
         if ($eventData) {
             $openid = $weixin->getRevFrom();
             if ($eventData['event'] == 'click') {
                 switch ($eventData['key']) {
                     case 'V1001_FREE':
                         $type = 1;
                         break;
                     case 'V1001_TODAY_ACTIVITY':
                         $type = 2;
                         break;
                     case 'V1001_FOUND':
                         $type = 3;
                         break;
                     default:
                         $type = 1;
                         break;
                 }
                 $data = $this->getNewsMsgData($type);
             } else {
                 if ($eventData['event'] == 'subscribe') {
                     //                        $upData = array(
                     //                            'subscribe' => 1,
                     //                            'subscribe_time' => date('Y-m-d H:i:s', time())
                     //                        );
                     $userInfo = $weixin->getUserInfo($openid);
                     FLogger::write($userInfo, 'subscribe');
                     Service_UserWechat::reg($userInfo, $openid);
                     //                        $data = $this->getNewsMsgData(2);
                     $data = '欢迎关注缘分吧';
                 }
                 if ($eventData['event'] == 'unsubscribe') {
                     //                        $upData = array(
                     //                            'subscribe' => 0
                     //                        );
                 }
             }
         }
         if ($data) {
             $logger->append(var_export($data, true));
             $logger->append(FRequest::getClientIP());
             //                $logger->append(json_encode($weixin->getRevData()));
             $weixin->text($data);
             $weixin->reply();
         }
     } else {
         $logger->append('getRevType为空' . $weixin->getRevType());
     }
     $logger->append('==============结束:===============');
 }
Esempio n. 19
0
 public function doSleepAction()
 {
     /* $Url = 'http://image1.yuanfenba.net/uploads/oss/photo/201508/20/20000561547.jpg@%20256w_90Q_1x.jpg';
             $S = parse_url($Url);
     
             if($Url){
                 $index = strrpos($Url,"@",0);
                 if($index){
                     $Url = strstr($Url, '@', TRUE);
                 }
             }
             echo $Url."<br>";
     
             echo json_encode($S)."<br>";
             $S = strtolower($S['host']) ; //取域名部分
     
             $re = pathinfo($Url);
             echo json_encode($re)."<br>";
             if(!strpos($S,"yuanFenba.net")){
                 echo"no error path";
             }else{
                 echo "yes";
             }
     \
             echo $S;*/
     /*for($i =0;$i<=100;$i++){
           $r = rand(0,20);
           echo (rand(0,20)-10)."<br>";
       }*/
     /*$url = "http://image2.yuanfenba.net/uploads/oss/photo/201506/19/13072474951.jpg";
             //获取图片二进制流
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $url);
             // curl_setopt($ch, CURLOPT_GET, 1);
             // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch,CURLOPT_HEADER,0);
             curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//return the image value
     
             //  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
             // curl_setopt($ch, CURLOPT_TIMEOUT, 15);
     
             curl_setopt($ch,CURLINFO_CONTENT_LENGTH_DOWNLOAD,1);//content 下载原大小
             curl_setopt($ch,CURLINFO_SIZE_DOWNLOAD,1);//实际下载大小
     
             $imageData = curl_exec($ch);
             $info = curl_getinfo($ch);
             curl_close($ch);
     
            // dfsdaf
            var_dump($info);
             echo("-------".$info["size_download"]!=$info["download_content_length"]);
             if($info["size_download"]!=$info["download_content_length"]){
                 // 实际下载大小于源文件大小不符
               //  echo("-------");
     
             }
             $md5 = md5($imageData);*/
     $stm = time();
     $log2 = new FLogger("images_log");
     $log2->append("---begin----" . $stm);
     $t = new FTable("user_detail");
     $t->fields(array("uid", "avatar", "avatarlevel"))->where(array("avatarlevel" => array('neq', '-1'), "uid" => array('gt' => '5025587')))->order(array("uid" => "asc"));
     //$data = $t->limit(100)->select();
     $res = $t->select();
     $data = $res;
     $log2->append("---begin----" . count($data));
     $i = 0;
     foreach ($data as $ud) {
         $url = $ud["avatar"];
         if ($url == "") {
             continue;
         }
         $image_table = new FTable("image_md5");
         $n = $image_table->where(array("url" => $url))->count();
         if ($n > 0) {
             $log2->append("-ok--" . $ud["uid"] . "--" . $ud["avatar"]);
             continue;
         }
         // sleep(1);
         //获取图片二进制流
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         // curl_setopt($ch, CURLOPT_GET, 1);
         // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         //return the image value
         //  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
         // curl_setopt($ch, CURLOPT_TIMEOUT, 15);
         $imageData = curl_exec($ch);
         $info = curl_getinfo($ch);
         curl_close($ch);
         // 判断是否全部下载完成
         if ($info["size_download"] != $info["download_content_length"]) {
             // 实际下载大小于源文件大小不符
             $log2->append("-下载不完整-" . $ud["uid"] . "--" . $ud["avatar"] . "---实际:-" . $info["size_download"] . "-源文件:-" . $info["download_content_length"]);
             continue;
         }
         $md5 = md5($imageData);
         /*if($i%20==0){
               $log2->append("---".$ud["uid"]."--".$ud["avatar"]."md5: ".$md5);
           }*/
         $log2->append("---" . $ud["uid"] . "--" . $ud["avatar"] . "md5: " . $md5);
         $t = 0;
         $img = array("url" => $url, "md5" => $md5, "type" => "avatar", "status" => $t);
         $image_table2 = new FTable("image_md5");
         try {
             $image_table2->insert($img);
         } catch (Exception $e) {
             $log2->append("重复key :" . $url . "e: " . $e->getTraceAsString());
         }
         $i++;
     }
 }