LEPTON CMS 7.0.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.rename_recursive_dirs.php
Go to the documentation of this file.
1<?php
2
18// include secure.php to protect this file and the whole CMS!
19if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
20if (defined('LEPTON_PATH')) {
21 include LEPTON_PATH.SEC_FILE;
22} else {
23 $oneback = "../";
24 $root = $oneback;
25 $level = 1;
26 while (($level < 10) && (!file_exists($root.SEC_FILE))) {
27 $root .= $oneback;
28 $level += 1;
29 }
30 if (file_exists($root.SEC_FILE)) {
31 include $root.SEC_FILE;
32 } else {
33 trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
34 }
35}
36// end include secure file
37
38
49function rename_recursive_dirs(string $dirsource, string $dirdest, int $deep=0): bool
50{
51 LEPTON_handle::register("rm_full_dir");
52
53 if (true === is_dir($dirsource))
54 {
55 if (false === is_dir($dirdest))
56 {
57 LEPTON_core::make_dir($dirdest);
58 }
59
60 $dir = dir($dirsource);
61 while ( $file = $dir->read() )
62 {
63 if( $file[0] != "." )
64 {
65 if( !is_dir($dirsource."/".$file) )
66 {
67 copy ($dirsource."/".$file, $dirdest."/".$file);
68 LEPTON_core::change_mode($dirdest."/".$file);
69 }
70 else
71 {
72 LEPTON_core::make_dir($dirdest."/".$file);
73 rename_recursive_dirs($dirsource."/".$file, $dirdest.'/'.$file, $deep+1);
74 }
75 }
76 }
77 $dir->close();
78 }
79 if ($deep == 0)
80 {
81 rm_full_dir( $dirsource );
82 }
83 return true;
84}
rename_recursive_dirs(string $dirsource, string $dirdest, int $deep=0)
rm_full_dir(string $directory)