Viewing file: index.php (10.63 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/********************************************************************************
- MemHT Portal -
Copyright (C) 2007-2008 by Miltenovik Manojlo
http://www.memht.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your opinion) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/> (GPLv2)
or write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA02110-1301, USA.
********************************************************************************/
if (!defined("_LOAD_PAGE_")) {
die("<table style='padding: 2px; border: 1px solid #999; background-color: #EEE; font-family: Verdana; font-size: 10px;' align='center'><tr><td><b>Error:</b> This file cannot be opened directly!</td></tr></table>");
}
if (isset($_GET['op'])) { $op = inCode($_GET['op']); } else { $op = ""; }
if (isset($_GET['id'])) { $id = intval($_GET['id']); } else { $id = ""; }
if (isset($_GET['ok'])) { $ok = inCode($_GET['ok']); } else { $ok = false; }
if (isset($_POST['ptitle'])) { $ptitle = eregi_replace("[/_']","-",inCode($_POST['ptitle'])); } else { $ptitle = ""; }
if (isset($_POST['text'])) { $text = inCode($_POST['text']); } else { $text = ""; }
if (isset($_POST['enabled'])) { $enabled = intval($_POST['enabled']); } else { $enabled = ""; }
if (isset($_GET['id'])) { $id = intval($_GET['id']); } else { $id = ""; }
if (isset($_POST['public'])) { $public = intval($_POST['public']); } else { $public = 0; }
if (isset($_POST['rank'])) { $rank = intval($_POST['rank']); } else { $rank = 0; }
if (isset($_GET['pg'])) { $pg = intval($_GET['pg']); } else { $pg = 1; }
$ofsppg = 20; //Items per page
$ofsbgn = ($pg*$ofsppg)-$ofsppg;
function myPageList($ofsbgn,$ofsppg,$pg) {
global $dblink,$siteConfig;
$n = 0;
echo "<table width='100%' align='center' cellspacing='1' cellpadding='0' class='std_nicetable'>";
echo "<thead>\n";
echo "<tr><td>"._TITLE_."</td><td>"._AUTHOR_."</td><td>"._DATE_."</td><td align='right'>"._HITS_."</td><td width='1%'> </td></tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
if ($result = $dblink->get_list("SELECT *,DATE_FORMAT(date, '".$siteConfig['timestamp']."') as date2 FROM memht_mypage ORDER BY title LIMIT $ofsbgn,$ofsppg")) {
foreach ($result as $row) {
$id = intval($row['id']);
$title = outCode($row['title']);
$author = outCode($row['author']);
$date = $row['date2'];
$hits = intval($row['hits']);
$enabled = intval($row['enabled']);
$off = ($enabled!="1") ? "<img src='images/off.gif' alt='"._OFF_."' title='"._OFF_."'>" : "" ;
$class = (($n++%2)!=0) ? "hlight" : "clean" ;
echo "<tr><td class='$class'><a href='index.php?page=mypage&op=openPage&id=$id&title=".mem_urlencode($title)."' title='$title'><b>$title</b></a></td><td class='$class' width='15%'>$author</td><td class='$class' width='20%' nowrap>$date</td><td class='$class' width='10%' align='right'>$hits</td><td class='$class' nowrap><a href='admin.php?page=mypage&op=editMyPage&id=$id' title='"._MODIFY_."'><img src='images/edit.gif' alt='Edit' border='0'></a> <a href='admin.php?page=mypage&op=deleteMyPage&id=$id' title='"._DELETE_."'><img src='images/delete.gif' alt='Delete' border='0'></a> $off</td></tr>\n";
}
} else {
echo "<tr><td colspan='5' align='center' id='errorText' class='clean'><b>"._NOPAGES_."</b></td></tr>";
}
echo "</tbody>\n";
echo "</table>";
//Pages
include_once("inc/class/paginationSystem.class.php");
$ps = new paginationSystem();
$ps->items = $ofsppg;
$ps->actpg = $pg;
$ps->query = "SELECT id FROM memht_mypage";
$ps->url = "admin.php?page=mypage&op=showPages&pg={{N}}";
$ps->show();
}
function add($ptitle,$text,$public,$rank,$enabled,$ok=false) {
global $dblink,$userInfo,$tzNOW;
if (!$ok) {
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form_mypage' method='post' action='admin.php?page=mypage&op=addMyPage&ok=true'>";
echo "<tr><td width='25%'><b>"._TITLE_."</b></td><td><input type='text' name='ptitle' size='40' maxlength='255'></td></tr>\n";
echo "<tr><td valign='top'><b>"._TEXT_."</b></td><td><div id='info'>"._PAGEBREAK_."</div>";
textarea("text","100%","600px",1,"fulladmin");
echo "</td></tr>\n";
echo "<tr><td><b>"._PUBLIC_."</b></td><td>";
echo "<select name='public'>\n";
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
echo "</select> <span id='info'>("._LISTEDIFPUBLIC_.")</span></td></tr>\n";
echo "<tr><td><b>"._REQUIREDRANK_."</b></td><td>";
echo "<select name='rank'>\n";
echo "<option value='0' selected>"._GUEST_."</option>\n";
echo "<option value='1'>"._USER_."</option>\n";
echo "<option value='2'>"._POWERUSER_."</option>\n";
echo "<option value='3'>"._ADMIN_."</option>\n";
echo "<option value='4'>"._SUPERADMIN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._CREATE_."'></td></tr>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($ptitle=="") { $save = false; }
if ($text=="") { $save = false; }
if ($save) {
$dblink->query("INSERT INTO memht_mypage (id,title,text,author,date,public,rank,enabled)
VALUES (null,'$ptitle','$text','".$userInfo['user']."',$tzNOW,'$public','$rank','$enabled')");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=mypage'>";
} else {
echo "<div align='center' id='errorText'><b>"._FIELDINVALID_."</b></div>";
}
}
}
function edit($id,$ptitle,$text,$public,$rank,$enabled,$ok=false) {
global $dblink;
$id = intval($id);
if (!$ok) {
$row = $dblink->get_row("SELECT * FROM memht_mypage WHERE id='$id'");
$mptitle = outCode($row['title']);
$mptext = outCode($row['text']);
$mpublic = intval($row['public']);
$mrank = intval($row['rank']);
$mpenabled = intval($row['enabled']);
echo "<table width='100%' align='center' cellspacing='0' cellpadding='1'>";
echo "<form name='form_mypage' method='post' action='admin.php?page=mypage&op=editMyPage&id=$id&ok=true'>";
echo "<tr><td width='25%'><b>"._TITLE_."</b></td><td><input type='text' name='ptitle' size='40' maxlength='255' value=\"$mptitle\"></td></tr>\n";
echo "<tr><td valign='top'><b>"._TEXT_."</b></td><td><div id='info'>"._PAGEBREAK_."</div>";
textarea("text","100%","600px",1,"fulladmin",$mptext);
echo "</td></tr>\n";
echo "<tr><td><b>"._PUBLIC_."</b></td><td>";
echo "<select name='public'>\n";
if ($mpublic==1) {
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
} else {
echo "<option value='1'>"._YES_."</option>\n";
echo "<option value='0' selected>"._NO_."</option>\n";
}
echo "</select> <span id='info'>("._LISTEDIFPUBLIC_.")</span></td></tr>\n";
echo "<tr><td><b>"._REQUIREDRANK_."</b></td><td>";
echo "<select name='rank'>\n";
$selected = ($mrank==0) ? " selected" : "" ;
echo "<option value='0'{$selected}>"._GUEST_."</option>\n";
$selected = ($mrank==1) ? " selected" : "" ;
echo "<option value='1'{$selected}>"._USER_."</option>\n";
$selected = ($mrank==2) ? " selected" : "" ;
echo "<option value='2'{$selected}>"._POWERUSER_."</option>\n";
$selected = ($mrank==3) ? " selected" : "" ;
echo "<option value='3'{$selected}>"._ADMIN_."</option>\n";
$selected = ($mrank==4) ? " selected" : "" ;
echo "<option value='4'{$selected}>"._SUPERADMIN_."</option>\n";
echo "</select></td></tr>\n";
echo "<tr><td><b>"._ENABLED_."</b></td><td>";
echo "<select name='enabled'>\n";
if ($mpenabled==1) {
echo "<option value='1' selected>"._YES_."</option>\n";
echo "<option value='0'>"._NO_."</option>\n";
} else {
echo "<option value='1'>"._YES_."</option>\n";
echo "<option value='0' selected>"._NO_."</option>\n";
}
echo "</select></td></tr>\n";
echo "<tr><td colspan='2'><input type='submit' name='Submit' value='"._MODIFY_."'></td></tr>\n";
echo "</form>\n";
echo "</table>\n";
} else {
$save = true;
if ($ptitle=="") { $save = false; }
if ($text=="") { $save = false; }
if ($save) {
$dblink->query("UPDATE memht_mypage SET title='$ptitle',text='$text',public='$public',rank='$rank',enabled='$enabled' WHERE id='$id'");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=mypage'>";
} else {
echo "<div align='center' id='errorText'><b>"._FIELDINVALID_."</b></div>";
}
}
}
function delete($id,$ok=false) {
global $dblink;
if ($ok) {
$dblink->query("DELETE FROM memht_mypage WHERE id='$id'");
echo "<meta http-equiv='refresh' content='0;URL=admin.php?page=mypage'>";
} else {
echo "<div align='center'><b>"._SUREDELETEPAGE_."</b><br><a href='admin.php?page=mypage&op=deleteMyPage&id=$id&ok=true' title='"._YES_."'>"._YES_."</a> - <a href='admin.php?page=mypage' title='"._NO_."'>"._NO_."</a></div>";
}
}
require_once("admin/inc/inc_header.php");
admin_page_title($page);
openTable();
echo "<div align='center' class='box'>";
echo "<a href='admin.php?page=mypage' title='"._LIST_."'><img src='admin/icons/list.png' border='0' title='"._LIST_."' align='top'> "._LIST_."</a>";
echo " - <a href='admin.php?page=mypage&op=addMyPage' title='"._CREATE_."'><img src='admin/icons/mypage.png' border='0' title='"._CREATE_."' align='top'> "._CREATE_."</a>";
echo "</div>";
closeTable();
openTable();
switch($op) {
case "addMyPage":
add($ptitle,$text,$public,$rank,$enabled,$ok);
break;
case "editMyPage":
edit($id,$ptitle,$text,$public,$rank,$enabled,$ok);
break;
case "deleteMyPage":
delete($id,$ok);
break;
case "showPages":
default:
myPageList($ofsbgn,$ofsppg,$pg);
break;
}
closeTable();
require_once("admin/inc/inc_footer.php");
?>
|