예제 #1
0
function CreateThemesList()
{
    global $gl_root_path, $content;
    $alldirectories = list_directories($gl_root_path . "themes/");
    for ($i = 0; $i < count($alldirectories); $i++) {
        // Init Theme Settings
        $themename = $alldirectories[$i];
        $content['STYLES'][$themename]['StyleName'] = $themename;
        // Init stuff from abvout
        InitThemeAbout($themename);
        // Copy to userstyles array
        $content['USERSTYLES'][$themename] = $content['STYLES'][$themename];
        // --- web_theme
        if ($content['web_theme'] == $themename) {
            $content['STYLES'][$themename]['selected'] = "selected";
        } else {
            $content['STYLES'][$themename]['selected'] = "";
        }
        // ---
        // --- user_theme
        if ($content['user_theme'] == $themename) {
            $content['USERSTYLES'][$themename]['is_selected'] = "selected";
        } else {
            $content['USERSTYLES'][$themename]['is_selected'] = "";
        }
        // ---
    }
}
예제 #2
0
 function __construct()
 {
     parent::Model();
     $CI =& get_instance();
     $CI->load->helper('directory');
     $this->_dirs = list_directories($CI->asset->assets_server_path, $CI->config->item('assets_excluded_dirs', 'fuel'), FALSE, TRUE);
     $this->_dir_filetypes = $CI->config->item('editable_asset_filetypes', 'fuel');
     $CI->load->helper('directory');
     $CI->load->helper('file');
     $this->validator = new Validator();
     $this->validator->register_to_global_errors = FALSE;
 }
function CreateThemesList()
{
    global $gl_root_path, $content;
    $alldirectories = list_directories($gl_root_path . "themes/");
    for ($i = 0; $i < count($alldirectories); $i++) {
        // --- web_theme
        $content['STYLES'][$i]['StyleName'] = $alldirectories[$i];
        if ($content['web_theme'] == $alldirectories[$i]) {
            $content['STYLES'][$i]['selected'] = "selected";
        } else {
            $content['STYLES'][$i]['selected'] = "";
        }
        // ---
        // --- user_theme
        $content['USERSTYLES'][$i]['StyleName'] = $alldirectories[$i];
        if ($content['user_theme'] == $alldirectories[$i]) {
            $content['USERSTYLES'][$i]['is_selected'] = "selected";
        } else {
            $content['USERSTYLES'][$i]['is_selected'] = "";
        }
        // ---
    }
}
예제 #4
0
function backup_copy_group_files($preferences)
{
    global $CFG;
    $status = true;
    //First we check if "group_files" exists and create it as necessary
    //in temp/backup/$backup_code  dir
    $status = check_and_create_group_files_dir($preferences->backup_unique_code);
    //Now iterate over directories under "groups" to check if that user must be
    //copied to backup
    $rootdir = $CFG->dataroot . '/groups';
    //Check if directory exists
    if (is_dir($rootdir)) {
        $list = list_directories($rootdir);
        if ($list) {
            //Iterate
            foreach ($list as $dir) {
                //Look for dir like group in groups table
                $data = get_record('groups', 'courseid', $preferences->backup_course, 'id', $dir);
                //If exists, copy it
                if ($data) {
                    $status = backup_copy_file($rootdir . "/" . $dir, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/group_files/" . $dir);
                }
            }
        }
    }
    return $status;
}
예제 #5
0
function restore_group_files($restore)
{
    global $CFG;
    $status = true;
    $counter = 0;
    //First, we check to "groups" exists and create is as necessary
    //in CFG->dataroot
    $dest_dir = $CFG->dataroot . '/groups';
    $status = check_dir_exists($dest_dir, true);
    //Now, we iterate over "group_files" records to check if that user dir must be
    //copied (and renamed) to the "groups" dir.
    $rootdir = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/group_files";
    //Check if directory exists
    if (is_dir($rootdir)) {
        $list = list_directories($rootdir);
        if ($list) {
            //Iterate
            $counter = 0;
            foreach ($list as $dir) {
                //Look for dir like groupid in backup_ids
                $data = get_record("backup_ids", "backup_code", $restore->backup_unique_code, "table_name", "groups", "old_id", $dir);
                //If that group exists in backup_ids
                if ($data) {
                    if (!file_exists($dest_dir . "/" . $data->new_id)) {
                        $status = backup_copy_file($rootdir . "/" . $dir, $dest_dir . "/" . $data->new_id, true);
                        $counter++;
                    }
                    //Do some output
                    if ($counter % 2 == 0) {
                        if (!defined('RESTORE_SILENTLY')) {
                            echo ".";
                            if ($counter % 40 == 0) {
                                echo "<br />";
                            }
                        }
                        backup_flush(300);
                    }
                }
            }
        }
    }
    //If status is ok and whe have dirs created, returns counter to inform
    if ($status and $counter) {
        return $counter;
    } else {
        return $status;
    }
}
예제 #6
0
파일: upgrade.php 프로젝트: hungnv0789/vhtm
	/**
	 * CopyFiles
	 * @return Void Returns nothing
	 */
	function CopyFiles()
	{
		if (SENDSTUDIO_SAFE_MODE) {
			?>
				<script>
					self.parent.parent.location = 'index.php?Page=Upgrade&Step=3';
				</script>
			<?php
			return;
		}

		$dirs_to_copy = IEM::sessionGet('DirectoriesToCopy');
		if (!$dirs_to_copy) {
			$dirs_to_copy = list_directories($GLOBALS['ROOTDIR'] . 'temp/images', null, true);

			IEM::sessionSet('DirectoriesToCopy', $dirs_to_copy);

			$dirs_copied = array();
			IEM::sessionSet('DirectoriesCopied', $dirs_copied);

			$dirs_not_copied = array();
			IEM::sessionSet('DirectoriesNotCopied', $dirs_not_copied);
		}

		$dirs_to_copy = IEM::sessionGet('DirectoriesToCopy');
		$dirs_copied = IEM::sessionGet('DirectoriesCopied');

		// Check if there is anything to copy
		if (count($dirs_to_copy) == 0) {
			?>
				<script>
					self.parent.parent.location = 'index.php?Page=Upgrade&Step=3';
				</script>
			<?php
		}

		if ($dirs_to_copy == $dirs_copied) {

			// copy attachments last. there won't be too many of these so we'll do it all in one step.
			$all_attachments = array();
			$query = "SELECT AttachmentID, AttachmentFilename, AttachmentName FROM " . $GLOBALS['TABLEPREFIX'] . "attachments";
			$result = mysql_query($query);
			while ($row = mysql_fetch_assoc($result)) {
				$all_attachments[$row['AttachmentID']] = array('filename' => $row['AttachmentFilename'], 'realname' => $row['AttachmentName']);
			}

			if (!empty($all_attachments)) {
				$query = "select ComposedID, AttachmentIDs from " . $GLOBALS['TABLEPREFIX'] . "composed_emails where attachmentids != ''";
				$result = mysql_query($query);
				while ($row = mysql_fetch_assoc($result)) {
					$new_folder = TEMP_DIRECTORY . '/newsletters/' . $row['ComposedID'];
					CreateDirectory($new_folder);
					$attachments = explode(':', stripslashes($row['AttachmentIDs']));
					foreach ($attachments as $k => $attachid) {
						$fname = basename($all_attachments[$attachid]['filename']);
						$file = $GLOBALS['ROOTDIR'] . 'temp/attachments/' . $fname;

						$realname = $all_attachments[$attachid]['realname'];
						copy($file, $new_folder . '/' . $realname);

						if (!SENDSTUDIO_SAFE_MODE) {
							@chmod($new_folder . '/' . $realname, 0644);
						}
					}
				}

				$query = "select AutoresponderID, AttachmentIDs from " . $GLOBALS['TABLEPREFIX'] . "autoresponders where attachmentids != ''";
				$result = mysql_query($query);
				while ($row = mysql_fetch_assoc($result)) {
					$new_folder = TEMP_DIRECTORY . '/autoresponders/' . $row['ComposedID'];
					CreateDirectory($new_folder);
					$attachments = explode(':', stripslashes($row['AttachmentIDs']));
					foreach ($attachments as $k => $attachid) {
						$fname = basename($all_attachments[$attachid]['filename']);
						$file = $GLOBALS['ROOTDIR'] . 'temp/attachments/' . $fname;

						$realname = $all_attachments[$attachid]['realname'];
						copy($file, $new_folder . '/' . $realname);

						if (!SENDSTUDIO_SAFE_MODE) {
							@chmod($new_folder . '/' . $realname, 0644);
						}
					}
				}
			}
			?>
				<script>
					self.parent.parent.location = 'index.php?Page=Upgrade&Step=3';
				</script>
			<?php
			return;
		}

		$listProcessed = count($dirs_copied);
		$listTotal = count($dirs_to_copy);
		$percentProcessed = 0;

		foreach ($dirs_to_copy as $p => $dir) {
			if (in_array($dir, $dirs_copied)) {
				continue;
			}

			$percentProcessed = ceil(($listProcessed / $listTotal)*100);
			echo "<script>\n";
			echo sprintf("self.parent.UpdateStatusReport('%s');", "Files copied: {$listProcessed}/{$listTotal}");
			echo sprintf("self.parent.UpdateStatus('%s', %d);", "Copying directory \\'{$dir}\\' to new location ...", $percentProcessed);
			echo "</script>\n";
			flush();

			echo 'Copying directory ' . str_replace($GLOBALS['ROOTDIR'], '', $dir) . ' to new location...<br/>';


			$new_dir = str_replace($GLOBALS['ROOTDIR'] . 'temp/images', TEMP_DIRECTORY . '/user', $dir);
			$copied = CopyDirectory($dir, $new_dir);
			if (!$copied) {
				$dirs_not_copied[] = $dir;
				IEM::sessionSet('DirectoriesNotCopied', $dirs_not_copied);
			}
			$dirs_copied[] = $dir;
			IEM::sessionSet('DirectoriesCopied', $dirs_copied);

			$listProcessed++;
		}
		?>
			<script>
				setTimeout('window.location="index.php?Page=Upgrade&Action=CopyFiles"', 1);
			</script>
		<?php

	}
/**
 * Lists the directories only from a give directory
 *
 * @access	public
 * @param 	string
 * @param 	mixed
 * @param 	boolean
 * @param 	boolean
 * @param 	boolean
 * @return	array
 */
function list_directories($directory, $exclude = array(), $full_path = TRUE, $is_writable = FALSE, $_first_time = TRUE)
{
    static $orig_directory;
    static $dirs;
    if ($_first_time) {
        $orig_directory = $directory;
    }
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if (strncmp($file, '.', 1) !== 0 and (is_array($exclude) and !in_array($file, $exclude) or is_string($exclude) and !empty($exclude) and !preg_match($exclude, $file))) {
                $file_path = $directory . "/" . $file;
                if (is_dir($file_path)) {
                    if ($is_writable and !is_writable($file_path)) {
                        continue;
                    }
                    $dir_prefix = !$full_path ? substr($directory, strlen($orig_directory)) : $directory;
                    $dir = $dir_prefix . "/" . $file;
                    $dir = str_replace("//", "/", $dir);
                    // replace double slash
                    if (substr($dir, 0, 1) == '/') {
                        $dir = substr($dir, 1);
                    }
                    // remove begining slash
                    if (!isset($dirs)) {
                        $dirs = array();
                    }
                    if (!in_array($dir, $dirs)) {
                        $dirs[] = $dir;
                    }
                    list_directories($file_path, $exclude, $full_path, $is_writable, FALSE);
                }
            }
        }
        closedir($handle);
    }
    return $dirs;
}
예제 #8
0
	/**
	 * GetUpgradesToRun
	 * @param String $current_version Current version
	 * @param String $latest Latest version
	 * @return Array Returns an array of upgrade to be performed
	 */
	function GetUpgradesToRun($current_version=0, $latest=0)
	{
		if ($current_version == $latest) {
			return array('upgrades' => array(), 'number_to_run' => 0);
		}

		$dirs = list_directories(IEM_PATH . '/upgrades');

		$upgrades_to_run = array();
		$number_to_run = 0;

		/**
		* If the current version is '2004'
		* we need to include the 'nx' upgrades before anything else.
		*/
		if ($current_version == '2004') {
			$upgrades = $this->upgrades_to_run['nx'];

			$upgrades_to_run['nx'] = $upgrades;
			$number_to_run += sizeof($upgrades);
		}

		foreach ($dirs as $p => $dir) {
			$dirname = str_replace(IEM_PATH . '/upgrades/', '', $dir);

			/**
			* If the directory isn't a numeric folder name, check the current version.
			* If the current version is '2004', then we need to include the 'nx' folder.
			* If the current version is NOT nx, then skip non-numeric folders.
			*/
			if (!is_numeric($dirname)) {
				continue;
			}

			/**
			* If we are mid-way through database changes, ie:
			* - our version is '2'
			* and there are upgrades for 1,2,3
			* we want to skip any that are before our current version.
			*/
			if ($dirname <= $current_version) {
				continue;
			}

			$upgrades = $this->upgrades_to_run[$dirname];

			$upgrades_to_run[$dirname] = $upgrades;
			$number_to_run += sizeof($upgrades);
		}

		return array('upgrades' => $upgrades_to_run, 'number_to_run' => $number_to_run);
	}
예제 #9
0
/**
 * Lists the directories only from a give directory
 *
 * @access	public
 * @param 	string
 * @param 	mixed
 * @param 	boolean
 * @param 	boolean
 * @param 	boolean
 * @param 	boolean
 * @return	array
 */
function list_directories($directory, $exclude = array(), $full_path = TRUE, $is_writable = FALSE, $recursive = TRUE, $_first_time = TRUE)
{
    static $orig_directory;
    static $dirs;
    if ($_first_time) {
        $orig_directory = rtrim($directory, '/');
        $dirs = NULL;
    }
    if ($handle = opendir($directory)) {
        while (FALSE !== ($file = readdir($handle))) {
            if (strncmp($file, '.', 1) !== 0 and (is_array($exclude) and !in_array($file, $exclude) or is_string($exclude) and !empty($exclude) and !preg_match($exclude, $file))) {
                $file_path = $directory . "/" . $file;
                if (is_dir($file_path)) {
                    if ($is_writable and !is_writable($file_path)) {
                        continue;
                    }
                    if (!$full_path) {
                        $dir_prefix = substr($directory, strlen($orig_directory));
                        $dir = trim($dir_prefix . "/" . $file, '/');
                    } else {
                        $dir_prefix = $directory;
                        $dir = $dir_prefix . "/" . $file;
                    }
                    $dir = str_replace("//", "/", $dir);
                    // replace double slash
                    if (!isset($dirs)) {
                        $dirs = array();
                    }
                    if (!empty($dir) and !in_array($dir, $dirs)) {
                        $dirs[] = $dir;
                    }
                    if ($recursive) {
                        list_directories($file_path, $exclude, $full_path, $is_writable, TRUE, FALSE);
                    }
                }
            }
        }
        closedir($handle);
    }
    return $dirs;
}
예제 #10
0
 /**
  * Returns an array of the main root asset folders
  *
  * @access	public
  * @return	array
  */
 public function root_dirs($full_path = FALSE)
 {
     $asset_server_path = $this->CI->asset->assets_server_path();
     $dirs = list_directories($asset_server_path, array(), $full_path, FALSE, FALSE);
     if (!empty($dirs)) {
         $dirs = array_combine($dirs, $dirs);
     }
     ksort($dirs);
     return $dirs;
 }
예제 #11
0
	function form_fields($values = null)
	{
		$CI =& get_instance();
		$CI->load->helper('directory');
		
		$fields = parent::form_fields();
		
		unset($fields['super_admin']);
		
		// save reference it so we can reorder
		$pwd_field = $fields['password'];
		unset($fields['password']);
		
		$user_id = NULL;
		if (!empty($values['id']))
		{
			$user_id = $values['id'];
		}

		if (!empty($user_id))
		{
			$fields['new_password'] = array('label' => lang('form_label_new_password'), 'type' => 'password', 'size' => 20, 'order' => 5);
		}
		else
		{
			$pwd_field['type'] = 'password';
			$pwd_field['size'] = 20;
			$pwd_field['order'] = 5;
			$fields['password']= $pwd_field;
		}
		
		$lang_dirs = list_directories(FUEL_PATH.'language/', array(), FALSE);
		$lang_options = array_combine($lang_dirs, $lang_dirs);
		
		if (count($lang_options) >= 2)
		{
			$fields['language'] = array('type' => 'select', 'options' => $lang_options, 'value' => 'english');
		}
		else
		{
			$fields['language']['type'] = 'hidden';
		}


		$fields['user_name']['order'] = 1;
		$fields['email']['order'] = 2;
		$fields['first_name']['order'] = 3;
		$fields['last_name']['order'] = 4;
		$fields['confirm_password'] = array('label' => lang('form_label_confirm_password'), 'type' => 'password', 'size' => 20, 'order' => 6);
		
		$fields['active']['order'] = 8;
		
		
		// get permissions
		$CI =& get_instance();
		$perm_fields = array();
		$user = $CI->fuel_auth->user_data();
		
		//if (($CI->fuel_auth->is_super_admin() AND ($user['id'] != $user_id)) AND (!empty($values['super_admin']) AND $values['super_admin'] != 'yes'))
		if (($CI->fuel_auth->is_super_admin() AND ($user['id'] != $user_id))
			OR (!$CI->fuel_auth->is_super_admin() AND $CI->fuel_auth->has_permission('permissions'))
		)
		{
			$CI->load->module_model(FUEL_FOLDER, 'user_to_permissions_model');
			$selected_perms = $CI->user_to_permissions_model->get_permissions($user_id, FALSE);

			// if (!empty($selected_perms)) 
			// {
				$fields[lang('permissions_heading')] = array('type' => 'section', 'order' => 10);
//			}
			
			$CI->load->module_model(FUEL_FOLDER, 'permissions_model');
			$perms = $CI->permissions_model->find_all_array(array('active' => 'yes'), 'name asc');
			
			$order = 11;
			foreach($perms as $val)
			{
				$perm_field = 'permissions_'.$val['id'];
				$perm_fields[$perm_field]['type'] = 'checkbox';
				$perm_fields[$perm_field]['value'] = $val['id'];
				$perm_fields[$perm_field]['order'] = $order;
				$label = lang('perm_'.$val['name']);
				if (empty($label))
				{
					$label = (!empty($val['description'])) ? $val['description'] : $val['name'];
				}
				$perm_fields[$perm_field]['label'] = $label;
				if (!empty($selected_perms[$val['id']])) $perm_fields[$perm_field]['checked'] = TRUE;
				$order++;
			}
		}
		$fields = array_merge($fields, $perm_fields);
		unset($fields['reset_key']);
		return $fields;
	}
예제 #12
0
 /**
  * User form fields
  *
  * @access	public
  * @param	array Values of the form fields (optional)
  * @param	array An array of related fields. This has been deprecated in favor of using has_many and belongs to relationships (deprecated)
  * @return	array An array to be used with the Form_builder class
  */
 public function form_fields($values = array(), $related = array())
 {
     $CI =& get_instance();
     $CI->load->helper('directory');
     $fields = parent::form_fields($values, $related);
     unset($fields['super_admin']);
     // save reference it so we can reorder
     $pwd_field = $fields['password'];
     unset($fields['password']);
     $user_id = NULL;
     if (!empty($values['id'])) {
         $user_id = $values['id'];
     }
     $fields['confirm_password'] = array('label' => lang('form_label_confirm_password'), 'type' => 'password', 'size' => 20, 'order' => 6);
     if (!empty($user_id)) {
         $fields['new_password'] = array('label' => lang('form_label_new_password'), 'type' => 'password', 'size' => 20, 'order' => 5);
     } else {
         $pwd_field['type'] = 'password';
         $pwd_field['size'] = 20;
         $pwd_field['order'] = 5;
         //$fields['password']= $pwd_field;
         $fields['new_password'] = array('label' => lang('form_label_password'), 'type' => 'password', 'size' => 20, 'order' => 5, 'required' => TRUE);
         $fields['confirm_password']['required'] = TRUE;
     }
     $lang_dirs = list_directories(FUEL_PATH . 'language/', array(), FALSE);
     $lang_options = array_combine($lang_dirs, $lang_dirs);
     if (count($lang_options) >= 2) {
         $fields['language'] = array('type' => 'select', 'options' => $lang_options, 'value' => 'english');
     } else {
         $fields['language']['type'] = 'hidden';
     }
     $fields['user_name']['order'] = 1;
     $fields['email']['order'] = 2;
     $fields['first_name']['order'] = 3;
     $fields['last_name']['order'] = 4;
     $fields['active']['order'] = 8;
     // get permissions
     $CI =& get_instance();
     $perm_fields = array();
     $user = $CI->fuel->auth->user_data();
     //if you are a super admin or a user that has permissions to assign permissions and you are not editing yourself, then display the permissions
     if ($CI->fuel->auth->has_permission('permissions') and ($user['id'] != $user_id and (!empty($values['super_admin']) and $values['super_admin'] != 'yes') or $CI->fuel->auth->has_permission('permissions') and empty($values['id']))) {
         $fields[lang('permissions_heading')] = array('type' => 'section', 'order' => 10);
         $fields['permissions'] = array('type' => 'custom', 'func' => array($this, '_create_permission_fields'), 'order' => 11, 'user_id' => isset($values['id']) ? $values['id'] : '');
         $fields['permissions']['mode'] = 'checkbox';
         $fields['permissions']['display_label'] = FALSE;
         $fields['permissions']['wrapper_tag'] = 'div';
         $fields['exists_permissions'] = array('type' => 'hidden', 'value' => 1);
     } else {
         unset($fields['permissions']);
     }
     //$fields = array_merge($fields, $perm_fields);
     unset($fields['reset_key'], $fields['salt']);
     return $fields;
 }
예제 #13
0
파일: general.php 프로젝트: hungnv0789/vhtm
/**
* list_directories
* Lists directories under a particular tree. Can also skip particular directory names of files.
*
* @param String $dir Name of directory to list directories for.
* @param Array $skip_dirs Directory names to skip. Can be a single name or an array.
* @param Boolean $recursive Whether to recursively list directories or not. Default is no.
*
* @return Mixed Returns false if it can't open a directory, else it returns a multi-dimensional array.
*/
function list_directories($dir='', $skip_dirs = null, $recursive=false)
{
	if (empty($dir) || !is_dir($dir)) {
		return false;
	}

	$file_list = array();

	if (substr($dir, -1) == '/') {
		$dir = substr($dir, 0, -1);
	}

	// need to use the '@' in case we can't open the directory
	// otherwise it still throws a notice.
	if (!$handle = @opendir($dir)) {
		return false;
	}

	while (($file = readdir($handle)) !== false) {
		if ($file == '.' || $file == '..') {
			continue;
		}

		if (is_dir($dir.'/'.$file) && !isset($file_list[$file])) {
			$file_list[] = $dir . '/' . $file;
			if ($recursive) {
				$subdir = list_directories($dir.'/'.$file, $skip_dirs, $recursive);
				if (!empty($subdir)) {
					foreach ($subdir as $p => $subdirname) {
						$file_list[] = $subdirname;
					}
				}
			}
		}
	}
	closedir($handle);
	if (!$recursive) {
		natcasesort($file_list);
	}

	return $file_list;
}
예제 #14
0
 /**
  * MoveFiles
  * Moves uploaded images from temporary storage under a user's id - to it's final location - under the type and it's id. Eg newsletter/1.
  *
  * @param String $destination The destination (eg newsletter or template).
  * @param Int $id The destinations id.
  *
  * @see CreateDirectory
  * @see list_files
  *
  * @return Boolean Returns false if it can't create the paths or it can't copy the necessary files. Returns true if everything worked ok.
  */
 function MoveFiles($destination = false, $id = 0)
 {
     if (!$destination || !$id) {
         return false;
     }
     $destinationdir = TEMP_DIRECTORY . '/' . $destination . '/' . $id;
     $createdir = CreateDirectory($destinationdir);
     if (!$createdir) {
         return false;
     }
     $user = IEM::getCurrentUser();
     $sourcedir = TEMP_DIRECTORY . '/user/' . $user->userid;
     $file_list = list_files($sourcedir);
     $dir_list = list_directories($sourcedir);
     if (empty($file_list) && empty($dir_list)) {
         return true;
     }
     $result = true;
     foreach ($file_list as $p => $filename) {
         if (!copy($sourcedir . '/' . $filename, $destinationdir . '/' . $filename)) {
             $result = false;
         }
     }
     if ($result) {
         foreach ($dir_list as $dir) {
             $dirname = str_replace($sourcedir, '', $dir);
             if ($dirname == 'attachments') {
                 continue;
             }
             $copy_dir_result = CopyDirectory($dir, $destinationdir . $dirname);
             if (!$copy_dir_result) {
                 $resut = false;
             }
         }
     }
     return $result;
 }