Jump to content

Recommended Posts

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;
?>

Link to comment
https://forums.phpfreaks.com/topic/211219-some-help-with-php/
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101402
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101406
Share on other sites

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;

Link to comment
https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101411
Share on other sites

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;
?>

 

Link to comment
https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101431
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/211219-some-help-with-php/#findComment-1101518
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.