Time of Update: 2016-07-25
/** * 通用加密 * @param String $string 需要加密的字串 * @param String $skey 加密EKY * @return String */function enCode($string = '', $skey = 'echounion') { $skey = array_reverse(str_split($skey)); $strArr = str_split(base64_encode($string)); $strCount =
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);} function verify_id($id=null) { if(!$id) { exit('沒有提交參數!'); } elseif(inject_check($
Time of Update: 2016-07-25
對於zip檔案網上的例子很多,rar檔案解壓php沒有直接支援,可以用pecl 到http://pecl.php.net/package/rar 下載對應版本的 非安全執行緒的dll 然後扔到php的 ext目錄下。 開啟php.ini. 加一行 extension=php_rar.dll 重啟web伺服器 和php public function _unzip($fileName,$extractTO){
Time of Update: 2016-07-25
function compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '', $string); //清除定位字元 $pattern = array ( "/> *([^ ]*
Time of Update: 2016-07-25
/** * +-------------------------------------------------------------------- * Description 遞迴建立目錄 +-------------------------------------------------------------------- * @param string $dir 需要創新的目錄 +----------------------------------------------------
Time of Update: 2016-07-25
通過php的 similar_text函數比較兩個字串的相似性 $word2compare = "stupid"; $words = array( 'stupid', 'stu and pid', 'hello', 'foobar', 'stpid', 'upid', 'stuuupid', 'sstuuupiiid',); while(list($id, $str) = each($words)){ similar_text($str,
Time of Update: 2016-07-25
function getfirstchar($s0) {$fchar = ord(substr($s0, 0, 1));if (($fchar >= ord("a") and $fchar = ord("A") and $fchar $s = iconv("UTF-8", "gb2312", $s0);$asc = ord($s{0}) * 256 + ord($s小貝)-65536;if ($asc >= -20319 and $asc if ($asc >= -20283 and $asc
Time of Update: 2016-07-25
這個php函數可以把指定的顏色變得更深一些 function ColorDarken($color, $dif=20){ $color = str_replace('#', '', $color); if (strlen($color) != 6){ return '000000'; } $rgb = ''; for ($x=0;$x $c = hexdec(substr($color,(2*$x),2)) - $dif; $c =
Time of Update: 2016-07-25
function getPicture($url,$pictureName){if ($url == "") return false;//擷取圖片的副檔名$info = getimagesize($url);$mime = $info['mime'];$type = substr(strrchr($mime,'/'), 1);//不同的圖片類型選擇不同的圖片產生和儲存函數switch($type){case 'jpeg':$img_create_func =
Time of Update: 2016-07-25
function show_page($count,$page,$page_size){$page_count = ceil($count/$page_size); //計算得出總頁數$init=1;$page_len=7;$max_p=$page_count;$pages=$page_count;//判斷當前頁碼$page=(empty($page)||$page//擷取當前頁url$url =
Time of Update: 2016-07-25
function quicksortX(&$seq){ $stack = array($seq); $sort = array(); while ($stack) { $arr = array_pop($stack); if(count($arr) if (count($arr) == 1) { $sort[] = &$arr[0]; }
Time of Update: 2016-07-25
php計算串連的mysql資料庫的大小,用MB,KB或者GB的格式返回 function CalcFullDatabaseSize($database, $db) { $tables = mysql_list_tables($database, $db); if (!$tables) { return -1; } $table_count = mysql_num_rows($tables); $size = 0; for ($i=0; $i
Time of Update: 2016-07-25
function num_format($num){if(!is_numeric($num)){return false;}$rvalue='';$num = explode('.',$num);//把整數和小數分開$rl = !isset($num['1']) ? '' : $num['1'];//小數部分的值$j = strlen($num[0]) % 3;//整數有多少位$sl = substr($num[0], 0, $j);//前面不滿三位的數取出來$sr = substr($num[
Time of Update: 2016-07-25
function dirSize($directoty){$dir_size=0;if($dir_handle=@opendir($directoty)){while($filename=readdir($dir_handle)){$subFile=$directoty.DIRECTORY_SEPARATOR.$filename;if($filename=='.'||$filename=='..'){continue;}elseif
Time of Update: 2016-07-25
處理代碼: header('Content-Type:text/html;charset=UTF-8'); //準備接收 /* echo '檔案名稱:'.$_FILES['userfile']['name']; echo '檔案大小:'.$_FILES['userfile']['size']; echo '錯誤:'.$_FILES['userfile']['error']; */
Time of Update: 2016-07-25
test();/** * 測試 */function test() { echo CnToInt('一'); // 1 echo CnToInt('十'); // 10 echo CnToInt('十一'); // 11 echo CnToInt('一百一十'); // 110 echo CnToInt('一千零一'); // 1001 echo CnToInt('一萬零一百零一'); // 10101 echo
Time of Update: 2016-07-25
require './class.phpmailer.php';$mail=new
Time of Update: 2016-07-25
/** * 返回兩個時間的相距時間,*年*月*日*時*分*秒 * @param int $one_time 時間一 * @param int $two_time 時間二 * @param int $return_type 預設值為0,0/不為0則拼接返回,1/*秒,2/*分*秒,3/*時*分*秒/,4/*日*時*分*秒,5/*月*日*時*分*秒,6/*年*月*日*時*分*秒 * @param array $format_array 格式化字元,例,array('年', '月', '日', '時'
Time of Update: 2016-07-25
defined('ACC')||exit('Access Denied');// 封裝mysql操作類,包括串連功能,及查詢功能.class mysql extends absdb{ protected static $ins = null; protected $host; // 主機名稱 protected $user; // 使用者名稱 protected $passwd; // 密碼 protected $db; // 資料庫名
Time of Update: 2016-07-25
$handle = @ fopen ( "demo.txt" , "r" ); if ( $handle ) { while (( $buffer = fgets ( $handle , 4096 )) !== false ) { echo $buffer ; } if (! feof ( $handle )) { echo "Error: unexpected