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");
 }
 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;
     }
 }
Example #3
0
 public function testRecord()
 {
     $record_msg = 'record';
     Log::record($record_msg, 'notice');
     $logs = Log::getLog();
     $this->assertNotFalse(array_search(['type' => 'notice', 'msg' => $record_msg], $logs));
 }
Example #4
0
 public function testWrite()
 {
     Log::init(['type' => 'test']);
     Log::clear();
     $this->assertTrue(Log::write('hello', 'info'));
     $this->assertTrue(Log::write([1, 2, 3], 'log'));
 }
 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', '数据丢失!');
 }
Example #6
0
 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;
         }
     }
 }
Example #7
0
 public function testRecord()
 {
     $record_msg = 'record';
     Log::record($record_msg, 'notice');
     $logs = Log::getLog();
     $this->assertNotFalse(array_search($record_msg, $logs['notice']));
 }
 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;
 }
Example #9
0
 /**
  * 加载语言定义(不区分大小写)
  * @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];
 }
Example #10
0
 /**
  * 发送模板短信
  * @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;
 }
Example #11
0
 /**
  * 获取插件列表
  * @param string $addon_dir
  * @author jry <*****@*****.**>
  */
 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;
 }
Example #12
0
 /**
  * 构造函数
  */
 public function __construct($modelName = null)
 {
     if (!is_null($modelName)) {
         $this->setUserModelProvider($modelName);
     }
     Log::info('request_cookie', array('request' => $_COOKIE));
 }
Example #13
0
 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;
 }
 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);
 }
 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);
 }
Example #16
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 = 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();
     }
 }
 public function auth()
 {
     $account = I("post.account");
     $pwd = I("post.password");
     Log::record($account . "" . $pwd);
     $all = '{"data":{"account":"*****@*****.**","apiKey":"ed8b72515a1577c26edebf2f2654238d74108b6d","articleVisible":1,"authString":"0,947742853@qq.com,1439045570","brokerDomain":null,"bwTenant":null,"device":null,"email":"*****@*****.**","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;
 }
 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);
 }
 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);
 }
Example #20
0
 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);
 }
Example #21
0
 /**
  * Shutdown Handler
  */
 public static function appShutdown()
 {
     if (!is_null($error = error_get_last()) && self::isFatal($error['type'])) {
         // 将错误信息托管至think\ErrorException
         $exception = new ErrorException($error['type'], $error['message'], $error['file'], $error['line']);
         self::appException($exception);
     }
     // 写入日志
     Log::save();
 }
 function movieStart($movietime)
 {
     \Think\Log::record('开场提示:' . $movietime['pid'] . '-' . $movietime['title']);
     //推送开场提醒
     D('JPush', 'Logic')->pushNotificationByTags(C('PUSH_PARTY_PREFIX') . $movietime['pid'], '你参加的' . $movietime['title'] . '活动即将开始,摇一摇加入社交圈,开启捉影之旅。', null, array("redirect" => "circleentry"));
     //向融云服务器发送创建群组的请求
     $im = D('Im', 'Logic');
     $im->createCircle($movietime['id']);
     M('Socialcircle')->where('id = %d', $movietime['id'])->setField('openstatus', 1);
 }
 public function getForverQrcodeTicket()
 {
     $token = $this->getAccessToken();
     $scene_id = mt_rand(0, 100000);
     $vars = '{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": ' . $scene_id . '}}}';
     Log::write('获得永久二维码ticket需要的参数:' . $vars);
     $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $token;
     $result = postCURL($url, $vars);
     Log::write('获得永久二维码返回ticket返回值:' . $result);
     return json_decode($result, TRUE);
 }
Example #24
0
 /**
  *index
  *api令牌生成
  * 支持操作post
  *@return json,xml
  *@author NewFuture
  */
 public function index()
 {
     $pwd = I('post.pwd');
     $type = I('post.type', null, 'int');
     $Model = null;
     switch ($type) {
         case C('STUDENT'):
         case C('STUDENT_API'):
             $account = I('post.account', 0, C('REGEX_NUMBER'));
             $Model = M('user');
             $where['student_number'] = $account;
             break;
         case C('PRINTER'):
         case C('PRINTER_WEB'):
             $account = I('post.account', null, C('REGEX_ACCOUNT'));
             $Model = M('printer');
             $where['account'] = $account;
             break;
         default:
             $data['err'] = 'unknown user type';
     }
     if (!isset($data)) {
         if ($account) {
             $key = 'api_' . $account;
             $times = S($key);
             if ($times > C('MAX_TRIES')) {
                 \Think\Log::record('api爆破警告:ip:' . get_client_ip() . ',account:' . $account, 'NOTIC', true);
                 $data['err'] = '此账号尝试次数过多,已经暂时封禁,请于一小时后重试!(ps:你的行为已被系统记录)';
             } else {
                 S($key, $times + 1, 3600);
                 $info = $Model->where($where)->field('id,password,name')->find();
                 $id = $info['id'];
                 $password = $info['password'];
                 if ($password == encode($pwd, $account)) {
                     $token = update_token($id, $type);
                     if ($token) {
                         S($key, null);
                         $data['token'] = $token;
                         $data['name'] = $info['name'];
                         $data['id'] = $info['id'];
                     } else {
                         $data['err'] = '创建令牌失败';
                     }
                 } else {
                     $data['err'] = 'authored failed';
                 }
             }
         } else {
             $data['err'] == 'illegal account';
         }
     }
     $data['version'] = C('API_VERSION');
     $this->response($data, $this->_type == 'xml' ? 'xml' : 'json');
 }
Example #25
0
 public function index()
 {
     Log::record('收到消息' . date('Ymd H:m:s') . 'Form:' . get_client_ip());
     $weixin = new ThinkWechat(get_opinion('weixin_token'));
     /* 获取请求信息 */
     $data = $weixin->request();
     /* 获取回复信息 */
     list($content, $type) = $this->reply($data);
     /* 响应当前请求 */
     $weixin->response($content, $type);
     Log::record('发送消息' . date('Ymd H:m:s'));
 }
Example #26
0
 /**
  * 获取Access Token
  * @return null | string
  */
 private function _fetchAccessToken()
 {
     $Curl = new Curl();
     $params['grant_type'] = 'client_credential';
     $params['appid'] = get_opinion('Weixin_appid');
     $params['secret'] = get_opinion('Weixin_secret');
     $accessToken = $Curl->callApi($this::$AccessTokenURL, $params, 'GET');
     if (!isset($accessToken['access_token'])) {
         Log::write("Error occurred when call AccessToken Api");
         return null;
     }
     return $accessToken['access_token'];
 }
Example #27
0
 /**
  * Report or log an exception.
  *
  * @param  \Exception $exception
  * @return void
  */
 public function report(Exception $exception)
 {
     if (!$this->isIgnoreReport($exception)) {
         // 收集异常数据
         if (APP_DEBUG) {
             $data = ['file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'code' => $this->getCode($exception)];
             $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]";
         } else {
             $data = ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
             $log = "[{$data['code']}]{$data['message']}";
         }
         Log::record($log, 'error');
     }
 }
Example #28
0
 /**
  * 显示页面Trace信息
  * @access private
  */
 private function showTrace()
 {
     // 系统默认显示信息
     $files = get_included_files();
     $info = [];
     foreach ($files as $key => $file) {
         $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
     }
     $trace = [];
     Debug::remark('START', NOW_TIME);
     $base = ['请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['PHP_SELF'], '运行时间' => Debug::getUseTime('START', 'END', 6) . 's', '内存开销' => MEMORY_LIMIT_ON ? G('START', 'END', 'm') . 'b' : '不支持', '查询信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加载' => count($files), '缓存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '配置加载' => count(Config::get())];
     // 读取项目定义的Trace文件
     $traceFile = MODULE_PATH . 'trace.php';
     if (is_file($traceFile)) {
         $base = array_merge($base, include $traceFile);
     }
     $debug = Log::getLog();
     $tabs = Config::get('trace_page_tabs');
     foreach ($tabs as $name => $title) {
         switch (strtoupper($name)) {
             case 'BASE':
                 // 基本信息
                 $trace[$title] = $base;
                 break;
             case 'FILE':
                 // 文件信息
                 $trace[$title] = $info;
                 break;
             default:
                 // 调试信息
                 $name = strtoupper($name);
                 if (strpos($name, '|')) {
                     // 多组信息
                     $array = explode('|', $name);
                     $result = [];
                     foreach ($array as $name) {
                         $result += isset($debug[$name]) ? $debug[$name] : [];
                     }
                     $trace[$title] = $result;
                 } else {
                     $trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
                 }
         }
     }
     unset($files, $info, $base, $debug);
     // 调用Trace页面模板
     ob_start();
     include Config::has('tmpl_trace_file') ? Config::get('tmpl_trace_file') : THINK_PATH . 'tpl/page_trace.tpl';
     return ob_get_clean();
 }
Example #29
0
 /**
  * 获取插件列表
  * @param string $addon_dir
  */
 public function getList($addon_dir = '')
 {
     if (!$addon_dir) {
         $addon_dir = ONETHINK_ADDON_PATH;
     }
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     //TODO 新增模块插件的支持
     /* $modules=D('Module')->getAll();
        foreach($modules as $m){
            if($m['is_setup']){
                $module_dir=APP_PATH.$m['name'].'/Addons/';
                if(!file_exists($module_dir)){
                    continue;
                }
                $tmp_dirs = array_map('basename',glob($module_dir.'*', GLOB_ONLYDIR));
                $dirs=array_merge($dirs,$tmp_dirs);
            }
        }*/
     if ($dirs === FALSE || !file_exists($addon_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return FALSE;
     }
     $addons = array();
     $where['name'] = array('in', $dirs);
     $list = $this->where($where)->field(true)->select();
     foreach ($list as $addon) {
         $addon['uninstall'] = 0;
         $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]['uninstall'] = 1;
                 unset($addons[$value]['status']);
             }
         }
     }
     //dump($list);exit;
     int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装')));
     $addons = list_sort_by($addons, 'uninstall', 'desc');
     return $addons;
 }
Example #30
0
File: Log.php Project: GDdark/cici
 /**
  * 日志初始化
  * @param array $config
  */
 public static function init($config = [])
 {
     $type = isset($config['type']) ? $config['type'] : 'File';
     $class = false !== strpos($type, '\\') ? $type : '\\think\\log\\driver\\' . ucwords($type);
     self::$config = $config;
     unset($config['type']);
     if (class_exists($class)) {
         self::$driver = new $class($config);
     } else {
         throw new ClassNotFoundException('class not exists:' . $class, $class);
     }
     // 记录初始化信息
     App::$debug && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info');
 }