<? require_once('news.config.php'); class News { var $Title; var $Content; var $Image; var $Filename; function News($title='', $content='', $image='') { $this->Title = $title; $this->Content = $content; $this->Image = $image; $this->Filename = false; } function load($fn) { return unserialize(file_get_contents($fn)); } function save() { if(!$this->Filename) { $this->Filename = date('YmdHis').'.txt'; } $fh = @fopen(SAVEPATH.$this->Filename, 'wb'); $rslt = @fwrite($fh, serialize($this)); @fclose($fh); return $rslt; } } function _STRIPFILENAME(&$v) { $v = News::load($v); } function &getNews($page=1) { $offset = ($page-1)*ITEMSPERPAGE; $files = glob(SAVEPATH.'??????????????.txt'); rsort($files); $files = array_slice($files, $offset, ITEMSPERPAGE); array_walk($files, '_STRIPFILENAME'); return $files; } function getNewsCount() { return count(glob(SAVEPATH.'??????????????.txt')); } function getPagesCount() {return max(ceil(getNewsCount()/ITEMSPERPAGE),1); } ?> <? $N = getNews(); foreach($N as $n) : ?> <div class="dcontain"> <div class="dtitle"></div> <div class="dcontent"> <table width="380" border="0" cellspacing="5" cellpadding="0"> <tr> </tr> <tr> <td valign="top" width="70" scope="col"><div align="left"> <? if($n->Image) : ?><a href="<?=$n->Image;?>" class="highslide" onclick="return hs.expand(this)"><img src="<?=$n->Image;?>" width="70" height="50"/></a><? endif; ?> </div></td> <td width="100%" valign="top"><div align="left"> <b><?=$n->Title;?></b><br><?=$n->Content;?></div></td> </tr> </table> </div></div> <hr size="1"> <? endforeach; ?>ทั้งหมด <b><?=getNewsCount();?></b> ข่าว
<html> <head> <title>ThaiCreate.Com PHP & Text File Pagination</title> </head> <body> <? $arrFile = null; $strFileName = "thaicreate.txt"; $objFopen = fopen($strFileName, 'r'); if ($objFopen) { while (!feof($objFopen)) { $file = fgets($objFopen, 4096); $arrFile[] = $file; } fclose($objFopen); } /*** Soft ***/ //rsort($arrFile); // DESC //asort($arrFile); // ASC $Num_Rows = count($arrFile); $Per_Page = 5; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page)+1; if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $Page_End = $Per_Page * $Page; if($Page_End > $Num_Rows) { $Page_End = $Num_Rows; } ?> <table width="300" border="1"> <tr> <th width="50"> <div align="center">No </div></th> <th width="250"> <div align="center">Files </div></th> </tr> <? $no = 1; if($Page > 1) { $no = ($Per_Page * ($Page-1)) + 1; } for($i=$Page_Start;$i<=$Page_End;$i++) { ?> <tr> <td><div align="center"><?=$no;?></div></td> <td><?=$arrFile[$i-1];?></td> </tr> <? $no++; } ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo "<a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'> Next>></a> "; } ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง