<?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>Geek is a Lift-Style. &#187; PHP</title>
	<atom:link href="http://www.taiwangeek.com/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.taiwangeek.com</link>
	<description>Time has a wonderful way of showing us what really matters.</description>
	<lastBuildDate>Mon, 23 May 2011 07:18:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Gatorhost pdo don&#8217;t support sqlite3</title>
		<link>http://www.taiwangeek.com/2011-05/gatorhost-pdo-dont-support-sqlite3.html</link>
		<comments>http://www.taiwangeek.com/2011-05/gatorhost-pdo-dont-support-sqlite3.html#comments</comments>
		<pubDate>Mon, 23 May 2011 07:08:48 +0000</pubDate>
		<dc:creator>tung</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[原創]]></category>
		<category><![CDATA[gatorhost]]></category>
		<category><![CDATA[pdo_sqlite]]></category>
		<category><![CDATA[sqlite3]]></category>

		<guid isPermaLink="false">http://www.taiwangeek.com/?p=6432</guid>
		<description><![CDATA[Greetings,
The sqlite PDO extension appears to be loaded properly. However, it appears that the extension supports sqlite2, but not sqlite3. Currently, I see the use of sqlite3 in your scripts. You will need to use sqlite2 instead in order for them to work properly. I apologize for the inconvenience.

Please feel free to ask if you need anything else at all.]]></description>
			<content:encoded><![CDATA[<p>As title </p>
<blockquote><p>
Greetings,<br />
The sqlite PDO extension appears to be loaded properly. However, it appears that the extension supports sqlite2, but not sqlite3. Currently, I see the use of sqlite3 in your scripts. You will need to use sqlite2 instead in order for them to work properly. I apologize for the inconvenience.</p>
<p>Please feel free to ask if you need anything else at all.
</p></blockquote>
<p>But I got a solution ~~<br />
1.</p>
<pre class="brush:shell">
cp -rf /opt/php53/lib/php/extensions/no-debug-non-zts-20090626/* ext/
</pre>
<p>2.conpile the pdo_sqlite.so by your self convert the ext/pdo_sqlite.so</p>
<p>3. change extension_dir in php.ini to the .so file you made.</p>
<pre class="brush:shell">
extension_dir = "/home/xxx/ext"
</pre>
<p>yes all done~~<br />
Something come from here (http://forums.hostgator.com/php-5-3-support-t100928.html)<br />
Hello,</p>
<p>We currently offer PHP 5.3 support on our shared servers as an addition with PHP 5.2.  In order to utilize PHP 5.3 on your domain, place the following code inside the document roots .htaccess file:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" dir="ltr" style="margin: 0px; padding: 6px; border: 1px inset; width: 520px; height: 50px; text-align: left; overflow: auto;">Action application/x-hg-php53 /cgi-sys/php53
AddType application/x-httpd-php53 .php</pre>
</div>
<p>
Thanks Richard for the below information:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Quote:</div>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tbody>
<tr>
<td class="alt2" style="border: 1px inset;">
<p>				CAUTION: For those who use the cPanel &#8220;QuickConfig&#8221; feature, it should be noted that it works by putting a php.ini copy into the /home/username/ folder and setting the suPHP_ConfigPath in your primary .htaccess file to point to that copy.</p>
<p>Because the &#8220;QuickConfig&#8221; php.ini copy is originally based on the php.ini file that is installed as part of the server&#8217;s setup for its default PHP version, there may be serious problems if the user subsequently decides to use some other PHP version. The php.ini copy pointed to by the suPHP_ConfigPath that &#8220;QuickConfig&#8221; sets may contain configuration paths, extensions and other settings that are not suitable for a PHP version that is chosen thereafter. It may even be missing some settings required by the newer version entirely.</p>
<p>As just one of many examples of problems that can thus arise, the PHP 5.3 option discussed by GatorJacob as the topic of this thread differs from PHP 5.2 in the server path that is used for its extension modules &#8211;<br />
PHP 5.2: extension_dir = &#8220;/usr/local/lib/php/extensions/no-debug-non-zts-20060613&#8243;<br />
PHP 5.3: extension_dir = &#8220;/opt/php53/lib/php/extensions/no-debug-non-zts-20090626&#8243;</p>
<p>So, if you&#8217;ve used cPanel&#8217;s &#8220;QuickConfig&#8221; to set up or modify your PHP configuration, get rid of its php.ini copy and the suPHP_ConfigPath pointer to it that &#8220;QuickConfig&#8221; puts in your primary .htaccess file before implementing any PHP version change!</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>Here is a generic fix for the TZ issue</p>
<p>PHP Code:</p>
<div style="margin: 5px 20px 20px;">
<div class="smallfont" style="margin-bottom: 2px;">Code:</div>
<pre class="alt2" dir="ltr" style="margin: 0px; padding: 6px; border: 1px inset; width: 520px; height: 98px; text-align: left; overflow: auto;">// Force PHP 5.3.0+ to take time zone information from OS
if (version_compare(phpversion(), '5.3.0', '&gt;='))
{
    @date_default_timezone_set(date_default_timezone_get());
}</pre>
</div>
<p>Please do let us know if you see any problems</p>
]]></content:encoded>
			<wfw:commentRss>http://www.taiwangeek.com/2011-05/gatorhost-pdo-dont-support-sqlite3.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>use curl to got Content-Disposition filename</title>
		<link>http://www.taiwangeek.com/2011-01/use-curl-to-got-content-disposition-filename.html</link>
		<comments>http://www.taiwangeek.com/2011-01/use-curl-to-got-content-disposition-filename.html#comments</comments>
		<pubDate>Mon, 10 Jan 2011 03:42:12 +0000</pubDate>
		<dc:creator>tung</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php curl]]></category>
		<category><![CDATA[原創]]></category>

		<guid isPermaLink="false">http://www.taiwangeek.com/?p=5655</guid>
		<description><![CDATA[curl CURLOPT_BINARYTRANSFER can't not got Content-Disposition filename for u]]></description>
			<content:encoded><![CDATA[<pre class="brush:php">/*
* usage:
=================================================
$fn = CurlTool::downloadFile('http://aaabb.com/download.php?id=zzzaaa','./');
echo "Grab file path =",$fn,"\n";
var_dump(CurlTool::$attach_info);
*/
class CurlTool {
    public static $userAgents = array(
        'FireFox3' =&gt; 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0',
        'GoogleBot' =&gt; 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
        'IE7' =&gt; 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
        'Netscape' =&gt; 'Mozilla/4.8 [en] (Windows NT 6.0; U)',
        'Opera' =&gt; 'Opera/9.25 (Windows NT 6.0; U; en)'
        );
    public static $options = array(
        CURLOPT_USERAGENT =&gt; 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
        CURLOPT_AUTOREFERER =&gt; true,
        CURLOPT_COOKIEFILE =&gt; '',
        CURLOPT_FOLLOWLOCATION =&gt; true
        );
    public static $header = array();
    public static $attach_info = array();

    private static $proxyServers = array();
    private static $proxyCount = 0;
    private static $currentProxyIndex = 0;

    public static function addProxyServer($url) {
        self::$proxyServers[] = $url;
        ++self::$proxyCount;
    }

    public static function fetchContent($url, $verbose = false,$url_reffer=false) {
        if (($curl = curl_init($url)) == false) {
            throw new Exception("curl_init error for url $url.");
        }

        if (self::$proxyCount &gt; 0) {
            $proxy = self::$proxyServers[self::$currentProxyIndex++ % self::$proxyCount];
            curl_setopt($curl, CURLOPT_PROXY, $proxy);
            if ($verbose === true) {
                echo "Reading $url [Proxy: $proxy] ... ";
            }
        } else if ($verbose === true) {
            echo "Reading $url ... ";
        }

        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt_array($curl, self::$options);
        if (is_string($url_reffer)) {
            curl_setopt($curl,CURLOPT_REFERER,$url_reffer);
        }
        $content = curl_exec($curl);
        if ($content === false) {
            throw new Exception("curl_exec error for url $url.");
        }
       	self::$header = curl_getinfo($curl);
        curl_close($curl);
        if ($verbose === true) {
            echo "Done.\n";
        }
        return $content;
    }

    public static function downloadFile($url, $fileName, $verbose = false) {
        if (($curl = curl_init($url)) == false) {
            throw new Exception("curl_init error for url $url.");
        }

        if (self::$proxyCount &gt; 0) {
            $proxy = self::$proxyServers[self::$currentProxyIndex++ % self::$proxyCount];
            curl_setopt($curl, CURLOPT_PROXY, $proxy);
            if ($verbose === true) {
                echo "Downloading $url [Proxy: $proxy] ... ";
            }
        } else if ($verbose === true) {
            echo "Downloading $url ... ";
        }

        curl_setopt_array($curl, self::$options);

        if (substr($fileName, -1) == '/') {
            $targetDir = $fileName;
            $fileName = tempnam(sys_get_temp_dir(), 'c_');
        }
        if (($fp = fopen($fileName, "wb")) === false) {
            throw new Exception("fopen error for filename $fileName");
        }
        curl_setopt($curl, CURLOPT_FILE, $fp);
		curl_setopt($curl,CURLOPT_HEADERFUNCTION,'self::get_att');
        curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
        if (curl_exec($curl) === false) {
            fclose($fp);
            unlink($fileName);
            throw new Exception("curl_exec error for url $url.");
        } elseif (isset($targetDir)) {
            $eurl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
            preg_match('#^.*/(.+)$#', $eurl, $match);
            fclose($fp);
            rename($fileName, "$targetDir{$match[1]}");
            $fileName = "$targetDir{$match[1]}";
        } else {
            fclose($fp);
        }
		self::$header = curl_getinfo($curl);
        curl_close($curl);
        if ($verbose === true) {
            echo "Done.\n";
        }
        return $fileName;
    }

	public static function get_att($ch, $header){
		if (preg_match("/Content-Length: (\d*)/i",$header,$matches)) {
			self::$attach_info['size'] = $matches[1];
		} elseif (preg_match('/Content-Disposition:.*?filename="(.*)"/i',$header,$matches)) {
			self::$attach_info['filename'] = $matches[1];
		} elseif (preg_match("/Content-Type: ([^; ]*)/i",$header,$matches)) {
			self::$attach_info['type'] = $matches[1];
		}
		//echo "$header";
		return strlen($header);
	}
    // activates POST and set post data
    public static function addPostData($data) {
        self::$options[CURLOPT_POST] = true;
        self::$options[CURLOPT_POSTFIELDS] = $data;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.taiwangeek.com/2011-01/use-curl-to-got-content-disposition-filename.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (request URI doesn't have a trailing slash)

Served from: www.taiwangeek.com @ 2012-05-19 06:02:26 -->
