Admin PHP Script Cookie Not Working?

  • themainjam
  • Born
  • Born
  • themainjam
  • Posts: 3
  • Loc: Middle of the US

Post 3+ Months Ago

ok guys this isnt my script but it will work perfectly for what i need. i need a photo gallery that you can upload modify leave comment blah blah blah.

now here is the problem. when i go to the admin button on the left side and enter the password when i click enter nothing happens. i went through the code and 1398-1404 there are only single quotes. when i put double quotes the page wont even load.

PHP Code: [ Select ]
 
if ($admin) {
 
   if (isadmin()) {
 
       $intro = "true";
 
 
 
   } else if ($admin == $password) {
 
       $seconds = 60*60*24*354;
 
       setCookie ('PFCOOKIE', "", time() - 3600, "/");
 
       setCookie ('PFCOOKIE', md5($admin), time()+$seconds, "/");
 
       $PFCOOKIE = md5($admin);
 
       $intro = "true";
 
       
 
   } else {
 
       PrintHeader("Administrator Login");
 
       echo '<CENTER>';
 
       echo '<P>&nbsp;</P>';
 
       echo '<ACTION=\"$scriptname\" FORM METHOD=\"POST\">';
 
       echo 'Admin Password: <INPUT NAME=admin TYPE=password SIZE=20>';
 
       echo '<INPUT TYPE=submit VALUE="Enter">';
 
       echo '</FORM>';
 
       exit;
 
   }
 
}
 
 
  1.  
  2. if ($admin) {
  3.  
  4.    if (isadmin()) {
  5.  
  6.        $intro = "true";
  7.  
  8.  
  9.  
  10.    } else if ($admin == $password) {
  11.  
  12.        $seconds = 60*60*24*354;
  13.  
  14.        setCookie ('PFCOOKIE', "", time() - 3600, "/");
  15.  
  16.        setCookie ('PFCOOKIE', md5($admin), time()+$seconds, "/");
  17.  
  18.        $PFCOOKIE = md5($admin);
  19.  
  20.        $intro = "true";
  21.  
  22.        
  23.  
  24.    } else {
  25.  
  26.        PrintHeader("Administrator Login");
  27.  
  28.        echo '<CENTER>';
  29.  
  30.        echo '<P>&nbsp;</P>';
  31.  
  32.        echo '<ACTION=\"$scriptname\" FORM METHOD=\"POST\">';
  33.  
  34.        echo 'Admin Password: <INPUT NAME=admin TYPE=password SIZE=20>';
  35.  
  36.        echo '<INPUT TYPE=submit VALUE="Enter">';
  37.  
  38.        echo '</FORM>';
  39.  
  40.        exit;
  41.  
  42.    }
  43.  
  44. }
  45.  
  46.  


if i go to the function isadmin

PHP Code: [ Select ]
function isadmin() {
 
    global $password, $PFCOOKIE;
 
    if ($password and isset($PFCOOKIE)) {
 
        if ($PFCOOKIE == md5($password) ) {    //This is a problem
 
            return true;
 
        }
 
    }
 
    return false;
 
}
 
 
  1. function isadmin() {
  2.  
  3.     global $password, $PFCOOKIE;
  4.  
  5.     if ($password and isset($PFCOOKIE)) {
  6.  
  7.         if ($PFCOOKIE == md5($password) ) {    //This is a problem
  8.  
  9.             return true;
  10.  
  11.         }
  12.  
  13.     }
  14.  
  15.     return false;
  16.  
  17. }
  18.  
  19.  


it wouldnt load the cookie info i am not sure if it even makes a cookie.
but if i bypass those two pieces of code (answer true instead of false) the admind features work..... but they work for everyone.....

if you need my server setup info or the entire script PM me

i am kinda of a noob to php as a matter of fact the only reason i know some of this stuff is because i did "some " VB in highschool
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • CE F
  • Newbie
  • Newbie
  • CE F
  • Posts: 13
  • Loc: Portland Or/Dallas Tx

Post 3+ Months Ago

This may help,
Try changing

*TAKE THIS OUT* $seconds = 60*60*24*354;
*SET THIS * $DATA = md5($admin)
setCookie ('PFCOOKIE', "", time() - 3600, "/");
setCookie ('PFCOOKIE', $DATA, time()+3600, "/"); **THIS SHOULD LAST AN HOUR, OR LEAVE IT BLANK AND IT WILL BE REMOVED AT THE END OF THE SESSION*
$PFCOOKIE = md5($admin);
$intro = "true";

*I HOPE*


themainjam wrote:
ok guys this isnt my script but it will work perfectly for what i need. i need a photo gallery that you can upload modify leave comment blah blah blah.

now here is the problem. when i go to the admin button on the left side and enter the password when i click enter nothing happens. i went through the code and 1398-1404 there are only single quotes. when i put double quotes the page wont even load.

PHP Code: [ Select ]
if ($admin) {
   if (isadmin()) {
       $intro = "true";
 
   } else if ($admin == $password) {
       $seconds = 60*60*24*354;
       setCookie ('PFCOOKIE', "", time() - 3600, "/");
       setCookie ('PFCOOKIE', md5($admin), time()+$seconds, "/");
       $PFCOOKIE = md5($admin);
       $intro = "true";
       
   } else {
       PrintHeader("Administrator Login");
       echo '<CENTER>';
       echo '<P>&nbsp;</P>';
       echo '<ACTION="$scriptname" FORM METHOD="POST">';
       echo 'Admin Password: <INPUT NAME=admin TYPE=password SIZE=20>';
       echo '<INPUT TYPE=submit VALUE="Enter">';
       echo '</FORM>';
       exit;
   }
}
 
  1. if ($admin) {
  2.    if (isadmin()) {
  3.        $intro = "true";
  4.  
  5.    } else if ($admin == $password) {
  6.        $seconds = 60*60*24*354;
  7.        setCookie ('PFCOOKIE', "", time() - 3600, "/");
  8.        setCookie ('PFCOOKIE', md5($admin), time()+$seconds, "/");
  9.        $PFCOOKIE = md5($admin);
  10.        $intro = "true";
  11.        
  12.    } else {
  13.        PrintHeader("Administrator Login");
  14.        echo '<CENTER>';
  15.        echo '<P>&nbsp;</P>';
  16.        echo '<ACTION="$scriptname" FORM METHOD="POST">';
  17.        echo 'Admin Password: <INPUT NAME=admin TYPE=password SIZE=20>';
  18.        echo '<INPUT TYPE=submit VALUE="Enter">';
  19.        echo '</FORM>';
  20.        exit;
  21.    }
  22. }
  23.  


if i go to the function isadmin

PHP Code: [ Select ]
function isadmin() {
    global $password, $PFCOOKIE;
    if ($password and isset($PFCOOKIE)) {
        if ($PFCOOKIE == md5($password) ) {    //This is a problem
            return true;
        }
    }
    return false;
}
 
  1. function isadmin() {
  2.     global $password, $PFCOOKIE;
  3.     if ($password and isset($PFCOOKIE)) {
  4.         if ($PFCOOKIE == md5($password) ) {    //This is a problem
  5.             return true;
  6.         }
  7.     }
  8.     return false;
  9. }
  10.  


it wouldnt load the cookie info i am not sure if it even makes a cookie.
but if i bypass those two pieces of code (answer true instead of false) the admind features work..... but they work for everyone.....

if you need my server setup info or the entire script PM me

i am kinda of a noob to php as a matter of fact the only reason i know some of this stuff is because i did "some " VB in highschool
:wink: :wink: :wink:
  • themainjam
  • Born
  • Born
  • themainjam
  • Posts: 3
  • Loc: Middle of the US

Post 3+ Months Ago

ok well i cant even check for the cookie because the admin script isnt working i am gonna post the whole script i hope no one gets mad... : :wink:

so in this script when you go to the admin button it opens a page where you need to enter the password. i type the password and when i hit enter it doesnt do anything....... so thats the first problem then on a previous version of this script it would do the admin fine but wouldnt do the cookie so i am going to see if i can get the cookie working in the previous version using the above code.

when you say "SET THIS" do you mean up near the variables? then transplant the rest of the code over the "other" cookie code?

also i set up the admin variable and capfile variable and pretty much set up the variables......

ok found out you cant heres a link to the script

http://www.hawkinsarchitects.com/original.source

let mw know :) thanks for all the help too!!
  • themainjam
  • Born
  • Born
  • themainjam
  • Posts: 3
  • Loc: Middle of the US

Post 3+ Months Ago

ok i am going to concentrate on the olde script because many people are having problems with the admin function.

so in the old script which i will put at the link above the only problem i have is the script doesnt put the cookie on the comp or cant read from it.

so i login and any option i choose that has to do with admin it say this is an admin only function.......

so here is the script: http://www.hawkinsarchitects.com/original.source

and here is the gallery if you scroll all the way down on the left you see an admin button. the password is "name" as you can see you cant do any other options.....

http://www.hawkinsarchitects.com/hawkpic/

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 61 guests
  • 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 post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.