Archive

Archive for May, 2008

字符集的问题

May 17th, 2008 No comments

GBK版与UTF-8版的区别:

中文 GBK版:
  GBK是在国家标准GB2312基础上扩容后兼容GB2312的标准,文字编码是双字节来表示的,即不论中、英文字符均使用双字节来表示,只不过为区分中文,将其最高位都定成1。GBK包含全部中文字符。

中文 UTF-8版:
  至于UTF-8编码则是用以解决国际上字符的一种多字节编码,它对英文使用8位(即一个字节),中文使用24位(三个字节)来编码。对于英文字符较多的网站则用UTF-8节省空间。UTF-8编码的文字可以在各国各种支持UTF8字符集的浏览器上显示。
例如,若网站采用UTF8编码,则在国外的英文IE上也能显示中文,而无需他们下载IE的中文语言支持包。
UTF-8包含全世界所有国家需要用到的字符。

window是下查看系统字符集的命令chcp

如果是中文简体的系统,应该会显示“活动的代码页: 936”,就是cp936,cp936是windows系统第936号编码,也就是国标的gbk编码,相同的东西叫法不一样而已。big5是cp960。

Categories: 网站建设 Tags:

apache中文url的理解

May 12th, 2008 No comments

通过apache下载url中含有中文的目录或文件会出现404错误,经查看是因为apache对中文url的支持有问题。
1.IE访问WEB的简单顺序为:
IE<->apache<->文件系统
即IE向apache发送URL请求,该请求是通过某种编码做了encode的,apache接到请求后对其进行解码,然后再用解码后的地址到文件系统获取请求的内容返回到客户端的IE。
从以上顺序可以看出,如果要正常使用中文路径的URL,必须保证:
1,IE端到apache端的URL请求的编码和解码的字符集必须一致,
2,apache到文件系统获取中文路径内容使用的字符集也要跟文件系统的文件名的编码一致。

2.ext2、ext3等文件系统(ufs文件系统估计也是)不像ntfs或者fat32文件系统,前者文件名是用原码的,不作任何编码,而后者是通过Unicode编码的,故而在win机器上的apache到文件系统获取中文路径的文件的问题不大,但是在Linux/Unix上,就必须保证使用正确的字符编码才能正确访问中文路径了。

3.IE默认是通过UTF8发送URL请求的,如果不想用UTF-8,即必须修改IE的配置,具体方法是IE选项->高级->不选总是以UTF-8发送URL。

4.ftp协议一般都是通过GBK编码作为路径编码传输文件的,故而要正确访问ext2、ext3经过ftp传输的中文路径文件,必须使用GBK才能正确访问到,用zh_CN.GB18030编码可以成功访问。

Categories: 网站建设 Tags:

给php新手的一个好东西

May 12th, 2008 No comments

自己刚开始学,有些php变量用echo显示不了,就把它们写进文件。先在脚本的同目录下建立1.txt,然后在要检测的变量后面加上下面的小代码。

$fp=fopen("1.txt",'w');
fwrite($fp,$name);

简单的东西但是比较省事。

Categories: 网站建设 Tags:

帝国后台批量添加附件的方法

May 11th, 2008 2 comments

注意:这个方法只是让上传的附件入库到enewsfile数据表,主要处理上传大文件的问题,小文件不用用它。 

修改enews.php

//删除目录文件
elseif($enews=="DelPathFile")
{
        $filename=$_POST['filename'];
        DelPathFile($filename,$logininid,$loginin);
}

后插入

//插入文件名到数据库
elseif($enews=="InsertPathFile")
{
        $filename=$_POST['filename'];
        InsertPathFile($filename,$logininid,$loginin,$classid);
}

查找“EditPrintTemp,DelPathFile,”在他后面加“InsertPathFile,”

在userfun.php文件中加入

function insertpathfile( $filename, $userid, $username,$classid,$xfile)
{
    global $empire;
    global $dbtbpre;
    checklevel( $userid, $username, $classid, "file" );
    $count = count( $filename );
    if ( empty( $count ) )
    {
        printerror( "NotFileid", "history.go(-1)" );
    }
    $i = 0;
    for ( ; $i < $count; ++$i )
    {
        if ( strstr( $filename[$i], ".." ) )
        {
        }
        else
        {
          $dfile = returnpathfile( $filename[$i] ); 
    $sql = $empire->query( "INSERT INTO `{$dbtbpre}enewsfile` VALUES (NULL,'$dfile', 315341, '$xfile', 'admin', '2007-12-12 15:48:59','$classid','$dfile', 1, 0, 17, 0, 1);" );
        }
    }
    insert_dolog( "" );
    printerror( "InsertDataBaseFileSuccess", $_SERVER['HTTP_REFERER'] );
}

将/admin/file/FilePath.php的文件结尾部分对照修改为下面的东西

<td height="25"><input type="submit" name="enews" id="enews" value="InsertPathFile"></td>
   <td ><input type="submit" name="enews" id="enews" value="DelPathFile"></td>
          <td height="25"><select name="classid" id="classid">
            <option value="0">所有栏目</option>
            <?=$do_class?>
          </select></td>
    <td><input type="text" id="xfile" name="xfile" value="文件路径" /></td>

开头部分添加

include("../../class/userfun.php");
$fcjsfile='../../data/fc/cmsclass.js';
$do_class=GetFcfiletext($fcjsfile);

删除掉

<input name="enews" type="hidden" id="enews" value="DelPathFile">

在e\data\language\gb\pub\message.php中添加

$message_r['InsertDataBaseFileSuccess']="文章已经插入到数据库";

 

Categories: 整站程序 Tags:

xubuntu8.04编译安装apache

May 9th, 2008 No comments

参考帖子

http://cpccai.javaeye.com/blog/150180

提示有错

configure: error: C compiler cannot create executables 

 
make: *** 没有指明目标并且找不到 makefile

 在新立得里搜apr安装相关的包

参考帖子中的命令如果不能运行,在前面加sudo。

Categories: 网站建设 Tags: