示例#1
0
/**
 * Add new host plan to DB
 */
function save_data_to_db()
{
    global $tpl;
    global $hp_name, $hp_php, $hp_phpe, $hp_cgi, $hp_ssl;
    global $hp_sub, $hp_als, $hp_mail;
    global $hp_ftp, $hp_sql_db, $hp_sql_user;
    global $hp_traff, $hp_disk, $hp_countbackup;
    global $hpid;
    global $hp_backup, $hp_dns;
    //	global $tos;
    $sql = EasySCP_Registry::get('Db');
    $err_msg = '';
    $description = clean_input($_POST['hp_description']);
    $price = clean_input($_POST['hp_price']);
    $setup_fee = clean_input($_POST['hp_setupfee']);
    $value = clean_input($_POST['hp_value']);
    $payment = clean_input($_POST['hp_payment']);
    $status = clean_input($_POST['status']);
    $tos = clean_input($_POST['hp_tos']);
    //$hp_props = "$hp_php;$hp_cgi;$hp_sub;$hp_als;$hp_mail;$hp_ftp;$hp_sql_db;" .
    //	"$hp_sql_user;$hp_traff;$hp_disk;$hp_backup;$hp_dns;$hp_ssl";
    $newProps = array('allow_php' => $hp_php, 'allow_phpe' => $hp_phpe, 'allow_cgi' => $hp_cgi, 'subdomain_cnt' => $hp_sub, 'alias_cnt' => $hp_als, 'mail_cnt' => $hp_mail, 'ftp_cnt' => $hp_ftp, 'db_cnt' => $hp_sql_db, 'sqluser_cnt' => $hp_sql_user, 'traffic' => $hp_traff, 'disk' => $hp_disk, 'disk_countbackup' => $hp_countbackup, 'allow_backup' => $hp_backup, 'allow_dns' => $hp_dns, 'allow_ssl' => $hp_ssl);
    $hp_props = serialize($newProps);
    $admin_id = $_SESSION['user_id'];
    if (reseller_limits_check($sql, $err_msg, $admin_id, $hpid, $hp_props)) {
        if (!empty($err_msg)) {
            set_page_message($err_msg, 'error');
            restore_form($tpl, $sql);
            return false;
        } else {
            $query = "\n\t\t\t\tUPDATE\n\t\t\t\t\t`hosting_plans`\n\t\t\t\tSET\n\t\t\t\t\t`name` = ?,\n\t\t\t\t\t`description` = ?,\n\t\t\t\t\t`props` = ?,\n\t\t\t\t\t`price` = ?,\n\t\t\t\t\t`setup_fee` = ?,\n\t\t\t\t\t`value` = ?,\n\t\t\t\t\t`payment` = ?,\n\t\t\t\t\t`status` = ?,\n\t\t\t\t\t`tos` = ?\n\t\t\t\tWHERE\n\t\t\t\t\t`id` = ?\n\t\t\t\t;\n\t\t\t";
            exec_query($sql, $query, array($hp_name, $description, $hp_props, $price, $setup_fee, $value, $payment, $status, $tos, $hpid));
            $_SESSION['hp_updated'] = '_yes_';
            user_goto('hosting_plan.php');
        }
    } else {
        set_page_message(tr("Hosting plan values exceed reseller maximum values!"), 'warning');
        restore_form($tpl, $sql);
        return false;
    }
}
示例#2
0
function process_restore($smarty, $local_templates_dir, $path_backup, $module_name)
{
    $smarty->assign("module", $module_name);
    // Recolectar las claves conocidas seleccionadas
    $opcionesBackup = Array_Options();
    $clavesBackup = array();
    foreach ($opcionesBackup as $opcionBackup) {
        $clavesBackup = array_merge($clavesBackup, array_keys($opcionBackup));
    }
    $clavesSeleccion = array_intersect($clavesBackup, array_keys($_POST));
    if (count($clavesSeleccion) <= 0) {
        $smarty->assign('ERROR_MSG', _tr('Choose an option to restore'));
    } elseif (!isset($_POST['backup_file']) || trim($_POST['backup_file']) == '') {
        $smarty->assign('ERROR_MSG', _tr("Backup file path can't be empty"));
    } elseif (!file_exists($path_backup . '/' . $_POST['backup_file'])) {
        $smarty->assign('ERROR_MSG', _tr("File doesn't exist"));
    } else {
        // Ejecución del comando en sí
        $sOpcionesBackup = implode(',', $clavesSeleccion);
        $output = $retval = NULL;
        $sComando = '/usr/bin/elastix-helper backupengine --restore' . ' --backupfile ' . escapeshellarg($_POST['backup_file']) . ' --tmpdir ' . escapeshellarg($path_backup) . " --components {$sOpcionesBackup}" . ' 2>&1';
        exec($sComando, $output, $retval);
        if ($retval == 0) {
            $smarty->assign('ERROR_MSG', _tr('Restore Complete!'));
        } else {
            $sMensaje = _tr('Could not restore from backup file') . ': ' . $_POST['backup_file'] . '<br/>' . _tr('Output follows: ') . '<br/><br/>' . implode("<br/>\n", $output);
            $smarty->assign('ERROR_MSG', $sMensaje);
        }
    }
    return restore_form($smarty, $local_templates_dir, $path_backup, $module_name);
}
示例#3
0
global $hpid;
// Show main menu
gen_admin_menu($tpl);
$tpl->assign(array('TR_RESELLER_MAIN_INDEX_PAGE_TITLE' => tr('VHCS - Administrator/Edit hosting plan'), 'THEME_COLOR_PATH' => "../themes/{$theme_color}", 'THEME_CHARSET' => tr('encoding'), 'VHCS_LICENSE' => $cfg['VHCS_LICENSE'], 'ISP_LOGO' => get_logo($_SESSION['user_id'])));
$tpl->assign(array('TR_HOSTING PLAN PROPS' => tr('Hosting plan properties'), 'TR_TEMPLATE_NAME' => tr('Template name'), 'TR_MAX_SUBDOMAINS' => tr('Max subdomains<br><i>(-1 disabled, 0 unlimited)'), 'TR_MAX_ALIASES' => tr('Max aliases<br><i>(-1 disabled, 0 unlimited)'), 'TR_MAX_MAILACCOUNTS' => tr('Mail account limit<br><i>(0 unlimited)</i>'), 'TR_MAX_FTP' => tr('FTP account limit<br><i>(0 unlimited)</i>'), 'TR_MAX_SQL' => tr('SQL databases Limit<br><i>(-1 disabled, 0 unlimited)</i>'), 'TR_MAX_SQL_USERS' => tr('SQL users limit<br><i>(-1 disabled, 0 unlimited)</i>'), 'TR_MAX_TRAFFIC' => tr('Traffic limit [MB]<br><i>(0 unlimited)</i>'), 'TR_DISK_LIMIT' => tr('Disk limit [MB]<br><i>(0 unlimited)</i>'), 'TR_PHP' => tr('PHP'), 'TR_CGI' => tr('CGI / Perl'), 'TR_BACKUP_RESTORE' => tr('Backup and restore'), 'TR_APACHE_LOGS' => tr('Apache logfiles'), 'TR_AWSTATS' => tr('AwStats'), 'TR_YES' => tr('yes'), 'TR_NO' => tr('no'), 'TR_BILLING_PROPS' => tr('Billing Settings'), 'TR_PRICE' => tr('Price'), 'TR_SETUP_FEE' => tr('Setup fee'), 'TR_VALUE' => tr('Currency'), 'TR_PAYMENT' => tr('Payment period'), 'TR_STATUS' => tr('Available for purchasing'), 'TR_TEMPLATE_DESCRIPTON' => tr('Description'), 'TR_EXAMPEL' => tr('(Ex. EUR)'), 'TR_UPDATE_PLAN' => tr('Update plan')));
/*
* Dynamic page process
*
*/
if (isset($_POST['uaction']) && 'add_plan' === $_POST['uaction']) {
    // Process data
    if (check_data_iscorrect($tpl)) {
        // Save data to db
        save_data_to_db();
    } else {
        restore_form($tpl, $sql);
    }
} else {
    // Get hosting plan id tha come for edit
    if (isset($_GET['hpid'])) {
        $hpid = $_GET['hpid'];
    }
    gen_load_ehp_page($tpl, $sql, $hpid, $_SESSION['user_id']);
    $tpl->assign('MESSAGE', "");
}
gen_page_message($tpl);
$tpl->parse('PAGE', 'page');
$tpl->prnt();
if (isset($cfg['DUMP_GUI_DEBUG'])) {
    dump_gui_debug();
}