Time of Update: 2016-07-25
/*** 去除數組中重複資料* by bbs.it-home.org**/$input = array("a" => "green","", "red","b" => "green", "","blue", "red","c" => "witer","hello","witer");//$result = array_unique($input); //去除重複元素$result = a_array_unique($input); //只留下單一元素foreach($result as
Time of Update: 2016-07-25
/* 24小時柱狀圖 作者:taokey QQ:29611705* 編輯:bbs.it-home.org*/ function h24($str){ $hour = explode(",",$str); $hmax = max($hour); $ppix = 150/$hmax; //計算柱狀圖高度 $h0 = 190-$hour[0]*$ppix; $h1 = 190-$hour[1]*$ppix; $h2 =
Time of Update: 2016-07-25
DEFINE("CACHE_DIR","/tmp/jpgraph_cache/");' DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/");複製代碼Windows系統改為: DEFINE("CACHE_DIR","c:/apache/htdocs/ jpgraph_cache/");' DEFINE("TTF_DIR","c:/windows/fonts");複製代碼注意事項:
Time of Update: 2016-07-25
/** * 數組轉編碼 * @param array $array 待轉碼數組 * @param String $inCharset 原編碼 * @param String $outCharset 轉換後的編碼 * @return $array 轉換後的數組 * @site:bbs.it-home.org */private function arrayCoding ($array, $inCharset, $outCharset) { if (!is_array($array))
Time of Update: 2016-07-25
//函數名: compress_html//參數: $string//傳回值: 壓縮後的$string//by bbs.it-home.orgfunction compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '',
Time of Update: 2016-07-25
#!/bin/awk -f #運行前 BEGIN { FS = " "; count = 0; } #運行中 { iparr[count ++] = $0; } #運行後 END { printf(" printf("$iparr = array(\n"); for (i = 0; i printf("'%s' => '%s',\n", iparr[i], iparr[i]); }
Time of Update: 2016-07-25
/*** JpGraph類產生柱狀圖* by bbs.it-home.org*/$datay=array(); //縱座標資料 $datax=array(); //橫座標資料 foreach ($usernums as $key => $value){ $datay[] = $value; $datax[] = $userids[$key]; } require_once (‘jpgraph-3.0.7/jpgraph/jpgraph.php'); require_once
Time of Update: 2016-07-25
number_format(288); 輸出 288 number_format(365,2); 輸出 365.00 number_format(365000000,3,".") (將數字 365000000 保留3位小數,小數點用"."表示) 輸出: 365,000,000.000 number_format(365000000,2,".","*") (將數字 365000000 保留2位小數,小數點用"."表示,千位分隔字元用"*"表示) 輸出:
Time of Update: 2016-07-25
/*** 取得網站的完整地址* by bbs.it-home.org*/function getRootUrl(){ $name = ''; if ( isset($_SERVER['HTTP_HOST']) ){ $name = $_SERVER['HTTP_HOST']; }else{ $name = $_SERVER['SERVER_NAME']; } if ( strpos($name,':') === false && $_SERVER['SERVER_PORT'
Time of Update: 2016-07-25
/* * 壓縮css檔案 * by bbs.it-home.org /*header('Content-type: text/css');ob_start("compress");function compress($buffer) { /* remove comments */ $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); /* remove tabs, spaces, newlines,
Time of Update: 2016-07-25
Upload 複製代碼2,php多檔案上傳代碼 upload.php //If directory doesnot exists create it. $output_dir = "../upload"; if(isset($_FILES["myfile"])) { $ret = array(); $error =$_FILES["myfile"]["error"]; {
Time of Update: 2016-07-25
/** * 按行讀取檔案 * @param string $filename * @site bbs.it-home.org */ function readFileByLine ($filename) { $fh = fopen($filename, 'r'); while (! feof($fh)) { $line = fgets($fh); echo $line; } fclose(
Time of Update: 2016-07-25
/*** PHP中CURL類比Post提交* by bbs.it-home.org*/$url = 'http://website/a.php';$fields = array('UserName'=>urlencode('a'),'PWD'=>urlencode('b') ,'AppReturn'=>urlencode('c') ,'AppSQL'=>urlencode('d') ,);$fields_string = http_build_query($fields);$ch =
Time of Update: 2016-07-25
/** php下載類,支援斷點續傳 * Date: 2013-06-30 * Author: fdipzone * Ver: 1.0 * edit: ww.jbxue.com* Func: * download: 下載檔案 * setSpeed: 設定下載速度 * getRange: 擷取header中Range */ class FileDownload{ // class start private $_speed = 512;
Time of Update: 2016-07-25
Function inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str);}if (inject_check($_SERVER['QUERY_STRING'])==1 or inject_check(file_get_contents("php://input"))==1){ /
Time of Update: 2016-07-25
/*** 發送帶附件的郵件* by bbs.it-home.org*/class CMailFile { var $subject; var $addr_to; var $text_body; var $text_encoded; var $mime_headers; var $mime_boundary = "--==================_846811060==_"; var
Time of Update: 2016-07-25
/** css 更新類,更新css檔案內圖片的版本 * Date: 2013-02-05 * Author: fdipzone * Ver: 1.1 * Edit: bbs.it-home.org* Func: * update(); * * Ver: 1.1 增加search_child參數,可遍曆子檔案夾 */ class CSSUpdate{ private $csstmpl_path = null; private
Time of Update: 2016-07-25
/*** 用php代碼產生excel或csv檔案中的序號*/public function loop(){ $loop = 0; $charnum = 65; for(; $loop $quotient = intval($loop / 26); $remainder = $loop % 26; $f = $quotient>0? chr($charnum+$quotient-1) : ''; $s = $remainder>=0?
Time of Update: 2016-07-25
/** 強制更新圖片緩存 * @param Array $files 待更新的圖片 * @param int $version 版本* @edit bbs.it-home.org*/ function force_reload_file($files=array(), $version=0){ $html = ''; if(!isset($_COOKIE['force_reload_page_'.$version])){ // 判斷是否已更新過
Time of Update: 2016-07-25
/** XML 檔案分析類 * Date: 2013-02-01 * Author: fdipzone * Ver: 1.0 * Edition bbs.it-home.org* func: * loadXmlFile($xmlfile) 讀入xml檔案輸出Array * loadXmlString($xmlstring) 讀入xmlstring 輸出Array */ class XMLParser{ /** 讀取xml檔案 *