File Copier

Started by nitins60, November 12, 2006, 08:31:36 AM

Previous topic - Next topic

nitins60

Hmmm, this s one of the most interesting things...
I made this script for sharing my files with my friends server, without uploading 2times. It helped me several times to shift my database from 1 server to another server, without uploading, downloading, as my internet speed always bad....So i want to share it, make it as a mod for several purposes

<?
$defaultDest = "./";
$password = "";
$os = "1";
$submit="hah!";
echo "<form method=\"POST\" action=\"$PHP_SELF\">";
echo "<fieldset>\n<legend>Database Copier</legend>\n";
echo "<label for=\"file\">File Url</label><br>";
echo "Example: http://bla.com/file.ext<br>";
echo "<input type=\"text\" name=\"file\" id=\"file\" tabindex=\"1\" value=\"\"><br>";
echo "<label for=\"new\">New file name</label><br>";
echo "Example: file.ext<br>";
echo "<input type=\"text\" name=\"new\" id=\"new\" tabindex=\"2\" value=\"\"><br>";
if ($password) {
echo "<label for=\"password\">Password</label><br>";
echo "<input type=\"password\" name=\"password\" id=\"password\" 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 "<p>File already exists! <br>\n Adding random digits to beginning of filename.</p>\n";
$ds = array($dest, $slash, rand(0,9999), $newfilename);
$ds = implode("", $ds);
}

echo "<p>New destination $ds</p>\n";
if (!copy($file, $ds)) {
echo "<p>Was unable to copy $file <br>\n See if your path and destination are correct.</p> \n";
} else {
echo "<p><strong>Copy successful!</strong></p> \n";
}}}
?>


basically i enabled password protection also, now it's disabled.
Features:
* you can share/shift/copy files from anywhere to yr server without downl and uploading it.
* mainly helps you to shift yr database
* ppl who have uploading file size restriction, much helpful. They can upload files n any other file hosting services, then use this script to copy to yr server.
Many useful things....

presently, i am looking for a mod writer, who can turn it as a mod, can be integrated in SMF...
* all copied files must be protected like attachments, in that directory
* these files must be downloaded @ registered users only
* this option(http upload) should be available to only certain allowed groups..

Hope i will see it soon as a mod

Advertisement: