ruạṛ
<?php /** * List of blog articles * @version 0.9 * @author Callum Muir <cmuirnz@gmail.com> * @author Robert Urquhart <programmer@activatedesign.co.nz> * @package WEP-CMS */ session_start(); require_once $_SERVER['DOCUMENT_ROOT'].'/admin/scripts-includes/universal.php'; require_once $_SERVER['DOCUMENT_ROOT'].'/admin/scripts-includes/display.php'; $connID = connect_to_db(); $query = "SELECT page_id, name " . "FROM page_data " . "WHERE page_type = 'blog'"; if(!$result = mysql_query($query)) { die("Error retrieving blog pages. " . mysql_error()); } $blogOptions = ""; while($page = mysql_fetch_assoc($result)) { $blogOptions .= "<option value='" . $page["page_id"] . "'>" . $page["name"] . "</option>"; } $query = "SELECT blog.*, page_data.name AS blogName, position " . "FROM blog, page_data " . "WHERE blog.page_id = page_data.page_id " . "ORDER BY position, date DESC"; if(!$result = mysql_query($query)) { die("Error retrieving blog articles. " . mysql_error()); } if(mysql_num_rows($result) == 0) { $table = "<p class='center'>\n"; $table .= "No articles found.\n"; $table .= "</p>\n"; } else { $table = "<table class='control_panel'>\n"; $table .= build_article_table($result); $table .= "</table>\n"; } head('blog','Administration Panel'); echo "<form name='add_article' id='add_article' action='processes/process-blog-new.php' method='post' enctype='multipart/form-data' class='add'>\n"; echo "<p class='center'>\n"; echo "<label for='article_name'>New article: <input name='article_name' id='article_name' type='text' size='40' value='' placeholder='Please enter an article name' /></label> in <select name='page'>" . $blogOptions . "</select> <input type='submit' name='add' value='Add Article' />\n"; echo "</p>\n"; echo "</form>\n"; echo $table; footer(); exit; function article_head($blogName) { $head .= "<thead>\n"; $head .= "<tr>\n"; $head .= "<th class='pad'></th>\n"; $head .= "<th>\n"; $head .= $blogName; $head .= "</th>\n"; $head .= "<th>\n"; $head .= "Article\n"; $head .= "</th>\n"; $head .= "<th>\n"; $head .= "Date\n"; $head .= "</th>\n"; $head .= "<th class='control'>\n"; $head .= "Active\n"; $head .= "</th>\n"; $head .= "<th class='control'>\n"; $head .= "Edit\n"; $head .= "</th>\n"; $head .= "<th class='control'>\n"; $head .= "Delete\n"; $head .= "</th>\n"; $head .= "</tr>\n"; $head .= "</thead>\n"; return $head; } /** * Creates a table of articles * @param resource $result Query result for article list * @return string the HTML for the article table */ function build_article_table($result) { $html = ""; $pageName = ""; while($article = mysql_fetch_assoc($result)) { if($pageName !== $article["blogName"]) { $html .= article_head($article["blogName"]); $pageName = $article["blogName"]; } $html .= "<tr>\n"; $html .= "<td></td>\n"; $html .= "<td></td>\n"; $html .= "<td>\n"; $html .= "<a href='" . $article['path'] . "'>" . $article['name'] . "</a>\n"; $html .= "</td>\n"; $html .= "<td>\n"; $html .= $article['date'] . "\n"; $html .= "</td>\n"; $html .= "<td>\n"; $html .= "<a class='toggle' href='processes/process-switch.php?f=active&article=" . $article['article_id'] . "'>".onOrOff($article['active'])."</a>\n"; $html .= "</td>\n"; $html .= "<td>\n"; $html .= "<a href='edit-blog.php?article_id=" . $article['article_id'] . "'>Edit</a>\n"; $html .= "</td>\n"; $html .= "<td>\n"; $html .= '<a href="processes/process-blog-delete.php?article_id=' . $article['article_id'] . '" onClick="if(confirm(\'Delete ' . addslashes($article['name']) . '?\')){return true}else{return false}" class="delete"><img src="images/img-del.png" width="20" height="20" alt="Delete"></a>'; $html .= "</td>\n"; $html .= "</tr>\n"; } return $html; } ?>
cải xoăn