Jump to content

Recommended Posts

I have the following script:

 

<?php 
$filename = $_GET['filename']; 
if (empty($filename)) 
{ 
?> 
<form action="" method="GET"> 
<input type="text" name="filename"> 
<input type="submit"> 
</form> 
<?php 
} 

else 
{ 
if (strpos($filename,".zip") >= 1) 
{ 
exec('unzip $filename',$ret); 
echo "Successful unzipping"; 
$url = str_ireplace(".zip","","$filename"); 
echo '<META HTTP-EQUIV="Refresh" Content="2; URL=http://www.argendeli.net/$filename">'; 
} 
elseif ((strpos($filename,".tgz") >= 1) || (strpos($filename,".tar.gz") >= 1)) 
{ 
exec('tar -xzf gammu-1.10.0.tar.gz',$ret); 
echo "Successful untargzing"; 
if ((strpos($filename,".tgz") >= 1)) 
{ 
$url = str_ireplace(".tgz","","$filename"); 
echo '<META HTTP-EQUIV="Refresh" Content="2; URL=http://www.argendeli.net/$filename">'; 
} 
else 
{ 
$url = str_ireplace(".tar.gz","","$filename"); 
echo '<META HTTP-EQUIV="Refresh" Content="2; URL=http://www.argendeli.net/$filename">'; 
} 
} 
else 
{ 
?> 
<form action="" method="GET"> 
<input type="text" name="filename"> 
<input type="submit"> 
</form> 
<?php 
} 
} 
?>

 

 

The point is, that after decompressingg, it should take you to the new uncompressed directory, and, for obvious reasons, I can't use headers, but on the other hand, I don't want to be redirected, as I am now, to http://www.argendeli.net/$filename

How do I redirect in the places where I have redirect code right now, after 1<small>1/2</small> - 2 seconds, and actually have $filename replaced with its contents.

Link to comment
https://forums.phpfreaks.com/topic/48201-redirects/
Share on other sites

I have tried combinations of different languages now, but I still seem to run into the problem of my code not actually replacing the variable name.  I have also brought my redirect codes down into a function at the bottom and called it passing $filename to the function.  Here is the function:

 

function redirect()
{
echo '<script type="text/javascript">
<!--
window.location = "http://www.argendeli.net/$filename"
//-->
</script>';
}
?>

 

I also tried this approach, varying use of of quotations around the javascript url (single, double, or none):

 

function redirect()
{
$redirecturl = "http://www.argendeli.net/$filename";
echo '<script type="text/javascript">
<!--
window.location = "$redirecturl"
//-->
</script>';
}
?>

 

Still no luck.  I get redirected to argendeli.net/$filename every time

Link to comment
https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235934
Share on other sites

Now if I try to decompress a file  (for instance, .tgz), I get this after entering the filename and submitting it:

 

Successful untargzing

Fatal error: Call to undefined function: redirect() in /home/argendeli/extractfile.php on line 60

 

Here is the full code, and the only problem is with the redirects:

 

<?php
session_start();
// Define your username and password
$username = "heckler0077";
$password = "ohyeah56";
if ($_SESSION['logon'] != "1")
{
$_SESSION['txtUsername'] = $_POST['txtUsername'];
$_SESSION['txtPassword'] = $_POST['txtPassword'];
}
if ($_SESSION['txtUsername'] != $username || $_SESSION['txtPassword'] != $password) {

?>

<h1>Login</h1>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><label for="txtUsername">Username:</label>
    <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>

    <p><label for="txtpassword">Password:</label>
    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>

    <p><input type="submit" name="Submit" value="Login" /></p>

</form>

<?php
}
else {
//---------------------------------------------------------------------------------------
$_SESSION['logon'] = "1";
$filename = $_GET['filename'];
if (empty($filename))
{
?>
<form action="" method="GET">
<input type="text" name="filename">
<input type="submit">
</form>
<?php
}

else
{
if (strpos($filename,".zip") >= 1)
{
exec("unzip $filename",$ret);
echo "Successful unzipping";
$url = str_ireplace(".zip","","$filename");
redirect($filename);
}
elseif ((strpos($filename,".tgz") >= 1) || (strpos($filename,".tar.gz") >= 1))
{
exec("tar -xzf $filename",$ret);
echo "Successful untargzing";
if ((strpos($filename,".tgz") >= 1))
{
$url = str_ireplace(".tgz","","$filename");
redirect($filename);
}
else
{
$url = str_ireplace(".tar.gz","","$filename");
redirect($filename);
}
}
else
{
?>
<form action="" method="GET">
<input type="text" name="filename">
<input type="submit">
</form>
<?php
}
}

function redirect($filename)
{
$redirecturl = "http://www.argendeli.net/$filename";
echo "<script type='text/javascript'>";
echo "<!--";
echo "window.location = $redirecturl";
echo "//-->";
echo "</script>";
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235963
Share on other sites

change

<?php
}
}

function redirect($filename)
{
$redirecturl = "http://www.argendeli.net/$filename";
echo "<script type='text/javascript'>";
echo "<!--";
echo "window.location = $redirecturl";
echo "//-->";
echo "</script>";
}
}
?>

 

to

<?php
}
}
}
function redirect($filename)
{
$redirecturl = "http://www.argendeli.net/$filename";
echo "<script type='text/javascript'>";
echo "<!--";
echo "window.location = $redirecturl";
echo "//-->";
echo "</script>";
}

?>

Link to comment
https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235968
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.