Файл: admin/admins_manage.php
Строк: 190
<?php
include("../include/config.php");
include_once("../include/functions/import.php");
verify_login_admin();
$adminurl = $config['adminurl'];
// DELETE BEGIN
if($_REQUEST['delete']=="1")
{
$DADMINID = intval($_REQUEST['ADMINID']);
if($DADMINID > 0)
{
$sql="select count(*) as total from administrators";
$executequery = $conn->Execute($sql);
$tadmins = $executequery->fields['total'];
if($tadmins > 1)
{
$sql="DELETE FROM administrators WHERE ADMINID='".mysql_real_escape_string($DADMINID)."'";
$conn->Execute($sql);
$message = "Administrator Successfully Deleted.";
Stemplate::assign('message',$message);
}
else
{
$error = "Error: You cannot delete the only admininstrator.";
}
}
}
// DELETE END
if($_REQUEST['sortby']=="email")
{
$sortby = "email";
$sort =" order by email";
$add1 = "&sortby=email";
}
elseif($_REQUEST['sortby']=="username")
{
$sortby = "username";
$sort =" order by username";
$add1 = "&sortby=username";
}
else
{
$sortby = "ADMINID";
$sort =" order by ADMINID";
$add1 = "&sortby=ADMINID";
}
if($_REQUEST['sorthow']=="desc")
{
$sorthow ="desc";
$add1 .= "&sorthow=desc";
}
else
{
$sorthow ="asc";
$add1 .= "&sorthow=asc";
}
//Search
$fromid = intval($_REQUEST['fromid']);
$toid = intval($_REQUEST['toid']);
$email = htmlentities(strip_tags($_REQUEST['email']), ENT_COMPAT, "UTF-8");
$username = htmlentities(strip_tags($_REQUEST['username']), ENT_COMPAT, "UTF-8");
$add1 .= "&fromid=$fromid&toid=$toid&email=$email&username=$username";
if($_POST['submitform'] == "1" || ($_REQUEST['fromid']!="" || $toid>0 || $email!="" || $username!=""))
{
if($fromid > 0)
{
$addtosql = "WHERE ADMINID>='".mysql_real_escape_string($fromid)."'";
Stemplate::assign('fromid',$fromid);
}
else
{
$addtosql = "WHERE ADMINID>'".mysql_real_escape_string($fromid)."'";
}
if($toid > 0)
{
$addtosql .= "AND ADMINID<='".mysql_real_escape_string($toid)."'";
Stemplate::assign('toid',$toid);
}
if($email != "")
{
$addtosql .= "AND email like'%".mysql_real_escape_string($email)."%'";
Stemplate::assign('email',$email);
}
if($username != "")
{
$addtosql .= "AND username like'%".mysql_real_escape_string($username)."%'";
Stemplate::assign('username',$username);
}
Stemplate::assign('search',"1");
}
//Search End
$page = intval($_REQUEST['page']);
if($page=="")
{
$page = "1";
}
$currentpage = $page;
if ($page >=2)
{
$pagingstart = ($page-1)*$config['items_per_page'];
}
else
{
$pagingstart = "0";
}
$queryselected = "select ADMINID from administrators $addtosql $sort $sorthow limit $config[maximum_results]";
$query2 = "select * from administrators $addtosql $sort $sorthow limit $pagingstart, $config[items_per_page]";
$executequeryselected = $conn->Execute($queryselected);
$totalvideos = $executequeryselected->rowcount();
if ($totalvideos > 0)
{
if($totalvideos<=$config[maximum_results])
{
$total = $totalvideos;
}
else
{
$total = $config[maximum_results];
}
$toppage = ceil($total/$config[items_per_page]);
if($toppage==0)
{
$xpage=$toppage+1;
}
else
{
$xpage = $toppage;
}
$executequery2 = $conn->Execute($query2);
$results = $executequery2->getrows();
$beginning=$pagingstart+1;
$ending=$pagingstart+$executequery2->recordcount();
$pagelinks="";
$k=1;
$theprevpage=$currentpage-1;
$thenextpage=$currentpage+1;
if ($currentpage > 0)
{
if($currentpage > 1)
{
$pagelinks.="<a href='$adminurl/admins_manage.php?page=1$add1' title='first page'>First</a> ";
$pagelinks.="<a href='$adminurl/admins_manage.php?page=$theprevpage$add1'>Previous</a> ";
};
$counter=0;
$lowercount = $currentpage-5;
if ($lowercount <= 0) $lowercount = 1;
while ($lowercount < $currentpage)
{
$pagelinks.="<a href='$adminurl/admins_manage.php?page=$lowercount$add1'>$lowercount</a> ";
$lowercount++;
$counter++;
}
$pagelinks.=$currentpage." ";
$uppercounter = $currentpage+1;
while (($uppercounter < $currentpage+10-$counter) && ($uppercounter<=$toppage))
{
$pagelinks.="<a href='$adminurl/admins_manage.php?page=$uppercounter$add1'>$uppercounter</a> ";
$uppercounter++;
}
if($currentpage < $toppage)
{
$pagelinks.="<a href='$adminurl/admins_manage.php?page=$thenextpage$add1'>Next</a> ";
$pagelinks.="<a href='$adminurl/admins_manage.php?page=$toppage$add1' title='last page'>Last</a> ";
};
}
}
else
{
$error = "Sorry, no administrators were found.";
}
$mainmenu = "12";
$submenu = "1";
Stemplate::assign('mainmenu',$mainmenu);
Stemplate::assign('submenu',$submenu);
Stemplate::assign('sorthow',$sorthow);
Stemplate::assign('sortby',$sortby);
Stemplate::assign('currentpage',$currentpage);
STemplate::display("administrator/global_header.tpl");
STemplate::assign('beginning',$beginning);
STemplate::assign('ending',$ending);
STemplate::assign('pagelinks',$pagelinks);
STemplate::assign('total',$total+0);
STemplate::assign('results',$results);
Stemplate::assign('error',$error);
STemplate::display("administrator/admins_manage.tpl");
STemplate::display("administrator/global_footer.tpl");
?>