首頁 > 下載 >  類別庫下載

  • <?php /*  * SiteMap接口类  */ class SitemapAction extends Action{   private static $baseURL = ''; //URL地址   private static $askMobileUrl = 'http://m.xxx.cn/ask/'; //问答移动版地址   private static $askPcUrl = "http://www.xxx.cn/ask/";   //问答pc地址   private static $askZonePcUrl = "http://www.xxx.cn/ask/jingxuan/"; //问答精选Pc链接   private static $askZoneMobileUrl = "http://m.xxx.cn/ask/jx/"; //问答精选移动版链接   //问答setmaps   public function askSetMap(){     header('Content-type:text/html;charset=utf-8');     //获取问题列表     $maxid = 0;    //索引文件最大id     $minid = 0;    //索引文件最小id     $psize = 1000; //数据库每次取数量     $maxXml = 5000; //xml写入记录数量     $where = array();     //读取索引文件     $index = APP_PATH.'setmapxml/Index.txt';     //关联setmaps路径     $askXml = "../siteditu/ask/ask.xml";     if(!file_exists($index)){       $fp=fopen("$index", "w+");       if ( !is_writable($index) ){         die("文件:" .$index. "不可写,请检查!");       }先取出1000個資料(可以靈活些成活的,方便以後修改),然後循環產生xml格式檔。 file_puts_contens寫入檔案。然後再把產生的xml檔名、取出問題的最小id、取出問題的最大id、取出問題的條數寫出一個索引查詢的txt檔當中,格式大概是這個樣子的。 0,3146886,3145887,1000發現最後面的條數是1000了嗎、第一次select取出1000條資料、然後寫入0.xml檔案當中。把取出的xml檔名、最小id、最大id、條數寫入到索引查詢txt中。第一次寫入了1000條資料到0.xml、生成條數為1000。第二次查詢的時候select語句會成為。 where id > 取出的最大id(目前mysql為正序查詢、如果為倒序、改成小於) limit 1000 這樣的話又取出1000、然後修改索引查詢txt的最小id、最大id、生成條數加到2000 。以此類推等產生條數到了5000的時候再另起一行寫入索引檔、類似這樣0,3146886,3145887,5000 1,3148886,3147887,1000這樣寫的話就減輕了伺服器的壓力。

    其它類別庫21372018-01-02
  • <?php class GeoHelper {     /**      * @param int $lat1      * @param int $lon1      * @param int $lat2      * @param int $lon2      * @param string $unit      * @return      */     public static function distance($lat1, $lon1, $lat2, $lon2, $unit = "K")     {         $theta = $lon1 - $lon2;         $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad           ($lat2)) * cos(deg2rad($theta));         $dist = acos($dist);         $dist = rad2deg($dist);         $miles = $dist * 60 * 1.1515;         $unit = strtoupper($unit);         if ($unit == "K") {             return ($miles * 1.609344);         } else             if ($unit == "N") {                 return ($miles * 0.8684);             } else { //mi                 return $miles;             }     }     /**      *      * @param string $address      * @param string $apikey      * @return array [1]:lat [0]:lng      */     public static function getLatLng($address, $apikey)     {         $find = array("\n", "\r", " ");         $replace = array("", "", "+");         $address = str_replace($find, $replace, $address);         $url = 'http://maps.google.com/maps/geo?q=' . $address . '&key=' . $apikey .           '&sensor=false&output=xml&oe=utf8';         $response = self::xml2array($url);         $coordinates = $response['kml']['Response']['Placemark']['Point']['coordinates'];         if (!empty($coordinates)) {             $point_array = split(",", $coordinates);             return $point_array;         }     } }計算地圖上兩點間的距離,使用的是Google地圖

    其它類別庫24422018-01-02
  • <?php /**  * Created by PhpStorm.  * User: jifei  * Date: 15/6/25  * Time: 下午2:26  */ class Pinyin {     //中文字符串     private static $string = '';     //拼音     private static $pinyin = '';     private static $encoding = 'UTF-8';     //短拼音     private static $short_pinyin = '';     //单个汉字拼音的字典     private static $dic = array(原生的只有轉換 是否會傳回首字母功能。 擴充後支援1. 返回格式[all:全拼音|first:首字母|one:僅第一字元首字母]2. 無法辨識的字元替換用的佔位符(原版寫死的是_ )3. 允許的非中文字元正規控制(原版寫死0-9a-zA-Z, 空格都不支援)用的是他pinyin. php ~ 206KB 那個UTF8字庫,經過壓縮擴充後就剩106K 了。 當然性能也直逼他的,1萬次壓力測試,他的2.4s,擴展後2.8s,僅損耗0.4s,所以可以忽略不計。

    其它類別庫38672018-01-02
  • <?php class Logic_BlackWord {   const APP_FORUM = 1;   const APP_BLOG  = 2;   const APP_VOTE  = 3;   public function getHitList($txt)   {     $hitList = array();     //对禁词分批过滤     $max = $this->getMax();     if($max)     {       $size = 1000;       $last = ceil($max/$size);       for($page=1;$page<=$last;$page++)       {         $result = $this->getHitListByPage($txt,$page,$size);         if($result) $hitList = array_merge($hitList,$result);       }     }主要使用了  int substr_count ( string haystack, string needle [, int offset [, int length]] )  這個方法,這個方法遍歷待測的字串$strord陣列中所包含的敏感詞: #

    其它類別庫26892018-01-02
  • <?php $_form = new formHtmlFind(); class formHtmlFind{ public function formHtml($array,$infoArray='') { if(empty($array))return false; $newform = null; $this->infoArray = !empty($infoArray)?$infoArray:array(); $this->array['class'] =  get_class_methods(get_class()); foreach ($array as $key =>$arr) { $key = preg_replace("/[^a-z]/i",'',$key); $newform .= $this->outputForm($arr,$key); } return $newform.$this->jsError(); } private function outputForm($arr,$key) { $value = null; if(empty($arr))return false; // input Type $type   = $key; // input NAME $name   = trim($arr[0]);這是一個php表單敏感字元過濾類別及其用法。分享給大家供大家參考。

    其它類別庫21102018-01-02
  • <?  phpclass BaseLogic extends MyDB {   protected $tabName;       protected $fieldList;      protected $messList;   function add($postList) {     $fieldList='';     $value='';     foreach ($postList as $k=>$v) {       if(in_array($k, $this->fieldList)){         $fieldList.=$k.",";         if (!get_magic_quotes_gpc())           $value .= "'".addslashes($v)."',";         else           $value .= "'".$v."',";       }     }     $fieldList=rtrim($fieldList, ",");     $value=rtrim($value, ",");     $sql = "INSERT INTO {$this->tabName} (".$fieldList.") VALUES(".$value.")";     echo $sql;     $result=$this->mysqli->query($sql);     if($result && $this->mysqli->affected_rows >0 )       return $this->mysqli->insert_id;     else       return false;   }這是一個資料處理的PHP類,需要的朋友可以下載使用。 表格的名稱以及欄位集合,作用有函數: add($postList)功能: 新增參數: $postList 提交的變數列表返回: 剛插入的自增ID

    其它類別庫20972018-01-01
  • <?php class SendM{   private $Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout,$ms,$ending = "\r\n",$endingc="\n";   function __construct($Mailhost,$Mailuser,$Mailpwd,$Mailport,$Mailtimeout){     $this->Mailhost=$Mailhost;     $this->Mailuser=$Mailuser;     $this->Mailpwd=$Mailpwd;     $this->Mailport=$Mailport;     $this->Mailtimeout=$Mailtimeout;     $this->ConnectSmtpServer();   }   private function ConnectSmtpServer(){     if(!is_string($this->Mailhost)){ settype(trim($this->Mailhost),"string"); }     if(!is_integer($this->Mailport)){ settype(trim($this->Mailport),"integer"); }     if(!is_integer($this->Mailtimeout)){ settype(trim($this->Mailtimeout),"integer"); }     $this->ms=@fsockopen($this->Mailhost,$this->Mailport,$this->errorno,$this->errorstr,$this->Mailtimeout);     if(substr(PHP_OS,0,3) != "WIN"){ stream_set_timeout($this->ms, $this->Mailtimeout, 0);}     $rcp = $this->get_echo();     fputs($this->ms,"ehlo bobo".$this->ending);     $rcp = $this->get_echo();     if(substr($rcp,0,3)!='250'){ return false; }     fputs($this->ms,'auth login'.$this->ending);     $rcp = $this->get_echo();     if(substr($rcp,0,3)=='334'){ $this->Auth($this->Mailuser,$this->Mailpwd); }else{ return false; } }   private function Auth($Mailuser,$Mailpwd){     $this->Mailuseren=base64_encode($Mailuser); $this->Mailpwden=base64_encode($Mailpwd);     fputs($this->ms,$this->Mailuseren.$this->ending);     $rcp = $this->get_echo();     fputs($this->ms,$this->Mailpwden.$this->ending);     $rcp = $this->get_echo();  }   private function get_echo(){     $edata=""; while($estr=@fgets($this->ms,600)){ $edata .= $estr;       if(substr($estr,3,1) == " ") { break; }  }     return $edata; }   public function Send($to,$subject,$connect){     $host=explode('.',$this->Mailhost);     $fromaddress=$this->Mailuser.'@'.$host[1].'.'.$host[2];     fputs($this->ms,'mail from:<'.$fromaddress.'>'.$this->ending);     $rcp = $this->get_echo();     fputs($this->ms,'rcpt to:<'.$to.'>'.$this->ending);     $rcp = $this->get_echo();     fputs($this->ms,'data'.$this->ending);     $rcp = $this->get_echo();     fputs($this->ms,"to:$to".$this->endingc);     fputs($this->ms,"from:$fromaddress".$this->endingc);     fputs($this->ms,"subject:$subject".$this->endingc.$this->endingc);     fputs($this->ms,"$connect".$this->endingc);     fputs($this->ms,'.'.$this->ending);     $rcp = $this->get_echo(); if(substr($rcp,0,3)=='250'){header("Location:main_pro.php?act=msg&errors=on&msg=邮件发送成功!已成功提交至对方服务器!"); }else{ header("Location:main_pro.php?act=msg&errors=on&msg=很遗憾,邮件发送失败了!请检查邮件账户配置是否正确!"); }   } } ?>這是一個發送電子郵件的php類,需要的朋友可以下載使用。 使用說明:$m= new SendM('smtp伺服器位址','帳號','密碼',連接埠(int),逾時重試時間(int));$m->Send('收件者信箱','主題','郵件正文內容');使用範例:$m= new SendM ('smtp.yeah.net','testuser','testuserpwd',25,30);$m->Send('a@coolmr.com ','測試郵件','這是一封郵件發送類別的測試郵件,謝謝您的支援');

    其它類別庫28872018-01-01
  • <?php   class emp   {     var $name;     var $address;     var $dept;     function assign_info($n,$a,$d)     {       $this->name=$n;       $this->state=$a;       $this->dept=$d;     }     function display_info()     {       echo("<p>Employee Name : $this->name");       echo("<p>State : $this->state");       echo("<p>Department : $this->dept");     }   }   $empobj = new emp;   $empobj->assign_info("kaka lname","California","Accounts");   echo("<center><h2>Displaying Employee Information</h2></center>");   echo("<font size=4>");   $empobj->display_info();   echo("</font>"); ?>這是一個定義和使用php類,需要的朋友可以下載使用。

    其它類別庫18702018-01-01
  • <?php defined('ACC')||exit('Access Denied'); // 封装mysql操作类,包括连接功能,及查询功能. class mysql extends absdb{   protected static $ins = null;   protected $host;  // 主机名   protected $user;  // 用户名   protected $passwd; // 密码   protected $db;      // 数据库名   protected $port;    // 端口   protected $conn = null;   // 在内部操作,获得一个对象   public static function getIns() {     if(self::$ins === null) {       self::$ins = new self();     }     $conf = conf::getIns();     self::$ins->host = $conf->host;     self::$ins->user = $conf->user;     self::$ins->passwd = $conf->pwd;     self::$ins->db = $conf->db;     self::$ins->port = $conf->port;     self::$ins->connect();     self::$ins->select_db();     self::$ins->setChar();     return self::$ins;   }   // 不让外部做new操作,   protected function __construct() {   }   // 连接数据库   public function connect() {     $this->conn = @mysql_connect($this->host,$this->user,$this->passwd,$this->port);     if(!$this->conn) {       $error = new Exception('数据库连不上',9);       throw $error;     }   }   // 发送sql查询   public function query($sql) {     $rs = mysql_query($sql,$this->conn);     if(!$rs) {       log::write($sql);     }     return $rs;   }這是一個單例模式實作mysql的PHP類,需要的朋友可以下載使用。

    其它類別庫19842018-01-01
  • <?php function ColorDarken($color, $dif=20){   $color = str_replace('#', '', $color);   if (strlen($color) != 6){ return '000000'; }   $rgb = '';   for ($x=0;$x<3;$x++){     $c = hexdec(substr($color,(2*$x),2)) - $dif;     $c = ($c < 0) ? 0 : dechex($c);     $rgb .= (strlen($c) < 2) ? '0'.$c : $c;   }   return '#'.$rgb; } //范例: for ($x=1; $x < 20; $x++){   // Start color:   $c = ColorDarken('#FF481D', ($x * 3));   print "<div style='background-color: $c; color: $c; font-size: 50%; padding: 0px;'>.</div>\n"; } ?>這是一個操作顏色變深的PHP類,需要的朋友可以下載使用。

    其它類別庫16802018-01-01
  • <?php class Backup {   /**    * @var stores the options    */   var $config;   /**    * @var stores the final sql dump    */   var $dump;   /**    * @var stores the table structure + inserts for every table    */   var $struktur = array();   /**    * @var zip file name    */   var $datei;   /**    * this function is the constructor and phrase the options    * and connect to the database    * @return    */   public function Backup($options)   {     // write options     foreach($options AS $name => $value)     {       $this->config[$name] = $value;     }這是一個很好用的php備份整個MySQL資料庫類,需要的朋友可以下載使用

    其它類別庫25552018-01-01
  • <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /* |-------------------------------------------------------------------------- | File and Directory Modes |-------------------------------------------------------------------------- | | These prefs are used when checking and setting modes when working | with the file system.  The defaults are fine on servers with proper | security, but you may wish (or even need) to change the values in | certain environments (Apache running a separate process for each | user, PHP under CGI with Apache suEXEC, etc.).  Octal values should | always be used to set the mode correctly. | */ define('FILE_READ_MODE', 0644); define('FILE_WRITE_MODE', 0666); define('DIR_READ_MODE', 0755); define('DIR_WRITE_MODE', 0777); /* |-------------------------------------------------------------------------- | File Stream Modes |-------------------------------------------------------------------------- | | These modes are used when working with fopen()/popen() | */ define('FOPEN_READ','rb'); define('FOPEN_READ_WRITE','r+b'); define('FOPEN_WRITE_CREATE_DESTRUCTIVE','wb'); // truncates existing file data, use with care define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE','w+b'); // truncates existing file data, use with care define('FOPEN_WRITE_CREATE','ab'); define('FOPEN_READ_WRITE_CREATE','a+b'); define('FOPEN_WRITE_CREATE_STRICT','xb'); define('FOPEN_READ_WRITE_CREATE_STRICT','x+b'); /* End of file constants.php */ /* Location: ./application/config/constants.php */這是一個PHP生成和線上瀏覽類別庫,需要的朋友可以下載使用。

    其它類別庫21582017-12-31