<?php 
//include libs
include_once 'includes/common/require.php';
_load_class('cpanel');
_load_class('fileman', 'cpanel');
//check user login
check_user_session();
global $DB;
$task = _post('task');
if (isset($_POST['submit'])) {
    //validation
    if (_post('acc') == '') {
        add_message("Please select which account you want to use ?");
        goto invalid_form;
    }
    //get cpanel credentials
    $acc_id = _post('acc');
    $acc = get_cpanel_acc($acc_id);
    $host = isset($acc['cpanel_host']) ? $acc['cpanel_host'] : '';
    $cpaneluser = isset($acc['cpanel_user']) ? $acc['cpanel_user'] : "";
    $cpaneluser_pass = isset($acc['cpanel_pass']) ? decrypt($acc['cpanel_pass']) : '';
    $email_domain = isset($acc['cpanel_email']) ? $acc['cpanel_email'] : '*****@*****.**';
    //authorize
    $cpanel = new HW_CPanel($host, $cpaneluser, $cpaneluser_pass);
}
if (isset($cpanel)) {
    /**
     * upload file
     */
    if ($task == 'upload') {
        #$cpanel_file = HW_CPanel_Fileman::init($cpanel);
function check_user_security($setting_name = "")
{
    global $db, $settings, $table_prefix;
    check_user_session();
    if ($setting_name) {
        $sql = " SELECT setting_value ";
        $sql .= " FROM " . $table_prefix . "user_types_settings ";
        $sql .= " WHERE type_id=" . $db->tosql(get_session("session_user_type_id"), INTEGER);
        $sql .= " AND setting_name=" . $db->tosql($setting_name, TEXT);
        $allow_access = get_db_value($sql);
        if (!$allow_access) {
            $site_url = get_setting_value($settings, "site_url", "");
            $user_home_url = $site_url . get_custom_friendly_url("user_home.php");
            header("Location: " . $user_home_url);
            exit;
        }
    }
}