Time of Update: 2016-07-25
class smtp{var $smtp_port;var $time_out;var $host_name;var $log_file;var $relay_host;var $debug;var $auth;var $user;var $pass;var $sock; function smtp($relay_host = "", $smtp_port = 25,$auth = false,$user,$pass){$this->debug = true;$this->smtp_port =
Time of Update: 2016-07-25
php 5,需要開啟socket擴充 //socke操作類class Socket { private $host;//串連socket的主機 private $port;//socket的連接埠號碼 private $error=array(); private $socket=null;//socket的串連標識 private $queryStr="";//發送的資料 public function __construct($host,$port) {
Time of Update: 2016-07-25
/** * 身份證 * * @param string $id * @return boolean */function is_idcard( $id ){ $id = strtoupper($id); $regx = "/(^\d{15}$)|(^\d{17}([0-9]|X)$)/"; $arr_split = array(); if(!preg_match($regx, $id)) { return FALSE;
Time of Update: 2016-07-25
class SysCrypt { private $crypt_key; // 建構函式public function __construct($crypt_key) { $this -> crypt_key = $crypt_key;} public function php_encrypt($txt) { srand((double)microtime() * 1000000); $encrypt_key = md5(rand(0,32000)); $ctr = 0; $
Time of Update: 2016-07-25
/** * auther soulence * 調用資料類檔案 * modify 2015/06/12 */class DBConnect{ private $dbname = null; private $pdo = null; private $persistent = false; private $statement = null; private $lastInsID = null; private static $_instance = [];
Time of Update: 2016-07-25
/** +------------------------------------------------ * 通用的樹型類 +------------------------------------------------ * @author yangyunzhou@foxmail.com +------------------------------------------------ * @date 2010年11月23日10:09:31 +------------------------
Time of Update: 2016-07-25
//擷取指定URL頁面中所有連結 function get_url_href($url){ $html = file_get_contents($url); $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate('/html/body//a')
Time of Update: 2016-07-25
echo "";echo date("Y-m-d",strtotime("now")), "\n";echo "";echo date("Y-m-d",strtotime("-1 week Monday")), "\n";echo "";echo date("Y-m-d",strtotime("-1 week Sunday")), "\n";echo "";echo date("Y-m-d",strtotime("+0 week Monday")), "\n";echo "";echo
Time of Update: 2016-07-25
/******************************************************* isProxy* check whether client is under Proxy or not* $_SERVER['HTTP_X_FORWARDED_FOR'] is pivotal here* if client is under Proxy, returns true* if client is not under Proxy,
Time of Update: 2016-07-25
php代碼,php很多東西都是提供好的,直接用函數,但是php目前所知填充模式只有ZeroPadding,於是其他語言就只能跟著它來了: $privateKey = "1234567812345678";$iv = "1234567812345678";$data = "Test String";//加密$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $privateKey, $data, MCRYPT_MODE_CBC, $iv)
Time of Update: 2016-07-25
class PHPZip{function Zip($dir, $zipfilename){ if (@function_exists('gzcompress')) { $curdir = getcwd(); if (is_array($dir)) { $filelist = $dir; } else {
Time of Update: 2016-07-25
class database { private $hostname; private $user; private $pass; private $dbname; private $linkflag; private $charset; function __construct() { $this->hostname="localhost";
Time of Update: 2016-07-25
在做web開發的時候經常會需要用到對行動裝置的頁面匹配,當然可以直接把網站做成響應式的,但如果不想這麼做的話,可以使用PHP對裝置類型進行判斷, 然後顯示相應的介面和內容。今天分享一種使用 PHP 判斷裝置是否是手機/平板的方法,方法來源於WordPress(wp-includes/vars.php:125),適用於大部分類型的手機/平板判 斷: /** * Test if the current browser runs on a mobile device (smart phone,
Time of Update: 2016-07-25
class CCheckCodeFile{//驗證碼位元private $mCheckCodeNum = 4; //產生的驗證碼private $mCheckCode = ''; //驗證碼的圖片private $mCheckImage = ''; //幹擾像素private $mDisturbColor = ''; //驗證碼的圖片寬度private $mCheckImageWidth = '80'; //驗證碼的圖片寬度private $mCheckImageHeight = '
Time of Update: 2016-07-25
使用前請引入PHPExcel庫 /** * excel 寫入,基於PHPExcel庫 * @param array $data * @param $file * @return bool * @throws PHPExcel_Exception * */function excel_insert(array $data,$file){// $data = [// '庫房'=>[// ['庫房編號','庫房名詞',1],//
Time of Update: 2016-07-25
PHP過濾提交表單的html代碼裡可能有被利用引入外部危險內容的代碼。例如,有些時候使用者提交表單中含有html內容,但這可能造成顯示頁面配置混亂,需要過濾掉。 function uhtml($str) { $farr = array( "/\s+/", //過濾多餘空白 //過濾 等可能引入惡意內容或惡意改變顯示布局的代碼,如果不需要插入flash等,還可以加入的過濾 "/]*?)>/isU",
Time of Update: 2016-07-25
//PHP陽曆到農曆轉換的一個類class Calendar{#農曆每月的天數 var $everyCMonth=array( 0=>array(8,0,0,0,0,0,0,0,0,0,0,0,29,30,7,1), 1=>array(0,29,30,29,29,30,29,30,29,30,30,30,29,0,8,2), 2=>array(0,30,29,30,29,29,30,29,30,29,30,30,30,0,9,3), 3=>array(5,29,30
Time of Update: 2016-07-25
採用get方式傳入參數http://domain/download.php?file='savepath on server'&name='file name you want' //傳入檔案路徑和檔案名稱,分別用於讀取檔案和重新命名檔案if( empty($_GET['file']) || empty($_GET['name'])){ echo'';
Time of Update: 2016-07-25
//PHP刪除目錄和目錄內所有的下級目錄、檔案代碼 function delDir( $dirName='' ){ if ( $handle = opendir( "$dirName" ) ) { while ( false !== ( $item = readdir( $handle ) ) ) { if ( $item != "." && $item != ".." ) {
Time of Update: 2016-07-25
一、基本知識 通過使用 PHP 的全域數組 $_FILES,你可以從客戶電腦向遠程伺服器上傳檔案。 第一個參數是表單的 input name,第二個下標可以是 "name", "type", "size", "tmp_name" 或 "error"。就像這樣: $_FILES["file"]["name"] - 被上傳檔案的名稱 $_FILES["file"]["type"] - 被上傳檔案的類型 $_FILES["file"]["size"