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


function generatelinksoptions()
{
 global $settings;
 $linkfields = explode(',', $settings->linkfields);
 $num = sizeof($linkfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $linkfields[$count];
  if (!(strstr($settings->excludedtoadmin, '|'. $field . '|')))
  {
   $fieldname = $field;
   if ($field == 'catid') $fieldname = 'category name';
   if ($field == 'recipurl') $fieldname = 'reciprocal url';
   if ($field == 'numcomments') $fieldname = 'number of comments';
   $linksoptions .= "<option value=$field>$fieldname</option>";
  }
 }
 return $linksoptions;
}

function ordermemoptions($selected)
{
 global $settings;
 $memfields = explode(',', $settings->memberfields);
 $num = sizeof($memfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $memfields[$count];
  $fieldfull = "ORDER BY $field ASC";
  $english = "By $field ascending";
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $memsoptions .= "<option value='$fieldfull' $isselected>$english</option>";
  $fieldfull = "ORDER BY $field DESC";
  $english = "By $field descending";   
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $memsoptions .= "<option value='$fieldfull' $isselected>$english</option>";
 }
 return $memsoptions;
}

function orderlinksoptions($selected)
{
 global $settings;
 $linkfields = explode(',', $settings->linkfields);
 $num = sizeof($linkfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $linkfields[$count];
  $fieldfull = "ORDER BY $field ASC";
  $english = "By $field ascending";
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $linksoptions .= "<option value='$fieldfull' $isselected>$english</option>";
  $fieldfull = "ORDER BY $field DESC";
  $english = "By $field descending";   
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $linksoptions .= "<option value='$fieldfull' $isselected>$english</option>";
 }
 return $linksoptions;
}

function ordercommentsoptions($selected)
{
 global $settings;
 $commentfields = explode(',', $settings->commentfields);
 $num = sizeof($commentfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $commentfields[$count];
  $fieldfull = "ORDER BY $field ASC";
  $english = "By $field ascending";
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $commentsoptions .= "<option value='$fieldfull' $isselected>$english</option>";
  $fieldfull = "ORDER BY $field DESC";
  $english = "By $field descending";   
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $commentsoptions .= "<option value='$fieldfull' $isselected>$english</option>";
 }
 return $commentsoptions;
}

function ordercatsoptions($selected)
{
 global $settings;
 $categoryfields = explode(',', $settings->categoryfields);
 $num = sizeof($categoryfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $categoryfields[$count];
  $fieldfull = "ORDER BY $field ASC";
  $english = "By $field ascending";
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $categoryoptions .= "<option value='$fieldfull' $isselected>$english</option>";
  $fieldfull = "ORDER BY $field DESC";
  $english = "By $field descending";   
  if ($fieldfull == $selected) $isselected = " selected"; else $isselected = '';
  $categoryoptions .= "<option value='$fieldfull' $isselected>$english</option>";
 }
 return $categoryoptions;
}

function generatecatsoptions()
{
 global $settings;
 $categoryfields = explode(',', $settings->categoryfields);
 $num = sizeof($categoryfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $categoryfields[$count];
  if (!(strstr($settings->excludedtoadmin, '|'. $field . '|')))
  {
   $fieldname = $field;
   if ($field == 'numlinks') $fieldname = 'number of links';
   $categoriesoptions .= "<option value=$field>$fieldname</option>";
  }
 }
 return $categoriesoptions;
}

function generatecommentoptions()
{
 global $settings;
 $commentfields = explode(',', $settings->commentfields);
 $num = sizeof($commentfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $commentfields[$count];
  if (!(strstr($settings->excludedtoadmin, '|'. $field . '|')))
  {
   $fieldname = $field;
   if ($field == 'postername') $fieldname = 'poster name';
   if ($field == 'linkname') $fieldname = 'link name';  
  $commentoptions .= "<option value=$field>$fieldname</option>";
  }
 }
 return $commentoptions;
}


function generatememberoptions()
{
 global $settings;
 $memberfields = explode(',', $settings->memberfields);
 $num = sizeof($memberfields);
 for ($count=0; $count<$num; $count++)
 {
  $field = $memberfields[$count];
  if (!(strstr($settings->excludedtoadmin, '|'. $field . '|')))
  {
   $fieldname = $field;
   if ($field == 'postername') $fieldname = 'poster name';
   if ($field == 'linkname') $fieldname = 'link name';  
  $memberoptions .= "<option value=$field>$fieldname</option>";
  }
 }
 return $memberoptions;
}

function sendvalidationemail($thislink)
{
 global $language, $settings;
 $adminaddress = $settings->email;
 $submitter = $thislink->email;
 $subject = $language->email_notifyusertitle;
 $message = $language->email_notifyuserbody;
 $message = linkreplacements($message, $thislink);   
 $message = str_replace('{DIRURL}', $settings->dirurl, $message);
 $message = decodeit($message);
 sendemail("$submitter", "$subject", "$message", "From: $adminaddress");
}

function updatelinkcounters($next)
{
 global $db, $settings, $inc, $linkstable, $commentstable;
 // recalculate comment totals for links
 $query = $db->query("SELECT id FROM $linkstable ORDER BY id LIMIT $next,$inc");
 $n = $db->numrows($query);
 $sofar = 0;
 for ($x=0; $x<$n; $x++)
 {
  $id = $db->rowitem($query);
  $tot = $db->query("SELECT COUNT(id) FROM $commentstable WHERE linkid=$id AND validated=1");
  $doit = $db->update('linkstable', 'numcomments', $tot, "id=$id");
  $sofar++;
 }
 return true;
}

function updatememcounters($next)
{ 
 global $db, $settings, $inc;
 // re-calculate number of links, comments and hits for member profiles
 $query = $db->select($settings->memberfields, 'memberstable', 'id>0', '', '');
 $num = $db->numrows($query);
 for ($count=$next; (($count<$num) && ($count<($next+$inc))); $count++)
 {
  $row = $db->row($query);
  $mem = new member('row', $row);
  $q2 = $db->select('id', 'linkstable', "ownerid=". $mem->id ." AND hide=0 AND validated=1", '', '');
  $tot = $db->numrows($q2);
  $mem->entries = $tot;
  $q3 = $db->select('id', 'commentstable', 'ownerid='. $mem->id .' AND validated=1', '', '');
  $totcom = $db->numrows($q3);
  $mem->comments = $totcom;
  $mem->update('entries,comments');
 } 
 return true;
}

function debugmenu($current)
{
 if (($current == 0) || ($current == 'no')) $stuff = '<option value=0 selected>None</option>';
 else $stuff .= '<option value=0>None</option>';
 if ($current == 1) $stuff .= '<option value=1 selected>Show queries as executed</option>';
 else $stuff .= '<option value=1>Show queries as executed</option>';
 if ($current == 2) $stuff .= '<option value=2 selected>Show queries at bottom after page is complete</option>';
 else $stuff .= '<option value=2>Show queries at bottom after page is complete</option>';
 if ($current == 3) $stuff .= '<option value=3 selected>Only show queries to admin, not to other users</option>';
 else $stuff .= '<option value=3>Only show queries to admin, not to other users</option>';
 if ($current == 4) $stuff .= '<option value=4 selected>Only show totals and execution time</option>';
 else $stuff .= '<option value=4>Only show totals and execution time</option>';
 if ($current == 5) $stuff .= '<option value=5 selected>Show totals and execution time to admin only</option>';
 else $stuff .= '<option value=5>Show totals and execution time to admin only</option>';
 return $stuff;
}

function registrationmenu($current)
{
 if ($current == 'direct') $stuff = "<option value='direct' selected>Direct</option>";
 else $stuff .= "<option value='direct'>Direct</option>";
 if ($current == 'email') $stuff .= "<option value='email' selected>E-mail activation code</option>";
 else $stuff .= "<option value='email'>E-mail activation code</option>";
 if ($current == 'validate') $stuff .= "<option value='validate' selected>Require validation by admin</option>";
 else $stuff .= "<option value='validate'>Require validation by admin</option>";
 return $stuff;
}



?>
Return current item: WSN Guest