Icy Phoenix

     
 


Tags And Keywordsfree php scripts, php files copier

Post new topic  Reply to topic 
Page 1 of 1
 
 
Reply with quote Download Post 
Post Copy A File In All Folders And SubFolders 
 
I have created this script a lot of time ago when I needed to update all index.html files into my Icy Phoenix... doing it by hand would have required a lot of time, so I have created this:

Code: [Download] [Hide] [Select]
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/GPL-license.php GNU Public License
*
*/

echo('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n");
echo(
'<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-gb" xml:lang="en-gb">' . "\n");
echo(
'<head><title>Files List</title></head>' . "\n");
echo(
'<body style="font-family:\'Courier New\', \'Trebuchet MS\', Verdana, Tahoma;font-size:12px;">' . "\n");
$root_dir = './';
$exclude_array = array('install');
$source_file = 'install/index.html';
$files_list = create_files_list_full($root_dir, '');
foreach (
$files_list as $file_element)
{
    if (
is_dir($file_element) && !in_array($file_element, $exclude_array))
    {
        
$tmp_paths = array();
        
$tmp_paths = explode('/', $file_element);
        
$skip_sub_folder = false;
        for (
$i = 0; $i < sizeof($tmp_paths); $i++)
        {
            for (
$j = 0; $j < sizeof($exclude_array); $j++)
            {
                if (
$exclude_array[$j] == $tmp_paths[$i])
                {
                    
$skip_sub_folder = true;
                    break;
                }
            }
            if (
$skip_sub_folder == true)
            {
                break;
            }
        }
        if (
$skip_sub_folder == false)
        {
            @
unlink($file_element . '/index.html');
            @
copy($source_file, $file_element . '/index.html');
            echo(
'<b style="color:#800080;">&bull;&nbsp;' . $file_element . '</b><br />' . "\n");
            
flush();
        }
    }
}

echo(
'</body>' . "\n" . '</html>');


// FUNCTIONS

function create_files_list_full($dir, $extensions = '')
{
    
$directory = @opendir($dir);
    
$files_list = array();

    while (@
$file = readdir($directory))
    {
        if (!
in_array($file, array('.', '..')))
        {
            
$is_dir = (is_dir($dir . '/' . $file)) ? true : false;

            
$temp_path = str_replace('//', '/', ($dir . '/' . $file));

            
$file_details = get_file_details($temp_path);
            
$file_title = $file_details['name'];
            
$file_type = strtolower($file_details['ext']);

            
$process_file = false;
            if (
$extensions == '')
            {
                
//$file_exclusions_array = array();
                
$file_exclusions_array = array('ace', 'bak', 'bmp', 'css', 'gif', 'hl', 'htc', 'htm', 'html', 'ico', 'jar', 'jpeg', 'jpg', 'js', 'pak', 'png', 'rar', 'sql', 'swf', 'tpl', 'ttf', 'txt', 'wmv', 'zip');
                if (!
in_array($file_type, $file_exclusions_array))
                {
                    
$process_file = true;
                }
            }
            else
            {
                if (
$file_type == $extensions)
                {
                    
$process_file = true;
                }
            }

            if (
$process_file == true)
            {
                
$files_list[] = $temp_path;
            }

            
// Directory found, so recall this function
            
if ($is_dir)
            {
                
$files_list = array_merge($files_list, create_files_list_full($dir . '/' . $file, $extensions));
            }
        }
// if
    
} // while

    
@closedir($directory);

    return
$files_list;
}

/*
* get_file_details
* Get File Details: name, extension
*/
function get_file_details($file_name)
{
    
$file_details = array();
    
$file_tmp = str_replace ('http://', '', $file_name);
    
$file_path[] = array();
    
$file_path = explode('/', $file_tmp);
    
$file_details['name_full'] = $file_path[sizeof($file_path) - 1];
    
$file_part = explode('.', strtolower($file_details['name_full']));
    
$file_details['ext'] = $file_part[sizeof($file_part) - 1];
    
$file_details['name'] = substr($file_details['name_full'], 0, strlen($file_details['name_full']) - strlen($file_details['ext']) - 1);
    return
$file_details;
}

?>


If you want to use this script, you just have to specify the file to be copied ($source_file) and the paths you would like to exclude (if any...).

Please note that this script will overwrite any file with the same name of the one you are going to copy, so make sure you use this script on a backup copy first.
 




____________
Luca
SEARCH is the quickest way to get support.
Icy Phoenix ColorizeIt - CustomIcy - HON
 
Mighty GorgonSend private messageSend e-mail to userVisit poster's website  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Reply with quote Download Post 
Post Re: Copy A File In All Folders And SubFolders 
 
Thanks Luca will come in very handy when i get back on board shortly
 




____________
Mods and themes for Icy Phoenix 1.3

IcyPhoenix UK is off-line permanently due to lack of time to update mods.
if anyone is interested in my templates I will upgrade them to Icy 2.0.
 
DWhoSend private messageVisit poster's website  
Back to topPage bottom
Post new topic  Reply to topic  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events


  

 

  cron