Alright, I have this php script that helps me copy files to my server and I need help modding it so I can input a number of times to grab the file from another server (ex 15 times). If this can't be done, just make an infinite loop. This is to make many copies of the same file on the server. I believe this has something to do with php loops, although I have no PHP experience so this is just a guess. I realize there are other ways to do this, but I would like it this way.
edit: offering 20 points instead.
15 points to the person who can do this.
This is the PHP code:
edit: offering 20 points instead.
15 points to the person who can do this.
This is the PHP code:
PHP:
<?
C:\htdocs\FOLDER (Windows)
$defaultDest = "/ho/";
$password = "";
// Operating System your SERVER Uses
//1 for Linux. 2 for Windows.
//I'm not sure but I think most Operating Systems other then Windows will use 1.
$os = "1";
//////////////////////////////////////////////
//Do Not Change Below Here////////////////////
//////////////////////////////////////////////
echo "<form method=\"POST\" action=\"$PHP_SELF\">";
echo "<fieldset>\n<legend>Image Upload</legend>\n";
echo "<label for=\"file\">Full path to file to copy</label><br>";
echo "Example: http://www.google.ca/intl/en_ca/images/logo.gif<br>";
echo "<input type=\"text\" name=\"file\" id=\"file\" size=\"35\" tabindex=\"1\" value=\"\"><br>";
echo "<label for=\"new\">New file name</label><br>";
echo "Example: google.gif<br>";
echo "<input type=\"text\" name=\"new\" id=\"new\" size=\"35\" tabindex=\"2\" value=\"\"><br>";
if ($password) {
echo "<label for=\"password\">Password</label><br>";
echo "<input type=\"password\" name=\"password\" id=\"password\" size=\"35\" tabindex=\"3\" value=\"\"><br>";
}
echo "<p><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"submit\"></p>";
echo "</fieldset>\n</form>";
$submit = $_POST['submit'];
if($submit) {
if($password) {
if ($_POST['password']!=$password) {
echo "Password incorrect!";
} else {
$access = "09023578353";
}
} else {
$access = "09023578353";
}
if($access=="09023578353") {
if($os==2) {
$slash="\\";
} else {
$slash="/";
}
$file = $_POST['file'];
$newfilename = $_POST['new'];
if($_POST['otherdest']) {
$dest = $_GET['otherdest'];
} else {
$dest = $defaultDest;
}
$ds = array($dest, $slash, $newfilename);
$ds = implode("", $ds);
if (file_exists($ds)) {
echo "File already exists! <br>\n Adding random digits to beginning of filename. <br>\n";
$ds = array($dest, $slash, rand(0,9999), $newfilename);
$ds = implode("", $ds);
}
echo "New destination $ds <br>\n";
if (!copy($file, $ds)) {
echo "Was unable to copy $file <br>\n See if your path and destination are correct. \n";
} else {
echo "<strong>Copy successful!</strong> \n";
}
}
}
?>
Last edited: