コード例 #1
0
ファイル: functions.php プロジェクト: keremcankaya0/CakeBlog
function recursive_copy($src, $dst)
{
    $dir = opendir($src);
    @mkdir($dst);
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($src . '/' . $file)) {
                recursive_copy($src . '/' . $file, $dst . '/' . $file);
            } else {
                copy($src . '/' . $file, $dst . '/' . $file);
            }
        }
    }
    closedir($dir);
}
コード例 #2
0
ファイル: file_helper.php プロジェクト: silvranz/ovs
 function recursive_copy($src, $dst)
 {
     if (!file_exists($src) && !is_dir($src)) {
         die("Template not found");
     }
     $dir = opendir($src);
     mkdir($dst);
     while (false !== ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             if (is_dir($src . '/' . $file)) {
                 recursive_copy($src . '/' . $file, $dst . '/' . $file);
             } else {
                 copy($src . '/' . $file, $dst . '/' . $file);
             }
         }
     }
     closedir($dir);
 }
コード例 #3
0
ファイル: recursive_copy.php プロジェクト: Prescia/Prescia
function recursive_copy($source, $destination)
{
    $counter = 0;
    if (substr($source, strlen($source), 1) != "/") {
        $source .= "/";
    }
    if (substr($destination, strlen($destination), 1) != "/") {
        $destination .= "/";
    }
    if (!is_dir($destination)) {
        makeDirs($destination);
    }
    $itens = listFiles($source);
    foreach ($itens as $id => $name) {
        if ($name[0] == "/") {
            $name = substr($name, 1);
        }
        if (is_file($source . $name)) {
            // file
            if ($name != "Thumbs.db") {
                $counter++;
                if (!copy($source . $name, $destination . $name)) {
                    echo "Error: " . $source . $name . " -> " . $destination . $name . "<br/>";
                } else {
                    safe_chmod($destination . $name, 0775);
                }
            } else {
                @unlink($source . $name);
            }
        } else {
            if (is_dir($source . $name)) {
                // dir
                if (!is_dir($destination . $name)) {
                    safe_mkdir($destination . $name);
                }
                $counter += recursive_copy($source . $name, $destination . $name);
            }
        }
    }
    return $counter;
}
コード例 #4
0
ファイル: _maintain.php プロジェクト: debruine/webmorph
function recursive_copy($source, $dest)
{
    global $return;
    if (is_dir($source)) {
        $dir_handle = opendir($source);
        while ($file = readdir($dir_handle)) {
            if ($file != "." && $file != "..") {
                if (is_dir($source . "/" . $file)) {
                    if (!is_dir($dest . "/" . $file)) {
                        mkdir($dest . "/" . $file);
                    }
                    recursive_copy($source . "/" . $file, $dest . "/" . $file);
                } else {
                    copy($source . "/" . $file, $dest . "/" . $file);
                    $return['copied'][] = $source . "/" . $file;
                }
            }
        }
        closedir($dir_handle);
    } else {
        copy($source, $dest);
        $return['copied'][] = $source;
    }
}
コード例 #5
0
ファイル: install_switch.php プロジェクト: shadowym/fusionpbx
 protected function copy_scripts()
 {
     $this->write_progress("\tCopying Scripts");
     $script_dir = $this->global_settings->switch_script_dir();
     if (strlen($script_dir) == 0) {
         throw new Exception("Cannot copy scripts the 'script_dir' is empty");
     }
     if (file_exists($script_dir)) {
         if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')) {
             $src_dir = '/usr/share/examples/fusionpbx/resources/install/scripts';
         } else {
             $src_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/install/scripts';
         }
         $dst_dir = $script_dir;
         if (is_readable($script_dir)) {
             recursive_copy($src_dir, $dst_dir, $_SESSION['scripts']['options']['text']);
             unset($src_dir, $dst_dir);
         } else {
             throw new Exception("Cannot read from '{$src_dir}' to get the scripts");
         }
         chmod($dst_dir, 0774);
     } else {
         $this->write_progress("\tSkipping scripts, script_dir is unset");
     }
 }
コード例 #6
0
 protected function backup_dir($dir, $backup_name)
 {
     if (!is_readable($dir)) {
         throw new Exception("backup_dir() source directory '" . $dir . "' does not exist.");
     }
     $dst_tar = join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), "{$backup_name}.tar"));
     //pharData is the correct ay to do it, but it keeps creating incomplete archives
     //$tar = new PharData($dst_tar);
     //$tar->buildFromDirectory($dir);
     $this->write_debug("backing up to {$dst_tar}");
     if (file_exists('/bin/tar')) {
         exec('tar -cvf ' . $dst_tar . ' -C ' . $dir . ' .');
     } else {
         $this->write_debug('WARN: old config could not be compressed');
         $dst_dir = join(DIRECTORY_SEPARATOR, array(sys_get_temp_dir(), "{$backup_name}"));
         recursive_copy($dir, $dst_dir);
     }
 }
コード例 #7
0
ファイル: scripts.php プロジェクト: urueedi/fusionpbx
 /**
  * Copy the switch scripts from the web directory to the switch directory
  */
 public function copy_files()
 {
     if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
         $dst_dir = $_SESSION['switch']['scripts']['dir'];
         if (strlen($dst_dir) == 0) {
             throw new Exception("Cannot copy scripts the 'script_dir' is empty");
         }
         if (file_exists($dst_dir)) {
             //get the source directory
             if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')) {
                 $src_dir = '/usr/share/examples/fusionpbx/resources/install/scripts';
             } else {
                 $src_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/resources/install/scripts';
             }
             if (is_readable($dst_dir)) {
                 recursive_copy($src_dir, $dst_dir);
                 unset($src_dir, $dst_dir);
             } else {
                 throw new Exception("Cannot read from '{$src_dir}' to get the scripts");
             }
             chmod($dst_dir, 0774);
         } else {
             throw new Exception("Scripts directory doesn't exist");
         }
     }
 }
コード例 #8
0
ファイル: libfreepbx.install.php プロジェクト: hardikk/HNH
/** Recursively copy a directory
 */
function recursive_copy($dirsourceparent, $dirdest, &$md5sums, $dirsource = "")
{
    global $dryrun;
    global $check_md5s;
    global $amp_conf;
    global $asterisk_conf;
    global $install_moh;
    global $make_links;
    $moh_subdir = isset($amp_conf['MOHDIR']) ? trim(trim($amp_conf['MOHDIR']), '/') : 'mohmp3';
    // total # files, # actually copied
    $num_files = $num_copied = 0;
    if ($dirsource && $dirsource[0] != "/") {
        $dirsource = "/" . $dirsource;
    }
    if (is_dir($dirsourceparent . $dirsource)) {
        $dir_handle = opendir($dirsourceparent . $dirsource);
    }
    /*
    echo "dirsourceparent: "; var_dump($dirsourceparent);
    echo "dirsource: "; var_dump($dirsource);
    echo "dirdest: "; var_dump($dirdest);
    */
    while (isset($dir_handle) && ($file = readdir($dir_handle))) {
        if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn") {
            $source = $dirsourceparent . $dirsource . "/" . $file;
            $destination = $dirdest . $dirsource . "/" . $file;
            if ($dirsource == "" && $file == "moh" && !$install_moh) {
                // skip to the next dir
                continue;
            }
            // configurable in amportal.conf
            if (strpos($destination, "htdocs_panel") == 1) {
                $destination = str_replace("/htdocs_panel", trim($amp_conf["FOPWEBROOT"]), $destination);
            } else {
                $destination = str_replace("/htdocs", trim($amp_conf["AMPWEBROOT"]), $destination);
            }
            $destination = str_replace("/htdocs_panel", trim($amp_conf["FOPWEBROOT"]), $destination);
            //			$destination=str_replace("/cgi-bin",trim($amp_conf["AMPCGIBIN"]),$destination);
            if (strpos($dirsource, 'modules') === false) {
                $destination = str_replace("/bin", trim($amp_conf["AMPBIN"]), $destination);
            }
            $destination = str_replace("/sbin", trim($amp_conf["AMPSBIN"]), $destination);
            // the following are configurable in asterisk.conf
            $destination = str_replace("/astetc", trim($asterisk_conf["astetcdir"]), $destination);
            $destination = str_replace("/moh", trim($asterisk_conf["astvarlibdir"]) . "/{$moh_subdir}", $destination);
            $destination = str_replace("/astvarlib", trim($asterisk_conf["astvarlibdir"]), $destination);
            if (strpos($dirsource, 'modules') === false) {
                $destination = str_replace("/agi-bin", trim($asterisk_conf["astagidir"]), $destination);
            }
            if (strpos($dirsource, 'modules') === false) {
                $destination = str_replace("/sounds", trim($asterisk_conf["astvarlibdir"]) . "/sounds", $destination);
            }
            // if this is a directory, ensure destination exists
            if (is_dir($source)) {
                if (!file_exists($destination)) {
                    if (!$dryrun && $destination != "") {
                        amp_mkdir($destination, "0750", true);
                    }
                }
            }
            //var_dump($md5sums);
            if (!is_dir($source)) {
                $md5_source = preg_replace("|^/?amp_conf/|", "/", $source);
                if ($check_md5s && file_exists($destination) && isset($md5sums[$md5_source]) && md5_file($destination) != $md5sums[$md5_source]) {
                    // double check using diff utility (and ignoring whitespace)
                    // This is a somewhat edge case (eg, the file doesn't match
                    // it's md5 sum from the previous version, but no substantial
                    // changes exist compared to the current version), but it
                    // pervents a useless prompt to the user.
                    if (checkDiff($source, $destination)) {
                        $overwrite = ask_overwrite($source, $destination);
                    } else {
                        debug("NOTE: MD5 for " . $destination . " was different, but `diff` did not detect any (non-whitespace) changes: overwriting");
                        $overwrite = true;
                    }
                } else {
                    $overwrite = true;
                }
                $num_files++;
                if ($overwrite) {
                    debug(($make_links ? "link" : "copy") . " " . $source . " -> " . $destination);
                    if (!$dryrun) {
                        if ($make_links) {
                            // symlink, unlike copy, doesn't overwrite - have to delete first
                            if (is_link($destination) || file_exists($destination)) {
                                unlink($destination);
                            }
                            symlink($_ENV["PWD"] . "/" . $source, $destination);
                        } else {
                            copy($source, $destination);
                        }
                        $num_copied++;
                    }
                } else {
                    debug("not overwriting " . $destination);
                }
            } else {
                //echo "recursive_copy($dirsourceparent, $dirdest, $md5sums, $dirsource/$file)";
                list($tmp_num_files, $tmp_num_copied) = recursive_copy($dirsourceparent, $dirdest, $md5sums, $dirsource . "/" . $file);
                $num_files += $tmp_num_files;
                $num_copied += $tmp_num_copied;
            }
        }
    }
    if (isset($dir_handle)) {
        closedir($dir_handle);
    }
    return array($num_files, $num_copied);
}
コード例 #9
0
ファイル: update.php プロジェクト: keremcankaya0/CakeBlog
} else {
    echo '<form method="post">';
    echo '<input name="submit" type="hidden" value="submit" />';
    echo '</form>';
    if (!empty($_POST['submit'])) {
        $hostfile = fopen($zip_url . $zip_name, 'r');
        $fh = fopen($zip_name, 'w');
        while (!feof($hostfile)) {
            $output = fread($hostfile, 8192);
            fwrite($fh, $output);
        }
        fclose($hostfile);
        fclose($fh);
        require_once 'pclzip.lib.php';
        $archive = new PclZip($zip_name);
        if (($v_result_list = $archive->extract()) == 0) {
            die("Error : " . $archive->errorInfo(true));
        }
        unlink($zip_name);
        //DELETE ZIP
        recursive_copy($src_dir, $dest_dir);
        //COPY FILES
        //system('/bin/rm -rf ' . escapeshellarg($src_dir)); //LINUX DELETE
        system('rd /Q /S "' . $src_dir . '"');
        //WINDOWS DELETE
        include 'mysql_update.php';
        //UPDATE MYSQL
        echo "Updater finished!";
        //FINAL
    }
}
コード例 #10
0
ファイル: Template.php プロジェクト: silvranz/ovs
 public function createStore()
 {
     $this->load->dbforge();
     $this->load->helper('file_helper');
     $this->load->helper('Mobile_Detect_helper');
     $this->load->helper('create_db_helper');
     $detect = new Mobile_Detect();
     $deviceName = "";
     if ($detect->isMobile()) {
         $deviceName = "mobile";
     } else {
         if ($detect->isTablet()) {
             $deviceName = "tablet";
         } else {
             $deviceName = "pc";
         }
     }
     $post = $this->input->post();
     $clientInfo = $post["clientInfo"];
     $userId = $this->session->userdata("userid");
     $databaseObj = $this->template->getTemplateName($post["key"]);
     $resultObj = $databaseObj->result()[0];
     $projectName = $resultObj->TemplateProjectName;
     $projectImage = $resultObj->TemplateImage;
     recursive_copy("assets/template/" . $projectName, "../" . $post["domainName"]);
     copy("assets/images/screen-shot/" . $projectImage, "assets/images/screen-shot/" . $post["domainName"] . ".jpg");
     $databaseObj->next_result();
     $databaseObj = $this->template->createStore($post["storeName"], $post["domainName"], $userId, $post["key"], $clientInfo["appCodeName"], $clientInfo["appVersion"], $this->input->ip_address(), $deviceName, $clientInfo["platform"]);
     $newStore = $databaseObj->result()[0];
     $databaseObj->next_result();
     execSql($newStore->TemplateType, $post["domainName"], get_instance());
 }
コード例 #11
0
 protected function copy_conf()
 {
     //send a message
     $this->write_progress("\tCopying Config");
     //make a backup of the config
     if (file_exists($this->global_settings->switch_conf_dir())) {
         $this->backup_dir($this->global_settings->switch_conf_dir(), 'fusionpbx_switch_config');
         recursive_delete($this->global_settings->switch_conf_dir());
     }
     //make sure the conf directory exists
     if (!is_dir($this->global_settings->switch_conf_dir())) {
         if (!mkdir($this->global_settings->switch_conf_dir(), 0774, true)) {
             throw new Exception("Failed to create the switch conf directory '" . $this->global_settings->switch_conf_dir() . "'. ");
         }
     }
     //copy resources/templates/conf to the freeswitch conf dir
     if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')) {
         $src_dir = "/usr/share/examples/fusionpbx/resources/templates/conf";
     } else {
         $src_dir = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/templates/conf";
     }
     $dst_dir = $this->global_settings->switch_conf_dir();
     if (is_readable($dst_dir)) {
         recursive_copy($src_dir, $dst_dir);
         unset($src_dir, $dst_dir);
     }
     $fax_dir = join(DIRECTORY_SEPARATOR, array($this->global_settings->switch_storage_dir(), 'fax'));
     if (!is_readable($fax_dir)) {
         mkdir($fax_dir, 0777, true);
     }
     $voicemail_dir = join(DIRECTORY_SEPARATOR, array($this->global_settings->switch_storage_dir(), 'voicemail'));
     if (!is_readable($voicemail_dir)) {
         mkdir($voicemail_dir, 0777, true);
     }
     //write the xml_cdr.conf.xml file
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/xml_cdr")) {
         xml_cdr_conf_xml();
     }
     //write the switch.conf.xml file
     if (file_exists($this->global_settings->switch_conf_dir())) {
         switch_conf_xml();
     }
 }
コード例 #12
0
ファイル: lib_switch.php プロジェクト: petekelly/fusionpbx
 function sync_directory()
 {
     global $v_id, $db;
     $v_settings_array = v_settings();
     foreach ($v_settings_array as $name => $value) {
         ${$name} = $value;
     }
     //if the directory does not exist then create it.
     clearstatcache();
     if (!is_dir($v_sounds_dir . "/en/us/callie/directory/48000")) {
         mkdir($v_sounds_dir . "/en/us/callie/directory/48000", 0700, true);
         $src_dir = $v_web_dir . '/includes/install/sounds/directory/48000';
         $dest_dir = $v_sounds_dir . "/en/us/callie/directory/48000";
         //echo "src_dir $src_dir<br />\n";
         //echo "dest_dir $dest_dir<br />\n";
         recursive_copy($src_dir, $dest_dir);
     }
     $tmp = "include(\"config.js\");\n";
     $tmp .= "//var sounds_dir\n";
     $tmp .= "var admin_pin = \"\";\n";
     $tmp .= "var search_type = \"\";\n";
     $tmp .= "//var tmp_dir\n";
     $tmp .= "var digitmaxlength = 0;\n";
     $tmp .= "var timeoutpin = 5000;\n";
     $tmp .= "var timeouttransfer = 5000;\n";
     $tmp .= "\n";
     $tmp .= "var dtmf = new Object( );\n";
     $tmp .= "dtmf.digits = \"\";\n";
     $tmp .= "\n";
     $tmp .= "function mycb( session, type, obj, arg ) {\n";
     $tmp .= "\ttry {\n";
     $tmp .= "\t\tif ( type == \"dtmf\" ) {\n";
     $tmp .= "\t\t\tconsole_log( \"info\", \"digit: \"+obj.digit+\"\\n\" );\n";
     $tmp .= "\t\t\tif ( obj.digit == \"#\" ) {\n";
     $tmp .= "\t\t\t\t//console_log( \"info\", \"detected pound sign.\\n\" );\n";
     $tmp .= "\t\t\t\texit = true;\n";
     $tmp .= "\t\t\t\treturn( false );\n";
     $tmp .= "\t\t\t}\n";
     $tmp .= "\t\t\tif ( obj.digit == \"*\" ) {\n";
     $tmp .= "\t\t\t\t//console_log( \"info\", \"detected pound sign.\\n\" );\n";
     $tmp .= "\t\t\t\texit = true;\n";
     $tmp .= "\t\t\t\treturn( false );\n";
     $tmp .= "\t\t\t}\n";
     $tmp .= "\t\t\tdtmf.digits += obj.digit;\n";
     $tmp .= "\t\t\tif ( dtmf.digits.length >= digitmaxlength ) {\n";
     $tmp .= "\t\t\t\texit = true;\n";
     $tmp .= "\t\t\t\treturn( false );\n";
     $tmp .= "\t\t\t}\n";
     $tmp .= "\t\t}\n";
     $tmp .= "\t} catch (e) {\n";
     $tmp .= "\t\tconsole_log( \"err\", e+\"\\n\" );\n";
     $tmp .= "\t}\n";
     $tmp .= "\treturn( true );\n";
     $tmp .= "} //end function mycb\n";
     $tmp .= "\n";
     $tmp .= "function directory_search(search_type) {\n";
     $tmp .= "\n";
     $tmp .= "\tdigitmaxlength = 3;\n";
     $tmp .= "\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-enter-person.wav\");\n";
     $tmp .= "\tif (search_type == \"last_name\") {\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t}\n";
     $tmp .= "\tif (search_type == \"first_name\") {\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t}\n";
     $tmp .= "\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-press.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\tsession.execute(\"say\", \"en name_spelled iterated 1\");\n";
     $tmp .= "\tsession.collectInput( mycb, dtmf, timeoutpin );\n";
     $tmp .= "\tvar dtmf_search = dtmf.digits;\n";
     $tmp .= "\t//console_log( \"info\", \"--\" + dtmf.digits + \"--\\n\" );\n";
     $tmp .= "\tif (dtmf_search == \"1\") {\n";
     $tmp .= "\t\t//console_log( \"info\", \"press 1 detected: \" + dtmf.digits + \"\\n\" );\n";
     $tmp .= "\t\t//console_log( \"info\", \"press 1 detected: \" + search_type + \"\\n\" );\n";
     $tmp .= "\t\tif (search_type == \"last_name\") {\n";
     $tmp .= "\t\t\t//console_log( \"info\", \"press 1 detected last_name: \" + search_type + \"\\n\" );\n";
     $tmp .= "\t\t\tsearch_type = \"first_name\";\n";
     $tmp .= "\t\t}\n";
     $tmp .= "\t\telse {\n";
     $tmp .= "\t\t\t//console_log( \"info\", \"press 1 detected first_name: \" + search_type + \"\\n\" );\n";
     $tmp .= "\t\t\tsearch_type = \"last_name\";\n";
     $tmp .= "\t\t}\n";
     $tmp .= "\t\tdtmf_search = \"\";\n";
     $tmp .= "\t\tdtmf.digits = \"\";\n";
     $tmp .= "\t\tdirectory_search(search_type);\n";
     $tmp .= "\t\treturn;\n";
     $tmp .= "\t}\n";
     $tmp .= "\tconsole_log( \"info\", \"first 3 letters of first or last name: \" + dtmf.digits + \"\\n\" );\n";
     $tmp .= "\n";
     $tmp .= "\t//session.execute(\"say\", \"en name_spelled pronounced mark\");\n";
     $tmp .= "\t//<action application=\"say\" data=\"en name_spelled iterated \${destination_number}\"/>\n";
     $tmp .= "\t//session.execute(\"say\", \"en number iterated 12345\");\n";
     $tmp .= "\t//session.execute(\"say\", \"en number pronounced 1001\");\n";
     $tmp .= "\t//session.execute(\"say\", \"en short_date_time pronounced [timestamp]\");\n";
     $tmp .= "\t//session.execute(\"say\", \"en CURRENT_TIME pronounced CURRENT_TIME\");\n";
     $tmp .= "\t//session.execute(\"say\", \"en CURRENT_DATE pronounced CURRENT_DATE\");\n";
     $tmp .= "\t//session.execute(\"say\", \"en CURRENT_DATE_TIME pronounced CURRENT_DATE_TIME\");\n";
     $tmp .= "\n";
     $tmp .= "\n";
     $tmp .= "\t//take each name and convert it to the equivalent number in php when this file is generated\n";
     $tmp .= "\t//then test each number see if it matches the user dtmf search keys\n";
     $tmp .= "\n";
     $tmp .= "\tvar result_array = new Array();\n";
     $tmp .= "\tvar x = 0;\n";
     //get a list of extensions and the users assigned to them
     $sql = "";
     $sql .= " select * from v_extensions ";
     $sql .= "where v_id = '{$v_id}' ";
     $prepstatement = $db->prepare(check_sql($sql));
     $prepstatement->execute();
     $x = 0;
     $result = $prepstatement->fetchAll();
     foreach ($result as &$row) {
         //print_r($row);
         $extension = $row["extension"];
         $effective_caller_id_name = $row["effective_caller_id_name"];
         $user_list = $row["user_list"];
         $user_list = trim($user_list, "|");
         //echo $user_list."<br />\n";
         $username_array = explode("|", $user_list);
         //print_r($username_array);
         foreach ($username_array as &$username) {
             if (strlen($username) > 0) {
                 $sql = "";
                 $sql .= "select * from v_users ";
                 $sql .= "where v_id = '{$v_id}' ";
                 $sql .= "and username = '******' ";
                 $prepstatement = $db->prepare(check_sql($sql));
                 $prepstatement->execute();
                 $tmp_result = $prepstatement->fetchAll();
                 foreach ($tmp_result as &$row_tmp) {
                     $userfirstname = $row_tmp["userfirstname"];
                     $userlastname = $row_tmp["userlastname"];
                     if ($userfirstname == "na") {
                         $userfirstname = "";
                     }
                     if ($userlastname == "na") {
                         $userlastname = "";
                     }
                     if ($userfirstname == "admin") {
                         $userfirstname = "";
                     }
                     if ($userlastname == "admin") {
                         $userlastname = "";
                     }
                     if ($userfirstname == "superadmin") {
                         $userfirstname = "";
                     }
                     if ($userlastname == "superadmin") {
                         $userlastname = "";
                     }
                     if (strlen($userfirstname . $userlastname) == 0) {
                         $name_array = explode(" ", $effective_caller_id_name);
                         $userfirstname = $name_array[0];
                         if (count($name_array) > 1) {
                             $userlastname = $name_array[1];
                         }
                     }
                     break;
                     //limit to 1 row
                 }
                 $f1 = phone_letter_to_number(substr($userfirstname, 0, 1));
                 $f2 = phone_letter_to_number(substr($userfirstname, 1, 1));
                 $f3 = phone_letter_to_number(substr($userfirstname, 2, 1));
                 $l1 = phone_letter_to_number(substr($userlastname, 0, 1));
                 $l2 = phone_letter_to_number(substr($userlastname, 1, 1));
                 $l3 = phone_letter_to_number(substr($userlastname, 2, 1));
                 //echo $sql." extension: $extension  firstname $userfirstname lastname $userlastname $tmp<br />";
                 $tmp .= "\tif (search_type == \"first_name\" && dtmf_search == \"" . $f1 . $f2 . $f3 . "\" || search_type == \"last_name\" && dtmf_search == \"" . $l1 . $l2 . $l3 . "\") {\n";
                 $tmp .= "\t\tresult_array[x]=new Array()\n";
                 $tmp .= "\t\tresult_array[x]['first_name'] =\"" . $userfirstname . "\";\n";
                 $tmp .= "\t\tresult_array[x]['last_name'] =\"" . $userlastname . "\";\n";
                 $tmp .= "\t\tresult_array[x]['extension'] = \"" . $extension . "\";\n";
                 $tmp .= "\t\t//console_log( \"info\", \"found: " . $userfirstname . " " . $userlastname . "\\n\" );\n";
                 $tmp .= "\t\tx++;\n";
                 $tmp .= "\t}\n";
             }
         }
     }
     unset($prepstatement);
     $tmp .= "\n";
     $tmp .= "\n";
     $tmp .= "\t//say the number of results that matched\n";
     $tmp .= "\t\$result_count = result_array.length;\n";
     $tmp .= "\tsession.execute(\"say\", \"en number iterated \"+\$result_count);\n";
     $tmp .= "\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-result_match.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\n";
     $tmp .= "\t//clear values\n";
     $tmp .= "\tdtmf_search = 0;\n";
     $tmp .= "\tdtmf.digits = '';\n";
     $tmp .= "\n";
     $tmp .= "\tif (\$result_count == 0) {\n";
     $tmp .= "\t\t//session.execute(\"transfer\", \"*347 XML default\");\n";
     $tmp .= "\t\tdirectory_search(search_type);\n";
     $tmp .= "\t\treturn;\n";
     $tmp .= "\t}\n";
     $tmp .= "\n";
     $tmp .= "\tsession.execute(\"set\", \"tts_engine=flite\");\n";
     $tmp .= "\tsession.execute(\"set\", \"tts_voice=rms\");  //rms //kal //awb //slt\n";
     $tmp .= "\tsession.execute(\"set\", \"playback_terminators=#\");\n";
     $tmp .= "\t//session.speak(\"flite\",\"kal\",\"Thanks for.. calling\");\n";
     $tmp .= "\n";
     $tmp .= "\ti=1;\n";
     $tmp .= "\tfor ( i in result_array ) {\n";
     $tmp .= "\n";
     $tmp .= "\t\t//say first name and last name is at extension 1001\n";
     $tmp .= "\t\t//session.execute(\"speak\", result_array[i]['first_name']);\n";
     $tmp .= "\t\t//session.execute(\"speak\", result_array[i]['last_name']);\n";
     $tmp .= "\t\tsession.execute(\"say\", \"en name_spelled pronounced \"+result_array[i]['first_name']);\n";
     $tmp .= "\t\tsession.execute(\"sleep\", \"500\");\n";
     $tmp .= "\t\tsession.execute(\"say\", \"en name_spelled pronounced \"+result_array[i]['last_name']);\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-at_extension.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t\tsession.execute(\"say\", \"en number pronounced \"+result_array[i]['extension']);\n";
     $tmp .= "\n";
     $tmp .= "\t\t//to select this entry press 1\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_select_entry.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t\tsession.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-press.wav\", mycb, \"dtmf\");\n";
     $tmp .= "\t\tsession.execute(\"say\", \"en number iterated 1\");\n";
     $tmp .= "\n";
     $tmp .= "\t\t//console_log( \"info\", \"first name: \" + result_array[i]['first_name'] + \"\\n\" );\n";
     $tmp .= "\t\t//console_log( \"info\", \"last name: \" + result_array[i]['last_name'] + \"\\n\" );\n";
     $tmp .= "\t\t//console_log( \"info\", \"extension: \" + result_array[i]['extension'] + \"\\n\" );\n";
     $tmp .= "\n";
     $tmp .= "\t\t//if 1 is pressed then transfer the call\n";
     $tmp .= "\t\tdtmf.digits = session.getDigits(1, \"#\", 3000);\n";
     $tmp .= "\t\tif (dtmf.digits == \"1\") {\n";
     $tmp .= "\t\t\tconsole_log( \"info\", \"directory: call transfered to: \" + result_array[i]['extension'] + \"\\n\" );\n";
     $tmp .= "\t\t\tsession.execute(\"transfer\", result_array[i]['extension']+\" XML default\");\n";
     $tmp .= "\t\t}\n";
     $tmp .= "\n";
     $tmp .= "\t}\n";
     $tmp .= "}\n";
     $tmp .= "\n";
     $tmp .= "\n";
     $tmp .= "if ( session.ready() ) {\n";
     $tmp .= "\tsession.answer();\n";
     $tmp .= "\tsearch_type = \"last_name\";\n";
     $tmp .= "\tdirectory_search(search_type);\n";
     $tmp .= "\tsession.hangup(\"NORMAL_CLEARING\");\n";
     $tmp .= "}\n";
     $tmp .= "";
     //write the file
     $fout = fopen($v_scripts_dir . "/directory.js", "w");
     fwrite($fout, $tmp);
     fclose($fout);
 }
コード例 #13
0
ファイル: installmodx.php プロジェクト: Vitaliz/modx_utils
/**
 * From http://www.php.net/manual/en/function.copy.php#91256
 * Copy file or folder from source to destination
 * @param string $source file or folder
 * @param string $dest   file or folder
 * @param array $options (optional) folderPermission,filePermission
 * @return boolean
 */
function recursive_copy($source, $dest, $options = array('folderPermission' => 0755, 'filePermission' => 0755))
{
    $result = false;
    if (is_file($source)) {
        if ($dest[strlen($dest) - 1] == '/') {
            if (!file_exists($dest)) {
                cmfcDirectory::makeAll($dest, $options['folderPermission'], true);
            }
            $__dest = $dest . '/' . basename($source);
        } else {
            $__dest = $dest;
        }
        $result = copy($source, $__dest);
        chmod($__dest, $options['filePermission']);
    } elseif (is_dir($source)) {
        if ($dest[strlen($dest) - 1] == '/') {
            if ($source[strlen($source) - 1] == '/') {
                //Copy only contents
            } else {
                //Change parent itself and its contents
                $dest = $dest . basename($source);
                @mkdir($dest);
                chmod($dest, $options['filePermission']);
            }
        } else {
            if ($source[strlen($source) - 1] == '/') {
                //Copy parent directory with new name and all its content
                @mkdir($dest, $options['folderPermission']);
                chmod($dest, $options['filePermission']);
            } else {
                //Copy parent directory with new name and all its content
                @mkdir($dest, $options['folderPermission']);
                chmod($dest, $options['filePermission']);
            }
        }
        $dirHandle = opendir($source);
        while ($file = readdir($dirHandle)) {
            if ($file != '.' && $file != '..') {
                if (!is_dir($source . "/" . $file)) {
                    $__dest = $dest . '/' . $file;
                } else {
                    $__dest = $dest . '/' . $file;
                }
                //echo "$source/$file ||| $__dest<br />";
                $result = recursive_copy($source . "/" . $file, $__dest, $options);
            }
        }
        closedir($dirHandle);
    } else {
        $result = false;
    }
    return $result;
}
コード例 #14
0
# Unpdates shebang for Unix
###############################################################################
*/
#error_reporting(0);  // Disable PHP errors and warnings
// Comment to Enable for testing
chdir(dirname(__FILE__));
// Change wd to this files location
include_once "../../main/includes/config.inc.php";
include_once "../../main/includes/functions.php";
run_location_tracker();
// Have servers moved update configuration accordingly
//=== Update shebang in all files in folder cgi-bin and sub-folders ===========
print "\n ============= End of line and shebang update =============\n\n";
if (perl_installed()) {
    //Copy all fies to new folder and update end of lines
    recursive_copy($base_f . '/cgi-bin', $base_f . '/cgi-bin-unix');
    // Copy folder tree before conversion
    $start_dir = $base_f . '/cgi-bin-unix';
    // starting folder
    $file_type = '/(\\.pl|\\.cgi)/';
    // list file types to convert
    $search_str = '/\\r/';
    // string to search for
    $replace_str = "";
    // replace string
    recursive_search_replace($start_dir, $file_type, $search_str, $replace_str);
    // replace
    //Update shebang to Unix
    $start_dir = $base_f . "/cgi-bin-unix";
    // Unix Perl folder
    $file_type = '/(\\.pl|\\.cgi)/';
コード例 #15
0
/** Recursively copy a directory
 */
function recursive_copy($dirsourceparent, $dirdest, &$md5sums, $dirsource = "")
{
    global $dryrun;
    global $check_md5s;
    global $amp_conf;
    global $asterisk_conf;
    global $install_moh;
    global $make_links;
    $overwrite = false;
    $moh_subdir = isset($amp_conf['MOHDIR']) ? trim(trim($amp_conf['MOHDIR']), '/') : 'mohmp3';
    // total # files, # actually copied
    $num_files = $num_copied = 0;
    if ($dirsource && $dirsource[0] != "/") {
        $dirsource = "/" . $dirsource;
    }
    if (is_dir($dirsourceparent . $dirsource)) {
        $dir_handle = opendir($dirsourceparent . $dirsource);
    }
    /*
    echo "dirsourceparent: "; var_dump($dirsourceparent);
    echo "dirsource: "; var_dump($dirsource);
    echo "dirdest: "; var_dump($dirdest);
    */
    while (isset($dir_handle) && ($file = readdir($dir_handle))) {
        if ($file != "." && $file != ".." && $file != "CVS" && $file != ".svn" && $file != ".git") {
            $source = $dirsourceparent . $dirsource . "/" . $file;
            $destination = $dirdest . $dirsource . "/" . $file;
            if ($dirsource == "" && $file == "moh" && !$install_moh) {
                // skip to the next dir
                continue;
            }
            // configurable in amportal.conf
            $destination = preg_replace("/^\\/htdocs\\//i", trim($amp_conf["AMPWEBROOT"]) . "/", $destination);
            if (strpos($dirsource, 'modules') === false) {
                $destination = str_replace("/bin", trim($amp_conf["AMPBIN"]), $destination);
            }
            $destination = str_replace("/sbin", trim($amp_conf["AMPSBIN"]), $destination);
            // the following are configurable in asterisk.conf
            $destination = str_replace("/astetc", trim($asterisk_conf["astetcdir"]), $destination);
            $destination = str_replace("/moh", trim($asterisk_conf["astvarlibdir"]) . "/{$moh_subdir}", $destination);
            $destination = str_replace("/astvarlib", trim($asterisk_conf["astvarlibdir"]), $destination);
            if (strpos($dirsource, 'modules') === false) {
                $destination = str_replace("/agi-bin", trim($asterisk_conf["astagidir"]), $destination);
            }
            if (strpos($dirsource, 'modules') === false) {
                $destination = str_replace("/sounds", trim($asterisk_conf["astvarlibdir"]) . "/sounds", $destination);
            }
            // if this is a directory, ensure destination exists
            if (is_dir($source)) {
                if (!file_exists($destination)) {
                    if (!$dryrun && $destination != "") {
                        amp_mkdir($destination, "0750", true);
                    }
                }
            }
            //var_dump($md5sums);
            if (!is_dir($source)) {
                $md5_source = preg_replace("|^/?amp_conf/|", "/", $source);
                if ($check_md5s && file_exists($destination) && isset($md5sums[$md5_source]) && md5_file($destination) != $md5sums[$md5_source]) {
                    // double check using diff utility (and ignoring whitespace)
                    // This is a somewhat edge case (eg, the file doesn't match
                    // it's md5 sum from the previous version, but no substantial
                    // changes exist compared to the current version), but it
                    // prevents a useless prompt to the user.
                    if (checkDiff($source, $destination)) {
                        $overwrite = ask_overwrite($source, $destination);
                    } else {
                        debug("NOTE: MD5 for " . $destination . " was different, but `diff` did not detect any (non-whitespace) changes: overwriting");
                        $overwrite = true;
                    }
                } else {
                    $overwrite = true;
                }
                // These are modified by apply_conf.sh, there may be others that fit in this category also. This keeps these from
                // being symlinked and then developers inadvertently checking in the changes when they should not have.
                //
                $never_symlink = array("cdr_mysql.conf", "manager.conf", "vm_email.inc", "modules.conf");
                $num_files++;
                if ($overwrite) {
                    debug(($make_links ? "link" : "copy") . " " . $source . " -> " . $destination);
                    if (!$dryrun) {
                        if ($make_links && !in_array(basename($source), $never_symlink)) {
                            // symlink, unlike copy, doesn't overwrite - have to delete first
                            if (is_link($destination) || file_exists($destination)) {
                                unlink($destination);
                            }
                            $links = recursive_readlink($source);
                            if (!empty($links)) {
                                @symlink(substitute_readlinks($source, $links), $destination);
                            } else {
                                if (file_exists(dirname(__FILE__) . "/" . $source)) {
                                    @symlink(dirname(__FILE__) . "/" . $source, $destination);
                                }
                            }
                        } else {
                            $ow = false;
                            if (file_exists($destination)) {
                                if (checkDiff($source, $destination) && !$make_links) {
                                    $ow = ask_overwrite($source, $destination);
                                } elseif ($make_links) {
                                    $ow = false;
                                }
                            } else {
                                $ow = true;
                            }
                            //ask_overwrite
                            if ($ow) {
                                //Copy will not overwrite a symlink, phpnesssss
                                if (file_exists($destination) && is_link($destination)) {
                                    unlink($destination);
                                }
                                copy($source, $destination);
                            } else {
                                continue;
                            }
                        }
                        $num_copied++;
                    }
                } else {
                    debug("not overwriting " . $destination);
                }
            } else {
                list($tmp_num_files, $tmp_num_copied) = recursive_copy($dirsourceparent, $dirdest, $md5sums, $dirsource . "/" . $file);
                $num_files += $tmp_num_files;
                $num_copied += $tmp_num_copied;
            }
        }
    }
    if (isset($dir_handle)) {
        closedir($dir_handle);
    }
    return array($num_files, $num_copied);
}
コード例 #16
0
ファイル: export.php プロジェクト: phill104/branches
function recursive_copy($src, $dest)
{
    // Base case, is file so just copy
    if (is_file($src)) {
        $c = copy($src, $dest);
        return $c;
    }
    if (!is_dir($dest)) {
        recursive_mkdir($dest);
    }
    $dir = dir($src);
    while (false !== ($entry = $dir->read())) {
        if ($entry == '.' || $entry == '..' || preg_match('/^\\./', $entry)) {
            // Skips the index '.' and '..' along with hidden files
            continue;
        }
        if ($dest !== "{$src}/{$entry}") {
            recursive_copy("{$src}/{$entry}", "{$dest}/{$entry}");
        }
    }
}
コード例 #17
0
ファイル: coreFull.php プロジェクト: Prescia/Prescia
 function loadMetadata()
 {
     if (!$this->debugmode) {
         return parent::loadMetadata();
     }
     $this->errorControl->raise(1000);
     $this->log = array();
     // we don't want the above "log" to cause an abort (yes, this function uses the log size to confirm an error - lame but extremelly effective)
     $this->allModulesLoaded = true;
     # initial clean up and check
     if (!is_dir(CONS_PATH_TEMP)) {
         safe_mkdir(CONS_PATH_TEMP);
     }
     if (!is_dir(CONS_PATH_CACHE)) {
         safe_mkdir(CONS_PATH_CACHE);
     }
     if (!is_dir(CONS_PATH_DINCONFIG)) {
         safe_mkdir(CONS_PATH_DINCONFIG);
     }
     if (!is_dir(CONS_PATH_CACHE . "locale/")) {
         safe_mkdir(CONS_PATH_CACHE . "locale/");
     }
     if (!is_dir(CONS_PATH_LOGS)) {
         safe_mkdir(CONS_PATH_LOGS);
     }
     if (!is_dir(CONS_PATH_LOGS . $_SESSION['CODE'] . "/")) {
         safe_mkdir(CONS_PATH_LOGS . $_SESSION['CODE'] . "/");
     }
     if (!is_dir(CONS_PATH_DINCONFIG . $_SESSION['CODE'] . "/")) {
         safe_mkdir(CONS_PATH_DINCONFIG . $_SESSION['CODE'] . "/");
     }
     if (!is_dir(CONS_PATH_CACHE . $_SESSION['CODE'] . "/")) {
         safe_mkdir(CONS_PATH_CACHE . $_SESSION['CODE'] . "/");
     }
     if (!is_dir(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/")) {
         safe_mkdir(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/");
     }
     if (!is_dir(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/locale")) {
         safe_mkdir(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/locale/");
     }
     if (!is_dir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/")) {
         safe_mkdir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/");
     }
     if (!is_dir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/actions/")) {
         safe_mkdir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/actions");
     }
     if (!is_dir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/content/")) {
         safe_mkdir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/content");
     }
     if (!is_dir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/_config/locale/")) {
         safe_mkdir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/_config/locale");
     }
     if (!is_dir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/files/")) {
         safe_mkdir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/files");
     }
     if (!is_dir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/")) {
         safe_mkdir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template");
         copy(CONS_PATH_SETTINGS . "defaults/basefile.html", CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/basefile.html");
         copy(CONS_PATH_SETTINGS . "defaults/index.html", CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/index.html");
     }
     if (!is_dir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail/")) {
         safe_mkdir(CONS_PATH_PAGES . $_SESSION['CODE'] . "/mail");
     }
     # Dimconfig
     if (is_file(CONS_PATH_DINCONFIG . $_SESSION['CODE'] . "/din.dat")) {
         $this->dimconfig = unserialize(cReadFile(CONS_PATH_DINCONFIG . $_SESSION['CODE'] . "/din.dat"));
     }
     if ($this->dimconfig === false) {
         $this->dimconfig = array();
     }
     # Error on load
     $this->checkConfig();
     # clear the meta cache
     if (!$this->offlineMode) {
         $files = listFiles(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/");
         foreach ($files as $file) {
             if (is_file(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/" . $file)) {
                 @unlink(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/" . $file);
             }
         }
         if (!$this->checkinstall()) {
             $this->errorControl->raise(118, array_unshift($this->log));
         }
         if (isset($_REQUEST['nocache'])) {
             recursive_del(CONS_PATH_CACHE . $_SESSION['CODE'] . "/pages/", true);
             recursive_del(CONS_PATH_CACHE . $_SESSION['CODE'] . "/", false, 'cache');
         }
     }
     # If no database, we are done
     if ($this->dbless) {
         return count($this->log) == 0;
     }
     # Search all necessary model files
     $parseXMLparams = array(C_XML_RAW => true, C_XML_AUTOPARSE => true, C_XML_REMOVECOMMENTS => true);
     $xml = new xmlHandler();
     $model = is_file(CONS_PATH_SETTINGS . "default.xml") ? cReadFile(CONS_PATH_SETTINGS . "default.xml") . "\n" : '';
     foreach ($this->loadedPlugins as $scriptName => $scriptObj) {
         if (is_file(CONS_PATH_SYSTEM . "plugins/" . $scriptName . "/meta.xml")) {
             $model .= cReadFile(CONS_PATH_SYSTEM . "plugins/" . $scriptName . "/meta.xml") . "\n";
         }
     }
     unset($scriptName);
     unset($scriptObj);
     if (is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/_config/meta.xml")) {
         $model .= cReadFile(CONS_PATH_PAGES . $_SESSION['CODE'] . "/_config/meta.xml") . "\n";
     }
     $model = $xml->parseXML($model, $parseXMLparams, true);
     unset($xml);
     if ($model === false) {
         $this->errorControl->raise(119);
     }
     # browses the XML and loads modules
     $model =& $model->getbranch(0);
     $total = $model->total();
     $relation = array();
     # foreign keys are only created later
     $lastLoad = "";
     for ($c = 0; $c < $total; $c++) {
         # for each module ...
         $thisbranch =& $model->getbranch($c);
         $total_campos = $thisbranch->total();
         # creates the module as from XML settings
         $module = strtolower($thisbranch->data[0]);
         $param =& $thisbranch->data[1];
         $dbname = strtolower(isset($param['dbname']) ? $param['dbname'] : '');
         foreach ($this->modules as $name => $otherModule) {
             if ($otherModule->dbname == $dbname && $dbname != "" && $module != $otherModule->name) {
                 $this->errorControl->raise(120, $otherModule->name, $name, $dbname);
             }
         }
         if ($module == '') {
             $this->errorControl->raise(107, $dbname, "XML error", "Module after {$lastLoad} is corrupt");
         }
         $this->loadModule($module, $dbname);
         #MODULE CREATE
         $lastLoad = $module;
         # loads standard data from this object ---------------------------------------------------------------------
         # read parameters for the MODULE
         foreach ($this->moduleOptions as $mo) {
             $this->modules[$module]->options[$mo[0]] = $mo[3] != '' ? array() : '';
         }
         if (is_array($param)) {
             foreach ($param as $pkey => $pcontent) {
                 $pkey = strtolower($pkey);
                 switch ($pkey) {
                     case "key":
                     case "keys":
                         # will use default auto_increment "id" if none specified. If you specify more than one, none will be auto_increment and the system will use auto-numbering
                         $this->modules[$module]->keys = explode(",", $pcontent);
                         break;
                     case "title":
                         $this->modules[$module]->title = strtolower($pcontent);
                         break;
                     case "volatile":
                         # this module can be deleted as a stand-alone volatile item
                         $this->modules[$module]->options[CONS_MODULE_VOLATILE] = strtolower($pcontent) == "true";
                         break;
                     case "parent":
                         $this->modules[$module]->options[CONS_MODULE_PARENT] = strtolower($pcontent);
                         // field which denotes parenthood
                         break;
                     case "plugins":
                     case "plugin":
                         $this->modules[$module]->plugins = explode(",", strtolower($pcontent));
                         break;
                     case "order":
                         $this->modules[$module]->order = trim(strtolower($pcontent));
                         break;
                     case "permissionoverride":
                         if (strlen($pcontent) >= 9) {
                             $this->modules[$module]->permissionOverride = substr(strtolower($pcontent), 0, 9);
                         }
                         break;
                     case "linker":
                         $this->modules[$module]->linker = true;
                         break;
                     case "systemmodule":
                         $this->modules[$module]->options[CONS_MODULE_SYSTEM] = true;
                         break;
                     case "autoclean":
                         $this->modules[$module]->options[CONS_MODULE_AUTOCLEAN] = $pcontent;
                         break;
                     case "meta":
                         $this->modules[$module]->options[CONS_MODULE_META] = $pcontent;
                         break;
                     case "disallowmultiple":
                         if (strtolower($pcontent) == "true") {
                             $this->modules[$module]->options[CONS_MODULE_DISALLOWMULTIPLE] = true;
                         } else {
                             unset($this->modules[$module]->options[CONS_MODULE_DISALLOWMULTIPLE]);
                         }
                         break;
                     case "noundo":
                         if (strtolower($pcontent) == "true") {
                             $this->modules[$module]->options[CONS_MODULE_NOUNDO] = true;
                         } else {
                             unset($this->modules[$module]->options[CONS_MODULE_NOUNDO]);
                         }
                     default:
                         if ($pkey != "name" && $pkey != "dbname") {
                             $isMO = false;
                             foreach ($this->moduleOptions as $mo) {
                                 if ($mo[1] == $pkey) {
                                     $isMO = true;
                                     if ($mo[2]) {
                                         $pcontent = strtolower($pcontent);
                                     }
                                     if ($mo[3] != '') {
                                         $pcontent = explode($mo[3], $pcontent);
                                     }
                                     $this->modules[$module]->options[$mo[0]] = $pcontent;
                                     break;
                                 }
                             }
                             if (!$isMO) {
                                 $this->modules[$module]->options[$pkey] = $pcontent;
                             }
                         }
                         break;
                 }
             }
             #foreach
             unset($pkey);
             unset($pcontent);
         }
         if ($this->modules[$module]->options[CONS_MODULE_PARENT] != '' && strpos($this->modules[$module]->order, $this->modules[$module]->options[CONS_MODULE_PARENT]) === false) {
             # in tree mode, the field that defines parenthood must be in the order clause, the first if possible
             $this->modules[$module]->order = $this->modules[$module]->options[CONS_MODULE_PARENT] . "+" . ($this->modules[$module]->order != '' ? "," . $this->modules[$module]->order : '');
         }
         # -- ok on reading parameters
         $campos = array();
         $mandatory = 0;
         # browse FIELDS ---------------------------------------------------------------------------------
         for ($campo = 0; $campo < $total_campos; $campo++) {
             $thiscampo =& $thisbranch->getbranch($campo);
             ## processParameters #########################################
             $campos = $this->processParameters($thiscampo, $campos, $module);
             ##############################################################
             $nomecampo = strtolower($thiscampo->data[0]);
             if ($campos[$nomecampo][CONS_XML_TIPO] == CONS_TIPO_LINK) {
                 array_push($relation, array($module, $nomecampo, $campos[$nomecampo][CONS_XML_MODULE]));
                 // if this is a non-mandatory link to myself, called "id_parent", and I don't have parent ... well .. obviously this is it
                 if ($campos[$nomecampo][CONS_XML_MODULE] == $module && !isset($campos[$nomecampo][CONS_XML_MANDATORY]) && $nomecampo == "id_parent" && $this->modules[$module]->options[CONS_MODULE_PARENT] == '') {
                     $this->modules[$module]->options[CONS_MODULE_PARENT] = $nomecampo;
                 }
             } else {
                 if ($campos[$nomecampo][CONS_XML_TIPO] == CONS_TIPO_SERIALIZED) {
                     // browse fields looking for links
                     foreach ($campos[$nomecampo][CONS_XML_SERIALIZEDMODEL] as $exname => &$exfield) {
                         if ($exfield[CONS_XML_TIPO] == CONS_TIPO_LINK) {
                             array_push($relation, array($module, $nomecampo . ":" . $exname, $exfield[CONS_XML_MODULE]));
                         }
                     }
                 }
             }
             # checks if this field can be NULL or NOT depending on options and mandatory setting
             if (isset($campos[$nomecampo][CONS_XML_SQL]) && $campos[$nomecampo][CONS_XML_SQL] != "") {
                 # relation will not be set
                 if (isset($campos[$nomecampo][CONS_XML_MANDATORY]) || $campos[$nomecampo][CONS_XML_TIPO] == CONS_TIPO_OPTIONS || isset($campos[$nomecampo][CONS_XML_DEFAULT])) {
                     $campos[$nomecampo][CONS_XML_SQL] .= " NOT NULL";
                     $mandatory++;
                 } else {
                     $campos[$nomecampo][CONS_XML_SQL] .= " NULL";
                 }
                 if (isset($campos[$nomecampo][CONS_XML_DEFAULT])) {
                     $campos[$nomecampo][CONS_XML_SQL] .= " DEFAULT '" . $campos[$nomecampo][CONS_XML_DEFAULT] . "'";
                 }
             }
         }
         # this module has a database (it's possible to have modules without a database)
         if ($this->modules[$module]->dbname != "") {
             # checks standard key "id" if no key specified
             if (in_array("id", $this->modules[$module]->keys) && !isset($this->modules[$module]->fields['id']) && !isset($campos['id'])) {
                 if ($this->modules[$module]->linker) {
                     $this->modules[$module]->keys = array();
                     $keys = 0;
                     foreach ($campos as $fieldname => $fieldobj) {
                         if (isset($fieldobj[CONS_XML_MODULE])) {
                             $keys++;
                             $this->modules[$module]->keys[] = $fieldname;
                             if ($keys == 2) {
                                 break;
                             }
                         }
                     }
                     unset($fieldname);
                     unset($fieldobj);
                 } else {
                     $campos['id'][CONS_XML_SQL] = "INT (11) UNSIGNED NOT NULL" . (count($this->modules[$module]->keys) <= 1 ? " AUTO_INCREMENT" : "");
                     $campos['id'][CONS_XML_TIPO] = CONS_TIPO_INT;
                     if (count($this->modules[$module]->keys) > 1) {
                         $campos['id'][CONS_XML_RESTRICT] = 99;
                     }
                 }
             }
             # -- keys (this is done to prevent repeated keys)
             $chave = $this->modules[$module]->keys;
             $this->modules[$module]->keys = array();
             foreach ($chave as $x => $di) {
                 if (!in_array($di, $this->modules[$module]->keys) && $di != "") {
                     array_push($this->modules[$module]->keys, $di);
                 }
             }
             unset($x);
             unset($di);
             # if this is a re-definition, will TOTALLY overright the fields (you can redefine fields from the default.xml on the meta.xml)
             $this->modules[$module]->fields = array_merge($this->modules[$module]->fields, $campos);
             # -- makes sure all keys are mandatory and present
             foreach ($this->modules[$module]->keys as $x => $chave) {
                 if (!isset($this->modules[$module]->fields[$chave])) {
                     array_push($this->log, "Key not defined, considering INT 11, please fix the XML: {$module}.{$chave}");
                     $this->modules[$module]->fields[$chave] = array("CONS_XML_SQL" => "INT (11) UNSIGNED NOT NULL", "CONS_XML_TIPO" => CONS_TIPO_INT);
                 }
                 $this->modules[$module]->fields[$chave][CONS_XML_MANDATORY] = true;
                 // vc keys without case specified, force ucase
                 if ($this->modules[$module]->fields[$chave][CONS_XML_TIPO] == CONS_TIPO_VC && !isset($this->modules[$module]->fields[$chave][CONS_XML_SPECIAL])) {
                     $this->modules[$module]->fields[$chave][CONS_XML_SPECIAL] = "ucase";
                 }
             }
             unset($x);
             unset($chave);
         }
     }
     # -- foreach module
     $total_relacoes = count($relation);
     # check our relationship counts and build proper fields or support tables -------------
     for ($c = 0; $c < $total_relacoes; $c++) {
         $rel = $relation[$c];
         # relation: MODULE => FIELD => MODULE or MODULE => SFIELD:FIELD => MODULE for serialized fields
         if (!isset($this->modules[$rel[0]]) || !isset($this->modules[$rel[2]])) {
             array_push($this->log, "Error (pass 1) trying to build foreign keys from '" . $rel[0] . "' to '" . $rel[2] . "' at " . $rel[1] . ": one of the modules do not exist, ignoring relation");
         } else {
             $sfield = "";
             if (strpos($rel[1], ":") !== false) {
                 #serialized field
                 $field = explode(":", $field);
                 $sfield = $field[0];
                 $field = $field[1];
             } else {
                 $field = $rel[1];
             }
             if (substr($field, 0, 3) != "id_") {
                 array_push($this->log, "All relations to another modules MUST start with id_ on " . $rel[0] . "' to '" . $rel[2] . "' at " . $rel[1] . ": should be id_" . $field . " ?");
             }
             if ($sfield == '') {
                 $this->modules[$rel[2]]->volatile = false;
             }
             # keeps volatile if linked from serialized (a.k.a. serialized links are not safe, because they are meant to be dinamic)
             foreach ($this->modules[$rel[2]]->keys as $x => $chave) {
                 # will create required keys for foreign table, except any one in common with this table
                 if ($chave == "id" || !isset($this->modules[$rel[0]]->fields[$chave])) {
                     # only standard id exists (always link it), or it's not a standard key ... still have to test if it's not a key to this table
                     # basically, this will create the second+ keys on multikey relations
                     if (!($this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] == CONS_TIPO_LINK && $this->modules[$rel[2]]->fields[$chave][CONS_XML_MODULE] == $rel[0])) {
                         # ok not a key to this table (the FOREING key is not this table, pay attention! this will still be true for id_parent)
                         if ($sfield == "") {
                             # normal
                             if ($chave == "id") {
                                 # uses the name that came in the XML model
                                 if (!isset($this->modules[$rel[0]]->fields[$field])) {
                                     $this->modules[$rel[0]]->fields[$field] = array();
                                 }
                                 $this->modules[$rel[0]]->fields[$field][CONS_XML_SQL] = str_replace("AUTO_INCREMENT", "", $this->modules[$rel[2]]->fields[$chave][CONS_XML_SQL]);
                                 $this->modules[$rel[0]]->fields[$field][CONS_XML_TIPO] = CONS_TIPO_LINK;
                                 $this->modules[$rel[0]]->fields[$field][CONS_XML_LINKTYPE] = $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] != CONS_TIPO_LINK ? $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] : CONS_TIPO_INT;
                                 $this->modules[$rel[0]]->fields[$field][CONS_XML_MODULE] = $rel[2];
                                 # the creation system might have added this already, that's why testing before resetting the array
                                 if (isset($this->modules[$rel[0]]->fields[$field][CONS_XML_JOIN]) && $this->modules[$rel[0]]->fields[$field][CONS_XML_JOIN] == "inner" || isset($this->modules[$rel[0]]->fields[$field][CONS_XML_MANDATORY])) {
                                     // is set join to INNER or is explicitly mandatory, make sure both are set
                                     $this->modules[$rel[0]]->fields[$field][CONS_XML_MANDATORY] = true;
                                     if ($x == 0) {
                                         $this->modules[$rel[0]]->fields[$field][CONS_XML_JOIN] = "inner";
                                     }
                                 } else {
                                     // no join mode set (defaults to left), set to left, and no explicit mandatory tag
                                     if ($x == 0) {
                                         $this->modules[$rel[0]]->fields[$field][CONS_XML_JOIN] = "left";
                                     }
                                     $this->modules[$rel[0]]->fields[$field][CONS_XML_SQL] = str_replace("NOT NULL", "NULL", $this->modules[$rel[0]]->fields[$field][CONS_XML_SQL]);
                                 }
                             } else {
                                 if ($x == 0) {
                                     $nome = $field;
                                     # first key keeps the original name
                                     $this->modules[$rel[0]]->fields[$field][CONS_XML_LINKTYPE] = $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] != CONS_TIPO_LINK ? $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] : CONS_TIPO_INT;
                                 } else {
                                     $nome = $field . "_" . str_replace("id_", "", $chave);
                                 }
                                 # creates a composition with the model name and the foreign name
                                 $this->modules[$rel[0]]->fields[$nome][CONS_XML_SQL] = str_replace("AUTO_INCREMENT", "", $this->modules[$rel[2]]->fields[$chave][CONS_XML_SQL]);
                                 $this->modules[$rel[0]]->fields[$nome][CONS_XML_TIPO] = $x == 0 ? CONS_TIPO_LINK : $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO];
                                 $this->modules[$rel[0]]->fields[$nome][CONS_XML_MODULE] = isset($this->modules[$rel[2]]->fields[$chave][CONS_XML_MODULE]) ? $this->modules[$rel[2]]->fields[$chave][CONS_XML_MODULE] : $rel[2];
                                 if (isset($this->modules[$rel[0]]->fields[$field][CONS_XML_JOIN]) && $this->modules[$rel[0]]->fields[$field][CONS_XML_JOIN] == "inner" || isset($this->modules[$rel[0]]->fields[$nome][CONS_XML_MANDATORY])) {
                                     $this->modules[$rel[0]]->fields[$nome][CONS_XML_MANDATORY] = true;
                                     if ($x == 0) {
                                         $this->modules[$rel[0]]->fields[$nome][CONS_XML_JOIN] = "inner";
                                     }
                                 } else {
                                     if ($x == 0) {
                                         $this->modules[$rel[0]]->fields[$nome][CONS_XML_JOIN] = "left";
                                     }
                                     unset($this->modules[$rel[0]]->fields[$nome][CONS_XML_MANDATORY]);
                                     $this->modules[$rel[0]]->fields[$nome][CONS_XML_SQL] = str_replace("NOT NULL", "NULL", $this->modules[$rel[0]]->fields[$nome][CONS_XML_SQL]);
                                 }
                             }
                         } else {
                             # serialized
                             if ($chave == "id") {
                                 # uses the name that came in the XML model
                                 if (!isset($this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field])) {
                                     $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field] = array();
                                 }
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_SQL] = str_replace("AUTO_INCREMENT", "", $this->modules[$rel[2]]->fields[$chave][CONS_XML_SQL]);
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_TIPO] = CONS_TIPO_LINK;
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_LINKTYPE] = $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] != CONS_TIPO_LINK ? $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] : CONS_TIPO_INT;
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_MODULE] = $rel[2];
                                 # serialized links cannot be "inner"
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_JOIN] = "left";
                                 if (isset($this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_MANDATORY])) {
                                     $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_MANDATORY] = true;
                                 } else {
                                     $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_SQL] = str_replace("NOT NULL", "NULL", $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_SQL]);
                                 }
                             } else {
                                 if ($x == 0) {
                                     $nome = $field;
                                     # first key keeps the original name
                                     $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$field][CONS_XML_LINKTYPE] = $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] != CONS_TIPO_LINK ? $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO] : CONS_TIPO_INT;
                                 } else {
                                     $nome = $field . "_" . str_replace("id_", "", $chave);
                                 }
                                 # creates a composition with the model name and the foreign name
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_SQL] = str_replace("AUTO_INCREMENT", "", $this->modules[$rel[2]]->fields[$chave][CONS_XML_SQL]);
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_TIPO] = $x == 0 ? CONS_TIPO_LINK : $this->modules[$rel[2]]->fields[$chave][CONS_XML_TIPO];
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_MODULE] = isset($this->modules[$rel[2]]->fields[$chave][CONS_XML_MODULE]) ? $this->modules[$rel[2]]->fields[$chave][CONS_XML_MODULE] : $rel[2];
                                 # serialized links cannot be "inner"
                                 $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_JOIN] = "left";
                                 if (isset($this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_MANDATORY])) {
                                     $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_MANDATORY] = true;
                                 } else {
                                     $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_SQL] = str_replace("NOT NULL", "NULL", $this->modules[$rel[0]]->fields[$sfield][CONS_XML_SERIALIZEDMODEL][$nome][CONS_XML_SQL]);
                                 }
                             }
                         }
                         # sfield?
                     }
                 }
                 # secondary (multikey)?
             }
             # foreach
             unset($x);
             unset($chave);
             if (!isset($this->modules[$rel[0]]->fields[$field][CONS_XML_SQL])) {
                 array_push($this->log, "Error (pass 2) trying to build foreing keys from " . $rel[0] . " to " . $rel[2] . " at " . $field . ": ignoring relation");
             }
         }
     }
     # foreach for relations
     // now some automatic settings since all modules are loaded, and consistency check on build, partOf, etc ---------------------
     $cacheLinkNum = array();
     // module => modules which link to this
     foreach ($this->modules as $mname => &$module) {
         $links = 0;
         $fieldsRequiredToLinks = 0;
         foreach ($module->fields as $name => $field) {
             // check for linker modules
             if ($field[CONS_XML_TIPO] == CONS_TIPO_LINK && $field[CONS_XML_MODULE] != $mname) {
                 // links to OTHER link not myself
                 $links++;
                 # do not count PARENTS as links
                 $fieldsRequiredToLinks += count($this->modules[$field[CONS_XML_MODULE]]->keys);
                 # a module can have more than one key, thus to know if this module is a linker module, we need to check if ALL THIS HAVE are the keys for 2 modules
                 // vc links that have no case specified, force to upper
                 if ($field[CONS_XML_TIPO] == CONS_TIPO_LINK && $field[CONS_XML_LINKTYPE] == CONS_TIPO_VC && !isset($field[CONS_XML_SPECIAL])) {
                     $this->modules[$mname]->fields[$name][CONS_XML_SPECIAL] = "ucase";
                 }
             }
             if (isset($field[CONS_XML_FILTEREDBY])) {
                 foreach ($field[CONS_XML_FILTEREDBY] as $fbname) {
                     if (!isset($module->fields[$fbname])) {
                         $this->log[] = "Error on filteredby for {$mname}.{$name}: {$fbname} does not exist";
                     } else {
                         if (!isset($this->modules[$module->fields[$fbname][CONS_XML_MODULE]])) {
                             $this->log[] = "Error on filteredby for {$mname}.{$name}: module defined in {$fbname} does not exist";
                         }
                     }
                 }
             }
         }
         if ($links == 2 && count($module->fields) == $fieldsRequiredToLinks || $this->modules[$mname]->linker) {
             # this is a linker module!
             $this->modules[$mname]->linker = true;
         }
         if ($this->modules[$mname]->title == "" && !$this->modules[$mname]->options[CONS_MODULE_SYSTEM] && !$this->modules[$mname]->linker) {
             $this->modules[$mname]->title = $this->modules[$mname]->keys[0];
             // first key
         }
     }
     # here we finished the automatic settings
     # load plugins that are defined by METADATA
     foreach ($this->modules as $name => &$module) {
         foreach ($module->plugins as $sname) {
             if (!isset($this->loadedPlugins[$sname])) {
                 $this->addPlugin($sname, $name);
             } else {
                 $this->loadedPlugins[$sname]->moduleRelation = $name;
             }
         }
     }
     foreach ($this->loadedPlugins as $sname => $obj) {
         if ($obj->name == '' || $obj->name != $sname) {
             $this->errorControl->raise(9, $obj->name, $sname);
         }
     }
     # DIE FREAKING THUMBS.DB, DIE!
     function dieFreakingThumbs($folder)
     {
         if ($folder[strlen($folder) - 1] != '/') {
             $folder .= "/";
         }
         foreach (glob($folder . "*") as $file) {
             if (is_dir($file)) {
                 dieFreakingThumbs($file);
             } else {
                 $arf = explode(".", $file);
                 if (array_pop($arf) == 'db') {
                     @unlink($file);
                 }
             }
         }
     }
     dieFreakingThumbs(CONS_PATH_PAGES . $_SESSION['CODE'] . "/");
     $customxml = is_file(CONS_PATH_PAGES . $_SESSION["CODE"] . "/_config/custom.xml") ? cReadFile(CONS_PATH_PAGES . $_SESSION["CODE"] . "/_config/custom.xml") : '';
     # All plugins are loaded, check their manifest and customs
     foreach ($this->loadedPlugins as $sname => $plugin) {
         if (is_file(CONS_PATH_SYSTEM . "plugins/{$sname}/payloadmanifest.php")) {
             $copyFiles = (include CONS_PATH_SYSTEM . "plugins/{$sname}/payloadmanifest.php");
             foreach ($copyFiles as $from => $to) {
                 if ($from[strlen($from) - 1] == "/" && is_dir($from) && (!is_dir($to) || !CONS_ONSERVER && isset($_REQUEST['nocache']))) {
                     // FOLDER
                     if (!function_exists('recursive_copy')) {
                         include_once CONS_PATH_INCLUDE . "recursive_copy.php";
                     }
                     recursive_copy($from, $to);
                 } else {
                     if (is_file($from) && (!is_file($to) || !CONS_ONSERVER && isset($_REQUEST['nocache']))) {
                         // FILE
                         $path = explode("/", $to);
                         array_pop($path);
                         // bye file
                         $path = implode("/", $path);
                         makeDirs($path);
                         copy($from, $to);
                     }
                 }
             }
         }
         if (is_file(CONS_PATH_SYSTEM . "plugins/{$sname}/custom.xml")) {
             $customxml .= cReadFile(CONS_PATH_SYSTEM . "plugins/{$sname}/custom.xml");
         }
     }
     # Read custom metadata for dimconfig
     if ($customxml != '') {
         $parseXMLparams = array(C_XML_RAW => true, C_XML_AUTOPARSE => true, C_XML_REMOVECOMMENTS => true);
         $xml = new xmlHandler();
         $customxml = $xml->parseXML($customxml, $parseXMLparams, true);
         if ($customxml === false) {
             $this->errorControl->raise(180);
         }
         unset($xml);
         $customxml =& $customxml->getbranch(0);
         $total = $customxml->total();
         $dimconfigMD = array();
         // MetaData -------------------------------------
         for ($c = 0; $c < $total; $c++) {
             # for each module ...
             $thisbranch =& $customxml->getbranch($c);
             $configname = strtolower($thisbranch->data[0]);
             if (!isset($this->dimconfig[$configname])) {
                 $this->dimconfig[$configname] = '';
             }
             $dimconfigMD = $this->processParameters($thisbranch, $dimconfigMD, '');
         }
         foreach ($dimconfigMD as $name => $field) {
             if ($field[CONS_XML_TIPO] == CONS_TIPO_UPLOAD && (!isset($field['location']) || $field['location'][0] == '/')) {
                 $this->errorControl->raise(181, $name, 'dimconfig');
             }
             if ($field[CONS_XML_TIPO] != CONS_TIPO_ENUM) {
                 unset($dimconfigMD[$name][CONS_XML_SQL]);
             }
         }
         cWriteFile(CONS_PATH_CACHE . $_SESSION['CODE'] . "/meta/_dimconfig.dat", serialize($dimconfigMD));
         // this defines the type of each item on dimconfig
     }
     # Apply and raise metadata
     $this->applyMetaData();
     # no log = no error
     return $sucess = count($this->log) == 0;
 }
コード例 #18
0
ファイル: functions.php プロジェクト: racontemoi/chi_win
function recursive_copy($src, $dst)
{
    $dir = opendir($src);
    // Get handle to open source
    @mkdir($dst);
    // Create destination folder
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            // Skip special folders
            if (is_dir($src . '/' . $file)) {
                // Is it a folder
                recursive_copy($src . '/' . $file, $dst . '/' . $file);
                // yes: repeat create new folder
            } else {
                // no: Its a file
                copy($src . '/' . $file, $dst . '/' . $file);
                // copy file
            }
        }
    }
    closedir($dir);
}
コード例 #19
0
ファイル: misc.php プロジェクト: 62BRAINS/EPESI
/**
 * Copies directory recursively, along with all files stored under source directory.
 * If destination directory doesn't exist it will be created.
 *
 * @param string source directory
 * @param string destination directory
 */
function recursive_copy($src, $dest)
{
    if (!is_dir($src)) {
        copy($src, $dest);
        return;
    }
    $src = rtrim($src, '/');
    $dest = rtrim($dest, '/');
    if (!is_dir($dest)) {
        mkdir($dest);
    }
    $content = scandir($src);
    foreach ($content as $name) {
        if ($name == '.' || $name == '..') {
            continue;
        }
        $src_name = $src . '/' . $name;
        $dest_name = $dest . '/' . $name;
        if (is_dir($src_name)) {
            if (!is_dir($dest_name)) {
                mkdir($dest_name);
            }
            recursive_copy($src_name, $dest_name);
        } else {
            copy($src_name, $dest_name);
        }
    }
}
コード例 #20
0
ファイル: ThemeCommon_0.php プロジェクト: 62BRAINS/EPESI
 public static function themeup()
 {
     $data_dir = self::Instance()->get_data_dir() . 'templates/default/';
     $content = scandir($data_dir);
     foreach ($content as $name) {
         if ($name == '.' || $name == '..') {
             continue;
         }
         recursive_rmdir($data_dir . $name);
     }
     $ret = DB::Execute('SELECT * FROM modules');
     while ($row = $ret->FetchRow()) {
         $directory = 'modules/' . str_replace('_', '/', $row[0]) . '/theme_' . $row['version'];
         if (!is_dir($directory)) {
             $directory = 'modules/' . str_replace('_', '/', $row[0]) . '/theme';
         }
         $mod_name = $row[0];
         $data_dir = DATA_DIR . '/Base_Theme/templates/default';
         if (!is_dir($directory)) {
             continue;
         }
         $content = scandir($directory);
         $mod_name = str_replace('_', '/', $mod_name);
         $mod_path = explode('/', $mod_name);
         $sum = '';
         foreach ($mod_path as $p) {
             $sum .= '/' . $p;
             @mkdir($data_dir . $sum);
         }
         foreach ($content as $name) {
             if ($name == '.' || $name == '..' || preg_match('/^[\\.~]/', $name)) {
                 continue;
             }
             recursive_copy($directory . '/' . $name, $data_dir . '/' . $mod_name . '/' . $name);
         }
     }
     self::install_default_theme_common_files('modules/Base/Theme/', 'images');
     self::create_cache();
 }
コード例 #21
0
ファイル: functions.php プロジェクト: rdissauer/fusionpbx
 function recursive_copy($src, $dst, $options = '')
 {
     $dir = opendir($src);
     if (!$dir) {
         throw new Exception("recursive_copy() source directory '" . $src . "' does not exist.");
     }
     if (!is_dir($dst)) {
         if (!mkdir($dst, 02770, true)) {
             throw new Exception("recursive_copy() failed to create destination directory '" . $dst . "'");
         }
     }
     while (false !== ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             if (is_dir($src . '/' . $file)) {
                 recursive_copy($src . '/' . $file, $dst . '/' . $file);
             } else {
                 copy($src . '/' . $file, $dst . '/' . $file);
             }
         }
     }
     closedir($dir);
 }
コード例 #22
0
ファイル: install.php プロジェクト: petekelly/fusionpbx
 //copy recordings files
 recursive_copy($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/includes/install/recordings', $v_recordings_dir . '');
 //get the javascript files
 if (!is_dir($v_scripts_dir . '')) {
     mkdir($v_scripts_dir . '', 0777, true);
 }
 if (!is_dir($v_scripts_dir . '/javascript')) {
     mkdir($v_scripts_dir . '/javascript', 0777, true);
 }
 if (!is_dir($v_scripts_dir . '/lua')) {
     mkdir($v_scripts_dir . '/lua', 0777, true);
 }
 if (!is_dir($v_scripts_dir . '/perl')) {
     mkdir($v_scripts_dir . '/perl', 0777, true);
 }
 recursive_copy($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/includes/install/scripts', $v_scripts_dir);
 //copy additional the flash mp3 player
 $srcfile = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/includes/install/htdocs/slim.swf';
 $destfile = $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/mod/recordings/slim.swf';
 if (!copy($srcfile, $destfile)) {
     //echo "failed to copy $srcfile to $destfile...\n";
     //exit;
 }
 unset($srcfile, $destfile);
 //activate the .htaccess file
 $srcfile = $install_secure_dir . '/htaccess.tmp';
 $destfile = $install_secure_dir . '/.htaccess';
 if (!copy($srcfile, $destfile)) {
     //echo "failed to copy $srcfile to $destfile...\n";
     //exit;
 }