Time of Update: 2016-07-25
header('Content-type:text/html;charset=utf-8');/*** 統計中文字串長度的函數* @param $str 要計算長度的字串* @param $type 計算長度類型,0(預設)表示一個中文算一個字元,1表示一個中文算兩個字元* @http://bbs.it-home.org**/function abslength($str){if(empty($str)){return
Time of Update: 2016-07-25
/** @UTF-8中文字元截斷程式 @http://bbs.it-home.org*/$str = "321這是測試字串";$str1 = "()()";echo subUTF8str($str,0,3)."";echo subUTF8str($str,0,4)."";echo subUTF8str($str1,0,4)."";echo subUTF8str($str1,0,10)."";function
Time of Update: 2016-07-25
//PHP整站防注入程式,需要在公用檔案中require_once本檔案//判斷magic_quotes_gpc狀態if (@get_magic_quotes_gpc ()) {$_GET = sec ( $_GET );$_POST = sec ( $_POST );$_COOKIE = sec ( $_COOKIE );$_FILES = sec ( $_FILES );}$_SERVER = sec ( $_SERVER );function sec(&$array)
Time of Update: 2016-07-25
$strarray[1] = "hello"; $strarray[2] = "123456"; $strarray[3] = "123hello"; $strarray[4] = "指令碼學堂"; $strarray[5] = "123程式員之家"; $strarray[6] = "hello程式員之家"; $strarray[7] = "123hello程式員之家"; foreach ($strarray
Time of Update: 2016-07-25
/*** FILE_NAME : arr.php FILE_PATH : test/* 在多維陣列中根據鍵名快速查詢其父鍵以及父索引值** @copyright Copyright (c) 2006-2010* @author Levi* @package test.arr* @subpackage* @version 2011-04-29* @link bbs.it-home.org*/header("Content-Type: text/html; charset=utf-8");$arr
Time of Update: 2016-07-25
/*** @ 擷取子欄目ID號 @ bbs.it-home.org @ 2013/2/26*/private function sonCategoryIds($categoryID){ //@初始化欄目數組 $array[] = $categoryID; do { $ids = ''; $temp = $this->mysql->select('SELECT `id` FROM `pcb_article_category` WHERE
Time of Update: 2016-07-25
/** des 加密 解密*/class STD3Des{private $key = "";private $iv = "";/*** 構造,傳遞二個已經進行base64_encode的KEY與IV** @param string $key* @param string $iv*/function __construct ($key, $iv){if (empty($key) || empty($iv)) {echo 'key and iv is not
Time of Update: 2016-07-25
$useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT'])); if (strpos($useragent, 'googlebot')!== false){$bot = 'Google';} elseif (strpos($useragent,'mediapartners-google') !== false){$bot = 'Google Adsense';} elseif
Time of Update: 2016-07-25
index.html複製代碼2、verifycode.php /* 圖片驗證碼 Powered By KASON test http://bbs.it-home.org */ session_start(); $num=4;//驗證碼個數 $width=80;//驗證碼寬度 $height=20;//驗證碼高度 $code=' '; for($i=0;$i { switch(rand(0,2)) { case 0:$code[$i]=chr(rand(48,5
Time of Update: 2016-07-25
/*// 函數名:CheckEmailAddr($C_mailaddr)// 作 用:判斷是否為有效郵件地址// 參 數:$C_mailaddr(待檢測的郵件地址)// 傳回值:布爾值// 備 註:無*/function CheckEmailAddr($C_mailaddr){if (!eregi(“^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$”,$C_mailaddr))//(!ereg(“^[_a-zA-Z0-9-]+(.[_a-
Time of Update: 2016-07-25
/****------------------******** Copyright (C) 2007 by 耿鴻飛 ** ghf@localhost.localdomain ** ** This program is free software; you can redistribute it and/or modify **
Time of Update: 2016-07-25
程式員:就目前的設計,我大概一周內就可以搞定基本架構。然後我們從頭再最佳化整理、完善設計,在接下來的一周提交一個穩定的版本。專案經理的理解:整個項目只要兩個禮拜就可以搞定。程式員:是的,我可以寫一些Web服務,通過這個服務,其他的開發人員能夠與我們的系統進行互動。專案經理的理解:他一人就可以構建出一個每分鐘能夠承受百萬使用者的負載平衡Web服務網站。程式員:我們需要和下一版本負責人開個會,告訴他們除非有合適的構建部署伺服器,我們無法按時完成項目。專案經理的理解:沒戲了!(淚奔中。。。)程式員:我
Time of Update: 2016-07-25
/**php上傳圖片link:http://bbs.it-home.org*/if (!empty($_FILES["img"]["name"])) { //提取檔案域內容名稱,並判斷$path=”uppic/”; //上傳路徑if(!file_exists($path)){//檢查是否有該檔案夾,如果沒有就建立,並給予最高許可權mkdir(“$path”, 0700);}//END IF//允許上傳的檔案格式$tp =
Time of Update: 2016-07-25
function tb_json_encode($value, $options = 0){ return json_encode(tb_json_convert_encoding($value, “GBK”, “UTF-8″));}function tb_json_decode($str, $assoc = false, $depth = 512){ return tb_json_convert_encoding(json_decode($str, $assoc), “UTF-8″,
Time of Update: 2016-07-25
/*** 功能:查看php代碼的已耗用時間* 日期:2012-12-29* 檔案:show_php_runtime.php**/class RunTime//頁面執行時間類{private $starttime;//頁面開始執行時間private $stoptime;//頁面結束執行時間private $spendtime;//頁面執行花費時間function getmicrotime()//擷取返回當前微秒數的浮點數{list($usec,$sec)=explode("
Time of Update: 2016-07-25
function rank($base, $temp=null){$len = strlen($base);if($len {echo $temp.$base.'';}else{for($i=0; $i{rank(substr($base, 0, $i).substr($base, $i+1, $len-$i-1),
Time of Update: 2016-07-25
據說$_SERVER['REQUEST_URI']只能在Apache才可以用(沒測試過),所以只相容Apache。 http://example.com/URIRouter.php/Hello/World 或 http://example.com/dir/URIRouter.php/Hello/World 傳回值: Hello/World 設定.htaccess後: http://example.com/Hello/World 或
Time of Update: 2016-07-25
/*** 批量修改檔案尾碼名 * func: foreachDir*/function foreachDir($path){$handle=opendir($path);if($handle){while (false !== ($file = readdir($handle))) {if($file!="." && $file!='..'){if(is_dir($path.$file)){echo
Time of Update: 2016-07-25
$im = imagecreatefromjpeg($_file["upload"]["tmp_name"]); //你要打水例子的圖片$watermark = imagecreatefrompng("Smiley.png"); //浮水印圖的路徑$im_x = imagesx($im);$im_y = imagesy($im);$w_x = imagesx($watermark);$w_y = imagesy($watermark);imagecopy($im,$watermark ,$im_
Time of Update: 2016-07-25
/***********************@filename - path to the image*@tmpname - temporary path to thumbnail*@xmax - max width*@ymax - max height*/function resize_image($filename, $tmpname, $xmax, $ymax){$ext = explode(".", $filename);$ext = $ext[count($ext)-1];if($