record() static public method

记录日志 并且会过滤未经设置的级别
static public record ( string $message, string $level = self::ERR, boolean $record = false ) : void
$message string 日志信息
$level string 日志级别
$record boolean 是否强制记录
return void
Example #1
0
 public function team()
 {
     $this->assign('title', '团队');
     $ing_groups = D('BookGroup')->where(['status' => 0])->select();
     Log::record(print_r($ing_groups, true));
     foreach ($ing_groups as &$ing_g) {
         $books = D('Book')->where(['gid' => $ing_g['id']])->order('uid asc,id desc')->select();
         foreach ($books as &$book) {
             $user = D('User')->where(['id' => $book['uid']])->find();
             $book['uname'] = $user['name'];
         }
         $ing_g['books'] = $books;
     }
     $ed_groups = D('BookGroup')->where(['status' => 1])->select();
     foreach ($ed_groups as &$ed) {
         $books = D('Book')->where(['gid' => $ed['id']])->order('uid asc,id desc')->select();
         foreach ($books as &$book) {
             $user = D('User')->where(['id' => $book['uid']])->find();
             $book['uname'] = $user['name'];
         }
         $ed['books'] = $books;
     }
     $this->assign('ing_groups', $ing_groups);
     $this->assign('ed_groups', $ed_groups);
     $this->display('');
 }
 /**
 +----------------------------------------------------------
 * 显示页面Trace信息
 +----------------------------------------------------------
 * @access private
 +----------------------------------------------------------
 */
 private function showTrace()
 {
     // 系统默认显示信息
     $log = Log::$log;
     $files = get_included_files();
     $trace = array('请求时间' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']), '当前页面' => __SELF__, '请求协议' => $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'], '运行信息' => $this->showTime(), '会话ID' => session_id(), '日志记录' => !empty($log) ? $log : '无日志记录', '加载文件' => $files);
     // 读取项目定义的Trace文件
     $traceFile = CONF_PATH . 'trace.php';
     if (is_file($traceFile)) {
         // 定义格式 return array('当前页面'=>$_SERVER['PHP_SELF'],'通信协议'=>$_SERVER['SERVER_PROTOCOL'],...);
         $trace = array_merge(include $traceFile, $trace);
     }
     // 设置trace信息
     trace($trace);
     $fire = array(array('', ''));
     foreach (trace() as $key => $value) {
         $fire[] = array($key, $value);
     }
     if (headers_sent($filename, $linenum)) {
         $fileInfo = !empty($filename) ? "(在{$filename}文件的第{$linenum}行)" : '';
         Log::record("已经有Http Header信息头输出{$fileInfo},请在你的入口文件加入ob_start() 或通过配置output_buffering,已确保headers不被提前输出");
     } else {
         fb(array('页面Trace信息', $fire), FirePHP::TABLE);
     }
 }
 function get_setting()
 {
     $payconf = M('redcash_wxconf')->where(array('token' => $this->token))->find();
     if (!$payconf['mchid'] || !$payconf['appid'] || !$payconf['key']) {
         Log::record('get red cash wechat params: ' . print_r($payconf, 1), Log::INFO);
         Log::save();
         die('微信参数配置不完整');
     }
     $setting = M('redcash_setting')->where(array('token' => $this->token, 'id' => $this->redcash_id))->find();
     $setting['mchid'] = $payconf['mchid'];
     $setting['appid'] = $payconf['appid'];
     $setting['key'] = $payconf['key'];
     if ($setting['status'] == '1') {
         $money = intval($setting['fixed_amount'] * 100);
         $setting['min_value'] = $money;
         $setting['max_value'] = $money;
         $setting['total_amount'] = $money;
     }
     if (!$setting['nick_name'] || !$setting['send_name'] || !$setting['fixed_amount'] || !$setting['wishing'] || !$setting['act_name'] || !$setting['remark']) {
         Log::record('get red cash params : ' . print_r($setting, 1), Log::INFO);
         Log::save();
         die('活动信息配置不完整');
     }
     $certs = array('SSLCERT' => getcwd() . '/' . $payconf['ssl_cert'], 'SSLKEY' => getcwd() . '/' . $payconf['ssl_key'], 'CAINFO' => getcwd() . '/' . $payconf['ssl_cainfo']);
     if (!$certs) {
         die('未设置微信支付证书信息');
     }
     $setting['certs'] = array('certs' => $certs);
     return $setting;
 }
Example #4
0
 /**
  * 实例化(分层)模型
  * @param string $name Model名称
  * @param string $layer 业务层名称
  * @return Object
  */
 public static function model($name = '', $layer = MODEL_LAYER)
 {
     if (empty($name)) {
         return new Model();
     }
     static $_model = [];
     if (isset($_model[$name . $layer])) {
         return $_model[$name . $layer];
     }
     if (strpos($name, '/')) {
         list($module, $name) = explode('/', $name, 2);
     } else {
         $module = MODULE_NAME;
     }
     $class = self::parseClass($module, $layer, $name);
     $name = basename($name);
     if (class_exists($class)) {
         $model = new $class($name);
     } else {
         $class = str_replace('\\' . $module . '\\', '\\' . COMMON_MODULE . '\\', $class);
         if (class_exists($class)) {
             $model = new $class($name);
         } else {
             Log::record('实例化不存在的类:' . $class, 'notic');
             $model = new Model($name);
         }
     }
     $_model[$name . $layer] = $model;
     return $model;
 }
Example #5
0
 public static function send($msg, $detail, $level = self::USER, $mobile = null)
 {
     //判断是否定义需要发送短信
     if (!in_array($level, explode(',', C('SMS_LEVEL')))) {
         return;
     }
     //判断发送频率
     $mc = memcache_init();
     $is_send = $mc->get('think_sms_send');
     //如果已经发送,则不发送
     if ($is_send === 'true') {
         $status = 'not send';
     } else {
         //TODU,如果apibus类调整,此类也得调整
         $sms = apibus::init('sms');
         if (is_null($mobile)) {
             $mobile = C('SMS_MOBILE');
         }
         $mc = memcache_init();
         $obj = $sms->send($mobile, mb_substr(C('SMS_SIGN') . $msg, 0, 65, 'utf-8'), "UTF-8");
         if ($sms->isError($obj)) {
             $status = 'failed';
         } else {
             $status = 'success';
             $mc->set('think_sms_send', 'true', 0, C('SMS_INTERVAL'));
         }
     }
     //记录日志
     if (C('LOG_RECORD')) {
         Log::record($msg . ';detail:' . $detail . '【status:' . $status . '】', 'SEND_SMS', true);
     } else {
         Log::write($msg . ';detail:' . $detail . '【status:' . $status . '】', 'SEND_SMS');
     }
 }
 /**
  *get
  *point,offset,status
  *point:请求界点,status订单状态,offset个数,为正则取大于界点point的offset个元素,反之取小于point的offset个元素
  **/
 protected function read()
 {
     $input = $this->get;
     $ret = $input && $input['point'] !== false && $input['offset'] !== false && $input['status'];
     if ($ret) {
         $condition['token'] = $this->token;
         $condition['hid'] = $this->hid;
         $condition['order_status'] = $input['status'];
         $limit = abs($input['offset']);
         if ($input['point'] == -1) {
             $ret = $this->model->listOrders($condition, $limit, true);
         } else {
             $is_desc = $input['offset'] < 0;
             $opration_con = $is_desc ? 'lt' : 'gt';
             //lt 小于,gt 大于
             $condition['id'] = array($opration_con, $input['point']);
             $ret = $this->model->listOrders($condition, $limit, $is_desc);
         }
     }
     if ($ret !== false) {
         $this->success("操作成功!", $ret);
     } else {
         $this->error('error in read');
         Log::record('error' . print_r($input) . '\\n');
     }
 }
Example #7
0
 /**
  * session初始化
  * @param array $config
  * @return void
  * @throws \think\Exception
  */
 public static function init(array $config = [])
 {
     if (empty($config)) {
         $config = Config::get('session');
     }
     // 记录初始化信息
     APP_DEBUG && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info');
     $isDoStart = false;
     if (isset($config['use_trans_sid'])) {
         ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
     }
     // 启动session
     if (!empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) {
         ini_set('session.auto_start', 0);
         $isDoStart = true;
     }
     if (isset($config['prefix'])) {
         self::$prefix = $config['prefix'];
     }
     if (isset($config['var_session_id']) && isset($_REQUEST[$config['var_session_id']])) {
         session_id($_REQUEST[$config['var_session_id']]);
     } elseif (isset($config['id']) && !empty($config['id'])) {
         session_id($config['id']);
     }
     if (isset($config['name'])) {
         session_name($config['name']);
     }
     if (isset($config['path'])) {
         session_save_path($config['path']);
     }
     if (isset($config['domain'])) {
         ini_set('session.cookie_domain', $config['domain']);
     }
     if (isset($config['expire'])) {
         ini_set('session.gc_maxlifetime', $config['expire']);
         ini_set('session.cookie_lifetime', $config['expire']);
     }
     if (isset($config['use_cookies'])) {
         ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0);
     }
     if (isset($config['cache_limiter'])) {
         session_cache_limiter($config['cache_limiter']);
     }
     if (isset($config['cache_expire'])) {
         session_cache_expire($config['cache_expire']);
     }
     if (!empty($config['type'])) {
         // 读取session驱动
         $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\session\\driver\\') . ucwords($config['type']);
         // 检查驱动类
         if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
             throw new \think\Exception('error session handler', 11700);
         }
     }
     if ($isDoStart) {
         session_start();
         self::$active = true;
     }
 }
Example #8
0
 public static function system_init()
 {
     parent::system_init();
     if (!self::is_enabled()) {
         return null;
     }
     \Log::record(__FILE__, "Test module is enable");
 }
Example #9
0
 public function query($sql)
 {
     $result = mysql_query($sql, $this->conn);
     if (DEBUG_MODE) {
         Log::record($sql);
     }
     return $result ? $result : false;
 }
 public function getCompanyStatus()
 {
     $Form = D("company");
     $con['cid'] = $_POST['cid'];
     $Info = $Form->where($con)->getField('status');
     Log::record($Info);
     $this->ajaxReturn($Info, 'Yes', 1);
 }
Example #11
0
 public static function autoload($class)
 {
     // 检测命名空间别名
     if (!empty(self::$namespaceAlias)) {
         $namespace = dirname($class);
         if (isset(self::$namespaceAlias[$namespace])) {
             $original = self::$namespaceAlias[$namespace] . '\\' . basename($class);
             if (class_exists($original)) {
                 return class_alias($original, $class, false);
             }
         }
     }
     // 检查是否定义类库映射
     if (isset(self::$map[$class])) {
         if (is_file(self::$map[$class])) {
             // 记录加载信息
             APP_DEBUG && (self::$load[] = self::$map[$class]);
             include self::$map[$class];
         } else {
             return false;
         }
     } elseif ($file = self::findFileInComposer($class)) {
         // Composer自动加载
         // 记录加载信息
         APP_DEBUG && (self::$load[] = $file);
         include $file;
     } else {
         // 命名空间自动加载
         if (!strpos($class, '\\')) {
             return false;
         }
         // 解析命名空间
         list($name, $class) = explode('\\', $class, 2);
         if (isset(self::$namespace[$name])) {
             // 注册的命名空间
             $path = self::$namespace[$name];
         } elseif (is_dir(EXTEND_PATH . $name)) {
             // 扩展类库命名空间
             $path = EXTEND_PATH . $name . DS;
         } else {
             return false;
         }
         $filename = $path . str_replace('\\', DS, $class) . EXT;
         if (is_file($filename)) {
             // 开启调试模式Win环境严格区分大小写
             if (APP_DEBUG && IS_WIN && false === strpos(realpath($filename), $class . EXT)) {
                 return false;
             }
             // 记录加载信息
             APP_DEBUG && (self::$load[] = $filename);
             include $filename;
         } else {
             Log::record('autoloader error : ' . $filename, 'notice');
             return false;
         }
     }
     return true;
 }
Example #12
0
 /**
  * 记录日志
  * @param unknown $content 日志内容
  * @param boolean $if_sql 是否记录SQL
  */
 protected function log($content, $if_sql = true) {
     if ($if_sql) {
         $log = Log::read();
         if (!empty($log) && is_array($log)){
             $content .= end($log);
         }
     }
     Log::record('queue\\'.$content,Log::RUN);
 }
Example #13
0
 public function testLaunchFile()
 {
     \Core::require_file('core', 'Tools\\Log.php');
     \Log::drop();
     \Log::record('CoreTest', 'Just a test');
     $log = \Log::get();
     $datetime = date('d-m-Y H:i:s');
     $this->assertEquals($log, "[{$datetime}] : Just a test (CoreTest)\r\n");
 }
Example #14
0
 /**
  * 通知初始化
  * @return void
  */
 public static function alarm($config = [])
 {
     $type = isset($config['type']) ? $config['type'] : 'Email';
     $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\alarm\\') . ucwords($type);
     unset($config['type']);
     self::$alarm = new $class($config['alarm']);
     // 记录初始化信息
     APP_DEBUG && Log::record('[ CACHE ] ALARM ' . $type . ': ' . var_export($config, true), 'info');
 }
 protected function _initialize()
 {
     define('PHONE_PAY', 9000);
     define('INTERNET_PAY', 9001);
     parent::_initialize();
     //获取合作伙伴id
     $fxs_id = $this->_get('fxs_id');
     if (!$fxs_id) {
         $fxs_id = session('fxs_id');
     }
     $this->fxs_userid = $fxs_id;
     session('fxs_id', $fxs_id);
     $this->wechat_id = session('wechat_id_' . $this->token);
     $this->branch_id = $this->_get('partner_id');
     $opened_funcs = session('opened_funcs_' . $this->token);
     $cur_func = 'shangcheng';
     if (!in_array($cur_func, $opened_funcs)) {
         Log::record('Shop function verification failed: token:' . $this->token . ' opened_funcs:' . print_r($opened_funcs, true));
         Log::save();
         echo 'Sorry!';
         exit;
     }
     $this->is_need_auth = $this->isNeedDoAuth();
     $this->assign('token', $this->token);
     $this->assign('staticFilePath', str_replace('./', '/', THEME_PATH . 'common/css/product'));
     //购物车信息
     $cart_items = $this->getCart();
     $item_count = 0;
     foreach ($cart_items as $key => $item) {
         $item_count += $item['count'];
     }
     $this->assign('cart_item_count', $item_count);
     //商城信息
     $shop_where = array('token' => $this->token, 'status' => 1);
     $this->branch_id = intval($_GET['bid']);
     if (!empty($this->branch_id)) {
         $shop_where['fake_id'] = $this->branch_id;
     }
     $shop_db = M('b2c_shop');
     $shop = $shop_db->where($shop_where)->find();
     if (empty($this->branch_id)) {
         $this->branch_id = $shop['fake_id'];
     }
     $this->assign('shop', $shop);
     $my_url = '#';
     if ($this->is_need_auth && !$this->wechat_id) {
         $my_url = $this->generateAuthUrl('Shop/my', array('fxs_id' => $fxs_id));
     } else {
         $my_url = $this->generateUrl('Shop/my', array('fxs_id' => $fxs_id));
     }
     $this->assign('my_url', $my_url);
     $cart_url = $this->generateUrl('Shop/cart', array('bid' => $this->branch, 'fxs_id' => $fxs_id, 'partner_id' => $this->branch_id));
     $this->assign('cart_url', $cart_url);
     $home_url = $this->generateUrl('Shop/index', array('fxs_id' => $fxs_id));
     $this->assign('home_url', $home_url);
 }
Example #16
0
 /**
  * 加载配置文件(PHP格式)
  *
  * @param string $file 配置文件名
  * @param string $name 配置名(如设置即表示二级配置)
  * @param string $range  作用域
  * @return mixed
  */
 public static function load($file, $name = '', $range = '')
 {
     $range = $range ?: self::$range;
     if (!isset(self::$config[$range])) {
         self::$config[$range] = [];
     }
     // 记录加载信息
     APP_DEBUG && Log::record('[ CONFIG ] ' . $file, 'info');
     return is_file($file) ? self::set(include $file, $name, $range) : self::$config[$range];
 }
Example #17
0
/** Set the value of a course setting.
 * 
 * @param int $setting_id   One of the SETTING_... constants
 * @param int $value        New value of the setting
 * @param int $course_id    The course id (default: the current course id)
 */
function setting_set($setting_id, $value, $course_id = null)
{
    if (!$course_id) {
        $course_id = $GLOBALS['course_id'];
    }
    $result = Database::get()->query("REPLACE INTO course_settings\n                                          (setting_id, course_id, value)\n                                          VALUES (?d, ?d, ?d)", $setting_id, $course_id, $value);
    if ($result) {
        Log::record($course_id, MODULE_ID_SETTINGS, LOG_MODIFY_COURSE, array('id' => $setting_id, 'value' => $value));
    }
}
Example #18
0
 public static function system_init()
 {
     $path = __DIR__ . DIRECTORY_SEPARATOR;
     \Core::require_file($path . 'class', 'Element.php');
     parent::system_init();
     if (!self::is_enabled()) {
         return null;
     }
     \Log::record(__FILE__, "Form module is enable");
     if (!\Core::is_loaded("Modules\\Forms\\Form")) {
         //\Log::record(__FILE__, "Form module not loaded");
     }
 }
 static function verifyVCode($token, $tel, $code)
 {
     $Cache = Cache::getInstance('File', array('expire' => '610'));
     $truth_code = $Cache->get('vcode_' . $token . $tel);
     if (!empty($truth_code) && $truth_code == $code) {
         Log::record('verifyvcode succeed:' . $token . ":" . $tel . ":" . $code . "", Log::DEBUG);
         Log::save();
         return true;
     }
     Log::record('verifyvcode fail:' . $token . ":" . $tel . ":" . $code . ":" . $truth_code);
     Log::save();
     return false;
 }
Example #20
0
 /**
  * 连接缓存
  * @access public
  * @param array $options  配置数组
  * @return object
  */
 public static function connect(array $options = [])
 {
     $md5 = md5(serialize($options));
     if (!isset(self::$instance[$md5])) {
         $type = !empty($options['type']) ? $options['type'] : 'File';
         $class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\cache\\driver\\') . ucwords($type);
         unset($options['type']);
         self::$instance[$md5] = new $class($options);
         // 记录初始化信息
         APP_DEBUG && Log::record('[ CACHE ] INIT ' . $type . ':' . var_export($options, true), 'info');
     }
     self::$handler = self::$instance[$md5];
     return self::$handler;
 }
 /**
  *data:{'id':48,'status':3}
  **/
 public function update()
 {
     $input = $this->put;
     $ret = $input['status'] && $input['id'];
     if ($ret) {
         $input['rest_id'] = $this->rid;
         $ret = $this->model->changeState($input);
     }
     if ($ret !== false) {
         $this->success("操作成功!");
     }
     $this->error('error in update');
     Log::record('error' . print_r($input) . '\\n');
 }
Example #22
0
 /**
  * 自定义错误处理
  * @access public
  * @param int    $error_number 错误类型
  * @param string $error_string 错误信息
  * @param string $error_file   错误文件
  * @param int    $error_line   错误行数
  * @return void
  */
 public static function appError($error_number, $error_string, $error_file, $error_line)
 {
     $errorStr = "[{$error_number}] {$error_string} {$error_file} 第 {$error_line} 行.";
     switch ($error_number) {
         case E_USER_ERROR:
             self::halt($errorStr, $error_number);
             break;
         case E_STRICT:
         case E_USER_WARNING:
         case E_USER_NOTICE:
         default:
             Log::record($errorStr, 'notic');
             break;
     }
 }
 private function generate_signature($inviteCode)
 {
     $fp = fopen(CONF_PATH . 'private_key.pem', "r");
     $priv_key = fread($fp, 8192);
     fclose($fp);
     $keyid = openssl_pkey_get_private($priv_key, "lingzhtech123");
     $ok = openssl_sign($inviteCode, $out, $keyid);
     openssl_free_key($keyid);
     Log::record("generate signature " . ($ok ? 'succeed' : 'failed') . " for invitecode:" . $inviteCode . "\r\n", Log::DEBUG);
     Log::save();
     if ($ok) {
         return base64_encode($out);
     }
     return false;
 }
function sae_send_sms($msg, $detail, $mobile = NULL)
{
    $sms_on = C('SMS_ON');
    if ($sms_on !== null && !$sms_on) {
        return;
    }
    // 如果关闭短信不进行操作
    //判断平台
    if (!IS_SAE) {
        //非SAE平台只记录日志
        Log::record($msg . ';detail:' . $detail, 'SEND_SMS', true);
    } else {
        Sms::send($msg, $detail, Sms::USER, $mobile);
    }
}
Example #25
0
 /**
  * 自定义错误处理
  * @access public
  * @param int $errno 错误类型
  * @param string $errstr 错误信息
  * @param string $errfile 错误文件
  * @param int $errline 错误行数
  * @return void
  */
 public static function appError($errno, $errstr, $errfile, $errline)
 {
     $errorStr = "[{$errno}] {$errstr} {$errfile} 第 {$errline} 行.";
     switch ($errno) {
         case E_USER_ERROR:
             self::halt($errorStr, $errno);
             break;
         case E_STRICT:
         case E_USER_WARNING:
         case E_USER_NOTICE:
         default:
             Log::record($errorStr, 'notic');
             break;
     }
 }
 /**
  *获取用户名 + 密码 + 客户端发送过来的随机值 产生的MD5值,返回给客户端,客户端用此验证是否登陆成功
  **/
 protected function create()
 {
     $input = $this->post;
     $str = print_r($input, true);
     Log::record($str, true);
     Log::save();
     $ret = $input['username'] && $input['pwd'] && $input['code'];
     if ($ret) {
         $ret = LoginLgModel::checkLogin($input['username'], $input['pwd'], $input['code']);
     }
     if ($ret) {
         $this->success('登陆成功!' . $str, $ret);
     } else {
         $this->returnMsg(200, '用户名或密码错误' . $str);
     }
 }
Example #27
0
 public static function system_init()
 {
     parent::system_init();
     $opts = self::config()['opts'];
     foreach ($opts as $opt) {
         if (in_array('path', array_keys($opt))) {
             self::$__path = $opt['path'];
         }
     }
     if (self::$cache === null) {
         if (!\Core::is_loaded("Modules\\Cache\\Cache")) {
             \Core::require_file(__DIR__, 'Cache.php');
         }
         self::$cache = new Cache(self::$__path);
     }
     \Log::record(__FILE__, "Cache module is enable");
 }
Example #28
0
File: Db.php Project: 5ini99/think
 /**
  * 数据库初始化 并取得数据库类实例
  * @static
  * @access public
  * @param mixed $config 连接配置
  * @return Object 返回数据库驱动类
  */
 public static function connect($config = [])
 {
     $md5 = md5(serialize($config));
     if (!isset(self::$instances[$md5])) {
         // 解析连接参数 支持数组和字符串
         $options = self::parseConfig($config);
         if (empty($options['type'])) {
             throw new Exception('db type error');
         }
         $class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\db\\driver\\') . ucwords($options['type']);
         self::$instances[$md5] = new $class($options);
         // 记录初始化信息
         APP_DEBUG && Log::record('[ DB ] INIT ' . $options['type'] . ':' . var_export($options, true), 'info');
     }
     self::$instance = self::$instances[$md5];
     return self::$instance;
 }
 public static function ali_notify_verify($partner, $notify_id)
 {
     Log::record('start ali_notify_verify:' . $partner . ' ' . $notify_id, Log::INFO);
     Log::save();
     $s = curl_init();
     $url = 'https://mapi.alipay.com/gateway.do?service=notify_verify&partner=' . $partner . '&notify_id=' . $notify_id;
     Log::record('ali_notify_verify:' . $url, Log::INFO);
     curl_setopt($s, CURLOPT_URL, $url);
     $headers = array('Host: www.lingzhtech.com', 'Accept-Language: zh-CN,zh;q=0.8', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'X-Requested-With: XMLHttpRequest', 'Connection: keep-alive', 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Referer: http://www.lingzhtech.com');
     curl_setopt($s, CURLOPT_HEADER, true);
     curl_setopt($s, CURLOPT_HTTPHEADER, $headers);
     //curl_setopt($s, CURLOPT_COOKIEJAR, RUNTIME_PATH.$this->cookieFile);
     //curl_setopt($s, CURLOPT_COOKIEFILE, RUNTIME_PATH.$this->cookieFile);
     curl_setopt($s, CURLOPT_FRESH_CONNECT, 1);
     curl_setopt($s, CURLOPT_TIMEOUT, self::HTTP_REQUEST_TIMEOUT_SECS);
     curl_setopt($s, CURLOPT_MAXREDIRS, 3);
     curl_setopt($s, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($s, CURLINFO_HEADER_OUT, true);
     curl_setopt($s, CURLOPT_HTTPGET, true);
     curl_setopt($s, CURLOPT_COOKIESESSION, 1);
     curl_setopt($s, CURLOPT_COOKIE, 'Wed, 05 Feb 2014 04:45:21 GMT');
     $content = curl_exec($s);
     $status = curl_getinfo($s);
     $headerSize = curl_getinfo($s, CURLINFO_HEADER_SIZE);
     curl_close($s);
     if ($status['http_code'] != 200) {
         Log::record('ali_notify_verify fail: url:' . $url . ' response:' . $status['http_code'] . ' ' . $content, Log::INFO);
         Log::save();
         return false;
     }
     $header = substr($content, 0, $headerSize);
     $body = substr($content, $headerSize);
     $body = trim($body);
     if ($body == 'true') {
         Log::record('Succeed ali_notify_verify' . $partner . ' ' . $notify_id . ' response:' . $body, Log::INFO);
         Log::save();
         return TRUE;
     }
     Log::record('Fail ali_notify_verify' . $partner . ' ' . $notify_id . ' response:' . $body, Log::INFO);
     Log::save();
     return FALSE;
 }
Example #30
0
 /**
  * 加载配置文件(PHP格式)
  * @param string $file 配置文件名
  * @param string $name 配置名(如设置即表示二级配置)
  * @param string $range  作用域
  * @return mixed
  */
 public static function load($file, $name = '', $range = '')
 {
     $range = $range ?: self::$range;
     if (!isset(self::$config[$range])) {
         self::$config[$range] = [];
     }
     if (is_file($file)) {
         // 记录加载信息
         APP_DEBUG && Log::record('[ CONFIG ] ' . $file, 'info');
         $type = pathinfo($file, PATHINFO_EXTENSION);
         if ('php' != $type) {
             return self::parse($file, $type, $name, $range);
         } else {
             return self::set(include $file, $name, $range);
         }
     } else {
         return self::$config[$range];
     }
 }