[php] Mod Rewrite and Members list.

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by Shadow121, Mar 24, 2008.

  1. Shadow121

    Shadow121 Member

    Messages:
    901
    Likes Received:
    0
    Trophy Points:
    16
    Okay so i have my members script here and some errors below which i've tried to solve on my own after searching around a few places on google.

    Basically set up how i want showing some debugging things somewhere in there marked by a comment. Theres really two-three errors.
    1. MOD Rewrite is picking up the wrong rule its using &y= instead of &user=
    2. Its only showing 2 out of three users.... http://joe.hrwr.org/members/
    3. I'll post with this error when i figure it out again >/

    My htaccess File.
    Code:
    RewriteEngine On
     RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]+)/([0-9]+)/$ index.php?x=$1&y=$2&page=$3&id=$4 [L]
     RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]+)/$ index.php?x=$1&y=$2&page=$3 [L]
     RewriteRule ^([a-zA-Z]+)/([0-9]+)/([0-9]+)/$ index.php?x=$1&id=$2&pg=$3 [L]
     RewriteRule ^members/([a-zA-Z]+)$ index.php?x=members&user=$1 [L]
     RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/$ index.php?x=$1&y=$2 [L]
     RewriteRule ^([a-zA-Z]+)/([0-9]+)/$ index.php?x=$1&id=$2 [L]
     RewriteRule ^([a-zA-Z]+)/$ index.php?x=$1 [L]
     RewriteRule ^([0-9]+)/$ index.php?pg=$1 [L]
     RewriteRule ^ver.jpg$ /Lib/imgvers.php
    My Memebrs file.
    Code:
     <?php
      $pg = (int)$_GET['pg'];
      if (!$pg) {
          $pg = 1;
      } else {
          $pg = $pg;
      }
      $mems_perpage = $settings->memspage;
      $curr_mempage = (($pg * $mems_perpage) / $mems_perpage);
      $username = addslashes($_GET['user']);
      if (!$username) {
          $getusers = $MySql->sqlQuery("SELECT * FROM `" . DB_PREFIX .
              "users` ORDER BY `id` DESC LIMIT $curr_mempage, $mems_perpage");
          $gettotal = $MySql->sqlQuery("SELECT * FROM `" . DB_PREFIX . "users`");
          $totalusers = $MySql->numRows($gettotal);
          $total_pages = ceil($totalusers / $mems_perpage);
     //start debug
          print $mems_perpage.', '; //total members per page
          print $totalusers.', '; //total users in db
          print $total_pages.', '; //total pages needed
          print $username.', '; //the username selected
          print $_GET['x'].', '; //current x page
          print $_GET['y']; //errored y page its meant to be user.
     //end debug
          print "<table width=\"300\">
          <tr>
          <th class=\"first\" align=\"center\" valign=\"middle\">
          <b>ID</b>
          </th>
          <th align=\"center\" valign=\"middle\">
          <b>Username</b>
          </th>
          <th align=\"center\" valign=\"middle\">
          <b>Position</b>
          </th>
          <th align=\"center\" valign=\"middle\">
          <b>Status</b>
          </th>
          </tr>";
          $class1 = "row-a";
          $class2 = "row-b";
          $class = $class1;
          while ($mem_stuff = $MySql->fetchArray($getusers)) {
              $getperms_query = $MySql->sqlQuery("SELECT * FROM `".DB_PREFIX."groups` WHERE `lvlnum` = '$mem_stuff->userlevel';");
              $getperms = $MySql->fetchArray($getperms_query);
              print "<tr class=\"$class\">
              <td class=\"first\" align=\"center\" valign=\"middle\">
              $mem_stuff->id
              </td>
              <td class=\"first\" align=\"center\" valign=\"middle\">
              <a href=\"".site_link."/members/$mem_stuff->username/\">$mem_stuff->username</a>
              </td>
              <td class=\"first\" align=\"center\" valign=\"middle\">
              $getperms->full_name
              </td>
              <td class=\"first\" align=\"center\" valign=\"middle\">
              Not Done
              </td>
              </tr>";
              if ($class == $class1) {
                  $class = $class2;
              } else {
                  $class = $class1;
              }
          }
          print "</table>";
      } else {
      
      }
      ?>

    Anyone got some suggestions or answers?
     
  2. woiwky

    woiwky New Member

    Messages:
    390
    Likes Received:
    0
    Trophy Points:
    0
    1. It looks like you forgot the last forward slash before the $ in ^members/([a-zA-Z]+)$

    2. I would try $curr_mempage = (($pg - 1) * $mems_perpage); instead of what you currently got.

    3. I'll post with the solution when you figure out the error :p
     
  3. Shadow121

    Shadow121 Member

    Messages:
    901
    Likes Received:
    0
    Trophy Points:
    16
    1. yep now it works >.o
    2. Yep works now =) thanks
    3. forget about i guess o_O'
     
    Last edited: Mar 24, 2008
  4. dbaker

    dbaker New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hi there

    I have this problem:

    Fatal error: SUHOSIN - Use of preg_replace() with /e modifier is forbidden by configuration in /home/leandro/public_html/wrybread/wordpress/wp-includes/kses.php(627) : regexp code on line 627

    What does this mean? When I uploaded the files last week or so there wasn't any problem. So why now. Please reply.
     
  5. Starshine

    Starshine Legend Killer

    Messages:
    14,423
    Likes Received:
    0
    Trophy Points:
    0
    Re: Hi there

    1. Next time, please don't hijack other people's threads.
    2. Use our search feature. This has been answered dozens of times. :)
    3. Login to your AMP ( Account Management Panel : www.x10hosting.com/account and upgrade your PHP to Intermediate.
     

Share This Page