Archive

Posts Tagged ‘PHP’

UsefulLink

November 20th, 2009 No comments

UnixChina手册中心

==================================================

程序员小抄集

Actionscript

Ajax

Apache

ASCII Character Codes

ASP

C# and VB.NET

CSS

CVS

C++

Django

Firefox

Google

HTML/XHTML

Java

JavaScript

Microformats

Misc

MySQL

Oracle

Perl

Photoshop/Gimp

PHP

Python

Regular Expressions

Ruby

Unix/Linux

Weblog

Windows

XML

Categories: Tags: , , , , , , , ,

Linux webserver 常用维护命令

March 20th, 2009 No comments

这里是维护时常用的一些命令,放在这里,备忘

注:大部分非原创,只是收集到这里而已

* 实时查看正在执行的sql语句
1./usr/sbin/tcpdump -i eth0 -s 0 -l -w – dst port 3306 | strings | egrep -i ‘SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL’

* 查看http连接
1.netstat -n | awk ‘/^tcp/ {++state[$NF]} END {for(key in state) print key,”\t”,state[key]}’

* 查看SYN状态的http连接
1.netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more

* 查看TIME_WAIT状态的http连接
1.netstat -tna | cut -b 49- |grep TIME_WAIT | sort |more
2.netstat -an | grep TIME_WAIT | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more

* 查看ESTABLISHED状态的http连接
1.netstat -an | grep ESTABLISHED | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more
2.netstat -an | grep “:80″ | grep ESTABLISHED | sort | more

* 批量kill进程
1.ps -efww|grep sqlr-listener|grep -v grep|cut -c 9-15|xargs kill -9

* 查看活动的php-cgi连接数
1.netstat -anpo|grep php-cgi|wc -l

* 按ip查看httpd连接数
1.netstat -anlp | grep 80 | grep tcp | awk {‘print $5′} | awk -F: {‘print $1′}| sort |uniq -c | sort -nr

* 禁IP
1.iptables -A INPUT -s IP地址 -j REJECT
2.iptables -A INPUT -s IP地址/24 -j REJECT
3.route add -net IP地址 netmask 255.255.255.0 reject

* 调试命令
1.strace -p pid

* 跟踪指定的进程pid.
1.gdb -p pid

* 跟踪指定的进程pid.

* 批量查找文件并删除
1.find . -name test.php -exec rm {} \;
2.find . -name test.php | xargs rm -rf

* 更改某一目录下所有目录的权限, 不包括文件, aaa 是目录名
1.find aaa -type d -exec chmod 755 {} \;

* 替换文件内容
1.sed -i ‘s/b/strong/g’ index.html

此命令搜索 index.html 文件中的 b 并将其替换为 strong。

Categories: Linux, Server Tags: , , ,

将阅读权限限制修改为威望(积分)限制

January 23rd, 2009 No comments
将阅读权限限制修改为威望(积分)限制
 
1、修改数据库(可以不修改)
 
登录数据库,表 x__threads (x表示表前缀)中 readperm 字段 结构修改
 
A.将 类型  tinyint  修改为 smallint
B.将 长度 3 修改为6
C.属性  UNSIGNED (不修改)
D.NULL 选择 not null (不修改)
E. 默认值选择 0 (不修改)
 
2. 打开 include/common.inc.php
 
 
到第 157if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
	showmessage('thread_nopermission', NULL, 'NOPERM');
}
修改为
if($thread['readperm'] && $thread['readperm'] > $extcredits1  && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
	showmessage('thread_nopermission', NULL, 'NOPERM');
}
//其中$extcredits1 可以更改为$extcredits 积分; 如extcredits1 积分1(威望); extcredits2 积分2(金钱); extcredits3; extcredits4;extcredits5 ;extcredits6 ;extcredits7; extcredits8,可以自行选择一个,或者自行设置加减。
3. 修改模板文件,将 “阅读权限”替换为 “威望”或“积分”
 
3.1 找到 templates\default\templates.lang.php (一共有3行,修改前两行)
 
第 416'readperm' => '阅读权限',
修改为
'readperm' => '威望',
 
417'readperm_thread' => '所需阅读权限',
修改为
'readperm_thread' => '所需威望',
 
3.2 找到templates\default\messages.lang.php (一共有2行,全部替换)
 
第 47'thread_nopermission' => '对不起,本帖要求阅读权限高于 $thread[readperm] 才可浏览,请返回。',
修改为
'thread_nopermission' => '对不起,本帖要求威望高于 $thread[readperm] 才可浏览,请返回。',
 
第90'attachment_nopermission' => '对不起,本附件要求阅读权限高于 $attach[readperm] 才可下载,请返回。',
修改为
'attachment_nopermission' => '对不起,本附件要求威望高于 $attach[readperm] 才可下载,请返回。',
 
3.3找到templates\default\messages.lang.php
第51'attach_readperm' => '阅读权限',
修改为
'attach_readperm' => '威望',
 
3.3找到\forumdata\cache\目录下 (可替换,也可不替换)
cache_viewpro.php 和 cache_viewthread.php
 
将 阅读权限 替换为 威望
Categories: SoftWare Tags: ,

DISCUZ 6.0 发新贴后标题前自动加入当天日期

January 15th, 2009 No comments
发新贴后标题前自动加入当天日期
1、找到include/newthread.inc.php
2、查找
 
if($post_invalid = checkpost()) {
        showmessage($post_invalid);
}
3、替换为
 
$date_fid = "2,4,6,8"; //需要加日期的版块,用逗号分隔
$date_fid = ",".$date_fid.",";
if(strstr($date_fid, ",".$fid.",")){
    $date = gmdate("y/m/d", $timestamp + $timeoffset * 3600);
  $subject = "[".$date."] ".$subject;}
 
===如果需要所有版块都自动加日期,则替换为===
 
$date = gmdate("y/m/d", $timestamp + $timeoffset * 3600);
        $subject = "[".$date."] ".$subject;
4、更新缓存
Categories: Other Tags: ,

在windows下用dbg在emacs里面调试程序

December 10th, 2008 No comments

在windows下面也可以用gdb调试程序了.跟在linux下面一样,先到mingw的主页

http://sourceforge.net/projects/mingw/,下载gdb包来安装,地址:

http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=20507

选择适合的版本下载(我选择的是gdb-6.8-mingw-3.tar.bz2),下载后解压就会得到
几个文件夹,跟mingw下面的文件夹是一一对应的,直接复制过去就可以了,
调试上图:
screen_gdb

使用:
当你在Emacs里面编辑好文件以后,编译.记得编译时要添加编译选项g,
比如我编译test.cpp时使用的是 g++ -ggdb3 test.cpp -o test.exe
,编译好以后就可以进行调试了,M-x gdba RET,你就会看到上面这样的图片了,开始你的调试之旅吧

Categories: SoftWare Tags: , , , ,

修改DIscuz等级图像显示

October 31st, 2008 No comments

找到代码:

 
   function showstars($num) {
           global $starthreshold;
   3.
 
           $alt = 'alt="Rank: '.$num.'"';
           if(empty($starthreshold)) {
                   for($i = 0; $i < $num; $i++) {
                           echo '<img src="'.IMGDIR.'/star_level1.gif" '.$alt.' />';
                   }
           } else {
                  for($i = 3; $i > 0; $i--) {
                          $numlevel = intval($num / pow($starthreshold, ($i - 1)));
                          $num = ($num % pow($starthreshold, ($i - 1)));
                          for($j = 0; $j < $numlevel; $j++) {
                                  echo '<img src="'.IMGDIR.'/star_level'.$i.'.gif" '.$alt.' />';
                          }
                  }
          }
  }
 
下面加上
 
   function showrankstars($num) {
           echo "<img src=images/rank/$num.gif title='Rank: ".$num."'>";
   }
 
第2步:、templates\default\viewthread.htm
找到
 
   showstars
 
替换成
 
   showrankstars
 
第3步:、templates\default\viewpro.htm
 
找到
 
   showstars
 
替换成
 
   showrankstars
 
有三个改后两个就行了,根据自己需要来改,我自己只改了第2个
 
第4:templates\default\my_grouppermission.htm
 
找到
 
   showstars
 
替换成
 
   showrankstars
Categories: Site Tags: ,

打造适合自己的System

October 14th, 2008 No comments

下面是自己的一些步骤仅供参考:
打造适合自己的系统
1 增加快捷键
1.1 增加Ctrl+R快捷命令行命令
1.1 建立sort目录,将常用操作快捷方式加入到其中(记得将名字改成简单易记的英文
名字),并将sort目录添加到系统环境path中。
Read more…

Categories: SoftWare Tags: , , , , , , , ,

WordPress Tips

October 14th, 2008 No comments
wordpress本身不依靠插件就能实现很多功能,很多人不注意这方面的积累。本文收集一些本人使用Wordpress 过程中的这类知识点,包括基本标签的使用,不用插件就能实现的功能等。标签
<more>
 
More 标签是 WordPress 一个非常有用的特性。它允许你选择切断点,然后在首页上只显示这个点的以上的内容。 More 这个标签同样也会在摘要后面插入一个 "Read more" 链接以鼓励读者带着疑问继续阅读日志。我使用的是 "Continue Reading..."。可能你想使用其他别的文本,那么你怎么去定制化在 More 标签中的链接呢?其实非常简单,到 WordPress 后台管理界面,然后 "Presentation",然后 "Theme Editor"。 最后打开控制首页的主题文件,一般是 "Main Index Template" (或者 index.php)。 你打开文件之后,找到调用日志内容的那一行,大概样子: <?php the_content( );?>
 
更改为:<?php the_content(__('Read more'));?>
 
你也可以通过在样式表上创建一个 class 来样式化上面的链接文本,结果可能如下所示: <?php the_content(__('<span class="moretag">Your text here</span>'));?> Full Text Feed:解决因为加入 more 标签而不能输出全文 Feed 的问题。
Categories: Other Tags:

WordPress 2.5添加自定义文件上传类型(允许上传rar文件方法)

April 1st, 2008 No comments

修改
wp-includesfunctions.php

wordpress2.1.3默认不支持上传rar文件,修改方法如下:
打开wp-includesfunctions.php,查找

‘zip’ => ‘application/zip’,

(第1106行左右),在这一行的下面加上这一行

‘rar’ => ‘application/rar’,

注意后面有个半角的逗号,别复制漏了,引号是半角单引号。

Categories: Other Tags: ,

给超级版主设置版主权限

March 26th, 2008 No comments


引用:

收藏:easonlee
原作:antgawe http://www.discuz.net/thread-241902-1-1.html
版本:4.1,5.0也可以
只能管理版面上的版主,不能管理和版主相关联的其他管理组人员

==========================================================

引用:

附:允许版主修改论坛简介 For 4.1

http://www.discuz.net/viewthread.php?tid=309826&highlight=%B0%E6%D6%F7

没有增加新的管理组,没有新增数据库,只是在原来管理组-->超级版主的权限作了一下修改,使得超级版主增加了设置版主的权限。
引用:

修改文件:
admincp.php
menu.inc.php

打开admincp.php --------------------------------------------------------------------------------------------------------

找到:
复制内容到剪贴板
代码:
}
if($cpscript) {
require_once DISCUZ_ROOT.'./admin/'.$cpscript.'.inc.php';
} else {
cpheader();
cpmsg('noaccess');
}
在上边添加(注意是添加在}号的上一行)
复制内容到剪贴板
代码:
elseif($action == 'forumsedit'|| $action == 'moderators' ) {
$cpscript = 'forums';
}

}
else{
if($action == 'home') {
$cpscript = 'home';
} elseif((($allowedituser || $allowbanuser) && $action == 'editmember') || ($allowbanip && $action == 'ipban')) {
$cpscript = 'members';
} elseif($action == 'forumrules') {
$cpscript = 'forums';
} elseif($allowpostannounce && $action == 'announcements') {
$cpscript = 'announcements';
} elseif(($allowmoduser && $action == 'modmembers') || ($allowmodpost && ($action == 'modthreads' || $action == 'modreplies'))) {
$cpscript = 'moderate';
} elseif(($allowcensorword && $action == 'censor') || $action == 'logout') {
$cpscript = 'misc';
} elseif($allowmassprune && $action == 'prune') {
$cpscript = 'prune';
} elseif($action == 'plugins') {
$cpscript = 'plugins';
} elseif($allowviewlog && ($action == 'ratelog' || $action == 'modslog' || $action == 'banlog')) {
$cpscript = 'logs';
}
找到:
复制内容到剪贴板
代码:
elseif($adminid == 2||$adminid == 3 )
将其改为
复制内容到剪贴板
代码:
elseif($adminid == 2)
打开menu.inc.php --------------------------------------------------------------------------------------------------------

找到
复制内容到剪贴板
代码:
if($allowmassprune) {
$menuarray[] = array('name' => $lang['menu_maint_prune'], 'url' => 'admincp.php?action=prune');
}
在下边添加:
复制内容到剪贴板
代码:
showmenu($lang['menu_forums'], array(array('name' => $lang['menu_forums_add'], 'url' => 'admincp.php?action=forumadd'),
array('name' => $lang['menu_forums_edit'], 'url' => 'admincp.php?action=forumsedit'),
array('name' => $lang['menu_forums_merge'], 'url' => 'admincp.php?action=forumsmerge'),
array('name' => $lang['menu_forums_threadtypes'], 'url' => 'admincp.php?action=threadtypes')));
OK

Categories: Other Tags: ,