Exemple #1
0
                    $ext0 = explode('.', $fileNameUpload);
                    $ext0 = $ext0[count($ext0) - 1];
                    while (file_exists($pathToUpload2)) {
                        $pathToUpload2 = str_ireplace($ext0, $seqncr++ . '.' . $ext0, $pathToUpload);
                    }
                    $pathToUpload = $pathToUpload2;
                    $old2 = basename($pathToUpload2);
                    $fileNameUpload = str_ireplace($old, $old2, $fileNameUpload);
                }
                $fileToUpload = $fileNameUpload;
                $doPreview = TRUE;
            }
            if ($fileToUpload == $fileNameUpload) {
                if (is_file($pathToUpload) && substr($pathToUpload, -4, 4) == '.xml') {
                    doBackup($fileNameTemp);
                    doBackup($pathToUpload);
                }
                if (move_uploaded_file($fileNameTemp, $pathToUpload)) {
                    @chmod($pathToUpload, CHMOD);
                    //permessi per poterci sovrascrivere/scaricare
                    $updateDone = true;
                    $resultMsg .= '<span class="ok">OK: ho caricato il file "' . strtoupper($fileNameUpload) . '" in "' . strtoupper(dirname(str_ireplace($ftp_path, '', $pathToUpload))) . '".</span><br />';
                    if ($isMedia) {
                        $resultMsg .= '<form action="javascript:void(0);">';
                        $theCode = 'img://' . $fileNameUpload;
                        $resultMsg .= '<fieldset><label>URI: </label><input name="new_name" onclick="javascript:this.form.new_name.focus();this.form.new_name.select();" class="linkRule" type="text" value="' . $theCode . '" size="' . strlen($theCode) . '"/><label>' . SYS_DBL_SPACE . '
 <span class="help">fai un click sul testo per selezionare tutto l\'identificativo, poi premi command+c o ctrl+c per copiare...</span></label></fieldset></form><br />';
                    }
                    if ($doPreview) {
                        createPreview($pathToUpload, TRUE);
                    }
Exemple #2
0
function generateBackup($cid, $option)
{
    // ----------------------------------------------------------
    // Routine to generate recurse a folder structure and record
    // the files, their sizes and parent folders
    // ----------------------------------------------------------
    global $_CONFIG;
    # generate database backup if required
    if (!$_CONFIG['enable_db_backup']) {
        $backupDatabase = 0;
    } else {
        $backupDatabase = $_REQUEST['dbbackup'];
    }
    if ($_REQUEST[cron_access]) {
        $_CONFIG['backup_refresh'] = 0;
        $_REQUEST['dbbackup_drop'] = $_CONFIG['cron_sql_drop'];
        if ($_CONFIG[cron_btype] == '1') {
            $backupDatabase = 0;
        }
    }
    if (!is_writeable($_CONFIG['clonerPath'])) {
        E_print("Your backup directory " . $_CONFIG['clonerPath'] . " is not writeable or does not exists!");
        return;
    }
    if (!is_writeable($_CONFIG['backups_dir'])) {
        E_print("Required sql backup directory " . $_CONFIG['backups_dir'] . " is not writeable or does not exists!");
        return;
    }
    # generate the backup set filename
    #$urlinfo = parse_url($mosConfig_live_site);
    #$domainname = strtolower(str_replace('.','_',$urlinfo[host]));
    #$domainname= $_SERVER['HTTP_HOST'];
    $domainname = $_CONFIG['mosConfig_live_site'];
    if ($_CONFIG['mem'] && $_CONFIG['backup_refresh']) {
        $f_ext = '.tar';
        $_CONFIG['tarcompress'] = '';
    } elseif ($_CONFIG['backup_compress']) {
        $f_ext = '.tgz';
        $_CONFIG['tarcompress'] = 'z';
    } else {
        $f_ext = '.tar';
        $_CONFIG['tarcompress'] = '';
    }
    /*if($_CONFIG['backup_refresh']){
         $f_ext = ".tar";
        }
        elseif($_REQUEST[cron_dbonly]){
    	 $f_ext = ".tar";
    	}
    	else{
    	 $f_ext = ".tgz";
    	}*/
    if ($_REQUEST['bname'] == "") {
        if ($backupDatabase == 1) {
            if ($_REQUEST['dbbackup_drop']) {
                $filename1 = 'backup_' . date("Y-m-d_H-i") . '_' . $domainname . '-sql-drop' . $f_ext;
            } else {
                $filename1 = 'backup_' . date("Y-m-d_H-i") . '_' . $domainname . '-sql-nodrop' . $f_ext;
            }
        } else {
            $filename1 = 'backup_' . date("Y-m-d_H-i") . '_' . $domainname . '-nosql' . $f_ext;
        }
    } else {
        $filename1 = $_REQUEST['bname'] . $f_ext;
    }
    $sql_file = array();
    if ($backupDatabase == 1) {
        $tables = array();
        $tables[0] = 'all';
        $excltables = $_REQUEST['excltables'];
        $sql_file[] = doBackup($tables, 'sql', 'local', 'both', $_SERVER['HTTP_USER_AGENT'], $_CONFIG['backups_dir'], $databaseResult, 'database', $excltables, $_CONFIG['mysql_database']);
        $databaseResult = "<b>" . $_CONFIG['mysql_database'] . ":</b> " . $databaseResult;
        ############## ADD multiple databases #######################
        $databases_incl = $_REQUEST['databases_incl'];
        if (is_array($databases_incl)) {
            foreach ($databases_incl as $database_name) {
                if ($database_name != '') {
                    $excltables = "";
                    mysql_query("USE  {$database_name}");
                    $sql_file[] = doBackup($tables, 'sql', 'local', 'both', $_SERVER['HTTP_USER_AGENT'], $_CONFIG['backups_dir'], $databaseResult_incl, $database_name, $excltables, $database_name);
                    $databaseResult .= "<br /> <b>{$database_name}:</b> " . $databaseResult_incl;
                }
            }
            mysql_query("USE  " . $_CONFIG['mysql_database']);
        }
    } else {
        $databaseResult = LM_DATABASE_EXCLUDED;
    }
    $excluded = array();
    $data = "";
    $excluded[] = $_CONFIG['backups_dir'] . "/" . $filename1;
    if ($_REQUEST['cron_access']) {
        $data = $_CONFIG['cron_exclude'];
    } elseif ($_CONFIG[select_folders] == 1) {
        $data = $_REQUEST['exluded'];
    }
    ##### START THE EXCLUSION FILTER
    if (($fp = @fopen($_CONFIG['exfile'], "r")) && !$_REQUEST['cron_access']) {
        while (!feof($fp)) {
            $data .= fread($fp, 1024);
        }
        fclose($fp);
    }
    if (sizeof($_REQUEST[cid]) > 0) {
        $data .= implode("\r\n", $_REQUEST[cid]);
    }
    $_COOKIES = explode("\r\n", $data);
    if (is_array($_COOKIES)) {
        foreach ($_COOKIES as $key => $value) {
            if ($value != "") {
                $value = str_replace($_CONFIG['backup_path'], "", $value);
                if ($value[0] != '/') {
                    $value = '/' . $value;
                }
                if (substr($value, strlen($value) - 1, 1) == '/' && strlen($value) != 1) {
                    $value = substr($value, 0, strlen($value) - 1);
                }
                if ($value != "" && $value != '/administrator/backups') {
                    if (trim($value) != '/administrator') {
                        $excluded[] = str_replace("//", "/", $_CONFIG['backup_path'] . "/" . $value);
                    } else {
                        if ($handle = opendir($_CONFIG['backup_path'] . '/administrator')) {
                            while (false !== ($file = readdir($handle))) {
                                if ($file != "." && $file != ".." && $file != "backups") {
                                    $excluded[] = str_replace("//", "/", $_CONFIG['backup_path'] . "/administrator/" . $file);
                                }
                            }
                            closedir($handle);
                        }
                    }
                }
            }
        }
    }
    #### END EXCLUSION FILTER
    if (!$_CONFIG['add_backups_dir']) {
        # initialise list arrays, directories and files separately and array counters for them
        $d_arr = array();
        $d = 0;
        $f_arr = array();
        $f = 0;
        $s_arr = array();
        $s = 0;
        getBackupFiles($d_arr, $f_arr, $s_arr, $d, $f);
        $i = 0;
        while ($i < sizeof($f_arr)) {
            $excluded[] = $_CONFIG['clonerPath'] . "/" . $f_arr[$i];
            $i++;
        }
    }
    # obtain list of folders included in the backup
    $includeFolder = array();
    #print_r($excluded);exit;
    #$includeFolder = confirmBackup('nohtml');
    #initialise list arrays, directories and files separately and array counters for them
    $d_arr = array();
    $d = 0;
    $ds_arr = array();
    $f_arr = array();
    $f = 0;
    $s_arr = array();
    $s = 0;
    $mdir = 0;
    $perm_file = $_CONFIG['backups_dir'] . "/perm.txt";
    @unlink($perm_file);
    $fperm = fopen($perm_file, "w");
    for ($i = 0; $i < sizeof($excluded); $i++) {
        $excluded[$i] = str_replace("//", "/", $excluded[$i]);
    }
    #print_r($excluded);exit;
    # obtain the list of files by recursing the mambo file store
    recurseFiles($d_arr, $ds_arr, $f_arr, $s_arr, $d, $f, $s, $includeFolder, '', $excluded, $fperm);
    @fclose($fperm);
    @chmod($perm_file, 0777);
    # format total archive size
    $originalSize = getFileSizeText($s);
    # extend the file locations to include the full path
    for ($i = 0; $i < count($f_arr); $i++) {
        if (!file_exists($f_arr[$i])) {
            unset($f_arr[$i]);
        }
    }
    #if((file_exists($perm_file))&&(!in_array($perm_file, $f_arr)))
    # $f_arr[] = $perm_file;
    # add sql file to the backup
    if ($_REQUEST[cron_access]) {
        if (is_array($sql_file)) {
            foreach ($sql_file as $key => $sqlfile) {
                if ($backupDatabase == 1 && !in_array($_CONFIG['backups_dir'] . $sqlfile, $f_arr)) {
                    $f_arr[] = $sqlfile;
                }
            }
        }
    }
    $filename = $_CONFIG['clonerPath'] . '/' . $filename1;
    $f_arr = array_unique($f_arr);
    # create the Zip file from the fileset array
    @unlink($filename);
    $perm_lines = 0;
    $handle = @fopen($perm_file, "r");
    if ($handle) {
        while (!feof($handle)) {
            fgets($handle, 4096);
            $perm_lines++;
        }
        fclose($handle);
    }
    if (!$_CONFIG['mem']) {
        #### START TAR MANUAL MODE ############################################################
        if ($_CONFIG['backup_refresh']) {
            $f_arr = array($_CONFIG['backups_dir'] . "/index.html");
        }
        if ($_CONFIG['backup_refresh']) {
            $tar_type = "tar";
        } else {
            $tar_type = "tgz";
        }
        $tar_object = new Archive_Tar($filename, compression($tar_type));
        #$tar_object->setErrorHandling(PEAR_ERROR_PRINT);  // Optional error handling
        $return = $tar_object->addModify($f_arr, '', $_CONFIG['backup_path']);
        if ($return != 1) {
            echo "Backup failed using tar mode, error code {$return}!";
        }
        if ($_CONFIG['backup_refresh']) {
            echo "Starting the manual backup process!<br />";
            echo "Database backup: " . $databaseResult . "<br /><br />";
            if (file_exists($filename)) {
                echo "Backup {$filename} created, we may continue!<br />";
                #echo "Database backup: ".$databaseResult ."<br />";
                echo "<a href='index2.php?option=com_cloner&lines=" . $perm_lines . "&task=refresh&backup={$filename}&excl_manual={$excl_manual}'>Please click here to continue!</a>";
                return;
            } else {
                E_print("Backup failed, please check your tar server utility support!");
                return;
            }
        }
        #### END TAR MODE ############################################################
    } else {
        #### CREATE BACKUP USING SERVER UTILITIES
        $i = 0;
        chdir($_CONFIG['backup_path']);
        $excl_files = "";
        while ($i < sizeof($excluded)) {
            $file = $excluded[$i];
            $file = str_replace($_CONFIG['backup_path'], "", $file);
            $file = "##" . $file;
            $file = str_replace("##//", "", $file);
            $file = str_replace("##/", "", $file);
            $file = str_replace("##", "", $file);
            $excl_files .= "/" . $file . "* ";
            $i++;
        }
        chdir($_CONFIG['backup_path']);
        $excl_cmd = "";
        if ($fp = fopen($_CONFIG['exfile_tar'], "w")) {
            $i = 0;
            while ($i < sizeof($excluded)) {
                $file = $excluded[$i];
                $file = str_replace($_CONFIG['backup_path'], "", $file);
                $file = "##" . $file;
                $file = str_replace("##//", "", $file);
                $file = str_replace("##/", "", $file);
                $file = str_replace("##", "", $file);
                $excl_cmd .= " --exclude=./" . $file . " ";
                $excl_files = "./" . $file . "\r\n";
                fwrite($fp, $excl_files);
                $i++;
            }
            fclose($fp);
        }
        if ($_CONFIG['backup_refresh']) {
            ########## STARTING THE MANUAL BACKUP ######################################################
            $exclude = $excl_cmd . " -X " . $_CONFIG['exfile_tar'];
            $excl_manual = $_CONFIG['exfile_tar'] . "_manual";
            if ($fp = fopen($excl_manual, "w")) {
                fwrite($fp, $exclude);
                fclose($fp);
            }
            echo "Starting the manual backup process!<br />";
            echo "Database backup: " . $databaseResult . "<br /><br />";
            chdir($_CONFIG['backup_path']);
            #$filename = str_replace(".tgz",".tar",$filename);
            exec($_CONFIG[tarpath] . " {$exclude} -c" . $_CONFIG['tarcompress'] . "vf {$filename} ./administrator/backups/index.html");
            exec($_CONFIG[tarpath] . " -" . $_CONFIG['tarcompress'] . "vf {$filename} --update ./administrator/backups/database-sql.sql");
            exec($_CONFIG[tarpath] . " -" . $_CONFIG['tarcompress'] . "vf {$filename} --update ./administrator/backups/htaccess.txt");
            exec($_CONFIG[tarpath] . " -" . $_CONFIG['tarcompress'] . "vf {$filename} --update ./administrator/backups/perm.txt");
            if (file_exists($filename)) {
                echo "Backup {$filename} created, we may continue!<br />";
                #echo "Database backup: ".$databaseResult."<br />" ;
                echo "<a href='index2.php?option=com_cloner&lines=" . $perm_lines . "&task=refresh&backup={$filename}&excl_manual={$excl_manual}'>Please click here to continue!</a>";
                return;
            } else {
                E_print("Backup failed, please check your tar server utility support!");
                return;
            }
            return;
        }
        if ($_REQUEST[cron_dbonly] != 1) {
            exec($_CONFIG[tarpath] . " {$excl_cmd} " . " -X " . $_CONFIG['exfile_tar'] . "  -chv" . $_CONFIG['tarcompress'] . "f {$filename} ./");
        } else {
            exec($_CONFIG[tarpath] . "  -" . $_CONFIG['tarcompress'] . "cvf {$filename} ./administrator/backups/database-sql.sql");
            if (is_array($databases_incl)) {
                foreach ($databases_incl as $database_name) {
                    if ($database_name != "") {
                        exec($_CONFIG[tarpath] . "  -" . $_CONFIG['tarcompress'] . "vf {$filename} --update  ./administrator/backups/" . $database_name . "-sql.sql");
                    }
                }
            }
        }
        #######END
        chdir($_CONFIG['script_path']);
        #### END
    }
    if (!file_exists($filename)) {
        if ($_CONFIG[archive_type] == 1) {
            echo LM_MSG_BACK_12;
        } else {
            echo LM_MSG_BACK_13;
        }
        return;
    }
    # format the compressed size of the fileset
    $archiveSize = getFileSizeText(filesize($filename));
    # load presentation layer
    if ($option != 'nohtml') {
        HTML_cloner::generateBackup($filename1, $archiveSize, $originalSize, $mdir, $f, $databaseResult, $option);
    } else {
        logxx(HTML_cloner::generateBackup_text($filename1, $archiveSize, $originalSize, $mdir, $f, $databaseResult, $option));
    }
    if (is_array($databases_incl)) {
        foreach ($databases_incl as $database_name) {
            @unlink($_CONFIG['backups_dir'] . "/" . $database_name . "-sql.sql");
        }
    }
    @unlink($_CONFIG['backups_dir'] . "/database-sql.sql");
    @unlink($sql_file);
    @unlink($perm_file);
    @unlink($htaccess);
    @unlink($_CONFIG['exfile']);
    @unlink($_CONFIG['exfile_tar']);
    return $filename1;
}
}
require_once $mainframe->getPath('admin_html');
require_once "{$mosConfig_absolute_path}/administrator/includes/pcl/pclzip.lib.php";
$task = mosGetParam($_REQUEST, "task", "");
$file = mosGetParam($_POST, "file", null);
$upfile = mosGetParam($_FILES, "upfile", null);
$tables = mosGetParam($_POST, "tables", null);
$OutType = mosGetParam($_POST, "OutType", null);
$OutDest = mosGetParam($_POST, "OutDest", null);
$toBackUp = mosGetParam($_POST, "toBackUp", null);
switch ($task) {
    case "dbBackup":
        dbBackup($option);
        break;
    case "doBackup":
        doBackup($tables, $OutType, $OutDest, $toBackUp, $_SERVER['HTTP_USER_AGENT'], $local_backup_path);
        break;
    case "dbRestore":
        dbRestore($local_backup_path);
        break;
    case "doRestore":
        doRestore($file, $upfile, $local_backup_path);
        break;
    case "xquery":
        xquery($option);
        break;
}
function dbBackup($p_option)
{
    global $database;
    $database->setQuery("SHOW tables");
Exemple #4
0
                 $select = $PACKAGE_FIELDS['label'];
                 foreach ($select as $field => $label) {
                     if (isset($_REQUEST[$field])) {
                         $value = $_REQUEST[$field];
                         if ($field == 'package_work' && $value == '') {
                             $value = $_REQUEST['source_author'] . ' - ' . $_REQUEST['source_title_main'];
                         }
                         $value = stripslashes($value);
                         $value = trim(preg_replace('/' . WS . WS . '+/', ' ', $value));
                         $value = htmlentities($value, ENT_QUOTES, 'UTF-8');
                         $value = preg_replace('/' . WS . WS . '+/', '<lb />', $value);
                         $value = stripslashes($value);
                         $contents = str_ireplace($field . ' ""', $field . ' "' . $value . '"', $contents);
                     }
                 }
                 doBackup($header2);
                 if (file_put_contents($header2, forceUTF8($contents, $header2)) !== FALSE) {
                     @chmod($header2, CHMOD);
                     $resultMsg .= '<span class="ok">Ho aggiornato le informazioni per "' . $package_short . '"</span><br />';
                 } else {
                     $resultMsg .= '<span class="error">ERRORE: non riesco a scrivere il file "' . $header2 . '" ... aggiornamento non riuscito!</span><br />';
                 }
             } else {
                 $resultMsg .= '<span class="error">ERRORE: non riesco a trovare il file "' . $header1 . '" ... aggiornamento non riuscito!</span><br />';
             }
         }
     }
 }
 //
 // CREATE PART
 if ($isCreatePart) {
Exemple #5
0
function ajax_saveLink($selector = 'new', $id1 = '', $id2 = '', $label = '', $what = '', $overwrite = TRUE)
{
    $resultText = '';
    $resultOK = '';
    $resultKO = '';
    $collection_id = explode('/', str_ireplace('xml://', '', $id1));
    $collection_id = $collection_id[0];
    if ($collection_id != '') {
        $thePath = DCTL_PROJECT_PATH . $collection_id . SYS_PATH_SEP;
        // $f = fopen('/tmp/diocaro.log', 'a');
        // fwrite($f, "------------------\n\n" . $thePath);
        switch ($what) {
            case 'lnk':
                $thePath .= DCTL_FILE_LINKER;
                break;
            case 'map':
                $thePath .= DCTL_FILE_MAPPER;
                break;
            default:
                $resultKO .= 'ERROR: CASE UNIMPLEMENTED IN ' . __FUNCTION__;
                break;
        }
        if (is_file($thePath)) {
            // fwrite($f, "------------------\n\n" . $thePath);
            switch ($selector) {
                case 'new':
                case 'add':
                case 'mod':
                case 'ovw':
                    $file_content = file_get_contents($thePath);
                    //fwrite($f, "--------1111111111----------\n\n");
                    $file_content = preg_replace('/' . WS . '+/', ' ', $file_content);
                    //fwrite($f, "------2222222222------------\n\n");
                    $text_head = substr($file_content, 0, stripos($file_content, '%BEGIN%')) . '%BEGIN% -->';
                    $text_foot = '<!-- ' . substr($file_content, stripos($file_content, '%END%'));
                    $dom = new DOMDocument('1.0', 'UTF-8');
                    $dom->preserveWhiteSpace = false;
                    forceUTF8($thePath);
                    if ($dom->load($thePath, DCTL_XML_LOADER)) {
                        $xpath = new DOMXPath($dom);
                        switch ($selector) {
                            case 'new':
                                $type = 'link';
                                $thisID = $collection_id . '-' . generateId();
                                $head = $label;
                                $query = 'id("placeholder")';
                                $entries = $xpath->query($query);
                                foreach ($entries as $entry) {
                                    $newNode = $dom->createElement('ref', $head);
                                    $newNode = $entry->parentNode->insertBefore($newNode, $entry);
                                    $newNode->setAttribute('xml:id', $thisID);
                                    $newNode->setAttribute('type', $type);
                                    $newNode->setAttribute('n', $label);
                                    $newNode->setAttribute('target', $id1 . ' ' . $id2);
                                    $newNode = $dom->createComment(' ');
                                    $newNode = $entry->parentNode->insertBefore($newNode, $entry);
                                }
                                break;
                            case 'add':
                                $query = 'id("' . $id2 . '")';
                                $entries = $xpath->query($query);
                                foreach ($entries as $entry) {
                                    $target = $entry->getAttribute('target');
                                    if (stripos($target, $id1) === FALSE) {
                                        $entry->setAttribute('target', $id1 . ' ' . $target);
                                    } else {
                                        $resultKO .= 'L\'ID "' . $id1 . '" è gia nel collegamento';
                                    }
                                }
                                break;
                            case 'mod':
                                $query = 'id("' . $id2 . '")';
                                $entries = $xpath->query($query);
                                foreach ($entries as $entry) {
                                    $entry->setAttribute('n', $label);
                                    if ((string) $entry->nodeValue == '') {
                                        $entry->nodeValue = $label;
                                    }
                                }
                                break;
                            case 'ovw':
                                //fwrite($f, "------ $query: pronti a morire? ------------ [[".memory_get_usage()."]]");
                                //fwrite($f, "------ 11 ?! ------------[".$entry->namespaceURI."]-- [[".memory_get_usage()."]]\n\n");
                                $entry = $dom->getElementById($id2);
                                //fwrite($f, "------ 22 ?! ------------ ".$entry->getAttribute('n')." > $label [[".memory_get_usage()."]]\n\n");
                                $entry->setAttribute('target', $id1);
                                //fwrite($f, "------ 33 ?! ------------[[".memory_get_usage()."]]\n\n");
                                if ($entry->getAttribute('n') != $label) {
                                    //fwrite($f, "------ 33 AA ?! ------(".$entry->getAttribute('n').")------[[".memory_get_usage()."]]\n\n");
                                    $entry->setAttributeNode(new DOMAttr('n', $label));
                                }
                                //fwrite($f, "------ 44 ?! ------------[[".memory_get_usage()."]]\n\n");
                                if ((string) $entry->nodeValue == '') {
                                    $entry->nodeValue = $label;
                                }
                                /*
                                                                $query = 'id("'.$id2.'")';
                                                                $entries = $xpath->query($query);
                                								foreach ($entries as $entry) {
                                									$entry->setAttribute('n', $label);
                                									$entry->setAttribute('target', $id1);
                                                  fwrite($f, "------ dentro foreach, o sono gia' morto? :| ------------\n\n");
                                									if ((string) $entry->nodeValue == '')  $entry->nodeValue = $label;
                                								};
                                */
                                break;
                        }
                        if ($resultKO == '') {
                            //fwrite($f, "------ Si salva vai!!  ------------[[".memory_get_usage()."]]\n\n");
                            $file_content = $dom->saveXML();
                            $file_content = preg_replace('/' . WS . '+/', ' ', $file_content);
                            $from = stripos($file_content, '%BEGIN%') + strlen('%BEGIN% -->');
                            $to = stripos($file_content, '%END%') - strlen('<-- ') - $from - 1;
                            $text_content = substr($file_content, $from, $to);
                            $file_content = $text_head . $text_content . $text_foot;
                            if ($overwrite) {
                                doBackup($thePath);
                                if (file_put_contents($thePath, forceUTF8($file_content), LOCK_EX) === false) {
                                    $resultKO .= 'Impossibile scrivere il file "' . basename($thePath) . '"';
                                } else {
                                    @chmod($thePath, CHMOD);
                                    $resultOK .= 'Modifica eseguita con successo ("' . $label . '")';
                                }
                            } else {
                                $resultOK .= 'Simulazione eseguita con successo ("' . $label . '")';
                            }
                        }
                    } else {
                        $resultKO .= 'Impossibile leggere il file "' . basename($thePath) . '"';
                    }
                    break;
                default:
                    $resultKO .= '?' . $selector . '?';
                    break;
            }
        } else {
            $resultKO .= 'Impossibile trovare "' . basename($thePath) . '"';
        }
    } else {
        $resultKO .= 'Impossibile trovare la collection...';
    }
    if ($resultKO != '') {
        $resultText .= '<span class="error">' . cleanWebString($resultKO) . '</span>';
    } else {
        $resultText .= '<span class="ok">' . cleanWebString($resultOK) . '</span>';
    }
    return $resultText;
}