smarty cache缓存的使用
星期四, 五月 20th, 2010机器实在太老了。。
在增加到8W条文章
TAG表已经增加到了30多万条了
10 个表 总计 415,762
在我那个老电脑上。。(p4 1.6 256内存)
很快。。内存不足了。。只剩下4MB剩余内存
于是TAOBAO上买了个 512的SDRAM
(全文…)
机器实在太老了。。
在增加到8W条文章
TAG表已经增加到了30多万条了
10 个表 总计 415,762
在我那个老电脑上。。(p4 1.6 256内存)
很快。。内存不足了。。只剩下4MB剩余内存
于是TAOBAO上买了个 512的SDRAM
(全文…)
哈。刚接触jquery
以前连JAVASCRIPT都不会。
JQUERY好方便。很容易理解。
几行代码就足够搞定了
(全文…)
找了几个函数
目前用的是第一个,虽然。。。不是很帅。。但是还是比较准的
/** * 将一个字串中含有全角的数字字符、字母、空格或'%+-()'字符转换为相应半角字符 * * @access public * @param string $str 待转换字串 * * @return string $str 处理后字串 */ function make_semiangle($str) { $arr = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E', 'F' => 'F', 'G' => 'G', 'H' => 'H', 'I' => 'I', 'J' => 'J', 'K' => 'K', 'L' => 'L', 'M' => 'M', 'N' => 'N', 'O' => 'O', 'P' => 'P', 'Q' => 'Q', 'R' => 'R', 'S' => 'S', 'T' => 'T', 'U' => 'U', 'V' => 'V', 'W' => 'W', 'X' => 'X', 'Y' => 'Y', 'Z' => 'Z', 'a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', 'e' => 'e', 'f' => 'f', 'g' => 'g', 'h' => 'h', 'i' => 'i', 'j' => 'j', 'k' => 'k', 'l' => 'l', 'm' => 'm', 'n' => 'n', 'o' => 'o', 'p' => 'p', 'q' => 'q', 'r' => 'r', 's' => 's', 't' => 't', 'u' => 'u', 'v' => 'v', 'w' => 'w', 'x' => 'x', 'y' => 'y', 'z' => 'z', '(' => '(', ')' => ')', '〔' => '[', '〕' => ']', '【' => '[', '】' => ']', '〖' => '[', '〗' => ']', '“' => '[', '”' => ']', '‘' => '[', '’' => ']', '{' => '{', '}' => '}', '《' => '<', '》' => '>', '%' => '%', '+' => '+', '—' => '-', '-' => '-', '~' => '-', ':' => ':', '。' => '.', '、' => ',', ',' => '.', '、' => '.', ';' => ',', '?' => '?', '!' => '!', '…' => '-', '‖' => '|', '”' => '"', '’' => '`', '‘' => '`', '|' => '|', '〃' => '"', ' ' => ' '); return strtr($str, $arr); }
另外还有一个
看起来很帅的代码
不过貌似有问题
虽然全角是转半角了
但是有部分中文字也出错了貌似。
function &StrToDBC($str,$Encode='GBK'){ if($Encode!='UTF8')$str=mb_convert_encoding($str,'UTF-8',$Encode); $ret=''; for($i=0;$s1=$str[$i],$i<strlen($str);$i++){ if(($c=ord($s1))&0x80){ $s2=$str[++$i]; $s3=$str[++$i]; $c=(($c&0xF)<<12)|((ord($s2)&0x3F)<<6)|(ord($s3)&0x3F); if($c==12288){ $ret.=' '; }elseif($c>65280&&$c<65375){ $c-=65248; $ret.=chr($c); }else{ $ret.=$s1.$s2.$s3; } }else{ $ret.=$str[$i]; } }
最近模仿UCHOME的DOING
我寸在MYSQL的时间都是unix时间。
(全文…)
PHP发送中文、Ajax接收
只需在php顶部加入一句:
header('Content-type: text/html;charset=GB2312');
xmlHttp会正确解析其中的中文。
Ajax发送中文、PHP接收
这个比较复杂:
Ajax中先用encodeURIComponent对要提交的中文进行编码
PHP中:
$view=iconv( 'UTF-8', 'gb2312//IGNORE' , $_POST['view']);
CAPTCHA,其全称是“全自动区分计算机和人类的图灵测试”(completely automated public Turing test to tell computers and humans apart)。
现在通过使用 Google免费的reCAPTCHA服务,您可以轻松地在您自己的网站上利用这项技术。
首先
我们需要申请一个 KEY
类似于GOOGLE MAP的API KEY一样
在reCAPTCHA网站注册一个API key(免费)。并记录下你的private key和 public key。
https://admin.recaptcha.net/accounts/signup/
然后去GOOGLE CODE 下载类库
http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest
调用类
require_once('recaptchalib.php'); $publickey = "..."; // you got this from the signup page echo recaptcha_get_html($publickey);
验证部分
require_once('recaptchalib.php'); $privatekey = "..."; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); }
官方还提供了一个 EXAMPLE
<html>
<body>
<form action="" method="post">
<?php
require_once('recaptchalib.php');
$publickey = "...";
$privatekey = "...";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# are we submitting the page?
if ($_POST["submit"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "You got it!";
# in a real application, you should send an email, create an account, etc
} else {
# set the error code so that we can display it. You could also use
# die ("reCAPTCHA failed"), but using the error message is
# more user friendly
$error = $resp->error;
}
}
echo recaptcha_get_html($publickey, $error);
?>
<br/>
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>需要用中文分词来获取TAG
找了DISCUZ的觉得不错,是在线的,不需要本地的词库
<?php //强制使用字符集 @header('Content-Type: text/html; charset=gbk'); $subjectenc =$_POST['subject']; $messageenc = preg_replace($_POST['message']); $data = @implode('', file("http://keyword.discuz.com/related_kw.html?title=$subjectenc&content=$messageenc&ics=gbk&ocs=gbk")); if($data) { $parser = xml_parser_create();//建立一个 XML 解析器 xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $values, $index);//将 XML 数据解析到数组中 xml_parser_free($parser); $kws = array(); foreach($values as $valuearray) { if(in_array($valuearray['tag'],array('kw','ekw'))) { //kw ekw是什么意思? $kws[] = iconv('utf-8','gbk',$valuearray['value']);//编码转换 } }} //最后出来的是数组. print_r($kws); ?>
文件上传表单的处理
<form action="http://qlj.sh.cn/post.php" enctype="multipart/form-data" method="post"> <input name="MAX_FILE_SIZE" type="hidden" value="1000" /> <input name="upfile" type="file" /> <input type="submit" value="上传文件" /> </form>
Warning: date() [function.date]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Chongqing’ for ‘CST/8.0/no DST’ instead in /home/www/qfclub/user/upimg.php on line 16