heckler0077 Posted April 23, 2007 Share Posted April 23, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/ Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 echo some javascript to redirect Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235619 Share on other sites More sharing options...
heckler0077 Posted April 23, 2007 Author Share Posted April 23, 2007 I tried that: echo '<script type="text/javascript"> <!-- window.location = "http://www.argendeli.net/$filename" //--> </script>'; But it still redirected me to argendeli.net/$filename Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235629 Share on other sites More sharing options...
heckler0077 Posted April 23, 2007 Author Share Posted April 23, 2007 Please, someone help! Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235636 Share on other sites More sharing options...
heckler0077 Posted April 23, 2007 Author Share Posted April 23, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235934 Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 <?php function redirect($filename) { $redirecturl = "http://www.argendeli.net/$filename"; echo "<script type='text/javascript'>"; echo "<!--"; echo "window.location = $redirecturl"; echo "//-->"; echo "</script>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235937 Share on other sites More sharing options...
heckler0077 Posted April 23, 2007 Author Share Posted April 23, 2007 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>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235963 Share on other sites More sharing options...
MadTechie Posted April 23, 2007 Share Posted April 23, 2007 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>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-235968 Share on other sites More sharing options...
heckler0077 Posted April 24, 2007 Author Share Posted April 24, 2007 The error is gone, but it is still not redirecting ??? Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-236554 Share on other sites More sharing options...
heckler0077 Posted April 24, 2007 Author Share Posted April 24, 2007 Now, if I feed it, say, a .tgz file, it will successfully decompress it and display the message on screen, but it now fails to redirect it at all. This is for all supported file types, as well. Quote Link to comment https://forums.phpfreaks.com/topic/48201-redirects/#findComment-236852 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.