<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>奔向远方 &#187; php</title>
	<atom:link href="http://www.tisswb.cn/archives/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tisswb.cn</link>
	<description>结婚开始倒计时了，高兴~</description>
	<lastBuildDate>Sat, 31 Jul 2010 16:42:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>php编译参数的含义</title>
		<link>http://www.tisswb.cn/archives/576.html</link>
		<comments>http://www.tisswb.cn/archives/576.html#comments</comments>
		<pubDate>Sat, 31 Jul 2010 16:42:44 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[Web服务器]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=576</guid>
		<description><![CDATA[今天整理编译php的时候的参数，在网上搜集了一些关于configure参数的资料：
./configure
&#8211;prefix=/usr/local/php                                   php 安装目录
&#8211;with-apxs2=/usr/local/apache/bin/apxs
&#8211;with-config-file-path=/usr/local/php/etc               指定php.ini位置
&#8211;with-mysql=/usr/local/mysql                        mysql安装目录，对mysql的支持
&#8211;with-mysqli=/usr/local/mysql/bin/mysql_config            mysqli文件目录,优化支持
<span class="readmore"><a href="http://www.tisswb.cn/archives/576.html" title="php编译参数的含义" target="_blank">阅读全文——共2772字</a></span>]]></description>
			<content:encoded><![CDATA[<p>今天整理编译php的时候的参数，在网上搜集了一些关于configure参数的资料：</p>
<p>./configure</p>
<p>&#8211;prefix=/usr/local/php                                   <a target="_self"><strong>php</strong> </a>安装目录<br />
&#8211;with-apxs2=/usr/local/apache/bin/apxs<br />
&#8211;with-config-file-path=/usr/local/php/etc               指定php.ini位置<br />
&#8211;with-mysql=/usr/local/mysql                        mysql安装目录，对mysql的支持<br />
&#8211;with-mysqli=/usr/local/mysql/bin/mysql_config            mysqli文件目录,优化支持<br />
&#8211;enable-safe-mode                              打开安全模式<br />
&#8211;enable-ftp                                 打开ftp的支持<br />
&#8211;enable-zip                                 打开对zip的支持<br />
&#8211;with-bz2                                    打开对bz2文件的支持                        <br />
&#8211;with-jpeg-dir                                 打开对jpeg图片的支持<br />
&#8211;with-png-dir                                 打开对png图片的支持<br />
&#8211;with-freetype-dir                              打开对freetype字体库的支持<br />
&#8211;without-iconv                                 关闭iconv函数，种字符集间的转换<br />
&#8211;with-libxml-dir                                 打开libxml2库的支持<br />
&#8211;with-xmlrpc                                 打开xml-rpc的c语言<br />
&#8211;with-zlib-dir                                 打开zlib库的支持<br />
&#8211;with-gd                                    打开gd库的支持<br />
&#8211;enable-gd-native-ttf                           支持TrueType字符串函数库<br />
&#8211;with-curl                                    打开curl浏览工具的支持<br />
&#8211;with-curlwrappers                              运用curl工具打开url流<br />
&#8211;with-ttf                                    打开freetype1.*的支持，可以不加了<br />
&#8211;with-xsl                                     打开XSLT 文件支持，扩展了libxml2库 ，需要libxslt软件<br />
&#8211;with-gettext                                 打开gnu 的gettext 支持，编码库用到<br />
&#8211;with-pear                      打开pear命令的支持，php扩展用的<br />
&#8211;enable-calendar                  打开日历扩展功能<br />
&#8211;enable-mbstring                  多字节，字符串的支持<br />
&#8211;enable-bcmath                  打开图片大小调整,用到zabbix监控的时候用到了这个模块<br />
&#8211;enable-sockets                  打开 sockets 支持<br />
&#8211;enable-exif                      图片的元数据支持<br />
&#8211;enable-magic-quotes               魔术引用的支持<br />
&#8211;disable-rpath                     关闭额外的运行库文件<br />
&#8211;disable-debug                  关闭调试模式<br />
&#8211;with-mime-magic=/usr/share/file/magic.mime      魔术头文件位置</p>
<p>cgi方式安装才用的<a target="_self"><strong>参数</strong> </a><br />
&#8211;enable-fpm                     打上php-fpm 补丁后才有这个参数，cgi方式安装的启动程序<br />
&#8211;enable-fastcgi                  支持fastcgi方式启动php<br />
&#8211;enable-force-cgi-redirect             同上 ,帮助里没有解释<br />
&#8211;with-ncurses                     支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库<br />
&#8211;enable-pcntl                     freeTDS需要用到的，可能是链接mssql 才用到</p>
<p>mhash和mcrypt算法的扩展<br />
&#8211;with-mcrypt                     算法<br />
&#8211;with-mhash                     算法</p>
<p>&#8211;with-gmp<br />
&#8211;enable-inline-optimization<br />
&#8211;with-openssl                     openssl的支持，加密传输时用到的<br />
&#8211;enable-dbase<br />
&#8211;with-pcre-dir=/usr/local/bin/pcre-config      perl的正则库案安装位置<br />
&#8211;disable-dmalloc<br />
&#8211;with-gdbm                     dba的gdbm支持<br />
&#8211;enable-sigchild<br />
&#8211;enable-sysvsem<br />
&#8211;enable-sysvshm<br />
&#8211;enable-zend-multibyte               支持zend的多字节<br />
&#8211;enable-mbregex<br />
&#8211;enable-wddx<br />
&#8211;enable-shmop<br />
&#8211;enable-soap</p>
<p>来源：<a href="http://nedvedheqing.javaeye.com/blog/545632">http://nedvedheqing.javaeye.com/blog/545632</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/576.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP中$_SERVER的详细参数与说明</title>
		<link>http://www.tisswb.cn/archives/560.html</link>
		<comments>http://www.tisswb.cn/archives/560.html#comments</comments>
		<pubDate>Thu, 27 May 2010 13:54:51 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=560</guid>
		<description><![CDATA[最近经常用到PHP的$_SERVER常量，都是零零碎碎的随用随查，今天整理一下，并且把$_SERVER的详细参数及说明整理一下：
$_SERVER['PHP_SELF'] #当前正在执行脚本的文件名，与 document root相关。
$_SERVER['argv'] #传递给该脚本的参数。
$_SERVER['argc'] #包含传递给程序的命令行参数的个数（如果运行在命令行模式）。
$_SERVER['GATEWAY_INTERFACE'] #服务器使用的 CGI 规范的版本。例如，“CGI/1.1”。
$_SERVER['SERVER_NAME'] #当前运行脚本所在服务器主机的名称。
$_SERVER['SERVER_SOFTWARE'] #服务器标识的字串，在响应请求时的头部中给出。
$_SERVER['SERVER_PROTOCOL'] #请求页面时通信协议的名称和版本。例如，“HTTP/1.0”。
<span class="readmore"><a href="http://www.tisswb.cn/archives/560.html" title="PHP中$_SERVER的详细参数与说明" target="_blank">阅读全文——共1706字</a></span>]]></description>
			<content:encoded><![CDATA[<p>最近经常用到PHP的$_SERVER常量，都是零零碎碎的随用随查，今天整理一下，并且把$_SERVER的详细参数及说明整理一下：</p>
<p><code>$_SERVER['PHP_SELF'] #当前正在执行脚本的文件名，与 document root相关。<br />
$_SERVER['argv'] #传递给该脚本的参数。<br />
$_SERVER['argc'] #包含传递给程序的命令行参数的个数（如果运行在命令行模式）。<br />
$_SERVER['GATEWAY_INTERFACE'] #服务器使用的 CGI 规范的版本。例如，“CGI/1.1”。<br />
$_SERVER['SERVER_NAME'] #当前运行脚本所在服务器主机的名称。<br />
$_SERVER['SERVER_SOFTWARE'] #服务器标识的字串，在响应请求时的头部中给出。<br />
$_SERVER['SERVER_PROTOCOL'] #请求页面时通信协议的名称和版本。例如，“HTTP/1.0”。<br />
$_SERVER['REQUEST_METHOD'] #访问页面时的请求方法。例如：“GET”、“HEAD”，“POST”，“PUT”。<br />
$_SERVER['QUERY_STRING'] #查询(query)的字符串。<br />
$_SERVER['DOCUMENT_ROOT'] #当前运行脚本所在的文档根目录。在服务器配置文件中定义。<br />
$_SERVER['HTTP_ACCEPT'] #当前请求的 Accept: 头部的内容。<br />
$_SERVER['HTTP_ACCEPT_CHARSET'] #当前请求的 Accept-Charset: 头部的内容。例如：“iso-8859-1,*,utf-8”。<br />
$_SERVER['HTTP_ACCEPT_ENCODING'] #当前请求的 Accept-Encoding: 头部的内容。例如：“gzip”。<br />
$_SERVER['HTTP_ACCEPT_LANGUAGE']#当前请求的 Accept-Language: 头部的内容。例如：“en”。<br />
$_SERVER['HTTP_CONNECTION'] #当前请求的 Connection: 头部的内容。例如：“Keep-Alive”。<br />
$_SERVER['HTTP_HOST'] #当前请求的 Host: 头部的内容。<br />
$_SERVER['HTTP_REFERER'] #链接到当前页面的前一页面的 URL 地址。<br />
$_SERVER['HTTP_USER_AGENT'] #当前请求的 User_Agent: 头部的内容。<br />
$_SERVER['HTTPS'] — 如果通过https访问,则被设为一个非空的值(on)，否则返回off<br />
$_SERVER['REMOTE_ADDR'] #正在浏览当前页面用户的 IP 地址。<br />
$_SERVER['REMOTE_HOST'] #正在浏览当前页面用户的主机名。<br />
$_SERVER['REMOTE_PORT'] #用户连接到服务器时所使用的端口。<br />
$_SERVER['SCRIPT_FILENAME'] #当前执行脚本的绝对路径名。<br />
$_SERVER['SERVER_ADMIN'] #管理员信息<br />
$_SERVER['SERVER_PORT'] #服务器所使用的端口<br />
$_SERVER['SERVER_SIGNATURE'] #包含服务器版本和虚拟主机名的字符串。<br />
$_SERVER['PATH_TRANSLATED'] #当前脚本所在文件系统（不是文档根目录）的基本路径。<br />
$_SERVER['SCRIPT_NAME'] #包含当前脚本的路径。这在页面需要指向自己时非常有用。<br />
$_SERVER['REQUEST_URI'] #访问此页面所需的 URI。例如，“/index.html”。<br />
$_SERVER['PHP_AUTH_USER'] #当 PHP 运行在 Apache 模块方式下，并且正在使用 HTTP 认证功能，这个变量便是用户输入的用户名。<br />
$_SERVER['PHP_AUTH_PW'] #当 PHP 运行在 Apache 模块方式下，并且正在使用 HTTP 认证功能，这个变量便是用户输入的密码。<br />
$_SERVER['AUTH_TYPE'] #当 PHP 运行在 Apache 模块方式下，并且正在使用 HTTP 认证功能，这个变量便是认证的类型。</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/560.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>配置LAMP生产环境：安装Apache、PHP、Mysql</title>
		<link>http://www.tisswb.cn/archives/526.html</link>
		<comments>http://www.tisswb.cn/archives/526.html#comments</comments>
		<pubDate>Sat, 28 Nov 2009 16:59:52 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[Web服务器]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[未分类]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=526</guid>
		<description><![CDATA[上一篇主要说了一下快速最小化安装CentOS5.3的过程，这一篇主要讲一讲APM（Apache、PHP、Mysql的缩写）的安装过程。下一篇将集中讲述一下我是优化LAMP（CentOS5.3+Apache2.2.14+PHP5.2.11+Mysql5.0.36）的具体细节。
在CentOS5.3下面安装APM 主要有两种方法，第一种，yum快速安装；第二种，编译安装。这两种方法可以说各有各的好处，作为生产环境都是可以的，下面我们分别讲讲两种方法。
第一种，yum快速安装APM

安装APM
安装命令如下：
yum install httpd httpd-devel mysql mysql-devel mysql-server php php-devel php-mysql php-common php-gd php-mbstring php-mcrypt php-xml
使用/etc/init.d/httpd start 就可以开启web服务器。
<span class="readmore"><a href="http://www.tisswb.cn/archives/526.html" title="配置LAMP生产环境：安装Apache、PHP、Mysql" target="_blank">阅读全文——共828字</a></span>]]></description>
			<content:encoded><![CDATA[<p>上一篇主要说了一下<a href="http://www.tisswb.cn/archives/519.html" target="_self">快速最小化安装CentOS5.3</a>的过程，这一篇主要讲一讲APM（Apache、PHP、Mysql的缩写）的安装过程。下一篇将集中讲述一下我是优化LAMP（CentOS5.3+Apache2.2.14+PHP5.2.11+Mysql5.0.36）的具体细节。</p>
<p>在CentOS5.3下面安装APM 主要有两种方法，第一种，yum快速安装；第二种，编译安装。这两种方法可以说各有各的好处，作为生产环境都是可以的，下面我们分别讲讲两种方法。</p>
<p>第一种，yum快速安装APM</p>
<ol>
<li>安装APM<br />
安装命令如下：<br />
<code>yum install httpd httpd-devel mysql mysql-devel mysql-server php php-devel php-mysql php-common php-gd php-mbstring php-mcrypt php-xml</code><br />
使用/etc/init.d/httpd start 就可以开启web服务器。<br />
使用/etc/init.d/mysqld start 就可以开启Mysql数据库服务器。</li>
<li>初始化Mysql<br />
第一次启动mysql以后执行如下命令：<br />
<code>/usr/bin/mysqladmin -u root password 'asdasd'</code><br />
其中&#8221;中的asdasd是密码，你可以设置成想要的密码。<br />
这样的话就可以使用如下命令登陆mysql了：<br />
<code>mysql -uroot -p</code></li>
<li>设置httpd和mysqld开机启动<br />
命令如下：<br />
<code>chkconfig httpd on<br />
chkconfig mysqld on<br />
</code></li>
<li>在/var/www/html下面新建网页phpinfo.php，内容如下：<br />
这样就可以访问基本的web了：http://192.168.0.6/phpinfo.php （其中192.168.0.6是服务器的ip地址）</li>
</ol>
<p>第二种，编译安装APM</p>
<p>具体编译过程正在整理，敬请期待</p>
<p>20100525 今天更新了一下yum的安装方法，添加了几个devel的安装，因为有些时候安装其他的软件的时候需要用到。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/526.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>在ubuntu9.04下安装ZendStudio7.0详解</title>
		<link>http://www.tisswb.cn/archives/517.html</link>
		<comments>http://www.tisswb.cn/archives/517.html#comments</comments>
		<pubDate>Sun, 16 Aug 2009 14:31:39 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[ZendStudio]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=517</guid>
		<description><![CDATA[ZendStudio7绝对是php编辑的神器，最近一段时间使用的是不亦乐乎。但是最近工作环境转移到了Ubuntu上了，还是相当希望能够使用ZS7。当然，zend公司还是给我们提供了linux下的安装文件了，由于是初次在linux下面安装ZendStudio7，下面记录一下安装步骤细节，以备以后查阅：
1.下载zendstudio的linux版本，我下载的地址是：http://downloads.zend.com/studio-eclipse/7.0.0/ZendStudio-7.0.0.tar.gz
2.安装支持环境，zendstudio7需要jre支持，所以需要安装一下
sudo apt-get instll sun-java6-jre sun-java6-jdk
3.解压缩ZendStudio7的压缩包，把内容解压缩到个人的home目录中，解压缩出来的文件是一个叫ZendStudio7_0_0.bin的文件
<span class="readmore"><a href="http://www.tisswb.cn/archives/517.html" title="在ubuntu9.04下安装ZendStudio7.0详解" target="_blank">阅读全文——共511字</a></span>]]></description>
			<content:encoded><![CDATA[<p>ZendStudio7绝对是php编辑的神器，最近一段时间使用的是不亦乐乎。但是最近工作环境转移到了Ubuntu上了，还是相当希望能够使用ZS7。当然，zend公司还是给我们提供了linux下的安装文件了，由于是初次在linux下面安装ZendStudio7，下面记录一下安装步骤细节，以备以后查阅：</p>
<p>1.下载zendstudio的linux版本，我下载的地址是：<a title="zendstudio7的官方下载地址" href="http://downloads.zend.com/studio-eclipse/7.0.0/ZendStudio-7.0.0.tar.gz">http://downloads.zend.com/studio-eclipse/7.0.0/ZendStudio-7.0.0.tar.gz</a></p>
<p>2.安装支持环境，zendstudio7需要jre支持，所以需要安装一下<br />
<code>sudo apt-get instll sun-java6-jre sun-java6-jd</code>k</p>
<p>3.解压缩ZendStudio7的压缩包，把内容解压缩到个人的home目录中，解压缩出来的文件是一个叫ZendStudio7_0_0.bin的文件</p>
<p>4.使用如下命令安装这个bin文件<br />
<code>./ZendStudio7_0_0.bin</code></p>
<p>5.再往后的安装步骤就跟在window下面安装一样了，一直点下一步就可以了</p>
<p>安装完成后的配置也跟windows下面的一样了，这里我就不多说了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/517.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php单引号和双引号的区别</title>
		<link>http://www.tisswb.cn/archives/505.html</link>
		<comments>http://www.tisswb.cn/archives/505.html#comments</comments>
		<pubDate>Tue, 26 May 2009 06:39:03 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=505</guid>
		<description><![CDATA[平时很少注意到这个细节，一直以为PHP中单引号和双引号是互通的，直到有一天，发现单引号和双引号确实存在区别的时候，就仔细研究了一下，有了下面这段文字。
&#8221; &#8221; 双引号里面的字段会经过编译器解释，然后再当作HTML代码输出。
&#8216; &#8216; 单引号里面的不进行解释，直接输出。
从字面意思上就可以看出，单引号比双引号要快了。
例如：
$abc=&#8217;my name is tome&#8217;;
echo $abc //结果是:my name is tom
echo &#8216;$abc&#8217; //结果是:$abc
echo &#8220;$abc&#8221; //结果是:my name is tom
特别在使用MYSQL语句的时候，双引号和单引号的用法让新手不知所措，在这里，举个例子，来进行说明。
<span class="readmore"><a href="http://www.tisswb.cn/archives/505.html" title="php单引号和双引号的区别" target="_blank">阅读全文——共957字</a></span>]]></description>
			<content:encoded><![CDATA[<p>平时很少注意到这个细节，一直以为PHP中单引号和双引号是互通的，直到有一天，发现单引号和双引号确实存在区别的时候，就仔细研究了一下，有了下面这段文字。</p>
<p>&#8221; &#8221; 双引号里面的字段会经过编译器解释，然后再当作HTML代码输出。</p>
<p>&#8216; &#8216; 单引号里面的不进行解释，直接输出。</p>
<p>从字面意思上就可以看出，单引号比双引号要快了。</p>
<p>例如：<br />
$abc=&#8217;my name is tome&#8217;;<br />
echo $abc //结果是:my name is tom<br />
echo &#8216;$abc&#8217; //结果是:$abc<br />
echo &#8220;$abc&#8221; //结果是:my name is tom</p>
<p>特别在使用MYSQL语句的时候，双引号和单引号的用法让新手不知所措，在这里，举个例子，来进行说明。</p>
<p>假设查询条件中使用的是常量，例如：</p>
<p>select    *    from    abc_table where user_name=&#8217;abc&#8217;;</p>
<p>SQL语句可以写成:</p>
<p>SQLstr = &#8220;select    *    from abc_table where user _name= &#8216;abc&#8217;&#8221; ;</p>
<p>假设查询条件中使用的是变量，例如：</p>
<p>$user_name = $_REQUEST['user_name']; //字符串变量</p>
<p>或</p>
<p>$user=array (&#8220;name&#8221;=&gt; $_REQUEST['user_name‘,"age"=&gt;$_REQUEST['age'];//数组变量</p>
<p>SQL语句就可以写成：</p>
<p>SQLstr = &#8220;select    *    from abc_table where user_name = &#8216; &#8221; . $user_name . &#8221; &#8216; &#8220;;</p>
<p>SQLstr = &#8220;select * from abc_table where user_name = &#8216; &#8221; . $user["name"] . &#8221; &#8216; &#8220;;</p>
<p>对比一下:</p>
<p>SQLstr=&#8221;select * from abc_table where user_name = &#8216; abc &#8216; &#8221; ;</p>
<p>SQLstr=&#8221;select * from abc_table where user_name =&#8217; &#8221; . $user _name . &#8221; &#8216; &#8220;;</p>
<p>SQLstr=&#8221;select * from abc_table where user_name =&#8217; &#8221; . $user["name"] . &#8221; &#8216; &#8220;;</p>
<p>SQLstr可以分解为以下3个部分:<br />
1：&#8221;select * from table where user_name = &#8216; &#8221; //固定SQL语句<br />
2：$user //变量<br />
3：&#8221; &#8216; &#8221;<br />
1,2,3部分字符串之间用&#8221;.&#8221; 来连接</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/505.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP中file_get_contents函数超时的几种解决方法</title>
		<link>http://www.tisswb.cn/archives/498.html</link>
		<comments>http://www.tisswb.cn/archives/498.html#comments</comments>
		<pubDate>Sun, 24 May 2009 17:33:01 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=498</guid>
		<description><![CDATA[在使用file_get_contents函数的时候，经常会出现超时的情况，在这里要通过查看一下错误提示，看看是哪种错误，比较常见的是读取超时，这种情况大家可以通过一些方法来尽量的避免或者解决。这里就简单介绍两种：
一、增加超时的时间限制
这里需要注意：set_time_limit只是设置你的PHP程序的超时时间，而不是file_get_contents函数读取URL的超时时间。
我一开始以为set_time_limit也能影响到file_get_contents，后来经测试，是无效的。真正的修改file_get_contents延时可以用resource $context的timeout参数：
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>60,
)
); 
<span class="readmore"><a href="http://www.tisswb.cn/archives/498.html" title="PHP中file_get_contents函数超时的几种解决方法" target="_blank">阅读全文——共683字</a></span>]]></description>
			<content:encoded><![CDATA[<p>在使用file_get_contents函数的时候，经常会出现超时的情况，在这里要通过查看一下错误提示，看看是哪种错误，比较常见的是读取超时，这种情况大家可以通过一些方法来尽量的避免或者解决。这里就简单介绍两种：</p>
<p>一、增加超时的时间限制</p>
<p>这里需要注意：set_time_limit只是设置你的PHP程序的超时时间，而不是file_get_contents函数读取URL的超时时间。<br />
我一开始以为set_time_limit也能影响到file_get_contents，后来经测试，是无效的。真正的修改file_get_contents延时可以用resource $context的timeout参数：</p>
<p><code>$opts = array(<br />
'http'=>array(<br />
'method'=>"GET",<br />
'timeout'=>60,<br />
)<br />
); </p>
<p>$context = stream_context_create($opts); </p>
<p>$html =file_get_contents('http://www.example.com', false, $context);<br />
fpassthru($fp);<br />
</code></p>
<p>二、一次有延时的话那就多试几次</p>
<p>有时候失败是因为网络等因素造成，没有解决办法，但是可以修改程序，失败时重试几次，仍然失败就放弃，因为file_get_contents()如果失败将返回 FALSE，所以可以下面这样编写代码：</p>
<p><code>$cnt=0;<br />
while($cnt < 3 &#038;&#038; ($str=@file_get_contents('http...'))===FALSE) $cnt++; </code></p>
<p>以上只是我搜集整理的一些小技巧，希望能找到更好的技巧。</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/498.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php安装模式mod_php和Fastcgi的选择与对比</title>
		<link>http://www.tisswb.cn/archives/294.html</link>
		<comments>http://www.tisswb.cn/archives/294.html#comments</comments>
		<pubDate>Sun, 15 Mar 2009 17:01:38 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[Web服务器]]></category>
		<category><![CDATA[服务器]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=294</guid>
		<description><![CDATA[安装php又面临到了模式的选择，以前都是选择mod_php模式，因为这样安装比较方便哈，今天突然关心起FastCGI这种模式，败毒了一把，找到了一些关于mod_php和Fastcgi的选择与对比这方面的讨论，现在发出来留一个记号，以便进一步研究：
第一篇：php在apache中安装模式的区别：fastcgi和mod_php
    说到fastCgi就不得不说Cgi。
    CGI英文全称是 Common Gateway Interface，通常翻译为共同网关接口，是HTTP服务器与机器上的其他程序进行通信的一个接口。这个“其他程序”可以使用任何计算机语言来编写，它通过CGI这个接口从HTTP服务器取得输入，然后把运行的结果又通过CGI这个接口交给HTTP服务器，而HTTP服务器把这个结果送给浏览器。
    CGI的出现让WEB从静态变为为动态，随着Web的越来越普及，很多的网站的都需要有动态的页面，以便与浏览者互交。CGI方式的缺点也越来越突出。因为HTTP要生成一个动态页面，系统就必须启动一个新的进程以运行CGI程序，不断地fork是一项很消耗时间和资源的工作。这就出现了FastCGI。
<span class="readmore"><a href="http://www.tisswb.cn/archives/294.html" title="php安装模式mod_php和Fastcgi的选择与对比" target="_blank">阅读全文——共3123字</a></span>]]></description>
			<content:encoded><![CDATA[<p>安装php又面临到了模式的选择，以前都是选择mod_php模式，因为这样安装比较方便哈，今天突然关心起FastCGI这种模式，败毒了一把，找到了一些关于mod_php和Fastcgi的选择与对比这方面的讨论，现在发出来留一个记号，以便进一步研究：</p>
<p>第一篇：<a href="http://www.tisswb.cn/wp-admin/read.php/150.htm" target="_blank">php在apache中安装模式的区别：fastcgi和mod_php</a></p>
<p>    说到fastCgi就不得不说Cgi。<br />
    CGI英文全称是 Common Gateway Interface，通常翻译为共同网关接口，是HTTP服务器与机器上的其他程序进行通信的一个接口。这个“其他程序”可以使用任何计算机语言来编写，它通过CGI这个接口从HTTP服务器取得输入，然后把运行的结果又通过CGI这个接口交给HTTP服务器，而HTTP服务器把这个结果送给浏览器。</p>
<p>    CGI的出现让WEB从静态变为为动态，随着Web的越来越普及，很多的网站的都需要有动态的页面，以便与浏览者互交。CGI方式的缺点也越来越突出。因为HTTP要生成一个动态页面，系统就必须启动一个新的进程以运行CGI程序，不断地fork是一项很消耗时间和资源的工作。这就出现了FastCGI。</p>
<p>   百度百科关于FastCGI</p>
<p><code>　1. FastCGI 像是一个常驻 (long-live) 型的 CGI，它可以一直执行着，只要激活后，不会每次都要花费时间去 fork 一次 (这是 CGI 最为人诟病的 fork-and-execute 模式)。<br />
　2. FastCGI 可在任何平台上使用，Netscape Enterprise 及 IIS 都有 FastCGI 的模块可供使用，阿帕契 (Apache，以及利用 Apache 衍生出做的服务器) 上也有 mod_fastcgi 可用。<br />
　3. FastCGI 支持 C/C++，Ruby, Perl，Tcl，Java，Python 等程序语言。<br />
　4. FastCGI 的应用程序亦兼容于 CGI。即 FastCGI 的应用程序也可以当成 CGI 来执行。<br />
　5. 现有的 CGI 程序要改写成 FastCGI 非常简单，最少可能只需要多加入三行程序代码。<br />
　6. FastCGI 的侦错方式与 CGI 大同小异，只要带入程序所需的环境变量及参数，即可在命令列模式执行或侦错。<br />
　7. FastCGI 应用程序的写作方式与 CGI 类似，除了几项原则要特别注意外，FastCGI 的写作方式跟 CGI 几乎一样，与学习 Web Server API 比较起来， FastCGI 简单多了。<br />
　8. FastCGI 支授分布式运算 (distributed computing)，即 FastCGI 程序可以在网站服务器以外的主机上执行并且接受来自其它网站服务器来的请求。</code></p>
<p>    mod_php就是把PHP做为APACHE一个内置模块。让apache http服务器本身能够支持PHP语言，不需要每一个请求就启动PHP解释器来解释PHP。</p>
<p>第二篇：<a href="http://hi.baidu.com/sprite_sy/blog/item/808adeca3cb14185c8176877.html" target="_blank">mod_php or fastcgi性能比较与选择</a></p>
<p>用php肯定少了不这个问题的选择，cgi自然就不必说了，但是mod_php和fastcgi的争论确还是比较多的。<br />
找了一些资料，晾在这，可供参考。<br />
首先，性能应该是大家最关心的问题了，除了mod_php和fastcgi 的 benchmark，还有一些服务器差别的测试，如apache vs lighthttpd</p>
<p>1 <a href="http://www.gnegg.ch/archives/305-mod_php,-LightTPD,-FastCGI-Whats-fastest.html" target="_blank">mod_php, LightTPD, FastCGI &#8211; What&#8217;s fastest?</a><br />
     这个bechmark的结果是 Apache(prefork)+Fastcgi+php的性能是最好的。超过了apache+mod_php，甚至也超过了lightty+fastcgi+php。当然，这个结果得出值相差都很小。另外，以上说的几个结果都使用了APC加速，使用APC后性能提高1倍以上。</p>
<p>2 <a href="http://www.meebey.net/projects/php4-mod-vs-cgi/" target="_blank">php4-mod-vs-cgi<br />
</a>   这个bechmark是在php4的环境下完成的。其<a href="http://www.meebey.net/projects/php4-mod-vs-cgi/summary.txt" target="_blank">summary.txt</a>的内容如下。<br />
<code>Summary of the benchmark<br />
------------------------</p>
<p>PHP4 module, very simple script (phpinfo.php): requests/s<br />
plain 130.04<br />
+turckcache 129.42<br />
+turckcache+zend-optimizer 125.50</p>
<p>PHP4 module, very complex script (insurance application): requests/s<br />
plain 1.84<br />
+turckcache 6.23<br />
+turckcache+zend-optimizer 5.58<br />
+optimizer 1.58</p>
<p>PHP4 CGI, very simple script (phpinfo.php): requests/s<br />
plain 22.69<br />
+turckcache n/a*<br />
+turckcache+zend-optimizer n/a*<br />
+optimizer 21.23</p>
<p>PHP4 CGI, very complex script (insurance application): requests/s<br />
plain 2.00<br />
+turckcache n/a*<br />
+turckcache+zend-optimizer n/a*<br />
+optimizer 1.72</p>
<p>* = turkcache doesn't support caching of the PHP scripts in CGI mode</code><br />
上面的结果我觉得需要关注的是无cache的情况，因为使用mod_php或fastcgi主要还是用来生成动态页面。前面的cache有更好的工具来实现，如squid。所以，这个结果也是fastcgi胜出，相差也不大。</p>
<p>3 <a href="http://buytaert.net/drupal-performance?page=1" target="_blank">http://buytaert.net/drupal-performance?page=1</a><br />
   这个文章的结果和上面两个刚好相反。使用fastcgi代替mod_php后，&#8221;When switching from <code>mod_php</code> to <code>FastCGI</code> we observe a 63% slowdown for anonymous visitors, and a 18% slowdown for authenticated visitors.&#8221;以下是图表</p>
<div><a href="http://buytaert.net/images/drupal/drupal-4.7-fastcgi-vs-mod_php.jpg" target="_blank"><img class="blogimg" src="http://buytaert.net/images/drupal/drupal-4.7-fastcgi-vs-mod_php.jpg" border="0" alt="" /></a></div>
<p>另外，benchmark中也做了和lightty的比较，如下图：</p>
<div><a href="http://buytaert.net/images/drupal/drupal-4.7-apache-vs-lighttpd.jpg" target="_blank"><img class="blogimg" src="http://buytaert.net/images/drupal/drupal-4.7-apache-vs-lighttpd.jpg" border="0" alt="" /></a></div>
<p>这个文章的结论是Apache+mod_php性能好于Apache+fastcgi。另外，Apache+mod_php略好于lightty+fastcgi。</p>
<p>4 最后看看 <a href="http://www.fastcgi.com/devkit/doc/fcgi-perf.htm#S2" target="_blank">fastcgi</a>官方自己怎么说的吧<br />
    Of course, the answer is that it depends upon the application. A more complete answer is that FastCGI often wins by a significant margin, and seldom loses by very much.</p>
<p>5 结论是，还是根据自己的应用测一下吧&#8230;.</p>
<p>最后,个人观点<br />
如果mod_php和fastcgi的性能相差不是很大的话，还是倾向于fastcgi的，这种方式毕竟更灵活、安全和简单。<br />
1 使用fastcgi，你的web server 可以比较简单的切换，可以测试不同的服务器，Apache,lightty,ngix 等等，不需要有代码的修改<br />
2 如果想换脚本的实现，如不用php，而是改成perl,python之类的，web服务器也不需要任何的改动<br />
3 web server和fastcgi可以用不同的帐号运行，带来了一定的安全隔离<br />
4 只在Apache中编个mod_fastcgi可以说是简单多了，把mod_php编进apache时，出问题时很难定位是php的问题还是apache的问题，我就见过这样的core，函数调用几十层，一点头绪都没有</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/294.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP抓取远程网站数据的代码</title>
		<link>http://www.tisswb.cn/archives/287.html</link>
		<comments>http://www.tisswb.cn/archives/287.html#comments</comments>
		<pubDate>Sat, 07 Mar 2009 20:57:18 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=287</guid>
		<description><![CDATA[这几天开发一套新的采集系统，整理了一些这方面的资料：如何像搜索引擎那样去抓取别人网站的HTML代码,然后把代码收集整理成为自己有用的数据!今天就等我介绍一些简单例子吧.
Ⅰ.抓取远程网页标题的例子:

< ?php
/*
+-------------------------------------------------------------
+抓取网页标题的代码,直接拷贝本代码片段,另存为.php文件执行即可.
+-------------------------------------------------------------
*/
error_reporting(7);
<span class="readmore"><a href="http://www.tisswb.cn/archives/287.html" title="PHP抓取远程网站数据的代码" target="_blank">阅读全文——共1792字</a></span>]]></description>
			<content:encoded><![CDATA[<p>这几天开发一套新的采集系统，整理了一些这方面的资料：如何像搜索引擎那样去抓取别人网站的HTML代码,然后把代码收集整理成为自己有用的数据!今天就等我介绍一些简单例子吧.</p>
<p><strong>Ⅰ.抓取远程网页标题的例子:</strong></p>
<p><code lang="php" linenum="on"><br />
< ?php<br />
/*<br />
+-------------------------------------------------------------<br />
+抓取网页标题的代码,直接拷贝本代码片段,另存为.php文件执行即可.<br />
+-------------------------------------------------------------<br />
*/<br />
error_reporting(7);<br />
$file = fopen ("http://www.dnsing.com/", "r");<br />
if (!$file) {<br />
echo "<font color=red>Unable to open remote file.n";<br />
exit;<br />
}<br />
while (!feof ($file)) {<br />
$line = fgets ($file, 1024);<br />
if (eregi ("", $line, $out)) {<br />
$title = $out[1];<br />
echo "".$title."";<br />
break;<br />
}<br />
}<br />
fclose($file); </p>
<p>//End<br />
?><br />
</code></p>
<p><strong>Ⅱ.抓取远程网页HTML代码的例子:</strong></p>
<p><code lang="php" linenum="on"><br />
< ? php<br />
/*<br />
+----------------<br />
+DNSing Sprider<br />
+----------------<br />
*/</p>
<p>$fp = fsockopen("www.dnsing.com", 80, $errno, $errstr, 30);<br />
if (!$fp) {<br />
   echo "$errstr ($errno)<br/>n";<br />
} else {<br />
   $out = "GET / HTTP/1.1rn";<br />
   $out .= "Host: www.dnsing.com rn";<br />
   $out .= "Connection: Close rnrn";<br />
   fputs($fp, $out);<br />
   while (!feof($fp)) {<br />
     echo fgets($fp, 128);<br />
   }<br />
   fclose($fp);<br />
}<br />
//End<br />
?></code></p>
<p>以上两个代码片段都直接Copy回去运行就知道效果了,上面的例子只是抓取网页数据的雏形,要使其更适合自己的使用,情况有各异.所以,在此各位程序爱好者自己好好研究一下吧.</p>
<p>===============================</p>
<p>稍微有点意义的函数是：get_content_by_socket(), get_url(), get_content_url(), get_content_object 几个函数，也许能够给你点什么想法。</p>
<p><code lang="php" linenum="on"><br />
< ?php </p>
<p>//获取所有内容url保存到文件<br />
function get_index($save_file, $prefix="index_"){<br />
     $count = 68;<br />
     $i = 1;<br />
     if (file_exists($save_file)) @unlink($save_file);<br />
     $fp = fopen($save_file, "a+") or die("Open ". $save_file ." failed");<br />
     while($i<$count){<br />
         $url = $prefix . $i .".htm";<br />
         echo "Get ". $url ."...";<br />
         $url_str = get_content_url(get_url($url));<br />
         echo " OKn";<br />
         fwrite($fp, $url_str);<br />
         ++$i;<br />
     }<br />
     fclose($fp);<br />
} </p>
<p>//获取目标多媒体对象<br />
function get_object($url_file, $save_file, $split="|--:**:--|"){<br />
     if (!file_exists($url_file)) die($url_file ." not exist");<br />
     $file_arr = file($url_file);<br />
     if (!is_array($file_arr) || empty($file_arr)) die($url_file ." not content");<br />
     $url_arr = array_unique($file_arr);<br />
     if (file_exists($save_file)) @unlink($save_file);<br />
     $fp = fopen($save_file, "a+") or die("Open save file ". $save_file ." failed");<br />
     foreach($url_arr as $url){<br />
         if (empty($url)) continue;<br />
         echo "Get ". $url ."...";<br />
         $html_str = get_url($url);<br />
         echo $html_str;<br />
         echo $url;<br />
         exit;<br />
         $obj_str = get_content_object($html_str);<br />
         echo " OKn";<br />
         fwrite($fp, $obj_str);<br />
     }<br />
     fclose($fp);<br />
} </p>
<p>//遍历目录获取文件内容<br />
function get_dir($save_file, $dir){<br />
     $dp = opendir($dir);<br />
     if (file_exists($save_file)) @unlink($save_file);<br />
     $fp = fopen($save_file, "a+") or die("Open save file ". $save_file ." failed");<br />
     while(($file = readdir($dp)) != false){<br />
         if ($file!="." &#038;&#038; $file!=".."){<br />
             echo "Read file ". $file ."...";<br />
             $file_content = file_get_contents($dir . $file);<br />
             $obj_str = get_content_object($file_content);<br />
             echo " OKn";<br />
             fwrite($fp, $obj_str);<br />
         }<br />
     }<br />
     fclose($fp);<br />
} </p>
<p>//获取指定url内容<br />
function get_url($url){<br />
     $reg = '/^http://[^/].+$/';<br />
     if (!preg_match($reg, $url)) die($url ." invalid");<br />
     $fp = fopen($url, "r") or die("Open url: ". $url ." failed.");<br />
     while($fc = fread($fp, 8192)){<br />
         $content .= $fc;<br />
     }<br />
     fclose($fp);<br />
     if (empty($content)){<br />
         die("Get url: ". $url ." content failed.");<br />
     }<br />
     return $content;<br />
} </p>
<p>//使用socket获取指定网页<br />
function get_content_by_socket($url, $host){<br />
     $fp = fsockopen($host, 80) or die("Open ". $url ." failed");<br />
     $header = "GET /".$url ." HTTP/1.1rn";<br />
     $header .= "Accept: */*rn";<br />
     $header .= "Accept-Language: zh-cnrn";<br />
     $header .= "Accept-Encoding: gzip, deflatern";<br />
     $header .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; InfoPath.1; .NET CLR 2.0.50727)rn";<br />
     $header .= "Host: ". $host ."rn";<br />
     $header .= "Connection: Keep-Alivern";<br />
     //$header .= "Cookie: cnzz02=2; rtime=1; ltime=1148456424859; cnzz_eid=56601755-rnrn";<br />
     $header .= "Connection: Closernrn"; </p>
<p>     fwrite($fp, $header);<br />
     while (!feof($fp)) {<br />
         $contents .= fgets($fp, 8192);<br />
     }<br />
     fclose($fp);<br />
     return $contents;<br />
} </p>
<p>//获取指定内容里的url<br />
function get_content_url($host_url, $file_contents){ </p>
<p>     //$reg = '/^(#|javascript.*?|ftp://.+|http://.+|.*?href.*?|play.*?|index.*?|.*?asp)+$/i';<br />
     //$reg = '/^(down.*?.html|d+_d+.htm.*?)$/i';<br />
     $rex = "/([hH][rR][eE][Ff])s*=s*['"]*([^>'"s]+)["'>]*s*/i";<br />
     $reg = '/^(down.*?.html)$/i';<br />
     preg_match_all ($rex, $file_contents, $r);<br />
     $result = ""; //array();<br />
     foreach($r as $c){<br />
         if (is_array($c)){<br />
             foreach($c as $d){<br />
                 if (preg_match($reg, $d)){ $result .= $host_url . $d."n"; }<br />
             }<br />
         }<br />
     }<br />
     return $result;<br />
} </p>
<p>//获取指定内容中的多媒体文件<br />
function get_content_object($str, $split="|--:**:--|"){<br />
     $regx = "/hrefs*=s*['"]*([^>'"s]+)["'>]*s*(<b>.*?< /b>)/i";<br />
     preg_match_all($regx, $str, $result); </p>
<p>     if (count($result) == 3){<br />
         $result[2] = str_replace("</b><b>多媒体： ", "", $result[2]);<br />
         $result[2] = str_replace("</b>", "", $result[2]);<br />
         $result = $result[1][0] . $split .$result[2][0] . "n";<br />
     }<br />
     return $result;<br />
} </p>
<p>?> </code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/287.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php小偷程序原理分析</title>
		<link>http://www.tisswb.cn/archives/284.html</link>
		<comments>http://www.tisswb.cn/archives/284.html#comments</comments>
		<pubDate>Sat, 07 Mar 2009 20:51:59 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=284</guid>
		<description><![CDATA[拿华军软件开刀,经过今天的教程以后,我相信大家都能偷.
当然,你想偷别的站也是一个道理.关键是方法.
我们打开华军软件园主站地址:
http://www.onlinedown.net/index.htm
当打开完成以后,点 查看&#8211;查看源文件
系统会用记事本显示出来首页的HTML代码.
/*
&#60;title&#62;华军软件园——共享软件发布-下载-学习-研究-交流之园(推荐用1024*768)&#60;/title&#62;
*/
看见这一行没?这就是标题.
<span class="readmore"><a href="http://www.tisswb.cn/archives/284.html" title="php小偷程序原理分析" target="_blank">阅读全文——共10526字</a></span>]]></description>
			<content:encoded><![CDATA[<p>拿华军软件开刀,经过今天的教程以后,我相信大家都能偷.<br />
当然,你想偷别的站也是一个道理.关键是方法.<br />
我们打开华军软件园主站地址:<br />
<a href="http://www.onlinedown.net/index.htm">http://www.onlinedown.net/index.htm</a></p>
<p>当打开完成以后,点 查看&#8211;查看源文件<br />
系统会用记事本显示出来首页的HTML代码.</p>
<p>/*<br />
&lt;title&gt;华军软件园——共享软件发布-下载-学习-研究-交流之园(推荐用1024*768)&lt;/title&gt;<br />
*/<br />
看见这一行没?这就是标题.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
写小偷需要能看懂HTML才行哦?如果你一点HTML都看不懂的话,那就学起来有难度.<br />
现在大家从HTML中,找出华军软件园首页的<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
软件总数:30738 更新:287<br />
国产软件:160国外软件:113<br />
汉化补丁:13 数码软件:1<br />
杀毒快报:10 资讯中心:42<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
以上信息从HTML代码从 哪里开始.<br />
是单独表格还是在表格内的行,或者列.<br />
不会也没关系,看多了就会了.如果你不会以后想成为神偷就有难度,所以现在开始就得学习了.</p>
<p>好了,讲了这么多,就是告诉大家,小偷就是用ASP,PHP或者其他语言在程序中打开并且处理这些HTML<br />
拿PHP讲<br />
&lt;?php<br />
$files=&#8221;http://www.onlinedown.net/index.htm&#8221;;<br />
$fp=fopen($files,&#8221;a&#8221;);<br />
&#8230;..<br />
&#8230;&#8230;<br />
?&gt;<br />
把打开的HTML代码进行切割,更换.<br />
比如刚才叫大家找的.下面的信息<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
软件总数:30738 更新:287<br />
国产软件:160国外软件:113<br />
汉化补丁:13 数码软件:1<br />
杀毒快报:10 资讯中心:42<br />
&#8212;&#8212;&#8212;&#8212;&#8211;<br />
PHP就是处理这个index.htm<br />
把你要的信息切割处理.简单的这么讲<br />
&#8211;<br />
首页更新 = 从index.htm中切割出首页更新内容<br />
&#8211;<br />
然后在你要显示的地方输出,就显示了上面内容.</p>
<p>其他内容也是一样处理.<br />
处理原理就是这样.所以说是一直自动更新.<br />
按照你的办法切割着首页.它首页内容变新了,当访问你小偷的时候,你切割出来的内容是他的内容,所以是同步时时的内容.</p>
<p>今天就讲这么多,就弄明白原理,知道怎么回事就可以,别往深处想.如果你看不懂HTML的话,应该花几个小时看看了.以后要用.<br />
对自己要有信心,其实每个人都很聪明的.知识是慢慢积累的.<br />
我相信经过我几天的教程,到最后你能写出你自己的小偷来!</p>
<p>____________________________________________________________________________________________</p>
<p>今天教第二天.<br />
有个朋友说的好,其实教功夫也是变相的教你怎么杀人,可是不说出来.<br />
所以这个教程从下一篇开始就改个名字<br />
叫&lt;远程操作对方数据程序&gt;有点土比小偷好听<br />
第二天.<br />
教几个函数给大家.<br />
1 读取判断函数<br />
2 更新cache函数<br />
3 写入文件函数<br />
4 切割字符函数<br />
5 读取字符函数<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
在我们想写之前我们先要做好准备,构思一下怎么去写.<br />
制作前构思1<br />
我们打开华军首页<br />
[url]http://www.onlinedown.net/[/url]<br />
经过我们统计,是不是发现它的连接有个很相同的规则?<br />
1 根目录的index.htm文件<br />
2 soft文件夹的 1.htm &#8230;&#8230;.30000.htm<br />
3 sort文件夹的 1_1.htm   200_1.htm<br />
4 a-z文件夹 1.htm &#8230;.200.htm<br />
到此我们可以想好一个打开函数,不是根目录 就是文件夹/名字<br />
只有2中可能.<br />
制作前构思2<br />
为了让速度更快,我们最好把内容读过来存储起来.<br />
1 减少了对对方站点的请求.<br />
2 提供了速度.<br />
这里我们判断这个文件写入的时间为准 我们自己设置一个时间<br />
当写入时间 和现在的时间比一下,如果在我们的设置时间内的话.就是可以.<br />
如果不在比如<br />
文件写入时间 2004年5月18好 06:00 我们现在时间是2004年5月19号 18:00<br />
我们设置时间是1个小时<br />
当再次请求这个文件的时候 他发现已经过期了.就会重新向对方请求一次并且存入.<br />
制作前构思3<br />
为了以后频繁的操作简单话,把固定的操作写进一个函数.<br />
切割字符.<br />
一般切割就是 从第一个位置   切割到第二个位置 然后取中间部分<br />
比如:<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;演示站点&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
从&lt;title&gt;开始切割到&lt;/title&gt;<br />
那切割出来的 就是 &#8220;演示站点&#8221;4个字<br />
如果说,可以找到   几个 &lt;title&gt;怎么办?程序会从第一处开始切割<br />
到这里构思差不多..<br />
程序要干净明了才行,不要这一个文件不知道什么,那一个文件不知道哪来.<br />
所以,如果你以后有做大站的机会的话,文件夹,文件一定要写的清楚,分的清楚.<br />
既然明白了构思,我们就开始动手做了.<br />
建立我们第一个PHP文件:<br />
你可以用记事本,可以用Dreamweaver也可以用专用PHP编辑软件<br />
取名字为 commom.php<br />
内容为<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&lt;?php<br />
include &#8216;./config.php&#8217;;<br />
include &#8216;./global.php&#8217;;<br />
?&gt;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
这个文件有什么用?就是在以后操作中直接 inclue 这个文件就可以用到所有的函数啊什么的<br />
然后config.php是设置 URL 刷新时间 等等<br />
global.php是 所有函数的文件<br />
也就是今天要给教给大家的!<br />
第一个个函数 open<br />
&#8212;&#8212;&#8212;&#8212;-<br />
function open($file,$type=&#8221;){<br />
         global $fromurl,$referer;<br />
         $cachename=$file;<br />
                 if($type){<br />
                         $file=$fromurl.&#8217;/&#8217;.$type.&#8217;/&#8217;.$file;<br />
                 }else{<br />
                         $file=$fromurl.$file;<br />
                 }</p>
<p>                <br />
                <br />
                <br />
                         if($open=file($file)){<br />
                                         $count=count($open);<br />
                                         for($i=0;$i&lt;$count;$i++){<br />
                                                 $theget.=$open[$i];</p>
<p>                                         }<br />
                                        <br />
                                 }else{<br />
                                         die(&#8216;请求过多，超时，请刷新&#8217;);<br />
                                 }<br />
                <br />
                <br />
         return $theget;</p>
<p>}<br />
&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
解释过了,连接地址就2中请求,根目录,和 文件夹/名字<br />
函数怎么用法等等,不多说了.建议大家下载译本PHP中文手册看看.<br />
第二个函数<br />
根据设置时间更新cache目录文件函数 update<br />
&#8212;&#8212;&#8212;&#8212;&#8212;<br />
function update($file,$type=&#8221;){<br />
         global $timestamp,$flush;<br />
         if(!file_exists(&#8220;cache/$file&#8221;)){<br />
                 if($type){<br />
                         $data=open($file,$type);<br />
                 }else{<br />
                         $data=open($file);<br />
                 }<br />
                <br />
                 writetofile(&#8220;cache/$file&#8221;,$data);<br />
         }else{<br />
                 $lastflesh=@filemtime(&#8220;cache/$file&#8221;);<br />
                <br />
        <br />
        <br />
                 if($lastflesh + ($flush * 60) &lt; $timestamp ){<br />
                         if($type){<br />
                                 $data=open($file,$type);<br />
                         }else{<br />
                                 $data=open($file);<br />
                         }<br />
                         writetofile(&#8220;cache/$file&#8221;,$data);<br />
                 }<br />
         }</p>
<p>}<br />
&#8212;&#8212;&#8211;<br />
简单解释<br />
$data=open($file,$type);就是用到上面的 open函数了<br />
如果我们用 udate(&#8220;index.htm&#8221;);<br />
那不就是用到了 update函数吗? 明白吗?<br />
上面出现了writetofile函数 下面是代码<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
function writetofile($file_name,$data,$method=&#8221;w&#8221;) {<br />
         if($filenum=fopen($file_name,$method)){<br />
                 flock($filenum,LOCK_EX);<br />
                 $file_data=fwrite($filenum,$data);<br />
                 fclose($filenum);<br />
                 return $file_data;<br />
         }else{<br />
                 return false;<br />
         }<br />
}&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
切割字符函数<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
function cut($file,$from,$end){</p>
<p>         $message=explode($from,$file);<br />
         $message=explode($end,$message[1]);<br />
return         $message[0];<br />
}<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
读取函数<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
function readfromfile($file_name) {<br />
         if($filenum=fopen($file_name,&#8221;r&#8221;)){<br />
                 flock($filenum,LOCK_SH);<br />
                 $file_data=fread($filenum,filesize($file_name));<br />
                 fclose($filenum);<br />
                 return $file_data;<br />
         }else{<br />
                 return false;<br />
         }<br />
        <br />
}<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
把所有函数写成一个文件 保存起来 取名字叫 global.php<br />
内容如下:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&lt;?php<br />
function open($file,$type=&#8221;){<br />
         global $fromurl,$referer;<br />
         $cachename=$file;<br />
                 if($type){<br />
                         $file=$fromurl.&#8217;/&#8217;.$type.&#8217;/&#8217;.$file;<br />
                 }else{<br />
                         $file=$fromurl.$file;<br />
                 }</p>
<p>                <br />
                <br />
                <br />
                         if($open=file($file)){<br />
                                         $count=count($open);<br />
                                         for($i=0;$i&lt;$count;$i++){<br />
                                                 $theget.=$open[$i];</p>
<p>                                         }<br />
                                        <br />
                                 }else{<br />
                                         die(&#8216;请求过多，超时，请刷新&#8217;);<br />
                                 }<br />
                <br />
                <br />
         return $theget;</p>
<p>}</p>
<p>function update($file,$type=&#8221;){<br />
//更新cache中的文件<br />
         global $timestamp,$flush;<br />
         if(!file_exists(&#8220;cache/$file&#8221;)){<br />
                 if($type){<br />
                         $data=open($file,$type);<br />
                 }else{<br />
                         $data=open($file);<br />
                 }<br />
                <br />
                 writetofile(&#8220;cache/$file&#8221;,$data);<br />
         }else{<br />
                 $lastflesh=@filemtime(&#8220;cache/$file&#8221;);<br />
                <br />
        <br />
        <br />
                 if($lastflesh + ($flush * 60) &lt; $timestamp ){<br />
                         if($type){<br />
                                 $data=open($file,$type);<br />
                         }else{<br />
                                 $data=open($file);<br />
                         }<br />
                         writetofile(&#8220;cache/$file&#8221;,$data);<br />
                 }<br />
         }</p>
<p>}<br />
function readfromfile($file_name) {<br />
         if($filenum=fopen($file_name,&#8221;r&#8221;)){<br />
                 flock($filenum,LOCK_SH);<br />
                 $file_data=fread($filenum,filesize($file_name));<br />
                 fclose($filenum);<br />
                 return $file_data;<br />
         }else{<br />
                 return false;<br />
         }<br />
        <br />
}</p>
<p>function writetofile($file_name,$data,$method=&#8221;w&#8221;) {<br />
         if($filenum=fopen($file_name,$method)){<br />
                 flock($filenum,LOCK_EX);<br />
                 $file_data=fwrite($filenum,$data);<br />
                 fclose($filenum);<br />
                 return $file_data;<br />
         }else{<br />
                 return false;<br />
         }<br />
}<br />
function cut($file,$from,$end){</p>
<p>         $message=explode($from,$file);<br />
         $message=explode($end,$message[1]);<br />
return         $message[0];<br />
}<br />
function updatecache($file,$cache=&#8221;){<br />
         global $timestamp,$flush;<br />
         if(!file_exists($file)){<br />
                 writetofile($file,$cache);<br />
                 $return=$cache;<br />
         }elseif(@filemtime($file) &lt; $timestamp &#8211; ($flush * 60)){<br />
                 writetofile($file,$cache);<br />
                 $return=$cache;<br />
         }else{<br />
                 $return=readfromfile($file);        <br />
         }<br />
         return $return;<br />
}<br />
?&gt;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
其中有几个变量在config.php中设置一下<br />
我们建立config.php文件 内容如下:<br />
&lt;?php<br />
$fromurl = &#8220;http://www.onlinedown.net/&#8221;;<br />
$flush=&#8221;120&#8243;;//update函数中自动同步更新时间<br />
?&gt;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
现在位置我们有了3个文件了 commom.php config.php global.php<br />
有了3个文件 程序总体完成了.接下来如何去偷呢?<br />
心急的人可以先试试<br />
建立一个index.php文件 就是首页<br />
你先做好模板 的样子<br />
HTML先做好.<br />
然后在<br />
&lt;html&gt;<br />
&#8230;&#8230;..<br />
&#8230;&#8230;..<br />
&lt;/html&gt;<br />
的上方插入PHP代码<br />
如下:<br />
&lt;?php<br />
require &#8216;./commom.php&#8217;;<br />
update(&#8220;index.htm&#8221;);<br />
$file=readfromfile(&#8220;cache/index.htm&#8221;);<br />
$gwrj = cut($file,&#8221;&lt;TD width=&#8221;307&#8243; height=&#8221;118&#8243;&gt;&#8221;,&#8221;&lt;/TD&gt;&#8221;);<br />
?&gt;<br />
&lt;html&gt;<br />
&#8230;&#8230;.<br />
&#8230;&#8230;<br />
&#8230;&#8230;.<br />
&lt;/html&gt;<br />
在你想要插入的地方插入&lt;?php echo $gwrj; ?&gt;<br />
就是从首页中切割出来的国外软件<br />
自己试试</p>
<p>___________________________________________________________________________________________</p>
<p>今天我们教,偷取首页.不同的首页需要不同的偷法,主要是分析HTML代码.函数以及方法前面2天介绍的很清楚了.今天我们在实践中讲解和使用.</p>
<p>还是拿华军软件园开刀.<br />
<a href="http://www.onlinedown.net/index.htm">http://www.onlinedown.net/index.htm</a><br />
用Dreamweaver新建一个index.php的页子.<br />
注意:<br />
先做好你要的首页模板,然后开始偷首页.由于考虑到对初学者的教程.所以先把模板和PHP处理代码放在同一个网页中.<br />
以后教大家HTML和PHP的分离.</p>
<p>模板建立好以后,我们就开偷.<br />
在&lt;html&gt;<br />
的上方插入PHP代码,如下形式:<br />
&lt;?<br />
require &#8216;./commom.php&#8217;;<br />
update(&#8220;index.htm&#8221;);<br />
$file=readfromfile(&#8220;cache/index.htm&#8221;);</p>
<p>?&gt;<br />
解释<br />
require &#8216;./commom.php&#8217;//引入commom.php文件<br />
update(&#8220;index.htm&#8221;)//读取写入index.htm网页<br />
$file=readfromfile(&#8220;cache/index.htm&#8221;)//从本地文件夹cache中读取index.htm<br />
这里的$file是一个变量,你可以随便取名.也可以叫它 $html<br />
但是后面用到的时候要统一.</p>
<p>上面代码,没有处理任何东西,也没有输出任何的东西.如果说输出$file的话,那么就是index.htm的所有html代码.<br />
下面就开始到index.htm中拿我们想要的东东.</p>
<p>1 拿国外软件更新的代码.<br />
大家可以取一个变量名为 $gwrj    //国外软件 名字随便取<br />
怎么从这个index.htm拿出这个我们想要的国外软件呢?这里拿出我们上一节讲过的cut函数<br />
$gwrj = cut($file,&#8221;&lt;TD width=&#8221;307&#8243; height=&#8221;118&#8243;&gt;&#8221;,&#8221;&lt;/TD&gt;&#8221;);<br />
解释<br />
$xxx = cut($file,&#8221;$first&#8221;,&#8221;$end&#8221;);<br />
如何工作的呢?就是把$file(index.htm)从$first处切割取下面部分,在切割$end取上面部分.<br />
比如说:<br />
$file = &#8220;111222333444&#8243;;<br />
$xxx = cut($file,&#8221;1&#8243;,&#8221;3&#8243;);//结果是11222 这样的解释应该明白吧?<br />
注意:<br />
&#8220;&lt;TD width=&#8221;307&#8243; height=&#8221;118&#8243;&gt;&#8221;<br />
在&#8221; &#8220;内的内容 如果也有 &#8221; 的话,需要在前面加<br />
例子<br />
&#8220;&lt;TD width=&#8221;307&#8243; height=&#8221;118&#8243;&gt;&#8221;<br />
成为<br />
&#8220;&lt;TD width=&#8221;307&#8243; height=&#8221;118&#8243;&gt;&#8221;<br />
下面这段代码就是成功偷取了国外软件:<br />
&lt;?<br />
require &#8216;./commom.php&#8217;;<br />
update(&#8220;index.htm&#8221;);<br />
$file=readfromfile(&#8220;cache/index.htm&#8221;);<br />
$gwrj = cut($file,&#8221;&lt;TD width=&#8221;307&#8243; height=&#8221;118&#8243;&gt;&#8221;,&#8221;&lt;/TD&gt;&#8221;);<br />
?&gt;<br />
然后在你的html模板中,在需要显示的地方插入代码<br />
&lt;? echo $gwrj; ?&gt;</p>
<p>其他偷取也一样.<br />
注意:<br />
这里拿出来的HTML需要更换为自己的代码,可以总的更换,也可以一个一个更换.<br />
我们讲单独更换代码就是:<br />
$gwrj = cut($file,&#8221;&lt;TD width=&#8221;307&#8243; height=&#8221;118&#8243;&gt;&#8221;,&#8221;&lt;/TD&gt;&#8221;);<br />
$gwrj = str_replace(&#8220;soft/&#8221;,&#8221;soft.php?id=&#8221;,$gwrj);<br />
$gwrj = str_replace(&#8220;.htm&#8221;,&#8221;",$gwrj);<br />
解释:<br />
就是把偷过来的国外软件中的代码更换.<br />
原来的<br />
&lt;a target=_blank href=&#8221;soft/18204.htm&#8221;&gt;<br />
变为了现在的<br />
&lt;a target=_blank href=&#8221;soft.php?id=18204&#8243;&gt;</p>
<p>基本差不多了,多菜鸟讲来应该很详细咯.先做好首页模板,然后一个一个的挖出来你想要的东西.<br />
想一个问题.<br />
index.htm中,有很多分类资讯的,都是调用JS显示的内容,你怎么把它拿过来显示在你的首页中.<br />
希望大家偷的都很顺利.<br />
简单讲下分类的偷取.和偷取首页一样.代码如下:<br />
&lt;?<br />
require &#8216;./commom.php&#8217;;</p>
<p>if($soft){<br />
         update(&#8220;${soft}.htm&#8221;,&#8221;soft&#8221;);<br />
         $file=readfromfile(&#8220;cache/${soft}.htm&#8221;);<br />
}<br />
?&gt;<br />
soft.php<br />
其中$soft就是从前面传递过来的soft.php?id=1234<br />
如果传递过来1234<br />
那么就是更新读取update(&#8220;1234.html&#8221;,&#8221;soft&#8221;);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/284.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP小偷原理实现及改进</title>
		<link>http://www.tisswb.cn/archives/272.html</link>
		<comments>http://www.tisswb.cn/archives/272.html#comments</comments>
		<pubDate>Sat, 07 Mar 2009 20:36:41 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=272</guid>
		<description><![CDATA[PHP小偷程序说白了就是让别人帮你维护你的网站，有点不劳而获的意思。至于这个东西到底是好是坏我们不评价了，还是研究一下程序要紧。
优点：通过PHP小偷我们可以借用别人网站上的信息而不用自己辛苦地去采集
缺点：需要把整页的HTML代码读取到本地,然后通过匹配获取到想要的信息再进行显示,这样大大影响网页的加载速度
改进：通过AJAX异步读取HTML代码,后台进行匹配获取到想要的信息,再显示到前台页面
预备知识：PHP,AJAX,正则表达式
关键字：file_get_contents()  fopen()  fwrite()  eregi()
前三个关键字都是关于PHP文件处理的函数,eregi()是关于正则表达式的函数
PHP小偷原理的实现
一、file_get_contents() fopen() fwrite() 的应用
咱们用华夏黑客牛刀小试吧,把主页的全部信息获取过来
<span class="readmore"><a href="http://www.tisswb.cn/archives/272.html" title="PHP小偷原理实现及改进" target="_blank">阅读全文——共2032字</a></span>]]></description>
			<content:encoded><![CDATA[<p>PHP小偷程序说白了就是让别人帮你维护你的网站，有点不劳而获的意思。至于这个东西到底是好是坏我们不评价了，还是研究一下程序要紧。</p>
<p><strong>优点</strong>：通过PHP小偷我们可以借用别人网站上的信息而不用自己辛苦地去采集</p>
<p><strong>缺点</strong>：需要把整页的HTML代码读取到本地,然后通过匹配获取到想要的信息再进行显示,这样大大影响网页的加载速度</p>
<p><strong>改进</strong>：通过AJAX异步读取HTML代码,后台进行匹配获取到想要的信息,再显示到前台页面</p>
<p><strong>预备知识</strong>：PHP,AJAX,正则表达式</p>
<p><strong>关键字</strong>：file_get_contents()  fopen()  fwrite()  eregi()</p>
<p>前三个关键字都是关于PHP文件处理的函数,eregi()是关于正则表达式的函数</p>
<p>PHP小偷原理的实现</p>
<p>一、file_get_contents() fopen() fwrite() 的应用</p>
<p>咱们用华夏黑客牛刀小试吧,把主页的全部信息获取过来</p>
<p>建立一个PHP文件</p>
<p><code lang="php"><br />
&lt; ?php<br />
$url = 'http://www.77169.com/';<br />
//file_get_contents（）函数获取网页的html文档<br />
$file = file_get_contents ( $url );<br />
//建立一个新文件ImitationIndex.htm<br />
$newfile = fopen ( 'ImitationIndex.htm', 'w' );<br />
//把内容读取进去<br />
fwrite ( $newfile, $file );<br />
//关闭打开的文件<br />
fclose ( $newfile );<br />
?&gt;<br />
</code><br />
ImitationIndex.htm获取主页全部的HTML(保存好,以备下次使用)</p>
<p>二、eregi()函数的应用</p>
<p>通过eregi()获取里的内容</p>
<div><code lang="php"><br />
&lt; ?php<br />
$url = 'http://www.77169.com/';<br />
//file_get_contents（）函数获取网页的html文档<br />
$file = file_get_contents ( $url );<br />
//通过eregi()匹配获取想要的信息<br />
eregi ( '之间的内容</code></div>
<div><code lang="php">　　从上面的两个例子,已经知道PHP小偷的实现原理,从中也知道它的不足之处,但通过AJAX可以完善它,使它可以用于实践项目中</code></div>
<p><code lang="php">　　PHP小偷技术的实用和改进</p>
<p>　　目的:获取华夏黑客的最新资讯,并实时更新查看示例<br />
实际中可能只用到三个页面</p>
<p>　　showNews.php,Update.php,HackNews.htm</p>
<p>　　但为了能看到实时更新的效果,这里用到了模拟主页的页面ImitationIndex.htm</p>
<div><code lang="html"><br />
<!--<br />
body {<br />
background: #c60;<br />
}</div>
<div mce_tmp="1">a {<br />
color: #444;<br />
font: 12px Courier New;<br />
padding: 8px;<br />
}</div>
<div mce_tmp="1">a:hover {<br />
color: #f00<br />
}</div>
<div mce_tmp="1">#hei_content {<br />
width: 400px;<br />
background: #ccc;<br />
border: 2px solid #000;<br />
border-bottom: 5px solid #000;<br />
}<br />
--></div>
<p></code><code lang="html">&lt; ?php<br />
echo ('<br />
</code></p>
<div></div>
</div>
<p> </p>
<p></code><code lang="html"></p>
<div id="hei_content">');<br />
include ('HackNews.htm');<br />
echo ('');<br />
?&gt;<br />
<script type="text/javascript"><!--
window.onload=UpdateNews;
function GetXmlHttp()
{
var xmlhttp;
try
{
//IE7.0 ect
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}</p>
<p>catch(a)
{
try
{
//ie6.0 ect
xmlhttp=new ActiveXObject("Mscrosoft.XMLHTTP");
}
catch(b)
{
//非IE
xmlhttp=new XMLHttpRequest();
}
}
return xmlhttp;
}
function StateChange()
{
if(xmlhttp.readyState==4&#038;&#038;xmlhttp.status==200)
{
document.getElementById("hei_content").innerHTML=xmlhttp.responseText;
}
}
function UpdateNews()
{
xmlhttp=GetXmlHttp();
xmlhttp.onreadystatechange=StateChange;</p>
<p>var url='Update.php';
url=url+"?sid="+Math.random();
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
// --></script></div>
<p>showNews.php中的</p>
<div><code lang="php"><br />
echo('</code></div>
<p></code><code lang="php"></p>
<div id="hei_content">');<br />
include('HackNews.htm');<br />
echo('</div>
<p>');</p>
<p></code></p>
<p>　　HackNews.htm是已经缓存的文件,这样不用加载主页上的整个HTML再显示,这个工作留给AJAX</p>
<p>　　document.getElementById(&#8220;hei_content&#8221;).innerHTML=xmlhttp.responseText</p>
<p>　　xmlhttp.responseText就是加载更新后的内容</p>
<p>　　Update.php</p>
<div><code lang="html"><br />
&lt; ?php<br />
$url = 'ImitationIndex.htm';<br />
//file_get_contents（）函数获取网页的html文档<br />
$file = file_get_contents ( $url );<br />
//$regx为正则表达式的内容,用于匹配获取想要的信息<br />
$regx = '</code></div>
<p><code lang="html"></p>
<td colspan="3" height="100" background="http://hack.77169.com/20090220100422648.gif"> </td>
<p> (.*)<br />
&lt; /td&gt;<br />
&lt; /tr&gt;<br />
&lt; /table&gt;<br />
&lt; /td&gt;<br />
&lt; /tr&gt;</p>
<td colspan="3"> </td>
<p> <img src="" alt="" height="8" /> //eregi()获取匹配到的内容,赋值给数组变量$rg;<br />
eregi ( $regx, $file, $rg );<br />
//建立一个新文件HackNews.htm<br />
$newfile = fopen ( 'HackNews.htm', 'w' );<br />
//把内容读取进去<br />
fwrite ( $newfile, $rg [1] );<br />
fclose ( $newfile );<br />
//用iconv编码转换后,输出匹配的HTML内容<br />
$rg [1] = iconv ( 'gb2312', 'utf-8', $rg [1] );<br />
echo ($rg [1]);<br />
?/&gt; </p>
<p>　　Update.php是异步更新的后台页面</p>
<p></code></p>
<p>　　$newfile=fopen(&#8216;HackNews.htm&#8217;,'w&#8217;);</p>
<p>　　fwrite($newfile,$rg[1]);</p>
<p>　　把更新的内容重新保存在HackNews.htm中,下次在index.php中include时就直接调用这个页面</p>
<p>　　$url=&#8217;ImitationIndex.htm&#8217;在实际应用中应该是这样$url=&#8217;http://www.77169.com/&#8217;</p>
<p>　　但为了便于调试,建立一个ImitationIndex.htm模拟页面,如果对ImitationIndex.htm页面中最新资讯中的内容改改,就可以看到实时更新效果。</p>
<p>　　总结:通过AJAX改进的PHP小偷技术,在采集多个网站的大量信息下,页面的加载速度并不会受多大影响。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/272.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP采集程序中常用的函数</title>
		<link>http://www.tisswb.cn/archives/259.html</link>
		<comments>http://www.tisswb.cn/archives/259.html#comments</comments>
		<pubDate>Sat, 07 Mar 2009 19:52:41 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=259</guid>
		<description><![CDATA[网上找到的，给大家总结一下：

//获得当前的脚本网址
function get_php_url(){
        if(!empty($_SERVER["REQUEST_URI"])){
                $scriptName = $_SERVER["REQUEST_URI"];
                $nowurl = $scriptName;
        }else{
                $scriptName = $_SERVER["PHP_SELF"];
                if(empty($_SERVER["QUERY_STRING"])) $nowurl = $scriptName;
<span class="readmore"><a href="http://www.tisswb.cn/archives/259.html" title="PHP采集程序中常用的函数" target="_blank">阅读全文——共2780字</a></span>]]></description>
			<content:encoded><![CDATA[<p>网上找到的，给大家总结一下：<br />
<code lang="php" linenum="on" download="phpcaiji_function.php"><br />
//获得当前的脚本网址<br />
function get_php_url(){<br />
        if(!empty($_SERVER["REQUEST_URI"])){<br />
                $scriptName = $_SERVER["REQUEST_URI"];<br />
                $nowurl = $scriptName;<br />
        }else{<br />
                $scriptName = $_SERVER["PHP_SELF"];<br />
                if(empty($_SERVER["QUERY_STRING"])) $nowurl = $scriptName;<br />
                else $nowurl = $scriptName."?".$_SERVER["QUERY_STRING"];<br />
        }<br />
        return $nowurl;<br />
}<br />
//把全角数字转为半角数字<br />
function GetAlabNum($fnum){<br />
        $nums = array("０","１","２","３","４","５","６","７","８","９");<br />
        $fnums = "0123456789";<br />
        for($i=0;$i< =9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum);<br />
        $fnum = ereg_replace("[^0-9.]|^0{1,}","",$fnum);<br />
        if($fnum=="") $fnum=0;<br />
        return $fnum;<br />
}<br />
//去除HTML标记<br />
function Text2Html($txt){<br />
        $txt = str_replace("  ","　",$txt);<br />
        $txt = str_replace("<","<",$txt);<br />
        $txt = str_replace(">",">",$txt);<br />
        $txt = preg_replace("/[rn]{1,}/isU","<br />rn",$txt);<br />
        return $txt;<br />
}</p>
<p>//清除HTML标记<br />
function ClearHtml($str){<br />
        $str = str_replace('< ','<',$str);<br />
        $str = str_replace('>','>',$str);<br />
        return $str;<br />
}<br />
//相对路径转化成绝对路径<br />
function relative_to_absolute($content, $feed_url) {<br />
    preg_match('/(http|https|ftp):///', $feed_url, $protocol);<br />
    $server_url = preg_replace("/(http|https|ftp|news):///", "", $feed_url);<br />
    $server_url = preg_replace("//.*/", "", $server_url);</p>
<p>    if ($server_url == '') {<br />
        return $content;<br />
    }</p>
<p>    if (isset($protocol[0])) {<br />
        $new_content = preg_replace('/href="//', 'href="'.$protocol[0].$server_url.'/', $content);<br />
        $new_content = preg_replace('/src="//', 'src="'.$protocol[0].$server_url.'/', $new_content);<br />
    } else {<br />
        $new_content = $content;<br />
    }<br />
    return $new_content;<br />
}<br />
//取得所有链接<br />
function get_all_url($code){<br />
        preg_match_all('/<a s+href=["|']?([^>"' ]+)["|']?s*[^>]*>([^>]+)< /a>/i',$code,$arr);<br />
        return array('name'=>$arr[2],'url'=>$arr[1]);<br />
}</p>
<p>//获取指定标记中的内容<br />
function get_tag_data($str, $start, $end){<br />
        if ( $start == '' || $end == '' ){<br />
               return;<br />
        }<br />
        $str = explode($start, $str);<br />
        $str = explode($end, $str[1]);<br />
        return $str[0];<br />
}<br />
//HTML表格的每行转为CSV格式数组<br />
function get_tr_array($table) {<br />
        $table = preg_replace("'
<td [^>]*?>'si",'"',$table);<br />
        $table = str_replace("</td>
<p>",'",',$table);<br />
        $table = str_replace("","{tr}",$table);<br />
        //去掉 HTML 标记<br />
        $table = preg_replace("'< [/!]*?[^<>]*?>'si","",$table);<br />
        //去掉空白字符<br />
        $table = preg_replace("'([rn])[s]+'","",$table);<br />
        $table = str_replace(" ","",$table);<br />
        $table = str_replace(" ","",$table);</p>
<p>        $table = explode(",{tr}",$table);<br />
        array_pop($table);<br />
        return $table;<br />
}</p>
<p>//将HTML表格的每行每列转为数组，采集表格数据<br />
function get_td_array($table) {<br />
        $table = preg_replace("'<br />
<table [^>]*?>'si","",$table);<br />
        $table = preg_replace("'<br />
<tr [^>]*?>'si","",$table);<br />
        $table = preg_replace("'
<td [^>]*?>'si","",$table);<br />
        $table = str_replace("</td>
</tr>
<p>","{tr}",$table);<br />
        $table = str_replace("","{td}",$table);<br />
        //去掉 HTML 标记<br />
        $table = preg_replace("'< [/!]*?[^<>]*?>'si","",$table);<br />
        //去掉空白字符<br />
        $table = preg_replace("'([rn])[s]+'","",$table);<br />
        $table = str_replace(" ","",$table);<br />
        $table = str_replace(" ","",$table);</p>
<p>        $table = explode('{tr}', $table);<br />
        array_pop($table);<br />
        foreach ($table as $key=>$tr) {<br />
                $td = explode('{td}', $tr);<br />
                array_pop($td);<br />
            $td_array[] = $td;<br />
        }<br />
        return $td_array;<br />
}</p>
<p>//返回字符串中的所有单词 $distinct=true 去除重复<br />
function split_en_str($str,$distinct=true) {<br />
        preg_match_all('/([a-zA-Z]+)/',$str,$match);<br />
        if ($distinct == true) {<br />
                $match[1] = array_unique($match[1]);<br />
        }<br />
        sort($match[1]);<br />
        return $match[1];<br />
}<br />
</table>
<p></a></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/259.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP学习——获得URL信息的类</title>
		<link>http://www.tisswb.cn/archives/255.html</link>
		<comments>http://www.tisswb.cn/archives/255.html#comments</comments>
		<pubDate>Sat, 07 Mar 2009 19:32:10 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=255</guid>
		<description><![CDATA[获取URL信息的类
使用这个类，你能获得URL的如下信息：
- Host
- Path
- Statuscode (eg. 404,200, &#8230;)
- HTTP Version
- Server
- Content Type
- Date
- The whole header string of the URL
<span class="readmore"><a href="http://www.tisswb.cn/archives/255.html" title="PHP学习——获得URL信息的类" target="_blank">阅读全文——共5315字</a></span>]]></description>
			<content:encoded><![CDATA[<p>获取URL信息的类<br />
使用这个类，你能获得URL的如下信息：<br />
- Host<br />
- Path<br />
- Statuscode (eg. 404,200, &#8230;)<br />
- HTTP Version<br />
- Server<br />
- Content Type<br />
- Date<br />
- The whole header string of the URL</p>
<p><code lang="php" linenum="on"><br />
< ?php<br />
/**<br />
 * Class for getting information about URL's<br />
 * @author Sven Wagener <[email]sven.wagener@intertribe.de[/email]><br />
 * @copyright Intertribe limited<br />
 * @PHP中文社区收集整理 [url]www.phpNet.cn[/url]<br />
 * @include Funktion:_include_<br />
 */<br />
class url {<br />
	var $url = "";<br />
	var $url_host;<br />
	var $url_path;<br />
	var $file = "";<br />
	var $code = "";<br />
	var $code_desc = "";<br />
	var $http_version = ""; // Variable for HTTP version<br />
	var $header_stream;<br />
	var $header_array;<br />
	var $timeout = "1";<br />
	/**<br />
	 * Constructor of class url<br />
	 * @param string $url the complete url<br />
	 * @desc Constructor of class url<br />
	 */<br />
	function url($url) {<br />
		$this->url = $url;<br />
		$url_array = parse_url ( $this->url );<br />
		$this->url_host = $url_array ['host'];<br />
		$this->url_path = $url_array ['path'];<br />
		if ($this->url_path == "") {<br />
			$this->url_path = "/";<br />
		}<br />
		$this->refresh_headerinfo ();<br />
	}<br />
	/**<br />
	 * Returns the whole url<br />
	 * @return string $url the whole url<br />
	 * @desc Returns the whole url<br />
	 */<br />
	function get_url() {<br />
		return $this->url;<br />
	}<br />
	/**<br />
	 * Returns the host of the url<br />
	 * @return string $url_host the host of the url<br />
	 * @desc Returns the host of the url<br />
	 */<br />
	function get_url_host() {<br />
		return $this->url_host;<br />
	}<br />
	/**<br />
	 * Returns the path of the url<br />
	 * @return string $url_path the path of the url<br />
	 * @desc Returns the path of the url<br />
	 */<br />
	function get_url_path() {<br />
		return $this->url_path;<br />
	}<br />
	/**<br />
	 * Returns the status code of the url<br />
	 * @return string $status_code the status code<br />
	 * @desc Returns the status code of the url<br />
	 */<br />
	function get_statuscode() {<br />
		return $this->code;<br />
	}<br />
	/**<br />
	 * Returns the status code description of the url<br />
	 * @return string $status_code_desc the status code description<br />
	 * @desc Returns the status code description of the url<br />
	 */<br />
	function get_statuscode_desc() {<br />
		return $this->code_desc;<br />
	}<br />
	/**<br />
	 * Returns the http version of the url by the returned headers of the server<br />
	 * @return string $http_version the http version<br />
	 * @desc Returns the http version of the url by the returned headers of the server<br />
	 */<br />
	function get_info_http_version() {<br />
		return $this->http_version;<br />
	}<br />
	/**<br />
	 * Returns the server type of the url's host by the returned headers of the server<br />
	 * @return string header_array['Server'] the server type<br />
	 * @desc Returns the server type of the url's host by the returned headers of the server<br />
	 */<br />
	function get_info_server() {<br />
		return $this->header_array ['Server'];<br />
	}<br />
	/**<br />
	 * Returns the date of the url's host by the returned headers of the server<br />
	 * @return string $header_array['Date'] the date<br />
	 * @desc Returns the date of the url's host by the returned headers of the server<br />
	 */<br />
	function get_info_date() {<br />
		return $this->header_array ['Date'];<br />
	}<br />
	/*<br />
function get_info_content_length(){<br />
return $this->header_array['Content-Length'];<br />
}<br />
*/<br />
	/**<br />
	 * Returns the content type by the returned headers of the server<br />
	 * @return string header_array['Content-Type'] the content type<br />
	 * @desc Returns the content type by the returned headers of the server<br />
	 */<br />
	function get_info_content_type() {<br />
		return $this->header_array ['Content-Type'];<br />
	}<br />
	/**<br />
	 * Returns the content of the url without the headers<br />
	 * @return string $content the content<br />
	 * @desc Returns the content of the url without the headers<br />
	 */<br />
	function get_content() {<br />
		// Get a web page into a string<br />
		$string = implode ( '', file ( $this->url ) );<br />
		return $string;<br />
	}<br />
	/**<br />
	 * Returns the whole header of url without content<br />
	 * @return string $header the header<br />
	 * @desc Returns the whole header of url without content<br />
	 */<br />
	function get_header_stream() {<br />
		return $this->header_stream;<br />
	}<br />
	/**<br />
	 * Returns the whole headers of the url in an array<br />
	 * @return array $header_array the headers in an array<br />
	 * @desc Returns the whole headers of the url in an array<br />
	 */<br />
	function get_headers() {<br />
		return $this->header_array;<br />
	}<br />
	/**<br />
	 * Refreshes the header information<br />
	 * @desc Refreshes the header information<br />
	 */<br />
	function refresh_headerinfo() {<br />
		// Open socket for connection via port 80 to put headers<br />
		$fp = fsockopen ( $this->url_host, 80, $errno, $errstr, 30 );<br />
		if (! $fp) {<br />
			// echo "$errstr ($errno)";<br />
			if ($errno == 0) {<br />
				$errstr = "Server Not Found";<br />
			}<br />
			$this->code = $errno;<br />
			$this->code_desc = $errstr;<br />
		} else {<br />
			$put_string = "GET " . $this->url_path . " HTTP/1.0rnHost: " . $this->url_host . "rnrn";<br />
			fputs ( $fp, $put_string );<br />
			@socket_set_timeout ( $fp, $this->timeout );<br />
			$stream = "";<br />
			$this->header_array = "";<br />
			$header_end = false;<br />
			// Getting header string and creating header array<br />
			$i = 0;<br />
			while ( ! feof ( $fp ) &#038;&#038; ! $header_end ) {<br />
				$line = fgets ( $fp, 128 );<br />
				if (strlen ( $line ) == 2) {<br />
					$header_end = true;<br />
				} else {<br />
					if ($i == 0) {<br />
						$line1 = $line;<br />
					}<br />
					$stream .= $line;<br />
					$splitted_line = split ( ":", $line );<br />
					$this->header_array [$splitted_line [0]] = $splitted_line [1];<br />
					$i ++;<br />
				}<br />
			}<br />
			fclose ( $fp );<br />
			$this->header_stream = $stream;<br />
			$splitted_stream = split ( " ", $line1 );<br />
			// Getting status code and description of the URL<br />
			$this->code = $splitted_stream [1];<br />
			$this->code_desc = $splitted_stream [2];<br />
			if (count ( $splitted_stream ) > 3) {<br />
				for($i = 3; $i < count ( $splitted_stream ); $i ++) {<br />
					$this->code_desc .= " " . $splitted_stream [$i];<br />
				}<br />
			}<br />
			// Cleaning up for n and r<br />
			$this->code_desc = preg_replace ( "[n]", "", $this->code_desc );<br />
			$this->code_desc = preg_replace ( "[r]", "", $this->code_desc );<br />
			// Getting Http Version<br />
			$http_array = split ( "/", $splitted_stream [0] );<br />
			$this->http_version = $http_array [1];<br />
		}<br />
	}<br />
	/**<br />
	 * Sets the timeout for getting header data from server<br />
	 * @param int $seconds time for timeout in seconds<br />
	 * @desc Sets the timeout for getting header data from server<br />
	 */<br />
	function set_timeout($seconds) {<br />
		$this->timeout = $seconds;<br />
	}<br />
}<br />
?><br />
</code></p>
<p>调用代码：<br />
<code lang="php" linenum="on"><br />
< ?php<br />
include ("url.class.php");<br />
$url = new url ( "[url]http://www.phpNet.cn/[/url]" );<br />
echo $url->get_header_stream ();<br />
$headers = $url->get_headers ();<br />
echo $headers ['Server'];<br />
echo $url->get_content ();<br />
echo "URL: <b>" . $url->get_url () . "</b><br />n";<br />
echo "URL Host: " . $url->get_url_host () . "<br />n";<br />
echo "URL Path: " . $url->get_url_path () . "<br />n<br />n";<br />
echo "Statuscode: " . $url->get_statuscode () . "<br />n";<br />
echo "Statuscode description: " . $url->get_statuscode_desc () . "<br />n";<br />
echo "HTTP Version: " . $url->get_info_http_version () . "<br />n";<br />
echo "Server: " . $url->get_info_server () . "<br />n";<br />
echo "Content Type: " . $url->get_info_content_type () . "<br />n";<br />
echo "Date: " . $url->get_info_date () . "<br />n<br />n";<br />
echo "WHOLE HEADERS:<br />n";<br />
echo $url->get_header_stream ();<br />
?> </code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/255.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php按指定大小生成不变形缩略图的函数</title>
		<link>http://www.tisswb.cn/archives/171.html</link>
		<comments>http://www.tisswb.cn/archives/171.html#comments</comments>
		<pubDate>Mon, 27 Oct 2008 08:39:02 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=171</guid>
		<description><![CDATA[今天需要写一个用php生成缩略图的函数，在网上转了转，发现了一个好人写的一段代码，感觉很标准，就拿来给大家分享分享这个按指定大小生成不变形缩略图的函数。
&#60;?php
function image_resize($f, $t, $tw, $th){
// 按指定大小生成缩略图，而且不变形，缩略图函数
// Cos.x 2007-9-5
        $temp = array(1=&#62;&#8217;gif&#8217;, 2=&#62;&#8217;jpeg&#8217;, 3=&#62;&#8217;png&#8217;);
        list($fw, $fh, $tmp) = getimagesize($f);
        if(!$temp[$tmp]){
                return false;
        }
<span class="readmore"><a href="http://www.tisswb.cn/archives/171.html" title="php按指定大小生成不变形缩略图的函数" target="_blank">阅读全文——共664字</a></span>]]></description>
			<content:encoded><![CDATA[<p>今天需要写一个用php生成缩略图的函数，在网上转了转，发现了一个好人写的一段代码，感觉很标准，就拿来给大家分享分享这个按指定大小生成不变形缩略图的函数。</p>
<p>&lt;?php<br />
function image_resize($f, $t, $tw, $th){<br />
// 按指定大小生成缩略图，而且不变形，缩略图函数<br />
// Cos.x 2007-9-5<br />
        $temp = array(1=&gt;&#8217;gif&#8217;, 2=&gt;&#8217;jpeg&#8217;, 3=&gt;&#8217;png&#8217;);</p>
<p>        list($fw, $fh, $tmp) = getimagesize($f);</p>
<p>        if(!$temp[$tmp]){<br />
                return false;<br />
        }<br />
        $tmp = $temp[$tmp];<br />
        $infunc = &#8220;imagecreatefrom$tmp&#8221;;<br />
        $outfunc = &#8220;image$tmp&#8221;;</p>
<p>        $fimg = $infunc($f);</p>
<p>        if($fw/$tw &gt; $fh/$th){<br />
                $fw = $tw * ($fh/$th);<br />
        }else{<br />
                $fh = $th * ($fw/$tw);<br />
        }</p>
<p>        $timg = imagecreatetruecolor($tw, $th);<br />
        imagecopyresampled($timg, $fimg, 0,0, 0,0, $tw,$th, $fw,$fh);<br />
        if($outfunc($timg, $t)){<br />
                return true;<br />
        }else{<br />
                return false;<br />
        }<br />
}<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/171.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php学习点滴-Failed to initialize storage module解决方法</title>
		<link>http://www.tisswb.cn/archives/119.html</link>
		<comments>http://www.tisswb.cn/archives/119.html#comments</comments>
		<pubDate>Sat, 20 Sep 2008 13:48:53 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=119</guid>
		<description><![CDATA[今天更新了一下自己的cms，然后后台就提示登陆不了，报错如下：Failed to initialize storage module。
解决方法有两种如下：
1。在报错的文件里的session start();之前加入如下代码：ini_set(&#8216;session.save_handler&#8217;, &#8216;files&#8217;); 。这种方法适合租用空间的用户使用。
2。在php.ini文件里，显式指定session的save_path(比如 c:/temp)然后重启web服务。如果服务器的管理权限属于你，那还是这样改比较方便。
原因分析：php5一个安全模式的bug，默认session的save_path是系统的临时目录，这样会要校验权限。
]]></description>
			<content:encoded><![CDATA[<p>今天更新了一下自己的cms，然后后台就提示登陆不了，报错如下：Failed to initialize storage module。</p>
<p>解决方法有两种如下：</p>
<p>1。在报错的文件里的session start();之前加入如下代码：ini_set(&#8216;session.save_handler&#8217;, &#8216;files&#8217;); 。这种方法适合租用空间的用户使用。</p>
<p>2。在php.ini文件里，显式指定session的save_path(比如 c:/temp)然后重启web服务。如果服务器的管理权限属于你，那还是这样改比较方便。</p>
<p>原因分析：php5一个安全模式的bug，默认session的save_path是系统的临时目录，这样会要校验权限。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/119.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php学习点滴-php的函数前的@含义</title>
		<link>http://www.tisswb.cn/archives/114.html</link>
		<comments>http://www.tisswb.cn/archives/114.html#comments</comments>
		<pubDate>Fri, 05 Sep 2008 16:18:21 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php学习点滴]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=114</guid>
		<description><![CDATA[php的函数前的@含义：
例子:$connid=@mysql_connect(&#8220;$hostname&#8221;,&#8221;$dbusename&#8221;,&#8221;$dbpassword&#8221;) or die(&#8220;未连接数据库服务器&#8221;)
其中@表示加到任何函数前，不触发错误提示（如果发生错误的情况下）
]]></description>
			<content:encoded><![CDATA[<p><strong>php的函数前的@含义：</strong></p>
<p>例子:$connid=@mysql_connect(&#8220;$hostname&#8221;,&#8221;$dbusename&#8221;,&#8221;$dbpassword&#8221;) or die(&#8220;未连接数据库服务器&#8221;)</p>
<p>其中@表示加到任何函数前，不触发错误提示（如果发生错误的情况下）</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/114.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get_magic_quotes_gpc 与 addslashes 用法详解</title>
		<link>http://www.tisswb.cn/archives/91.html</link>
		<comments>http://www.tisswb.cn/archives/91.html#comments</comments>
		<pubDate>Thu, 24 Jul 2008 16:18:01 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=91</guid>
		<description><![CDATA[int get_magic_quotes_gpc ( void )
本函式取得 PHP 环境设定的变数 magic_quotes_gpc (GPC, Get/Post/Cookie) 值。传回 0 表示关闭本功能；传回 1 表示本功能开启。当 magic_quotes_gpc 开启时，所有的 &#8216; (单引号), &#8221; (双引号),  (反斜线) and 空字符会自动转为含有反斜线的溢出字符。
string addslashes ( string str )
返回字符串，该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号（&#8216;）、双引号（&#8220;）、反斜线（）与 NUL（NULL 字符）。
一个使用 addslashes() 的例子是当你要往数据库中输入数据时。例如，将名字 O&#8217;reilly 插入到数据库中，这就需要对其进行转义。大多数据库使用  作为转义符：O&#8217;reilly。这样可以将数据放入数据库中，而不会插入额外的 。当 PHP 指令 magic_quotes_sybase 被设置成 on 时，意味着插入 &#8216; 时将使用 &#8216; 进行转义。
<span class="readmore"><a href="http://www.tisswb.cn/archives/91.html" title="get_magic_quotes_gpc 与 addslashes 用法详解" target="_blank">阅读全文——共694字</a></span>]]></description>
			<content:encoded><![CDATA[<p>int <strong class="methodname">get_magic_quotes_gpc</strong> ( void )</p>
<p>本函式取得 PHP 环境设定的变数 magic_quotes_gpc (GPC, Get/Post/Cookie) 值。传回 0 表示关闭本功能；传回 1 表示本功能开启。当 magic_quotes_gpc 开启时，所有的 &#8216; (单引号), &#8221; (双引号),  (反斜线) and 空字符会自动转为含有反斜线的溢出字符。</p>
<p>string <strong class="methodname">addslashes</strong> ( string str )</p>
<p>返回字符串，该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号（<var class="literal">&#8216;</var>）、双引号（<var class="literal">&#8220;</var>）、反斜线（<var class="literal"></var>）与 NUL（<tt class="constant"><strong><span style="font-family: 新宋体;">NULL</span></strong></tt> 字符）。</p>
<p>一个使用 <strong class="function">addslashes()</strong> 的例子是当你要往数据库中输入数据时。例如，将名字 <var class="literal">O&#8217;reilly</var> 插入到数据库中，这就需要对其进行转义。大多数据库使用 <var class="literal"></var> 作为转义符：<var class="literal">O&#8217;reilly</var>。这样可以将数据放入数据库中，而不会插入额外的 <var class="literal"></var>。当 PHP 指令 magic_quotes_sybase 被设置成 <var class="literal">on</var> 时，意味着插入 <var class="literal">&#8216;</var> 时将使用 <var class="literal">&#8216;</var> 进行转义。</p>
<p>默认情况下，PHP 指令 magic_quotes_gpc 为 <var class="literal">on</var>，它主要是对所有的 GET、POST 和 COOKIE 数据自动运行 <strong class="function">addslashes()</strong>。不要对已经被 magic_quotes_gpc 转义过的字符串使用 <strong class="function">addslashes()</strong>，因为这样会导致双层转义。遇到这种情况时可以使用函数 <strong class="function">get_magic_quotes_gpc()</strong> 进行检测。</p>
<p>所以我们自定义一个转义函数：</p>
<p>function my_addslashes($str){<br />
return get_magic_quotes_gpc() ? $str : addslashes($str);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/91.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5中的this,self和parent关键字详解</title>
		<link>http://www.tisswb.cn/archives/89.html</link>
		<comments>http://www.tisswb.cn/archives/89.html#comments</comments>
		<pubDate>Thu, 24 Jul 2008 15:55:29 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=89</guid>
		<description><![CDATA[PHP5是一具备了大部分面向对象语言的特性的语言,比PHP4有了很多的面向对象的特性,但是有部分概念也比较绕人,所以今天拿出来说说,说的不好,请高手见谅. (阅读本文，需要了解PHP5的面向对象的知识)
首先我们来明白上面三个关键字: this,self,parent,从字面上比较好理解,是指这,自己,父亲,呵呵,比较好玩了,我们先建立几个概念,这三个关键字分别是用在什么地方呢?我们初步解释一下,this是指向当前对象的指针(我们姑且用C里面的指针来看吧),self是指向当前类的指针,parent是指向父类的指针。我们这里频繁使用指针来描述，是因为没有更好的语言来表达，呵呵，语文没学好。 -_-#
这么说还不能很了解，那我们就根据实际的例子结合来讲讲。
(1) this
1 &#60;?php
2
3 class UserName
4 { 
5     //定义属性   
6     private $name;
<span class="readmore"><a href="http://www.tisswb.cn/archives/89.html" title="PHP5中的this,self和parent关键字详解" target="_blank">阅读全文——共3032字</a></span>]]></description>
			<content:encoded><![CDATA[<p>PHP5是一具备了大部分面向对象语言的特性的语言,比PHP4有了很多的面向对象的特性,但是有部分概念也比较绕人,所以今天拿出来说说,说的不好,请高手见谅. (阅读本文，需要了解PHP5的面向对象的知识)</p>
<p>首先我们来明白上面三个关键字: this,self,parent,从字面上比较好理解,是指这,自己,父亲,呵呵,比较好玩了,我们先建立几个概念,这三个关键字分别是用在什么地方呢?我们初步解释一下,this是指向当前对象的指针(我们姑且用C里面的指针来看吧),self是指向当前类的指针,parent是指向父类的指针。我们这里频繁使用指针来描述，是因为没有更好的语言来表达，呵呵，语文没学好。 -_-#</p>
<p>这么说还不能很了解，那我们就根据实际的例子结合来讲讲。<br />
<strong><span style="color: #000080; background-color: #ffffff;">(1) this</span></strong></p>
<p>1 &lt;?php<br />
2<br />
3 class UserName<br />
4 { <br />
5     //定义属性   <br />
6     private $name;<br />
7 <br />
8     //定义构造函数<br />
9     function __construct( $name )<br />
10     {<br />
11          $this-&gt;name = $name; //这里已经使用了this指针<br />
12     }<br />
13 <br />
14     //析构函数<br />
15     function __destruct(){}<br />
16<br />
17     //打印用户名成员函数<br />
18     function printName()<br />
19     {<br />
20          print( $this-&gt;name ); //又使用了this指针<br />
21     }<br />
22 }<br />
23<br />
24 //实例化对象<br />
25 $nameObject = new UserName( &#8220;heiyeluren&#8221; );<br />
26<br />
27 //执行打印<br />
28 $nameObject-&gt;printName(); //输出: heiyeluren<br />
29<br />
30 //第二次实例化对象<br />
31 $nameObject2 = new UserName( &#8220;PHP5&#8243; );<br />
32<br />
33 //执行打印<br />
34 $nameObject2-&gt;printName(); //输出：PHP5<br />
35 ?&gt;</p>
<p>我们看，上面的类分别在11行和20行使用了this指针，那么当时this是指向谁呢？其实this是在实例化的时候来确定指向谁，比如第一次实例化对象的时候(25行)，那么当时this就是指向$nameObject对象，那么执行18行的打印的时候就把print( $this-&gt;&lt;name )变成了print( $nameObject-&gt;name )，那么当然就输出了&#8221;heiyeluren&#8221;。第二个实例的时候，print( $this-&gt;name )变成了print( $nameObject2-&gt;name )，于是就输出了&#8221;PHP5&#8243;。所以说，this就是指向当前对象实例的指针，不指向任何其他对象或类。</p>
<p> </p>
<p><strong><span style="color: #000080; background-color: #ffffff;">(2)self</span></strong></p>
<p>首先我们要明确一点，self是指向类本身，也就是self是不指向任何已经实例化的对象，一般self使用来指向类中的静态变量。</p>
<p>1 &lt;?php<br />
2<br />
3     class Counter<br />
4     {<br />
5         //定义属性，包括一个静态变量<br />
6         private static $firstCount = 0;<br />
7         private $lastCount;<br />
8<br />
9         //构造函数<br />
10         function __construct()<br />
11         {<br />
12              $this-&gt;lastCount = ++selft::$firstCount; //使用self来调用静态变量,使用self调用必须使用::(域运算符号)<br />
13         }<br />
14<br />
15         //打印最次数值<br />
16         function printLastCount()<br />
17         {<br />
18              print( $this-&gt;lastCount );<br />
19         } <br />
20     }<br />
21<br />
22 //实例化对象<br />
23 $countObject = new Counter();<br />
24<br />
25 $countObject-&gt;printLastCount(); //输出 1<br />
26<br />
27 ?&gt;</p>
<p>我们这里只要注意两个地方，第6行和第12行。我们在第二行定义了一个静态变量$firstCount，并且初始值为0，那么在12行的时候调用了这个值得，使用的是self来调用，并且中间使用&#8221;::&#8221;来连接，就是我们所谓的域运算符，那么这时候我们调用的就是类自己定义的静态变量$frestCount，我们的静态变量与下面对象的实例无关，它只是跟类有关，那么我调用类本身的的，那么我们就无法使用this来引用，可以使用self来引用，因为self是指向类本身，与任何对象实例无关。换句话说，假如我们的类里面静态的成员，我们也必须使用self来调用。<br />
<span style="color: #000080; background-color: #ffffff;"><strong>(3)parent</strong></span></p>
<p>我们知道parent是指向父类的指针，一般我们使用parent来调用父类的构造函数。</p>
<p>1 &lt;?php<br />
2<br />
3 //基类<br />
4 class Animal<br />
5 {<br />
6     //基类的属性<br />
7     public $name; //名字<br />
8<br />
9     //基类的构造函数<br />
10     public function __construct( $name )<br />
11     {<br />
12          $this-&gt;name = $name;<br />
13     }<br />
14 }<br />
15<br />
16 //派生类<br />
17 class Person extends Animal //Person类继承了Animal类<br />
18 {<br />
19     public $personSex; //性别<br />
20     public $personAge; //年龄<br />
21<br />
22     //继承类的构造函数<br />
23     function __construct( $personSex, $personAge )<br />
24     {<br />
25          parent::__construct( &#8220;heiyeluren&#8221; ); //使用parent调用了父类的构造函数<br />
26          $this-&gt;personSex = $personSex;<br />
27          $this-&gt;personAge = $personAge;<br />
28     }<br />
29<br />
30     function printPerson()<br />
31     {<br />
32          print( $this-&gt;name. &#8221; is &#8221; .$this-&gt;personSex. &#8220;,this year &#8221; .$this-&gt;personAge );<br />
33      }<br />
34 }<br />
35<br />
36 //实例化Person对象<br />
37 $personObject = new Person( &#8220;male&#8221;, &#8220;21&#8243;);<br />
38<br />
39 //执行打印<br />
40 $personObject-&gt;printPerson(); //输出：heiyeluren is male,this year 21<br />
41<br />
42 ?&gt;<br />
我们注意这么几个细节：成员属性都是public的，特别是父类的，是为了供继承类通过this来访问。我们注意关键的地方，第25行：parent::__construct( &#8220;heiyeluren&#8221; ),这时候我们就使用parent来调用父类的构造函数进行对父类的初始化，因为父类的成员都是public的，于是我们就能够在继承类中直接使用this来调用。<br />
总结：</p>
<p>this是指向对象实例的一个指针，self是对类本身的一个引用，parent是对父类的引用。</p>
<p>基本上我所了解就这么多，肯定有理解错误之处，请高手指出！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/89.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP中利用GD库输出图像和汉字实例</title>
		<link>http://www.tisswb.cn/archives/88.html</link>
		<comments>http://www.tisswb.cn/archives/88.html#comments</comments>
		<pubDate>Wed, 23 Jul 2008 10:58:47 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[GD编程]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=88</guid>
		<description><![CDATA[一、原理
PHP中的GD库支持中文，但是必须要以UTF-8格式的参数来进行传递。下面先说一下汉字的UTF-8编码的求得。
用WORD2000或WINDOW 2000下的记事本编辑所要显示的汉字。 
把所编辑的文字存成格式为UTF-8格式的文件。 
用一个16进制的编辑器(如用PCTOOLS的EDIT功能)打开这个文件，这时会看到打开的文件里面有一些16进制的字符。一个汉字占三个字节，所以应该选择编辑汉字个数乘以3个字节的内容，把此编码记录下来以备后用。如赛迪网的代码是：E8 B5 9B E8 BF AA E7 BD 91
二、实现
本例中实现：赛迪网 www.tisswb.cn的图像输出。文件名为:ttf.php。&#60;?php
//定义输出为图像类型
header(&#8220;content-type:image/gif&#8221;);
//新建图象
<span class="readmore"><a href="http://www.tisswb.cn/archives/88.html" title="PHP中利用GD库输出图像和汉字实例" target="_blank">阅读全文——共1229字</a></span>]]></description>
			<content:encoded><![CDATA[<table class="wr" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="gray14">一、原理<br />
PHP中的GD库支持中文，但是必须要以UTF-8格式的参数来进行传递。下面先说一下汉字的UTF-8编码的求得。</p>
<p>用WORD2000或WINDOW 2000下的记事本编辑所要显示的汉字。 <br />
把所编辑的文字存成格式为UTF-8格式的文件。 <br />
用一个16进制的编辑器(如用PCTOOLS的EDIT功能)打开这个文件，这时会看到打开的文件里面有一些16进制的字符。一个汉字占三个字节，所以应该选择编辑汉字个数乘以3个字节的内容，把此编码记录下来以备后用。如赛迪网的代码是：E8 B5 9B E8 BF AA E7 BD 91</p>
<p>二、实现<br />
本例中实现：赛迪网 <a href="http://www.tisswb.cn" target="_blank"><span style="color: #261cdc;">www.tisswb.cn</span></a>的图像输出。文件名为:ttf.php。&lt;?php<br />
//定义输出为图像类型<br />
header(&#8220;content-type:image/gif&#8221;);<br />
//新建图象<br />
$pic=imagecreate(240,30);<br />
//定义黑白颜色<br />
$black=imagecolorallocate($pic,0,0,0);<br />
$white=imagecolorallocate($pic,255,255,255);<br />
//定义字体<br />
$font=&#8221;c://WIN2000//fonts//simhei.ttf&#8221;;<br />
//定义输出字体串<br />
$str = chr(0xE8).chr(0xB5).chr(0x9B).chr(0xE8).chr(0xBF).chr(0xAA).chr(0xE7).chr(0xBD).chr(0&#215;91).&#8221; <a href="http://www.ccidnet.com/" target="_blank"><span style="color: #261cdc;">www.tisswb.com</span></a>&#8220;;<br />
//写 TTF 文字到图中<br />
imagettftext($pic,20,0,10,20,$white,$font,$str);<br />
//建立 GIF 图型<br />
imagegif($pic);<br />
//结束图形，释放内存空间<br />
imagedestroy($pic);<br />
?&gt;  </p>
<p>输出结果如图：</p>
<p>说明：<br />
汉字的引用方式为chr(编码)。如chr(0xE8).chr(0xB5).chr(0x9B)显示汉字。 <br />
ImageTTFText(int im, int size, int angle, int x, int y, int col, string fontfile, string text)：本函数将 TTF (TrueType Fonts) 字型文字写入图片。参数 size 为字形的尺寸；angle 为字型的角度，顺时针计算，0 度为水平，也就是三点钟的方向 (由左到右)，90 度则为由下到上的文字；x,y 二参数为文字的坐标值 (原点为左上角)；参数 col 为字的颜色；fontfile 为字型文件名称；text 是字符串内容。 <br />
必须安装GD库才能利用php中的图像处理函数。 <br />
图像引用方式：在需要的地方直接插入：&lt;img src=&#8221;ttf.php&#8221; border=0&gt;即可。</p>
<p>三、结束语<br />
PHP的GD库提供了相当完善的功能，充分利用其功能就能制作出各式各样的图形图像来，这样使页面内容更加丰富。</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/88.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php+mysql数据库编程学习小细节</title>
		<link>http://www.tisswb.cn/archives/87.html</link>
		<comments>http://www.tisswb.cn/archives/87.html#comments</comments>
		<pubDate>Tue, 22 Jul 2008 16:55:58 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=87</guid>
		<description><![CDATA[好多年没写程序了,现在对于php+mysql数据库编程都已经生疏了,最近又重新拾了起来,当然一开始就出现遇见了这样那样的问题.
1.乱码问题
按照以前的习惯写了代码如下；
$link = mysql_connect(&#8216;localhost&#8217;,'hgqy&#8217;,'hgqy&#8217;);　//连接数据服务器
mysql_select_db(&#8216;hgqy&#8217; , $link);　　//选择数据库
$sql = &#8220;select * from `plug＿qiye` where cpname = &#8216;济南&#8217;&#8221;;
$query = mysql_query($sql) or die(&#8220;查询失败&#8221; . mysql_error());　//执行数据查询语句
$row = mysql_fetch_array($query);
<span class="readmore"><a href="http://www.tisswb.cn/archives/87.html" title="php+mysql数据库编程学习小细节" target="_blank">阅读全文——共522字</a></span>]]></description>
			<content:encoded><![CDATA[<p>好多年没写程序了,现在对于php+mysql数据库编程都已经生疏了,最近又重新拾了起来,当然一开始就出现遇见了这样那样的问题.<br />
1.<strong>乱码问题</strong><br />
按照以前的习惯写了代码如下；</p>
<blockquote><p>$link = mysql_connect(&#8216;localhost&#8217;,'hgqy&#8217;,'hgqy&#8217;);　//连接数据服务器</p>
<p>mysql_select_db(&#8216;hgqy&#8217; , $link);　　//选择数据库</p>
<p>$sql = &#8220;select * from `plug＿qiye` where cpname = &#8216;济南&#8217;&#8221;;</p>
<p>$query = mysql_query($sql) or die(&#8220;查询失败&#8221; . mysql_error());　//执行数据查询语句</p>
<p>$row = mysql_fetch_array($query);</p>
<p>foreach ($row as $i){<br />
　　　echo $i ;<br />
}</p></blockquote>
<p>输出的时候问题来了，没有任何输出，测试了所有我知道的方法，也没找到原因，于是就开始把 cpname = &#8216;济南&#8217;换成了id = 。终于找到问题了，输出的文字部分变成了乱码，傻了眼。<br />
在查阅资料后发现，原来在选择数据库后，需要再做一步</p>
<blockquote><p>mysql_query(&#8220;set names utf8&#8243;) ;　　//设定编码，utf8和gbk可以自行调整。</p></blockquote>
<p>这回终于可以正确输出了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/87.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP实现放大和截取图片</title>
		<link>http://www.tisswb.cn/archives/34.html</link>
		<comments>http://www.tisswb.cn/archives/34.html#comments</comments>
		<pubDate>Sun, 04 May 2008 16:04:25 +0000</pubDate>
		<dc:creator>笨二十一</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web技术]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[截取图片]]></category>

		<guid isPermaLink="false">http://www.tisswb.cn/?p=34</guid>
		<description><![CDATA[一:
我有原图
oldimg.PNG
现在要用php对其放小10%或放大200%怎么写代码啊
二:
我有原图
oldimg.PNG
高为200,宽为300
我要在上面剪切
坐标为
<span class="readmore"><a href="http://www.tisswb.cn/archives/34.html" title="PHP实现放大和截取图片" target="_blank">阅读全文——共1021字</a></span>]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: Verdana;">一:<br />
我有原图<br />
oldimg.PNG<br />
现在要用php对其放小10%或放大200%怎么写代码啊</span></p>
<p><span style="font-family: Verdana;">二:<br />
我有原图<br />
oldimg.PNG<br />
高为200,宽为300<br />
我要在上面剪切<br />
坐标为<br />
10,10,50,30<br />
 X,Y,W,H<br />
用php代码怎么在原图上剪切,生存新的图片啊</span></p>
<p><span style="font-family: Verdana;"><br />
1、<br />
&lt;?php<br />
$image = &#8220;oldimg.PNG&#8221;; // 原图<br />
$imgstream = file_get_contents($image);<br />
$im = imagecreatefromstring($imgstream);<br />
$x = imagesx($im);<br />
$y = imagesy($im);//放大200%,缩小雷同<br />
$thumbw = $x*2; // 期望的目标图宽<br />
$thumbh = $y*2; // 期望的目标图高</p>
<p>if(function_exists(&#8220;imagecreatetruecolor&#8221;))<br />
  $dim = imagecreatetruecolor($thumbw, $thumbh); // 创建目标图gd2<br />
else<br />
  $dim = imagecreate($thumbw, $thumbh); // 创建目标图gd1<br />
imagecopyresized ($dim,$im,0,0,0,0,$thumbw,$thumbh,$x,$y);</p>
<p>header (&#8220;Content-type: image/jpeg&#8221;);<br />
imagejpeg ($dim);<br />
?&gt;<br />
2、<br />
&lt;?php<br />
$image = &#8220;oldimg.PNG&#8221;; // 原图<br />
$imgstream = file_get_contents($image);<br />
$im = imagecreatefromstring($imgstream);<br />
$x = imagesx($im);<br />
$y = imagesy($im);</p>
<p>$thumbw = 50; // 期望的目标图宽<br />
$thumbh = 30; // 期望的目标图高</p>
<p>if(function_exists(&#8220;imagecreatetruecolor&#8221;))<br />
  $dim = imagecreatetruecolor($thumbw, $thumbh); // 创建目标图gd2<br />
else<br />
  $dim = imagecreate($thumbw, $thumbh); // 创建目标图gd1<br />
imagecopyresized ($dim,$im,0,0,10,10,$thumbw,$thumbh,$thumbw,$thumbh);</p>
<p>header (&#8220;Content-type: image/jpeg&#8221;);<br />
imagejpeg ($dim);<br />
?&gt;</p>
<p><span style="font-family: Verdana;"> </span></p>
<p><span style="font-family: Verdana;"><span style="font-family: Verdana;"><span style="font-family: Verdana;"><font face="Verdana"> </p>
<p></font></span></span> </p>
<p></span></span></p>
<p> </p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tisswb.cn/archives/34.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
