Time of Update: 2016-07-25
/*==================================================================*/ /* 檔案名稱:BaseLogic.class.php */ /* 概要: 資料處理公用類. */ class BaseLogic extends MyDB {
Time of Update: 2016-07-25
/* http認證 判斷來路頁面 寫日誌 */ ////////////禁用錯誤報表////////////// error_reporting(0); ///////////http認證//////////// if(!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="login:"');
Time of Update: 2016-07-25
用在伺服器上提供下載的php代碼,可以指定被下載的檔案名稱,可以動態指定檔案內容 // local file that should be send to the client$local_file = 'test.zip';// filename that the user gets as default$download_file = 'your-download-name.zip'; if(file_exists($local_file) && is_file($local_file))
Time of Update: 2016-07-25
function recursiveChmod($path, $filePerm=0644, $dirPerm=0755) { // Check if the path exists if(!file_exists($path)) { return(FALSE); } // See whether this is a file if(is_file($path)) { // Chmod
Time of Update: 2016-07-25
class DateFormat{ private static $_DIFF_FORMAT = array( 'DAY' => '%s天前', 'DAY_HOUR' => '%s天%s小時前', 'HOUR' => '%s小時', 'HOUR_MINUTE' => '%s小時%s分前', 'MINUTE' => '%s分鐘前',
Time of Update: 2016-07-25
class Verify{ /** * 驗證使用者名稱 * @param string $value * @param int $length * @return boolean */ public static function isNames($value, $minLen=2, $maxLen=20, $charset='ALL'){ if(empty($value)) return false; switch($charset)
Time of Update: 2016-07-25
一個很簡單的功能,從一個PHP數組產生一個.csv檔案。此函數使用 fputcsv PHP 內建函數產生逗點分隔檔(.CSV)。該函數有3個參數:資料,分隔字元和CSV enclosure,預設是雙引號。 function generateCsv($data, $delimiter = ',', $enclosure = '"') { $handle = fopen('php://temp', 'r+'); foreach ($data as $line)
Time of Update: 2016-07-25
// f(ucking) u(ncrackable) e(ncryption) function by BlackHatDBL (www.netforme.net) function fue($hash,$times) { // Execute the encryption(s) as many times as the user wants for($i=$times;$i>0;$i--) { // Encode
Time of Update: 2016-07-25
function ezip($zip, $hedef = ''){ $dirname=preg_replace('/.zip/', '', $zip); $root = $_SERVER['DOCUMENT_ROOT'].'/zip/'; // echo $root. $zip; $zip = zip_open($root . $zip); // var_dump($zip); @mkdir($root . $hedef .
Time of Update: 2016-07-25
最近在做的項目有一項需要耗時任務在後台啟動並執行功能,雖然PHP並不是非常適合做常駐背景守護進程,但是由於項目主要代碼都是基於PHP實現,如 果運行在背景守護進程改換別的語言會非常不方便。所以不可避免會涉及到Web端和Daemon部分的通訊,Socket是一個不錯的方式。 Socket是什麼 socket的英文原義是“孔”或“插座”。作為BSD
Time of Update: 2016-07-25
function auto_save_image($body){$img_array = explode('&',$body);/*$img_array = array();preg_match_all("/(src)=[\"|\'| ]{0,}(http:\/\/(.*)\.(gif|jpg|jpeg|bmp|png))[\"|\'| ]{0,}/isU", $body, $img_array);$img_array = array_unique($img_array[2]);*/
Time of Update: 2016-07-25
class encryptCalss{ var $key=12; function encode($txt){ for($i=0;$i $txt[$i]=chr(ord($txt[$i])+$this->key); } return $txt=urlencode(base64_encode(urlencode($txt))); } function decode($txt){
Time of Update: 2016-07-25
php遍曆某檔案夾下的所有檔案和檔案夾 function list_dir($dirpath){ if($dirpath[strlen($dirpath)-1]!="\\"){$dirpath.="\\";} static $result_array=array(); if(is_dir($dirpath)){ $handle=opendir($dirpath);
Time of Update: 2016-07-25
產生一定數量的不重複隨機數 /** array unique_rand( int $min, int $max, int $num )* 產生一定數量的不重複隨機數* $min 和 $max: 指定隨機數的範圍* $num: 指定產生數量*/function unique_rand($min, $max, $num) { $count = 0; $return = array(); while ($count $return[] = mt_rand($min,
Time of Update: 2016-07-25
產生多種類型的縮圖 /****************************************作者:落夢天蠍(beluckly)*完成時間:2006-12-18*類名:CreatMiniature*功能:產生多種類型的縮圖*基本參數:$srcFile,$echoType*方法用到的參數: $toFile,產生的檔案 $toW,產生的寬 $toH,產生的高
Time of Update: 2016-07-25
php擷取圖片的exif資訊,php內建一個exif_read_data函數可以用來讀取圖片的exif資訊 echo "test1.jpg:\n";$exif = exif_read_data('tests/test1.jpg', 'IFD0');echo $exif===false ? "No header data found.\n" : "Image contains headers\n"; $exif = exif_read_data('tests/test2.jpg', 0,
Time of Update: 2016-07-25
如下代碼實現了301重新導向,301重新導向是一種seo搜尋引擎友好的重新導向方式,其用意是告訴搜尋引擎現在訪問的內容已經轉到其他地址了。 如下是php實現301重新導向的代碼: header("HTTP/1.1 301 Moved Permanently");header("Location: http://www.open-open.com/");複製代碼 常用的重新導向方式有: 301 redirect, 302 redirect 301
Time of Update: 2016-07-25
$flag = 0; //要post的資料 $argv = array( 'var1'=>'abc', 'var2'=>'你好嗎'); //構造post字串 foreach ($argv as $key=>$value) { if ($flag!=0) { $params .= "&";
Time of Update: 2016-07-25
/** * 圖片縮放浮水印類 * * @version 1.0 ; * */class cls_photo{ protected $waterrate = 0.2; //浮水印表徵圖在圖片上的比例 protected $width = 300; //縮圖預設寬度 protected $height = 200; //縮圖預設高度 protected $padding = 5; //浮水印圖到邊的距離 protected $water_mark =
Time of Update: 2016-07-25
class Thumb{ public function create($srcPath, $dstPath, $dstWidth, $dstHeight) { if (!file_exists($srcPath)) { return false; } @$srcSize = getimagesize($srcPath); if (empty($srcSize)) { return