/**
  * load twig class
  * @param $dir
  */
 public static function init($dir)
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     if (!self::$twig && class_exists('Twig_Autoloader')) {
         Twig_Autoloader::register();
         $loader = new Twig_Loader_Filesystem($dir);
         self::$twig = new Twig_Environment($loader);
     }
 }
Exemplo n.º 2
0
/**
 *  set account pass
 * @param $data
 */
function setacctpass($data)
{
    $cpuser = _get('cpuser');
    $cppass = _post('pass');
    $cpanel = authorize_hwm();
    $res = $cpanel->setAcctPass($cpuser, $cppass);
    $result = json_decode($res);
    if (isset($result->passwd) && isset($result->passwd[0]->statusmsg) && strpos($result->passwd[0]->statusmsg, 'Password changed') !== false) {
        $row = get_cpanel_info(array('cpanel_user' => $cpuser, 'cpanel_host' => $cpanel->host));
        $cpid = isset($row['id']) ? $row['id'] : '';
        update_cpacct(array('cpanel_user' => $cpuser, 'cpanel_pass' => encrypt($cppass), 'cpanel_host' => $cpanel->host), $cpid);
    }
    //print result
    ajax_output($res);
    //send mail
    $body = HW_Twig_engine::twig_render('email/setacctpass.tpl', array('domain' => $data->domain, 'username' => $data->cpaneluser, 'email_domain' => $data->email_domain, 'cpanel_pass' => $cppass, 'cpanel_host' => $cpanel->host));
    send_mail1($data->email_domain, 'Hoangweb - thay đổi tài khoản cpanel', $body);
}
Exemplo n.º 3
0
/**
 * Libs path
 */
define('HWCP_LIBS_PATH', dirname(dirname(__FILE__)) . '/libs');
//include classes file
define('HWCP_CLASSES_PATH', dirname(__FILE__) . '/classes');
/**
 * through composer library
 */
include HWCP_LIBS_PATH . '/vendor/autoload.php';
//
/**
 * ADBDb
 */
include HWCP_LIBS_PATH . '/adodb5/adodb.inc.php';
include HWCP_CLASSES_PATH . '/database.class.php';
//database mysql
//php hooks
include_once HWCP_LIBS_PATH . '/php-hooks.php';
/**
 * twig template
 */
include HWCP_CLASSES_PATH . '/twig_template.class.php';
//
// Create connection
global $DB;
$conn = HW_DB::connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
// twig template
global $twig;
HW_Twig_engine::init(ROOT_DIR . '/template');
Exemplo n.º 4
0
/**
 * create wp user
 * @param $cp
 */
function create_wp_user($cp)
{
    $subdomain = _post('subdomain');
    $wp_user = _post('user');
    $wp_pass = _post('pass');
    $wp_email = _post('email');
    $role = _post('role');
    $login_path = _post('login_path', '/login');
    $fullname = urldecode(_post('fullname'));
    $update_svn_user = _post('update_svn_user');
    //check for exist user in db, wp user is unique for all cpanel domain
    /*$exist_u = hw_svn_get_user(array(
            'svn_user' => $wp_user
        ));
    
        if($exist_u && count($exist_u)) {
            echo "Sory, exists user {$wp_user}. Choose a other name.";
            exit();
        }*/
    //update wp tool on wp root
    $res = $cp->upload_wptool($cp->acc_id, $subdomain);
    ajax_output($res);
    //run this file
    $url = rtrim(_domain($cp->domain, $subdomain), '/') . '/' . HW_WP_TOOL_FILE . '?do=create_user&acc=' . $cp->acc_id;
    $data = array('user' => _post('user'), 'pass' => _post('pass'), 'email' => _post('email'), 'fullname' => $fullname, 'role' => $role, 'update_svn_user' => $update_svn_user);
    $res = curl_post($url, $data);
    $result = json_decode($res);
    ajax_output($res);
    //save to db option
    if (_post('savedb') && $result) {
        $myuser = array('svn_user' => $wp_user, 'svn_pass' => encrypt($wp_pass), 'svn_fullname' => $fullname, 'svn_email' => $wp_email, 'domain' => $cp->domain . (trim($subdomain, '/') ? '/' . trim($subdomain, '/') : ''));
        //add new or update user
        $_user = hw_svn_get_user(array('svn_user' => $wp_user));
        if ($_user && count($_user)) {
            //update exist user
            $res = hw_svn_adduser($myuser, $_user['id']);
        } else {
            $res = hw_svn_adduser($myuser);
        }
        //add new user
        #$res = hw_svn_update_user($myuser, array('svn_user' => $wp_user ));    //other way
        ajax_output($res ? "Add svn user [{$myuser['svn_user']}] successful !" : "Fail adding svn user to manager because exist !");
    }
    //send mail
    if (isset($result->email)) {
        //login path
        $login_url = rtrim(hw_valid_url($cp->domain), '/') . '/' . ltrim($login_path, '/');
        $body = HW_Twig_engine::twig_render('email/create_wp_user.tpl', array('domain' => $cp->domain, 'username' => $cp->cpaneluser, 'email_domain' => $cp->email_domain, 'user' => $result->user, 'pass' => $result->pass, 'email' => $result->email, 'login_url' => $login_url));
        send_mail1($result->email, 'Hoangweb.COM - tạo tài khoản đăng nhập Wordpress', $body);
    }
}
Exemplo n.º 5
0
/**
 * create backup
 * @param $data
 */
function createbackup($data)
{
    $cpanel_file = $data->get_instance('fileman1');
    //new HW_CPanel_Fileman($data->host, $data->cpaneluser, $data->cpaneluser_pass);
    #$cpanel_file->cre
    $res = $cpanel_file->create_backup();
    ajax_output($res);
    //send mail
    $body = HW_Twig_engine::twig_render('email/createbackup.tpl', array('domain' => $data->domain, 'username' => $data->cpaneluser, 'email_domain' => $data->email_domain));
    send_mail1($data->email_domain, 'Hoangweb - backup website ' . $data->domain, $body);
}