akshay1234 Posted August 19, 2010 Share Posted August 19, 2010 the following file is /account.php it returns Parse error: syntax error, unexpected T_ELSE in C:\Program Files\XAMPP\xampp\htdocs\account.php on line 26 basically, when someone without the login cookie navigates here, they should be redirected to login.php. can anyone help me? <?php if(isset($_COOKIE["LOGIN"])); { $key = 'MY_WORKING_KEY_WHICH_DOES_WORK'; $string = ($_COOKIE['LOGIN']); $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); include("/oauth/accounts/$decrypted_username.html"); echo "<script type=\"text/javascript\"> <!-- if (self != top) { top.location.href = self.location;href; } //--> </script>"; } if(isset($_GET['browse'])); { $key = 'MY_WORKING_KEY WHICH DOES WORK'; $string = ($_COOKIE['LOGIN']); $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); scandir("/oauth/files/$decrypted_username"); echo "To upload new files, click <a href=\"account.php?upload\">here</a>."; }else{ header('Location: /login.html'); } exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/ Share on other sites More sharing options...
hcdarkmage Posted August 19, 2010 Share Posted August 19, 2010 This line: if(isset($_GET['browse'])); should be if(isset($_GET['browse'])) //<--NOTICE: No ; Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101394 Share on other sites More sharing options...
Rifts Posted August 19, 2010 Share Posted August 19, 2010 what about this line if(isset($_COOKIE["LOGIN"])); remove ; there also? Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101397 Share on other sites More sharing options...
hcdarkmage Posted August 19, 2010 Share Posted August 19, 2010 I would say Yes. Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101398 Share on other sites More sharing options...
akshay1234 Posted August 19, 2010 Author Share Posted August 19, 2010 but now, when someone is logged in, and goes to account.php, and it shows you the content of /oauth/accounts/$decrypted_username.html (line 7 of the code). it also displays Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\XAMPP\xampp\htdocs\oauth\accounts\akshay.html:1) in C:\Program Files\XAMPP\xampp\htdocs\account.php on line 27 when someone goes to account.php?browse, it shows you /oauth/accounts/$decrypted_username.html (line 7 of the code), AND asks you if you want to upload files (line 25). no sign of the scandir... Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101402 Share on other sites More sharing options...
hcdarkmage Posted August 19, 2010 Share Posted August 19, 2010 Two more lines to fix: include("/oauth/accounts/".$decrypted_username.".html"); and scandir("/oauth/files/".$decrypted_username); Try that. Also remember to clear your cookies before you test it again. Doing a refresh doesn't always clear that. Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101406 Share on other sites More sharing options...
hcdarkmage Posted August 19, 2010 Share Posted August 19, 2010 Here, I hope this helps: if(isset($_COOKIE['LOGIN'])) { $key = 'MY_WORKING_KEY_WHICH_DOES_WORK'; $string = $_COOKIE['LOGIN']; $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); include("/oauth/accounts/".$decrypted_username.".html"); echo "<script type=\"text/javascript\"> <!-- if (self != top){ top.location.href = self.location;href; } //--></script>"; } if(isset($_GET['browse'])){ $key = 'MY_WORKING_KEY WHICH DOES WORK'; $string = $_COOKIE['LOGIN']; $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); scandir("/oauth/files/".$decrypted_username); echo "To upload new files, click <a href=\"account.php?upload\">here</a>."; }else{ header('Location: /login.html'); } exit; Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101411 Share on other sites More sharing options...
akshay1234 Posted August 19, 2010 Author Share Posted August 19, 2010 Parse error: syntax error, unexpected ')' in C:\Program Files\XAMPP\xampp\htdocs\account.php on line 18 shows up Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101418 Share on other sites More sharing options...
Rifts Posted August 19, 2010 Share Posted August 19, 2010 what is your line 18 Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101427 Share on other sites More sharing options...
akshay1234 Posted August 19, 2010 Author Share Posted August 19, 2010 scandir("/oauth/files/".$decrypted_username.); is line 18 here is my full code: <?php if(isset($_COOKIE["LOGIN"])) { $key = 'my_key'; $string = $_COOKIE['LOGIN']; $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); include("/oauth/accounts/$decrypted_username.html"); echo "<script type=\"text/javascript\"> <!-- if (self != top){ top.location.href = self.location;href; } //--></script>"; } if(isset($_GET['browse'])){ $key = 'my_key'; $string = $_COOKIE['LOGIN']; $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); scandir("/oauth/files/".$decrypted_username.); echo "To upload new files, click <a href=\"account.php?upload\">here</a>."; exit; }else{ header('Location: /login.html'); } exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101431 Share on other sites More sharing options...
hcdarkmage Posted August 19, 2010 Share Posted August 19, 2010 Try to do it this way: $dir = "/oauth/files/".$decrypted_username; scandir($dir); Makes me wonder if it doesn't like the break up of the string. Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101433 Share on other sites More sharing options...
Pikachu2000 Posted August 19, 2010 Share Posted August 19, 2010 You have an extra concatenation operator ( . ) after $decrypted_username, before the closing parenthesis. scandir("/oauth/files/".$decrypted_username.); Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101437 Share on other sites More sharing options...
akshay1234 Posted August 20, 2010 Author Share Posted August 20, 2010 ok, i redid the code ( a little bit ) this one returns unexpected T_else in line 29. <?php $jscript = "<script type=\"text/javascript\"> <!-- if (self != top){ top.location.href = self.location;href; } //--></script>"; if(isset($_COOKIE["LOGIN"])){ echo $jscript; } if(isset($_GET['browse'])){ $key = 'myencryptionkey'; $string = $_COOKIE['LOGIN']; $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); $dir = "/oauth/files/".$decrypted_username; scandir($dir); echo "To upload new files, click <a href=\"account.php?upload\">here</a>."; } else { $key = 'myencryptionkey'; $string = $_COOKIE['LOGIN']; $decrypted_username = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); include("/oauth/accounts/$decrypted_username.html"); exit; } else // line 29 is this line { header('Location: /login.html'); } exit; ?> thank you any help is appreciated Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101518 Share on other sites More sharing options...
trq Posted August 20, 2010 Share Posted August 20, 2010 Parse errors are simple syntax errors, you shouldn't really need help finding them. Indent your code consistently and this error in particular will stand out. Quote Link to comment https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101519 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.