GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Sep-2006, 21:16
Chris1061 Chris1061 is offline
New Member
 
Join Date: Sep 2006
Posts: 1
Chris1061 is on a distinguished road
Question

Huge Problems in the world of PHP


Okay, Im a moderator on a game and the owner has taken flight to another country for awhile, and here recently for some reason the mod tools went nuts, we cant login, I have to access the database to get anything done.

Files:
PHP Code:

<?
INCLUDE ('../data/db.php');

/////////////////////////////////////////////////
//  functions and variables                //
/////////////////////////////////////////////////

$handle = mysql_connect($GLOBALS['where'], $GLOBALS['who'], $GLOBALS['how']);
openDB($handle);

function printHeader()
{
print ("<style>
.table {border-color: gray; background-color: silver; font-family: verdana; font-size: 11px; color: gray; width: 300px; font-weight: bold;}
</style>");
print ("<body style=\"font-size: 11px; font-family: verdana;\"><center><div style=\"width: 500px; text-align: left;\"><h3><center><a href=mods.php>Moderator Tools</a></center></h3> ");
}

$text_status = array('Basic Access', 'Advanced Access', 'Full Access');

//Cookie check
$cookie_name = $HTTP_COOKIE_VARS['modLogin'];

if($cookie_name != NULL)
{
   $cookie_info = explode('//', $cookie_name);
       $array_file = file('mods.inf');
    for($c = 0; $c < sizeof($array_file); $c++)
    {
       $data_file = explode(' ', $array_file[$c]);
       if($data_file[0] == $cookie_info[0] && $data_file[1] == $cookie_info[1])
       {
          $match = 1; break;
       }
    }
    if(!isset($match))
    {
       print ("Incorrect login."); exit;
    }

}
elseif(!(isset($action) && $action == "login"))
{

   print ("<center><form action=mods.php?action=login method=post><table border=3 bordercolor=gray bgcolor=silver style=\"font-family: verdana; font-size: 11px; color: gray; width: 225px; font-weight: bold;\"><tr><td>Name: </td><td><input type=text name=name style=\"width: 150\"></td></tr><tr><td>Password:</td><td><input type=text name=password style=\"width: 150\"></td></tr><tr><td colspan=2><center><input type=submit value=Login style=\"width: 221px; border-color: gray; border-style: outset; border-width: 1px;\"></td></tr></table></form><br><br>After you are finished using this system, close the browser.<br><br>"); exit;
}



//log in
if(isset($action))
{
   switch($action)
   {
     case 'login':  
      include('incs/mods_login.php');
      break;
  case 'browse_players':
      include('incs/players_browse.php');
      break;
  case 'Fine_Player': 
      include('incs/players_fine.php');
      break;
  case 'Fine_Player_5':
    INCLUDE('incs/players_fine_5.php');
      break;
  case 'Reward_Player': 
      include('incs/players_reward.php');
      break;
  case 'Reward_Player_5':
    INCLUDE('incs/players_reward_5.php');  
      break;
  case 'Freeze_Player': 
            include('incs/players_freeze.php');
      break;  
  case 'Recent_Actions':
      printHeader();
      $query = "SELECT mod, action, date_format(date, '%M %D %Y, %l:%i %p') FROM mod_info order by date desc limit 20";
      $query = mysql_query($query, $handle);
      while($row = mysql_fetch_row($query));
      {
         print ("<b>$row[2]</b><br>&nbsp; &nbsp;$row[1] -- $row[0]<br><br>");
      }
      exit;
      break;
  case 'Ban_Player':
      include('incs/players_ban.php');
      break;
        case 'Edit_Bio':
      include('incs/players_bio.php');
      break;
        case 'Edit_Desc':
      include('incs/players_desc.php');
      break;
        case 'Edit_Pic':
      include('incs/players_pic.php');
      break;
        case 'Edit_Image':
      include('incs/players_image.php');
      break;
        case 'Edit_Shop':
      include('incs/players_shop.php');
      break;
        case 'Edit_Clinic':
      include('incs/players_clinic.php');
      break;  
        case 'Browse_Horses':
      include('incs/horses_browse.php');
      break;
        case 'Horse_Desc':
      include('incs/horses_desc.php');
      break;
        case 'Horse_Image':
      include('incs/horses_image.php');
      break;
        case 'Browse_Forums':
      include('incs/forums_browse.php');
      break;
        case 'Topic_Edit':
      include('incs/topics_edit.php');
      break;
   case 'Topic_Move':
      include('incs/topics_move.php');
      break;
   case 'Post_Edit':
      include('incs/posts_edit.php');
      break;
   case 'Edit_Name':
      include('incs/players_name.php');
      break;
   case 'Add_Note':
     include('incs/add_note.php');
     break;
   }
}



//Actions
$name = $data_file[0];
$status = trim($data_file[2]); 


printHeader();
print ("You are logged in as <b>$data_file[0]</b> and have <b>$text_status[$status]</b> to mod tools.<br><br>");

print ("<br><br>> <a href=mods.php?action=browse_players>Browse Players</a><br>> <a href=mods.php?action=Browse_Horses>Browse Horses</a><br>> <a href=mods.php?action=Browse_Forums>Browse Forums</a><br><br>> <a href=mods.php?action=Recent_Actions>View Recent Actions</a>");



closeDB($handle);
?>


and then it takes you to this page which is where the errors pop up, It doesnt set a cookie or even check the login.
PHP Code:

<?
    if(!isset(name) || name == NULL || !isset(password) ||password == NULL)
    {
       print ("You did not fill out all information."); exit;
    }
     else
     (
    array_file = file('mods.inf');
    for(c = 0; c < sizeof(array_file); c++);
    )
    {
       data_file = explode(' ', array_file[c]);
       if(data_file[0] == name && data_file[1] == vbfdsy54u87r23
          match = 1; break;
       }
    }
    if(isset(match))
    {
       cookie_set = "name//password"
       setcookie("modLogin", cookie_set, 0, "/", "", 0);

       echo <i>"You are now logged in."</i>;
    }
    else
    {
       printHeader();
       echo "Login Incorrect."; exit;
    }
     ?>


any help at all would be greatly appeceated, as I have been working on this for hours and came up with nothing.
  #2  
Old 28-Sep-2006, 21:32
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Huge Problems in the world of PHP


If this was a copy/paste, and not a typo, check the second block of code carefully around the first 'else'...there are some issues...

1. There appears to be parentheses characters to the else instead of curly-brackets.
2. The for-loop has a semi-colon at the end. I don't think this is what you want. [also, because of #1, the loop appears as if it's part of the else, but probably not]
3. Within the loop's body, the if check is missing a curly-bracket.

Basically, verify the layout of your code, and see how it goes. [hint: this is an example of where consistent indenting of the code would have helped! (it isn't that bad though, really)]
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 28-Sep-2006, 22:12
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 841
admin will become famous soon enough

Re: Huge Problems in the world of PHP


Also, glancing over your scripts, I noticed that all your variables are invalid. See the second script you pasted in your opening post.

name should be $name
password should be $password
data_file should be $data_file
... etc.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #4  
Old 04-Oct-2006, 22:02
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: Huge Problems in the world of PHP


And in the second script,
PHP Code:

echo <i>"You are now logged in."</i>; 


won't work. The string to be echoed needs quotes:
PHP Code:

echo '<i>You are now logged in.</i>'; 


 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple file creation with fopen? robin C Programming Language 6 17-Aug-2006 00:38
Problems following php installation Clive73 MySQL / PHP Forum 4 02-Jun-2005 11:03
Apache - problems using PHP outside the intranet ooandioo Apache Web Server Forum 6 04-Feb-2004 10:27
Problems with apache win 98 php and vhosts Kplonk Computer Software Forum - Windows 2 22-May-2002 11:06

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:12.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.