存档

2008年5月 的存档

json and jtemplates 来实现前台变化(原创)

2008年5月15日

http://www.fleaphp.cn/bbs/viewthread.php?tid=3247&extra=page%3D1

使用fleaphp来实现json和jtemplates快速实现前台显示与非刷新动态页面。

技术路径

lighttpd 下 discuz的rewrite写法(原创)

2008年5月12日


url.rewrite = ( "^/archiver/((fid|tid)-[\w\-]+\.html)$" => "archiver/index.php?$1",
"^/forum-([0-9]+)-([0-9]+)\.html$" => "forumdisplay.php?fid=$1&page=$2",
"^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "viewthread.php?tid=$1&extra=page\%3D$3&page=$2",
"^/space-(username|uid)-(.+)\.html$" => "space.php?$1=$2",
"^/tag-(.+)\.html$" => "tag.php?name=$1" )

技术路径

关于CMS思考(摘录)

2008年5月9日

http://cms.phpmagazine.net

http://cms.phpmagazine.net/2006/11/the_cms_pattern_thoughts_on_cm_1.html

This CMS have four main parts : Core, modules, plugins and templates.

We go back to the examples that I’ve given in the first part of this article :

Blog = CMS {Core + Modules [categories + articles (plugins comment + anti-spam + trackback ...) + users (plugins registration + ....)]}
Ad Management softwre = CMS {Core + Modules [Ads (plugins stats ...) + Compains (plugins stats ...) + users (plugins registration + purchase ...) + Basket]}
E-Commerce = CMS {Core + Modules [Products (plugins : documentation, download, stats, galery ...) + Users (plugins registration + purchase+support ...) + Basket + ...]}
News portal = CMS {Core + Modules [categories + articles (plugins comment ....) + users (plugins registration + ....)]}

项目路径

install avast4workstation on my linux server

2008年5月6日

1. download avast4workstation
2. tar zxvf avast4workstation
3. run…

安装确实非常简单,且没有任何出错和提示,仅仅在第一次运行时,根据当前用户需要输入授权号(仅申请即可)。

但我安装的原因是得杀某个病毒(卡巴斯基报毒),实际上就是一个恶意的script。但实际情况看,avast4workstation并未能监测到这个毒,故未能杀出。

而我的解决方法如我的blog下面的关于find and xargs perl 方式直接将那段代码替换删除罢了。个人认为此举仅治标不治本,所以linux下权限问题和代码检查以及日志分析监测方面工作今后得认真注意。

技术路径

Install mysql on redhat (转)

2008年5月6日

Install and Configure MySQL on Linux
用 MySQL 有年头了,写篇简单的文档来记录下自己的常用安装和配置过程。本文旨在介绍如何在 Linux 系统上安装 MySQL 数据库服务器,以及基本配置。本文仅仅提供一份快速指南,请访问 MySQL 官方网站获取详细安装、配置指南。

OS: Red Hat Enterprise Linux AS 3.0
MySQL: 5.0.22

源码 tarball 放置在 /home/huangys , 安装目的地是/opt/mysql

1. 准备

创建一个用户来运行 MySQL 守护进程。
# groupadd mysqlg
# useradd –g mysqlg –M –s /sbin/nologin mysqld

解包
# cd /home/huangys
# tar zxvf mysql-5.0.22.tar.gz

2. 配置编译选项

# cd mysql-5.0.22
# ./configure –prefix=/opt/mysql –with-charset=utf8 –with-extra-charsets=all –with-tcp-port=3306 –with-unix-socket-path=/tmp/mysql.sock –with-mysqld-user=mysqld –with-federated-storage-engine

选项说明:
–prefix=/opt/mysql 将MySQL安装到目录/opt/mysql下
–with-charset=utf8 指定缺省字符集为utf8
–with-extra-charsets=all 将MySQL所有支持的字符集编译进来
–with-tcp-port=3306 指定此MySQL实例将监听TCP 3306端口
–with-unix-socket-path=/tmp/mysql.sock 指定UNIX socket文件的路径(为绝对路径)
–wih-mysqld-user=mysqld 指定用来运行MySQL守护进程的用户
–with-federated-storage-engine 支持federated存储引擎

通过指令 configure –help 可以查看全部选项信息。

3. 编译、安装

# make
# make install

4. 初始化

# scripts/mysql_install_db
这将会在安装目录 /opt/mysql 下创建 MySQL 的数据目录 var

5. 配置

在 MySQL 提供的支持文件中复制一个合适的配置档到 MySQL 数据目录中,并命名为 my.cnf
# cp support-files/my-huge.cnf /opt/mysql/var/my.cnf

主要修改点在 [mysqld] 配置块中:

指定允许的最大包尺寸:
max_allowed_packet = 2M

指定最大连接数(默认为100):
max_connections = 1000

指定服务器端字符集:
character_set_server = utf8

强制指定连接使用的字符集:
init_connect = ’set names utf8′
(注意:若连接时使用的是 super user ,则此项不会被执行,MySQL 文档对此有详细解释。)

指定安装目录和数据目录:
basedir = /opt/mysql2/
datadir = /opt/mysql2/var/

忽略Berkeley DB:
skip-bdb
(同理,若也打算忽略 InnoDB,则使用 skip-innodb)

配置InnoDB:
innodb_data_home_dir = /opt/mysql2/var/
innodb_data_file_path = ibdata1:500M;ibdata2:50M:autoextend
innodb_log_group_home_dir = /opt/mysql2/var/
innodb_log_arch_dir = /opt/mysql2/var/
innodb_buffer_pool_size = 384M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

完成编辑此配置档后,记得顺便修改一下 MySQL 数据目录的 ownership:
# cd /opt/mysql
# chown –Rc mysqld.mysqlg var

6. 控制脚本

MySQL提供了一个脚本文件,可以用来方便地控制MySQL守护进程。
# cp support-files/mysql.server /opt/mysql/bin/mysqlctl
# cd /opt/mysql/bin
# chmod 755 mysqlctl

启动:
# /opt/mysql/bin/mysqlctl start
停止:
# /opt/mysql/bin/mysql stop

注意,若启用了 InnoDB 存储引擎,那么第一次启动 MySQL 服务器时,速度会比较慢,因为需要分配在配置档中定义的空间、生成相应的数据文件、日志文件等。

7. Security

安全问题在哪里都是很重要的,特别是对于初安装的新系统而言,尤其如此。

MySQL 往往携带有四个缺省用户,分别是 ‘root’@'localhost’, ‘root’@'%’, ”@’localhost’, ”@’%’.
除了第一个本地root,其他三个(任意来源的root,以及两个匿名用户)都应该删除:

mysql> use mysql
mysql> delete from user where user=”;
mysql> delete from user where user=’root’ and host=’%';

这唯一保留的用户 root@localhost 的密码默认为空,当然不好。为它加上密码:

# /opt/mysql/bin/mysqladmin -uroot -hlocalhost -P3306 -p password my_pass

指令中的 my_pass 就是设定的密码,注意,不要用单引号把它括起来。

8. Appendix

[root@tbox2 root]# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 3 (Taroon)

[root@tbox2 root]# uname -a
Linux tbox2.test.net 2.4.21-4.ELsmp #1 SMP Fri Oct 3 17:52:56 EDT 2003 i686 i686 i386 GNU/Linux

[root@tbox2 root]# rpm -qa | grep gcc
libgcc-ssa-3.5ssa-0.20030801.41
gcc-g77-3.2.3-20
gcc-ssa-3.5ssa-0.20030801.41
gcc-objc-ssa-3.5ssa-0.20030801.41
compat-gcc-c++-7.3-2.96.122
compat-gcc-7.3-2.96.122
gcc-c++-3.2.3-20
gcc-gnat-3.2.3-20
gcc-objc-3.2.3-20
gcc-c++-ssa-3.5ssa-0.20030801.41
gcc-java-ssa-3.5ssa-0.20030801.41
libgcc-3.2.3-20
gcc-3.2.3-20
gcc-java-3.2.3-20
gcc-g77-ssa-3.5ssa-0.20030801.41

[root@tbox2 root]# rpm -qa | grep glibc
glibc-headers-2.3.2-95.3
glibc-common-2.3.2-95.3
glibc-utils-2.3.2-95.3
glibc-kernheaders-2.4-8.34
glibc-devel-2.3.2-95.3
compat-glibc-7.x-2.2.4.32.5
glibc-2.3.2-95.3
glibc-profile-2.3.2-95.3

[root@tbox2 root]# /opt/mysql/bin/mysql –version
/opt/mysql/bin/mysql Ver 14.12 Distrib 5.0.22, for pc-linux-gnu (i686) using EditLine wrapper

END.

http://huang.yunsong.net/2006/install-and-configure-mysql-on-linux.html

技术路径 ,

linux text replace with many files

2008年5月6日

当前目录下,所有index.html中包含木马的文字替换

find . -name index.html |xargs perl -pi -e ’s/<iframe src=http:\/\/msn.vnm3.cn\/wmpu\/msn.htm width=1 height=1><\/iframe>//i’

http://www.oreilly.com/pub/h/73

技术路径

php-java bridge mysql 连接例子(仅连接)

2008年5月4日
评论关闭

以下例子仅仅是可以访问,但感觉未实现数据池的效果;

require_once("./java/java/Java.inc");

/* autoload NAME.jar from include_path/NAME/NAME.jar or ~/lib/NAME.jar */
//java_autoload();
java_require("j2ee.jar;mysql-connector-java-5.1.6-bin.jar;commons-configuration-1.4.jar;commons-lang-2.3.jar;commons-logging-1.1.jar;commons-collections-3.2.jar;commons-beanutils-core-1.7.0.jar;commons-dbcp-1.2.2.jar;commons-pool-1.3.jar");
//phpinfo();

try {
    echo "";
    echo "Setting up data source:";

    $t = new java("org.apache.commons.dbcp.BasicDataSource");
    $t->setDriverClassName("org.gjt.mm.mysql.Driver");
    $t->setUsername("root");
    $t->setPassword("");
    $t->setUrl("jdbc:mysql://localhost:3306/test");
    $t->setMaxActive(10);

    echo "Done.";

    $conn = new java("java.sql.Connection");
    $stmt = new java("java.sql.Statement");
    $rset = new java("java.sql.ResultSet");

    echo "Creating connection.";
    $conn = java_values($t->getConnection());
    echo $conn;
    echo "Creating statement.";
    $stmt = java_values($conn->createStatement());
    echo $stmt;
    echo "Executing statement.";
    $rset = java_values($stmt->executeQuery("select * from fad_upload_33_5"));
    echo $rset;
    echo "Results:";
    $numcols = java_values($rset->getMetaData()->getColumnCount());
    print_r($numcols);
    echo "numclos=".$numcols;
    echo "";

    while(java_values($rset->next()))
    {
      for($i=1;$i<=$numcols;$i++)
      {
        echo "-".java_values($rset->getString($i));
      }
      echo "";
    }

    echo "getMaxActive:".$t->getMaxActive();
    echo "getNumActive:".$t->getNumActive();
    echo "getMaxIdle:".$t->getMaxIdle();
    echo "getInitialSize:".$t->getInitialSize();
    echo "getMaxOpenPreparedStatements:".$t->getMaxOpenPreparedStatements();
    echo "";

} catch (JavaException $ex) {
  echo "An exception occured: "; echo $ex; echo "\n";
}

技术路径 ,