首页 > 下载 >  类库下载

  • <?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;         }     } }计算地图上两点间的距离,使用的是谷歌地图

    其它类库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]] )  这个方法,这个方法遍历待测的字符串$str中有没有$allergicWord数组中所包含的敏感词: 

    其它类库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