Home > Download >  Library download

  • <?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. "不可写,请检查!");       }First take out 1000 pieces of data (which can be more flexible and convenient for later modification), and then generate xml format files in a loop. file_puts_contens writes files. Then write the name of the generated xml file, the minimum id of the retrieved question, the maximum id of the retrieved question, and the number of retrieved questions into a txt file for index query. The format is roughly like this. 0,3146886,3145887,1000 Did you find that the last number is 1000? The first time you select, take out 1000 pieces of data, and then write it into the 0.xml file. Write the extracted xml file name, minimum id, maximum id, and number of entries into the index query txt. For the first time, 1,000 pieces of data were written to 0.xml, and the number of pieces generated was 1,000. The select statement will become when querying for the second time. where id > The maximum id taken out (currently mysql is a forward order query, if it is in reverse order, change it to less than) limit 1000 In this case, take out 1000, and then modify the minimum id and maximum id of the index query txt, and add the number of generated items to 2000 . By analogy, when the number of generated items reaches 5000, start another line and write it into the index file, similar to this 0,3146886,3145887,5000 1,3148886,3147887,1000 If you write it like this, it will reduce the problem. reduces the pressure on the server.

    Other libraries21372018-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;         }     } }Calculate the distance between two points on the map, using Google Maps

    Other libraries24422018-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(The native only conversion function is whether to return the first letter. Extended support1. Return format [all: full pinyin|first: initial letter|one: only the first letter of the first character]2. Placeholder for unrecognized character replacement (original version Hard-coded is _ )3. Allowed regular control of non-Chinese characters (the original hard-coded 0-9a-zA-Z, spaces are not supported) is used by his pinyin. php ~ 206KB The UTF8 font library is only 106K after compression and expansion. Of course, the performance is also close to his. In the 10,000 stress test, his 2.4s, after expansion, 2.8s, the loss is only 0.4s, so it can be ignored.

    Other libraries38672018-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);       }     }Mainly uses int substr_count (string haystack, string needle [, int offset [, int length]]) This method, this method traverses whether there is $allergicWord in the string $str to be tested Sensitive words contained in the array:

    Other libraries26892018-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]);This is a PHP form sensitive character filtering class and its usage. Share it with everyone for your reference.

    Other libraries21102018-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;   }This is a PHP class for data processing. Friends who need it can download it and use it. The name of the table and the set of fields, which have the following functions: Function: add($postList)Function: AddParameters: $postList Submitted variables ListReturns: The newly inserted auto-increment ID

    Other libraries20972018-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=很遗憾,邮件发送失败了!请检查邮件账户配置是否正确!"); }   } } ?>This is a php class for sending emails. Friends who need it can download it and use it. Instructions for use: $m= new SendM('smtp server address', 'account', 'password', port (int), timeout retry time (int));$m->Send('Recipient Email', 'Subject', 'Mail text'); Usage example: $m= new SendM ('smtp.yeah.net','testuser','testuserpwd',25,30);$m->Send('a@coolmr.com ','Test Email','This This is a test email for sending emails. Thank you for your support');

    Other libraries28862018-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>"); ?>This is a php class to define and use. Friends who need it can download it and use it.

    Other libraries18702018-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;   }This is a PHP class that implements mysql in singleton mode. Friends who need it can download it and use it.

    Other libraries19842018-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"; } ?>This is a PHP class for operating the color to become darker. Friends who need it can download it and use it.

    Other libraries16802018-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;     }This is a very useful PHP backup class for the entire MySQL database. Friends who need it can download and use it

    Other libraries25552018-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 */This is a PHP generation and online browsing library. Friends who need it can download it and use it.

    Other libraries21582017-12-31