Home > Download >  Library download

  • <?php class FanyiAction extends Action {   public function _empty(){     header("HTTP/1.0 404 Not Found");     $this->display("Public:404");   }   public function index()   {     $User = A("Index");     $User->head();     $User->right();     $User->footer();     $this->display();   }   public function fanyi()   {     $value=$_POST['value'];     $from="auto";     $to="auto";     $value_code=urlencode($value);     $appid="xxxxxxxx";//这里填写你在百度上申请的API key     $languageurl = "http://openapi.baidu.com/public/2.0/bmt/translate?client_id=" . $appid ."&q=" .$value_code. "&from=".$from."&to=".$to;     $text=json_decode($this->language_text($languageurl));     $text = $text->trans_result;     $rs=$text[0]->dst;     $this->assign('value',$value);     $this->assign('rs',$rs);     $User = A("Index");     $User->head();     $User->right();     $User->footer();     $this->display('index');   } Baidu Translation is an online translation service released by Baidu. It relies on the advantages of Internet data resources and natural language processing technology to help users bridge the language gap and obtain information and services conveniently and quickly. Baidu Translation supports translation into 28 popular languages ​​around the world, including Chinese, English, Japanese, Korean, Spanish, Thai, French, Arabic, Portuguese, Russian, German, Italian, Dutch, and Greek English, Estonian, Bulgarian, Polish, Danish, Finnish, Czech, Romanian, Swedish, Slovenian, Hungarian, Vietnamese, Cantonese, classical Chinese and traditional Chinese, covering 756 translation directions. "The world is complex, Baidu understands you better." Baidu Translate has multiple product forms such as web version and mobile APP. In addition, it also provides open cloud interface services for developers, responding to hundreds of millions of translation requests every day. . In addition to text translation, based on the diverse translation needs of users, it has launched functions such as web page translation, online definitions, massive example sentences, authoritative dictionaries, offline translation, voice translation, conversation translation, practical spoken language and photo translation, allowing users to enjoy every translation experience. On February 28, 2013, based on mobile phone usage scenarios, Baidu Translation officially launched the Android mobile client, and on March 7, 2013, the iOS mobile client was officially released. In May 2015, the neural network translation (NMT) system was released, which is the world's first Internet NMT online product. In June 2015, the offline NMT system for mobile phones was released, supporting multiple languages ​​such as Chinese, English, Japanese and Korean. On July 5, 2016, Baidu Human Translation was officially released, providing users with paid and accurate human translation services, and is committed to more comprehensively meeting the translation needs of users in different scenarios.

    Other libraries23572017-12-29
  • <?php //功能:生成缩略图 class CreatMiniature { //公共变量   var $srcFile = ""; //原图   var $echoType; //输出图片类型,link--不保存为文件;file--保存为文件   var $im = ""; //临时变量   var $srcW = ""; //原图宽   var $srcH = ""; //原图高 //设置变量及初始化   function SetVar($srcFile, $echoType)   {     if (!file_exists($srcFile)) {       echo '源图片文件不存在!';       exit();     }     $this->srcFile = $srcFile;     $this->echoType = $echoType;     $info = "";     $data = GetImageSize($this->srcFile, $info);     switch ($data[2]) {       case 1:         if (!function_exists("imagecreatefromgif")) {           echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!返回";           exit();         }Generate thumbnail function (supports image formats: gif, jpeg, png and bmp) * @author ruxing.li * @param string $src Source image path * @param int $width Thumbnail width (conformal scaling is performed when only the height is specified) * @param int $width Thumbnail height (conformal scaling is performed when only the width is specified) * @param string $filename Save path (directly output to the browser if not specified) * @return bool

    Other libraries17372017-12-29
  • <?php class Student {   var $str_Name;   var $str_Sex;   var $int_Id;   var $int_English;   var $int_maths;   function  Input ( $Name, $Sex, $Id, $English, $Maths)   {     $this->str_Name=$Name;     $this->str_Sex =$Sex;     $this->int_Id =$Id;     $this->int_English=$English;     $this->int_Maths=$Maths;   }   function ShowInfo()   {       echo ("姓名:$this->str_Name<br>   ");   echo ("性别:$this->str_Sex <br>   ");   echo ("学号:$this->int_Id <br>   ");   echo ("英语成绩:$this->int_English <br>   ");   echo ("数学成绩:$this->int_Maths <br>   ");   } }   $Wing = new Student;   $Wing->Input ("Wing","男",33,95,87);   $Paladin = new Student;     $Paladin->Input ("paladin","女",38,58,59.5);     $Wing->ShowInfo();   $Paladin->ShowInfo(); ?> Defines the human class, including name, gender, student number, English score, math score, etc.

    Other libraries16282017-12-29
  • <?php class cache {   var $cacheRoot    = "./cache/";   var $cacheLimitTime  = 3;   var $cacheFileName  = "";   var $cacheFileExt   = "php";   function cache( $cacheLimitTime ) {     if( intval( $cacheLimitTime ) )       $this->cacheLimitTime = $cacheLimitTime;     $this->cacheFileName = $this->getCacheFileName();     ob_start();   }   function cacheCheck(){     if( file_exists( $this->cacheFileName ) ) {       $cTime = $this->getFileCreateTime( $this->cacheFileName );       if( $cTime + $this->cacheLimitTime > time() ) {         echo file_get_contents( $this->cacheFileName );         ob_end_flush();         exit;       }     }     return false;   } Generally speaking, the purpose of caching is to put data in one place to make access faster. There is no doubt that memory is the fastest, but can hundreds of M of data be stored in it? This is not the case In reality, of course, sometimes it is temporarily placed in the server cache. For example, if the ob_start() cache page is turned on, the page content will be cached in the memory before sending the file header, until the page output is automatically cleared or waiting for the return of ob_get_contents, [or Cleared by ob_end_clean, which can be well used in the generation of static pages and can be well reflected in templates

    Other libraries18732017-12-29
  • <?php class fileoperate { var $path; var $name; var $result;   function creat_file($path,$name) {   $filename=$path.$name;   if (file_exists($filename))   {     echo "文件已经存在,请换个文件名";   }   else   {     if (file_exists($path))     {       touch($name);       rename($name,$filename);       echo "文件建立成功 </br>";     }     else{       echo "目录不存在,请检查";     }   } } Create the specified file under the specified path * @param string $path (needs to include the file name and suffix) * @param boolean $over_write Whether to overwrite the file * @param int $time Set time. The default is the current system time * @param int $atime Set the access time. The default is the current system time

    Other libraries20482017-12-29
  • <?php //打印上一个session; //echo "上一个session:<b>".$_SESSION["authnum_session"]."</b><br>"; $validate=""; if(isset($_POST["validate"])){   $validate=$_POST["validate"];   echo "您刚才输入的是:".$_POST["validate"]."<br>状态:";   if($validate!=$_SESSION["authnum_session"]){ //判断session值与用户输入的验证码是否一致;     echo "<font color=red>输入有误</font>";   }else{     echo "<font color=green>通过验证</font>";   } }First create a complete verification page, and then open the session on the page first,Remove the session, so that you can get a new session value every time;The effect of using seesion is good, It’s also very convenient

    Other libraries22212017-12-27
  • <?PHP header("Content-type: text/html; charset=utf-8");   $link = mysql_connect('localhost','root','eric') or die(mysql_error()); mysql_select_db('sortclass',$link);   class SortClass{   var $data = array();   var $child = array(-1=>array());   var $layer = array(-1=>-1);   var $parent = array();   var $link;   var $table;   function SortClass($link, $table){     $this->setNode(0, -1, '顶极节点');     $this->link = $link;     $this->table = $table;     $node = array();     $results = mysql_query('select * from '.$this->table.'',$this->link);     while($node = mysql_fetch_assoc($results)){       $this->setNode($node['cid'],$node['pid'],$node['cname']);     }   }This is an implementation library for PHP infinite splitting, with two methods: recursive and non-recursive. Friends who need it can download it and use it.

    Other libraries23112017-12-27
  • <?php class Parser {   private $_tpl;   public function __construct($_tplFile)   {     if (! $this->_tpl = file_get_contents($_tplFile)) {       exit('ERROR:模版文件读取错误');     }   }   private function parvar()   {     $_patten = '/<!--\s+\{$([\w]+)\}\s+-->/';     if (preg_match($_patten,$this->_tpl)) {       $this->_tpl = preg_replace($_patten, "<?php echo $this->_vars[''];?>",$this->_tpl);     }   }   private function parif(){     $_pattenif = '/<!--\s+\{if\s+$([\w]+)\}\s+-->/';     $_pattenElse = '/<!--\s+\{else\}\s+-->/';     $_pattenEndif = '/<!--\s+\{\/if\}\s+-->/';     if (preg_match($_pattenif,$this->_tpl)) {       if (preg_match($_pattenEndif,$this->_tpl)) {         $this->_tpl = preg_replace($_pattenif,"<?php if ($this->_vars['']){?>",$this->_tpl);         $this->_tpl = preg_replace($_pattenEndif,"<?php } ?>",$this->_tpl);         if (preg_match($_pattenElse,$this->_tpl)) {           $this->_tpl = preg_replace($_pattenElse,"<?php }else{?>",$this->_tpl);         }       }else{         echo 'ERROR:IF语句没有关闭!';       }     }   }After receiving the content of the template file, construct a method, obtain the content of the template file and parse it, use ordinary variables to parse the IF statement, and then parse the template file to generate a compiled file.

    Other libraries18452017-12-27
  • <?php class AlipayNotify {   var $https_verify_url = 'https://mapi.alipay.com/gateway.do?service=notify_verify&';   var $http_verify_url = 'http://notify.alipay.com/trade/notify_query.do?';   var $alipay_config;   function __construct($alipay_config){     $this->alipay_config = $alipay_config;   }   function AlipayNotify($alipay_config) {     $this->__construct($alipay_config);   }   function verifyNotify(){     if(empty($_POST)) {//判断POST来的数组是否为空       return false;     }This is to verify the address in the form of HTTPS message and then use notify_url to verify whether the message is a legitimate message sent by Alipay, judge whether the array from POST is empty, and obtain the ATN result of the Alipay remote server (verify whether it is a message sent by Alipay).

    Other libraries19702017-12-27
  • <?php class mysafe{ public $logname; public $isshwomsg; function __construct(){ set_error_handler('MyError',E_ALL); //----- } function MyError($errno, $errstr, $errfile, $errline){ echo "<b>Error number:</b> [$errno],error on line $errline in $errfile<br />"; exit; } function wlog($logs){ if(empty($logname)){ $this->logname=$_SERVER["DOCUMENT_ROOT"]."/log.htm"; } $Ts=fopen($this->logname,"a+"); fputs($Ts,$logs."\r\n"); fclose($Ts); } function showmsg($msg='',$flag=false){ $this->isshwomsg=empty($this->isshwomsg) ? false : true; if ($this->isshwomsg) { echo '<br />--------------------------------------<br />'; echo $msg; echo '<br />--------------------------------------<br />'; if ($flag) exit; }This is a PHP parameter and data filtering class. For data security, filtered data must be used before it can be used.

    Other libraries17682017-12-27
  • <?php class qqlogin{   public $app_id;   public $app_key;   public $callback;   public $code;   public $state;   public function __construct($app_id,$app_key,$callback){     $this->code = isset($_REQUEST['code'])? $_REQUEST['code'] : '';     $this->state = isset($_REQUEST['state'])? $_REQUEST['state'] : '';     $this->app_id = $app_id;     $this->app_key = $app_key;     $this->callback = $callback;   }   public function get_token(){     $url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=".$this->app_id."&client_secret=".$this->app_key."&code=".$this->code."&redirect_uri=".urlencode($this->callback);     $str = $this->visit_url($url);     parse_str($str,$arr);     return $arr;   }This is a QQ login class, used for the QQ login interface, php-qq login class, the class has been encapsulated, used for the QQ login callback page. app_id, app_key, callbackYou need to go to the QQ Internet documentation to understand the QQ access process. This type only encapsulates the callback function. Request the URL address, get the return string, convert the string into a format that can be json_decoded, and get the page return value through curl.

    Other libraries19702017-12-27
  • <?php class Image {   private $info;   private $image;   public $type;   public function __construct($src)   {     $this->info=getimagesize($src);     $this->type=image_type_to_extension($this->info['2'],false);     $fun="imagecreatefrom{$this->type}";     $this->image=$fun($src);   }This is a class library that can operate pictures. You can add watermarks to pictures, compress pictures, and cut pictures. * Text watermark * @param [type] $font Font * @param [type] $content Content * @ param [type] $size Text size * @param [type] $col Text color (quaternary array) * @param array $location Location * @ param integer $angle Tilt angle * @return [type] * Image watermark * @param [type] $imageMark Watermark image address * @param [type] $dst The position of the watermark image in the original image * @param [type] $pct Transparency * @return [type] * Compression Image * @param [type] $thumbSize Compressed image size * @return [type] [description] * Crop image * @ param [type] $cutSize cutting size * @param [type] $location cutting position * @return [type] [description] * Display picture * @return [type] [description] * Save the picture * @param [type] $newname New picture name * @return [type ] [description]

    Other libraries20662017-12-26