Location: PHPKode > projects > WSN Guest > wsn-guest/admin/index.php
<?php

require 'adminstart.php';
require '../classes/comments.php';

$returnto = $_COOKIE['returnto'];
if ($returnto == '') $returnto = 'index.php';

$adminpath = "http://". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
$adminpath = str_replace('/'. $admindir, '', $adminpath);
$adminpath .= '/index.php?action=setadminlocation';
if (($set != 1) && ($returnto != 'index.php')) header("Location: $adminpath"); 

if ($thismember->isadmin())
{
if ($action == 'checkforupdates')
{
  $current = geturl("http://scripts.webmastersite.net/wsnguest/version.txt");
  if ($version != $current) $versioninfo = geturl("http://scripts.webmastersite.net/wsnguest/wsnguestsversion.txt");
  else $versioninfo = $language->admin_mostrecent; 
  $template = new template("blank");
  $template->text = $versioninfo;
  $template->text .= '<p>[<a href=index.php>'. $language->admin_back .'</a>]</p>';  
}
else if ($action == 'reject')
{
 if (($customreject != 'yes') || ($message != ''))
 {
  $thislink = new onelink('id', $id);
  $thislink->reject($reason);
  if (!$template) $template = new template("../$templatesdir/redirect.tpl");
  $template->replace('{MESSAGE}', str_replace('{ITEM}', 'entry', $language->admin_delete));
  $template->replace('{DESTINATION}', 'index.php');
 }
 else
 {
  if (!$template) $template = new template("../$templatesdir/admin/reject.tpl");
  $template->replace('{ID}', $id);
 }
}
else if ($action == 'validatechecked')
{
 // handle members
 $totmems = $db->select('id', 'memberstable', 'id>0', 'ORDER BY id DESC', 'LIMIT 0,1');
 $num = $db->rowitem($totmems);
 for ($i=0; $i<=$num; $i++)
 {
  if ($todo == 'approve')
  {
   if ($member[$i])
   {
    $thismem = new member('id', $i);  
    $thismem->validated = 1;
    $thismem->update('validated');
	if ($thismem->email != '') emailmembervalidation($thismem);
   }
  }
  else if ($todo == 'reject')
  {
   if ($member[$i])
   {
    $thismem = new member('id', $i);  
    $thismem->deletethis();
   }
  }
 }

 // handle comments
 $totcoms = $db->select('id', 'commentstable', 'id>0', 'ORDER BY id DESC', 'LIMIT 0,1');
 $num = $db->rowitem($totcoms);
 for ($i=0; $i<=$num; $i++)
 {
  if ($todo == 'approve')
  {
   if ($comment[$i]) 
   {
    $thiscomment = new comment('dummy', $i); 
    $thiscomment->validated = 1;
    $thiscomment->update('validated');
    $memberid = $thiscomment->ownerid;
    if ($memberid > 0)
    {
     $amem = new member('id', $memberid);
     $amem->addcomment($i);
    }
    if (!$template) $template = new template("../$templatesdir/redirect.tpl");
    $template->replace('{MESSAGE}', str_replace('{TYPE}', 'comment', $language->admin_validate));
    $template->replace('{DESTINATION}', 'index.php');
   }
  }
  else if ($todo == 'reject')
  {
   if ($comment[$i])
   {
    $thiscomment = new comment('dummy', $i); 
    $thiscomment->deletethis();
   }
  }
 } 

 // handle links
 $totlinks = $db->select('id', 'linkstable', 'id>0', 'ORDER BY id DESC', 'LIMIT 0,1');
 $num = $db->rowitem($totlinks);
 for ($i=0; $i<=$num; $i++)
 {
  if ($link[$i])
  {
   if ($todo == 'approve')
   {
    $thislink = new onelink('id', $i);
    $thislink->validate();
    $memberid = $thislink->ownerid;
    if ($memberid > 0)
    {
     $amem = new member('id', $memberid);
     $amem->addentry($i);
    }
   }
   else if ($todo == 'reject')
   {
    $thislink = new onelink('id', $i);
    $thislink->reject($message);
   }
  }
 } 

 // show completed status
 if (!$template) $template = new template("../$templatesdir/redirect.tpl");
 if ($todo == 'approve') $template->replace('{MESSAGE}', str_replace('{TYPE}', 'selected item(s)', $language->admin_validate));
 if ($todo == 'reject') $template->replace('{MESSAGE}', str_replace('{TYPE}', 'selected item(s)', $language->admin_reject)); 
 $template->replace('{DESTINATION}', 'index.php');
}

else if ($action=='generatestatic')
{
 $template = new template("blank");
 $template->text = $language->admin_static;
 $dostatic = true;
}
else
{
  // display admin center and then display links awaiting validation
  $template = new template("../$templatesdir/admin/main.tpl");


  $unvalidated = getunvallinks();
  $unval = $db->numrows($unvalidated); 
 
  $template_linksbody = templateextract($template->text, '<!-- BEGIN VALIDATE AREA -->', '<!-- END VALIDATE AREA -->');
  $template->replace($template_linksbody, '{VALIDATEAREA}'); // replace with marker

  for ($count=0; $count<$unval; $count++)
  {
   $row = $db->row($unvalidated);  // get next unvalidated link
   $thislink = new onelink('row', $row);
   // print the details of this link to the screen, with links to click for validating
   $linksbody .= linkreplacements($template_linksbody, $thislink);
  }
  
  // now comments
  $template_comsbody = templateextract($template->text, '<!-- BEGIN VALIDATE COMMENTS AREA -->', '<!-- END VALIDATE COMMENTS AREA -->');
  $template->replace($template_comsbody, '{VALIDATECOMMENTS}'); // replace with marker
  $query = $db->select($settings->commentfields, 'commentstable', 'validated=0', 'ORDER BY id DESC', '');
  $num = $db->numrows($query);
  for ($count=0; $count<$num; $count++)
  {
   $row = $db->row($query);
   $thiscomment = new comment('row', $row);
   $comsbody .= commentreplacements($template_comsbody, $thiscomment);
  }

  // now members
  $template_memsbody = templateextract($template->text, '<!-- BEGIN VALIDATE MEMBERS AREA -->', '<!-- END VALIDATE MEMBERS AREA -->');
  $template->replace($template_memsbody, '{VALIDATEMEMBERS}'); // replace with marker
  $query = $db->select($settings->memberfields, 'memberstable', 'validated=0', 'ORDER BY id DESC', '');
  $num = $db->numrows($query);
  for ($count=0; $count<$num; $count++)
  {
   $row = $db->row($query);
   $thismem = new member('row', $row); 
   $memsbody .= memberreplacements($template_memsbody, $thismem);
  }

  $template->replace('{VALIDATEMEMBERS}', $memsbody);
  $template->replace('{VALIDATECATSAREA}', $catsbody); 
  $template->replace('{VALIDATEAREA}', $linksbody);
  $template->replace('{VALIDATECOMMENTS}', $comsbody);

  $categoryselect = $settings->categoryselector;
  $template->replace('{CATSELECTOR}', $categoryselect);

  $template->replace('{VERSIONNUMBER}', $version);
 }
// now we're back to outermost section within which the user's password is validated

}
require 'adminend.php';

?>
Return current item: WSN Guest