Time of Update: 2016-07-25
/*** desc:create directory through FTP connection* link:bbs.it-home.org* date:2013/02/24*/function FtpMkdir($path, $newDir) { $server='ftp.yourserver.com'; // ftp server $connection = ftp_connect($server); // connection // login to ftp
Time of Update: 2016-07-25
/** desc:header函數設定各種HTTP頭 link:bbs.it-home.org date:2013/2/24*///定義編碼 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/atom+xml'); //CSS header('Content-type: text/css'); //Javascript header(
Time of Update: 2016-07-25
/** * desc:FTP類* link:bbs.it-home.org* date:2013/02/24 */ class ftp { public $off; // 返回操作狀態(成功/失敗) public $conn_id; // FTP串連 /** * 方法:FTP串連 * @FTP_HOST -- FTP主機 * @FTP_PORT -- 連接埠 * @FTP_USER -- 使用者名稱 * @FTP_PASS -- 密碼 */ function
Time of Update: 2016-07-25
網站的運行安全肯定是每個站長必須考慮的問題,大家知道,大多數駭客攻擊網站都是採用sql注入,這就是我們常說的為什麼 ?
Time of Update: 2016-07-25
寫過PHP+MySQL的程式員都知道有時間差,UNIX時間戳記和格式化日期是我們常打交道的兩個時間表示形式,Unix時間戳記儲存、處理方便,但是不直觀,格式化日期直觀,但是處理起來不如Unix時間戳記那麼自如,所以有的時候需要互相轉換,下面給出互相轉換的幾種轉換方式。 一、在MySQL中完成 這種方式在MySQL查詢語句中轉換,優點是不佔用PHP解析器的解析時間,速度快,缺點是只能用在資料庫查詢中,有局限性。 1. UNIX時間戳記轉換為日期用函數:
Time of Update: 2016-07-25
$conn=mssql_connect("執行個體名或者伺服器IP","使用者名稱","密碼"); //測試連接if($conn){echo "串連成功";} 複製代碼 2、選擇要串連的資料庫 mssql_select_db("dbname"); 複製代碼 3、執行查詢 $rs = mssql_query("select top 1 id,username from
Time of Update: 2016-07-25
//截取中文字串function mysubstr($str, $start, $len) {$tmpstr = "";$strlen = $start + $len;for($i = 0; $i if(ord(substr($str, $i, 1)) > 0xa0) {$tmpstr .= substr($str, $i, 2);$i++;} else$tmpstr .= substr($str, $i, 1);}return $tmpstr;}?>複製代碼2、截取utf8編碼的多位元組字串/
Time of Update: 2016-07-25
$input = array("a", "b", "c", "d", "e");$output = array_slice($input, 2); // returns "c", "d", and "e"$output = array_slice($input, -2, 1); // returns "d"$output = array_slice($input, 0, 3); // returns "a", "b", and "c"// note the differences in the
Time of Update: 2016-07-25
/* 從字典檔案中提取隨機值 */$file1 = "./Words.dic";$file2 = "./common_pass_mini.dic";$file3 = "./Sys_Month_Date.Dic";$rfile = "./5.dic";$n = 2000;//提取字典$basef = file($file1);$extf = file($file2);$extf2 = file($file3);$bf_sum = (count($basef)-1);$ef_sum =
Time of Update: 2016-07-25
mysql>CREATE TABLE members (->username CHAR(14) NOT NULL,->password CHAR(32) NOT NULL,->PRIMARY KEY(username)->);複製代碼然後,我們可以輸入使用者的資料到該表中:使用者名稱 密碼Tom keloD1C377lKEJohn ba1T7vnz9AWgkBill paLUvRWsRLZ4U這些加密的口令對應的明碼分別是Tom、John和Bill。我們將根據口令的前二個字母建立幹擾串:
Time of Update: 2016-07-25
$url = "http://bbs.it-home.org/";$ctx = stream_context_create(array('http' => array('timeout' => 5,'proxy' => 'tcp://60.175.203.243:8080','request_fulluri' => True,)));$result = file_get_contents($url, False, $ctx);echo $result;?>複製代碼2、curl 代理的方法:
Time of Update: 2016-07-25
/*** 作者:胡睿* 日期:2012/07/21* 電郵:hooray0905@foxmail.com*/class HRDB{protected $pdo;protected $res;protected $config;/*建構函式*/function __construct($config){$this->Config = $config;$this->connect();}/*資料庫連接*/public function connect(){$this->pdo = new PDO($
Time of Update: 2016-07-25
複製代碼2、php代碼 $dom=new DOMDocument('1.0');$dom->load('x.xml');$em=$dom->getElementsByTagName('emotions');$em=$em->item(0);$items=$em->getElementsByTagName('item');foreach($items as $a){foreach($a->attributes as
Time of Update: 2016-07-25
/** php ftp上傳類 link:bbs.it-home.org date:2013/2/25*///R FTP 處理;class ftp {var $ftpUrl = '58.123.24.32';var $ftpUser = 'test123';var $ftpPass = 'yourpassword';var $ftpDir = '/others/';var $ftpR = ''; //R ftp資源;var $status = '';//R 1:成功;2:無法串連ftp;3:
Time of Update: 2016-07-25
wget http://pear.php.net/go-pear php go_pear[root@localhost ~]# php go-pearWelcome to go-pear!Go-pear will install the 'pear' command and all the files needed byit. This command is your tool for PEAR installation and maintenance.Go-pear also lets
Time of Update: 2016-07-25
/** @截取中文字串 適用於GB2312編碼 @http://bbs.it-home.org*/function FSubstr($title,$start,$len="",$magic=true){$length = 0;if($len == "") $len = strlen($title);//判斷起始為不正確位置if($start > 0){$cnum = 0;for($i=0;$i{if(ord(substr($title,$i,1)) >= 128) $cnum ++;}if(
Time of Update: 2016-07-25
display_errors = Offerror_reporting = E_ALL複製代碼通過在 php.ini 檔案中搜尋它們,可以發現這兩個變數當前的預設值。display_errors 變數的目的很明顯 —— 它告訴 PHP 是否顯示錯誤。預設值是 Off。但是,要讓開發過程更加輕鬆,請把這個值設為 On: display_errors = On複製代碼error_reporting 變數的預設值是 E_ALL。這個設定會顯示從不良編碼實踐到無害提示到出錯的所有資訊。E_ALL
Time of Update: 2016-07-25
/** @中文字串截取函數 @http://bbs.it-home.org*/function cnSubStr($string,$sublen){if($sublen>=strlen($string)){return $string;}$s="";for($i=0;$i{if(ord($string{$i})>127){$s.=$string{$i}.$string{++$i};continue;}else{$s.=$string{$i};continue;}}return $s;}//
Time of Update: 2016-07-25
class Db { var $conn; function Db($host="localhost",$user="root",$pass="root",$db="test") { if(!$this->conn=mysql_connect($host,$user,$pass)) die("can't connect to mysql sever");
Time of Update: 2016-07-25
auto_prepend_file = "c:/Program Files/include/header.php" auto_append_file = "c:/Program Files/include/footer.php"複製代碼unix中這樣設定: auto_prepend_file = "/home/username/include/header.php" auto_append_file =