Home > Download >  Library download

  • <?php function xml2array($contents, $get_attributes = 1, $priority = 'tag') {   if (!$contents) return array();   if (!function_exists('xml_parser_create')) {     // print "'xml_parser_create()' function not found!";     return array();   }   // Get the XML parser of PHP - PHP must have this module for the parser to work   $parser = xml_parser_create('');   xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); // http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss   xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);   xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);   xml_parse_into_struct($parser, trim($contents), $xml_values);   xml_parser_free($parser);   if (!$xml_values) return; //Hmm...   // Initializations   $xml_array = array();   $parents = array();   $opened_tags = array();   $arr = array();   $current = &$xml_array; //Refference   // Go through the tags.   $repeated_tag_index = array(); //Multiple tags with same name will be turned into an array   foreach($xml_values as $data) {     unset($attributes, $value); //Remove existing values, or there will be trouble     // This command will extract these variables into the foreach scope     // tag(string), type(string), level(int), attributes(array).     extract($data); //We could use the array by itself, but this cooler.     $result = array();     $attributes_data = array();     if (isset($value)) {       if ($priority == 'tag') $result = $value;       else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode     }This is a class library that can convert between XML and data formats. Friends who need it can download and use it.

    Other libraries17042017-12-26
  • <? class FileUtil {   /**    * 建立文件夹    *    * @param string $aimUrl    * @return viod    */   function createDir($aimUrl) {     $aimUrl = str_replace('', '/', $aimUrl);     $aimDir = '';     $arr = explode('/', $aimUrl);     foreach ($arr as $str) {       $aimDir .= $str . '/';       if (!file_exists($aimDir)) {         mkdir($aimDir);       }     }   } * Manipulate file class * Example: * FileUtil::createDir('a/1/2/3'); Test to create a folder to create a/1/ 2/3 Folder * FileUtil::createFile('b/1/2/3'); # * FileUtil::createFile('b/1/2/3.exe'); Test to create a file Create a 3.exe file under the b/1/2/ folder * FileUtil::copyDir ('b','d/e'); Test copy the folder to create a d/e folder and copy the contents of the b folder into it * FileUtil::copyFile('b/1/ 2/3.exe','b/b/3.exe'); Test copying files Create a b/b folder and copy the 3.exe file in the b/1/2 folder into it* Fileutil :: movedir ('a/', 'b/c'); test the mobile folder to create a B/C folder, move the content under the A folder, delete the A folder ## * FileUtil::moveFile('b/1/2/3.exe','b/d/3.exe'); Test moving files Create a b/d folder and put b/1/ Move 3.exe in 2 * FileUtil::unlinkFile('b/d/3.exe'); Test deletion of files Delete b/d/3.exe file * FileUtil::unlinkDir('d'); Test deletion of folder Delete d folder */

    Other libraries16402017-12-26
  • <?php class Params {   public $get = array();   public $post = array();   function __construct()   {     if (!empty($_GET)) {       foreach ($_GET as $key => $val) {         if (is_numeric($val)) {           $this->get[$key] = $this->getInt($val);         } else {           $this->get[$key] = $this->getStr($val);         }       }     }     if (!empty($_POST)) {       foreach ($_POST as $key => $val) {         if (is_numeric($val)) {           $this->post[$key] = $this->getInt($val);         } else {           $this->post[$key] = $this->getStr($val);         }       }     }   }This is a PHP security library that uses prepared statements and parameterized queries. SQL statements with any parameters will be sent to the database server and parsed! It is impossible for an attacker to maliciously inject SQL!

    Other libraries21002017-12-26
  • <?php class DBManage {   var $db; // 数据库连接   var $database; // 所用数据库   var $sqldir; // 数据库备份文件夹   var $record;   // 换行符   private $ds = "n";   // 存储SQL的变量   public $sqlContent = "";   // 每条sql语句的结尾符   public $sqlEnd = ";";   /**    * 初始化    *    * @param string $host    * @param string $username    * @param string $password    * @param string $thisatabase    * @param string $charset    */ Description: The volume file ends with _v1.sql Function: Implement mysql database volume backup, select tables for backup, and implement single sql file and volume sql import Usage: 1. Database backup (export)-------------------------------- ----------------------------//They are the host, user name, password, and database name respectively. , database encoding$db = new DBManage ('localhost', 'root', 'root', 'test', 'utf8' );//Parameter: which table to back up ( Optional), backup directory (optional, default is backup), volume size (optional, default is 2000, which is 2M)$db->backup (); * ------2. Database recovery (import)--------------------------------------------- -----------------------//They are the host, user name, password, database name, and database encoding$db = new DBManage ('localhost', 'root', 'root', 'test', 'utf8' );//Parameter: sql file

    Other libraries21172017-12-26
  • <?php class db {         var $db;         var $position=0;         function sub_sql($str)         {                 global $prefix;                 return str_replace("detest_",$prefix,$str);         }         function Sql($str)         {                 $str=$this->sub_sql($str);                 $result = mysql_query($str);                 $i=0;                 while($row = mysql_fetch_array($result))                 {                         $str_array[$i]=$row;                         $i++;                 }                 if(empty($str_array))                 {                         $str_array=array();                 }                 $this->db=$str_array;         }This is a MYSQL database operation class. Friends can download it and use it.

    Other libraries17302017-12-26
  • <?php use PHPImageWorkshop\ImageWorkshop as ImageWorkshop; require_once(__DIR__.'/autoload.php'); class ImageWorkshopTest extends \PHPUnit_Framework_TestCase { ===================================================================================          const IMAGE_SAMPLE_PATH = '/Resources/images/sample1.jpg';     const FONT_SAMPLE_PATH  = '/Resources/fonts/arial.ttf';     const WEB_PATH          = 'http://localhost:8000';     public function testInitFromPath()     {         // test 1                  $layer = ImageWorkshop::initFromPath(__DIR__.static::IMAGE_SAMPLE_PATH);                  $this->assertTrue(is_object($layer) === true, 'Expect $layer to be an object');         $this->assertTrue(get_class($layer) === 'PHPImageWorkshop\Core\ImageWorkshopLayer', 'Expect $layer to be an ImageWorkshopLayer object');         // test 2         $layer = ImageWorkshop::initFromPath('file://'.__DIR__.static::IMAGE_SAMPLE_PATH);         $this->assertTrue(is_object($layer) === true, 'Expect $layer to be an object');         $this->assertTrue(get_class($layer) === 'PHPImageWorkshop\Core\ImageWorkshopLayer', 'Expect $layer to be an ImageWorkshopLayer object');         // test 3         if (version_compare(PHP_VERSION, '5.4', '>=')) {             $layer = ImageWorkshop::initFromPath(static::WEB_PATH.'/sample1.jpg');             $this->assertTrue(is_object($layer) === true, 'Expect $layer to be an object');             $this->assertTrue(get_class($layer) === 'PHPImageWorkshop\Core\ImageWorkshopLayer', 'Expect $layer to be an ImageWorkshopLayer object');         }The advantages of this library. The thumbnail speed is very fast and the quality is very highSupport smart croppingVery good support for GIF images5 thumbnail modesImage comparison functionAdvanced image filtering functionImage blendingThe APIs supported by other image processing libraries are basically supported

    Other libraries22992017-12-25
  • <?php namespace Stampie; /**  * @author Christophe Coevoet <stof@notk.org>  */ interface IdentityInterface {     /**      * @return string      */     public function getEmail();     /**      * @return string|null      */     public function getName(); }This class library has the same function as phpmailer, but its performance is better than phpmailer, especially in the ability to process attachments, and the probability of sending emails successfully is also high.

    Other libraries18212017-12-25
  • <?php namespace Stampie; class Identity implements IdentityInterface {     private $email;     private $name;     public function __construct($email = null, $name = null)     {         $this->email = $email;         $this->name = $name;     }     public function setEmail($email)     {         $this->email = $email;         return $this;     }     public function getEmail()     {         return $this->email;     }File uploading is a common function in project development, but the process of file uploading is relatively cumbersome. As long as there is a file uploading place, these complex codes need to be written. In order to reduce the difficulty of writing functions in each development and to save development time, we usually encapsulate these repeatedly used pieces of code into a class. This class library is such a convenient library.

    Other libraries22862017-12-25
  • <?php require_once __DIR__.'/../vendor/autoload.php'; use Gregwar\Captcha\CaptchaBuilder; $tests = 10000; $passed = 0; shell_exec('rm passed*.jpg'); for ($i=0; $i<$tests; $i++) {     echo "Captcha $i/$tests... ";     $captcha = new CaptchaBuilder;     $captcha         ->setDistortion(false)         ->build()     ;     if ($captcha->isOCRReadable()) {         $passed++;         $captcha->save("passed$passed.jpg");         echo "passed at ocr... ";     } else {         echo "failed... ";     }     echo "pass rate: ".round(100*$passed/($i+1),2)."%\n"; } echo "\n"; echo "Over, $passed/$tests readed with OCR\n";When logging in to the module with user permissions first, we will often use verification codes. Today I would like to recommend a verification code library for your future use. The steps to generate a verification code are roughly: 1) Generate a random string; 2) Create an image (imagecreatetruecolor), and then output the string to In the image (imagestring or imagettftext); 3) Interfere with noise in the image, such as adding some lines or pixels (imageline and imagesetpixel). 4) Output image (imagepng) 5) Destroy image resources

    Other libraries24362017-12-25
  • <?php        class QRbitstream {              public $data = array();                  //----------------------------------------------------------------------         public function size()         {             return count($this->data);         }                  //----------------------------------------------------------------------         public function allocate($setLength)         {             $this->data = array_fill(0, $setLength, 0);             return 0;         }              //----------------------------------------------------------------------         public static function newFromNum($bits, $num)         {             $bstream = new QRbitstream();             $bstream->allocate($bits);                          $mask = 1 << ($bits - 1);             for($i=0; $i<$bits; $i++) {                 if($num & $mask) {                     $bstream->data[$i] = 1;                 } else {                     $bstream->data[$i] = 0;                 }                 $mask = $mask >> 1;             }             return $bstream;         }This QR code generation library is very easy to use. Of course, your PHP environment must enable GD2 support. This library provides a key png() method, in which the parameter $text indicates the generation of two-digit information text; the parameter $outfile indicates whether to output a QR code image file, the default is no; the parameter $level indicates the fault tolerance rate, that is, there is The covered areas can also be identified, which are L (QR_ECLEVEL_L, 7%), M (QR_ECLEVEL_M, 15%), Q (QR_ECLEVEL_Q, 25%), H (QR_ECLEVEL_H, 30%); the parameter $size indicates the size of the generated image, The default is 3; the parameter $margin indicates the spacing value of the blank area of ​​the border around the QR code; the parameter $saveandprint indicates whether to save the QR code and display it.

    Other libraries21702017-12-25
  • <?php  *  * @author    Colin Verot <colin@verot.net>  * @license   http://opensource.org/licenses/gpl-license.php GNU Public License  * @copyright Colin Verot  */ class upload {     /**      * Class version      *      * @access public      * @var string      */     var $version;     /**      * Uploaded file name      *      * @access public      * @var string      */     var $file_src_name;     /**      * Uploaded file name body (i.e. without extension)      *      * @access public      * @var string      */File uploading is a common function in project development, but the process of file uploading is relatively cumbersome. As long as there is a file uploading place, these complex codes need to be written. In order to reduce the difficulty of writing functions in each development and to save development time, we usually encapsulate these repeatedly used pieces of code into a class. This class library is such a convenient library.

    Other libraries19272017-12-23
  • <?php namespace JasonGrimes; class Paginator {     const NUM_PLACEHOLDER = '(:num)';     protected $totalItems;     protected $numPages;     protected $itemsPerPage;     protected $currentPage;     protected $urlPattern;     protected $maxPagesToShow = 10;     protected $previousText = 'Previous';     protected $nextText = 'Next';     /**      * @param int $totalItems The total number of items.      * @param int $itemsPerPage The number of items per page.      * @param int $currentPage The current page number.      * @param string $urlPattern A URL for each page, with (:num) as a placeholder for the page number. Ex. '/foo/page/(:num)'      */     public function __construct($totalItems, $itemsPerPage, $currentPage, $urlPattern = '')     {         $this->totalItems = $totalItems;         $this->itemsPerPage = $itemsPerPage;         $this->currentPage = $currentPage;         $this->urlPattern = $urlPattern;         $this->updateNumPages();     }Function 1: Generate paging navigation and paging function parameter list based on the total number of pages, current page, page grouping and url (how many pages, current page, how many per page, link address). Function 2: According to the number of records, page columns are counted, $page, current page; $row_num total number of records; $pagesize: number of records per page; $url record page.

    Pagination library96592017-12-23