$v){
$post = new stdClass;
$filepath = $v['dirname'] . '/' . $v['basename'];
// Extract the date
$arr = explode('_', $filepath);
// Replaced string
$replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/';
// Author string
$str = explode('/', $replaced);
$author = $str[count($str)-3];
// The post author + author url
$post->author = $author;
$post->authorurl = site_url() . 'author/' . $author;
// The post date
$post->date = strtotime(str_replace($replaced,'',$arr[0]));
// The archive per day
$post->archive = site_url(). 'archive/' . date('Y-m-d', $post->date) ;
// The post URL
$post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]);
$tag = array();
$url = array();
$t = explode(',', $arr[1]);
foreach($t as $tt) {
$tag[] = array($tt, site_url(). 'tag/' . $tt);
}
foreach($tag as $a) {
$url[] = ''. $a[0] .'';
}
$post->tag = implode(', ', $url);
$post->tagb = implode(' ยป ', $url);
$post->file = $filepath;
// Get the contents and convert it to HTML
// $content = file_get_contents($filepath);
// $post->content = $content;
$tmp[] = $post;
}
return $tmp;
}
// Return posts list on profile.
function get_profile($profile, $page, $perpage){
$posts = admin_get_post();
$tmp = array();
foreach ($posts as $index => $v) {
$url = $v['dirname'];
$str = explode('/', $url);
$author = $str[count($str)-2];
if($profile === $author){
$tmp[] = $v;
}
}
if(empty($tmp)) {
echo '
';
return;
}
return $tmp = get_posts($tmp, $page, $perpage);
}
function get_post_list() {
if (isset($_SESSION['user'])) {
$posts = get_profile($_SESSION['user'], null, null);
if(!empty($posts)) {
echo '';
foreach($posts as $p) {
echo '';
echo '| ' . $p->file . ' | ';
echo ' | ';
echo ' | ';
echo '
';
}
echo '
';
}
}
}
?>