Пример #1
0
 public static function run()
 {
     // On a besoin du path où mettre le fichier de backup
     $opts = array('path' => 'y', 'sn' => 'y');
     $r = command::get_runner($opts);
     $options = getopt($r->shortoptions, $r->options);
     $error = false;
     if (!isset($options['path']) || !is_dir($options['path'])) {
         logger::shout('loption --path nest pas valide');
         $error = true;
     }
     if (!isset($options['sn'])) {
         logger::shout('indiquer le shortname --sn ');
         $error = true;
     }
     if ($error) {
         return;
     }
     // $permissions = fileperms($options['path']);
     // logger::shout($options['path'] . ' permissions:' . $permissions. PHP_EOL);
     backup::execute($options['sn'], $options['path']);
 }
Пример #2
0
        if (!empty($curlResult)) {
            $curlInfo = curl_getinfo($ch);
            $curlInfo['http_code'] == 200 ? $result =& $curlResult : ($result = 'err' . $curlInfo['http_code']);
        } else {
            $result = 'errCurlNoExec';
        }
        curl_close($ch);
        echo $result;
    } else {
        echo 'errParams';
    }
} elseif (!empty($_POST['backup'])) {
    if ($_POST['backup'] === 'php') {
        echo ($res = backup::backupSite()) === true ? MESSAGE_BACKUP_SUCCESSFULLY_CREATED : $res . '<br><span style="color: red;">' . WARNING_BACKUP_NOT_CREATE . '</span>';
    } elseif ($_POST['backup'] === 'sql') {
        echo backup::backupDB() ? MESSAGE_BACKUP_SUCCESSFULLY_CREATED : '<span style="color: red;">' . WARNING_BACKUP_NOT_CREATE . '</span>';
    }
} elseif (!empty($_POST['setupUpdate']) && !empty($_POST['step'])) {
    $fileSetupUpdate = CONF_UPDATES_PATH_TO_FILES . $_POST['setupUpdate'];
    //$logFile = CONF_UPDATES_PATH_TO_LOG_FILES . terms::currentDate() . '_update.log';
    //$message = addslashes(MESSAGE_WARNING_UPDATE_ERRORS_OCCURRED . SITE_UPDATE_ERROR_LOG_FILE . ' - <b><a href="' . CONF_ADMIN_FILE . '?m=system&s=updates&action=saveLog&file=' . $logFile . '" title="' . FORM_BUTTON_SAVE . '">' . $logFile . '</a></b>');
    if (1 == $_POST['step']) {
        if (!updates::setupUpdate(CONF_UPDATES_PATH_TO_FILES . $_POST['setupUpdate'])) {
            echo ajax::sdgJSONencode(array('error' => updates::$errorMessage));
        } else {
            // Если сообщения не пустые, значит ошибки были
            if (!empty(updates::$errorMessage)) {
                echo ajax::sdgJSONencode(array('success' => MESSAGE_WARNING_UPDATE_SETUP_BUT_ERRORS_OCCURRED));
            } else {
                echo ajax::sdgJSONencode(array('success' => updates::$message));
            }
Пример #3
0
     if (file_exists(INVENTORY_DIR_ATTACHMENTS . $filename)) {
         require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
         $backup = new backup();
         $backup->download(INVENTORY_DIR_ATTACHMENTS, $filename, true);
     }
     die;
 case 'dn_attach':
     // download from list, assume the first document only
     $cID = db_prepare_input($_POST['rowSeq']);
     $result = $db->Execute("select attachments from " . TABLE_INVENTORY . " where id = {$cID}");
     $attachments = unserialize($result->fields['attachments']);
     foreach ($attachments as $key => $value) {
         $filename = 'inventory_' . $cID . '_' . $key . '.zip';
         if (file_exists(INVENTORY_DIR_ATTACHMENTS . $filename)) {
             require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
             $backup = new backup();
             $backup->download(INVENTORY_DIR_ATTACHMENTS, $filename, true);
             die;
         }
     }
 case 'reset':
     $_SESSION['filter_field'] = null;
     $_REQUEST['filter_field'] = null;
     $_SESSION['filter_criteria'] = null;
     $_REQUEST['filter_criteria'] = null;
     $_SESSION['filter_value'] = null;
     $_REQUEST['filter_value'] = null;
     break;
 case 'go_first':
     $_REQUEST['list'] = 1;
     break;
Пример #4
0
$db_name = EZSQL_DB_NAME;
//---- Your database name.
$db_user = EZSQL_DB_USER;
//---- Your database username.
$db_pass = EZSQL_DB_PASSWORD;
//---- Your database password.
$dowhat = "backup";
//$dowhat = "restore";
if ($dowhat == "backup") {
    // This code doesn't export dates
    //$structure_only = false;
    //$output = "./backup/backup_data.txt";
    //$backup = new mysql_backup($db_host,$db_name,$db_user,$db_pass,$output,$structure_only);
    //$backup->backup();
    require_once "../libs/backup/mysql_backup/init.php";
    $b = new backup();
    $b->dbconnect($GonxAdmin["dbhost"], $GonxAdmin["dbuser"], $GonxAdmin["dbpass"], $GonxAdmin["dbname"], "", $GonxAdmin["dbtype"]);
    $b->generate();
    $structure_only = true;
    $output = "./backup/MySQL-Structure-Backup-" . $b->filename;
    $backup = new mysql_backup($db_host, $db_name, $db_user, $db_pass, $output, $structure_only);
    $backup->backup();
}
if ($dowhat == "restore") {
    $output = "./backup/backup_structure.txt";
    $backup = new mysql_backup($db_host, $db_name, $db_user, $db_pass, $output, $structure_only);
    $backup->restore(";");
    $output = "./backup/backup_data.txt";
    $backup = new mysql_backup($db_host, $db_name, $db_user, $db_pass, $output, $structure_only);
    $backup->restore(");");
}
Пример #5
0
 function cleanup($VAR)
 {
     $alert = false;
     /*
               cleanup:  sessions
                         session auth cache
                         searches
                         saved searches
                         old task logs
                         old error logs
                         old login logs
                         old login locks
                         old temporary data
                         old backups
                         expired groups
     */
     $clean = array(array('table' => 'log_error', 'field' => 'date_orig', 'where' => '<=', 'cond' => time() - 86400 * AGILE_LOG_ERR_EXPIRE_DAYS), array('table' => 'login_log', 'field' => 'date_orig', 'where' => '<=', 'cond' => time() - 86400 * AGILE_LOGIN_LOGS_EXPIRE_DAYS), array('table' => 'session_auth_cache', 'field' => 'date_expire', 'where' => '<=', 'cond' => time()), array('table' => 'search', 'field' => 'date_expire', 'where' => '<=', 'cond' => time()), array('table' => 'search_saved', 'field' => 'date_expire', 'where' => '<=', 'cond' => time()), array('table' => 'login_lock', 'field' => 'date_expire', 'where' => '<=', 'cond' => time()), array('table' => 'temporary_data', 'field' => 'date_expire', 'where' => '<=', 'cond' => time()));
     for ($i = 0; $i < count($clean); $i++) {
         $db =& DB();
         $sql = "DELETE FROM " . AGILE_DB_PREFIX . "" . $clean[$i]['table'] . " WHERE\n                    site_id             = " . $db->qstr(DEFAULT_SITE) . " AND " . $clean[$i]['field'] . "   != " . $db->qstr('') . " AND " . $clean[$i]['field'] . "   != " . $db->qstr('0') . " AND " . $clean[$i]['field'] . " " . $clean[$i]['where'] . " " . $db->qstr($clean[$i]['cond']);
         $result = $db->Execute($sql);
     }
     ########################################################################
     ### Remove old sessions
     ########################################################################
     $sql = "DELETE FROM " . AGILE_DB_PREFIX . "session WHERE\n        \t\tsite_id     = " . $db->qstr(DEFAULT_SITE) . " AND\n        \t\tdate_last\t< " . $db->qstr(time() - 86400 * AGILE_SESS_EXPIRE_DAYS) . "   \n                AND\n                ( \n                \taffiliate_id IS NULL OR\n                \taffiliate_id = '' OR\n                \taffiliate_id = 0 OR\n                \tcampaign_id IS NULL OR\n                \tcampaign_id = '' OR\n                \tcampaign_id = 0 OR\n                \tdate_last\t< " . $db->qstr(time() - 86400 * AGILE_SESS_AFFIL_EXPIRE_DAYS) . "\n                )";
     $result = $db->Execute($sql);
     ########################################################################
     ### Remove expired group access
     ########################################################################
     $sql = "DELETE FROM " . AGILE_DB_PREFIX . "account_group WHERE\n                site_id        = " . $db->qstr(DEFAULT_SITE) . " AND\n                date_expire IS NOT NULL AND\n                date_expire > 0 AND\n                date_expire <= " . $db->qstr(time());
     $result = $db->Execute($sql);
     ########################################################################
     ### Remove old backups
     ########################################################################
     $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "backup WHERE\n                site_id        = " . $db->qstr(DEFAULT_SITE) . " AND\n                date_expire   != " . $db->qstr('') . " AND\n                date_expire   != " . $db->qstr('0') . " AND\n                date_expire   != " . $db->qstr(time());
     $result = $db->Execute($sql);
     if ($result != false && $result->RecordCount() > 0) {
         while (!$result->EOF) {
             ## Delete this one..
             $arr["delete_id"] = $result->fields['id'];
             include_once PATH_MODULES . 'backup/backup.inc.php';
             $backup = new backup();
             $backup->delete($arr, $backup);
             $result->MoveNext();
         }
     }
     #########################################################################
     ### Repair/optimize DB Tables (MYSQL ONLY!)
     #########################################################################
     if (AGILE_DB_TYPE == 'mysql') {
         $db =& DB();
         $q = "SELECT name FROM " . AGILE_DB_PREFIX . "module WHERE site_id = " . $db->qstr(DEFAULT_SITE);
         $rs = $db->Execute($q);
         while (!$rs->EOF) {
             $table = $rs->fields['name'];
             $sql = "CHECK TABLE " . AGILE_DB_PREFIX . $table;
             $rscheck = $db->Execute($sql);
             if ($rscheck && $rscheck->fields['Msg_type'] == 'status' && $rscheck->fields['Msg_text'] == 'OK') {
                 $sql = "ANALYZE TABLE " . AGILE_DB_PREFIX . $table;
                 $db->Execute($sql);
             } else {
                 $sql = "REPAIR TABLE " . AGILE_DB_PREFIX . $table;
                 $db->Execute($sql);
                 $sql = "OPTIMIZE TABLE " . AGILE_DB_PREFIX . $table;
                 $db->Execute($sql);
             }
             $rs->MoveNext();
         }
     }
     #########################################################################
     ### Force the correct id keys in each table that has unique ids
     #########################################################################
     $sql = "SELECT name FROM " . AGILE_DB_PREFIX . "module WHERE\n                site_id  = " . $db->qstr(DEFAULT_SITE) . " AND\n                status   = " . $db->qstr('1') . " \n\t\t\t\tORDER BY name";
     $rs = $db->Execute($sql);
     while (!$rs->EOF) {
         $module = $rs->fields['name'];
         # check if key table exists:
         $sql = "SELECT id FROM " . AGILE_DB_PREFIX . $module . "_id ORDER BY id DESC";
         $keytable = $db->Execute($sql);
         if ($module != 'session' && $module != 'affiliate' && $keytable != false && $keytable->RecordCount() > 0) {
             $current_id = $keytable->fields['id'];
             # get the current id from the main table:
             $sql = "SELECT id FROM " . AGILE_DB_PREFIX . $module . " ORDER BY id DESC";
             $table = $db->Execute($sql);
             if ($table != false && $table->RecordCount() > 0) {
                 $last_id = $table->fields['id'];
                 # does key need updated?
                 if ($current_id < $last_id) {
                     $id = $last_id + 1;
                     $sql = "UPDATE " . AGILE_DB_PREFIX . $module . "_id\n\t\t\t\t\t\t\t\tSET \n\t\t\t\t\t\t\t\tid = " . $db->qstr($id) . " \n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tid = " . $db->qstr($current_id);
                     $db->Execute($sql);
                     $alert .= "Corrected incorrect primary key on the <u>{$module}</u> table.<br>";
                 }
             }
         }
         $rs->MoveNext();
     }
     #########################################################################
     ### Run any new upgrade files in the /upgrades directory
     #########################################################################
     @($dir = opendir(PATH_AGILE . 'upgrades'));
     while (@($file_name = readdir($dir))) {
         $display = true;
         if ($file_name != '..' && $file_name != '.') {
             # check if upgrade has been run:
             $md5 = md5($file_name);
             $sql = "SELECT data FROM " . AGILE_DB_PREFIX . "temporary_data\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\tdata = " . $db->qstr($md5) . " AND\n\t\t\t\t\t\tfield1 = " . $db->qstr('upgrade');
             $rs = $db->Execute($sql);
             if ($rs->RecordCount() == 0) {
                 # Run the upgrade:
                 if (is_file(PATH_AGILE . 'upgrades/' . $file_name) && !is_dir(PATH_AGILE . 'upgrades/' . $file_name)) {
                     include_once PATH_AGILE . 'upgrades/' . $file_name;
                 }
                 $function = strtolower(preg_replace('/.php/', '', $file_name));
                 if (preg_match('/^upgrade/', $function)) {
                     if (is_callable($function)) {
                         $result = call_user_func($function);
                         #$result = true;
                     } else {
                         $result = false;
                     }
                 }
                 # If success, save so it is not run again:
                 if ($result) {
                     /* Start: SQL Insert Statement */
                     $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "temporary_data WHERE id = -1";
                     $rs = $db->Execute($sql);
                     $id = $db->GenID(AGILE_DB_PREFIX . 'temporary_data_id');
                     $insert = array('id' => $id, 'site_id' => DEFAULT_SITE, 'data' => $md5, 'field1' => 'upgrade', 'date_orig' => time(), 'date_expire' => time() + 86400 * 365 * 20);
                     $sql = $db->GetInsertSQL($rs, $insert);
                     $result = $db->Execute($sql);
                     if ($result === false) {
                         global $C_debug;
                         $C_debug->error('core.inc.php', 'core :: cleanup()', $db->ErrorMsg() . "\r\n\r\n" . $sql);
                     }
                     /* End: SQL Insert Statement */
                     $alert .= "Upgraded to <u>{$file_name}</u>!<br>";
                 } else {
                     $alert .= "The <u>{$file_name}</u> upgrade failed!<br>";
                 }
             }
         }
     }
     #########################################################################
     ## Print any alerts:
     #########################################################################
     if (!empty($alert)) {
         global $C_debug;
         $C_debug->alert($alert);
     }
     return true;
 }
// |                                                                 |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of  |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   |
// | GNU General Public License for more details.                    |
// +-----------------------------------------------------------------+
//  Path: /modules/xml_builder/pages/main/pre_process.php
//
// This script updates the xml module information file
$security_level = validate_user(SECURITY_ID_XML_BUILDER);
/**************  include page specific files    *********************/
require_once DIR_FS_WORKING . 'classes/xml_builder.php';
require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
/**************   page specific initialization  *************************/
$working = new xml_builder();
$mod_xml = new backup();
/***************   Act on the action request   *************************/
switch ($_REQUEST['action']) {
    case 'save':
        validate_security($security_level, 2);
        // read the input variables
        $mod = $_POST['mod'];
        $mod_admin = $mod . '_admin';
        require_once DIR_FS_MODULES . $mod . '/classes/install.php';
        $mod_info = new $mod_admin();
        // read the existing xml file to set as base, if it exists
        if (file_exists(DIR_FS_MODULES . $mod . '/' . $mod . '.xml')) {
            $working->output = xml_to_object(file_get_contents(DIR_FS_MODULES . $mod . '/' . $mod . '.xml'));
            // fix some lists
            if (!is_array($working->output->Module->Table)) {
                $working->output->Module->Table = array($working->output->Module->Table);
Пример #7
0
 function except($p_event, &$p_header)
 {
     return backup::skipAddingFilesToArchive($p_event, $p_header);
 }
    	$arrNamePage[] = array('name' => MENU_CONFIG, 'link' => false);
    
    	if (isset($_POST['save'])) // сохраняем данные, переданные из формы
    	{
    		$data = "<?php\n\n"
    			  . "(!defined('SDG')) ? die ('Triple protection!') : null;\n\n"
    			  . 'define("CONF_BACKUPS_PATH_TO_FILES", "' . filesys::setPath($_POST['path']) . '");' . "\n";
    
       		if (!tools::saveConfig('core/conf/const.config.backups.php', $data, CONF_ADMIN_FILE . '?m=system&s=backups&action=config'))
    		{
    			$arrErrors[] = ERROR_FILES_MISSING_FILE;
    		}
    	}
    */
} else {
    /**
     * удаление файлов
     */
    if (isset($_POST['action'])) {
        if ('del' === $_POST['action'] && !empty($_POST['files'])) {
            foreach ($_POST['files'] as $key => $value) {
                unlink($key);
            }
            messages::messageChangeSaved(MESSAGE_CHANGE_SAVED, false, CONF_ADMIN_FILE . '?m=system&s=backups');
        }
    }
    $arrFiles = backup::getBackupFiles();
    $smarty->assignByRef('arrFiles', $arrFiles);
}
$smarty->assignByRef('errors', $arrErrors);
$smarty->assignByRef('action', $arrActions);
Пример #9
0
// +-----------------------------------------------------------------+
//  Path: /modules/shipping/methods/fedex_v7/generate_sample.php
//
/**************   Check user security   *****************************/
// none
/**************  include page specific files    *********************/
load_method_language(DIR_FS_WORKING . 'methods/', 'fedex_v7');
require DIR_FS_WORKING . 'defaults.php';
require DIR_FS_WORKING . 'functions/shipping.php';
require DIR_FS_WORKING . 'classes/shipping.php';
require DIR_FS_MODULES . 'phreedom/classes/backup.php';
require DIR_FS_WORKING . 'methods/fedex_v7/fedex_v7.php';
require DIR_FS_WORKING . 'methods/fedex_v7/sample_data.php';
/**************   page specific initialization  *************************/
$error = false;
$backup = new backup();
$backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/temp/fedex_qual/';
$backup->dest_dir = DIR_FS_MY_FILES . 'backups/';
$backup->dest_file = 'fedex_qual.zip';
/***************   Act on the action request   *************************/
// retrieve the sample ship to addresses and query FEDEX_V7
$count = 1;
foreach ($shipto as $pkg) {
    $sInfo = new shipment();
    // load defaults
    while (list($key, $value) = each($pkg)) {
        $sInfo->{$key} = db_prepare_input($value);
    }
    $sInfo->ship_date = date('Y-m-d', strtotime($sInfo->ship_date));
    // load package information
    $sInfo->package = array();
Пример #10
0
<?php

/**
 * 数据表优化文件
 *
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	admin
 */
require_once '../config/config.inc.php';
require_once '../checklogin.php';
require_once 'class/backup.class.php';
$objWebInit = new backup();
//smarty参数
$objWebInit->arrGSmarty = $arrGSmarty;
//数据库连接参数
$objWebInit->setDBG($arrGPdoDB);
$objWebInit->db();
//访问权限检查
if (!$objWebInit->checkPopedomG($_SESSION['user_id'], 'r', 'backup')) {
    check::AlertExit('对不起,您没有读权限', -1);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!$objWebInit->checkPopedomG($_SESSION['user_id'], 'x', 'backup')) {
        check::AlertExit('对不起,您没有执行权限', -1);
    }
    $arrTables = $objWebInit->get_table();
    foreach ($arrTables as $k => $table) {
        if ($objWebInit->db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
Пример #11
0
// | but WITHOUT ANY WARRANTY; without even the implied warranty of  |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   |
// | GNU General Public License for more details.                    |
// +-----------------------------------------------------------------+
//  Path: /modules/translator/pages/main/pre_process.php
//
$security_level = validate_user(SECURITY_TRANSLATOR_MGT);
/**************  include page specific files    *********************/
gen_pull_language('phreedom', 'admin');
require_once DIR_FS_WORKING . 'functions/translator.php';
require_once DIR_FS_WORKING . 'classes/translator.php';
require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
/**************   page specific initialization  *************************/
$error = false;
$translator = new translator();
$backup = new backup();
$replace = array();
$criteria = array();
history_filter();
// load the filters
$f0 = isset($_POST['action']) ? $_POST['f0'] : $_GET['f0'];
$f1 = isset($_POST['action']) ? $_POST['f1'] : $_GET['f1'];
$f2 = isset($_POST['action']) ? $_POST['f2'] : $_GET['f2'];
$f3 = isset($_POST['action']) ? $_POST['f3'] : $_GET['f3'];
/***************   Act on the action request   *************************/
switch ($_REQUEST['action']) {
    case 'import_go':
        // imports existing language file constants from current install
        $mod = db_prepare_input($_POST['mod']);
        $lang = db_prepare_input($_POST['lang']);
        switch ($mod) {
Пример #12
0
<?php

/**
 * 后台管理栏目基本设置文件
 *
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	admin
 */
require_once '../config/config.inc.php';
require_once '../checklogin.php';
require_once 'class/backup.class.php';
$objWebInit = new backup();
//smarty参数
$objWebInit->arrGSmarty = $arrGSmarty;
//数据库连接参数
$objWebInit->setDBG($arrGPdoDB);
$objWebInit->db();
//访问权限检查
if (!$objWebInit->checkPopedomG($_SESSION['user_id'], 'r', 'backup')) {
    check::AlertExit('对不起,您没有读权限', -1);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!$objWebInit->checkPopedomG($_SESSION['user_id'], 'x', 'backup')) {
        check::AlertExit('对不起,您没有执行权限', -1);
    }
    if (empty($_FILES['Filedata']['name'])) {
        check::AlertExit("必须上传.sql文件 !", -1);
    }
Пример #13
0
         default:
             $backup->dest_file = $backup->source_file;
             @rename($backup->source_dir . $backup->source_file, $backup->dest_dir . $backup->dest_file);
             break;
     }
     if (!$error) {
         gen_add_audit_log(GEN_DB_DATA_BACKUP);
         $backup->download($backup->dest_dir, $backup->dest_file, $save_local);
         // will not return if successful
     }
     break;
 case 'backup_log':
     if (ini_get('max_execution_time') < 20000) {
         set_time_limit(20000);
     }
     $backup = new backup();
     $backup->db_filename = 'log-' . $_SESSION['company'] . '-' . date('Ymd');
     $backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/';
     $backup->source_file = $backup->db_filename . '.sql';
     $backup->dest_dir = DIR_FS_MY_FILES . 'backups/';
     $backup->dest_file = $backup->db_filename . '.zip';
     if (!($result = $backup->dump_db_table($db, TABLE_AUDIT_LOG, 'both'))) {
         break;
     }
     $backup->make_zip('file');
     if (file_exists($backup->source_dir . $backup->source_file)) {
         unlink($backup->source_dir . $backup->source_file);
     }
     if (!$error) {
         gen_add_audit_log(GEN_AUDIT_DB_DATA_BACKUP);
         $backup->download($backup->dest_dir, $backup->dest_file, false);
Пример #14
0
function main_share_retranslation_save()
{
    $bck = new backup();
    if (isset($_GET["index"])) {
        $bck->MountBackup[$_GET["index"]] = "{$_GET["servername"]};{$_GET["share_folder"]};{$_GET["username"]};{$_GET["password"]};{$_GET["domain"]}";
    } else {
        $bck->MountBackup[] = "{$_GET["servername"]};{$_GET["share_folder"]};{$_GET["username"]};{$_GET["password"]};{$_GET["domain"]}";
    }
    if ($bck->SaveToLdap()) {
        $tpl = new templates();
        echo $tpl->_ENGINE_parse_body('Share:{success}');
    } else {
        echo $bck->ldap_error;
    }
}
Пример #15
0
         $_SESSION['db_server'] = $db_server;
         $_SESSION['company'] = $db_name;
         $_SESSION['db_user'] = $db_user;
         $_SESSION['db_pw'] = $db_pw;
         gen_redirect(html_href_link(FILENAME_DEFAULT, $get_parmas, ENABLE_SSL_ADMIN ? 'SSL' : 'NONSSL'));
     } else {
         // restore db connection
         $db = new queryFactory();
         $db->connect(DB_SERVER_HOST, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE);
     }
     $default_tab_id = 'manager';
     break;
 case 'delete_co':
     $db_name = $_SESSION['companies'][$_POST['del_company']];
     // Failsafe to prevent current company from being deleted accidently
     $backup = new backup();
     if ($db_name == 'none') {
         $error = $messageStack->add(SETUP_CO_MGR_NO_SELECTION, 'error');
     }
     if (!$error && $db_name != $_SESSION['company']) {
         // connect to other company, retrieve login info
         $config = file(DIR_FS_MY_FILES . $db_name . '/config.php');
         foreach ($config as $line) {
             if (strpos($line, 'DB_SERVER_USERNAME')) {
                 $db_user = substr($line, strpos($line, ",") + 1, strpos($line, ")") - strpos($line, ",") - 1);
             } elseif (strpos($line, 'DB_SERVER_PASSWORD')) {
                 $db_pw = substr($line, strpos($line, ",") + 1, strpos($line, ")") - strpos($line, ",") - 1);
             } elseif (strpos($line, 'DB_SERVER_HOST')) {
                 $db_server = substr($line, strpos($line, ",") + 1, strpos($line, ")") - strpos($line, ",") - 1);
             }
         }
Пример #16
0
            $messageStack->write_debug();
        }
        $cInfo = new objectInfo($_POST);
        // if we are here, there was an error, reload page
        $cInfo->post_date = gen_db_date($_POST['post_date']);
        break;
    case 'edit':
        $oID = (int) $_GET['oID'];
        validate_security($security_level, 2);
        $cInfo = new objectInfo(array());
        break;
    case 'dn_attach':
        $oID = db_prepare_input($_POST['id']);
        if (file_exists(PHREEBOOKS_DIR_MY_ORDERS . 'order_' . $oID . '.zip')) {
            require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
            $backup = new backup();
            $backup->download(PHREEBOOKS_DIR_MY_ORDERS, 'order_' . $oID . '.zip', true);
        }
        die;
    default:
}
/*****************   prepare to display templates  *************************/
// retrieve the list of gl accounts and fill js arrays
$gl_array_list = gen_coa_pull_down();
$i = 0;
$js_gl_array = 'var js_gl_array = new Array();' . chr(10);
foreach ($gl_array_list as $account) {
    $is_asset = $coa_types_list[$account['type']]['asset'] ? '1' : '0';
    $js_gl_array .= 'js_gl_array[' . $i . '] = new glProperties("' . $account['id'] . '", "' . $account['text'] . '", "' . $is_asset . '");' . chr(10);
    $i++;
}
Пример #17
0
 function load_demo()
 {
     global $db;
     $error = false;
     // Data for table inventory
     $db->Execute("TRUNCATE TABLE " . TABLE_INVENTORY);
     $db->Execute("INSERT INTO " . TABLE_INVENTORY . " (sku, inactive, inventory_type, description_short, description_sales, image_with_path, account_sales_income, account_inventory_wage, account_cost_of_sales, item_taxable, cost_method, full_price, full_price_with_tax, item_weight, quantity_on_hand, minimum_stock_level, reorder_quantity, lead_time, creation_date ) VALUES\n('AMD-3600-CPU',\t\t'0', 'si', 'AMD 3600+ Athlon CPU', \t\t\t'AMD 3600+ Athlon CPU',\t\t\t'demo/athlon.jpg', \t\t'4000', '1200', '5000', '1', 'f', 150,\t150, \t\t1.5, \t1,   0,  0,  3, now()),\n('ASSY-BB', \t\t'0', 'lb', 'Labor - BB Computer Assy', \t\t'Labor - BB Computer Assy',\t\t'', \t\t\t\t\t'4000', '6000', '5000', '1', 'f',   0,   \t0, \t\t0,    0,   0,  0,  0, now()),\n('BOX-TW-322', \t\t'0', 'ns', 'TW-322 Shipping Box', \t\t\t'TW-322 Shipping Box', \t\t\t'', \t\t\t\t\t'4000', '6800', '5000', '1', 'f',   0,   \t0, \t\t0,    0,  15, 25,  0, now()),\n('BOX-TW-553', \t\t'0', 'ns', 'TW-533 Shipping Box', \t\t\t'TW-533 Shipping Box', \t\t\t'', \t\t\t\t\t'4000', '6800', '5000', '1', 'f',   0,   \t0, \t\t0,    0,   0,  0,  0, now()),\n('CASE-ALIEN', \t\t'0', 'si', 'Alien Case - Red', \t\t\t'Alien Case - Red', \t\t\t'demo/red_alien.jpg', \t\t'4000', '1200', '5000', '1', 'f', 98.26,\t98.26, \t1.5, 11,   2,  1, 13, now()),\n('DESC-WARR', \t\t'0', 'ds', 'Warranty Template', \t\t\t'Warranty Template', \t\t\t'', \t\t\t\t\t'1000', '1000', '1000', '1', 'f',   0, \t0, \t\t0,   \t0,   0,  0,  0, now()),\n('DVD-RW', \t\t\t'0', 'si', 'DVD RW with Lightscribe', \t\t'DVD RW with Lightscribe', \t\t'demo/lightscribe.jpg',\t\t'4000', '1200', '5000', '1', 'f',   45, \t45, \t\t1.5, \t2,   3,  1, 15, now()),\n('HD-150GB', \t\t'0', 'si', '150GB SATA Hard Drive', \t\t'150GB SATA Hard Drive', \t\t'demo/150gb_sata.jpg', \t\t'4000', '1200', '5000', '1', 'f', \t56, \t56, \t\t1.5, \t2,  10, 15, 15, now()),\n('KB-128-ERGO', \t\t'0', 'si', 'KeysRus ergonomic keyboard', \t\t'KeysRus ergonomic keyboard', \t'demo/ergo_key.jpg', \t\t'4000', '1200', '5000', '0', 'f', 56.88, \t56.88, \t1.5, \t0,   5, 10, 11, now()),\n('LCD-21-WS', \t\t'0', 'si', 'LCDisplays 21\" LCD Monitor',\t \t'LCDisplays 21\" LCD Monitor',\t'demo/monitor.jpg', \t\t'4000', '1200', '5000', '1', 'f', 189.99, 189.99, \t1.5, \t0,   2,  1,  5, now()),\n('MB-ATI-K8', \t\t'0', 'si', 'ATI K8 Motherboard', \t\t\t'ATI K8 Motherboard', \t\t\t'demo/mobo.jpg', \t\t\t'4000', '1200', '5000', '1', 'f', 155.25, 155.25, \t1.5, \t1,   5, 10,  3, now()),\n('MB-ATI-K8N', \t\t'0', 'si', 'ATI K8 Motherboard w/network', \t'ATI K8 Motherboard w/network', \t'demo/mobo.jpg', \t\t\t'4000', '1200', '5000', '1', 'f', 176.94, 176.94,\t1.5, 1.2,  3, 10,  3, now()),\n('Mouse-S', \t\t'0', 'si', 'Serial Mouse - 300 DPI', \t\t'Serial Mouse - 300 DPI', \t\t'demo/serial_mouse.jpg',\t'4000', '1200', '5000', '1', 'f', 13.99, \t13.99, \t1.5, 0.6, 15, 25, 11, now()),\n('PC-2GB-120GB-21', \t'0', 'ma', 'Computer 2GB-120GB-21', \t\t'Computer 2GB-120GB-21', \t\t'demo/complete_computer.jpg', '4000', '1200', '5000', '1', 'f', 750, \t750, \t\t1.5, 21.3, 0,  0,  0, now()),\n('PS-450W', \t\t'0', 'si', '450 Watt Silent Power Supply', \t'450 Watt Silent Power Supply', \t'demo/power_supply.jpg', \t'4000', '1200', '5000', '1', 'f', 124.5, \t124.5, \t1.5, 4.7, 10,  6, 14, now()),\n('RAM-2GB-0.2', \t\t'0', 'si', '2GB SDRAM', \t\t\t\t'2GB SDRAM', \t\t\t\t'demo/2gbram.jpg', \t\t'4000', '1200', '5000', '1', 'f', 89.65, \t89.65, \t1.5, \t0,   8, 10,  3, now()),\n('VID-NV-512MB', \t\t'0', 'si', 'nVidia 512 MB Video Card', \t\t'nVidia 512 MB Video Card', \t\t'demo/nvidia_512.jpg', \t\t'4000', '1200', '5000', '1', 'f', 300, \t300, \t\t1.5, 0.7,  4,  5,  1, now()),\n('PC-BB-512', \t\t'0', 'ma', 'Bare Bones Computer 2600+/2GB', \t'Bare Bones Computer 2600+/2GB', \t'demo/barebones.jpg', \t\t'4000', '1200', '5000', '1', 'f', 750, \t750, \t\t1.5, 21.3, 0,  0,  0, now());");
     // Data for table inventory_assy_list
     $db->Execute("TRUNCATE TABLE " . TABLE_INVENTORY_ASSY_LIST);
     $db->Execute("INSERT INTO " . TABLE_INVENTORY_ASSY_LIST . " (ref_id, sku, description, qty) VALUES\n(14, 'LCD-21-WS', 'LCDisplays 21', 1),\n(14, 'HD-150GB', '150GB SATA Hard Drive', 1),\n(14, 'DVD-RW', 'DVD RW with Lightscribe', 1),\n(14, 'VID-NV-512MB', 'nVidea 512 MB Video Card', 1),\n(14, 'RAM-2GB-0.2', '2GB SDRAM', 2),\n(14, 'AMD-3600-CPU', 'AMD 3600+ Athlon CPU', 1),\n(14, 'MB-ATI-K8N', 'ATI K8 Motherboard w/network', 1),\n(14, 'CASE-ALIEN', 'Alien Case - Red', 1),\n(14, 'Mouse-S', 'Serial Mouse - 300 DPI', 1),\n(14, 'KB-128-ERGO', 'KeysRus ergonomic keyboard', 1),\n(18, 'RAM-2GB-0.2', '2GB SDRAM', 2),\n(18, 'AMD-3600-CPU', 'AMD 3600+ Athlon CPU', 1),\n(18, 'MB-ATI-K8N', 'ATI K8 Motherboard w/network', 1),\n(18, 'CASE-ALIEN', 'Alien Case - Red', 1),\n(18, 'VID-NV-512MB', 'nVidea 512 MB Video Card', 1);");
     // data for table inventory_purchase_details
     $db->Execute("TRUNCATE TABLE " . TABLE_INVENTORY_PURCHASE);
     $db->Execute("INSERT INTO " . TABLE_INVENTORY_PURCHASE . " (sku, vendor_id, description_purchase, purch_taxable, item_cost) VALUES\n('AMD-3600-CPU', 3, 'AMD 3600+ Athlon CPU', 0, 100),\n('ASSY-BB', 0, 'Labor Cost - Assemble Bare Bones Computer', 0, 25),\n('BOX-TW-322', 0, 'TW-322 Shipping Box - 12 x 12 x 12', 0, 1.35),\n('BOX-TW-553', 0, 'TW-533 Shipping Box - 24 x 12 x 12', 0, 1.75),\n('CASE-ALIEN', 13, 'Closed Cases - Red Full Tower ATX case w/o power supply', 0, 47),\n('DESC-WARR', 0, 'Warranty Template', 0, 0),\n('DVD-RW', 15, 'DVD RW with Lightscribe - 8x', 0, 23.6),\n('HD-150GB', 15, '150GB SATA Hard Drive - 7200 RPM', 0, 27),\n('KB-128-ERGO', 11, 'KeysRus ergonomic keyboard - Lighted for Gaming', 1, 23.51),\n('LCD-21-WS', 5, 'LCDisplays 21\" LCD Monitor - wide screen w/anti-glare finish, Black', 0, 145.01),\n('MB-ATI-K8', 3, 'ATI-K8-TW AMD socket 939 Motherboard for Athlon Processors', 0, 125),\n('MB-ATI-K8N', 3, 'ATI-K8-TW AMD socket 939 Motherboard for Athlon Processors with network ports', 0, 135),\n('Mouse-S', 11, 'Serial Mouse - 300 DPI', 0, 4.85),\n('PC-2GB-120GB-21', 0, 'Fully assembled computer AMD/ATI 2048GB Ram/1282 GB HD/Red Case/ Monitor/ Keyboard/ Mouse', 0, 0),\n('PS-450W', 14, '850 Watt Silent Power Supply - for use with Intel or AMD processors', 0, 86.26),\n('RAM-2GB-0.2', 3, '2 GB PC3200 Memory Modules - for Athlon processors', 0, 56.25),\n('VID-NV-512MB', 1, 'nVidea 512 MB Video Card - with SLI support', 0, 0),\n('PC-BB-512', 0, 'Fully assembled bare bones computer AMD/ATI 512MB/2GB/Red Case', 0, 0);\n\t");
     // copy the demo images
     require DIR_FS_MODULES . 'phreedom/classes/backup.php';
     $backups = new backup();
     if (!is_dir(DIR_FS_MY_FILES . $_SESSION['company'] . '/inventory/images/demo')) {
         if (!@mkdir(DIR_FS_MY_FILES . $_SESSION['company'] . '/inventory/images/demo')) {
             $error = true;
         }
     }
     $dir_source = DIR_FS_MODULES . 'inventory/images/demo/';
     $dir_dest = DIR_FS_MY_FILES . $_SESSION['company'] . '/inventory/images/demo/';
     $backups->copy_dir($dir_source, $dir_dest);
     return $error;
 }
Пример #18
0
            $_SESSION["message"] = $text['message-backup_failed_format'];
            header("Location: " . $_SERVER['PHP_SELF']);
            exit;
        }
    } else {
        //set response message
        $_SESSION["message"] = $text['message-backup_failed_paths'];
        header("Location: " . $_SERVER['PHP_SELF']);
        exit;
    }
}
//script a backup (cron)
if ($_GET['a'] == "script" && permission_exists('backup_download')) {
    $file_format = $_GET['file_format'];
    $target_type = "script";
    $backup = new backup();
    $command = $backup->command("backup", $file_format);
}
//restore a backup
if ($_POST['a'] == "restore" && permission_exists('backup_upload')) {
    $backup_path = $_SESSION['server']['backup']['path'] != '' ? $_SESSION['server']['backup']['path'] : '/tmp';
    $backup_file = $_FILES['backup_file']['name'];
    if (is_uploaded_file($_FILES['backup_file']['tmp_name'])) {
        //move temp file to backup path
        move_uploaded_file($_FILES['backup_file']['tmp_name'], $backup_path . '/' . $backup_file);
        //determine file format and restore backup
        $file_format = pathinfo($_FILES['backup_file']['name'], PATHINFO_EXTENSION);
        $valid_format = true;
        switch ($file_format) {
            case "rar":
                $cmd = 'rar x -ow -o+ ' . $backup_path . '/' . $backup_file . ' /';
Пример #19
0
                }
                break;
        }
        if (!$error) {
            gen_add_audit_log(GEN_DB_DATA_BACKUP, TABLE_AUDIT_LOG);
            $backup->download($backup->dest_dir, $backup->dest_file);
            // will not return if successful
        }
        $default_tab_id = 'tools';
        break;
    case 'clean':
        $carrier = db_prepare_input($_POST['carrier']);
        $fy_month = db_prepare_input($_POST['fy_month']);
        $fy_year = db_prepare_input($_POST['fy_year']);
        $conv_type = db_prepare_input($_POST['conv_type']);
        $backup = new backup();
        $backup->source_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/shipping/labels/' . $carrier . '/' . $fy_year . '/' . $fy_month . '/';
        if ($backup->delete_dir($backup->source_dir, $recursive = true)) {
            $error = true;
        }
        if (!$error) {
            gen_add_audit_log(GEN_FILE_DATA_CLEAN);
        }
        $default_tab_id = 'tools';
        break;
    default:
}
/*****************   prepare to display templates  *************************/
// build some general pull down arrays
$sel_yes_no = array(array('id' => '0', 'text' => TEXT_NO), array('id' => '1', 'text' => TEXT_YES));
$sel_checked = array(array('id' => '0', 'text' => TEXT_UNCHECKED), array('id' => '1', 'text' => TEXT_CHECKED));
Пример #20
0
<?php

/**
 * 后台管理栏目基本设置文件
 *
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	admin
 */
require_once '../config/config.inc.php';
require_once '../checklogin.php';
require_once 'class/backup.class.php';
$objWebInit = new backup();
//smarty参数
$objWebInit->arrGSmarty = $arrGSmarty;
//数据库连接参数
$objWebInit->setDBG($arrGPdoDB);
$objWebInit->db();
//访问权限检查
if (!$objWebInit->checkPopedomG($_SESSION['user_id'])) {
    check::AlertExit('对不起,您没有权限访问此页', -1);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    @set_time_limit(0);
    /* 系统信息 */
    $sys_info['os'] = PHP_OS;
    $sys_info['web_server'] = $_SERVER['SERVER_SOFTWARE'];
    $sys_info['php_ver'] = PHP_VERSION;
    $sys_info['mysql_ver'] = $objWebInit->get_ver();
Пример #21
0
function saveUploadZip($file_field, $dest_dir, $dest_name)
{
    global $messageStack;
    if ($_FILES[$file_field]['error']) {
        // php error uploading file
        $messageStack->add(TEXT_IMP_ERMSG5 . $_FILES[$file_field]['error'], 'error');
    } elseif ($_FILES[$file_field]['size'] > 0) {
        require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
        $backup = new backup();
        $backup->source_dir = $_FILES[$file_field]['tmp_name'];
        $backup->source_file = '';
        $backup->dest_dir = $dest_dir;
        $backup->dest_file = $dest_name;
        if (file_exists($dest_dir . $dest_name)) {
            @unlink($dest_dir . $dest_name);
        }
        $backup->make_zip('file', $_FILES[$file_field]['name']);
        @unlink($backup->source_dir);
    }
}
Пример #22
0
     if (file_exists(RMA_DIR_ATTACHMENTS . $filename)) {
         require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
         $backup = new backup();
         $backup->download(RMA_DIR_ATTACHMENTS, $filename, true);
     }
     die;
 case 'dn_attach':
     // download from list, assume the first document only
     $cID = db_prepare_input($_POST['rowSeq']);
     $result = $db->Execute("select attachments from " . TABLE_RMA . " where id = " . $cID);
     $attachments = unserialize($result->fields['attachments']);
     foreach ($attachments as $key => $value) {
         $filename = 'rma_' . $cID . '_' . $key . '.zip';
         if (file_exists(RMA_DIR_ATTACHMENTS . $filename)) {
             require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
             $backup = new backup();
             $backup->download(RMA_DIR_ATTACHMENTS, $filename, true);
             die;
         }
     }
     break;
 case 'go_first':
     $_REQUEST['list'] = 1;
     break;
 case 'go_previous':
     $_REQUEST['list'] = max($_REQUEST['list'] - 1, 1);
     break;
 case 'go_next':
     $_REQUEST['list']++;
     break;
 case 'go_last':
Пример #23
0
     if (file_exists(ASSETS_DIR_ATTACHMENTS . $filename)) {
         require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
         $backup = new backup();
         $backup->download(ASSETS_DIR_ATTACHMENTS, $filename, true);
     }
     die;
 case 'dn_attach':
     // download from list, assume the first document only
     $cID = db_prepare_input($_POST['rowSeq']);
     $result = $db->Execute("select attachments from " . TABLE_ASSETS . " where id = " . $cID);
     $attachments = unserialize($result->fields['attachments']);
     foreach ($attachments as $key => $value) {
         $filename = 'assets_' . $cID . '_' . $key . '.zip';
         if (file_exists(ASSETS_DIR_ATTACHMENTS . $filename)) {
             require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
             $backup = new backup();
             $backup->download(ASSETS_DIR_ATTACHMENTS, $filename, true);
             die;
         }
     }
     break;
 case 'go_first':
     $_REQUEST['list'] = 1;
     break;
 case 'go_previous':
     $_REQUEST['list'] = max($_REQUEST['list'] - 1, 1);
     break;
 case 'go_next':
     $_REQUEST['list']++;
     break;
 case 'go_last':
Пример #24
0
<?php

/**
* This file is part of MajorDoMo system. More details at http://smartliving.ru/
*
* @package MajorDoMo
* @author Serge Dzheigalo <*****@*****.**> http://smartliving.ru/
* @version 1.1
*/
include_once "./config.php";
include_once "./lib/loader.php";
// start calculation of execution time
startMeasure('TOTAL');
include_once DIR_MODULES . "application.class.php";
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
include_once "./load_settings.php";
include_once DIR_MODULES . 'backup/backup.class.php';
$b = new backup();
$b->create_backup();
echo "DONE";
// closing database connection
$db->Disconnect();
// end calculation of execution time
endMeasure('TOTAL');
// print performance report
performanceReport();
Пример #25
0
 case "config":
     $b = new backup();
     $page = $b->configure();
     break;
 case "monitor":
     $b = new backup();
     $b->dbconnect($GonxAdmin["dbhost"], $GonxAdmin["dbuser"], $GonxAdmin["dbpass"], $GonxAdmin["dbname"]);
     $page = $b->monitor();
     break;
 case "saveconfig":
     $b = new backup();
     $b->saveconfig();
     $page = $b->configure();
     break;
 case "getbackup":
     $b = new backup();
     $b->getbackup($bfile);
     break;
 default:
     $page = $GONX['homepage'];
     $db = new db();
     $db->dbconnect($GonxAdmin["dbhost"], $GonxAdmin["dbuser"], $GonxAdmin["dbpass"], $GonxAdmin["dbname"]);
     $page .= $db->signature();
     $table = "<br/><br/><table width=\"100%\" border=\"1\" style=\"border-collapse: collapse\" bordercolor=#CCCCCC>\n\t<tr><td align=\"center\"><b>" . $GONX["compression"] . "</b></td></tr>\n\r";
     foreach ($GonxAdmin["compression"] as $v) {
         $isdef = get_extension_funcs($v);
         if ($isdef) {
             $table .= "\t<tr><td align=\"center\"><font color=green>{$v} " . $GONX["installed"] . "</font></td></tr>\n\r";
         } else {
             $table .= "\t<tr><td align=\"center\"><font color=red>{$v} " . $GONX["notinstalled"] . "</font></td></tr>\n\r";
         }
Пример #26
0
     if (file_exists(CONTACTS_DIR_ATTACHMENTS . $filename)) {
         require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
         $backup = new backup();
         $backup->download(CONTACTS_DIR_ATTACHMENTS, $filename, true);
     }
     die;
 case 'dn_attach':
     // download from list, assume the first document only
     $cID = db_prepare_input($_POST['rowSeq']);
     $result = $db->Execute("select attachments from " . TABLE_CONTACTS . " where id = {$cID}");
     $attachments = unserialize($result->fields['attachments']);
     foreach ($attachments as $key => $value) {
         $filename = 'contacts_' . $cID . '_' . $key . '.zip';
         if (file_exists(CONTACTS_DIR_ATTACHMENTS . $filename)) {
             require_once DIR_FS_MODULES . 'phreedom/classes/backup.php';
             $backup = new backup();
             $backup->download(CONTACTS_DIR_ATTACHMENTS, $filename, true);
             die;
         }
     }
 case 'reset':
     $_SESSION['f0'] = $default_f0;
     break;
 case 'go_first':
     $_REQUEST['list'] = 1;
     break;
 case 'go_previous':
     $_REQUEST['list'] = max($_REQUEST['list'] - 1, 1);
     break;
 case 'go_next':
     $_REQUEST['list']++;
Пример #27
0
function backups_form($item)
{
    global $user;
    global $DB;
    global $website;
    global $layout;
    $navibars = new navibars();
    $naviforms = new naviforms();
    $layout->navigate_media_browser();
    // we can use media browser in this function
    if (empty($item->id)) {
        $navibars->title(t(329, 'Backups') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(329, 'Backups') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    if (empty($item->id)) {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/database_save.png"> ' . t(410, 'Begin backup') . '</a>'));
    } else {
        if ($item->status == 'completed') {
            $navibars->add_actions(array('<a href="#" onclick="navigate_restore_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/database_refresh.png"> ' . t(412, 'Restore') . '</a> '));
        }
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>'));
        $delete_html = array();
        $delete_html[] = '<div id="navigate-delete-dialog" class="hidden">' . t(57, 'Do you really want to delete this item?') . '</div>';
        $delete_html[] = '<script language="javascript" type="text/javascript">';
        $delete_html[] = 'function navigate_delete_dialog()';
        $delete_html[] = '{';
        $delete_html[] = '$("#navigate-delete-dialog").removeClass("hidden");';
        $delete_html[] = '$("#navigate-delete-dialog").dialog({
							resizable: true,
							height: 150,
							width: 300,
							modal: true,
							title: "' . t(59, 'Confirmation') . '",
							buttons: {
								"' . t(58, 'Cancel') . '": function() {
									$(this).dialog("close");
								},
								"' . t(35, 'Delete') . '": function() {
									$(this).dialog("close");
									window.location.href = "?fid=backups&act=4&id=' . $item->id . '";
								}
							}
						});';
        $delete_html[] = '}';
        $delete_html[] = '</script>';
        $navibars->add_content(implode("\n", $delete_html));
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=backups&act=2"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=backups&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
    $navibars->form();
    $navibars->add_tab(t(43, "Main"));
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $navibars->add_tab_content($naviforms->hidden('id', $item->id));
    $navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(67, 'Title') . '</label>', $naviforms->textfield('title', $item->title), ''));
    $navibars->add_tab_content_row(array('<label>' . t(168, 'Notes') . '</label>', $naviforms->textarea('notes', $item->notes)));
    $navibars->add_tab_content_row(array('<br />'));
    if (empty($item->status) && !empty($item->id)) {
        $item->status = 'prepare';
        if (!empty($item->id)) {
            $layout->add_script('
                $.get("?fid=backups&act=backup&id=' . $item->id . '");
            ');
        }
    }
    // show current backup status
    $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', backup::status($item->status)));
    if (empty($item->status)) {
        $estimated_size = backup::estimated_size();
        $navibars->add_tab_content_row(array('<br />'));
        $navibars->add_tab_content_row(array('<label>' . t(420, 'Estimated size') . '</label>', core_bytes($estimated_size)));
    } else {
        if ($item->status != 'completed' && $item->status != 'error') {
            $navibars->add_tab_content_row(array('<label>&nbsp;</label>', '<button id="backup_refresh_status"><img src="' . NAVIGATE_URL . '/img/icons/silk/reload.png" align="absmiddle" /> ' . t(423, "Refresh") . '</button>'));
            $layout->add_script('
            $("#backup_refresh_status").bind("click", function(e)
            {
                e.stopPropagation();
                e.preventDefault();
                window.location.replace("?fid=backups&act=2&id=' . $item->id . '");
            });
        ');
        } else {
            if ($item->status == 'completed') {
                $navibars->add_tab_content_row(array('<br />'));
                $navibars->add_tab_content_row(array('<label>' . t(409, 'Size') . '</label>', core_bytes($item->size)));
                $navibars->add_tab_content_row(array('<label>' . t(421, 'Created on') . '</label>', core_ts2date($item->date_created, true)));
                $navibars->add_tab_content_row(array('<label>' . t(82, 'File') . '</label>', '<a href="?fid=backups&act=download&id=' . $item->id . '">' . $item->file . '</a>'));
            }
        }
    }
    return $navibars->generate();
}