Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Admin Panel Gone Wrong

    Hi, yesturday i made an admin panel for a CMS im working on.
    the admin panel is protected by a .htaccess & .htpasswd file authentication + user authentication which is all dealt with by php and stored in my database.

    Anyway, as i said i've only just created it hence i've only got a few icons for the actual panel itsself.

    heres the code for the admin panel index.php

    PHP Code:
    $catid mysql_real_escape_string($_GET['catid']);

    if(
    $catid == "1"){
     
    $admin_title "Content Management";
    }elseif(
    $catid == "2"){
     
    $admin_title "User Management";
    }elseif(
    $catid == "3"){
     
    $admin_title "System_Management";
    }

    $admin mysql_query("SELECT * FROM administration WHERE catid='{$catid}'");
    $admin mysql_fetch_array($admin);
    echo 
    "     <td valign=\"top\">\n";
    echo 
    "      <table class=\"news_tbl\" cellspacing=\"0\">\n       <tr>\n        <td class=\"news_title\">".$admin_title."</td>\n       </tr>\n";
    echo 
    "<Tr><Td>";
    $i 0;
    while(
    $admin mysql_fetch_array(mysql_query("SELECT * FROM administration WHERE catid='{$catid}' ORDER BY name ASC"))){
     if(
    $i == 0){
      echo 
    "<tr>";
     }
     echo 
    "<td class=\"icon\"><a href=\"index.php?module=".$admin['id']."\"><img src=\"/themes/".$site['theme']."/images/administration/".$admin['icon']."\" alt=\"".$admin['name']."\"><br />";
     echo 
    $admin['name']."</a></td>";
     if(
    $i == "4"){
      echo 
    "</tr>";
      
    $i "0";
     }
     
    $i++;

    i inserted a admin "module" today named : Users.
    with this information:

    Code:
    INSERT INTO `ccurityo_cms`.`administration` (
    `id` ,
    `name` ,
    `file_location` ,
    `auth` ,
    `icon` ,
    `catid`
    )
    VALUES (
    NULL , 'users', 'users.php', 'U', 'UsersFolderIcon.png', '2'
    );
    Yet all i get is a continous flood of

    Code:
    <td class="icon"><a href="index.php?module=1"><img src="UsersFolderIcon.png" alt="users"><br />users</a></td>
    Any ideas of what's wrong?

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Because you have got the while loop doing the query over and over.

    Try this.

    PHP Code:
    $result mysql_query("SELECT * FROM administration WHERE catid='{$catid}' ORDER BY name ASC");
    while(
    $admin mysql_fetch_array($result)){
     if(
    $i == 0){
      echo 
    "<tr>";
     }
     echo 
    "<td class=\"icon\"><a href=\"index.php?module=".$admin['id']."\"><img src=\"/themes/".$site['theme']."/images/administration/".$admin['icon']."\" alt=\"".$admin['name']."\"><br />";
     echo 
    $admin['name']."</a></td>";
     if(
    $i == "4"){
      echo 
    "</tr>";
      
    $i "0";
     }
     
    $i++;


  • Users who have thanked SeeIT Solutions for this post:

    Jesuspwnt (12-24-2007)

  • #3
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    ahhh, i see now, thanks alot!

  • #4
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    uh oh, another problem.

    my logout page is for some reason not working..

    i created a quick like 10 lines of code when i created to end ALL sessions, yet when i log out from an admin account, i can still delete posts, any ideas?

    PHP Code:
    foreach($_SESSION as $name=>$value){
     
    $_SESSION[$name]=NULL;
    }
    $_SESSION = array();
    if (isset(
    $_COOKIE[session_name()])) {
        
    setcookie(session_name(), ''time()-42000'/');


  • #5
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Try using session_destroy

  • #6
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    oops i must have forgotten to include that in my copy and paste :P, that is in the script too lol, promise :P

  • #7
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I'd use...

    PHP Code:
    unset($_COOKIE,$_SESSION); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •