display a sigle post of the file array the thing is that im trying to display the most recent post and where thinking enumarating the array and using ksort().
microblog class
<?php class micro_blog{ var $stmp; var $cmp; var $set; public function __Constructor(){ $this->stmp = microtime(true); return $this->stmp; } public function ping($class, $caption){ $this->cmp = '<script type="text/javascript">'.$class.'("'.$caption.'"); history.go(-1);</script>'; return $this->cmp; } public function phtml($data){ return htmlentities($data, ENT_QUOTES); } public function digest($path, $data, $id){ if(empty($data[0]) || empty($data[3]) || empty($data[5])){ exit($this->ping('alert', 'All fields required')); }else{ $posfile = $id.'_'.$data[6].'.txt'; if($hdl = fopen($path.'/'.$posfile, "w+")){ fwrite($hdl, $data[0]."\n".$data[4]."\n".$data[2]."\n".$data[3]."\n".$data[5]."\n"); fclose($hdl); exit($this->ping('alert', 'Message sent @Borikenmedia')); } } } function buffer($path){ ob_start(); $ctrl = !is_dir($path)? file($path): opendir($path); ob_end_flush(); return $ctrl; } public function feed($path){ $dir = is_dir($path)? $this->buffer($path): $this->ping('alert', 'No post found'); while(false !== ($data = readdir($dir))){ if($data !== '.' && $data !== '..'){ $this->set[] = $data; } } return $this->set; } } ?>
blog feed
<?php $cat = !empty($_REQUEST['cat'])? phtml($_REQUEST['cat']): 'blog'; #Request topic $form_path = 'editor/path'; $form_type = '.tpl'; $news_path = 'post/path'.$cat.'/'; #Set variable values #Set Micro Blog instance [[Do not edit]] $motd = new micro_blog(); if($array = $motd->feed($news_path)){ if(count($array) >= 1){ $post = $array[0]; } } if(isset($_POST['submit'])){ $posdata = array( $motd->phtml($_POST['blog_user']), $motd->phtml($_POST['blog_mail']), $motd->phtml($_POST['blog_cat']), $motd->phtml($_POST['blog_title']), date('F j, Y, g:i a'), $motd->phtml($_POST['blog_message']), date('YmdHis')); $motd->digest($news_path, $posdata, $cat); //Process request $uri = $_SERVER['SERVER_NAME'].'/node?task=feed&cat='.$cat; header('Location: http://'.$uri); }else{ $data = $news_path.$post; $feed = file_exists($data)? file($data): 'Empty thread'; print '<div class="article"><h2><span>'.$feed[3].'</span></h2>'; print '<div class="clr"></div>'; print '<p style="margin: 0px; padding: 0px; font: normal 12px Arial; color: #333333;">'; print 'By '.$feed[0].' @ '.$feed[1].'</p>'; print '<div class="clr"></div>'; print '<p>'.$feed[4].'</p></div>'; } include 'module/misc/blog_edit.tpl'; ?>
Greetings Rc69, hope yall can help
Edited by borikenmedia, 07 April 2011 - 06:20 PM.