|
|
|
|
|
|
| |
- Use this class to upload any file - already uploaded on another website - ( very useful for megaupload & rapidshare ).
- Use this class to copy a file from another website to your website directly, no need - to download it and reupload it on your website
- you can change the file's original name into a new name ( ranom numbers & letters ).
- you can select the folder that's the file will be uploaded into .
- Show the time used to copy the file
- Show the file size
MyEasyCopy.class.php
|
<?php
/************************************
/
/ @ script : My Easy Copy
/ @ version : 1.3 beta
/ @ date created : 31-8-2006
/ @ created : naif php
/ @ site : www.naifphp.net
/
************************************/
class MyEasyCopy {
var $Url;
var $Path = "./";// don't add the => '/' in end when add folder name.Ex("./folder_copy");
var $CopyName;
var $errors = array(
" Please Enter The File Link !",
" The file wasn't found ! ",
" Can't Read The File !",
" File was created successfuly , file size : ",
" File wasn't created, please try again ! ");
// Main abstract method to handle all mattres
function EasyCopy()
{
$this->Url = strip_tags($_GET['Url']);
$new_name = (empty($this->CopyName)) ? md5(date("h_i_s")) : $this->CopyName;
if (isset($_GET['get']) && $_GET['get'] == "Copy")
{
if (empty($this->Url))
{
return $this->errors[0];
}
else
{
if(file_exists($this->Path) == false)
{
return $this->errors[1];
}
else
{
@set_time_limit(0);
$old_name = str_replace('/','',strrchr($this->Url,'/'));
$str = $this->GetStretchFile($old_name);
$diff = @fopen($this->Url,'rb');
if(!$diff)
{
return $this->errors[2];
}
else
{
$startmtime = microtime();
$con = '';
$new_co = @fopen($this->Path .'/'.$new_name.$str,'w');
while(!feof($diff))
{
$con .= @fread($diff,1024);
}
$created = @fwrite($new_co,$con);
@fclose($new_co);
@fclose($diff);
$endmtime = microtime();
$i = strrpos($startmtime," ");
$startmtime = substr($startmtime,$i+1,strlen($startmtime)-$i)+substr($startmtime,0,$i);
$i = strrpos($endmtime," ");
$endmtime = substr($endmtime,$i+1,strlen($endmtime)-$i)+substr($endmtime,0,$i);
$totaltime = $endmtime - $startmtime;
$kbs = round((strlen($con)/1024)/$totaltime);
$port = ("Fast Translate File : ".number_format($kbs)." kb/s , Time Used : $totaltime Second <br>\n");
if($created)
{
return $this->errors[3] . $this->GetSize($new_name.$str) .'<br>'. $port;
}
else
{
return $this->errors[4];
}
}
}
}
}
}
// Interface
function GetInfo ()
{
$form = "<FORM METHOD='GET'>";
$form .= "File Url : ";
$form .= "<INPUT TYPE='TEXT' NAME='Url'>";
$form .= "<INPUT TYPE='HIDDEN' NAME='get' VALUE='Copy'>";
$form .= "<INPUT TYPE='SUBMIT' VALUE='Get Copiedy'>";
$form .= "</FORM><HR>";
return $form;
}
// Getting the extension of the file
function GetStretchFile($name)
{
$GetStretch = @explode('.',$name);
$reStretch = @count($GetStretch) - 1;
$Stretch = '.'.$GetStretch[$reStretch];
return $Stretch;
}
// handling size, return full size option : 500 Kb
function GetSize($file_name)
{
$filesize = filesize($this->Path .'/'. $file_name);
if ($filesize >= 1073741824)
{
$filesize = number_format($filesize / 1073741824, 1) . ' Gb';
}
else if ($filesize >= 1048576)
{
$filesize = number_format($filesize / 1048576, 1) . ' Mb';
}
else if ($filesize >= 1024)
{
$filesize = number_format($filesize / 1024, 1) . ' Kb';
}
else
{
$filesize = number_format($filesize, 1) . ' b';
}
return $filesize;
}
} // End Class :)
?> | |
Example Usage
| <?php
/************************************
/
/ @ script : My Easy Copy
/ @ version : 1.0 beta
/ @ date : 20-8-2006
/ @ created : naif php
/ @ site : www.naifphp.net
/
************************************/
include_once ("MyEasyCopy.class.php");
$EC = new MyEasyCopy;
//$EC->Path = "./coped";
//$EC->CopyName = "naif";
if(isset($_GET['get']))
{
echo $EC->EasyCopy();
}
else
{
echo $EC->GetInfo();
}
// or you can do this
/*
echo $EC->GetInfo();
echo $EC->EasyCopy();
*/
?> | | |
|
| An efficient iterative and buffered text file reader Categories : PHP, Classes and Objects, Filesystem, PHP Classes, Log Files | | | cPanel Email Accounts Creator Categories : PHP, PHP Classes, Email, Form Processing, Web Services | | | Search and Replace Text : Searches Files for Specified Text and Replaces It by a Given Text Categories : PHP, PHP Classes, Search, Filesystem | | | PHP Transfer data from text file to Mysql Table Categories : PHP, PHP Classes, Filesystem, Databases, MySQL | | | Easy upload class Categories : PHP Classes, Filesystem, HTTP, PHP | | | Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects. Categories : PHP, PHP Classes, XML, Web Services | | | PHP4 DirectoryIterator Class Categories : PHP, PHP Classes, Filesystem, Directories | | | cPanel Subdomains Creator - Create cPanel subdomains without logging into cPanel. Let your visitors create their own subdomains without your intervention. Moreover, it will inform if a subdomain is already exists. Categories : PHP, Web Services, PHP Classes | | | Compare two texts and display a block of text with the differences between them. Categories : PHP, PHP Classes, Filesystem, Strings, Arrays | | | 3 lines of Code to extract Tar, Zip, Gzip etc.. Categories : PHP, Filesystem, PHP Classes, Compression | | | filesplit : Split big text files in multiple small ones Categories : PHP, Log Files, Filesystem, PHP Classes | | | Bs_IniHandler is a class that can read and write ini-style files (and strings) Categories : PHP, Filesystem, PHP Classes | | | Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support Categories : PHP, FTP, Filesystem, PHP Classes, Compression | | | Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem | | | A File Browser Class.To Read Drives,Directories and Files .Files writing is also possible Categories : PHP, PHP Classes, Filesystem | |
|
|