This is the whole Code, I'm sure you don't need to see all this as Its overkill.
AS I say Just a simple bit of code that can solve my problem of having to tick all the boxes that need updating within a range.
Thanks for your time .
<?php
/*******************************************************************************
*
* Copyright (C) 2007
*
*************************************************************************************/
function session_defaults() {
$_SESSION['logged'] = false;
$_SESSION['admin']=false;
$_SESSION['ip'] = '';
}
function check_login($us,$ps){
if (!isset($_SESSION['ip']) ) {session_defaults();}
if (!$_SESSION['logged']){
if(isset($_POST['user']) && isset($_POST['passwd'])){
//check login credentials
if(($_POST['user']==$us) && ($_POST['passwd']==$ps)){
$_SESSION['logged']=true;
$_SESSION['admin']=true;
$_SESSION['ip']=md5($_SERVER['REMOTE_ADDR']);
return true;
}else{
echo 'bad login <a href="admin.php">try again</a>.';
exit;
}
}else{
echo '<html><head><link href="style.css" rel="stylesheet" type="text/css"/></head>
<body><div class="header"><font color="orange">ikbin admin</font></div>
<br/>
<br/>
<div class="admin" style="width:300px;padding-right:40px"><br/>
<center><b>You must login to use this function.</b><br/>
<form name="form1" id="form1" method="post" action="admin.php">
Username: <input name="user" type="text" id="user" /><br/>
Password: <input name="passwd" type="password" id="passwd" /><br/>
<input type="submit" name="Submit" value="Login" />
</form></center></div></body></html>';
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<br/>First header ID: ".
$ns->group['firstID'].'<br/>Last Header ID: '.$ns->group['lastID'].'<br/>';
}
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].'<br/>';
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 '<h2>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!!</h2><br/><br/>';}
$sql->addgrouparray($gac);
$message.="<br/>$i groups added<br/>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!!<br/>";
}
$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.='<br/>';
$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.'.<br/>';
}
$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.'<br>';
}
$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;
}
}
?>
<html>
<head>
<title>ikbin | admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function showImport(){
var ad=obj('import');
ad.style.display='block';
}
function obj(i){
return document.getElementById(i);
}
//functions added by jordy 25-Feb-07
function inverse($o) {
for ($i=0; $i < $o.elements.length; $i++) {
if ($o.elements[$i].type == "checkbox" && $o.elements[$i].name != "collection"
&& $o.elements[$i].parentNode.parentNode.style.display!='none') {
$o.elements[$i].checked = !$o.elements[$i].checked;
}
}
}
</script>
</head>
<body>
<div class="header"> <font color='orange'>ikbin admin</font> <a href="admin.php?logout=true">logout</a></div>
<center>
<a href='#Bottom'>Bottom</a>
<a name=Top></a>
</center>
<br/>
<div id="message" class="message"><center><font color="red"><?php echo $message;?></font></center></div>
<br/>
<div id="groups" class="admin">
<form name="form2" method="post" action="admin.php">
<input class="newgroup" type="button" value="Reverse selected" onClick="inverse(this.form);">
<table border="0" cellspacing="1" cellpadding="1">
<tr>
<td></td>
<td><strong>Group</strong></td>
<td><strong>Last Scan</strong></td>
<td><strong>Newest File</strong></td>
<td ><strong>Oldest File</strong></td>
<td><strong>Total Files</strong></td>
<td><strong>Last Header ID</strong></td>
<td><strong>Retention</strong></td>
<td><strong>Last Purged</strong></td>
<td><strong>Update Lock</strong></td>
</tr>
<?php
$q=$sql->groups();
$db->query($q);
//display or none
//none
if($db->num_rows()<1){
?><tr><td><font color="red">No Groups</font><td><tr><?php
}else{
//build rows
require_once('class/utilities.class.php');
$uf=new utilityfunctions;
while($db->next_record()){
if($db->Record['active']==1){$bgcolor='#66FF99';}else{$bgcolor='#FF9966';}
if($db->Record['updatelock']){$lock='On';}else{$lock='Off';}
echo'<tr bgcolor="'.$bgcolor.'">
<td><input name="'.$db->Record['key'].'" type="checkbox" value="action"></td>
<td>'.$db->Record['group'].'</td>
<td>'.$uf->fuzzyage($db->Record['lastscan']).'</td>
<td>'.$uf->fuzzyage($db->Record['newestfile']).'</td>
<td>'.$uf->fuzzyage($db->Record['oldestfile']).'</td>
<td>'.$db->Record['totalfiles'].'</td>
<td>'.$db->Record['lastheaderid'].'</td>
<td>'.$db->Record['purgeage'].'</td>
<td>'.$uf->fuzzyage($db->Record['lastpurge']).'</td>
<td>'.$lock.'</td>
</tr>';
}
}
?>
</table>
<br/>
<center>
<a name=Bottom></a>
<a href='#Top'>Top</a>
</center>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF9966" width="10"> </td>
<td width="30">Inactive Group</td>
<td bgcolor="#66FF99" width="10"> </td>
<td width="5">Active Group</td>
</tr>
<tr>
<td colspan="4" bgcolor="">Only ACTIVE groups are included in the cron job.</td>
</tr>
</table>
<center>
<!-Extra Reverse selected button->
<div id="groups" class="admin">
<form name="form2" method="post" action="admin.php">
<input class="newgroup" type="button" value="Reverse selected" onClick="inverse(this.form);">
<table border="0" cellspacing="1" cellpadding="1">
<!-Extra Reverse selected button->
</center>
<br>
<br/>
<select name="action">
<option value="Info">Get Info</option>
<option value="Import">Import Headers</option>
<option value="Refresh">Refresh Stats</option>
<option value="PurgeAge">Remove Old</option>
<option value="Activate">Activate</option>
<option value="Deactivate">Deactivate</option>
<option value="Purge">Set Retention</option>
<option value="Unlock">Unlock Group</option>
<option value="Empty">Empty</option>
<option value="PurgeNFO">Purge NFOs</option>
<option value="Clean">Clean Orphans</option>
<option value="Remove">Remove</option>
</select>
<input name="update" type="submit" value="Update">
<br/>
<div id="import" style="display:none">
<input type="text" name="starthdr">
Start Header ID <br/>
<input value="10000" type="text" name="numhdr">
Fetch About <br/>
<input type="checkbox" name="all" value="true">
Fetch All <br/>
<input type="text" name="purgeage">
Retention (days)
</div>
<a href="#" onClick="showImport();return false;">+import/purge options.</a>
</form>
</div>
<br/>
<div id="addgroup" class="admin">
<form name="form1" method="post" action="admin.php" >
<table width="518" height="29" border="0" cellpadding="1" cellspacing="1" bordercolor="#000000">
<tr>
<td width="26%">Add group: </td>
<td width="64%"><input name="newgroup" type="text" id="newgroup" size="50"></td>
<td width="10%"><input name="Add" type="submit" id="Add" value="Add"></td>
</tr>
</table>
<div id="addmultiple" style="display:none;">
<table width="518" height="29" border="0" cellpadding="1" cellspacing="1" bordercolor="#000000">
<tr>
<td valign="top">Enter groups to add, one per line (a CSV formated list).
Optionally, enter retention in days.<br/>
<br/>
<em>group[,retention]</em><br/>
<br/>
<input name="groupcheck" type="checkbox" id="groupcheck" value="1" checked> Check that groups exist before adding.
</td>
<td><textarea name="newgroups" cols="45" rows="10" id="newgroups"></textarea></td>
<td> </td>
</tr>
</table>
<br/>
</div>
<a href="#" onClick="document.getElementById('addmultiple').style.display='block';return false;">+add multiple groups</a>
</form>
</div>
<br/>
<div class="footer">powered by <font color="orange">ikbin</font></div>
</body>
</html>