';
exit;
}
}else{//logged is true, check IP match
if(md5($_SERVER['REMOTE_ADDR'])==$_SESSION['ip']&&$_SESSION['admin']==true){
return true;
}else{
//something funny happened, clear the session and send by to admin.php
session_defaults();
header('Location:admin.php');
exit;
}
}
}
function addgroup($group,&$ns){
if($ns->nntp_con==false){
$message='Error opening connection: '.$ns->errorLog;
return array(false,$message);
}
$ns->changegroup($group);
if (!$ns->group['status']){
$message='Error opening group: '.$ns->errorLog;
return array(false,$message);
}
//do this
$message='Group added: '.$ns->group['name'].' First ID: '.$ns->group['firstID'].' Last ID:'.$ns->group['lastID'];
return array(true,$message);
}
function groupinfo($group,&$ns){
$ns->changegroup($group);
if (!$ns->group['status']){
$message='Error opening group: '.$ns->errorLog;
}else{
$message="Group Info - $group First header ID: ".
$ns->group['firstID'].' Last Header ID: '.$ns->group['lastID'].' ';
}
return $message;
}
require_once('config.backend.php');
session_start();
if(isset($_GET['logout'])){
session_defaults();
}
$up=new Admin_login;
$log=check_login($up->user,$up->passwd);
$db=new Admin_db;
$db->connect();
$sql=new sqladmin;
$sql->db=&$db;
//add a new group
if(isset($_POST['Add'])){
//add a check when groups are added:
//make sure that there is a row in the site stats table.
$sql->checksitestatstable();
$ns=new My_nntp();
$t=$ns->startNNTPconnection();
if(strlen($_POST['newgroup'])>strlen($_POST['newgroups'])){
$m=addgroup($_POST['newgroup'],$ns);
$message=$m[1];
if($m[0]){$sql->addgroup($_POST['newgroup']);}
}else{
$grouprows=explode("\r\n",$_POST['newgroups']);
$i=0;
$gac=array();
foreach($grouprows as $group){
if(strlen($group)>0){
$g=explode(',',$group);
if(strlen($g[0])>0){
if(!is_numeric($g[1])){$g[1]=0;}
$g[0]=trim(stripslashes($g[0]),"\"");
if(isset($_POST['groupcheck'])&&($_POST['groupcheck']>0)){
$m=addgroup($g[0],$ns);
$message.=$m[1].' ';
if($m[0]){
$gac[$i]['group']=$g[0];
$gac[$i]['purgeage']=$g[1];
$i++;
}
}else{
$gac[$i]['group']=$g[0];
$gac[$i]['purgeage']=$g[1];
$i++;
}
}
}
}
if($i>10){echo '
If you add more than 127 groups, be sure that you increase the data size of `key` (groups table) and `group` (collections and files table) to smallint or mediumint!!
';}
$sql->addgrouparray($gac);
$message.=" $i groups added If you add more than 127 groups, be sure that you increase the data size of `key` (groups table) and `group` (collections and files table) to smallint or mediumint!! ";
}
$ns->closeNNTPconnection();
}
if(isset($_POST['update'])){
$i=0;
foreach($_POST as $key => $value){
if($value=='action'){
$checked[$i]=$key;
$i++;
}
}
if($i<1){
$message="Nothing Selected!";
$_POST['action']='';//clear action so no switch
}
switch($_POST['action']){
case "Info":
$message=0;
$ns=new My_nntp();
if(!$ns->startNNTPconnection()){
$message='Error opening connection: '.$ns->errorLog;
break;
}
foreach($checked as $key=>$value){
$group=$sql->ID2GROUP($value);
$tm.=groupinfo($group,$ns);
$tm.=' ';
$message++;
}
$ns->closeNNTPconnection();
$message=$tm.$message.' groups queried.';
break;
case "Refresh":
$message=0;
foreach($checked as $key=>$value){
$sql->UPDATEGROUPSTATS($value);
$message++;
}
$sql->updatesitestats();
$sql->updateNFOdirinfo($GLOBALS['CONF_nfo']['folder']);
$message=$tm.$message.' groups refreshed.';
break;
case "Unlock":
$message=0;
foreach($checked as $key=>$value){
$override=$sql->toggleupdatelock(false,$value);
if($override){
$group=$sql->ID2GROUP($value);
$tm.='Lock overridden on '.$group.'. ';
}
$message++;
}
$message=$tm.$message.' groups unlocked.';
break;
case "Import":
$ns=new My_nntp();
if(!$ns->startNNTPconnection()){
$message='Error opening connection: '.$ns->errorLog;
break;
}
$fill=new filler;
$fill->live=true;
$fill->sql=&$sql;
$fill->ns=&$ns;
if(isset($_POST['starthdr'])){$starthdr=$_POST['starthdr'];}else{$starthdr=0;}
if(isset($_POST['numhdr'])){$numhdr=$_POST['numhdr'];}else{$numhdr=10000;}
if(isset($_POST['all'])&&($_POST['all']==true)){$allhdr=true;}else{$allhdr=false;}
$i=0;
foreach($checked as $value){
$gi['groupid']=$value;
$gi['group']=$sql->ID2GROUP($value);
$gi['lastheaderid']=$sql->lastheaderid($value);
$r=$fill->doXOVER($gi,$numhdr,$starthdr,$allhdr);
$i++;
}
//clear out the NFO cache
$fill->processNFOcache();
$ns->closeNNTPconnection();
$sql->updatesitestats();
$sql->updateNFOdirinfo($GLOBALS['CONF_nfo']['folder']);
foreach($fill->errorLog['e'] as $key=>$value){
$message.=$value.' ';
}
$message.=$i.' groups imported.';
break;
case "Activate":
$message=0;
foreach($checked as $key=>$value){
$sql->setgroupactive($value,'1');
$message++;
}
$message=$message.' groups activated';
break;
case "Deactivate":
$message=0;
foreach($checked as $key=>$value){
$sql->setgroupactive($value,'0');
$message++;
}
$message=$message.' groups deactivated';
break;
case "Empty":
$message=0;
foreach($checked as $key=>$value){
$sql->flushgroup($value);
$sql->UPDATEGROUPSTATS($value);
$message++;
}
$sql->updatesitestats();
$sql->updateNFOdirinfo($GLOBALS['CONF_nfo']['folder']);
$message=$message.' groups emptied.';
break;
case "PurgeAge":
$message=0;
foreach($checked as $key=>$value){
$sql->purgegroupid($value);
$sql->UPDATEGROUPSTATS($value);
$message++;
}
$sql->updatesitestats();
$sql->updateNFOdirinfo($GLOBALS['CONF_nfo']['folder']);
$message=$message.' groups flushed to retention age.';
break;
case "Remove":
$message=0;
foreach($checked as $key=>$value){
$sql->flushgroup($value);
$sql->deletegroup($value);
$message++;
}
$sql->updatesitestats();
$message=$message.' groups removed.';
break;
case "Purge":
$message=0;
foreach($checked as $key=>$value){
$sql->setpurge($_POST['purgeage'],$value);
$message++;
}
$message="Retention set for $message groups.";
break;
case "Clean":
$sql->cleanuptables();
$sql->updatesitestats();
$message="Orphan files and headers deleted.";
break;
case "PurgeNFO":
$sql->purgeNFOdir($GLOBALS['CONF_nfo']['folder']);
break;
}
}
?>
ikbin | admin