新程php培训–就业率100%的php培训中心 全国免费咨询热线 400-668-8834 了解更多,请访问 http://www.phppx.com
2010/03/31php培训

评论关闭
2010/01/26学员就业

评论关闭

李震毕业感言


学员姓名:李震就业情况:

就业于水晶石数字科技有限公司 (http://www.crystalcg.com/cn/

李震毕业感言

    转眼之间,我的三个月的培训已经结束了.时间虽然短暂,也许与高中或者大学无法相比,可这三个月朋友之间的喜怒哀乐与缴老师不厌其烦的讲解.这些回忆才是 最宝贵和美好的. 记得我们刚刚来到新程培训的时候是那样的稚嫩,关于培训的项目我们可以说是”零”基础,虽然是大学刚刚毕业,可四年的大学生活中,又能真正学到些什 么………
     在来到新程PHP培训之前,已经大学毕业半年多了,我在大学学的专业是计算机网络技术,在大学毕业后自然而然也就围着关于网络的工作找,面对着一次次的招 聘会,面对着一次次的尴尬与摇头,自己才发现,大学所学的东西怎么那么没有用呢,怎么就找不到一个工作呢,一个关于网络的工作这么难找吗???
     之后,跟父母研究以后,决定找个培训班,在充充电,就这样找到了新程PHP培训,与缴老师结识了.
     我选择的是LAMP全能就业班,在这三个月的学习中,真的就一个感觉,每天都在飞快的成长,每天都在飞快的进步.
     在缴老师的教学中,我感觉到了什么叫做责任心,由于我们来的时候对于PHP都是零基础,所以感觉比较笨,但是无论我们怎么笨,怎么不会,怎么听不懂,缴老 师都是始终如一的去讲解每一个问题,每一个知识点一直讲到我们点头说会为止,在签订合同的时候,上课时间只有一上午,可是实际上课的时间基本都是一整天, 一整天的上,缴老师从来没有在收取别的费用了.
      三个月的时间过去了,缴老师也按照合同给我们找到了工作,可没想到的是给我们找到了一家这么有实力,这么大的公司—水晶石数字科技有限公司.这是一家跨国公司,在中国 北京,天津上海等都有公司,在英国伦敦也有分公司,还是2012年奥运会合作伙伴…
     缴老师的培训班没得说,一个字”棒”,两个字”责任”,
     最后祝愿新程PHP培训班越办越好,哈哈其实不用祝愿也会办的越来越好的,因为有着一个这么负责任的老师在指导着我们前进,临了给新程写了一首小诗…..

      新程诗
新山青,程山青
两岸青山相对迎
总关同窗离别情
祝愿新程往前行

马铮毕业感言

mazheng_small

学员姓名:马铮

基本资料:毕业于北京工业大学,本科。毕业后曾从事COBOL语言开发。自学过4个月的php语言,但是一直不得要领。到新程php培训中心学习之前,曾考虑到北京某知名php培训班学习,但因对方宣传与实际不符而放弃。

就业情况:现就业360圈(http://www.360quan.com/),因与公司签订工资保密协议而不能公布工资 。

马铮毕业感言:

  秋天的凉意还没有到来,三个月的学习生活就已走到了尽头。还没有褪去记忆里相逢的色彩,耳边却已响起了离别的歌谣。三个月的时间虽然短暂,但在我心里却如曲水流长婉转,脑海中留下的点滴痕迹也似萤火虫般醒目难忘。

想起今年从上家公司离职的时候,感觉刚毕业不久而且非科班出身的自己对于软件的理解就像是打补丁,这里一块那里一块,没有一个完整的知识体系,又像是在黑夜里行走,有力气也跑不了几步。思前想后,决定还是要进行一下完整知识体系的培训,需要一个好的导师进行沟通指导。在进行了很多培训机构的调查咨询后,我最终选择了新程PHP培训,这段难忘的时光也由此宣告开始。

乍到此处,心有戚戚然,然而随着渐渐与导师与同学沟通的深入,感觉到了这里浓厚的大家庭的氛围。每天上午的任课老师邓老师的讲课也由浅入深,循序渐进,从HTML到CSS,从JS到BOM,从PHP到MYSQL,我也由懵懵懂懂的听课看书,逐步进入深入学习探讨的状态,从一开始脑子里满是问题都不知道问哪个好到后来能够根据导师的提示自己寻找线索解决答案再到后来的自己提出问题能够给出几个解决方案,每一次都是飞跃,每一次都增长了我的不断学习的信心与继续技术这条路的决心。

随着学习的深入,接触的技术不断的增多,随之而来的一种浮躁的心态愈演愈烈。慢慢的我发现我自己每天很累很疲惫,还总有种失去方向的感觉,想要一口吃下一个胖子却又不可能一口吃下一个胖子。在这样矛盾的心理的作用下,有时候一点自信也没有,有时候想要放弃,但是导师缴老师的一句话(遇到问题不要怕,当你分析并解决问题后,你会比别人获得更大的收获),让我思量良久。于是我静下心来,专注导师所讲课的内容,从基础一点一点的掌握,就像先哲马克思所说,基础决定上层建筑。要想在技术这条路上越走越远,就必须把基础打牢,这样才能学的更深,飞得更高。

这里和其他培训机构最大的不同:每天下午缴老师都要牺牲自己休息的时间,耐心的为大家做辅导,巩固每天学习的知识,定期为我们做一些高级技术的专题讲座(如JSON SEO JQUERY,大流量负载方案)并最终指导我们每人独立完成了3个版本(普通,静态,MVC)的CMS系统,这些最终成为了我之后一次次面试,笔试成功的最大资本。

唐骏说过一句话:我们需要的不是给你1个月时间你能考100分的人,我们需要的是给你1天时间你能考60分的人。两位老师每天不断地强调我们要养成独立学习的习惯,遇到问题如何分析和解决,当我们离开老师时,也可以不断地自我成长。

就这样,每天在课堂上认真求索,在家里坚持复习,一切都有条不紊的进行着。日子一天天的过去,我从一个懵懵懂懂的初学者到了现在一些理念熟稔于心的老鸟。临到这几天的面试笔试,感觉有些从容,不再像初毕业时候的那般捉襟见肘穷于应付。

现在是离别的时刻,现在也是开始的时刻。感谢这个大家庭给我带来的自信与从容,感谢缴老师对我的照顾与指导。

最后祝愿新程PHP培训越做越好,每位同学们都能在这里实现梦想,找到理想的工作。

2010/09/01php培训

评论关闭

新程php培训,可免费试听5天,不收任何费用!

考虑到有些同学不太清楚自己是不是适合学习php,同时也为了打消各位同学的顾虑,新程PHP培训决定把免费试听的时间从2天提高到5天,完全免费,不收取任何费用。
很多“所谓知名培训”只能试听半天时间,这说明什么,他们对教学时不自信的。我们之所以这样做,源于我们对教学的自信,以及“一切为就业服务”的态度。
新程PHP培训将一如既往,竭尽全力为各位同学服务。

学员就业

评论关闭

新程php培训就业班第五期全部8名同学已在1个月内100%就业

经过三个月的紧张而有序的学习,新程PHP培训就业班第六期全部8名同学在一个月内已经100%就业。

之所以能够100%就业,最重要3个因素是:

  • ·具有多年开发经验的老师认真负责的做好教学工作;
  • ·非常全面、合理的lamp课程体系,课程内容即是以后工作内容;
  • ·各位同学自身的不懈努力;

新程成立2年多以来,严格恪守“好好做教学,好好做就业”的宗旨,用铁一样事实一次次证明,新程PHP培训从来没有食言过,是真正对得起学员每一分学费的。

下面是8位同学的工作照。(注:我们绝不拿入学照,或者生活照当工作照,那样完全没有可信度)。以下所有同学QQ,手机联系方式都有,但是考虑到个人隐私,这里不方便公开。如想跟其中某位同学聊聊,请加QQ543850577(毛老师) 点击这里给我发消息 或者 QQ群100498385。(以下同学都在群里)

胡佳就业于:天啸融通(北京)科技有限公司 李金霞就业于:马可波罗网
祝清就业于:宏合窗景科技有限公司 李想就业于:无限新空信息技术有限公司
马曙光就业于:北京芙德中天科贸有限公司 金建丞就业于:国际教育科技有限公司
张鹏飞就业于:乐你游旅行网 王方超就业于:北京百德诚医疗科技有限公司

2010/04/08php技术

评论关闭

一个不依靠ZLib模块可以创建、操作 ZIP 文件的PHP类

这个类的所有操作不需要 zLib 模块的支持,有的时候可能会用到这个类。

<?
/**
* @copyright 互联网
* @author bouchon
* 整理:www.phppx.com
* @desc 建立、操作、控制 ZIP 文件的类
*/

class zip
{
        var $datasec, $ctrl_dir = array();
        var $eof_ctrl_dir = “\x50\x4b\x05\x06\x00\x00\x00\x00″;
        var $old_offset = 0; var $dirs = Array(“.”);

        function get_List($zip_name)
        {
                $zip = @fopen($zip_name, ‘rb’);
                if(!$zip) return(0);
                $centd = $this->ReadCentralDir($zip,$zip_name);

                @rewind($zip);
                @fseek($zip, $centd['offset']);

                for ($i=0; $i<$centd['entries']; $i++)
                {
                        $header = $this->ReadCentralFileHeaders($zip);
                        $header['index'] = $i;$info['filename'] = $header['filename'];
                        $info['stored_filename'] = $header['stored_filename'];
                        $info['size'] = $header['size'];$info['compressed_size']=$header['compressed_size'];
                        $info['crc'] = strtoupper(dechex( $header['crc'] ));
                        $info['mtime'] = $header['mtime']; $info['comment'] = $header['comment'];
                        $info['folder'] = ($header['external']==0×41FF0010||$header['external']==16)?1:0;
                        $info['index'] = $header['index'];$info['status'] = $header['status'];
                        $ret[]=$info; unset($header);
                }
                return $ret;
        }

        function Add($files,$compact)
        {
                if(!is_array($files[0])) $files=Array($files);

                for($i=0;$files[$i];$i++){
                        $fn = $files[$i];
                        if(!in_Array(dirname($fn[0]),$this->dirs))
                        $this->add_Dir(dirname($fn[0]));
                        if(basename($fn[0]))
                        $ret[basename($fn[0])]=$this->add_File($fn[1],$fn[0],$compact);
                }
                return $ret;
        }

        function get_file()
        {
                $data = implode(”, $this -> datasec);
                $ctrldir = implode(”, $this -> ctrl_dir);

                return $data . $ctrldir . $this -> eof_ctrl_dir .
                pack(‘v’, sizeof($this -> ctrl_dir)).pack(‘v’, sizeof($this -> ctrl_dir)).
                pack(‘V’, strlen($ctrldir)) . pack(‘V’, strlen($data)) . “\x00\x00″;
        }

        function add_dir($name)
        {
                $name = str_replace(“\\”, “/”, $name);
                $fr = “\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00″;

                $fr .= pack(“V”,0).pack(“V”,0).pack(“V”,0).pack(“v”, strlen($name) );
                $fr .= pack(“v”, 0 ).$name.pack(“V”, 0).pack(“V”, 0).pack(“V”, 0);
                $this -> datasec[] = $fr;

                $new_offset = strlen(implode(“”, $this->datasec));

                $cdrec = “\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00″;
                $cdrec .= pack(“V”,0).pack(“V”,0).pack(“V”,0).pack(“v”, strlen($name) );
                $cdrec .= pack(“v”, 0 ).pack(“v”, 0 ).pack(“v”, 0 ).pack(“v”, 0 );
                $ext = “\xff\xff\xff\xff”;
                $cdrec .= pack(“V”, 16 ).pack(“V”, $this -> old_offset ).$name;

                $this -> ctrl_dir[] = $cdrec;
                $this -> old_offset = $new_offset;
                $this -> dirs[] = $name;
        }

        function add_File($data, $name, $compact = 1)
        {
                $name     = str_replace(‘\\’, ‘/’, $name);
                $dtime    = dechex($this->DosTime());

                $hexdtime = ‘\x’ . $dtime[6] . $dtime[7].’\x’.$dtime[4] . $dtime[5]
                . ‘\x’ . $dtime[2] . $dtime[3].’\x’.$dtime[0].$dtime[1];
                eval(‘$hexdtime = “‘ . $hexdtime . ‘”;’);

                if($compact)
                $fr = “\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00″.$hexdtime;
                else $fr = “\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00″.$hexdtime;
                $unc_len = strlen($data); $crc = crc32($data);

                if($compact){
                        $zdata = gzcompress($data); $c_len = strlen($zdata);
                        $zdata = substr(substr($zdata, 0, strlen($zdata) – 4), 2);
                }else{
                        $zdata = $data;
                }
                $c_len=strlen($zdata);
                $fr .= pack(‘V’, $crc).pack(‘V’, $c_len).pack(‘V’, $unc_len);
                $fr .= pack(‘v’, strlen($name)).pack(‘v’, 0).$name.$zdata;

                $fr .= pack(‘V’, $crc).pack(‘V’, $c_len).pack(‘V’, $unc_len);

                $this -> datasec[] = $fr;
                $new_offset        = strlen(implode(”, $this->datasec));
                if($compact)
                $cdrec = “\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00″;
                else $cdrec = “\x50\x4b\x01\x02\x14\x00\x0a\x00\x00\x00\x00\x00″;
                $cdrec .= $hexdtime.pack(‘V’, $crc).pack(‘V’, $c_len).pack(‘V’, $unc_len);
                $cdrec .= pack(‘v’, strlen($name) ).pack(‘v’, 0 ).pack(‘v’, 0 );
                $cdrec .= pack(‘v’, 0 ).pack(‘v’, 0 ).pack(‘V’, 32 );
                $cdrec .= pack(‘V’, $this -> old_offset );

                $this -> old_offset = $new_offset;
                $cdrec .= $name;
                $this -> ctrl_dir[] = $cdrec;
                return true;
        }

        function DosTime() {
                $timearray = getdate();
                if ($timearray['year'] < 1980) {
                        $timearray['year'] = 1980; $timearray['mon'] = 1;
                        $timearray['mday'] = 1; $timearray['hours'] = 0;
                        $timearray['minutes'] = 0; $timearray['seconds'] = 0;
                }
                return (($timearray['year'] – 1980) << 25) | ($timearray['mon'] << 21) |     ($timearray['mday'] << 16) | ($timearray['hours'] << 11) |
                ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
        }

        function Extract ( $zn, $to, $index = Array(-1) )
        {
                $ok = 0; $zip = @fopen($zn,’rb’);
                if(!$zip) return(-1);
                $cdir = $this->ReadCentralDir($zip,$zn);
                $pos_entry = $cdir['offset'];

                if(!is_array($index)){ $index = array($index);  }
                for($i=0; $index[$i];$i++){
                        if(intval($index[$i])!=$index[$i]||$index[$i]>$cdir['entries'])
                        return(-1);
                }

                for ($i=0; $i<$cdir['entries']; $i++)
                {
                        @fseek($zip, $pos_entry);
                        $header = $this->ReadCentralFileHeaders($zip);
                        $header['index'] = $i; $pos_entry = ftell($zip);
                        @rewind($zip); fseek($zip, $header['offset']);
                        if(in_array(“-1″,$index)||in_array($i,$index))
                        $stat[$header['filename']]=$this->ExtractFile($header, $to, $zip);

                }
                fclose($zip);
                return $stat;
        }

        function ReadFileHeader($zip)
        {
                $binary_data = fread($zip, 30);
                $data = unpack(‘vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len’, $binary_data);

                $header['filename'] = fread($zip, $data['filename_len']);
                if ($data['extra_len'] != 0) {
                        $header['extra'] = fread($zip, $data['extra_len']);
                } else { $header['extra'] = ”; }

                $header['compression'] = $data['compression'];$header['size'] = $data['size'];
                $header['compressed_size'] = $data['compressed_size'];
                $header['crc'] = $data['crc']; $header['flag'] = $data['flag'];
                $header['mdate'] = $data['mdate'];$header['mtime'] = $data['mtime'];

                if ($header['mdate'] && $header['mtime']){
                        $hour=($header['mtime']&0xF800)>>11;$minute=($header['mtime']&0×07E0)>>5;
                        $seconde=($header['mtime']&0×001F)*2;$year=(($header['mdate']&0xFE00)>>9)+1980;
                        $month=($header['mdate']&0×01E0)>>5;$day=$header['mdate']&0×001F;
                        $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
                }else{$header['mtime'] = time();}

                $header['stored_filename'] = $header['filename'];
                $header['status'] = “ok”;
                return $header;
        }

        function ReadCentralFileHeaders($zip){
                $binary_data = fread($zip, 46);
                $header = unpack(‘vchkid/vid/vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset’, $binary_data);

                if ($header['filename_len'] != 0)
                $header['filename'] = fread($zip,$header['filename_len']);
                else $header['filename'] = ”;

                if ($header['extra_len'] != 0)
                $header['extra'] = fread($zip, $header['extra_len']);
                else $header['extra'] = ”;

                if ($header['comment_len'] != 0)
                $header['comment'] = fread($zip, $header['comment_len']);
                else $header['comment'] = ”;

                if ($header['mdate'] && $header['mtime'])
                {
                        $hour = ($header['mtime'] & 0xF800) >> 11;
                        $minute = ($header['mtime'] & 0×07E0) >> 5;
                        $seconde = ($header['mtime'] & 0×001F)*2;
                        $year = (($header['mdate'] & 0xFE00) >> 9) + 1980;
                        $month = ($header['mdate'] & 0×01E0) >> 5;
                        $day = $header['mdate'] & 0×001F;
                        $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
                } else {
                        $header['mtime'] = time();
                }
                $header['stored_filename'] = $header['filename'];
                $header['status'] = ‘ok’;
                if (substr($header['filename'], -1) == ‘/’)
                $header['external'] = 0×41FF0010;
                return $header;
        }

        function ReadCentralDir($zip,$zip_name)
        {
                $size = filesize($zip_name);
                if ($size < 277) $maximum_size = $size;
                else $maximum_size=277;

                @fseek($zip, $size-$maximum_size);
                $pos = ftell($zip); $bytes = 0×00000000;

                while ($pos < $size)
                {
                        $byte = @fread($zip, 1); $bytes=($bytes << 8) | Ord($byte);
                        if ($bytes == 0×504b0506){ $pos++; break; } $pos++;
                }

                $data=unpack(‘vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size’,
                fread($zip, 18));

                if ($data['comment_size'] != 0)
                $centd['comment'] = fread($zip, $data['comment_size']);
                else $centd['comment'] = ”; $centd['entries'] = $data['entries'];
                $centd['disk_entries'] = $data['disk_entries'];
                $centd['offset'] = $data['offset'];$centd['disk_start'] = $data['disk_start'];
                $centd['size'] = $data['size'];  $centd['disk'] = $data['disk'];
                return $centd;
        }

        function ExtractFile($header,$to,$zip)
        {
                $header = $this->readfileheader($zip);

                if(substr($to,-1)!=”/”) $to.=”/”;
                if(!@is_dir($to)) @mkdir($to,0777);

                $pth = explode(“/”,dirname($header['filename']));
                for($i=0;isset($pth[$i]);$i++){
                        if(!$pth[$i]) continue;
                        if(!is_dir($to.$pth[$i])) @mkdir($to.$pth[$i],0777);
                }
                if (!($header['external']==0×41FF0010)&&!($header['external']==16))
                {
                        if ($header['compression']==0)
                        {
                                $fp = @fopen($to.$header['filename'], ‘wb’);
                                if(!$fp) return(-1);
                                $size = $header['compressed_size'];

                                while ($size != 0)
                                {
                                        $read_size = ($size < 2048 ? $size : 2048);
                                        $buffer = fread($zip, $read_size);
                                        $binary_data = pack(‘a’.$read_size, $buffer);
                                        @fwrite($fp, $binary_data, $read_size);
                                        $size -= $read_size;
                                }
                                fclose($fp);
                                touch($to.$header['filename'], $header['mtime']);

                        }else{
                                $fp = @fopen($to.$header['filename'].’.gz’,'wb’);
                                if(!$fp) return(-1);
                                $binary_data = pack(‘va1a1Va1a1′, 0×8b1f, Chr($header['compression']),
                                Chr(0×00), time(), Chr(0×00), Chr(3));

                                fwrite($fp, $binary_data, 10);
                                $size = $header['compressed_size'];

                                while ($size != 0)
                                {
                                        $read_size = ($size < 1024 ? $size : 1024);
                                        $buffer = fread($zip, $read_size);
                                        $binary_data = pack(‘a’.$read_size, $buffer);
                                        @fwrite($fp, $binary_data, $read_size);
                                        $size -= $read_size;
                                }

                                $binary_data = pack(‘VV’, $header['crc'], $header['size']);
                                fwrite($fp, $binary_data,8); fclose($fp);

                                $gzp = @gzopen($to.$header['filename'].’.gz’,'rb’) or die(“Cette archive est compress閑”);
                                if(!$gzp) return(-2);
                                $fp = @fopen($to.$header['filename'],’wb’);
                                if(!$fp) return(-1);
                                $size = $header['size'];

                                while ($size != 0)
                                {
                                        $read_size = ($size < 2048 ? $size : 2048);
                                        $buffer = gzread($gzp, $read_size);
                                        $binary_data = pack(‘a’.$read_size, $buffer);
                                        @fwrite($fp, $binary_data, $read_size);
                                        $size -= $read_size;
                                }
                                fclose($fp); gzclose($gzp);

                                touch($to.$header['filename'], $header['mtime']);
                                @unlink($to.$header['filename'].’.gz’);

                        }}
                        return true;
        }
}

?>

继续阅读 »

一个操作xml的PHP类(附使用办法)

<?php
/**
* @copyright 互联网
* 整理:[url]www.phppx.com[/url]
* @desc 一个操作xml的PHP类
*/

/*
   (c) 2000 Hans Anderson Corporation.  All Rights Reserved.
   You are free to use and modify this class under the same
   guidelines found in the PHP License.

   ———–

   bugs/me:
   [url]http://www.hansanderson.com/php/[/url]
   [email]me@hansanderson.com[/email]
   [email]showstv@163.com[/email]

   ———–

   Version 1.0

      – 1.0 is the first actual release of the class.  It”s 
       finally what I was hoping it would be, though there
       are likely to still be some bugs in it.  This is
       a much changed version, and if you have downloaded
       a previous version, this WON”T work with your existing
       scripts!  You”ll need to make some SIMPLE changes.

      – .92 fixed bug that didn”t include tag attributes

       (to use attributes, add _attributes[array_index]
        to the end of the tag in question:
        $xml_html_head_body_img would become
        $xml_html_head_body_img_attributes[0], 
        for example)

        — Thanks to Nick Winfield <[email]nick@wirestation.co.uk[/email]>
          for reporting this bug.

      – .91 No Longer requires PHP4!

      – .91 now all elements are array.  Using objects has
       been discontinued.
*/

class xml_container{

   function store($k,$v) {
      $this->{$k}[] = $v;
   }
}
/* parses the information */
/*********************************
*   类定义开始
*
*********************************/
class xml{
  
   // initialize some variables
   var $current_tag=array();
   var $xml_parser;
   var $Version = 1.0;
   var $tagtracker = array();

   /* Here are the XML functions needed by expat */
   /* when expat hits an opening tag, it fires up this function */
   function startElement($parser, $name, $attrs){

      array_push($this->current_tag, $name); // add tag to the cur. tag array
      $curtag = implode(“_”,$this->current_tag); // piece together tag

      /* this tracks what array index we are on for this tag */

      if(isset($this->tagtracker["$curtag"])) {
        $this->tagtracker["$curtag"]++;
      }
      else{
        $this->tagtracker["$curtag"]=0;
      }

      /* if there are attributes for this tag, we set them here. */

      if(count($attrs)>0) {
        $j = $this->tagtracker["$curtag"];
        if(!$j) $j = 0;

        if(!is_object($GLOBALS[$this->identifier]["$curtag"][$j])) {
           $GLOBALS[$this->identifier]["$curtag"][$j] = new xml_container;
        }

        $GLOBALS[$this->identifier]["$curtag"][$j]->store(“attributes”,$attrs);
      }
  
   }// end function startElement

   /* when expat hits a closing tag, it fires up this function */
   function endElement($parser, $name) {
      $curtag = implode(“_”,$this->current_tag); // piece together tag
     
      // before we pop it off,
      // so we can get the correct
      // cdata

      if(!$this->tagdata["$curtag"]) {
        $popped = array_pop($this->current_tag); // or else we screw up where we are
        return; // if we have no data for the tag
      }
      else{
        $TD = $this->tagdata["$curtag"];
        unset($this->tagdata["$curtag"]);
      }

      $popped = array_pop($this->current_tag);
      // we want the tag name for
      // the tag above this, it 
      // allows us to group the
      // tags together in a more
      // intuitive way.

      if(sizeof($this->current_tag) == 0) return; // if we aren”t in a tag

      $curtag = implode(“_”,$this->current_tag); // piece together tag
      // this time for the arrays

      $j = $this->tagtracker["$curtag"];
     
      if(!$j) $j = 0;

      if(!is_object($GLOBALS[$this->identifier]["$curtag"][$j])) {
        $GLOBALS[$this->identifier]["$curtag"][$j] = new xml_container;
      }

      $GLOBALS[$this->identifier]["$curtag"][$j]->store($name,$TD);
      #$this->tagdata["$curtag"]);
      unset($TD);
      return TRUE;
   } // end function endElement
   /* when expat finds some internal tag character data,
     it fires up this function */

   function characterData($parser, $cdata) {
      $curtag = implode(“_”,$this->current_tag); // piece together tag
      $this->tagdata["$curtag"] .= $cdata;
   }
   function xml($data,$identifier=”xml”) { 

      $this->identifier = $identifier;

      // create parser object
      $this->xml_parser = xml_parser_create();

      // set up some options and handlers
      xml_set_object($this->xml_parser,$this);
      xml_parser_set_option($this->xml_parser,XML_OPTION_CASE_FOLDING,0);
      xml_set_element_handler($this->xml_parser, “startElement”, “endElement”);
      xml_set_character_data_handler($this->xml_parser, “characterData”);

      if (!xml_parse($this->xml_parser, $data, TRUE)) {
        sprintf(“XML error: %s at line %d”,
        xml_error_string(xml_get_error_code($this->xml_parser)),
        xml_get_current_line_number($this->xml_parser));
      }

      // we are done with the parser, so let”s free it
      xml_parser_free($this->xml_parser);

   }//end constructor: function xml()
}//thus, we end our class xml

?>

使用方法:

<?php
require(“class.xml.php”);
$file = “data.xml”;
$data = implode(“”,file($file)) or die(“could not open XML input file”);
$obj = new xml($data,”xml”);
print $xml["hans"][0]->num_results[0];
for($i=0;$i<sizeof($xml["hans"]);$i++) {
        print $xml["hans"][$i]->tag[0] . ” “;
}

//To print url attributes (if they exist):

print $xml["hans"][0]->attributes[0]["size"];

?>

PHP邮件发送类(附使用方法)

email.class.php  代码:

<?
/**
* 来源:互联网
* 整理:www.phppx.com
*/
class smtp
{
        /* Public Variables */
        var $smtp_port;
        var $time_out;
        var $host_name;
        var $log_file;
        var $relay_host;
        var $debug;
        var $auth;
        var $user;
        var $pass;

        /* Private Variables */
        var $sock;

        /* Constractor */
        function smtp($relay_host = “”, $smtp_port = 25,$auth = false,$user,$pass)
        {
                $this->debug = FALSE;
                $this->smtp_port = $smtp_port;
                $this->relay_host = $relay_host;
                $this->time_out = 30; //is used in fsockopen()
                #
                $this->auth = $auth;//auth
                $this->user = $user;
                $this->pass = $pass;
                #
                $this->host_name = “localhost”; //is used in HELO command
                $this->log_file =”";

                $this->sock = FALSE;
        }

        /* Main Function */
        function sendmail($to, $from, $subject = “”, $body = “”, $mailtype, $cc = “”, $bcc = “”, $additional_headers = “”)
        {
                $mail_from = $this->get_address($this->strip_comment($from));
                $body = ereg_replace(“(^|(\r\n))(\\.)”, “\\1.\\3“, $body);
                $header .= “MIME-Version:1.0\r\n”;
                if($mailtype==”HTML”){
                        $header .= “Content-Type:text/html\r\n”;
                }
                $header .= “To: “.$to.”\r\n”;
                if ($cc != “”) {
                        $header .= “Cc: “.$cc.”\r\n”;
                }
                $header .= “From: $from<”.$from.”>\r\n”;
                $header .= “Subject: “.$subject.”\r\n”;
                $header .= $additional_headers;
                $header .= “Date: “.date(“r”).”\r\n”;
                $header .= “X-Mailer:By Redhat (PHP/”.phpversion().”)\r\n”;
                list($msec, $sec) = explode(” “, microtime());
                $header .= “Message-ID: <”.date(“YmdHis”, $sec).”.”.($msec*1000000).”.”.$mail_from.”>\r\n”;
                $TO = explode(“,”, $this->strip_comment($to));

                if ($cc != “”) {
                        $TO = array_merge($TO, explode(“,”, $this->strip_comment($cc)));
                }

                if ($bcc != “”) {
                        $TO = array_merge($TO, explode(“,”, $this->strip_comment($bcc)));
                }

                $sent = TRUE;
                foreach ($TO as $rcpt_to) {
                        $rcpt_to = $this->get_address($rcpt_to);
                        if (!$this->smtp_sockopen($rcpt_to)) {
                                $this->log_write(“Error: Cannot send email to “.$rcpt_to.”\n”);
                                $sent = FALSE;
                                continue;
                        }
                        if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
                                $this->log_write(“E-mail has been sent to <”.$rcpt_to.”>\n”);
                        } else {
                                $this->log_write(“Error: Cannot send email to <”.$rcpt_to.”>\n”);
                                $sent = FALSE;
                        }
                        fclose($this->sock);
                        $this->log_write(“Disconnected from remote host\n”);
                }
                echo “<br>”;
                echo $header;
                return $sent;
        }

        /* Private Functions */

        function smtp_send($helo, $from, $to, $header, $body = “”)
        {
                if (!$this->smtp_putcmd(“HELO”, $helo)) {
                        return $this->smtp_error(“sending HELO command”);
                }
                #auth
                if($this->auth){
                        if (!$this->smtp_putcmd(“AUTH LOGIN”, base64_encode($this->user))) {
                                return $this->smtp_error(“sending HELO command”);
                        }

                        if (!$this->smtp_putcmd(“”, base64_encode($this->pass))) {
                                return $this->smtp_error(“sending HELO command”);
                        }
                }
                #
                if (!$this->smtp_putcmd(“MAIL”, “FROM:<”.$from.”>”)) {
                        return $this->smtp_error(“sending MAIL FROM command”);
                }

                if (!$this->smtp_putcmd(“RCPT”, “TO:<”.$to.”>”)) {
                        return $this->smtp_error(“sending RCPT TO command”);
                }

                if (!$this->smtp_putcmd(“DATA”)) {
                        return $this->smtp_error(“sending DATA command”);
                }

                if (!$this->smtp_message($header, $body)) {
                        return $this->smtp_error(“sending message”);
                }

                if (!$this->smtp_eom()) {
                        return $this->smtp_error(“sending <CR><LF>.<CR><LF> [EOM]“);
                }

                if (!$this->smtp_putcmd(“QUIT”)) {
                        return $this->smtp_error(“sending QUIT command”);
                }

                return TRUE;
        }

        function smtp_sockopen($address)
        {
                if ($this->relay_host == “”) {
                        return $this->smtp_sockopen_mx($address);
                } else {
                        return $this->smtp_sockopen_relay();
                }
        }

        function smtp_sockopen_relay()
        {
                $this->log_write(“Trying to “.$this->relay_host.”:”.$this->smtp_port.”\n”);
                $this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out);
                if (!($this->sock && $this->smtp_ok())) {
                        $this->log_write(“Error: Cannot connenct to relay host “.$this->relay_host.”\n”);
                        $this->log_write(“Error: “.$errstr.” (“.$errno.”)\n”);
                        return FALSE;
                }
                $this->log_write(“Connected to relay host “.$this->relay_host.”\n”);
                return TRUE;;
        }

        function smtp_sockopen_mx($address)
        {
                $domain = ereg_replace(“^.+@([^@]+)$“, “\\1“, $address);
                if (!@getmxrr($domain, $MXHOSTS)) {
                        $this->log_write(“Error: Cannot resolve MX \”".$domain.”\”\n”);
                        return FALSE;
                }
                foreach ($MXHOSTS as $host) {
                        $this->log_write(“Trying to “.$host.”:”.$this->smtp_port.”\n”);
                        $this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);
                        if (!($this->sock && $this->smtp_ok())) {
                                $this->log_write(“Warning: Cannot connect to mx host “.$host.”\n”);
                                $this->log_write(“Error: “.$errstr.” (“.$errno.”)\n”);
                                continue;
                        }
                        $this->log_write(“Connected to mx host “.$host.”\n”);
                        return TRUE;
                }
                $this->log_write(“Error: Cannot connect to any mx hosts (“.implode(“, “, $MXHOSTS).”)\n”);
                return FALSE;
        }

        function smtp_message($header, $body)
        {
                fputs($this->sock, $header.”\r\n”.$body);
                $this->smtp_debug(“> “.str_replace(“\r\n”, “\n”.”> “, $header.”\n> “.$body.”\n> “));

                return TRUE;
        }

        function smtp_eom()
        {
                fputs($this->sock, “\r\n.\r\n”);
                $this->smtp_debug(“. [EOM]\n”);

                return $this->smtp_ok();
        }

        function smtp_ok()
        {
                $response = str_replace(“\r\n”, “”, fgets($this->sock, 512));
                $this->smtp_debug($response.”\n”);

                if (!ereg(“^[23]“, $response)) {
                        fputs($this->sock, “QUIT\r\n”);
                        fgets($this->sock, 512);
                        $this->log_write(“Error: Remote host returned \”".$response.”\”\n”);
                        return FALSE;
                }
                return TRUE;
        }

        function smtp_putcmd($cmd, $arg = “”)
        {
                if ($arg != “”) {
                        if($cmd==”") $cmd = $arg;
                        else $cmd = $cmd.” “.$arg;
                }

                fputs($this->sock, $cmd.”\r\n”);
                $this->smtp_debug(“> “.$cmd.”\n”);

                return $this->smtp_ok();
        }

        function smtp_error($string)
        {
                $this->log_write(“Error: Error occurred while “.$string.”.\n”);
                return FALSE;
        }

        function log_write($message)
        {
                $this->smtp_debug($message);

                if ($this->log_file == “”) {
                        return TRUE;
                }

                $message = date(“M d H:i:s “).get_current_user().”[".getmypid()."]: “.$message;
                if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, “a”))) {
                        $this->smtp_debug(“Warning: Cannot open log file \”".$this->log_file.”\”\n”);
                        return FALSE;
                }
                flock($fp, LOCK_EX);
                fputs($fp, $message);
                fclose($fp);

                return TRUE;
        }

        function strip_comment($address)
        {
                $comment = “\\([^()]*\\)”;
                while (ereg($comment, $address)) {
                        $address = ereg_replace($comment, “”, $address);
                }

                return $address;
        }

        function get_address($address)
        {
                $address = ereg_replace(“([ \t\r\n])+”, “”, $address);
                $address = ereg_replace(“^.*<(.+)>.*$”, “\\1“, $address);

                return $address;
        }

        function smtp_debug($message)
        {
                if ($this->debug) {
                        echo $message.”<br>”;
                }
        }

        function get_attach_type($image_tag) { //

                $filedata = array();

                $img_file_con=fopen($image_tag,”r”);
                unset($image_data);
                while ($tem_buffer=AddSlashes(fread($img_file_con,filesize($image_tag))))
                $image_data.=$tem_buffer;
                fclose($img_file_con);

                $filedata['context'] = $image_data;
                $filedata['filename']= basename($image_tag);
                $extension=substr($image_tag,strrpos($image_tag,”.”),strlen($image_tag)-strrpos($image_tag,”.”));
                switch($extension){
                        case “.gif”:
                                $filedata['type'] = “image/gif”;
                                break;
                        case “.gz”:
                                $filedata['type'] = “application/x-gzip”;
                                break;
                        case “.htm”:
                                $filedata['type'] = “text/html”;
                                break;
                        case “.html”:
                                $filedata['type'] = “text/html”;
                                break;
                        case “.jpg”:
                                $filedata['type'] = “image/jpeg”;
                                break;
                        case “.tar”:
                                $filedata['type'] = “application/x-tar”;
                                break;
                        case “.txt”:
                                $filedata['type'] = “text/plain”;
                                break;
                        case “.zip”:
                                $filedata['type'] = “application/zip”;
                                break;
                        default:
                                $filedata['type'] = “application/octet-stream”;
                                break;
                }
                return $filedata;
        }

}
?>

继续阅读 »

图像处理类(图像信息,缩略图,加水印),有详细的注释

<?php
/**
* 来源:互联网
* 整理:www.phppx.com
*/
class image
{
 var $w_pct = 50; //透明度
 var $w_quality = 80; //质量
 var $w_minwidth = 300; //最小宽
 var $w_minheight = 300; //最小高
 var $thumb_enable; //是否生成缩略图
 var $watermark_enable; //是否生水印
 var $interlace = 0;  //图像是否为隔行扫描的
 var $fontfile;  //字体文件
 var $w_img ; //默认水印图

    function __construct()
    {
  global $SITE_CONFING;
  $this->thumb_enable = $SITE_CONFING['thumb_enable'];
  $this->watermark_enable = $SITE_CONFING['watermark_enable'];
  $this->set($SITE_CONFING['watermark_minwidth'], $SITE_CONFING['watermark_minheight'], $SITE_CONFING['watermark_quality'], $SITE_CONFING['watermark_pct'], $SITE_CONFING['watermark_fontfile'],$SITE_CONFING['watermark_img']);
    }

 function image()
 {
  $this->__construct();
 }

 function set($w_minwidth = 300, $w_minheight = 300, $w_quality = 80, $w_pct = 100,$fontfile,$w_img)
 {
  $this->w_minwidth = $w_minwidth;
  $this->w_minheight = $w_minheight;
  $this->w_quality = $w_quality;
  $this->w_pct = $w_pct;
  $this->fontfile = $fontfile;
  $this->w_img = $w_img;
 }

    function info($img)
 {
        $imageinfo = getimagesize($img); //返回图像信息数组 0=>宽的像素 1=>高的像素 2=>是图像类型的标记 3 =>是文本字符串,内容为“height=”yyy” width=”xxx””,
        if($imageinfo === false) return false;
  $imagetype = strtolower(substr(image_type_to_extension($imageinfo[2]),1)); //获取图像文件类型 $imageinfo[2]是图像类型的标记
  $imagesize = filesize($img); //图像大小
  $info = array(
    ’width’=>$imageinfo[0],
    ’height’=>$imageinfo[1],
    ’type’=>$imagetype,
    ’size’=>$imagesize,
    ’mime’=>$imageinfo['mime']
    );
  return $info;
    }

    function thumb($image, $filename = ”, $maxwidth = 200, $maxheight = 50, $suffix=’_thumb’, $autocut = 0)
    {
     if(!$this->thumb_enable || !$this->check($image)) return false;
        $info  = $this->info($image); //获取图片信息
        if($info === false) return false;
  $srcwidth  = $info['width']; //源图宽
  $srcheight = $info['height']; //源图高
  $pathinfo = pathinfo($image);
  $type =  $pathinfo['extension']; //取得扩展名
  if(!$type) $type = $info['type']; //如果没有取到,用$info['type']
  $type = strtolower($type);
  unset($info);
  $scale = min($maxwidth/$srcwidth, $maxheight/$srcheight); //获取缩略比例
  //获取按照源图的比列
  $createwidth = $width  = (int)($srcwidth*$scale); //取得缩略宽
  $createheight = $height = (int)($srcheight*$scale); //取得缩略高
  $psrc_x = $psrc_y = 0;
  if($autocut) //按照缩略图的比例来获取
  {
   if($maxwidth/$maxheight<$srcwidth/$srcheight && $maxheight>=$height) //如果缩略图按比列比源图窄的话
   {
    $width = $maxheight/$height*$width; //宽按照相应比例做处理
    $height = $maxheight; //高不变
   }
   elseif($maxwidth/$maxheight>$srcwidth/$srcheight && $maxwidth>=$width)//如果缩略图按比列比源图宽的话
   {
    $height = $maxwidth/$width*$height;
    $width = $maxwidth;
   }
   $createwidth = $maxwidth;
   $createheight = $maxheight;
  }
  $createfun = ‘imagecreatefrom’.($type==’jpg’ ? ‘jpeg’ : $type); //找到不同的图像处理函数
  $srcimg = $createfun($image); //新建图像
  if($type != ‘gif’ && function_exists(‘imagecreatetruecolor’))
   $thumbimg = imagecreatetruecolor($createwidth, $createheight); //新建一个真彩色图像
  else
   $thumbimg = imagecreate($width, $height); //新建一个基于调色板的图像

  if(function_exists(‘imagecopyresampled’)) //重采样拷贝部分图像并调整大小,真彩
   //imagecopyresampled(新图,源图,新图左上角x距离,新图左上角y距离,源图左上角x距离,源图左上角y距离,新图宽,新图高,源图宽,源图高)
   imagecopyresampled($thumbimg, $srcimg, 0, 0, $psrc_x, $psrc_y, $width, $height, $srcwidth, $srcheight);
  else //拷贝部分图像并调整大小,调色板
   imagecopyresized($thumbimg, $srcimg, 0, 0, $psrc_x, $psrc_y, $width, $height,  $srcwidth, $srcheight);
  if($type==’gif’ || $type==’png’)
  {
   //imagecolorallocate 为一幅图像分配颜色
   $background_color  =  imagecolorallocate($thumbimg,  0, 255, 0);  // 给基于调色板的图像填充背景色, 指派一个绿色
   // imagecolortransparent 将某个颜色定义为透明色
   imagecolortransparent($thumbimg, $background_color);  //  设置为透明色,若注释掉该行则输出绿色的图
  }
  // imageinterlace 激活或禁止隔行扫描
  if($type==’jpg’ || $type==’jpeg’) imageinterlace($thumbimg, $this->interlace);
  $imagefun = ‘image’.($type==’jpg’ ? ‘jpeg’ : $type);
  //imagejpeg imagegif imagepng
  if(empty($filename)) $filename  = substr($image, 0, strrpos($image, ‘.’)).$suffix.’.’.$type; //获取文件名
  //aaa.gif aaa_thumb.gif
  $imagefun($thumbimg, $filename); //新建图像
  imagedestroy($thumbimg); //销毁缩略图
  imagedestroy($srcimg); //销毁源图
  return $filename;
    }
 //watermark(源图,生成文件,生成位置,水印文件,水印文本,背景色)
 function watermark($source, $target = ”, $w_pos = 9, $w_img = ”, $w_text = ”, $w_font = 12, $w_color = ‘#cccccc’)
 {
  if(!$this->watermark_enable || !$this->check($source)) return false;
  if(!$target) $target = $source;
  if ($w_img == ” && $w_text == ”)
  $w_img = $this->w_img;
  $source_info = getimagesize($source);
  $source_w    = $source_info[0]; //获取宽
  $source_h    = $source_info[1]; //获取高
  if($source_w < $this->w_minwidth || $source_h < $this->w_minheight) return false; //宽和高达不到要求直接返回
  switch($source_info[2]) //新建图片
  {
   case 1 :
    $source_img = imagecreatefromgif($source);
    break;
   case 2 :
    $source_img = imagecreatefromjpeg($source);
    break;
   case 3 :
    $source_img = imagecreatefrompng($source);
    break;
   default :
    return false;
  }
  if(!empty($w_img) && file_exists($w_img)) //水印文件
  {
   $ifwaterimage = 1; //是否水印图
   $water_info   = getimagesize($w_img); //水印信息
   $width        = $water_info[0];
   $height       = $water_info[1];
   switch($water_info[2])
   {
    case 1 :
     $water_img = imagecreatefromgif($w_img);
     break;
    case 2 :
     $water_img = imagecreatefromjpeg($w_img);
     break;
    case 3 :
     $water_img = imagecreatefrompng($w_img);
     break;
    default :
     return;
   }
  }
  else
  {
   $ifwaterimage = 0;
   //imagettfbbox 本函数计算并返回一个包围着 TrueType 文本范围的虚拟方框的像素大小。
   //imagettfbbox ( 字体大小, 字体角度, 字体文件,文件 )
   $temp = imagettfbbox(ceil($w_font*1.2), 0, $this->fontfile, $w_text);//取得使用 truetype 字体的文本的范围
   $width = $temp[4] – $temp[6]; //右上角 X 位置 – 左上角 X 位置
   $height = $temp[3] – $temp[5]; //右下角 Y 位置- 右上角 Y 位置
   unset($temp);
  }
  switch($w_pos)
  {
   case 0: //随机位置
    $wx = rand(0,($source_w – $width));
    $wy = rand(0,($source_h – $height));
    break;
   case 1: //左上角
    $wx = 5;
    $wy = 5;
    break;
   case 2: //上面中间位置
    $wx = ($source_w – $width) / 2;
    $wy = 0;
    break;
   case 3: //右上角
    $wx = $source_w – $width;
    $wy = 0;
    break;
   case 4: //左面中间位置
    $wx = 0;
    $wy = ($source_h – $height) / 2;
    break;
   case 5: //中间位置
    $wx = ($source_w – $width) / 2;
    $wy = ($source_h – $height) / 2;
    break;
   case 6: //底部中间位置
    $wx = ($source_w – $width) / 2;
    $wy = $source_h – $height;
    break;
   case 7: //左下角
    $wx = 0;
    $wy = $source_h – $height;
    break;
   case 8: //右面中间位置
    $wx = $source_w – $width;
    $wy = ($source_h – $height) /2;
    break;
   case 9: //右下角
    $wx = $source_w – $width;
    $wy = $source_h – $height ;
    break;
   default: //随机
    $wx = rand(0,($source_w – $width));
    $wy = rand(0,($source_h – $height));
    break;
  }
  if($ifwaterimage) //如果有水印图
  {
   //imagecopymerge 拷贝并合并图像的一部分
   //参数(源图,水印图,拷贝到源图x位置,拷贝到源图y位置,从水印图x位置,从水印图y位置,高,宽,透明度)
   imagecopymerge($source_img, $water_img, $wx, $wy, 0, 0, $width, $height, $this->w_pct);
  }
  else
  {
   if(!empty($w_color) && (strlen($w_color)==7))
   {
    $r = hexdec(substr($w_color,1,2)); //获取红色
    $g = hexdec(substr($w_color,3,2)); //获取绿色
    $b = hexdec(substr($w_color,5)); //获取蓝色
   }
   else
   {
    return;
   }
   //imagecolorallocate 基于调色板的图像填充背景色
   //imagestring 水平地画一行字符串
   //imagestring(源图,字体大小,位置X,位置Y,文字,颜色)
   //参数($image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text)
   imagettftext($source_img,$w_font,0,$wx,$wy,imagecolorallocate($source_img,$r,$g,$b),$this->fontfile,$w_text);
   //imagestring($source_img,$w_font,$wx,$wy,$w_text,imagecolorallocate($source_img,$r,$g,$b));
  }
  //输出到文件或者浏览器
  switch($source_info[2])
  {
   case 1 :
    imagegif($source_img, $target); //以 GIF 格式将图像输出到浏览器或文件
    break;
   case 2 :
    imagejpeg($source_img, $target, $this->w_quality); //以 JPEG 格式将图像输出到浏览器或文件
    break;
   case 3 :
    imagepng($source_img, $target); //以 PNG 格式将图像输出到浏览器或文件
    break;
   default :
    return;
  }
  if(isset($water_info))
  {
   unset($water_info); //销毁
  }
  if(isset($water_img))
  {
   imagedestroy($water_img); //销毁
  }
  unset($source_info);
  imagedestroy($source_img);
  return true;
 }
 //gd库必须存在,后缀为jpg|jpeg|gif|png,文件存在,imagecreatefromjpeg或者imagecreatefromgif存在
 function check($image)
 {
  return extension_loaded(‘gd’) &&
  preg_match(“/\.(jpg|jpeg|gif|png)/i”, $image, $m) &&
  file_exists($image) &&
  function_exists(‘imagecreatefrom’.($m[1] == ‘jpg’ ? ‘jpeg’ : $m[1]));
  //imagecreatefromjpeg
  //imagecreatefromgif
  //imagecreatefrompng
 }
}?>

php文件下载程序

<?php

$fileurl = ‘E:/demo/phper.rar’;

if(strpos($fileurl, ‘http://’) !== false || strpos($fileurl, ‘ftp://’) !== false) {
 header(“Location: $fileurl”);
}else {
 $filename = basename($fileurl); //取文件名
 $pathinfo = pathinfo($filename);
 $filetype =  $pathinfo['extension']; //取得扩展名
 $filesize = filesize($fileurl);
 if(ob_get_length() !== false) @ob_end_clean(); //清除以前的缓冲
 header(‘Pragma: public’);
 header(‘Last-Modified: ‘.gmdate(‘D, d M Y H:i:s’) . ‘ GMT’);
 header(‘Cache-Control: no-store, no-cache, must-revalidate’);
 header(‘Cache-Control: pre-check=0, post-check=0, max-age=0′);
 header(‘Content-Transfer-Encoding: binary’);
 header(‘Content-Encoding: none’);
 header(‘Content-type: ‘.$filetype);
 header(‘Content-Disposition: attachment; filename=”‘.$filename.’”‘);
 header(‘Content-length: ‘.$filesize);
 //readfile($fileurl);
 $fp = @fopen($fileurl,”rb”);
 while(!feof($fp)) {
  $buffer= fread($fp,8192);
  echo $buffer;
 }
 @flush();
 @ob_flush();
}

?>

PHP中文转换拼音函数

<?php
/**
* 来源:互联网
* 整理:www.phppx.com
*/
$d=array(
array(“a”,-20319),
array(“ai”,-20317),
array(“an”,-20304),
array(“ang”,-20295),
array(“ao”,-20292),
array(“ba”,-20283),
array(“bai”,-20265),
array(“ban”,-20257),
array(“bang”,-20242),
array(“bao”,-20230),
array(“bei”,-20051),
array(“ben”,-20036),
array(“beng”,-20032),
array(“bi”,-20026),
array(“bian”,-20002),
array(“biao”,-19990),
array(“bie”,-19986),
array(“bin”,-19982),
array(“bing”,-19976),
array(“bo”,-19805),
array(“bu”,-19784),
array(“ca”,-19775),
array(“cai”,-19774),
array(“can”,-19763),
array(“cang”,-19756),
array(“cao”,-19751),
array(“ce”,-19746),
array(“ceng”,-19741),
array(“cha”,-19739),
array(“chai”,-19728),
array(“chan”,-19725),
array(“chang”,-19715),
array(“chao”,-19540),
array(“che”,-19531),
array(“chen”,-19525),
array(“cheng”,-19515),
array(“chi”,-19500),
array(“chong”,-19484),
array(“chou”,-19479),
array(“chu”,-19467),
array(“chuai”,-19289),
array(“chuan”,-19288),
array(“chuang”,-19281),
array(“chui”,-19275),
array(“chun”,-19270),
array(“chuo”,-19263),
array(“ci”,-19261),
array(“cong”,-19249),
array(“cou”,-19243),
array(“cu”,-19242),
array(“cuan”,-19238),
array(“cui”,-19235),
array(“cun”,-19227),
array(“cuo”,-19224),
array(“da”,-19218),
array(“dai”,-19212),
array(“dan”,-19038),
array(“dang”,-19023),
array(“dao”,-19018),
array(“de”,-19006),
array(“deng”,-19003),
array(“di”,-18996),
array(“dian”,-18977),
array(“diao”,-18961),
array(“die”,-18952),
array(“ding”,-18783),
array(“diu”,-18774),
array(“dong”,-18773),
array(“dou”,-18763),
array(“du”,-18756),
array(“duan”,-18741),
array(“dui”,-18735),
array(“dun”,-18731),
array(“duo”,-18722),
array(“e”,-18710),
array(“en”,-18697),
array(“er”,-18696),
array(“fa”,-18526),
array(“fan”,-18518),
array(“fang”,-18501),
array(“fei”,-18490),
array(“fen”,-18478),
array(“feng”,-18463),
array(“fo”,-18448),
array(“fou”,-18447),
array(“fu”,-18446),
array(“ga”,-18239),
array(“gai”,-18237),
array(“gan”,-18231),
array(“gang”,-18220),
array(“gao”,-18211),
array(“ge”,-18201),
array(“gei”,-18184),
array(“gen”,-18183),
array(“geng”,-18181),
array(“gong”,-18012),
array(“gou”,-17997),
array(“gu”,-17988),
array(“gua”,-17970),
array(“guai”,-17964),
array(“guan”,-17961),
array(“guang”,-17950),
array(“gui”,-17947),
array(“gun”,-17931),
array(“guo”,-17928),
array(“ha”,-17922),
array(“hai”,-17759),
array(“han”,-17752),
array(“hang”,-17733),
array(“hao”,-17730),
array(“he”,-17721),
array(“hei”,-17703),
array(“hen”,-17701),
array(“heng”,-17697),
array(“hong”,-17692),
array(“hou”,-17683),
array(“hu”,-17676),
array(“hua”,-17496),
array(“huai”,-17487),
array(“huan”,-17482),
array(“huang”,-17468),
array(“hui”,-17454),
array(“hun”,-17433),
array(“huo”,-17427),
array(“ji”,-17417),
array(“jia”,-17202),
array(“jian”,-17185),
array(“jiang”,-16983),
array(“jiao”,-16970),
array(“jie”,-16942),
array(“jin”,-16915),
array(“jing”,-16733),
array(“jiong”,-16708),
array(“jiu”,-16706),
array(“ju”,-16689),
array(“juan”,-16664),
array(“jue”,-16657),
array(“jun”,-16647),
array(“ka”,-16474),
array(“kai”,-16470),
array(“kan”,-16465),
array(“kang”,-16459),
array(“kao”,-16452),
array(“ke”,-16448),
array(“ken”,-16433),
array(“keng”,-16429),
array(“kong”,-16427),
array(“kou”,-16423),
array(“ku”,-16419),
array(“kua”,-16412),
array(“kuai”,-16407),
array(“kuan”,-16403),
array(“kuang”,-16401),
array(“kui”,-16393),
array(“kun”,-16220),
array(“kuo”,-16216),
array(“la”,-16212),
array(“lai”,-16205),
array(“lan”,-16202),
array(“lang”,-16187),
array(“lao”,-16180),
array(“le”,-16171),
array(“lei”,-16169),
array(“leng”,-16158),
array(“li”,-16155),
array(“lia”,-15959),
array(“lian”,-15958),
array(“liang”,-15944),
array(“liao”,-15933),
array(“lie”,-15920),
array(“lin”,-15915),
array(“ling”,-15903),
array(“liu”,-15889),
array(“long”,-15878),
array(“lou”,-15707),
array(“lu”,-15701),
array(“lv”,-15681),
array(“luan”,-15667),
array(“lue”,-15661),
array(“lun”,-15659),
array(“luo”,-15652),
array(“ma”,-15640),
array(“mai”,-15631),
array(“man”,-15625),
array(“mang”,-15454),
array(“mao”,-15448),
array(“me”,-15436),
array(“mei”,-15435),
array(“men”,-15419),
array(“meng”,-15416),
array(“mi”,-15408),
array(“mian”,-15394),
array(“miao”,-15385),
array(“mie”,-15377),
array(“min”,-15375),
array(“ming”,-15369),
array(“miu”,-15363),
array(“mo”,-15362),
array(“mou”,-15183),
array(“mu”,-15180),
array(“na”,-15165),
array(“nai”,-15158),
array(“nan”,-15153),
array(“nang”,-15150),
array(“nao”,-15149),
array(“ne”,-15144),
array(“nei”,-15143),
array(“nen”,-15141),
array(“neng”,-15140),
array(“ni”,-15139),
array(“nian”,-15128),
array(“niang”,-15121),
array(“niao”,-15119),
array(“nie”,-15117),
array(“nin”,-15110),
array(“ning”,-15109),
array(“niu”,-14941),
array(“nong”,-14937),
array(“nu”,-14933),
array(“nv”,-14930),
array(“nuan”,-14929),
array(“nue”,-14928),
array(“nuo”,-14926),
array(“o”,-14922),
array(“ou”,-14921),
array(“pa”,-14914),
array(“pai”,-14908),
array(“pan”,-14902),
array(“pang”,-14894),
array(“pao”,-14889),
array(“pei”,-14882),
array(“pen”,-14873),
array(“peng”,-14871),
array(“pi”,-14857),
array(“pian”,-14678),
array(“piao”,-14674),
array(“pie”,-14670),
array(“pin”,-14668),
array(“ping”,-14663),
array(“po”,-14654),
array(“pu”,-14645),
array(“qi”,-14630),
array(“qia”,-14594),
array(“qian”,-14429),
array(“qiang”,-14407),
array(“qiao”,-14399),
array(“qie”,-14384),
array(“qin”,-14379),
array(“qing”,-14368),
array(“qiong”,-14355),
array(“qiu”,-14353),
array(“qu”,-14345),
array(“quan”,-14170),
array(“que”,-14159),
array(“qun”,-14151),
array(“ran”,-14149),
array(“rang”,-14145),
array(“rao”,-14140),
array(“re”,-14137),
array(“ren”,-14135),
array(“reng”,-14125),
array(“ri”,-14123),
array(“rong”,-14122),
array(“rou”,-14112),
array(“ru”,-14109),
array(“ruan”,-14099),
array(“rui”,-14097),
array(“run”,-14094),
array(“ruo”,-14092),
array(“sa”,-14090),
array(“sai”,-14087),
array(“san”,-14083),
array(“sang”,-13917),
array(“sao”,-13914),
array(“se”,-13910),
array(“sen”,-13907),
array(“seng”,-13906),
array(“sha”,-13905),
array(“shai”,-13896),
array(“shan”,-13894),
array(“shang”,-13878),
array(“shao”,-13870),
array(“she”,-13859),
array(“shen”,-13847),
array(“sheng”,-13831),
array(“shi”,-13658),
array(“shou”,-13611),
array(“shu”,-13601),
array(“shua”,-13406),
array(“shuai”,-13404),
array(“shuan”,-13400),
array(“shuang”,-13398),
array(“shui”,-13395),
array(“shun”,-13391),
array(“shuo”,-13387),
array(“si”,-13383),
array(“song”,-13367),
array(“sou”,-13359),
array(“su”,-13356),
array(“suan”,-13343),
array(“sui”,-13340),
array(“sun”,-13329),
array(“suo”,-13326),
array(“ta”,-13318),
array(“tai”,-13147),
array(“tan”,-13138),
array(“tang”,-13120),
array(“tao”,-13107),
array(“te”,-13096),
array(“teng”,-13095),
array(“ti”,-13091),
array(“tian”,-13076),
array(“tiao”,-13068),
array(“tie”,-13063),
array(“ting”,-13060),
array(“tong”,-12888),
array(“tou”,-12875),
array(“tu”,-12871),
array(“tuan”,-12860),
array(“tui”,-12858),
array(“tun”,-12852),
array(“tuo”,-12849),
array(“wa”,-12838),
array(“wai”,-12831),
array(“wan”,-12829),
array(“wang”,-12812),
array(“wei”,-12802),
array(“wen”,-12607),
array(“weng”,-12597),
array(“wo”,-12594),
array(“wu”,-12585),
array(“xi”,-12556),
array(“xia”,-12359),
array(“xian”,-12346),
array(“xiang”,-12320),
array(“xiao”,-12300),
array(“xie”,-12120),
array(“xin”,-12099),
array(“xing”,-12089),
array(“xiong”,-12074),
array(“xiu”,-12067),
array(“xu”,-12058),
array(“xuan”,-12039),
array(“xue”,-11867),
array(“xun”,-11861),
array(“ya”,-11847),
array(“yan”,-11831),
array(“yang”,-11798),
array(“yao”,-11781),
array(“ye”,-11604),
array(“yi”,-11589),
array(“yin”,-11536),
array(“ying”,-11358),
array(“yo”,-11340),
array(“yong”,-11339),
array(“you”,-11324),
array(“yu”,-11303),
array(“yuan”,-11097),
array(“yue”,-11077),
array(“yun”,-11067),
array(“za”,-11055),
array(“zai”,-11052),
array(“zan”,-11045),
array(“zang”,-11041),
array(“zao”,-11038),
array(“ze”,-11024),
array(“zei”,-11020),
array(“zen”,-11019),
array(“zeng”,-11018),
array(“zha”,-11014),
array(“zhai”,-10838),
array(“zhan”,-10832),
array(“zhang”,-10815),
array(“zhao”,-10800),
array(“zhe”,-10790),
array(“zhen”,-10780),
array(“zheng”,-10764),
array(“zhi”,-10587),
array(“zhong”,-10544),
array(“zhou”,-10533),
array(“zhu”,-10519),
array(“zhua”,-10331),
array(“zhuai”,-10329),
array(“zhuan”,-10328),
array(“zhuang”,-10322),
array(“zhui”,-10315),
array(“zhun”,-10309),
array(“zhuo”,-10307),
array(“zi”,-10296),
array(“zong”,-10281),
array(“zou”,-10274),
array(“zu”,-10270),
array(“zuan”,-10262),
array(“zui”,-10260),
array(“zun”,-10256),
array(“zuo”,-10254)
);
function g($num){
        global $d;
        if($num>0&&$num<160){
                return chr($num);
        }
        elseif($num<-20319||$num>-10247){
                return “”;
        }else{
                for($i=count($d)-1;$i>=0;$i–)
                {if($d[$i][1]<=$num)break;}
                return $d[$i][0];
        }
}

function c($str){
        $ret=”";
        for($i=0;$i<strlen($str);$i++){
                $p=ord(substr($str,$i,1));
                if($p>160){
                        $q=ord(substr($str,++$i,1));
                        $p=$p*256+$q-65536;
                }
                $ret.=g($p);
        }
        return $ret;
}

//这里接收表单参数
if (isset($_POST['ok']) and $_POST['chinese'] != ”) {
        $str = $_POST['chinese'];
} else {
        $str = “新程php培训”;
}
echo $str;
?>
<form action=”" method=”POST”>
请输入要转换的中文:
<input type=”text” name=”chinese”>
<input type=”submit” name=”ok” value=”中文转拼音” >
</form>

返回顶部