Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
NoFantasy
Worker
Worker



Joined: Apr 26, 2005
Posts: 114

PostPosted: Fri May 13, 2005 12:40 pm Reply with quote

For some time i have tried to get this module from Only registered users can see links on this board! Get registered or login! to work as it's supposed without any luck. I began to rewrite some parts, mostly adding language and cleaned up small parts.

Now i'm stuck...again. The mainproblem is that the script won't show the users in a spesific group. I'm no programmer so I might forgotten some essential things. Any suggestions is welcome (probably for the guys at webdever too). It seems to work fine at webdever's site, could it be a version-spesific thing is blocking something?
Here's "my" version of the script:
Code:
if ( !defined('MODULE_FILE') ) 

{
   die("You can't access this file directly...");
}

require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = "- "._PAGETITLE."";
$index = 1;

function ugheader() {
   global $admin, $db, $prefix, $admin_file, $module_name;
      OpenTable();
      echo "<center>&nbsp;<a href=\"modules.php?name=$module_name\">"._MAINGROUPS."</a>&nbsp;|&nbsp<a href=\"modules.php?name=$module_name&amp;op=list\">"._MAINEARN."</a>&nbsp;|&nbsp<a href=\"modules.php?name=$module_name&amp;op=users\">"._MAINTOP."</a>&nbsp";
   if (is_admin($admin)) {
   if ($admin_file == '') { $admin_file == 'admin'; }
      echo"<br>&nbsp;<a href=\"modules.php?name=$module_name&amp;op=alist\">"._MAINEDDESC."</a>&nbsp;|&nbsp;<a href=\"$admin_file.php?op=Groups\">"._MAINEDGRP."</a>&nbsp;|&nbsp;<a href=\"modules.php?name=$module_name&amp;op=modusers\">"._MAINEDUSR."</a>&nbsp;</center>";
   }
      echo "</center>";
      CloseTable();
      echo "<br>";
}

function arch() {
   global $db, $prefix, $module_name;
   include("header.php");
      ugheader();
      OpenTable();
      echo "<span class=\"content\"><center><b>"._GRHEAD."</b></center><br>";
      $sql = "SELECT * FROM ".$prefix."_groups ORDER BY points ASC";
      $result = $db->sql_query($sql);
   while ($row = $db->sql_fetchrow($result)) {
      $description = $row['description'];
      $gname = $row['name'];
      $gpoints = $row['points'];
      $id = $row['id'];
      echo "<br><a href=\"modules.php?name=$module_name&amp;op=group&amp;id=$id\">$gname</a><br>"._RECPOINT1." $gpoints "._RECPOINT2."<br>($description)<br>";
   }
      CloseTable();
      echo "<br>";
   include("footer.php");
}

function group($id) {
   global $db, $prefix, $module_name;
   include("header.php");
      ugheader();
      OpenTable();
      $sql = "SELECT * FROM ".$prefix."_groups WHERE `id`='$id' LIMIT 1";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $description = $row['description'];
      $gpoints = $row['points'];
      $gname = $row['name'];
      echo "<span class=\"content\"><b>$gname</b><br><br>"._RECPOINT1." $gpoints "._RECPOINT2."<br>$description</span>";
      CloseTable();
      OpenTable();
      echo "<span class=\"content\"><b>"._USRINGROUP."</b></span><br><br>";
      $sql = "SELECT `points` FROM ".$prefix."_groups WHERE `points` >$gpoints ORDER BY `points` ASC LIMIT 1";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $mpoints = $row['points'];
   if ($mpoints) {
      $sql = "SELECT `username`, `user_id`, `points` FROM ".$prefix."_users WHERE `points` <$mpoints AND `points` >=$gpoints AND `user_id` >1 ORDER BY `points` DESC";
      }
   else {
      $sql = "SELECT `username`, `user_id`, `points` FROM ".$prefix."_users WHERE `points` >=$gpoints AND `user_id` > 1 ORDER BY `points` DESC";
      }
      $result = $db->sql_query($sql);
   while ($row = $db->sql_fetchrow($result)) {
      $uid = $row['user_id'];
      $uname = $row['username'];
      $upoints = $row['points'];
   echo "<a href=\"forums.html?amp;file=profile&amp;mode=viewprofile&amp;u=$uid\">$uname</a> ($upoints "._POINTS.")<br><br>";
      }
      CloseTable();
   echo "<br>";
   include("footer.php");
}

function users() {
   global $db, $prefix;
   include("header.php");
      ugheader();
      OpenTable();
      echo "<span class=\"content\"><center><b>"._TOPUSR."</b></span><br><br><table width=\"300\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\"><tr><td width=\"100%\" align=\"center\"><span class=\"content\"><b>"._USR."</b></span></td><td align=\"center\"><span class=\"content\"><b>"._POINTS."</b></span></td></tr>";
      $sql = "SELECT `username`, `user_id`, `points` FROM ".$prefix."_users WHERE `user_id` > 1 ORDER BY `points` DESC LIMIT 50";
      $result=$db->sql_query($sql);
      $i = 1;
   while ($row = $db->sql_fetchrow($result)) {
      $id = $row['user_id'];
      $name = $row['username'];
      $points = $row['points'];
      echo "<tr><td align=\"left\"><span class=\"content\">$i: </span><a href=\"forums.html?amp;file=profile&amp;mode=viewprofile&amp;u=$id\">$name</a></td><td align=\"center\"><span class=\"content\">$points</span></td></tr>";
      $i++;
   }
      echo "</table></center><br>";
      CloseTable();
   include("footer.php");
}

function glist() {
   global $db, $prefix;
   include("header.php");
      ugheader();
      OpenTable();
      echo "<center><span class=\"content\"><b>"._POINTLIST."</b></span></center><br>";
      $sql = "SELECT `points` FROM ".$prefix."_groups_points ORDER BY `id` ASC LIMIT 21";
      $result=$db->sql_query($sql);
      $i = 1;
   while ($row = $db->sql_fetchrow($result))
   {
      ${'p'.$i.''} = $row['points'];
      $i++;
   }
      $sql = "SELECT `desc` FROM ".$prefix."_groups_info ORDER BY `id` ASC LIMIT 21";
      $result = $db->sql_query($sql);
      $i = 1;
   while ($row = $db->sql_fetchrow($result))
   {
      ${'i'.$i.''} = $row['desc'];
      $i++;
   }
      echo"<table border=\"0\" width=\"100%\" cellspacing=\"10px\"><tr><td align=\"center\" bgcolor=\"#FFFFFF\"><b>"._POINTNAME."</b></td><td align=\"center\" bgcolor=\"#FFFFFF\"><b>"._POINTDESC."</b></td><td align=\"center\" bgcolor=\"#FFFFFF\"><b>"._POINTS."</b></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST1." </span></td><td><span class=\"content\">$i1</span></td><td><span class=\"content\"> $p1 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST2." </span></td><td><span class=\"content\">$i2</span></td><td><span class=\"content\"> $p2 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST3." </span></td><td><span class=\"content\">$i3</span></td><td><span class=\"content\"> $p3 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST4." </span></td><td><span class=\"content\">$i4</span></td><td><span class=\"content\"> $p4 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST5." </span></td><td><span class=\"content\">$i5</span></td><td><span class=\"content\"> $p5 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST6." </span></td><td><span class=\"content\">$i6</span></td><td><span class=\"content\"> $p6 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST7." </span></td><td><span class=\"content\">$i7</span></td><td><span class=\"content\"> $p7 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST8." </span></td><td><span class=\"content\">$i8</span></td><td><span class=\"content\"> $p8 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST9." </span></td><td><span class=\"content\">$i9</span></td><td><span class=\"content\"> $p9 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST10." </span></td><td><span class=\"content\">$i10</span></td><td><span class=\"content\"> $p10 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST11." </span></td><td><span class=\"content\">$i11</span></td><td><span class=\"content\"> $p11 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST12." </span></td><td><span class=\"content\">$i12</span></td><td><span class=\"content\"> $p12 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST13." </span></td><td><span class=\"content\">$i13</span></td><td><span class=\"content\"> $p13 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST14." </span></td><td><span class=\"content\">$i14</span></td><td><span class=\"content\"> $p14 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST15." </span></td><td><span class=\"content\">$i15</span></td><td><span class=\"content\"> $p15 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST16." </span></td><td><span class=\"content\">$i16</span></td><td><span class=\"content\"> $p16 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST17." </span></td><td><span class=\"content\">$i17</span></td><td><span class=\"content\"> $p17 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST18." </span></td><td><span class=\"content\">$i18</span></td><td><span class=\"content\"> $p18 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST19." </span></td><td><span class=\"content\">$i19</span></td><td><span class=\"content\"> $p19 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST20." </span></td><td><span class=\"content\">$i20</span></td><td><span class=\"content\"> $p20 </span></td></tr>"
  . ""
  . "<tr><td><span class=\"content\"> "._POINTLIST21." </span></td><td><span class=\"content\">$i21</span></td><td><span class=\"content\"> $p21 </span></td></tr></table>"
 ."";
      CloseTable();
      echo "<br>";
   include("footer.php");
   }

function alist() {
   global $db, $prefix, $admin, $module_name;
   if (!is_admin($admin)) {
   die("Access Denied");
   }
   include('header.php');
      ugheader();
      OpenTable();
      echo "<center><span class=\"content\"><b>"._POINTLISTADM."</b></span></center><br>";
      $sql = "SELECT `points` FROM ".$prefix."_groups_points ORDER BY `id` ASC LIMIT 21";
      $result=$db->sql_query($sql);
      $i = 1;
   while ($row = $db->sql_fetchrow($result))
   {
      ${'p'.$i.''} = $row['points'];
      $i++;
   }
      $sql = "SELECT `desc` FROM ".$prefix."_groups_info ORDER BY `id` ASC LIMIT 21";
      $result = $db->sql_query($sql);
      $i = 1;
   while ($row = $db->sql_fetchrow($result))
   {
      ${'i'.$i.''} = $row['desc'];
      $i++;
   }
      echo"<table border=\"0\" width=\"100%\" cellspacing=\"10px\"><tr><td align=\"center\" bgcolor=\"#FFFFFF\"><b>"._POINTNAME."</b></td><td align=\"center\" bgcolor=\"#FFFFFF\"><b>"._POINTDESC."</b></td><td align=\"center\" bgcolor=\"#FFFFFF\"><b>"._POINTLISTEDIT."</b></td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST1." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i1</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"1\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST2." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i2</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"2\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST3." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i3</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"3\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST4." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i4</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"4\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST5." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i5</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"5\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST6." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i6</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"6\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST7." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i7</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"7\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST8." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i8</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"8\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST9." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i9</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"9\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST10." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i10</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"10\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST11." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i11</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"11\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST12." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i12</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"12\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST13." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i13</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"13\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST14." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i14</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"14\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST15." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i15</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"15\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST16." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i16</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"16\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST17." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i17</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"17\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST18." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i18</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"18\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST19." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i19</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"19\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST20." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i20</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"20\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr>"
  . ""
  . "<tr><form action=\"modules.php\" method=\"post\"><td><span class=\"content\"> "._POINTLIST21." </span></td><td><textarea name=\"text\" rows=\"2\" cols=\"30\">$i21</textarea></td><td align=\"center\">&nbsp;<input type=\"hidden\" name=\"name\" value=\"$module_name\"><input type=\"hidden\" name=\"id\" value=\"21\"><input type=\"submit\" name=\"op\" value="._EDBOUTT1."></form>&nbsp;</td></tr></table>"
 ."";
      CloseTable();
      echo "<br>";
   include("footer.php");
}

function Submit() {
   global $db, $prefix, $id, $text, $admin;
   if (!is_admin($admin)) {
   die("Access Denied");
   }
   include("header.php");
      ugheader();
      OpenTable();
      $text = addslashes($text);
      $sql = "UPDATE ".$prefix."_groups_info SET `desc`=$text WHERE `id`=$id LIMIT 1";
      $result=$db->sql_query($sql);
   if ($result)
   {
      echo ""._EDITDESCSUC."";
   } else {
      echo "<span class=\"content\">"._EDITERR."</span>";
   }
      CloseTable();
      echo "<br>";
   include("footer.php");
}

function modusers() {
   global $db, $prefix;
   include("header.php");
      ugheader();
      OpenTable();
      $res = $db->sql_query("SELECT `username`, `user_id`, `points` FROM ".$prefix."_users WHERE `user_id`>1 ORDER BY `username`");
      $num = $db->sql_numrows($res);
      echo "<center><span class=\"content\"><b>"._EDITUSRPOINT."</b></span></center><br><br>
      <scri pt type=\"text/javascri pt\">
      var unames=new Array($num)
      ";
   while($row = $db->sql_fetchrow($res)) {
      echo "unames[${row['user_id']}]=\"${row['points']}\"\n";
   }
      echo "
      function put(form)
   {
      option=form.id.options[form.id.selectedIndex].value
      txt=unames[option]
      form.points.value=txt
   }
      </scri pt>
      "
      .""
      ."<center><form action=\"$PHP_SELF\" method=\"post\">
      <select name=\"id\" onchange=\"put(this.form)\">";
      $sql = $db->sql_query("SELECT `username`, `user_id`, `points` FROM ".$prefix."_users WHERE `user_id`>1 ORDER BY `username`");
   while ($row = $db->sql_fetchrow($sql)) {
      $id = $row['user_id'];
      $name = $row['username'];
      $points = $row['points'];
       echo "<option value=\"${row['user_id']}\">${row['username']}</option>";
   }
       echo "</select>" 
      ."<input type=\"text\" name=\"points\" value=\"$points\" size=\"5\" maxlength=\"5\">"
      ."<input type=\"submit\" name=\"op\" value="._EDBOUTT2.">"
      ."</form></center>";
      CloseTable();
      echo "<br>";
      include("footer.php");
}

function AddMember() {
   global $db, $prefix, $id, $name, $points, $admin, $module_name;
   if (!is_admin($admin)) {
   die("Access Denied");
   }
      $result=$db->sql_query("UPDATE ".$prefix."_users SET points=$points WHERE user_id=$id LIMIT 1");
   if ($result)
   {
   include("header.php");
      ugheader();
      OpenTable();
   Header("Location: modules.php?name=$module_name&op=modusers");
   } else {
      echo "<span class=\"content\">"._EDITERR."</span>";
   }
      CloseTable();
      echo "<br>";
   include("footer.php");
}

switch($op) {
default:
arch();
break;

case "group":
group($_GET['id']);
break;

case "Submit":
Submit();
break;

case "users":
users();
break;

case "list":
glist();
break;

case "alist":
alist();
break;

case "modusers":
modusers();
break;

case "Edit Member":
AddMember();
break;

}


Hope any of you have time to take a look. Thanks in advance.


Last edited by NoFantasy on Sat May 14, 2005 2:57 pm; edited 2 times in total 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri May 13, 2005 10:02 pm Reply with quote

Are you talking about in this routine?
Code:
function users() {

 global $db, $prefix;
 include("header.php");
  ugheader();
  OpenTable();
  echo "<span class=\"content\"><center><b>"._TOPUSR."</b></span><br><br><table width=\"300\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\"><tr><td width=\"100%\" align=\"center\"><span class=\"content\"><b>"._USR."</b></span></td><td align=\"center\"><span class=\"content\"><b>"._POINTS."</b></span></td></tr>";
  $sql = "SELECT `username`, `user_id`, `points` FROM ".$prefix."_users WHERE `user_id` > 1 ORDER BY `points` DESC LIMIT 50";
  $result=$db->sql_query($sql);
  $i = 1;
 while ($row = $db->sql_fetchrow($result)) {
  $id = $row[user_id];
  $name = $row[username];
  $points = $row[points];
  echo "<tr><td align=\"left\"><span class=\"content\">$i: </span><a href=\"forums.html?amp;file=profile&amp;mode=viewprofile&amp;u=$id\">$name</a></td><td align=\"center\"><span class=\"content\">$points</span></td></tr>";
  $i++;
 }
  echo "</table></center><br>";
  CloseTable();
 include("footer.php");
 
View user's profile Send private message
NoFantasy







PostPosted: Sat May 14, 2005 9:12 am Reply with quote

This seems to be the main-problem.
Code:
function group($id) { 

 include("header.php");
 global $db, $prefix, $module_name;
  ugheader();
  OpenTable();
  $sql = "SELECT * FROM ".$prefix."_groups WHERE `id`='$id' LIMIT 1";

If I change the statement to
Code:
$sql = "SELECT * FROM ".$prefix."_groups WHERE `id`=3 LIMIT 1";

(group number three) this function seems to be working fine (a static selection of course). It's supposed to fetch the $id from function arch()
 
Raven







PostPosted: Sat May 14, 2005 9:31 am Reply with quote

To see if $id is resolving, modify this
Code:
function group($id) {

 include("header.php");
to
Code:
function group($id) {

die('id = '.$id);
 include("header.php");
 
NoFantasy







PostPosted: Sat May 14, 2005 10:40 am Reply with quote

Seems it don't...
Getting a white page showing
Code:
id = 
 
Raven







PostPosted: Sat May 14, 2005 10:48 am Reply with quote

I don't know this mod so it's difficult to diagnose. In function arch() there is this
Code:
echo "<br><a href=\"modules.php?name=$module_name&amp;op=group&amp;id=$id\">$gname</a><br>"._RECPOINT1." $gpoints "._RECPOINT2."<br>($description)<br>";

so it appears there is a hyperlink you click on that should call the group function and pass the $id. When you mouse over that hyperlink, does the id=$id have a value?
 
NoFantasy







PostPosted: Sat May 14, 2005 10:53 am Reply with quote

Yes, the arch()-function seems to be working as it should. Listing all groups with description and the right id-value in the link.
 
Raven







PostPosted: Sat May 14, 2005 12:37 pm Reply with quote

In functions arch() and group(), move the global statement ahead of the include("header.php"); statement.
 
NoFantasy







PostPosted: Sat May 14, 2005 1:08 pm Reply with quote

A better way, thanks...but it didn't solve much. Still the same result as before.
Normally, how is a statement passed from one function to another? Is the $id-statement correctly placed everywhere? I have looked at other scripts, and they seems similar to this. Could it be the line of order of the functions? Ex. should function arch() come after function groups() ?
 
Raven







PostPosted: Sat May 14, 2005 1:26 pm Reply with quote

The PHP compiler makes 2 passes of the script code. During the first pass it compiles all the functions amongst other things. So, the order is not significant. I keep noticing some really bad programming (no offence). In function arch() and anywhere else you see this, change code like this
Code:
  $description = "$row[description]";

  $gname = "$row[name]";
  $gpoints = "$row[points]";
  $id = "$row[id]";
to
Code:
  $description = $row['description'];

  $gname = $row['name'];
  $gpoints = $row['points'];
  $id = $row['id'];

You should never surround array definitions with quotes like that. And you ALWAYS want to use single quotes inside of those brackets. Make those changes to see if some anomaly is happening.
 
NoFantasy







PostPosted: Sat May 14, 2005 1:46 pm Reply with quote

*lol* ...no offence taken at all.

When the $id is used other places in the script (function modusers() ) pointing to the user_id, could it in other words be a conflict?
 
Raven







PostPosted: Sat May 14, 2005 2:14 pm Reply with quote

Try changing
Code:
case "group":

group($id);
break;
to
Code:
case "group":

group($_GET['id']);
break;
 
NoFantasy







PostPosted: Sat May 14, 2005 2:48 pm Reply with quote

Jackpot!
Great, thanks alot Raven!

Is this a version-spesific fix? I'll inform the webdever's team anyway, they might have use for this.

The next thing is now how the update-function works. I haven't done anything with those yet, but it needs to be done. None of the functions that's supposed to change groupsdescription and userpoints works. I'll look into them myself first, but I might come back and ask for help when i'm stuck again Wink
 
Raven







PostPosted: Sat May 14, 2005 3:00 pm Reply with quote

No. It's not a phpnuke issue, per se. It just dawned on me that you were passing a variable ($id) that wasn't defined in the module. This just hilights the issue. It fixes that issue with groups(). If you had another case call that needed $id you would need to tell PHP where to get it. Also, that module may have been written expecting register_globals to be "on" in which case $id would have been defined. But, that's a security issue if not coded correctly. So, you must tell PHP where to get the value for $id, which in this case is from the $_GET array.
 
NoFantasy







PostPosted: Sun Jun 05, 2005 10:53 am Reply with quote

I'm currently working on another module and the issue appears again. I used the solution with $_GET['id'] and that part seems to be working. This module highlights the thing mentioned above with more cases passing the id-variable.
I'm having trouble to find out where exactly the variable is stored and where to get it.

The problem is function editstory() -> function updatestory()
This is the relevant part of the code:
Code:
function roomstory() {

   global $prefix, $db;
      $result = $db->sql_query("SELECT * FROM ".$prefix."_chatrom_story");
   while ($row = $db->sql_fetchrow($result)) {
      $id = $row['id'];
      $stitle = $row['stitle'];
      $slinktitle = $row['slinktitle'];
      $sstory = $row['sstory'];
      }
include ("header.php");
    OpenTable();
      echo "<center><font class=\"title\"><b>"._CHATADMIN."</b></font></center>";   
    CloseTable();
      echo "<br>";   
    OpenTable();
      echo "<center><font class=\"option\"><a href=\"admin.php?op=chatconf\"><b>"._CHATCONF."</b></a></font> | <font class=\"option\"><a href=\"admin.php?op=navbarconf\"><b>"._MAINMENU."</b></a></font> | <font class=\"title\"><b><font color=\"Red\">"._STORYMENU."</font></b></font></center><br><br>"
       ."<form action=\"admin.php\" method=\"post\">"
      ."<b>"._STORY."</b><br>"
      .""._STORYTITLE."<br>"
      ."<input type=\"text\" name=\"stitle\" size=\"100\" maxlength=\"100\"><br>"
      .""._STORYLINKTITLE."<br>"
      ."<input type=\"text\" name=\"slinktitle\" size=\"50\" maxlength=\"50\"><br>"
      .""._STORYCONTENT."<br>"
      ."<textarea wrap=\"virtual\" cols=\"100\" rows=\"12\" name=\"sstory\"></textarea><br><br>"
      ."<input type=\"hidden\" name=\"op\" value=\"poststory\">"
      ."<input type=\"submit\" value=\""._CONFSAVE."\">"
      ."</form>"
      ."<hr>"
      ."<center><b>"._STORYLIST."</b></center>"
      ."<table><td>$stitle ($slinktitle)</td><td><a href=\"admin.php?op=editstory&id=$id\">"._EDITSTORY."</a></td><td><a href=\"admin.php?op=delstory&id=$id\">"._DELSTORY."</a></td></table>";
   CloseTable();
include("footer.php");
}

function poststory($stitle, $slinktitle, $sstory) {
    global $prefix, $db;
      $db->sql_query("insert into ".$prefix."_chatrom_story values (NULL, '$stitle', '$slinktitle', '$sstory')");
      Header("Location: admin.php?op=roomstory");
    }
   
function editstory($id) {
    global $prefix, $db;
      $result = $db->sql_query("SELECT id, stitle, slinktitle, sstory FROM ".$prefix."_chatrom_story WHERE id='$id'");
   while ($row = $db->sql_fetchrow($result)) {
      $id = $row['id'];
      $stitle = $row['stitle'];
      $slinktitle = $row['slinktitle'];
      $sstory = $row['sstory'];
      }
include ("header.php");
   OpenTable();
      echo "<center><font class=\"title\"><b>"._CHATADMIN."</b></font></center>";   
   CloseTable();
      echo "<br>";   
   OpenTable();
      echo "<center><font class=\"option\"><a href=\"admin.php?op=chatconf\"><b>"._CHATCONF."</b></a></font> | <font class=\"option\"><a href=\"admin.php?op=navbarconf\"><b>"._MAINMENU."</b></a></font> | <font class=\"title\"><b><font color=\"Red\">"._STORYMENU."</font></b></font></center><br><br>"
       ."<form action=\"admin.php\" method=\"post\">"
      ."<input type=\"hidden\" name=\"id\" size=\"50\" value=\"$id\">"
      ."<b>"._STORY."</b><br>"
      .""._STORYTITLE."<br>"
      ."<input type=\"text\" name=\"stitle\" size=\"100\" maxlength=\"100\" value=\"$stitle\"><br>"
      .""._STORYLINKTITLE."<br>"
      ."<input type=\"text\" name=\"slinktitle\" size=\"50\" maxlength=\"50\" value=\"$slinktitle\"><br>"
      .""._STORYCONTENT."<br>"
      ."<textarea wrap=\"virtual\" cols=\"100\" rows=\"12\" name=\"sstory\">$sstory</textarea><br><br>"
      ."<input type=\"hidden\" name=\"op\" value=\"updatestory\">"
      ."<input type=\"submit\" value=\""._CONFSAVE."\">"
      ."</form>";
   CloseTable();
include("footer.php");
}
   
function updatestory($id, $stitle, $slinktitle, $sstory) {
    global $prefix, $db;
      $db->sql_query("update ".$prefix."_chatrom_story set stitle='$stitle', slinktitle='$slinktitle', sstory='$sstory' WHERE id='$id'");
    Header("Location: admin.php?op=roomstory");
}

switch($op) {
   
    case "roomstory":
    roomstory();
    break;
   
   case "poststory":
    poststory($stitle, $slinktitle, $sstory);
    break;
   
    case "editstory":
    editstory($_GET['id']);
    break;
   
   case "updatestory":
    updatestory($id, $stitle, $slinktitle, $sstory);
    break;
}
 
Raven







PostPosted: Sun Jun 05, 2005 1:16 pm Reply with quote

I don't understand what your exact issue is?
 
NoFantasy







PostPosted: Sun Jun 05, 2005 1:31 pm Reply with quote

Sorry, it's my norwegian-english...I'll try to explain better:
I want this part of the script to do three things.
1. Add a new story.
2. Edit a existing story
3. Delete a existing story

Part 1 and 3 is working as it's supposed.
Part 2 is the problem.
Function editstory() collects the existing information based on $id and shows the form so that I can edit. The form sends the information to function updatestory() so that it can be insertetd into the database.
It seems to be a problem passing the variables from function editstory() to function updatestory().

I don't know if I have used the right $'s in case "updatestory" nor in the functions. For all that I know, it might be another problem with both functions mentioned.
Hope this helps, sorry again for my poor translation from norwegian to english *lol*
 
Raven







PostPosted: Sun Jun 05, 2005 1:50 pm Reply with quote

After the global statement in updatestory(), place this code to see what's happening (or not)
Code:
echo '$id = '.$id.'<br />$stitle = '.$stitle.'<br />$slinktitle = '.$slinktitle.'<br />$sstory = '.$sstory; die();
 
NoFantasy







PostPosted: Sun Jun 05, 2005 2:43 pm Reply with quote

If it was like this you meant, the whole thingy turns white...Like when you have a . or ; missing inside the script...
Code:
function updatestory($id, $stitle, $slinktitle, $sstory) {

    global $prefix, $db;
      echo '$id = '.$id.'<br />$stitle = '.$stitle.'<br />$slinktitle = '.$slinktitle.'<br />$sstory = '.$sstory; die();
      $db->sql_query("update ".$prefix."_chatrom_story set stitle='$stitle', slinktitle='$slinktitle', sstory='$sstory' WHERE id='$id'");
    Header("Location: admin.php?op=roomstory");
}
 
Raven







PostPosted: Sun Jun 05, 2005 2:54 pm Reply with quote

There's nothing wrong with that statement that I can see. If you comment it out does it then work? If so, then try this
Code:
echo '$id = '."$id".'<br />$stitle = '."$stitle".'<br />$slinktitle = '."$slinktitle".'<br />$sstory = '."$sstory"; die();
 
NoFantasy







PostPosted: Sun Jun 05, 2005 3:12 pm Reply with quote

Sorry, that was my webhotel down for a few minutes...not the script.
The outcome is:
Code:
$id = 

$stitle = Title goes here
$slinktitle = Linktitle goes here
$sstory = Text goes here


So, it's the passing of $id again...
 
NoFantasy







PostPosted: Sun Jun 05, 2005 3:17 pm Reply with quote

Speaking of webhotel, this is the php-info if that might help:
http://sm1.nordkapp.net/pi.php

As far as I can see, the register_globals is set to 'on', among other things.
 
Raven







PostPosted: Sun Jun 05, 2005 3:33 pm Reply with quote

Have you tried
Code:
updatestory($_GET['id'], $stitle, $slinktitle, $sstory);
 
NoFantasy







PostPosted: Sun Jun 05, 2005 3:37 pm Reply with quote

Yes, it gives the same result as with
Code:
updatestory($id, $stitle, $slinktitle, $sstory);
 
Raven







PostPosted: Sun Jun 05, 2005 3:48 pm Reply with quote

Try
Code:
updatestory($_POST['id'], $stitle, $slinktitle, $sstory);

Just want to rule that out.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©