yhdsir@function:php
curl 获取页面信息
function curl_get_content($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97'); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
// curl_setopt($curl, CURLOPT_HTTPHEADER, $refer);
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 1); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 $res = curl_exec($curl);
curl_close($curl);
return $res;
}
调试用
function p($str)
{
echo '<pre>';
print_r($str);
echo '</pre>';
}
罗飞老师的socketLog、项目地址:https://github.com/luofei614/SocketLog
<?php
/**
* github: https://github.com/luofei614/SocketLog
* @author luofei614<weibo.com/luofei614>
*/
function slog($log,$type='log',$css='')
{
if(is_string($type))
{
$type=preg_replace_callback('/_([a-zA-Z])/',create_function('$matches', 'return strtoupper($matches[1]);'),$type);
if(method_exists('SocketLog',$type) || in_array($type,SocketLog::$log_types))
{
return call_user_func(array('SocketLog',$type),$log,$css);
}
} if(is_object($type) && 'mysqli'==get_class($type))
{
return SocketLog::mysqlilog($log,$type);
} if(is_resource($type) && ('mysql link'==get_resource_type($type) || 'mysql link persistent'==get_resource_type($type)))
{
return SocketLog::mysqllog($log,$type);
} if(is_object($type) && 'PDO'==get_class($type))
{
return SocketLog::pdolog($log,$type);
} throw new Exception($type.' is not SocketLog method');
} class SocketLog
{
public static $start_time=0;
public static $start_memory=0;
public static $port=1116;//SocketLog 服务的http的端口号
public static $log_types=array('log','info','error','warn','table','group','groupCollapsed','groupEnd','alert'); protected static $_instance; protected static $config=array(
'host'=>'localhost',
//是否显示利于优化的参数,如果允许时间,消耗内存等
'optimize'=>false,
'show_included_files'=>false,
'error_handler'=>false,
//日志强制记录到配置的client_id
'force_client_id'=>'',
//限制允许读取日志的client_id
'allow_client_ids'=>array()
); protected static $logs=array(); protected static $css=array(
'sql'=>'color:#009bb4;',
'sql_warn'=>'color:#009bb4;font-size:14px;',
'error_handler'=>'color:#f4006b;font-size:14px;',
'page'=>'color:#40e2ff;background:#171717;'
); public static function __callStatic($method,$args)
{
if(in_array($method,self::$log_types))
{
array_unshift($args,$method);
return call_user_func_array(array(self::getInstance(),'record'),$args);
}
} public static function big($log)
{
self::log($log,'font-size:20px;color:red;');
} public static function trace($msg,$trace_level=2,$css='')
{
if(!self::check())
{
return ;
}
self::groupCollapsed($msg,$css);
$traces=debug_backtrace(false);
$traces=array_reverse($traces);
$max=count($traces)-$trace_level;
for($i=0;$i<$max;$i++){
$trace=$traces[$i];
$fun=isset($trace['class'])?$trace['class'].'::'.$trace['function']:$trace['function'];
$file=isset($trace['file'])?$trace['file']:'unknown file';
$line=isset($trace['line'])?$trace['line']:'unknown line';
$trace_msg='#'.$i.' '.$fun.' called at ['.$file.':'.$line.']';
if(!empty($trace['args'])){
self::groupCollapsed($trace_msg);
self::log($trace['args']);
self::groupEnd();
}else{
self::log($trace_msg);
}
}
self::groupEnd();
} public static function mysqlilog($sql,$db)
{
if(!self::check())
{
return ;
} $css=self::$css['sql'];
if(preg_match('/^SELECT /i', $sql))
{
//explain
$query = @mysqli_query($db,"EXPLAIN ".$sql);
$arr=mysqli_fetch_array($query);
self::sqlexplain($arr,$sql,$css);
}
self::sqlwhere($sql,$css);
self::trace($sql,2,$css);
} public static function mysqllog($sql,$db)
{
if(!self::check())
{
return ;
}
$css=self::$css['sql'];
if(preg_match('/^SELECT /i', $sql))
{
//explain
$query = @mysql_query("EXPLAIN ".$sql,$db);
$arr=mysql_fetch_array($query);
self::sqlexplain($arr,$sql,$css);
}
//判断sql语句是否有where
self::sqlwhere($sql,$css);
self::trace($sql,2,$css);
} public static function pdolog($sql,$pdo)
{
if(!self::check())
{
return ;
}
$css=self::$css['sql'];
if(preg_match('/^SELECT /i', $sql))
{
//explain
try {
$obj=$pdo->query( "EXPLAIN ".$sql);
if(is_object($obj) && method_exists($obj,'fetch'))
{
$arr=$obj->fetch(PDO::FETCH_ASSOC);
self::sqlexplain($arr,$sql,$css);
}
} catch (Exception $e) { }
}
self::sqlwhere($sql,$css);
self::trace($sql,2,$css);
} private static function sqlexplain($arr,&$sql,&$css)
{
$arr = array_change_key_case($arr, CASE_LOWER);
if(false!==strpos($arr['extra'],'Using filesort'))
{
$sql.=' <---################[Using filesort]';
$css=self::$css['sql_warn'];
}
if(false!==strpos($arr['extra'],'Using temporary'))
{
$sql.=' <---################[Using temporary]';
$css=self::$css['sql_warn'];
}
}
private static function sqlwhere(&$sql,&$css)
{
//判断sql语句是否有where
if(preg_match('/^UPDATE |DELETE /i',$sql) && !preg_match('/WHERE.*(=|>|<|LIKE|IN)/i',$sql))
{
$sql.='<---###########[NO WHERE]';
$css=self::$css['sql_warn'];
}
} /**
* 接管报错
*/
public static function registerErrorHandler()
{
if(!self::check())
{
return ;
} set_error_handler(array(__CLASS__,'error_handler'));
register_shutdown_function(array(__CLASS__,'fatalError'));
} public static function error_handler($errno, $errstr, $errfile, $errline)
{
switch($errno){
case E_WARNING: $severity = 'E_WARNING'; break;
case E_NOTICE: $severity = 'E_NOTICE'; break;
case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
case E_USER_WARNING: $severity = 'E_USER_WARNING'; break;
case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break;
case E_STRICT: $severity = 'E_STRICT'; break;
case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break;
case E_DEPRECATED: $severity = 'E_DEPRECATED'; break;
case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break;
case E_ERROR: $severity = 'E_ERR'; break;
case E_PARSE: $severity = 'E_PARSE'; break;
case E_CORE_ERROR: $severity = 'E_CORE_ERROR'; break;
case E_COMPILE_ERROR: $severity = 'E_COMPILE_ERROR'; break;
case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
default: $severity= 'E_UNKNOWN_ERROR_'.$errno; break;
}
$msg="{$severity}: {$errstr} in {$errfile} on line {$errline} -- SocketLog error handler";
self::trace($msg,2,self::$css['error_handler']);
} public static function fatalError()
{
// 保存日志记录
if ($e = error_get_last())
{
self::error_handler($e['type'],$e['message'],$e['file'],$e['line']);
self::sendLog();//此类终止不会调用类的 __destruct 方法,所以此处手动sendLog
}
} public static function getInstance()
{
if (self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
} protected static function _log($type,$logs,$css='')
{
self::getInstance()->record($type,$logs,$css);
} protected static function check()
{
$tabid=self::getClientArg('tabid');
//是否记录日志的检查
if(!$tabid && !self::getConfig('force_client_id'))
{
return false;
}
//用户认证
$allow_client_ids=self::getConfig('allow_client_ids');
if(!empty($allow_client_ids))
{
if (!$tabid && in_array(self::getConfig('force_client_id'), $allow_client_ids)) {
return true;
} $client_id=self::getClientArg('client_id');
if(!in_array($client_id,$allow_client_ids))
{
return false;
}
}
return true;
} protected static function getClientArg($name)
{
static $args=array(); $key = 'HTTP_USER_AGENT'; if (isset($_SERVER['HTTP_SOCKETLOG'])) {
$key = 'HTTP_SOCKETLOG';
} if(!isset($_SERVER[$key]))
{
return null;
}
if(empty($args))
{
if(!preg_match('/SocketLog\((.*?)\)/',$_SERVER[$key],$match))
{
$args=array('tabid'=>null);
return null;
}
parse_str($match[1],$args);
}
if(isset($args[$name]))
{
return $args[$name];
}
return null;
} //设置配置
public static function setConfig($config)
{
$config=array_merge(self::$config,$config);
self::$config=$config;
if(self::check())
{
self::getInstance(); //强制初始化SocketLog实例
if($config['optimize'])
{
self::$start_time=microtime(true);
self::$start_memory=memory_get_usage();
} if($config['error_handler'])
{
self::registerErrorHandler();
}
}
} //获得配置
public static function getConfig($name)
{
if(isset(self::$config[$name]))
return self::$config[$name];
return null;
} //记录日志
public function record($type,$msg='',$css='')
{
if(!self::check())
{
return ;
} self::$logs[]=array(
'type'=>$type,
'msg'=>$msg,
'css'=>$css
);
} /**
* @param null $host - $host of socket server
* @param string $message - 发送的消息
* @param string $address - 地址
* @return bool
*/
public static function send($host,$message='',$address='/')
{
$url='http://'.$host.':'.self::$port.$address;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$headers=array(
"Content-Type: application/json;charset=UTF-8"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//设置header
$txt = curl_exec($ch);
return true;
} public static function sendLog()
{
if(!self::check())
{
return ;
} $time_str='';
$memory_str='';
if(self::$start_time)
{
$runtime=microtime(true)-self::$start_time;
$reqs=number_format(1/$runtime,2);
$time_str="[运行时间:{$runtime}s][吞吐率:{$reqs}req/s]";
}
if(self::$start_memory)
{
$memory_use=number_format(memory_get_usage()-self::$start_memory/1024,2);
$memory_str="[内存消耗:{$memory_use}kb]";
} if(isset($_SERVER['HTTP_HOST']))
{
$current_uri=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
else
{
$current_uri="cmd:".implode(' ',$_SERVER['argv']);
}
array_unshift(self::$logs,array(
'type'=>'group',
'msg'=>$current_uri.$time_str.$memory_str,
'css'=>self::$css['page']
)); if(self::getConfig('show_included_files'))
{
self::$logs[]=array(
'type'=>'groupCollapsed',
'msg'=>'included_files',
'css'=>''
);
self::$logs[]=array(
'type'=>'log',
'msg'=>implode("\n",get_included_files()),
'css'=>''
);
self::$logs[]=array(
'type'=>'groupEnd',
'msg'=>'',
'css'=>'',
);
} self::$logs[]=array(
'type'=>'groupEnd',
'msg'=>'',
'css'=>'',
); $tabid=self::getClientArg('tabid');
if(!$client_id=self::getClientArg('client_id'))
{
$client_id='';
}
if($force_client_id=self::getConfig('force_client_id'))
{
$client_id=$force_client_id;
}
$logs=array(
'tabid'=>$tabid,
'client_id'=>$client_id,
'logs'=>self::$logs,
'force_client_id'=>$force_client_id,
);
$msg=@json_encode($logs);
$address='/'.$client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁
self::send(self::getConfig('host'),$msg,$address); } public function __destruct()
{
self::sendLog();
} }
socketLog
socketLog.class.php 下载地址:http://pan.baidu.com/s/1ntEjEe1
socketLog基本配置
<?php include './SocketLog.class.php'; slog(array(
'host' => 'localhost', //websocket服务器地址,默认localhost
'port' => '1229', //websocket服务器端口,默认端口是1229
'optimize' => false, //是否显示利于优化的参数,如果运行时间,消耗内存等,默认为false
'show_included_files' => false, //是否显示本次程序运行加载了哪些文件,默认为false
'error_handler' => false, //是否接管程序错误,将程序错误显示在console中,默认为false
'force_client_id' => '', //日志强制记录到配置的client_id,默认为空
'allow_client_ids' => array()////限制允许读取日志的client_id,默认为空,表示所有人都可以获得日志。
)
, 'set_config');
<?php
/**
* github: https://github.com/luofei614/SocketLog
* @author luofei614<weibo.com/luofei614>
*/
function slog($log,$type='log',$css='')
{
if(is_string($type))
{
$type=preg_replace_callback('/_([a-zA-Z])/',create_function('$matches', 'return strtoupper($matches[1]);'),$type);
if(method_exists('SocketLog',$type) || in_array($type,SocketLog::$log_types))
{
return call_user_func(array('SocketLog',$type),$log,$css);
}
} if(is_object($type) && 'mysqli'==get_class($type))
{
return SocketLog::mysqlilog($log,$type);
} if(is_resource($type) && ('mysql link'==get_resource_type($type) || 'mysql link persistent'==get_resource_type($type)))
{
return SocketLog::mysqllog($log,$type);
} if(is_object($type) && 'PDO'==get_class($type))
{
return SocketLog::pdolog($log,$type);
} throw new Exception($type.' is not SocketLog method');
} class SocketLog
{
public static $start_time=0;
public static $start_memory=0;
public static $port=1116;//SocketLog 服务的http的端口号
public static $log_types=array('log','info','error','warn','table','group','groupCollapsed','groupEnd','alert'); protected static $_instance; protected static $config=array(
'host'=>'localhost',
//是否显示利于优化的参数,如果允许时间,消耗内存等
'optimize'=>true,
'show_included_files'=>false,
'error_handler'=>true,
//日志强制记录到配置的client_id
'force_client_id'=>'',
//限制允许读取日志的client_id
array('yhdsir_log', 'yhdsir_loger'),
); protected static $logs=array(); protected static $css=array(
'sql'=>'color:#009bb4;',
'sql_warn'=>'color:#009bb4;font-size:14px;',
'error_handler'=>'color:#f4006b;font-size:14px;',
'page'=>'color:#40e2ff;background:#171717;'
); public static function __callStatic($method,$args)
{
if(in_array($method,self::$log_types))
{
array_unshift($args,$method);
return call_user_func_array(array(self::getInstance(),'record'),$args);
}
} public static function big($log)
{
self::log($log,'font-size:20px;color:red;');
} public static function trace($msg,$trace_level=2,$css='')
{
if(!self::check())
{
return ;
}
self::groupCollapsed($msg,$css);
$traces=debug_backtrace(false);
$traces=array_reverse($traces);
$max=count($traces)-$trace_level;
for($i=0;$i<$max;$i++){
$trace=$traces[$i];
$fun=isset($trace['class'])?$trace['class'].'::'.$trace['function']:$trace['function'];
$file=isset($trace['file'])?$trace['file']:'unknown file';
$line=isset($trace['line'])?$trace['line']:'unknown line';
$trace_msg='#'.$i.' '.$fun.' called at ['.$file.':'.$line.']';
if(!empty($trace['args'])){
self::groupCollapsed($trace_msg);
self::log($trace['args']);
self::groupEnd();
}else{
self::log($trace_msg);
}
}
self::groupEnd();
} public static function mysqlilog($sql,$db)
{
if(!self::check())
{
return ;
} $css=self::$css['sql'];
if(preg_match('/^SELECT /i', $sql))
{
//explain
$query = @mysqli_query($db,"EXPLAIN ".$sql);
$arr=mysqli_fetch_array($query);
self::sqlexplain($arr,$sql,$css);
}
self::sqlwhere($sql,$css);
self::trace($sql,2,$css);
} public static function mysqllog($sql,$db)
{
if(!self::check())
{
return ;
}
$css=self::$css['sql'];
if(preg_match('/^SELECT /i', $sql))
{
//explain
$query = @mysql_query("EXPLAIN ".$sql,$db);
$arr=mysql_fetch_array($query);
self::sqlexplain($arr,$sql,$css);
}
//判断sql语句是否有where
self::sqlwhere($sql,$css);
self::trace($sql,2,$css);
} public static function pdolog($sql,$pdo)
{
if(!self::check())
{
return ;
}
$css=self::$css['sql'];
if(preg_match('/^SELECT /i', $sql))
{
//explain
try {
$obj=$pdo->query( "EXPLAIN ".$sql);
if(is_object($obj) && method_exists($obj,'fetch'))
{
$arr=$obj->fetch(PDO::FETCH_ASSOC);
self::sqlexplain($arr,$sql,$css);
}
} catch (Exception $e) { }
}
self::sqlwhere($sql,$css);
self::trace($sql,2,$css);
} private static function sqlexplain($arr,&$sql,&$css)
{
$arr = array_change_key_case($arr, CASE_LOWER);
if(false!==strpos($arr['extra'],'Using filesort'))
{
$sql.=' <---################[Using filesort]';
$css=self::$css['sql_warn'];
}
if(false!==strpos($arr['extra'],'Using temporary'))
{
$sql.=' <---################[Using temporary]';
$css=self::$css['sql_warn'];
}
}
private static function sqlwhere(&$sql,&$css)
{
//判断sql语句是否有where
if(preg_match('/^UPDATE |DELETE /i',$sql) && !preg_match('/WHERE.*(=|>|<|LIKE|IN)/i',$sql))
{
$sql.='<---###########[NO WHERE]';
$css=self::$css['sql_warn'];
}
} /**
* 接管报错
*/
public static function registerErrorHandler()
{
if(!self::check())
{
return ;
} set_error_handler(array(__CLASS__,'error_handler'));
register_shutdown_function(array(__CLASS__,'fatalError'));
} public static function error_handler($errno, $errstr, $errfile, $errline)
{
switch($errno){
case E_WARNING: $severity = 'E_WARNING'; break;
case E_NOTICE: $severity = 'E_NOTICE'; break;
case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
case E_USER_WARNING: $severity = 'E_USER_WARNING'; break;
case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break;
case E_STRICT: $severity = 'E_STRICT'; break;
case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break;
case E_DEPRECATED: $severity = 'E_DEPRECATED'; break;
case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break;
case E_ERROR: $severity = 'E_ERR'; break;
case E_PARSE: $severity = 'E_PARSE'; break;
case E_CORE_ERROR: $severity = 'E_CORE_ERROR'; break;
case E_COMPILE_ERROR: $severity = 'E_COMPILE_ERROR'; break;
case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
default: $severity= 'E_UNKNOWN_ERROR_'.$errno; break;
}
$msg="{$severity}: {$errstr} in {$errfile} on line {$errline} -- SocketLog error handler";
self::trace($msg,2,self::$css['error_handler']);
} public static function fatalError()
{
// 保存日志记录
if ($e = error_get_last())
{
self::error_handler($e['type'],$e['message'],$e['file'],$e['line']);
self::sendLog();//此类终止不会调用类的 __destruct 方法,所以此处手动sendLog
}
} public static function getInstance()
{
if (self::$_instance === null) {
self::$_instance = new self();
}
return self::$_instance;
} protected static function _log($type,$logs,$css='')
{
self::getInstance()->record($type,$logs,$css);
} protected static function check()
{
$tabid=self::getClientArg('tabid');
//是否记录日志的检查
if(!$tabid && !self::getConfig('force_client_id'))
{
return false;
}
//用户认证
$allow_client_ids=self::getConfig('allow_client_ids');
if(!empty($allow_client_ids))
{
if (!$tabid && in_array(self::getConfig('force_client_id'), $allow_client_ids)) {
return true;
} $client_id=self::getClientArg('client_id');
if(!in_array($client_id,$allow_client_ids))
{
return false;
}
}
return true;
} protected static function getClientArg($name)
{
static $args=array(); $key = 'HTTP_USER_AGENT'; if (isset($_SERVER['HTTP_SOCKETLOG'])) {
$key = 'HTTP_SOCKETLOG';
} if(!isset($_SERVER[$key]))
{
return null;
}
if(empty($args))
{
if(!preg_match('/SocketLog\((.*?)\)/',$_SERVER[$key],$match))
{
$args=array('tabid'=>null);
return null;
}
parse_str($match[1],$args);
}
if(isset($args[$name]))
{
return $args[$name];
}
return null;
} //设置配置
public static function setConfig($config)
{
$config=array_merge(self::$config,$config);
self::$config=$config;
if(self::check())
{
self::getInstance(); //强制初始化SocketLog实例
if($config['optimize'])
{
self::$start_time=microtime(true);
self::$start_memory=memory_get_usage();
} if($config['error_handler'])
{
self::registerErrorHandler();
}
}
} //获得配置
public static function getConfig($name)
{
if(isset(self::$config[$name]))
return self::$config[$name];
return null;
} //记录日志
public function record($type,$msg='',$css='')
{
if(!self::check())
{
return ;
} self::$logs[]=array(
'type'=>$type,
'msg'=>$msg,
'css'=>$css
);
} /**
* @param null $host - $host of socket server
* @param string $message - 发送的消息
* @param string $address - 地址
* @return bool
*/
public static function send($host,$message='',$address='/')
{
$url='http://'.$host.':'.self::$port.$address;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$headers=array(
"Content-Type: application/json;charset=UTF-8"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//设置header
$txt = curl_exec($ch);
return true;
} public static function sendLog()
{
if(!self::check())
{
return ;
} $time_str='';
$memory_str='';
if(self::$start_time)
{
$runtime=microtime(true)-self::$start_time;
$reqs=number_format(1/$runtime,2);
$time_str="[运行时间:{$runtime}s][吞吐率:{$reqs}req/s]";
}
if(self::$start_memory)
{
$memory_use=number_format(memory_get_usage()-self::$start_memory/1024,2);
$memory_str="[内存消耗:{$memory_use}kb]";
} if(isset($_SERVER['HTTP_HOST']))
{
$current_uri=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
else
{
$current_uri="cmd:".implode(' ',$_SERVER['argv']);
}
array_unshift(self::$logs,array(
'type'=>'group',
'msg'=>$current_uri.$time_str.$memory_str,
'css'=>self::$css['page']
)); if(self::getConfig('show_included_files'))
{
self::$logs[]=array(
'type'=>'groupCollapsed',
'msg'=>'included_files',
'css'=>''
);
self::$logs[]=array(
'type'=>'log',
'msg'=>implode("\n",get_included_files()),
'css'=>''
);
self::$logs[]=array(
'type'=>'groupEnd',
'msg'=>'',
'css'=>'',
);
} self::$logs[]=array(
'type'=>'groupEnd',
'msg'=>'',
'css'=>'',
); $tabid=self::getClientArg('tabid');
if(!$client_id=self::getClientArg('client_id'))
{
$client_id='';
}
if($force_client_id=self::getConfig('force_client_id'))
{
$client_id=$force_client_id;
}
$logs=array(
'tabid'=>$tabid,
'client_id'=>$client_id,
'logs'=>self::$logs,
'force_client_id'=>$force_client_id,
);
$msg=@json_encode($logs);
$address='/'.$client_id; //将client_id作为地址, server端通过地址判断将日志发布给谁
self::send(self::getConfig('host'),$msg,$address); } public function __destruct()
{
self::sendLog();
} }
配置好的SocketLog.class.php
yhdsir@function:php的更多相关文章
- 通过百度echarts实现数据图表展示功能
现在我们在工作中,在开发中都会或多或少的用到图表统计数据显示给用户.通过图表可以很直观的,直接的将数据呈现出来.这里我就介绍说一下利用百度开源的echarts图表技术实现的具体功能. 1.对于不太理解 ...
- jsp中出现onclick函数提示Cannot return from outside a function or method
在使用Myeclipse10部署完项目后,原先不出错的项目,会有红色的叉叉,JSP页面会提示onclick函数错误 Cannot return from outside a function or m ...
- JavaScript function函数种类
本篇主要介绍普通函数.匿名函数.闭包函数 目录 1. 普通函数:介绍普通函数的特性:同名覆盖.arguments对象.默认返回值等. 2. 匿名函数:介绍匿名函数的特性:变量匿名函数.无名称匿名函数. ...
- 在ubuntu16.10 PHP测试连接MySQL中出现Call to undefined function: mysql_connect()
1.问题: 测试php7.0 链接mysql数据库的时候发生错误: Fatal error: Uncaught Error: Call to undefined function mysqli_con ...
- jquery中的$(document).ready(function() {});
当文档载入时执行function函数里的代码, 这部分代码主要声明,页面加载后 "监听事件" 的方法.例如: $(document).ready( $("a") ...
- Function.prototype.toString 的使用技巧
Function.prototype.toString这个原型方法可以帮助你获得函数的源代码, 比如: function hello ( msg ){ console.log("hello& ...
- 转:ORA-15186: ASMLIB error function = [asm_open], error = [1], 2009-05-24 13:57:38
转:ORA-15186: ASMLIB error function = [asm_open], error = [1], 2009-05-24 13:57:38http://space.itpub. ...
- [Xamarin] 透過Native Code呼叫 JavaScript function (转帖)
今天我們來聊聊關於如何使用WebView 中的Javascript 來呼叫 Native Code 的部分 首先,你得先來看看這篇[Xamarin] 使用Webview 來做APP因為這篇文章至少講解 ...
- Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等
功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...
随机推荐
- 对国外某hotel的内网域简单渗透
Penetration Testing不单单是一个博客,更热衷于技术分享的平台. 本文将讲述对国外某一hotel的渗透测试,让更多的人安全意识得到提高,有攻才有防,防得在好,也有疏忽的地方,这就是为啥 ...
- 微信小程序 - 对象转换成对象数组
后端传过来的一个个对象 {1,2,3,4},{1,3,5,},{1,3,5} 我们应该转化为数组对象 [{},{},{},{}] ,最后通过wx:for遍历到页面 示例图:
- 出现“Windows资源管理器已停止工作”错误
出现"Windows资源管理器已停止工作"错误 什么是资源管理器呢,explorer.exe进程的作用就是让我们管理计算机中的资源! 今天开电脑的时候就一直提示windows资源管 ...
- Vue2.0 :key作用
转自:https://www.cnblogs.com/zhumingzhenhao/p/7688336.html 为了给 Vue 一个提示,以便它能跟踪每个节点的身份,从而重用和重新排序现有元素,你需 ...
- 转:十六进制颜色与RGB颜色对照表
http://www.vis.cc/html/ppyj/zscs/1090.html 十六进制颜色查询 颜 色 英文代码 形象描述 十六进制 RGB LightPink 浅粉红 #FFB6C1 255 ...
- css:清除浮动 overflow
是因为overflow除了(visible)会重新给他里面的元素建立块级格式化(block formatting context)floats, position absolute, inline-b ...
- java个人感想
java与c++相比,摒弃了c++的指针,把c++中的stl封装成一个库,而且改变了当中的某些方法,使用方法也产生了非常多不同,读者在编程过程中须要自己细细体会 个人觉得三大框架基于前端+领域逻辑+数 ...
- VueJS计算属性: computed
computed属性 HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...
- 开始nodejs+express的学习+实践(1)
开始nodejs+express的学习+实践(1) 开始nodejs+express的学习+实践(2) 开始nodejs+express的学习+实践(3) 开始nodejs+express的学习+实践 ...
- C++第4次实验(提高班)—继承和派生1
从项目2和项目3中选1题作为实验.剩下2题写成作业. [项目1 - 龙三] 请在以下程序的横线处填上适当内容,以使程序完整,并使程序的输出为: Name: 龙三 Grade: 19 #include ...