久艹网,亚洲一日韩欧美中文字幕2019,国产欧美日韩精品专区黑人,一区二区三区久久99

中山php|最優(yōu)網(wǎng)絡(luò)中山做網(wǎng)站 中山php建站

最優(yōu)良人

2011/08/25 at 12:18

asyncbox異步彈出窗口,jq彈出層插件,可異步加載頁面

AsyncBox(異步盒子)是一款基于 jQuery 的彈窗插件。能夠?qū)崿F(xiàn)網(wǎng)站的整體風(fēng)格效果,給用戶一個新的視覺享受。主要模擬常用的 alert、confirm、prompt、open 和擴展了一些對話框。它通過回調(diào)函數(shù)觸發(fā)事件動作并執(zhí)行,使操作區(qū)域更加明了、統(tǒng)一。而且能夠在主流瀏覽器中靈活運用。

介紹及下載地址 http://www.nnhuashi.com/asyncbox/index.html

實例:
$('#select-furns').click(function() {
asyncbox.open({
id: 'select-form',
title: $(this).val(),
url: 'index.php',
width: 700,
height: 400,
tipsbar: {
title: '操作提示',
content: '請先通過下方 <strong>篩選操作</strong>,篩選出你需要的家具。'
},
data: {
module: 'House_Furniture',
load: 'AjaxFurniture',
col_key: '<?php echo $_GET['col_key']; ?>',
lang: '<?php echo getLanguage(); ?>'
}
});
});
注意:如果通過a標簽點擊彈出,如果a標簽的href為javascript:;或javascript:void(0);在ie6下可能會產(chǎn)生阻斷,導(dǎo)致頁面無法打開
解決的方法是用href=#或者不用a標簽
為了防止瀏覽器跳到頂部,可以加上onclick="return false;" ,或者可以用href=#click這樣的形式,這樣點擊的話如果有id=click的元素瀏覽器會定位到那里,如果沒有,則原地不動

標簽:,
comments Comments (20)    -
2011/08/25 at 11:58

解決jquery和prototype沖突,jquery和prototype共存的方法

今天遇到一個項目的修改,由于該項目之前是使用prototype框架,而我拿手的是使用jquery框架,但是又不想全部重寫原來的頁面效果,所以在頁面引入了jquery文件,但是發(fā)現(xiàn)原來的js效果消失了,這是因為他們共同使用了$這個對象,造成了重寫覆蓋,解決方法是重定義jquery的這個對象

首先在頁面最開頭引入jquery文件,一定要在prototype文件引入之前,然后緊接著重寫$

<script type="text/javascript" src="data/jquery.min.js"></script>
<script type="text/javascript">
var jQuery=$;
</script>

然后在后面運用jquery時把原來使用$的地方全部換成jQuery就可以了

標簽:,
comments Comments (251)    -
2011/08/24 at 23:53

php在windows主機或虛擬空間利用socket在線發(fā)送郵件

在linux虛擬主機下一般可以利用php的mail函數(shù)直接發(fā)郵件
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

但是在windows虛擬主機下則不能直接使用mail函數(shù),可以通過socket了,采用郵箱的smtp服務(wù)在線發(fā)送郵件(現(xiàn)在的163免費郵箱一注冊就可以免費使用這個服務(wù),并且默認開通的),比較成熟的在線發(fā)送郵件類有php_mailer,功能很強大,不過下面介紹的是一個比較簡單的socket郵件發(fā)送類,應(yīng)付一般的需求足夠了。

使用方法是:

require_once (dirname(__FILE__).'/email.class.php');//該類的代碼附在文章后面
//##########################################
$smtpserver = "smtp.163.com";//SMTP服務(wù)器
$smtpserverport =25;//SMTP服務(wù)器端口
$smtpusermail = "XXX@163.com";//SMTP服務(wù)器的用戶郵箱
$smtpemailto = "XXXXX@qq.com";//發(fā)送給誰
$smtpuser = "s_XXX";//SMTP服務(wù)器的用戶帳號
$smtppass = "aaa123456";//SMTP服務(wù)器的用戶密碼
$mailsubject = "收到用戶的產(chǎn)品詢價";//郵件主題
$mailbody = "用戶提交了產(chǎn)品詢價,請登錄網(wǎng)站后臺查看!";//郵件內(nèi)容
$mailtype = "HTML";//郵件格式(HTML/TXT),TXT為文本郵件
//##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);//這里面的一個true是表示使用身份驗證,否則不使用身份驗證.
$smtp->debug = false;//是否顯示發(fā)送的調(diào)試信息
$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);

附簡單的郵件發(fā)送類代碼

<?
class smtp
{
/* Public Variables */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;

/* Private Variables */
var $sock;

/* Constractor */
function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass)
{
$this->debug = FALSE;
$this->smtp_port = $smtp_port;
$this->relay_host = $relay_host;
$this->time_out = 30; //is used in fsockopen()
#
$this->auth = $auth;//auth
$this->user = $user;
$this->pass = $pass;
#
$this->host_name = "localhost"; //is used in HELO command
$this->log_file ="";

$this->sock = FALSE;
}

/* Main Function */
function sendmail($to, $from, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
{
$mail_from = $this->get_address($this->strip_comment($from));
$body = ereg_replace("(^|(\r\n))(\\.)", "\\1.\\3", $body);
$header .= "MIME-Version:1.0\r\n";
if($mailtype=="HTML"){
$header .= "Content-Type:text/html\r\n";
}
$header .= "To: ".$to."\r\n";
if ($cc != "") {
$header .= "Cc: ".$cc."\r\n";
}
$header .= "From: $from<".$from.">\r\n";
$header .= "Subject: ".$subject."\r\n";
$header .= $additional_headers;
$header .= "Date: ".date("r")."\r\n";
$header .= "X-Mailer:By Redhat (PHP/".phpversion().")\r\n";
list($msec, $sec) = explode(" ", microtime());
$header .= "Message-ID: <".date("YmdHis", $sec).".".($msec*1000000).".".$mail_from.">\r\n";
$TO = explode(",", $this->strip_comment($to));

if ($cc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
}

if ($bcc != "") {
$TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
}

$sent = TRUE;
foreach ($TO as $rcpt_to) {
$rcpt_to = $this->get_address($rcpt_to);
if (!$this->smtp_sockopen($rcpt_to)) {
$this->log_write("Error: Cannot send email to ".$rcpt_to."\n");
$sent = FALSE;
continue;
}
if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
$this->log_write("E-mail has been sent to <".$rcpt_to.">\n");
} else {
$this->log_write("Error: Cannot send email to <".$rcpt_to.">\n");
$sent = FALSE;
}
fclose($this->sock);
$this->log_write("Disconnected from remote host\n");
}
//echo "<br>";
//echo $header;
return $sent;
}

/* Private Functions */

function smtp_send($helo, $from, $to, $header, $body = "")
{
if (!$this->smtp_putcmd("HELO", $helo)) {
return $this->smtp_error("sending HELO command");
}
#auth
if($this->auth){
if (!$this->smtp_putcmd("AUTH LOGIN", base64_encode($this->user))) {
return $this->smtp_error("sending HELO command");
}

if (!$this->smtp_putcmd("", base64_encode($this->pass))) {
return $this->smtp_error("sending HELO command");
}
}
#
if (!$this->smtp_putcmd("MAIL", "FROM:<".$from.">")) {
return $this->smtp_error("sending MAIL FROM command");
}

if (!$this->smtp_putcmd("RCPT", "TO:<".$to.">")) {
return $this->smtp_error("sending RCPT TO command");
}

if (!$this->smtp_putcmd("DATA")) {
return $this->smtp_error("sending DATA command");
}

if (!$this->smtp_message($header, $body)) {
return $this->smtp_error("sending message");
}

if (!$this->smtp_eom()) {
return $this->smtp_error("sending <CR><LF>.<CR><LF> [EOM]");
}

if (!$this->smtp_putcmd("QUIT")) {
return $this->smtp_error("sending QUIT command");
}

return TRUE;
}

function smtp_sockopen($address)
{
if ($this->relay_host == "") {
return $this->smtp_sockopen_mx($address);
} else {
return $this->smtp_sockopen_relay();
}
}

function smtp_sockopen_relay()
{
$this->log_write("Trying to ".$this->relay_host.":".$this->smtp_port."\n");
$this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);
if (!($this->sock && $this->smtp_ok())) {
$this->log_write("Error: Cannot connenct to relay host ".$this->relay_host."\n");
$this->log_write("Error: ".$errstr." (".$errno.")\n");
return FALSE;
}
$this->log_write("Connected to relay host ".$this->relay_host."\n");
return TRUE;;
}

function smtp_sockopen_mx($address)
{
$domain = ereg_replace("^.+@([^@]+)$", "\\1", $address);
if (!@getmxrr($domain, $MXHOSTS)) {
$this->log_write("Error: Cannot resolve MX \"".$domain."\"\n");
return FALSE;
}
foreach ($MXHOSTS as $host) {
$this->log_write("Trying to ".$host.":".$this->smtp_port."\n");
$this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);
if (!($this->sock && $this->smtp_ok())) {
$this->log_write("Warning: Cannot connect to mx host ".$host."\n");
$this->log_write("Error: ".$errstr." (".$errno.")\n");
continue;
}
$this->log_write("Connected to mx host ".$host."\n");
return TRUE;
}
$this->log_write("Error: Cannot connect to any mx hosts (".implode(", ", $MXHOSTS).")\n");
return FALSE;
}

function smtp_message($header, $body)
{
fputs($this->sock, $header."\r\n".$body);
$this->smtp_debug("> ".str_replace("\r\n", "\n"."> ", $header."\n> ".$body."\n> "));

return TRUE;
}

function smtp_eom()
{
fputs($this->sock, "\r\n.\r\n");
$this->smtp_debug(". [EOM]\n");

return $this->smtp_ok();
}

function smtp_ok()
{
$response = str_replace("\r\n", "", fgets($this->sock, 512));
$this->smtp_debug($response."\n");

if (!ereg("^[23]", $response)) {
fputs($this->sock, "QUIT\r\n");
fgets($this->sock, 512);
$this->log_write("Error: Remote host returned \"".$response."\"\n");
return FALSE;
}
return TRUE;
}

function smtp_putcmd($cmd, $arg = "")
{
if ($arg != "") {
if($cmd=="") $cmd = $arg;
else $cmd = $cmd." ".$arg;
}

fputs($this->sock, $cmd."\r\n");
$this->smtp_debug("> ".$cmd."\n");

return $this->smtp_ok();
}

function smtp_error($string)
{
$this->log_write("Error: Error occurred while ".$string.".\n");
return FALSE;
}

function log_write($message)
{
$this->smtp_debug($message);

if ($this->log_file == "") {
return TRUE;
}

$message = date("M d H:i:s ").get_current_user()."[".getmypid()."]: ".$message;
if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) {
$this->smtp_debug("Warning: Cannot open log file \"".$this->log_file."\"\n");
return FALSE;
}
flock($fp, LOCK_EX);
fputs($fp, $message);
fclose($fp);

return TRUE;
}

function strip_comment($address)
{
$comment = "\\([^()]*\\)";
while (ereg($comment, $address)) {
$address = ereg_replace($comment, "", $address);
}

return $address;
}

function get_address($address)
{
$address = ereg_replace("([ \t\r\n])+", "", $address);
$address = ereg_replace("^.*<(.+)>.*$", "\\1", $address);

return $address;
}

function smtp_debug($message)
{
if ($this->debug) {
echo $message."<br>";
}
}

function get_attach_type($image_tag) { //

$filedata = array();

$img_file_con=fopen($image_tag,"r");
unset($image_data);
while ($tem_buffer=AddSlashes(fread($img_file_con,filesize($image_tag))))
$image_data.=$tem_buffer;
fclose($img_file_con);

$filedata['context'] = $image_data;
$filedata['filename']= basename($image_tag);
$extension=substr($image_tag,strrpos($image_tag,"."),strlen($image_tag)-strrpos($image_tag,"."));
switch($extension){
case ".gif":
$filedata['type'] = "image/gif";
break;
case ".gz":
$filedata['type'] = "application/x-gzip";
break;
case ".htm":
$filedata['type'] = "text/html";
break;
case ".html":
$filedata['type'] = "text/html";
break;
case ".jpg":
$filedata['type'] = "image/jpeg";
break;
case ".tar":
$filedata['type'] = "application/x-tar";
break;
case ".txt":
$filedata['type'] = "text/plain";
break;
case ".zip":
$filedata['type'] = "application/zip";
break;
default:
$filedata['type'] = "application/octet-stream";
break;
}
return $filedata;
}

}
?>

標簽:,
2011/08/24 at 22:09

記錄一下網(wǎng)站百度谷歌的收錄情況,對比兩大搜索引擎的差別

網(wǎng)站上線19天,今天百度終于收錄了首頁,總算度過了這個漫長的考核期,雖然網(wǎng)上一般說法是百度對新站會有一個月左右的考核期,現(xiàn)在這個時候收錄應(yīng)該算正常吧,接下來會不會像某些新站一樣很長一段時間只收錄首頁就要繼續(xù)觀察了。

網(wǎng)站上線第二天,谷歌百度的蜘蛛就造訪了,谷歌很快就收錄并放出了抓到的頁面,百度就先抓取不顯示,剛開始兩條蜘蛛都非常勤快,百度蜘蛛最多一天爬300多次,谷歌蜘蛛3000多次,現(xiàn)在每天一般是前者100次,后者2000次這樣的頻率。

谷歌收錄頁面數(shù)量一直都是穩(wěn)定地增長,到昨天達到將近6000個頁面,并且谷歌給這個博客的權(quán)重還算比較高的,關(guān)鍵詞都能獲得比較好的排名,每天都會有不少ip是通過谷歌搜索技術(shù)問題過來的,并且谷歌對新文章的反應(yīng)速度極快,基本上發(fā)一篇新博文在兩三分鐘內(nèi)會被收錄并且放出來。

百度雖然也會比較快抓取新文章,但是就是不放出,在8月10號也就是10天前放出了通過ip抓取的首頁,然后就一直沒更新快照,前天我把ip都301到域名下來,那個應(yīng)該不會再更新了。

這期間沒有去做什么外鏈,只是在博客里面對百度做了一點小小的優(yōu)化,不知道對今天的收錄有沒有一點影響。

說實話我還是比較看重網(wǎng)站在百度的表現(xiàn),谷歌退出大陸之后,在市場份額方面已經(jīng)很難跟百度抗衡了,百度現(xiàn)在擁有中國大陸絕大部分的搜索流量,對網(wǎng)站的收錄情況直接影響到網(wǎng)站的訪問量。

標簽:, , ,
comments Comments (294)    -
2011/08/23 at 14:13

htaccess在根目錄和子目錄下的執(zhí)行順序

如果在根目錄和子目錄下都存在htaccess文件,默認根目錄下htaccess的規(guī)則是不會被繼承的,如果這些配置需要影響到子目錄,需要手動寫上"RewriteOptions inherit"才能繼承父配置,參考上一篇 htaccess的用法 。

所以如果子目錄也要用到根目錄的配置規(guī)則,最好是重新定義,因為如果單純的繼承的話,根目錄htaccess里面的某些規(guī)則的路徑可能已經(jīng)不適用子目錄。

標簽:
comments Comments (81)    -
2011/08/23 at 14:06

htaccess,apache下分布式配置文件的配置選項和flag標簽

以下指命令的作用域都是.htaccess
RewriteEngine On|Off

RewriteEngine 可用On 或者 Off 打開或關(guān)閉rewrite功能。
rewrite configurations 不會繼承,所以你得給每個你想用 rewrite功能的virtual host加上這個指令。
RewriteBase URL-path

RewriteBase指令顯式地設(shè)置了目錄級重寫的基準URL。在下文中,你可以看見RewriteRule可以用于目錄級的配置文件中 (.htaccess)并在局部范圍內(nèi)起作用,即規(guī)則實際處理的只是剝離了本地路徑前綴的一部分。處理結(jié)束后,這個路徑會被自動地附著回去。默認值是"RewriteBase physical-directory-path"。
在對一個新的URL進行替換時,此模塊必須把這個URL重新注入到服務(wù)器處理中。為此,它必須知道其對應(yīng)的URL前綴或者說URL基準。通常,此前綴就是對應(yīng)的文件路徑。但是,大多數(shù)網(wǎng)站URL不是直接對應(yīng)于其物理文件路徑的,因而一般不能做這樣的假定! 所以在這種情況下,就必須用RewriteBase指令來指定正確的URL前綴。
如果你的網(wǎng)站服務(wù)器URL不是與物理文件路徑直接對應(yīng)的,而又需要使用RewriteBase指令,則必須在每個對應(yīng)的.htaccess文件中指定RewriteRule 。
RewriteCond TestString CondPattern

RewriteCond指令定義了一個規(guī)則的條件,即在一個RewriteRule指令之前有一個或多個RewriteCond指令。條件之后的重寫規(guī)則僅在當(dāng)前URI與pattern匹配并且符合這些條件的時候才會起作用。
Notice:All of these tests can also be prefixed by an exclamation mark ('!') to negate their meaning. 在正則表達式中,如果取反的話要用^,在這里需要用!號取反
RewriteOptions Options

Sets some special options for the rewrite engine.
設(shè)定一些特殊的選項給rewrite.
The Option string can be currently only one:inherit
inherit
此值強制當(dāng)前配置可以繼承其父配置。 在虛擬主機級配置中,它意味著主服務(wù)器的映射表、條件和規(guī)則可以被繼承。 在目錄級配置中,它意味著其父目錄的.htaccess中的條件和規(guī)則可以被繼承。
MaxRedirects=number
為了避免目錄級RewriteRule的無休止的內(nèi)部重定向, 在此類重定向和500內(nèi)部服務(wù)器錯誤次數(shù)達到一個最大值的時候, mod_rewrite會停止對此請求的處理。 如果你確實需要對每個請求允許大于10次的內(nèi)部重定向,可以增大這個值。
This forces the current configuration to inherit the configuration of the parent.
強制當(dāng)前的配置繼承它parent的配置。
在per-virtual-server環(huán)境下,意味著maps, conditions , rules會被繼承!
在per-directory 環(huán)境下 意味著它父目錄的.htaccess配置中的conditions , rules 會被繼承!
RewriteRule Pattern Substitution [flags]

Text:
. 任何單字符
[chars] Character class: One of chars
[^chars] Character class: None of chars
text1|text2 兩者選一個: text1 or text2

Quantifiers:量詞
? 0 or 1 of the 前面的 text
* 0 or N of the 前面的 text (N > 0)
+ 1 or N of the 前面的 text (N > 1)

Grouping:
(text) Grouping of text

可用$N來得到()中的內(nèi)容:
( (a|b) | (c|d))
$1 $2 $3

Anchors:
^ Start of line anchor
$ End of line anchor

Escaping:
\char escape that particular char
(for instance to specify the chars ".[]()" etc.)

注意:沒有并且&

=========================================================================================
flags

1.
'redirect|R [=code]' (強制重定向 redirect)
以http://thishost[:thisport]/(使新的URL成為一個URI) 為前綴的Substitution可以強制性執(zhí)行一個外部重定向。 如果code沒有指定,則產(chǎn)生一個HTTP響應(yīng)代碼302(臨時性移動)。 如果需要使用在300-400范圍內(nèi)的其他響應(yīng)代碼,只需在此指定這個數(shù)值即可, 另外,還可以使用下列符號名稱之一: temp (默認的), permanent, seeother. 用它可以把規(guī)范化的URL反饋給客戶端,如, 重寫``/~''為 ``/u/'',或?qū)?u/user加上斜杠,等等。 注意: 在使用這個標記時,必須確保該替換字段是一個有效的URL! 否則,它會指向一個無效的位置! 并且要記住,此標記本身只是對URL加上 http://thishost[:thisport]/的前綴,重寫操作仍然會繼續(xù)。 通常,你會希望停止重寫操作而立即重定向,則還需要使用'L'標記.
2.
'forbidden|F' (強制URL為被禁止的 forbidden)
強制當(dāng)前URL為被禁止的,即,立即反饋一個HTTP響應(yīng)代碼403(被禁止的)。 使用這個標記,可以鏈接若干RewriteConds以有條件地阻塞某些URL。
3.
'gone|G' (強制URL為已廢棄的 gone)
強制當(dāng)前URL為已廢棄的,即,立即反饋一個HTTP響應(yīng)代碼410(已廢棄的)。 使用這個標記,可以標明頁面已經(jīng)被廢棄而不存在了.
4.
'proxy|P' (強制為代理 proxy)
此標記使替換成分被內(nèi)部地強制為代理請求,并立即(即, 重寫規(guī)則處理立即中斷)把處理移交給代理模塊。 你必須確保此替換串是一個有效的(比如常見的以 http://hostname開頭的)能夠為Apache代理模塊所處理的URI。 使用這個標記,可以把某些遠程成分映射到本地服務(wù)器名稱空間, 從而增強了ProxyPass指令的功能。 注意: 要使用這個功能,代理模塊必須編譯在Apache服務(wù)器中。 如果你不能確定,可以檢查``httpd -l''的輸出中是否有mod_proxy.c。 如果有,則mod_rewrite可以使用這個功能; 如果沒有,則必須啟用mod_proxy并重新編譯``httpd''程序。
5.
'last|L' (最后一個規(guī)則 last)
立即停止重寫操作,并不再應(yīng)用其他重寫規(guī)則。 它對應(yīng)于Perl中的last命令或C語言中的break命令。 這個標記可以阻止當(dāng)前已被重寫的URL為其后繼的規(guī)則所重寫。 舉例,使用它可以重寫根路徑的URL('/')為實際存在的URL, 比如, '/e/www/'.
6.
'next|N' (重新執(zhí)行 next round)
重新執(zhí)行重寫操作(從第一個規(guī)則重新開始). 這時再次進行處理的URL已經(jīng)不是原始的URL了,而是經(jīng)最后一個重寫規(guī)則處理的URL。 它對應(yīng)于Perl中的next命令或C語言中的continue命令。 此標記可以重新開始重寫操作,即, 立即回到循環(huán)的頭部。但是要小心,不要制造死循環(huán)!
7.
'chain|C' (與下一個規(guī)則相鏈接 chained)
此標記使當(dāng)前規(guī)則與下一個(其本身又可以與其后繼規(guī)則相鏈接的, 并可以如此反復(fù)的)規(guī)則相鏈接。 它產(chǎn)生這樣一個效果: 如果一個規(guī)則被匹配,通常會繼續(xù)處理其后繼規(guī)則, 即,這個標記不起作用;如果規(guī)則不能被匹配, 則其后繼的鏈接的規(guī)則會被忽略。比如,在執(zhí)行一個外部重定向時, 對一個目錄級規(guī)則集,你可能需要刪除``.www'' (此處不應(yīng)該出現(xiàn)``.www''的)。
8.
'type|T=MIME-type' (強制MIME類型 type)
強制目標文件的MIME類型為MIME-type。 比如,它可以用于模擬mod_alias中的ScriptAlias指令, 以內(nèi)部地強制被映射目錄中的所有文件的MIME類型為``application/x-httpd-cgi''.
9.
'nosubreq|NS' (僅用于不對內(nèi)部子請求進行處理 no internal sub-request)
在當(dāng)前請求是一個內(nèi)部子請求時,此標記強制重寫引擎跳過該重寫規(guī)則。 比如,在mod_include試圖搜索可能的目錄默認文件(index.xxx)時, Apache會內(nèi)部地產(chǎn)生子請求。對子請求,它不一定有用的,而且如果整個規(guī)則集都起作用, 它甚至可能會引發(fā)錯誤。所以,可以用這個標記來排除某些規(guī)則。 根據(jù)你的需要遵循以下原則: 如果你使用了有CGI腳本的URL前綴,以強制它們由CGI腳本處理, 而對子請求處理的出錯率(或者開銷)很高,在這種情況下,可以使用這個標記。
10.
'nocase|NC' (忽略大小寫 no case)
它使Pattern忽略大小寫,即, 在Pattern與當(dāng)前URL匹配時,'A-Z' 和'a-z'沒有區(qū)別。
11.
'qsappend|QSA' (追加請求串 query string append)
此標記強制重寫引擎在已有的替換串中追加一個請求串,而不是簡單的替換。 如果需要通過重寫規(guī)則在請求串中增加信息,就可以使用這個標記。
12.
'noescape|NE' (在輸出中不對URI作轉(zhuǎn)義 no URI escaping)
此標記阻止mod_rewrite對重寫結(jié)果應(yīng)用常規(guī)的URI轉(zhuǎn)義規(guī)則。 一般情況下,特殊字符(如'%', '$', ';'等)會被轉(zhuǎn)義為等值的十六進制編碼。 此標記可以阻止這樣的轉(zhuǎn)義,以允許百分號等符號出現(xiàn)在輸出中,如: RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE]
可以使'/foo/zed'轉(zhuǎn)向到一個安全的請求'/bar?arg=P1=zed'.
13.
'passthrough|PT' (移交給下一個處理器 pass through)
此標記強制重寫引擎將內(nèi)部結(jié)構(gòu)request_rec中的uri字段設(shè)置為 filename字段的值,它只是一個小修改,使之能對來自其他URI到文件名翻譯器的 Alias,ScriptAlias, Redirect 等指令的輸出進行后續(xù)處理。舉一個能說明其含義的例子: 如果要通過mod_rewrite的重寫引擎重寫/abc為/def, 然后通過mod_alias使/def轉(zhuǎn)變?yōu)?ghi,可以這樣: RewriteRule ^/abc(.*) /def$1 [PT]
Alias /def /ghi
如果省略了PT標記,雖然mod_rewrite運作正常, 即, 作為一個使用API的URI到文件名翻譯器, 它可以重寫uri=/abc/...為filename=/def/..., 但是,后續(xù)的mod_alias在試圖作URI到文件名的翻譯時,則會失效。
注意: 如果需要混合使用不同的包含URI到文件名翻譯器的模塊時, 就必須使用這個標記。混合使用mod_alias和mod_rewrite就是個典型的例子。

For Apache hackers
如果當(dāng)前Apache API除了URI到文件名hook之外,還有一個文件名到文件名的hook, 就不需要這個標記了! 但是,如果沒有這樣一個hook,則此標記是唯一的解決方案。 Apache Group討論過這個問題,并在Apache 2.0 版本中會增加這樣一個hook。
14.
'skip|S=num' (跳過后繼的規(guī)則 skip)
此標記強制重寫引擎跳過當(dāng)前匹配規(guī)則后繼的num個規(guī)則。 它可以實現(xiàn)一個偽if-then-else的構(gòu)造: 最后一個規(guī)則是then從句,而被跳過的skip=N個規(guī)則是else從句. (它和'chain|C'標記是不同的!)
15.
'env|E=VAR:VAL' (設(shè)置環(huán)境變量 environment variable)
此標記使環(huán)境變量VAR的值為VAL, VAL可以包含可擴展的反向引用的正則表達式$N和%N。 此標記可以多次使用以設(shè)置多個變量。 這些變量可以在其后許多情況下被間接引用,但通常是在XSSI (via or CGI (如 $ENV{'VAR'})中, 也可以在后繼的RewriteCond指令的pattern中通過%{ENV:VAR}作引用。 使用它可以從URL中剝離并記住一些信息。
16.
'cookie|CO=NAME:VAL:domain[:lifetime[:path]]' (設(shè)置cookie)
它在客戶端瀏覽器上設(shè)置一個cookie。 cookie的名稱是NAME,其值是VAL。 domain字段是該cookie的域,比如'.apache.org', 可選的lifetime是cookie生命期的分鐘數(shù), 可選的path是cookie的路徑。

標簽:,
comments Comments (100)    -
2011/08/20 at 14:54

PHP定界符EOT的用法

定界符:
另一種給字符串定界的方法使用定界符語法("<<<")。應(yīng)該在 <<< 之后提供一個標識符,然后是字符串,然后是同樣的標識符結(jié)束字符串。
結(jié)束標識符必須從行的第一列開始。同樣,標識符也必須遵循 PHP 中其它任何標簽的命名規(guī)則:只能包含字母數(shù)字下劃線,而且必須以下劃線或非數(shù)字字符開始。

php 中(<<<eot)的用法

有時候我們需要在php輸出比較復(fù)雜的html文本,如果使用雙引號的話,文本里面有雙引號的

 

例:

<?php

while($rs=$db->fetch_array($news)){

echo <<<EOT

<li>

<a href="?{$rs[id]}">{$rs[title]}</a><img src="images/new.gif" alt=""><span>[{$rs[date]}]</span></li>

EOT; //注意,此處的EOT;必須在當(dāng)前行的最前,其前面不允許有任何字符

?>

從上面的例子可以看出<<<eot為開始標識,結(jié)束為eot; 中間引用變量則就為{變量} 這種方法通常用在生成靜態(tài)度頁面時,可以把此代碼寫在靜態(tài)文件中,然后然后用來調(diào)用即可

定界符

給字符串定界的方法使用定界符語法("<<<")。應(yīng)該在 <<< 之后提供一個標識符,然后是字符串,然后是同樣的標識符結(jié)束字符串。

結(jié)束標識符必須從行的第一列開始。同樣,標識符也必須遵循 PHP 中其它任何標簽的命名規(guī)則:只能包含字母數(shù)字下劃線,而且必須以下劃線或非數(shù)字字符開始。

舉個例子:

<?php

$str = <<<EOD

Example of string

spanning multiple lines

using heredoc syntax.

EOD;

?>

但要注意的是:

結(jié)束標識符所在的行不能包含任何其它字符,可能除了一個分號(;)之外。這尤其意味著該標識符不能被縮進,而且在分號之前和之后都不能有任何空格或制表符。同樣重要的是要意識到在結(jié)束標識符之前的第一個字符必須是你的操作系統(tǒng)中定義的換行符。例如在 Macintosh 系統(tǒng)中是 \r。 如果破壞了這條規(guī)則使得結(jié)束標識符不"干凈",則它不會被視為結(jié)束標識符,PHP 將繼續(xù)尋找下去。如果在這種情況下找不到合適的結(jié)束標識符,將會導(dǎo)致一個在腳本最后一行出現(xiàn)的語法錯誤。

如下:

print <<<eot

eot;

中間可以放置變量的,如果是數(shù)組變量也是可以的。

假如數(shù)組

$arrTest=array("abc","123");

在eot之間可以用以下方式置入變量

"{$arrTest[0]}"

標簽:,
comments Comments (120)    -
2011/08/19 at 23:37

wordpress防止百度收錄動態(tài)鏈接,針對百度做SEO優(yōu)化

通過網(wǎng)站的服務(wù)器日志分析,百度經(jīng)常會先訪問博客文章的動態(tài)頁,再被301重定向到固定鏈接,可能由于wordpress是國外的產(chǎn)物,沒有專門針對百度做seo,甚至連robots文件都沒有,今天主要做了以下優(yōu)化工作,過幾天看效果如何:

一,安裝wp的百度地圖插件:Baidu Sitemap Generator,生成網(wǎng)站地圖

插件使用方法:

1.在 http://www.tianchuangseo.com/wp-content/uploads/2010/09/baidu-sitemap-generator.zip 下載插件,安裝并激活。

2.點擊設(shè)置里面的 Baidu-Sitemap 選項,即可看到設(shè)置界面,第一次使用你需要先激活配置。

3.然后點擊"更新 XML 文件"按鈕即可生成上述的 XML 文件和 Html 靜態(tài)頁面。

4.在你網(wǎng)站的合適位置加入這兩個鏈接即可。

二,添加robots.txt文件,文件內(nèi)容為:

User-agent: *
Disallow: /wp-
Allow: /wp-content/uploads/
Disallow: /?
Disallow: /feed
Disallow: /*/*/feed
Disallow: /trackback
Disallow: /*/*/trackback
Disallow: /index.php?
Disallow: /index.php/
Disallow: /*.php$
Disallow: /*.css$
Disallow: /date/
Sitemap: http://www.dgkai.cn/blog/sitemap_baidu.xml
Sitemap: http://www.dgkai.cn/blog/sitemap.html

三,在百度博客提交頁面提交了博客feed地址 http://ping.baidu.com/ping.html

四,設(shè)置wordrpess的自動ping服務(wù)。登陸博客后臺,選擇"設(shè)置"->"撰寫"功能模塊,在更新服務(wù)ping service那一欄填寫各個Ping中心地址保存即可。
百度博客的ping中心地址是:http://ping.baidu.com/ping/RPC2

我這邊添加的ping地址是:

http://rpc.pingomatic.com/

http://ping.baidu.com/ping/RPC2

http://blogsearch.google.com/ping/RPC2

http://api.my.yahoo.com/RPC2

http://api.my.yahoo.com/rss/ping

http://ping.feedburner.com

http://www.zhuaxia.com/rpc/server.php

http://www.xianguo.com/xmlrpc/ping.php

http://www.feedsky.com/api/RPC2

http://blog.iask.com/RPC2

http://ping.blog.qikoo.com/rpc2.php

http://rpc.technorati.com/rpc/ping

http://www.blogsdominicanos.com/ping/

標簽:, ,
comments Comments (504)    -
2011/08/19 at 18:04

smarty使用date函數(shù)

smarty在模板上可以直接使用php自帶的函數(shù),甚至可以使用自定義的函數(shù),使用的方法是:

模板中調(diào)用變量時,當(dāng)只有一個參數(shù)是,就直接{$str1|函數(shù)名},當(dāng)有函數(shù)有兩個參數(shù)時,{第一個參數(shù)|函數(shù)名:第二個參數(shù)},當(dāng)有三個參數(shù)時,{第一個參數(shù)|函數(shù)名:第二個參數(shù):第三個參數(shù)},,當(dāng)有4,5,,,參數(shù)時,以此類推。

smarty使用date函數(shù)的用法是{{'Y-m-d'|date:$var}}

標簽:
comments Comments (5)    -
2011/08/19 at 16:56

php時間日期函數(shù)date,getdate,strtotime,strftime,strptime,time,mktime,microtime匯總對比

date — 格式化一個本地時間/日期(把時間戳變成文本格式)
string date ( string $format [, int $timestamp ] )
timestamp 是可選的,默認值為 time()。
$today = date("H:i:s"); // 17:16:17

getdate — 取得日期/時間信息(把時間戳的信息存到數(shù)組)
array getdate ([ int $timestamp ] )
<?php
$today = getdate();
print_r($today);
?>
返回
Array
(
[seconds] => 40
[minutes] => 58
[hours] => 21
[mday] => 17
[wday] => 2
[mon] => 6
[year] => 2003
[yday] => 167
[weekday] => Tuesday
[month] => June
[0] => 1055901520
)

strtotime — 將任何英文文本的日期時間描述解析為 Unix 時間戳 (把文本格式變成時間戳)
int strtotime ( string $time [, int $now ] )
函數(shù)預(yù)期接受一個包含美國英語日期格式的字符串并嘗試將其解析為 Unix 時間戳(自 January 1 1970 00:00:00 GMT 起的秒數(shù)),其值相對于 now 參數(shù)給出的時間,如果沒有提供此參數(shù)則用系統(tǒng)當(dāng)前時間。
<?php
echo strtotime("2011-9-9"), "\n";
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>
strtotime的第一個參數(shù)可以是我們常見的英文時間格式,比如"2008-8-20"或"10 September 2000"等等。也可以是以參數(shù)now為基準的時間描述,比如"+1 day"等等。

下面是后一種方式的可使用參數(shù)清單,其中"當(dāng)前時間"是指strtotime第二個參數(shù)now的值,默認為當(dāng)前時間。

1. 月,日英文名及其常用縮寫清單:
january,february,march,april,may,june,july,august,september,sept,october,november,december,
sunday,monday,tuesday,tues,wednesday,wednes,thursday,thur,thurs,friday,saturday

2. 時間參數(shù)和祥細描述:
am: the time is before noon 上午
pm: the time is noon or later 下午
year: one year; for example, "next year" 年,比如"next year"代表明年
month: one month; for example, "last month" 月,比如"last month"代表上一月
fortnight: two weeks; for example, "a fortnight ago" 兩周,比如"a fortnight ago"代表兩周前
week: one week 周
day: a day 天
hour: an hour 小時
minute: a minute 分鐘
min: same as minute 同"minute"
second: a second 秒
sec: same as second 同"second"

3.相關(guān)和順序說明:
+n/-n:以當(dāng)前時間算,加個減指定的時間,比如"+1 hour"是指當(dāng)前時間加一小時
ago:time relative to now; such as "24 hours ago"  以當(dāng)前時間往前算,比如"24 hours ago"代表"24小時前"
tomorrow: 24 hours later than the current date and time 以當(dāng)前時間(包括日期和時間)為標準,明天同一時間
yesterday: 24 hours earlier than the current date and time 以當(dāng)前時間(包括日期和時間)為標準,昨天同一時間
today: the current date and time 當(dāng)前時間(包括日期和時間)
now: the current date and time 當(dāng)前時間(包括日期和時間)
last: modifier meaning "the preceding"; for example, "last tuesday" 代表"上一個",比如"last tuesday"代表"上周二同一時間"
this: the given time during the current day or the next occurrence of the given time; for example, "this 7am" gives the timestamp for 07:00 on the current day, while "this week" gives the timestamp for one week from the current time 當(dāng)天的指定時間或下面一個時間段的時間戳,比如"this 7am"給出當(dāng)天7:00的時間戳,而"this week"給出的是從當(dāng)前時間開始的一整周的時間戳,也就是當(dāng)前時間(經(jīng)本人測試:strtotime('this week')=strtotime('now'));
next: modifier meaning the current time value of the subject plus one; for example, "next hour" 當(dāng)前時間加上指定的時間,比如"next hour"是指當(dāng)前時間加上一小時,即加3600

first: ordinal modifier, esp. for months; for example, "May first" (actually, it's just the same as next)
third: see first (note that there is no "second" for ordinality, since that would conflict with the second time value)
fourth: see first
fifth: see first
sixth: see first
seventh: see first
eighth: see first
ninth: see first
tenth: see first
eleventh: see first
twelfth: see first

4. 時區(qū)描述:
gmt: Greenwich Mean Time
ut: Coordinated Universal Time
utc: same as ut
wet: Western European Time
bst: British Summer Time
wat: West Africa Time
at: Azores Time
ast: Atlantic Standard Time
adt: Atlantic Daylight Time
est: Eastern Standard Time
edt: Eastern Daylight Time
cst: Central Standard Time
cdt: Central Daylight Time
mst: Mountain Standard Time
mdt: Mountain Daylight Time
pst: Pacific Standard Time
pdt: Pacific Daylight Time
yst: Yukon Standard Time
ydt: Yukon Daylight Time
hst: Hawaii Standard Time
hdt: Hawaii Daylight Time
cat: Central Alaska Time
akst: Alaska Standard Time
akdt: Alaska Daylight Time
ahst: Alaska-Hawaii Standard Time
nt: Nome Time
idlw: International Date Line West
cet: Central European Time
met: Middle European Time
mewt: Middle European Winter Time
mest: Middle European Summer Time
mesz: Middle European Summer Time
swt: Swedish Winter Time
sst: Swedish Summer Time
fwt: French Winter Time
fst: French Summer Time
eet: Eastern Europe Time, USSR Zone 1
bt: Baghdad Time, USSR Zone 2
zp4: USSR Zone 3
zp5: USSR Zone 4
zp6: USSR Zone 5
wast: West Australian Standard Time
wadt: West Australian Daylight Time
cct: China Coast Time, USSR Zone 7
jst: Japan Standard Time, USSR Zone 8
east: Eastern Australian Standard Time
eadt: Eastern Australian Daylight Time
gst: Guam Standard Time, USSR Zone 9
nzt: New Zealand Time
nzst: New Zealand Standard Time
nzdt: New Zealand Daylight Time
idle: International Date Line East

strftime — 根據(jù)區(qū)域設(shè)置格式化本地時間/日期 (把時間戳變成文本格式)
string strftime ( string $format [, int $timestamp ] )
strftime()工作的方式和date()沒有什么不同,除了特殊格式化字符的前面必須添加一個百分號%。
strftime()有兩個好處。第一個好處是如果你使用setlocale()函數(shù),你可以通過strftime得到相應(yīng)語言的月份的名稱。另外的一個好處是你可以將特別的日期和時間的格式化字符包含在你的字符串中。這同時也意味著無論你是否要學(xué)習(xí)date()函數(shù)的所有特殊格式化字符,你都必須學(xué)習(xí)一整套完全不同的格式化字符。
一般phper用date會比較順手吧。

strptime — 解析由 strftime() 生成的日期/時間 (把文本格式的日期信息存到數(shù)組)
array strptime ( string $date , string $format )
類似于date函數(shù)的getdate
<?php
$format = '%d/%m/%Y %H:%M:%S';
$strf = strftime($format);

echo "$strf\n";

print_r(strptime($strf, $format));
?>
輸出
03/10/2004 15:54:19

Array
(
[tm_sec] => 19
[tm_min] => 54
[tm_hour] => 15
[tm_mday] => 3
[tm_mon] => 9
[tm_year] => 104
[tm_wday] => 0
[tm_yday] => 276
[unparsed] =>
)

time — 返回當(dāng)前的 Unix 時間戳
int time ( void )

mktime — 取得一個日期的 Unix 時間戳
int mktime ([ int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst ]]]]]]] )
參數(shù)可以從右向左省略,任何省略的參數(shù)會被設(shè)置成本地日期和時間的當(dāng)前值,參數(shù)全部為空則與time()相同

microtime — 返回當(dāng)前 Unix 時間戳和微秒數(shù)
microtime() 當(dāng)前 Unix 時間戳以及微秒數(shù)。本函數(shù)僅在支持 gettimeofday() 系統(tǒng)調(diào)用的操作系統(tǒng)下可用。
如果調(diào)用時不帶可選參數(shù),本函數(shù)以 "msec sec" 的格式返回一個字符串,其中 sec 是自 Unix 紀元(0:00:00 January 1, 1970 GMT)起到現(xiàn)在的秒數(shù),msec 是微秒部分。字符串的兩部分都是以秒為單位返回的。
如果給出了 get_as_float 參數(shù)并且其值等價于 TRUE,microtime() 將返回一個浮點數(shù)。默認為false
<?php
echo microtime(true);//1313743963.77
echo microtime(false);//0.10190200 1313744036
?>

標簽:,
comments Comments (379)    -