Source for file admin.php
Documentation is available at admin.php
require_once 'liveuser_rights.php';
require_once 'HTML/Template/IT.php';
if (!$usr->isLoggedin () || !$usr->checkRight (EDITNEWS)) {
echo 'Sorry but you cannot access this page';
if (isset ($_POST['news'])) {
echo 'You are trying to modify a news but do not have the right to do so !';
if (isset ( $_POST['id'])) {
insertNews($db, $_POST['title'], $_POST['newscontent'], $usr->getProperty ('user_id'));
updateNewsContent($db, $_POST['id'], $_POST['title'], $_POST['newscontent'], $usr->getProperty ('user_id'));
if (isset ( $_GET['mode']) && $_GET['mode'] == 'edit') {
if (!isset ($_GET['id']) && !is_numeric($_GET['id'])) {
} elseif (isset ($_GET['mode']) && $_GET['mode'] == 'insert') {
$tpl = & new HTML_Template_IT ('./');
$tpl->loadTemplatefile ('admin.tpl', true , true );
// assign the content to the vars
$tpl->setVariable ('USER', $usr->getProperty ('handle'));
$tpl->setVariable ('NEWS', $news);
* @param object &$db a reference to a db connection object
* @param string $category news category
DATE_FORMAT(news_date, '%D %b %Y at %H:%I:%S') AS date,
news_category = '$category'
$news = $db->getAssoc ($query);
if (DB ::isError ($news)) {
die ($news->getMessage () . ' ' . $news->getUserinfo ());
$tpl = & new HTML_Template_IT ('./');
$tpl->loadTemplatefile ('news_list.tpl', true , true );
$tpl->setVariable ('CATEGORY', ucfirst($category));
foreach ($news as $id => $name) {
foreach ($name as $cell) {
// Assign data to the inner block
$tpl->setCurrentBlock ('cell');
$tpl->setVariable ("ID", $id);
$tpl->setVariable ("DATA", nl2br($cell));
$tpl->parseCurrentBlock ('cell');
// Assign data and the inner block to the
$tpl->setCurrentBlock ('row');
$tpl->parseCurrentBlock ('row');
* @param object &$db a reference to a db connection object
* @param string $content the new content
* @return mixed content as a string or error
DATE_FORMAT(news_date, '%D %b %Y at %H:%I:%S') AS date,
$news = $db->getRow ( $query );
if (DB ::isError ($news)) {
die ($news->getMessage () . ' ' . $news->getUserinfo ());
$tpl = & new HTML_Template_IT ('./');
$tpl->loadTemplatefile ('news_edit.tpl', true , true );
$tpl->setVariable ('ID', $news['id']);
$tpl->setVariable ('TITLE', $news['title']);
$tpl->setVariable ('DATE', $news['date']);
$tpl->setVariable ('CONTENT', $news['content']);
* @param object &$db a reference to a db connection object
* @param string $content the new content
* @return mixed content as a string or error
news_content = ' . $db->quoteSmart ($content) . ',
news_title = ' . $db->quoteSmart ($title) . '
news_id = "' . $id . '"';
* Insert news in database
* @param object &$db a reference to a db connection object
* @param string $title news title
* @param string $content the new content
* @return mixed content as a string or error
function insertNews(&$db, $title, $content, $user)
news_title, news_content)
("' . $db->nextId ('news') . '", "' . date('Y-m-d H:i:s') . '",
' . $db->quoteSmart ($title) . ', ' . $db->quoteSmart ($content) . ')';
Documentation generated on Mon, 11 Mar 2019 13:56:15 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|