Again, I ask you for a help
1. This script: Reads links from a file
[php]<?php
// Reads links from a file
$read_dir="./";
$read_file=“links_data.txt”;
$connect_to_red=@fopen ("$read_dir/$read_file",‘r’);
if (!$connect_to_red) {
echo “could not open database”;
exit();
}
while (!feof ($connect_to_red) ) {
$read=fgets ($connect_to_red,1024);
echo “$read\n”;
}
@fclose($connect_to_red);
?>[/php]
2. This script: Creates folders of Links
[php]<?php
// Creates folders of Links
$url = array(
‘http://www.domain.com/file.php’,
‘http://www.domain.com/dir1-1/dir2/dir3/file.jpg’,
‘http://www.domain.com/dir1-2/dir2/dir3/dir4/file.zip’,
‘http://www.domain.com/dir1-3/dir2/dir3/dir4/dir5/file.gif’,
‘http://www.domain.com/dir1-4/dir2/dir3/dir4/dir5/dir6/file.png’,
‘http://www.domain.com/dir1-5/dir2/dir3/dir4/dir5/dir6/dir7/file.rar’,
);
if(is_array($url) && !empty($url)) foreach($url as $url_new) {
$path = explode(’/’,dirname($url_new),4);
$dirspath = array(’./’.$path[3].’/’);
$dirspath2 = array($path[3]);
for($i=0;$i<count($dirspath);$i++){
$fullDir = $dirspath[$i];
exec("mkdir -p ".$fullDir);
$dirs=explode("/",$fullDir);
$currentFolder=’’;
for ($x=0; $x<count($dirs); $x++){
$currentFolder.=$dirs[$x].’/’;
if(!is_dir($currentFolder)){
echo "Created: $currentFolder
";
if(!mkdir($currentFolder)){ die("Could not make ".$currentFolder); }
}
}
}
}
?>[/php]
3. This script: Moved files of Links
[php]
<?php
// Moved files of Links
$url = array(
'http://www.domain.com/file.php',
'http://www.domain.com/dir1-1/dir2/dir3/file.jpg',
'http://www.domain.com/dir1-2/dir2/dir3/dir4/file.zip',
'http://www.domain.com/dir1-3/dir2/dir3/dir4/dir5/file.gif',
'http://www.domain.com/dir1-4/dir2/dir3/dir4/dir5/dir6/file.png',
'http://www.domain.com/dir1-5/dir2/dir3/dir4/dir5/dir6/dir7/file.rar',
);
$record_directory = './test_folder/';
for($i=0;$i<count($url);$i++){
$file_name = basename($url[$i]);
if(copy($url[$i],$record_directory.$file_name)){
echo '-
File Uploaded: ';
echo $file_name;
echo '
';
}else{
echo '- error
';
}
}
?>
[/php]
Is it possible to run scripts by combining numbered 1,2,3?
I will use to move to my website from the server to another server.
you can also
This script does not list the folders named “0”. I wonder what could be the problem?
[php]<?php
// Lists directory
error_reporting(“E_ALL & ~E_NOTICE”);
set_time_limit(0);
function lists ($directory)
{
$slash = “/”;
$dir = dir($directory);
while ($x = $dir->read())
{
if ($x != “.” && $x != “…”)
{
if (is_dir($directory.$slash.$x))
{
lists($directory.$slash.$x);
}
else
{
if ($x != “.” && $x != “…”)
{
$data0="’";
$data1=‘http://’;
$data2= $_SERVER[‘HTTP_HOST’];
$data3=’/’;
$data4= $directory.$slash.$x;
$data5=’’’;
$data6=",";
$data7="
";
$data= $data0.$data1.$data2.$data3.$data4.$data5.$data6;
////////////////////////////////////////////
$file_name = “links_data.txt”;
$value_write = “$data\n”;
if ($data) {
if (!file_exists($file_name)){
touch($file_name);
chmod($file_name,0666);
}
$connect_to_file = fopen($file_name,“a+”);
if (!fwrite($connect_to_file,$value_write)){
echo “Write to file.
”;
exit;
}
echo “Successfully written. See: >> links_data.txt
”;
} else {
echo “Write to file.
”;
}
////////////////////////////////////////////////
}
}
}
}
$dir->close();
}
lists(’./’);
?> [/php]
Best Regards