mysql使用source导入备份文件,但导入中出错,出现:ERROR at line 1418: Unknown command ‘\n’.
这种情况一般是字符集不对应引起的,如果数据库是utf8编码,则
我是通过phpmyadmin查看原来数据库编码latin1比较特殊
对应编码就能导入成功了
mysql使用source导入备份文件,但导入中出错,出现:ERROR at line 1418: Unknown command ‘\n’.
这种情况一般是字符集不对应引起的,如果数据库是utf8编码,则
我是通过phpmyadmin查看原来数据库编码latin1比较特殊
对应编码就能导入成功了
有时候进行安全检查就需要查看它是否被重启过,运行是否稳定,有什么人登录过,还有都做过哪些操作,都是可查而且使用的,这个时候就需要比较实用的last命令和history命令。虽然记录是可以被清除的^_^。
查看重启日志last reboot命令
[root@localhost ~]# last reboot
reboot system boot 2.6.18-194.el5PA Mon Mar 19 14:12 (112+19:37) 括号内容为从使用系统到现在的时间 112为天数
reboot system boot 2.6.18-194.el5PA Sun Nov 27 19:40 (112+18:29)
reboot system boot 2.6.18-194.el5PA Tue Nov 15 15:17 (12+04:19)
reboot system boot 2.6.18-194.el5PA Mon Oct 17 22:35 (40+21:02)
reboot system boot 2.6.18-194.el5PA Mon Oct 17 17:12 (02:53)
reboot system boot 2.6.18-194.el5PA Sat Oct 15 00:54 (00:36)
reboot system boot 2.6.18-194.el5PA Fri Oct 14 21:38 (03:12)
reboot system boot 2.6.18-194.el5PA Fri Oct 14 17:20 (03:16)
reboot system boot 2.6.18-194.el5PA Fri Oct 14 02:00 (00:01)
wtmp begins Fri Oct 14 02:00:21 2011 //这里提示系统从什么时候开始使用 2011年10月14开始启用。
查看登录日志last命令
[root@localhost ~]# last -x
root pts/1 113.89.183.* Tue Jul 10 09:27 still logged in
root pts/1 14.153.61.* Mon Jul 9 10:18 – 10:20 (00:02)
root pts/1 119.139.70.* Mon Jul 9 07:24 – 07:26 (00:02)
查看操作日志history命令:
一般操作日志查看都会比较长,所以需要加more来查看
[root@localhost ~]# history |more
17 top
18 exit
19 cd /etc/sysconfig/network-scripts/
20 cat mifcfg-eth0
21 cat ifcfg-eth0
附件:
linux last 命令详解
功能说明:列出目前与过去登入系统的用户相关信息。
语 法:last [-adRx][-f <记录文件>][-n <显示列数>][帐号名称…][终端机编号…]
补充说明:单独执行last指令,它会读取位于/var/log目录下,名称为wtmp的文件,并把该给文件的内容记录的登入系统的用户名单全部显示出来。
参 数:
-a 把从何处登入系统的主机名称或IP地址,显示在最后一行。
-d 将IP地址转换成主机名称。
-f <记录文件> 指定记录文件。
-n <显示列数>或-<显示列数> 设置列出名单的显示列数。
-R 不显示登入系统的主机名称或IP地址。
-x 显示系统关机,重新开机,以及执行等级的改变等信息
之前使用v9更换编辑器为百度UEditer更换后需要在上面价格自定义按钮,查询手册后发现不难。
以v9添加了UE 1.4.3.3版为例,加入以下红色部分自定义addCustomizeButton.js
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.config.js"></script>';
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.all.js"></script>';
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.parse.js"></script>';
$str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/addCustomizeButton.js"></script>';
$str .= '<link rel="stylesheet" href="'.JS_PATH.'ueditor/themes/default/css/ueditor.css"/>';
define('EDITOR_INIT', 1);
$str .= "<script type=\"text/javascript\">\r\n";
$str .= "var editor = UE.getEditor('$textareaid');";
$str .= '</script>';
addCustomizeButton.js的内容如下
UE.registerUI('button',function(editor,uiName){
//注册按钮执行时的command命令,使用命令默认就会带有回退操作
editor.registerCommand(uiName,{
execCommand:function(){
alert('execCommand:' + uiName)
}
});
//创建一个button
var btn = new UE.ui.Button({
//按钮的名字
name:uiName,
//提示
title:uiName,
//需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon
cssRules :'background-position: -500px 0;',
//点击时执行的命令
onclick:function () {
//这里可以不用执行命令,做你自己的操作也可 具体需要什么api也可以查手册
editor.execCommand('inserthtml', 'hello!');
editor.execCommand(uiName);
editor.execCommand('bold'); //加粗
editor.execCommand('italic'); //加斜线
editor.execCommand('subscript'); //设置上标
editor.execCommand('supscript'); //设置下标
editor.execCommand('forecolor', '#FF0000'); //设置字体颜色
editor.execCommand('backcolor', '#0000FF'); //设置字体背景颜色
}
});
//当点到编辑内容上时,按钮要做的状态反射
editor.addListener('selectionchange', function () {
var state = editor.queryCommandState(uiName);
if (state == -1) {
btn.setDisabled(true);
btn.setChecked(false);
} else {
btn.setDisabled(false);
btn.setChecked(state);
}
});
//因为你是添加button,所以需要返回这个button
return btn;
});
/*index 指定添加到工具栏上的那个位置,默认时追加到最后,editorId 指定这个UI是那个编辑器实例上的,默认是页面上所有的编辑器都会添加这个按钮*/
温习php类中static和self的不同
class Car { public static function model(){ self::getModel(); } protected static function getModel(){ echo "This is a car model"; } } Car::model(); Class Taxi extends Car { protected static function getModel(){ echo "This is a Taxi model"; } } Taxi::model();
输出
This is a car model This is a car model
可以发现,self在子类中还是会调用父类的方法
class Car { public static function model(){ static::getModel(); } protected static function getModel(){ echo "This is a car model"; } } Car::model(); Class Taxi extends Car { protected static function getModel(){ echo "This is a Taxi model"; } } Taxi::model();
输出
This is a car model This is a Taxi model
可以看到,在调用static
,子类哪怕调用的是父类的方法,但是父类方法中调用的方法还会是子类的方法。
总结呢就是:self
只能引用当前类中的方法,而static
关键字允许函数能够在运行时动态绑定类中的方法。
父类不能被实例化,不能给覆盖。子类实现单例不能使用self,而是用static,它们都是在类体内调用类的方式,区别在于self关键字是在编译时决定它所指代的类,它写在了哪个类中,它指代的就是那个类。而static关键字则是在执行的过程中才决定它所指代的类。
abstract class father{ final protected function __construct(){ $this->init(); } final protected function __clone(){} protected function init(){} //abstract protected function init(); public static function getInstance(){ if(static::$instance === null){ static::$instance = new static(); } return static::$instance; } }
子类声明$instance静态属性,它们从属于各个子类,在父类的getIntance方法中,通过static关键字,调用子类并实例化,然后又赋给子类静态属性$instance。这样就可以实现将获取单例的函数封装在父类的目的。修改子类代码如下:
class Son1 extends Father{ protected static $instance = null; ... } class Son2 extends father{ protected static $instance = null; .... }
使用phpcms v9发现自带的编辑器从fckedotror 到 ckeditor太老了,批量除去链接都无法使用了。决定更换编辑器。
首先去UEditor官网下载所需对应版本:http://ueditor.baidu.com/website/download.html
下载1.4.3.3 PHP UTF-8版。
1. 将所下载的程序包解压,得到程序包目录,将程序包目录更名为ueditor。
2. 将ueditor包放入PHPCMS_PATH/statics/js/中。(PHPCMS_PATH为phpcms的入口文件所在路径)
3. 修改ueditor/php/config.json,将上传路径/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6} 改为
/phpcms/uploadfile/{yyyy}/{mm}{dd}/{yyyy}{mm}{dd}{rand:6},符合PHPCMS的路径规则。
4. 修改ueditor/ueditor.config.js配置文件,
1) 自定义工具栏内容: ,toorbars : [[ ********** ]]
这个工具栏图标你可以参照官方文档进行修改,去掉不需要的功能:http://fex.baidu.com/ueditor/#start-toolbar
2) 自定义编辑器宽高: ,initialFrameWidth:655 //初始化编辑器宽度,默认1000
,initialFrameHeight:500 //初始化编辑器高度,默认320
5. 修改PC_PATH/libs/classes/form.class.php文件,
将原来的:
if(!defined('EDITOR_INIT')) { $str = '<script type="text/javascript" src="'.JS_PATH.'ckeditor/ckeditor.js"></script>'; define('EDITOR_INIT', 1); }
注释掉,改为:
if(!defined('EDITOR_INIT')) { $str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.config.js"></script>'; $str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.all.js"></script>'; $str .= '<script type="text/javascript" src="'.JS_PATH.'ueditor/ueditor.parse.js"></script>'; $str .= '<link rel="stylesheet" href="'.JS_PATH.'ueditor/themes/default/css/ueditor.css"/>'; define('EDITOR_INIT', 1);} $str .= "<script type=\"text/javascript\">\r\n"; $str .= "var editor = UE.getEditor('$textareaid');"; $str .= '</script>';
6. 在ueditor/themes/default/css/ueditor.css中,
/*UI工具栏、编辑区域、底部*/ .edui-default .edui-editor { border: 1px solid #d4d4d4; background-color: white; position: relative; overflow: visible; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; width:auto !important;//注:增加此行,使编辑器自适应 }
7. 去编辑器下方除子标题显示:注释掉phpcms/libs/classes/form.class.php中 如下代码:
/*$ext_str = "<div class='editor_bottom'>"; if(!defined('IMAGES_INIT')) { $ext_str .= '<script type="text/javascript" src="'.JS_PATH.'swfupload/swf2ckeditor.js"></script>'; define('IMAGES_INIT', 1); } $ext_str .= "<div id='page_title_div'> <table cellpadding='0' cellspacing='1' border='0'><tr><td class='title'>".L('subtitle')."<span id='msg_page_title_value'></span></td><td> <a class='close' href='javascript:;' onclick='javascript:$(\"#page_title_div\").hide();'><span>×</span></a></td> <tr><td colspan='2'><input name='page_title_value' id='page_title_value' class='input-text' value='' size='30'> <input type='button' class='button' value='".L('submit')."' onclick=insert_page_title(\"$textareaid\",1)></td></tr> </table></div>"; $ext_str .= "</div>";*/
8. ueditor\ueditor.all.js
//在这里加上格式化按钮 去除段落开始留下空格的问题 re = new RegExp("^((\ \;)+)*","g"); ci.innerHTML=ci.innerHTML.replace(re, ""); ci.innerHTML=ci.innerHTML.replace(/(^\s*)/g, ""); ci.innerHTML=ci.innerHTML.replace(re, ""); if(isLine(ci,true) && ci.tagName != 'SPAN'){ if(opt.indent){ ci.style.textIndent = opt.indentValue; } if(opt.textAlign){ ci.style.textAlign = opt.textAlign; } // if(opt.lineHeight) // ci.style.lineHeight = opt.lineHeight + 'cm'; }
很简单
修改配置文件ueditor.config.js 上的参数
找到注释去掉,修改为false
//抓取远程图片是否开启,默认true
,catchRemoteImageEnable:false
ini_set ('memory_limit', '1024M');
$log = file_get_contents('upstream.log');//读取nginx日志
$log=explode("\n",$log);
$p = '/^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s-\s(.*)\s\[(.*)\]\s"(.*)\"\s(\d{3})\s(\d+)\s"(.*)"\s\"(.*)\"(.*)$/u';//正则分析
foreach($log as $k=>$v){
preg_match($p,$v,$a_match);
if($a_match[8]='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36'){//提取特征匹配
//echo $a_match[1]."\n";
$host[]=$a_match[1];//提取ip
}
//var_dump($a_match);
}
print_r(array_unique($host));