Skip navigation.

小群纪

lxqun's blog

js 取 cookie 的中文乱码

js 取 cookie 的中文乱码
php 写 cookie

$username="小群";
$username=mb_convert_encoding($username,"UTF-8","GB2312");  //因为 此文件为ascii 编码
//$username=iconv("GB2312","UTF-8",$username);

$username=urlencode($username);  //这个 函数出来的 结果 与 js cookie 

setcookie('testname',$username,time()+3600);


js 取cookie
//document.write( document.cookie);
document.writeln(decodeURI("<?= $username ?>")) ;

document.writeln(GetCookie("testname")) ;

function GetCookie(cookieName){
    var cookieString = document.cookie;
    //return cookieString;
    var start = cookieString.indexOf(cookieName + '=');
    if (start == -1) 
    return null;
    start += cookieName.length + 1;
    var end = cookieString.indexOf(";", start);
    if (end == -1) 
    return decodeURI(cookieString.substring(start));
    //return unescape(cookieString.substring(start));
    
    return decodeURI(cookieString.substring(start, end));
    //return unescape(cookieString.substring(start, end));
}


因为我们php写cookie 直接 是原来的 string,未加 urlencode 这类函数.
js 取 cookie 时发现 与 urlencode(string) 后的 结果 相同.

所以 在 js 中 改 unescape 为 decodeURI

js 取cookie 好像也只认 utf8 编码的.所以
php写cookie之前 要 转为utf8

硬盘空间配额 file system quota

, , ,

硬盘空间配额 file system quota
我们的server 出了问题, 除了root 用户,可以正常上传文件 ,其它 用户, 包括 apache 都不可以 正常写入文件.写任何文件 都是 0 字节.

好多天来, 重装 apache php mysql ,可以暂时解决 问题,但没过多久问题还是 出来了.
一开始 重装 后 可以用上几天, 现在装完就没用.

这样一天 就过去 也没找到问题.

今天 用某用户 vi 写一文件 报错了
 E514: write error (file system full?)

找到 一篇 说
...turns out I went over my quota on the server...
kevin 说空间配额 问题?

df 查一下

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              2016016   1937348         0 100% /
none                   1037212         0   1037212   0% /dev/shm
/dev/sda5             70880216   1750920  65528732   3% /usr
/dev/sda3              2016044    163708   1749924   9% /var



my god. 我们的网站放在 /home 下的.空间全用光了.
文件 当然写不进去了.



perl 正则表达式 去除中文

[^_0-9a-zA-Z\-.=+\(\),;'"`<>\[\]\$ ]



在 js 中 可用
[^\x00-\xFF]

linux 下的 apache + mysql + php

主要是 php
./configure --with-apxs2=/home/webadm/bin/apxs --disable-debug --with-mysql=/home/mysql5 --enable-so --with-libxml-dir=/home/libxml --enable-mbstring --with-gd --with-zlib --with-png --with-jpeg --with-xsl=/home/libxslt/lib


----------
xsl libxslt 的加载php5 为
--with-xsl=/home/libxslt/lib
不是
--with-libxsl-dir=/

还头一次在我的电脑上杀毒

现在的病毒 确实不是我所解决得了。有太多的文件 被感染。
而且我又不可以狠下心,把这些全删除掉。
卡巴斯基 试用,可以。
几乎全部的 exe 文件都被感染
viking.kl

电脑真是减寿啊。

安装pear

pear安装

unix:
运行
lynx -source http://go-pear.org | php
这实际上就是用lynx得到这个脚本并用管道传递给php程序以shell脚本的方式运行安装。

windows

打开这个
http://go-pear.org/
将 脚本 存为 pear_install.php

用dos 运行

php.exe pear_install.php

若有路径问题,无法在cmd 下 启动 , 我是在php目录下 建一 bat 文件 内容为
cmd.exe

pear_install.php中有一行
$pfc_packages

这个数组指定 需安装某些 pear 包

执行安装

最后 在 php.ini 中加上 pear 的路径


===================
资源:
pear的网站 http://pear.php.net/
PEAR简介:用PEAR来写你的下一个php程序 http://www-900.ibm.com/developerWorks/cn/linux/sdk/php/pear1/index.shtml
PEAR:常用模块 http://www-900.ibm.com/developerWorks/cn/linux/sdk/php/pear2/index.shtml
PEAR实践:PHP中MVC机制的实现 http://www-900.ibm.com/developerWorks/cn/linux/sdk/php/pear5/index.shtml
PEAR:使用PHPDoc轻松建立你的PEAR文档 http://www-900.ibm.com/developerWorks/cn/linux/sdk/php/pear3/index.shtml
PEAR:创建中间的数据库应用层 http://www-900.ibm.com/developerWorks/cn/linux/sdk/php/pear4/index.shtml

电脑再次中病毒 2007-04-08

电脑再次中病毒

首先,我的电脑是不装杀毒软件的,并且是给大家随便用的。出现病毒应该是正常情况,这也意味着我的电脑与我,已经开始与病毒做斗争。

症状:windows\ 下 多个 8y,9y,log1_ 这样的东西。
删除后 发现 每过1分钟,进程多出一个 IExplore,共6个后, 停止增加。每一个进程 用18M,共用去100M 内存。

在无杀毒软件可用的情况下,
用Ghost 还原上次的备份, 开机就发现 已经中毒了。因为开机时 有些服务已经启动。apache,mysql 放在 D盘的。
看来这个病毒已经 感染了 所有 exe 文件.
舍不得删除啊,改了目录名。

再用Ghost 还原,这次开机未有病毒了.
但还未根治,也许只能 Delete all exe programs .

重装linux 去掉 Fedora5 用旧的 RedHat 9

问题多多
1, 我的screen 是什么?识不出来了.
2, firefox 没了,自己下.
还好 , http://www.mozilla.com/en-US/firefox/
2.0.0.3 for Linux i686, Chinese (Simplified) (9.2MB)
网站自识别 系统 不错.
tar.gz 包 , tar zvft XXX 解压后 ... 没有安装文件,只有一个 firefox 可执行
可用. 不必安装..

mysql 的 rand 与分页

,

用了 rand() 并且要 分页.

Select * From table order by rand() Limit 10


问题是 分页一下,就会 重新对全部记录随机 一次.

若为 rand(100) 加上基数
则 Limit 不会 重新随机..
Select * From table order by rand($r) Limit 10,10

apache配置为 同一个IP 两个端口指向两个路径

,

apache
httpd.conf
加入以下 配置 虚拟机 代码

Listen 80
Listen 8000

NameVirtualHost *:80
NameVirtualHost *:8000

<VirtualHost *:80>
    DocumentRoot "/home/webadm/htdocs"
    ServerName *:80
</VirtualHost>

<VirtualHost *:8000>
    DocumentRoot "/home/webadm/htdocs/popen"
    ServerName *:8000
</VirtualHost>



OK,但 发现另一问题, linux 下好像不能访问 8000 端口?
service iptables stop 

关闭 iptables