首页 > 下载 >  类库下载

  • <?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');   }百度翻译是百度发布的在线翻译服务,依托互联网数据资源和自然语言处理技术优势,致力于帮助用户跨越语言鸿沟,方便快捷地获取信息和服务。百度翻译支持全球28种热门语言互译,包括中文、英语、日语、韩语、西班牙语、泰语、法语、阿拉伯语、葡萄牙语、俄语、德语、意大利语、荷兰语、希腊语、爱沙尼亚语、保加利亚语、波兰语、丹麦语、芬兰语、捷克语、罗马尼亚语、瑞典语、斯洛文尼亚语、匈牙利语、越南语、粤语、文言文和中文繁体等,覆盖756个翻译方向。“世界很复杂,百度更懂你”,百度翻译拥有网页版和手机APP等多种产品形态,此外还针对开发者提供开放云接口服务,日均响应上亿次翻译请求。除文本翻译外,结合用户多样性的翻译需求,推出网页翻译、网络释义、海量例句、权威词典、离线翻译、语音翻译、对话翻译、实用口语和拍照翻译等功能,让用户畅享每一次翻译体验。2013年2月28日,结合移动手机使用场景,百度翻译正式推出Android手机客户端,2013年3月7日,正式发布iOS手机客户端。2015年5月,发布神经网络翻译(NMT)系统,是世界上首个互联网NMT线上产品。2015年6月,发布手机端离线NMT系统,支持中英日韩等多种语言。2016年7月5日,百度人工翻译正式发布,为用户提供付费的精准人工翻译服务,致力于更全面地满足不同场景下用户的翻译需求。

    其它类库23582017-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();         }生成缩略图函数(支持图片格式:gif、jpeg、png和bmp)  * @author ruxing.li  * @param  string $src      源图片路径  * @param  int    $width    缩略图宽度(只指定高度时进行等比缩放)  * @param  int    $width    缩略图高度(只指定宽度时进行等比缩放)  * @param  string $filename 保存路径(不指定时直接输出到浏览器)  * @return bool 

    其它类库17372017-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(); ?>定义人的类,有姓名,性别,学号,英语成绩,数学成绩等

    其它类库16282017-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;   }一般来说,缓存的目的是把数据放在一个地方让访问的更快点,毫无疑问,内存是最快的,但是,几百M的数据能往内存放么?这不现实,当然,有的时候临时放如服务器缓存,如ob_start()这个缓存页面开启的话在发送文件头之前页面内容都被缓存在内存中,知道等页面输出自动清楚或者等待 ob_get_contents的返回,[或者被ob_end_clean显示的清除,这在静态页面的生成中能很好的利用,在模板中能得到很好的体现

    其它类库18732017-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 "目录不存在,请检查";     }   } } 创建指定路径下的指定文件     * @param string $path(需要包含文件名和后缀)     * @param boolean $over_write 是否覆盖文件     * @param int $time 设置时间。默认是当前系统时间     * @param int $atime 设置访问时间。默认是当前系统时间

    其它类库20482017-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>";   } }首先创建一个完整验证页面,然后在页首先要开启session,将session去掉,以每次都能取新的session值;用seesion 效果不错,也很方便

    其它类库22222017-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']);     }   }这是一个PHP无限级分裂的实现库,有递归 非递归俩种方法。需要的朋友可以下载使用。

    其它类库23112017-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语句没有关闭!';       }     }   }接收模版文件内容后,构造方法,获取模版文件内容解析后用普通变量解析IF语句,之后解析模版文件生成编译文件。

    其它类库18462017-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;     }这是以HTTPS形式消息验证地址然后针对notify_url验证消息是否是支付宝发出的合法消息判断POST来的数组是否为空获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)。

    其它类库19702017-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; }这个是个PHP的参数和数据的过滤类,为了数据的安全一定要过滤后的数据才可以使用。

    其它类库17682017-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;   }这是一个QQ登陆类,用于QQ登陆的界面,php-qq登陆类,类已封装,用于QQ登陆的callback页面。 app_id,app_key,callbackqq接入流程需要自己去QQ互联文档上了解,此类只做回调功能封装。请求URL地址,得到返回字符串,将字符串转换为可以进行json_decode的格式,通过curl取得页面返回值。

    其它类库19702017-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);   }这是一个可以操作图片的类库,可以给图片添加水印,压缩图片,剪切图片。 * 文字水印   * @param [type] $font   字体   * @param [type] $content 内容   * @param [type] $size   文字大小   * @param [type] $col   文字颜色(四元数组)   * @param array  $location 位置   * @param integer $angle  倾斜角度   * @return [type]   * 图片水印   * @param [type] $imageMark 水印图片地址   * @param [type] $dst    水印图片在原图片中的位置   * @param [type] $pct    透明度   * @return [type]   * 压缩图片   * @param [type] $thumbSize 压缩图片大小   * @return [type]      [description]   * 裁剪图片   * @param [type] $cutSize 裁剪大小   * @param [type] $location 裁剪位置   * @return [type]      [description]   * 展现图片   * @return [type] [description]   * 保存图片   * @param [type] $newname 新图片名   * @return [type]     [description]

    其它类库20672017-12-26