Exemple #1
0
 }
 $calID = $selCal;
 //set destination calendar
 $count = importSqlFile($sqlArray);
 //import SQL file
 if ($count['cat'] > 0 and $count['use'] > 0 and $count['gro'] > 0 and $count['set'] > 0) {
     $resMsg[] = "<h5>Importing LuxCal calendar data successful</h5><br>";
     $resMsg[] = "From file '{$_FILES['fName']['name']}' (LuxCal V{$lcVBup})";
     $resMsg[] = "Into calendar '{$selCal}'";
     $resMsg[] = "<br>";
     $resMsg[] = "- Table events: {$count['eve']} records inserted";
     $resMsg[] = "- Table users: {$count['use']} records inserted";
     $resMsg[] = "- Table groups: {$count['gro']} records inserted";
     $resMsg[] = "- Table categories: {$count['cat']} records inserted";
     $resMsg[] = "- Table settings: {$count['set']} records inserted";
     $lcVUpg = upgradeDb();
     //upgrade db schema
     $resMsg[] = "<br>";
     $resMsg[] = "Imported database upgraded from V{$lcVUpg} to V" . substr($lcV, 0, 3);
     $dbSet = getSettings();
     //get imported settings
     checkSettings($dbSet);
     //check & complete settings
     saveSettings($dbSet);
     //save completed settings
     $resMsg[] = "<br>";
     $resMsg[] = "Imported settings verified/completed";
 } else {
     $errMsg[] = "The selected backup file could not be imported";
 }
 $stH = null;
Exemple #2
0
function restoreTables()
{
    global $ax, $calID, $lcV, $dbType;
    echo "<fieldset><legend>{$ax['mdb_restore']}</legend>\n";
    do {
        if (empty($_FILES['fName']['tmp_name'])) {
            echo "{$ax['mdb_noshow_restore']}\n";
            break;
            //abort restore
        }
        if (substr($_FILES['fName']['name'], -4) != '.sql') {
            echo "{$ax['mdb_file_not_sql']}\n";
            break;
            //abort restore
        }
        $buFile = $_FILES['fName']['tmp_name'];
        //get backup file name
        //Read SQL queries from $buFile
        $sqlArray = file($buFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        unlink($buFile);
        //check version of backup file
        foreach ($sqlArray as $qLine) {
            //search 1st comment block
            if ($qLine[0] != '-' or preg_match('~LuxCal version:\\s*(\\d.\\d)~i', $qLine, $matches)) {
                break;
            }
        }
        if (!empty($matches) and $matches[1] != substr($lcV, 0, 3)) {
            //version found but not matching
            echo "<span class='hired'>{$ax['mdb_no_bup_match']}</span><br>\n";
            break;
            //abort restore
        }
        echo "{$ax['mdb_backup_file']}: '<strong>{$_FILES['fName']['name']}</strong>'<br><br>";
        $count = importSqlFile($sqlArray);
        //import SQL file
        upgradeDb();
        //recreate db schema
        echo "{$ax['mdb_restore_table']} 'events' - {$count['eve']} {$ax['mdb_inserted']}<br>\n{$ax['mdb_restore_table']} 'users' - {$count['use']} {$ax['mdb_inserted']}<br>\n{$ax['mdb_restore_table']} 'groups' - {$count['gro']} {$ax['mdb_inserted']}<br>\n{$ax['mdb_restore_table']} 'categories' - {$count['cat']} {$ax['mdb_inserted']}<br>\n{$ax['mdb_restore_table']} 'settings' - {$count['set']} {$ax['mdb_inserted']}<br>\n";
        if ($count['cat'] > 0 and $count['use'] > 0 and $count['gro'] > 0 and $count['set'] > 0) {
            echo "<br><strong>{$ax['mdb_db_restored']}</strong><br>\n";
        }
    } while (0);
    //end of: restore tables
    echo "</fieldset>\n";
}