Time of Update: 2016-07-25
本文是對上篇文章的一個補充,主要是官方沒有關於通知的demo,摸石頭過河真的很難受,方便大家開發,放出來給大家看看通知機制的實現,官方只有文檔沒有demo代碼,對沒搞過的人來說,需要花大量時間來做測試。從文檔上說的來看,每次通知過來的資料,結構比較複雜,是一個多段資料,除了要取出POST資料外,還要取其它的資料。這裡首先涉及到一個關於php://input與$_POST取值的問題,簡單列幾點如下:1,Content-
Time of Update: 2016-07-25
限制程式只能在裡面瀏覽,下面是PHP限制頁面只能在內建瀏覽器訪問的代碼。為了防止自己辛辛苦苦做的webapp被人copy,都想限制程式只能在裡面瀏覽,雖然下面實現了這個功能,單都是小菜,沒什麼技術含量,懂代碼的偽造下就破了。下面是PHP限制頁面只能在內建瀏覽器訪問的代碼。例子: $useragent = $_SERVER['HTTP_USER_AGENT']; if (strpos($useragent, 'MicroMessenger') === false) { echo "
Time of Update: 2016-07-25
有如下PHP數組,數組中的內容: $list = array( array(2,3,5), array(2,5,24), array(3,8,6), array(3,2,10), array(4,7,20), array(4,1,15), array(6,4,10), array(7,9,20), );複製代碼為了方便表達,我把3列數字分別稱為,ABC三列需求:預設以A列排序為主,如果A列相同則以C列倒序排列相同的元素。B列其實沒有參與排序,
Time of Update: 2016-07-25
php數組遞迴方法有如下php數組: function genTree5($items) { foreach ($items as $item) $items[$item['pid']]['son'][$item['id']] = &$items[$item['id']]; return isset($items[0]['son']) ? $items[0]['son'] : array(); }複製代碼方法二: function findChild($arr,$
Time of Update: 2016-07-25
php擷取本機ip地址 php擷取遠程IP地址完整代碼: // echo $_SERVER['REMOTE_ADDR']; //本機IP地址function get_local_ip() { $preg = "/\A((([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.){3}(([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\Z/"; //擷取作業系統為win2000
Time of Update: 2016-07-25
thinkPHP+Uploadify圖片上傳執行個體教程首先,將下載的Uploadify壓縮包解壓放到公用檔案夾內。實現代碼如下:1,前台html部分: 上傳複製代碼2,action執行代碼部分: public function uploadify() { $ph=M('Upload'); import('ORG.Net.UploadFile'); $upload = new UploadFile();// 執行個體化上傳類 $upload->maxSize = 93145728 ;//
Time of Update: 2016-07-25
這是一個將指定資料庫裡的所有表備份為一個SQL檔案,可下載。 /****** 備份資料庫結構 ******/ /* 函數名稱:table2sql() 函數功能:把表的結構轉換成為SQL 函數參數:$table: 要進行提取的表名 返 回 值:返回提取後的結果,SQL集合
Time of Update: 2016-07-25
PHP檔案遍曆小例子完整代碼: $dir = "D:\workspace"; function list_file($dir = '.'){ $list = scandir($dir); echo ''; foreach($list as $file){ $target = "$dir/$file"; if ( is_dir($target) && $file != '.' && $file != '..' ){
Time of Update: 2016-07-25
PHP讀取四種設定檔(php,ini,yaml,xml)的例子,代碼如下,大家自己看吧,說不好哪天就能用得上哦。 /*** 讀取4中配置的表資訊,現支援php.ini,xml.yaml*/class Settings{var $_settings = array();/** * 擷取某些設定的值 * * @param unknown_type $var * @return unknown */ function get($var) { $
Time of Update: 2016-07-25
分享一下discuz論壇的sql防注入函數,寫的不錯。 $magic_quotes_gpc = get_magic_quotes_gpc();@extract(daddslashes($_COOKIE));@extract(daddslashes($_POST));@extract(daddslashes($_GET));if(!$magic_quotes_gpc) {$_FILES = daddslashes($_FILES);} function daddslashes($string, $
Time of Update: 2016-07-25
php中擷取欄位資訊,可以用到以下的函數:mysql_fetch_field()mysql_num_fields()mysql_list_fields()mysql_field_flags()mysql_field_len()mysql_field_name()mysql_field_type()mysql_field_table()欄位的屬性有:name
Time of Update: 2016-07-25
serialize()和unserialize()在php手冊上的解釋是:serialize — Generates a storable representation of a valueserialize — 產生一個可儲存的值的表示unserialize — Creates a PHP value from a stored representationunserialize — 從已儲存的表示中建立 PHP 的值很顯然,"a stored
Time of Update: 2016-07-25
php mysqli擴充庫的例子: #串連資料庫 $link=mysqli_connect("localhost","root","root"); #選擇資料庫 $link->select_db("rorely") or die("could not find database"); #查詢資料庫 $result=$link->query("select * from test"); #輸出資料庫表各個記錄的內容
Time of Update: 2016-07-25
判斷資料庫中的欄位與檔案夾中的檔案是否對應,如果沒有對應則刪除檔案,極大的減少了佔用系統資源。 //Created on 2010-4-24 Made by Wolf QQ116311316 //作用:是判斷資料庫中的欄位與檔案夾中的檔案是否對應,如果沒有對應//則刪除檔案,極大的減少了佔用系統資源。 //$dir 是要尋找的檔案目錄 //$table 為尋找的表 //$
Time of Update: 2016-07-25
.PHP產生靜態html檔案的方法 1,下面使用模版的一個方法! $fp = fopen ("templets.html","a"); if ($fp){ $fup = fread ($fp,filesize("templets.html")); $fp2 = fopen ("html.shtml","w"); if ($fwrite ($fp2,$fup)){
Time of Update: 2016-07-25
class DataBase{ var $pConnect=FALSE;//是否使用長串連 var $mHost;//資料庫主機 var $mDatabase; var $db; //資料庫 var $mUser;//資料庫使用者名稱 var $mPwd;//資料庫使用者密碼 var $mConn;//串連標識 var $result;// 執行query命令的結果資源標識 var $num_rows;// 返回的條目數 var $insert_id;//
Time of Update: 2016-07-25
首先,來看array->xml。$value) {首先,來看array->xml。 function ia2xml($array) { $xml=""; foreach ($array as $key=>$value) { if (is_array($value)) { $xml.="".ia2xml($value).""; } else {
Time of Update: 2016-07-25
驗證碼檔案類 /*** @file* @version 1.0* @author 網海浪子* @date 2006-3-30* @email [email]sxf02615@163.com[/email]* @brief 驗證碼檔案類**/?>class CCheckCodeFile{//驗證碼位元private $mCheckCodeNum =
Time of Update: 2016-07-25
if (isset($_GET["value"])) { $value = $_GET["value"]; } else { $value = false; } if (is_numeric($value) && ($value >= 15 && $value // run my code } else { // handle the issue }複製代碼這是一個非常基本的例子,我們已經寫更多的行,我想看到??的。首先,因為我們不能確定設定的$
Time of Update: 2016-07-25
RewriteEngine onRewriteRule !\.(js|ico|gif|jpg|png|css)$ index.phpphp_value include_path "../lib"#------------------------------httpd.confRewriteEngine onRewriteLog "g:\ZendFramework-0.1.2\rewrite.log"RewriteRule !\.(js|ico|gif|jpg|png|css|php)$