예제 #1
0
파일: ecl.php 프로젝트: rdmenezes/pfsense
function find_config_xml()
{
    global $g, $debug;
    $disks = get_disks();
    // Safety check.
    if (!is_array($disks)) {
        return;
    }
    $boot_disk = get_boot_disk();
    exec("/bin/mkdir -p /tmp/mnt/cf");
    foreach ($disks as $disk) {
        $slices = get_disk_slices($disk);
        if (is_array($slices)) {
            foreach ($slices as $slice) {
                if ($slice == "") {
                    continue;
                }
                if (stristr($slice, $boot_disk)) {
                    if ($debug) {
                        echo "\nSkipping boot device slice {$slice}";
                    }
                    continue;
                }
                echo " {$slice}";
                // First try msdos fs
                if ($debug) {
                    echo "\n/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n";
                }
                $result = exec("/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null");
                // Next try regular fs (ufs)
                if (!$result) {
                    if ($debug) {
                        echo "\n/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n";
                    }
                    $result = exec("/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null");
                }
                $mounted = trim(exec("/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep '/tmp/mnt/cf' | /usr/bin/wc -l"));
                if ($debug) {
                    echo "\nmounted: {$mounted} ";
                }
                if (intval($mounted) > 0) {
                    // Item was mounted - look for config.xml file
                    $config_location = discover_config($slice);
                    if ($config_location) {
                        if (test_config($config_location)) {
                            // We have a valid configuration.  Install it.
                            echo " -> found config.xml\n";
                            echo "Backing up old configuration...\n";
                            backup_config();
                            echo "Restoring [{$slice}] {$config_location}...\n";
                            restore_backup($config_location);
                            echo "Cleaning up...\n";
                            exec("/sbin/umount /tmp/mnt/cf");
                            exit;
                        }
                    }
                    exec("/sbin/umount /tmp/mnt/cf");
                }
            }
        }
    }
}
예제 #2
0
파일: chat.php 프로젝트: grlong/le-chat-php
            $_REQUEST['maxmessage'] = 1;
        } elseif ($_REQUEST['maxmessage'] > 20000) {
            $_REQUEST['maxmessage'] = 20000;
        }
        if ($_REQUEST['numnotes'] < 1) {
            $_REQUEST['numnotes'] = 1;
        }
        foreach ($C['settings'] as $setting) {
            if (isset($_REQUEST[$setting])) {
                update_setting($setting, $_REQUEST[$setting]);
            }
        }
    } elseif ($_REQUEST['do'] === 'backup' && $U['status'] == 8) {
        send_backup();
    } elseif ($_REQUEST['do'] === 'restore' && $U['status'] == 8) {
        restore_backup();
        send_backup();
    } elseif ($_REQUEST['do'] === 'destroy' && $U['status'] == 8) {
        if (isset($_REQUEST['confirm'])) {
            destroy_chat();
        } else {
            send_destroy_chat();
        }
    }
    send_setup();
} elseif ($_REQUEST['action'] === 'init') {
    init_chat();
} else {
    send_login();
}
exit;
    $db_year = 2012;
    //default year
}
$flash = '';
$error_flash = '';
$dump = '';
if ($post->post_status != 'private') {
    $error_flash = "<h1>This interface is not published privately!</h1>";
    $error_flash .= "Please remedy this IMMEDIATELY by editing this post<br/><pre>post title '" . $post->post_title . "', id " . $post->ID . "</pre>and setting visibility to private!";
}
include 'verifier/functions.php';
include 'verifier/multi-connection.php';
if (count($_POST) > 0) {
    if ($_POST['restore']) {
        $table = $_POST["table"];
        restore_backup($table);
        $flash = "Restored {$table} table from last backup!";
    } else {
        if (count($_FILES) > 0) {
            if ($_FILES["file"]["error"] > 0) {
                $error_flash = "Error: " . $_FILES["file"]["error"];
            } else {
                //setup
                $file = $_FILES["file"];
                $drop = $_POST["drop"] == "true" ? true : false;
                $table = $_POST["table"];
                $fref = fopen($file["tmp_name"], "r");
                if ($table == 'machine') {
                    include 'verifier/machine-importer.php';
                } else {
                    if ($table == 'official') {
예제 #4
0
파일: admin.inc.php 프로젝트: aunderwo/sobc
 if (empty($errors)) {
     if (empty($_POST['restore_password']) || $_POST['restore_password'] == '') {
         $errors[] = 'error_password_wrong';
     }
     if (empty($errors)) {
         $result = mysql_query("SELECT user_pw FROM " . $db_settings['userdata_table'] . " WHERE user_id=" . intval($_SESSION[$settings['session_prefix'] . 'user_id']) . " LIMIT 1", $connid) or raise_error('database_error', mysql_error());
         if (mysql_num_rows($result) != 1) {
             raise_error('database_error', mysql_error());
         }
         $data = mysql_fetch_array($result);
         if (!is_pw_correct($_POST['restore_password'], $data['user_pw'])) {
             $errors[] = 'error_password_wrong';
         }
         #if(md5($_POST['restore_password'])!=$data['user_pw']) $errors[] = 'error_password_wrong';
         if (empty($errors)) {
             if (!restore_backup('backup/' . $_POST['backup_file'])) {
                 $errors[] = 'error_restore_mysql';
                 $smarty->assign('mysql_error', $error_message);
             }
             if (empty($errors)) {
                 header('Location: index.php?mode=admin&action=backup&msg=restore_backup_ok');
                 exit;
             }
         }
     }
 }
 if (isset($errors)) {
     $backup_file = $_POST['backup_file'];
     $smarty->assign('errors', $errors);
     $action = 'restore';
 }
예제 #5
0
function handle_form($conn)
{
    global $path_to_root;
    //Generate Only
    if (isset($_GET['c'])) {
        if ($_GET['c'] == 'g') {
            $filename = generate_backup($conn, $_GET['comp'], $_GET['comm']);
            header("Location: backups.php?c=gs&fn=" . urlencode($filename));
            return "";
        }
        //Generate and download
        if ($_GET['c'] == 'gd') {
            $filename = generate_backup($conn);
            header("Location: backups.php?c=ds&fn=" . urlencode($filename));
            return "";
        }
        //Download the file
        if ($_GET['c'] == 'd') {
            download_file(BACKUP_PATH . $_GET['fn']);
            exit;
        }
        //Delete the file
        if ($_GET['c'] == 'df') {
            $filename = $_GET['fn'];
            @unlink(BACKUP_PATH . $filename);
            header("Location: backups.php?c=dff&fn=" . urlencode($filename));
            return "";
        }
        if ($_GET['c'] == 'dff') {
            $msg = tr("File successfully deleted.") . "&nbsp;&nbsp;&nbsp;";
            $msg .= tr("Filename") . " = " . $_GET['fn'];
            return $msg;
        }
        //Write JS script to open download window
        if ($_GET['c'] == 'ds') {
            $filename = urlencode($_GET['fn']);
            $msg = tr("Backup is being downloaded...");
            $msg .= "<script language='javascript'>";
            $msg .= "function download_file() {location.href ='backups.php?c=d&fn={$filename}'}; window.onload=download_file";
            $msg .= "</script>";
            return $msg;
        }
        //Print backup success message
        if ($_GET['c'] == 'gs') {
            $msg = tr("Backup successfully generated.") . "&nbsp;&nbsp;&nbsp;";
            $msg .= tr("Filename") . " = " . $_GET['fn'];
            return $msg;
        }
        //Restore backup
        if ($_GET['c'] == 'r') {
            $filename = $_GET['fn'];
            restore_backup(BACKUP_PATH . $filename, $conn);
            header("Location: backups.php?c=rs&fn=" . urlencode($filename));
            return "";
        }
        //Print restore success message
        if ($_GET['c'] == 'rs') {
            $msg = tr("Restore backup completed.") . "&nbsp;&nbsp;&nbsp;";
            return $msg;
        }
        if ($_GET['c'] == 'u') {
            $filename = $_FILES['uploadfile']['tmp_name'];
            if (is_uploaded_file($filename)) {
                restore_backup($filename, $conn);
                $msg = tr("Uploaded file has been restored.");
            } else {
                $msg = tr("Backup was not uploaded into the system.");
            }
            return $msg;
        }
    }
    return "";
}