CentOS7 firewalld防火墙基础命令

作者:@ouyang 发布时间:2016年04月16日 阅读: 2,289 分类:Linux摘要 暂无评论

CentOS7默认使用firewalld替代了iptables,所以熟悉熟悉firewalld的一些基础用法。

firewall-cmd --zone=public --add-port=80/tcp --permanent  #打开80端口, --permanent为永久有效
firewall-cmd --permanent --remove-port=8080/tcp #删除端口
firewall-cmd --query-port=8080/tcp # 查询端口是否开放
firewall-cmd --reload  #重新装载配置生效 
firewall-cmd --list-all  #查看防火墙添加的端口
firewall-cmd --list-services #查看当前的服务
firewall-cmd --state #查看firewall的状态

systemctl start firewalld.service #打开防火墙
systemctl stop firewalld.service #关闭防火墙
systemctl disable firewalld.service #禁止开机启动
systemctl enable firewalld.service #开启开机启动
systemctl restart firewalld.service #重启防火墙

解决关闭 Hyper-V管理器前你必须关闭所有会话框

作者:@ouyang 发布时间:2016年03月26日 阅读: 3,604 分类:学习笔记 暂无评论

关闭Hyper-V管理器时候,提示“关闭Hyper-V管理器前你必须关闭所有会话框”,感觉是微软的一个Bug
HV关闭窗口问题
解决办法是:在Hyper-V管理器界面只要把输入法切换为英文,这时候关闭不会有提示了。这Bug真叫人汗颜。

PHPCMS V9二次开发自定义后台访问入口

作者:@ouyang 发布时间:2016年03月19日 阅读: 2,153 分类:学习笔记 暂无评论

PHPCMS V9由于采用了MVC的设计模式,所以它的后台访问地址是固定的,虽然可以通过修改路由配置文件来实现修改,但每次都修改路由配置文件对于我来说有点麻烦 了,而且一不小心就会出错。这里使用另外一个一劳永逸的方法,达到了方便修改访问后台入口的目的,整个修改共分两步:

第一步:
在网站根目录创建一个文件夹,以后就要通过这个文件夹进入后台登录界面的,所以文件夹名就要取一个不易被人轻易猜到的名称。这里作为演示,我就取为 houtai 好了。接着,在这个文件夹里新建一个文件index.php,内容为:

<?php
define('PHPCMS_PATH', realpath(dirname(__FILE__) . '/..') . '/');
include PHPCMS_PATH . '/phpcms/base.php';
// pc_base::creat_app();
$session_storage = 'session_' . pc_base :: load_config('system', 'session_storage');
pc_base :: load_sys_class($session_storage);
session_start();
$_SESSION['right_enter'] = 1;

unset($session_storage);
header('location:../index.php?m=admin');
?>

第二步:
在 phpcms/modules/admin/ 文件夹里新建一个文件 MY_index.php(切记MY为大写,index为小写),内容为:

<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class MY_index extends index {
public function __construct() {
if(empty($_SESSION['right_enter'])) {
header('location:./');exit;
}
parent::__construct();
}

public function public_logout() {
$_SESSION['right_enter'] = 0;
parent::public_logout();
}
}
?>

修改完成。以后就只能通过 http://域名/houtai/ 目录访问后台登录入口 了,如果直接使用 index.php?m=admin 访问的话,会直接跳转到网站首页,这样就阻止了对后台登录入口的直接访问了。当然houtai这个目录名可以随意修改的!

文章来自:周涛blog 原文地址:http://www.zhoutao.org/blog/2013/03/145.html

Directadmin平滑升级nginx版本,添加nginx–http–concat模块

作者:@ouyang 发布时间:2016年02月20日 阅读: 2,634 分类:学习笔记 暂无评论

[root@server ~]#nginx -V   //查看Nginx安装信息以及目录
nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt=''-D FD_SETSIZE=32768''

下载nginx-http-concat模块以及nginx最新版本

[root@server ~]# git clone git://github.com/alibaba/nginx-http-concat.git  //下载nginx-http-concat模块
[root@server ~]# mv nginx–http–concat/ /usr/local/src/nginx-http-concat   //将模块移动到指定目录
[root@server ~]# wget http://nginx.org/download/nginx-1.9.11.tar.gz  //下载最新nginx版本
[root@server ~]# tar zxvf nginx-1.9.11.tar.gz  //解压
[root@server ~]# cd nginx-1.9.11   //进入nginx最新目录

这里需要修改一下nginx-http-concat的ngx_http_concat_module.c文件,因为nginx最新的js类别已经修改成application/javascript。所以需要将ngx_http_concat_module.c里的application/x-javascript修改成application/javascript。不然js无法合并,并会提示400错误。

[root@server nginx-1.9.11]# vi /usr/local/src/nginx-http-concat/ngx_http_concat_module.c
找到
ngx_string("application/x-javascript")
将其修改为
ngx_string("application/javascript")
:wq  //保存

现在可以进行编译了,将nginx-http-concat一起与nginx编译。

[root@server nginx-1.9.11]# ./configure  --user=nginx --group=nginx --prefix=/usr --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt="-D FD_SETSIZE=32768" --add-module=/usr/local/src/nginx-http-concat
make

make以后进入objs

[root@server nginx-1.9.11]# cd ./objs
[root@server objs]# mv /usr/sbin/nginx /usr/sbin/nginx.old   //移动1.8版本nginx为nginx.old
[root@server objs]# cp nginx /usr/sbin/nginx  //将刚编译的1.9.11的nginx复制原地址。

这个时候基本就升级完成了。

[root@server objs]# nginx -V
nginx version: nginx/1.9.11
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr --user=nginx --group=nginx --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt='-D FD_SETSIZE=32768' --add-module=/usr/local/src/nginx-http-concat

这时候看到nginx版本升级到指定版本,并且看到nginx-http-concat已经成功编译进去。
但还没有完成,我们还需要在nginx.conf里面进行配置。
举例:

server
{
        listen 120.0.0.1:80;
        server_name ouyang.wang www.ouyang.wang ;
        access_log /var/log/nginx/domains/ouyang.wang.log;
        access_log /var/log/nginx/domains/ouyang.wang.bytes bytes;
        error_log /var/log/nginx/domains/ouyang.wang.error.log;
        root /home/domains/ouyang.wang/public_html;
        index index.htm index.html index.php;
        include /usr/local/directadmin/data/users/news/nginx_php.conf;
        location / {
        concat on;
        concat_max_files 20;
        concat_unique off;  //允许不同类型文件合并
        }
        include /etc/nginx/webapps.conf;
}

只需要将下列加入server里即可。

        location / {
        concat on;
        concat_max_files 20;
        concat_unique off; 
        }

参数说明:

# nginx_concat_module 开关
concat on; 

# 最大合并文件数
# concat_max_files 10;

# 允许不同类型文件合并
# concat_unique off;

# 允许合并的文件类型,多个以逗号分隔。如:application/javascript, text/css
# concat_types application/javascript, text/css;

配置保存完成后,启动nginx即可。

 systemctl reload nginx.service

PHP获取当前日期和时间格式化方法

作者:@ouyang 发布时间:2016年01月24日 阅读: 2,759 分类:学习笔记 暂无评论

使用函式 date() 实现


显示的格式: 年-月-日 小时:分钟:妙

相关时间参数:
a - "am" 或是 "pm"
A - "AM" 或是 "PM"
d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31"
D - 星期几,三个英文字母; 如: "Fri"
F - 月份,英文全名; 如: "January"
h - 12 小时制的小时; 如: "01" 至 "12"
H - 24 小时制的小时; 如: "00" 至 "23"
g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12"
G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23"
i - 分钟; 如: "00" 至 "59"
j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31"
l - 星期几,英文全名; 如: "Friday"
m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12"
n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12"
M - 月份,三个英文字母; 如: "Jan"
s - 秒; 如: "00" 至 "59"
S - 字尾加英文序数,二个英文字母; 如: "th","nd"
t - 指定月份的天数; 如: "28" 至 "31"
U - 总秒数
w - 数字型的星期几,如: "0" (星期日) 至 "6" (星期六)
Y - 年,四位数字; 如: "1999"
y - 年,二位数字; 如: "99"
z - 一年中的第几天; 如: "0" 至 "365"

phpcms其中获取内容也时间方式为:{date('Y-m-d H:i:s', $rs['inputtime'])}

修改phpsso_server的工作路径

作者:@ouyang 发布时间:2016年01月12日 阅读: 2,624 分类:学习笔记 暂无评论

1、移动phpsso_server目录

将根目录下的phpsso_server移动到其他文件路径下。
2、给该目录绑定新的域名,一级域名或者二级域名均可。
3、修改 phpsso_server 下面的配置文件。

阅读剩余部分...

phpcms v9文章排序功能的方法

作者:@ouyang 发布时间:2016年01月02日 阅读: 2,411 分类:学习笔记 暂无评论

phpcms v9自带的相关文章、专题等模块不支持order排序,调用的相关文章、专题默认为升序,这样就造成了一个问题,调出来的相关文章是最早的文章,没有时效性。我们只能通过修改程序文件,只需简单修改一个文件,就能达到我们的需求。
修改相关文章排序的方法:
打开根目录下的phpcms/modules/content/classes/content_tag.class.php,找到

$r = $this->db->select($sql2, '*', $limit, '','','id');

修改为:

$r = $this->db->select($sql2, '*', $limit, $order,'','','id');

PC标签格式如下:

{pc:content action="relation" relation="$relation" id="$id" catid="$catid" num="5" order="inputtime DESC" keywords="$rs[keywords]"}

阅读剩余部分...

利用TTL将WDR4310刷回官方固件

作者:@ouyang 发布时间:2015年10月21日 阅读: 3,558 分类:技术相关,发现分享 暂无评论

TTL链接步骤就直接省略。
修改IP为192.168.1.100 子网掩码为255.255.255.0
将固件复制到tftp文件夹(不带uboot的固件,一般大小为7.75M,如果有uboot请使用winhex软件进行处理。)
把固件改名为“6F01A8C0.img”,启动tftp软件

阅读剩余部分...

话说QQ群签到玩法一二技巧

作者:@ouyang 发布时间:2015年08月25日 阅读: 3,025 分类:热点话题 暂无评论

QQ推出了群签到,连续签名15天会有橙色名字赐予,对于VIP党来说这可以忽略了。当然最重要的是可以批量进行签名,只要一个PHP文件即可,在服务器上做个定时任务,执行PHP,每天就能够自动签名了,一劳永逸的方法。
将下面代码存为PHP文件即可,放到服务器上或本地运行PHP即可执行你全部的群签到。
Github项目地址:https://github.com/xqin/qiandao

un = preg_replace('/^o0*/', '', $uin);//数字QQ号码
        $this->cookie = sprintf('Cookie: uin=%s; skey=%s;', $uin, $skey);//Cookie

        $this->g_tk = $this->getGTK($skey);//计算 g_tk

        $this->sign($this->getQunList());//获取群列表并签到
    }

    function getGTK($skey){
        $len = strlen($skey);
        $hash = 5381;

        for($i = 0; $i < $len; $i++){
            $hash += ($hash << 5) + ord($skey[$i]);
        }

        return $hash & 0x7fffffff;//计算g_tk
    }

    function getQunList(){
        $html = @file_get_contents(
                sprintf('http://qun.qzone.qq.com/cgi-bin/get_group_list?uin=%s&g_tk=%s', $this->un, $this->g_tk),
                false,
                stream_context_create(array(
                    'http'=>array(
                        'method'=>'GET',
                        'header'=>$this->cookie
                    )
                ))
            );

        preg_match('/(\{[\s\S]+\})/', $html, $qunList);

        if(count($qunList) == 0){
            return NULL;
        }

        $qunList = json_decode($qunList[1]);

        if($qunList == NULL || $qunList->code != 0){
            return NULL;
        }

        return $qunList->data->group;
    }

    function sign($groups){
        if($groups == NULL)return;

        $i = 1;
        foreach($groups as $qun){
            $this->qiandao($qun->groupid);//签到
            printf("%d\t%s(%d)\tok\r\n", $i++, $qun->groupname, $qun->groupid);//输出群信息
        }
    }

    function qiandao($qin){
        @file_get_contents($this->signUrl, false,
            stream_context_create(
                array('http' => array(
                    'method'  => 'POST',
                    'header'  => $this->cookie,
                    'content' => sprintf('gc=%s&is_sign=0&bkn=%s', $qin, $this->g_tk)
                ))
            )
        );
    }
}

这样玩不够爽?能自定义签到内容吗?这当然可以。
准备工具:Chrome和一个抓包工具,可以用Fiddler。
先打开Fiddler,然后打开想要签到的QQ群,点击签到功能(不要点击签到),然后在Fiddler里面能够找到gc和bkn的值。
QQ群BKN值

OK,打开Chrome,然后打开http://qiandao.qun.qq.com/,登录QQ,F12打开开发工具,先引入jq.
引入jq代码:

;(function(d,s){d.body.appendChild(s=d.createElement('script')).src='http://code.jquery.com/jquery-1.9.1.min.js'})(document);

然后(实现自定义签名说明的代码来了。)

$.post("http://qiandao.qun.qq.com/cgi-bin/sign",
	{
		gc:"XX55XXX", //这里填写你获取到的gc值
		is_sign:"0",
		from:"1",
		bkn:"XXX88XXXX", //这里填写你获取到的bkn值
		poi:"群也好久了,对于签到,其实是个苦力活,要签到起码要能够做点广告吧?来吧,来友链一个吧?http://www.joming.com 欢迎来换友链,就这样吧,Joming在此",
	},
	function(data,status)
		{
		alert("数据:"+ data.ec);
		}
	);

好了,检查你刚才打开的群吧。是不是签到成功了?

Centos安装oracle 11g R2详解

作者:@ouyang 发布时间:2015年08月10日 阅读: 2,597 分类:Linux摘要 暂无评论

安装所需要的组建环境

yum install gcc libaio libaio-devel libstdc++ libstdc++-devel libgcc elfutils-libelf-devel glibc-devel glibc-devel gcc-c++ compat-libstdc++-33 unixODBC unixODBC-devel

Oracle安装还需要一个必要的rpm包,pdksh-5.2.14-37.el5_8.1.x86_64,解压rpm -ivh安装即可。

创建oinstall组
groupadd oinstall

创建dba组
groupadd dba

创建oracle用户
useradd -g oinstall -G dba oracle

修改oracle用户的密码
passwd oracle (设立会提示输入自己的密码)

阅读剩余部分...