php think-Log类(方法)实例源码

下面列出了php think-Log 类(方法)源码代码实例,从而了解它的用法。

作者:xiaoxianlin    项目:zini   
public function index()
 {
     if (!isset($_GET['code'])) {
         $redirect_uri = URL2;
         $scope = 'snsapi_base';
         $log = new Log();
         $log->write("order请求", 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y/m/d') . '.log');
         $this->oauth($redirect_uri, $scope);
         // $this->get_city();
     } else {
         $code = (string) $_GET['code'];
         $open_id = $this->get_oauth_openid($code);
         $log = new Log();
         $log->write("order微信回调", 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y/m/d') . '.log');
     }
     $user_model = M("User");
     $where = array('openid' => (string) $open_id);
     $user = $user_model->where($where)->find();
     $user_id = $user['id'];
     $orderlist = $this->get_user_order($user_id);
     /*
      * $msg = $this->get_endorsement (); print_r ( $msg );
      */
     $order_status = array(1 => '未支付', 2 => '确认中', 3 => '处理中', 5 => '已处理', 6 => '退款中', 7 => '已退款', 8 => '已取消');
     $this->assign('user_id', $user_id);
     $this->assign('order_status', $order_status);
     $this->assign('orderlist', $orderlist);
     $this->display(":order");
 }

作者:xiaoxianlin    项目:zini   
public function sendWeiXin($touser, $template_id, $url, $data, $topcolor = '#7B68EE')
 {
     $log = new Log();
     $template = array('touser' => $touser, 'template_id' => $template_id, 'url' => $url, 'topcolor' => $topcolor, 'data' => $data);
     $json_template = json_encode($template);
     $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $this->get_access_token();
     $dataRes = $this->request_post($url, urldecode($json_template));
     $log->write(serialize($dataRes), 'DEBUG', '', dirname($_SERVER['SCRIPT_FILENAME']) . '/Logs/Weixin/' . date('y_m_d') . '.log');
     if ($dataRes['errcode'] == 0) {
         return true;
     } else {
         return false;
     }
 }

作者:Lofanm    项目:thin   
public function testRecord()
 {
     $record_msg = 'record';
     Log::record($record_msg, 'notice');
     $logs = Log::getLog();
     $this->assertNotFalse(array_search(['type' => 'notice', 'msg' => $record_msg], $logs));
 }

作者:Lofanm    项目:thin   
public function testWrite()
 {
     Log::init(['type' => 'test']);
     Log::clear();
     $this->assertTrue(Log::write('hello', 'info'));
     $this->assertTrue(Log::write([1, 2, 3], 'log'));
 }

作者:xiaowei52    项目:future-   
public function j_email()
 {
     // 如果
     if (isset($_POST['em'])) {
         $email = $_POST['em'];
         $account_model = D('Account');
         // 证明已经注册过
         if ($account_model->judge_account_id_isset($email)) {
             Response::show('-101', '该邮箱已经被注册!');
         } else {
             // 发送给用户的信息
             $rand_string = strtolower(rand_string());
             $title = '欢迎您注册!么么哒。';
             $content = '您好,您的注册验证码是 : ' . $rand_string . '   !, 如果不是本人操作,请忽略!';
             $Memcached = Memcached::getInstance();
             // 暂时不加密了。
             $Memcached->set($email, $rand_string);
             if (SendMail($email, $title, $content) === true) {
                 Response::show('200', '已经发送验证码,请注意查收!');
             } else {
                 Log::write('发送验证码失败,to [--' . $email . '--]', 'WARN');
                 Response::show('-102', '邮件发送失败,未知原因!');
             }
         }
     }
     Response::show('-103', '数据丢失!');
 }

作者:rainly12    项目:zyz   
public function sendsms()
 {
     if (IS_POST) {
         $mac = md5($_POST['time'] . C('SMSKEY'));
         if ($mac != $_POST['mac']) {
             return false;
         }
         if (empty($_POST['content']) || empty($_POST['phone'])) {
             return false;
         }
         $path = C('LOG_PATH') . 'sms.txt';
         Log::write($_POST['phone'] . ':' . $_POST['content'], 'SMS-CONTENT', '', $path);
         $data = array('userid' => 416, 'account' => 'HY-jmzc', 'password' => 'Hj1234', 'mobile' => $_POST['phone'], 'content' => $_POST['content'], 'sendTime' => '', 'action' => 'send', 'checkcontent' => '0', 'taskName' => '', 'countnumber' => $_POST['count'], 'mobilenumber' => $_POST['count'], 'telephonenumber' => 0);
         // 短信发送
         $xml = curlPost($this->url, $data);
         Log::write($xml, 'SMS-CONTENT', '', $path);
         $res = simplexml_load_string($xml);
         $arr = json_decode(json_encode($res), true);
         if ($arr['returnstatus'] == 'Success') {
             echo true;
         } else {
             echo false;
         }
     }
 }

作者:top-thin    项目:framewor   
public function testRecord()
 {
     $record_msg = 'record';
     Log::record($record_msg, 'notice');
     $logs = Log::getLog();
     $this->assertNotFalse(array_search($record_msg, $logs['notice']));
 }

作者:foryoufen    项目:thinkmobil   
public function NotifyProcess($data, &$msg)
 {
     Log::write(json_encode($data));
     //记录下支付信息
     if (!array_key_exists("transaction_id", $data)) {
         $msg = "输入参数不正确";
         return false;
     }
     //查询订单,判断订单真实性
     if (!$this->Queryorder($data["transaction_id"])) {
         $msg = "订单查询失败";
         return false;
     }
     $order = D('Order');
     $order_info = $order->getOne(array('order_id' => $data['out_trade_no'], 'phone' => $data['attach']));
     if ($order_info && $order_info['status'] == 0) {
         $order_info['status'] = 1;
         $result = $order->editData($order_info);
         if ($result == CommonModel::MSUCCESS) {
             $point = D('Pointlog');
             $point->log($order_info['user_id'], $order_info['point'], "订单" . $order_info['order_id'] . " 使用了" . $order_info['point'] . "积分", PointlogModel::DEC);
             $money = $order_info['total'] / 100;
             $addpiont = intval($money / C('DEVPOINT'));
             $point->log($order_info['user_id'], $addpiont, "订单" . $order_info['order_id'] . " 获得了" . $addpiont . "积分", PointlogModel::ADD);
         }
     }
     return true;
 }

作者:xuyi591    项目:ipensof   
/**
  * 加载语言定义(不区分大小写)
  * @param string $file 语言文件
  * @param string $range 语言作用域
  * @return mixed
  */
 public static function load($file, $range = '')
 {
     $range = $range ?: self::$range;
     if (!isset(self::$lang[$range])) {
         self::$lang[$range] = [];
     }
     // 批量定义
     if (is_string($file)) {
         $file = [$file];
     }
     $lang = [];
     foreach ($file as $_file) {
         if (is_file($_file)) {
             // 记录加载信息
             APP_DEBUG && Log::record('[ LANG ] ' . $_file, 'info');
             $_lang = (include $_file);
         } else {
             $_lang = [];
         }
         $lang = array_change_key_case($_lang) + $lang;
     }
     if (!empty($lang)) {
         self::$lang[$range] = $lang + self::$lang[$range];
     }
     return self::$lang[$range];
 }

作者:Emon052    项目:zhuoying-w   
/**
  * 发送模板短信
  * @param String $to 短信接收彿手机号码集合,用英文逗号分开
  * @param array $datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
  * @param int $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
  * @return 内容数据|mixed
  */
 function sendTemplateSMS($to, $datas, $tempId)
 {
     $this->Batch = date("YmdHis");
     // 拼接请求包体
     $data = "";
     for ($i = 0; $i < count($datas); $i++) {
         $data = $data . "'" . $datas[$i] . "',";
     }
     $body = "{'to':'{$to}','templateId':'{$tempId}','appId':'{$this->AppId}','datas':[" . $data . "]}";
     $level = Log::INFO;
     Log::record("response body = " . $body, $level);
     // 大写的sig参数
     $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
     // 生成请求URL
     $url = "https://{$this->ServerIP}:{$this->ServerPort}/{$this->SoftVersion}/Accounts/{$this->AccountSid}/SMS/TemplateSMS?sig={$sig}";
     Log::record("request url = " . $url, $level);
     // 生成授权:主帐户Id + 英文冒号 + 时间戳。
     $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
     // 生成包头
     $header = array("Accept:application/{$this->BodyType}", "Content-Type:application/{$this->BodyType};charset=utf-8", "Authorization:{$authen}");
     // 发送请求
     $result = $this->curl_post($url, $body, $header);
     Log::record("response body = " . $result, $level);
     $datas = json_decode($result);
     //重新装填数据
     if ($datas->statusCode == 0) {
         if ($this->BodyType == "json") {
             $datas->TemplateSMS = $datas->templateSMS;
             unset($datas->templateSMS);
         }
     }
     return $datas;
 }

作者:sayi21c    项目:corethin   
/**
  * 获取插件列表
  * @param string $addon_dir
  * @author jry <598821125@qq.com>
  */
 public function getAllAddon($addon_dir = THINK_ADDON_PATH)
 {
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     if ($dirs === FALSE || !file_exists($addon_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return FALSE;
     }
     $addons = array();
     $map['name'] = array('in', $dirs);
     $list = $this->where($map)->field(true)->order('sort asc,id desc')->select();
     foreach ($list as $addon) {
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['status'] = -1;
                 //未安装
             }
         }
     }
     foreach ($addons as &$val) {
         switch ($val['status']) {
             case '-1':
                 //未安装
                 $val['status'] = '<i class="glyphicon glyphicon-trash" style="color:red"></i>';
                 $val['right_button'] = '<a class="ajax-get" href="' . U('install?addon_name=' . $val['name']) . '">安装</a>';
                 break;
             case '0':
                 //禁用
                 $val['status'] = '<i class="glyphicon glyphicon-ban-circle" style="color:red"></i>';
                 $val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'resume', 'ids' => $val['id'])) . '">启用</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
                 if ($val['adminlist']) {
                     $val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
                 }
                 break;
             case '1':
                 //正常
                 $val['status'] = '<i class="glyphicon glyphicon-ok" style="color:green"></i>';
                 $val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'forbid', 'ids' => $val['id'])) . '">禁用</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
                 if ($val['adminlist']) {
                     $val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
                 }
                 break;
         }
     }
     return $addons;
 }

作者:minow    项目:smartthin   
/**
  * 构造函数
  */
 public function __construct($modelName = null)
 {
     if (!is_null($modelName)) {
         $this->setUserModelProvider($modelName);
     }
     Log::info('request_cookie', array('request' => $_COOKIE));
 }

作者:torry99    项目:lingsh   
protected function _sock_post($url, $query)
 {
     $data = "";
     $info = parse_url($url);
     $fp = fsockopen($info["host"], 80, $errno, $errstr, 30);
     if (!$fp) {
         return $data;
     }
     $head = "POST " . $info['path'] . " HTTP/1.0\r\n";
     $head .= "Host: " . $info['host'] . "\r\n";
     $head .= "Referer: http://" . $info['host'] . $info['path'] . "\r\n";
     $head .= "Content-type: application/x-www-form-urlencoded\r\n";
     $head .= "Content-Length: " . strlen(trim($query)) . "\r\n";
     $head .= "\r\n";
     $head .= trim($query);
     $write = fputs($fp, $head);
     $header = "";
     while ($str = trim(fgets($fp, 4096))) {
         $header .= $str;
     }
     while (!feof($fp)) {
         $data .= fgets($fp, 4096);
     }
     $ret = json_decode($data, true);
     if (!$ret) {
         \Think\Log::write('无法解析短信接口返回值:' . $data);
         return false;
     }
     return $ret;
 }

作者:lnmpo    项目:wechat_t   
public function index($arr = array())
 {
     Log::write('开始调用ResponseUnknowMessageController@index并获得参数' . json_encode($arr));
     $fromusername = $arr['fromusername'];
     $tousername = $arr['tousername'];
     $content = '[Cry][Cry][Cry]暂时不支持处理您的消息类型';
     $this->sendTextMessage($fromusername, $tousername, $content);
 }

作者:lnmpo    项目:wechat_t   
public function index($arr = array())
 {
     Log::write('开始调用ResponseImageMessageController@index并获得参数' . json_encode($arr));
     $fromusername = $arr['fromusername'];
     $tousername = $arr['tousername'];
     $mediaid = $arr['mediaid'];
     $this->sendImageMessage($fromusername, $tousername, $mediaid);
 }

作者:GDdar    项目:cic   
/**
  * 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 = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']);
         // 检查驱动类
         if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
             throw new ClassNotFoundException('error session handler:' . $class, $class);
         }
     }
     if ($isDoStart) {
         session_start();
     }
 }

作者:huzhengchua    项目:trade   
public function auth()
 {
     $account = I("post.account");
     $pwd = I("post.password");
     Log::record($account . "" . $pwd);
     $all = '{"data":{"account":"947742853@qq.com","apiKey":"ed8b72515a1577c26edebf2f2654238d74108b6d","articleVisible":1,"authString":"0,947742853@qq.com,1439045570","brokerDomain":null,"bwTenant":null,"device":null,"email":"947742853@qq.com","expiredAt":1443862842,"guest":false,"ip":"222.41.113.210","locale":"zh","login":null,"mt4Group":null,"nickname":"test123","phone":null,"randomKey":null,"serviceId":null,"symbols":null,"tenantId":"0","tenantName":null,"token":"1439112842,266,24e8bc0ef5","twTimeout":30,"userAvatar":"https://p-picture.b0.upaiyun.com/default_avatar.jpg","userId":266,"verification":null},"message":"登录成功","result":1}';
     $data = json_decode($all);
     echo $all;
 }

作者:lnmpo    项目:wechat_t   
public function createMenu()
 {
     Log::write("开始创建自定义菜单");
     $access_token = $this->getAccessToken();
     $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token;
     $vars = C('MENU_ONE');
     $result = postCURL($url, $vars);
     Log::write("创建自定义菜单返回消息:" . $result);
 }

作者:lnmpo    项目:wechat_t   
public function setForeverImageSource()
 {
     $access_token = $this->getAccessToken();
     $path = "/var/www/v.vxndy.com/Public/images/shasha.jpg";
     $vars = array('media' => '@' . $path);
     $url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=" . $access_token;
     $result = postCURL($url, $vars);
     Log::write('新增永久素材返回信息:' . $result);
 }

作者:lizhu    项目:thinkuni   
public function buildRequestForm(\Org\Util\Pay\PayVo $vo)
 {
     $param = array('nonce_str' => (string) mt_rand(), 'spbill_create_ip' => get_client_ip(), 'device_info' => 'WEB', 'appid' => $this->config['appid'], 'mch_id' => $this->config['mch_id'], 'notify_url' => $this->config['notify_url'], 'out_trade_no' => $vo->getOrderNo(), 'body' => $vo->getTitle(), 'detail' => $vo->getBody(), 'total_fee' => $vo->getFee(), 'trade_type' => $vo->getType(), 'product_id' => $vo->getId(), 'openid' => $vo->getOpenid());
     \Think\Log::write("11111" . $this->config['notify_url']);
     $param['sign'] = $this->signatureArithmetic($param);
     $param = $this->xml_encode($param);
     $order = $this->fsockOpen($this->gateway, 0, $param);
     return (array) simplexml_load_string($order, 'SimpleXMLElement', LIBXML_NOCDATA);
 }


问题


面经


文章

微信
公众号

扫码关注公众号