/**
 * Update autoresponder of the given mail account
 *
 * @param int $mailAccountId Mail account id
 * @param string $autoresponderMessage Auto-responder message
 * @return void
 */
function client_updateAutoresponder($mailAccountId, $autoresponderMessage)
{
    $autoresponderMessage = clean_input($autoresponderMessage);
    if ($autoresponderMessage == '') {
        set_page_message(tr('Auto-responder message cannot be empty.'), 'error');
        redirectTo("mail_autoresponder_enable.php?mail_account_id={$mailAccountId}");
    } else {
        $db = iMSCP_Database::getInstance();
        try {
            $db->beginTransaction();
            $query = "SELECT `mail_addr` FROM `mail_users` WHERE `mail_id` = ?";
            $stmt = exec_query($query, $mailAccountId);
            $query = "UPDATE `mail_users` SET `status` = ?, `mail_auto_respond_text` = ? WHERE `mail_id` = ?";
            exec_query($query, array('tochange', $autoresponderMessage, $mailAccountId));
            // Purge autoreplies log entries
            delete_autoreplies_log_entries();
            $db->commit();
            // Ask iMSCP daemon to trigger engine dispatcher
            send_request();
            write_log(sprintf("%s: Updated auto-responder for the '%s' mail account", $_SESSION['user_logged'], $stmt->fields['mail_addr']), E_USER_NOTICE);
            set_page_message(tr('Auto-responder successfully scheduled for update.'), 'success');
        } catch (iMSCP_Exception_Database $e) {
            $db->rollBack();
            throw $e;
        }
    }
}
/**
 * Updates htaccess user.
 *
 * @param int $dmn_id Domain unique identifier
 * @param int $uuser_id Htaccess user unique identifier
 * @return
 */
function client_updateHtaccessUser(&$dmn_id, &$uuser_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'modify_user') {
        // we have to add the user
        if (isset($_POST['pass']) && isset($_POST['pass_rep'])) {
            if (!checkPasswordSyntax($_POST['pass'])) {
                return;
            }
            if ($_POST['pass'] !== $_POST['pass_rep']) {
                set_page_message(tr("Passwords do not match."), 'error');
                return;
            }
            $nadmin_password = cryptPasswordWithSalt($_POST['pass'], generateRandomSalt(true));
            $change_status = 'tochange';
            $query = "\n\t\t\t\tUPDATE\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tSET\n\t\t\t\t\t`upass` = ?, `status` = ?\n\t\t\t\tWHERE\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t\tAND\n\t\t\t\t\t`id` = ?\n\t\t\t";
            exec_query($query, array($nadmin_password, $change_status, $dmn_id, $uuser_id));
            send_request();
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`uname`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tWHERE\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t\tAND\n\t\t\t\t\t`id` = ?\n\t\t\t";
            $rs = exec_query($query, array($dmn_id, $uuser_id));
            $uname = $rs->fields['uname'];
            $admin_login = $_SESSION['user_logged'];
            write_log("{$admin_login}: updated htaccess user ID: {$uname}", E_USER_NOTICE);
            redirectTo('protected_user_manage.php');
        }
    } else {
        return;
    }
}
function gen_page_dynamic_data(&$tpl, &$sql, $mail_id)
{
    global $cfg;
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'enable_arsp') {
        if ($_POST['arsp_message'] === '') {
            $tpl->assign('ARSP_MESSAGE', '');
            set_page_message(tr('Please type your mail autorespond message!'));
            return;
        }
        $arsp_message = $_POST['arsp_message'];
        $item_change_status = $cfg['ITEM_CHANGE_STATUS'];
        check_for_lock_file();
        $query = <<<SQL_QUERY
            update
                mail_users
            set
                status = ?,
                mail_auto_respond = ?
            where
                mail_id = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($item_change_status, $arsp_message, $mail_id));
        send_request();
        write_log($_SESSION['user_logged'] . " : add mail autorsponder");
        set_page_message(tr('Mail account scheduler for modification!'));
        header("Location: email_accounts.php");
        exit(0);
    } else {
        $tpl->assign('ARSP_MESSAGE', '');
    }
}
Beispiel #4
0
/**
 * Schedule backup restoration.
 *
 * @param int $userId Customer unique identifier
 * @return void
 */
function scheduleBackupRestoration($userId)
{
    exec_query("UPDATE `domain` SET `domain_status` = ? WHERE `domain_admin_id` = ?", array('torestore', $userId));
    send_request();
    write_log($_SESSION['user_logged'] . ": scheduled backup restoration.", E_USER_NOTICE);
    set_page_message(tr('Backup has been successfully scheduled for restoration.'), 'success');
}
Beispiel #5
0
function padd_group($tpl, $sql, $dmn_id)
{
    $cfg = EasySCP_Registry::get('Config');
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_group') {
        // we have to add the group
        if (isset($_POST['groupname'])) {
            if (!validates_username($_POST['groupname'])) {
                set_page_message(tr('Invalid group name!'), 'warning');
                return;
            }
            $groupname = $_POST['groupname'];
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_groups`\n\t\t\t\tWHERE\n\t\t\t\t\t`ugroup` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($sql, $query, array($groupname, $dmn_id));
            if ($rs->recordCount() == 0) {
                $change_status = $cfg->ITEM_ADD_STATUS;
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_groups`\n\t\t\t\t\t\t(`dmn_id`, `ugroup`, `status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?)\n\t\t\t\t";
                exec_query($sql, $query, array($dmn_id, $groupname, $change_status));
                send_request();
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: add group (protected areas): {$groupname}");
                user_goto('protected_user_manage.php');
            } else {
                set_page_message(tr('Group already exists!'), 'error');
                return;
            }
        } else {
            set_page_message(tr('Invalid group name!'), 'error');
            return;
        }
    } else {
        return;
    }
}
/**
 * Adds Htaccess group.
 *
 * @param int $domainId Domain unique identifier
 * @return
 */
function client_addHtaccessGroup($domainId)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_group') {
        // we have to add the group
        if (isset($_POST['groupname'])) {
            if (!validates_username($_POST['groupname'])) {
                set_page_message(tr('Invalid group name!'), 'error');
                return;
            }
            $groupname = $_POST['groupname'];
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_groups`\n\t\t\t\tWHERE\n\t\t\t\t\t`ugroup` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($query, array($groupname, $domainId));
            if ($rs->rowCount() == 0) {
                $change_status = 'toadd';
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_groups` (\n\t\t\t\t\t    `dmn_id`, `ugroup`, `status`\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t    ?, ?, ?\n\t\t\t\t\t)\n\t\t\t\t";
                exec_query($query, array($domainId, $groupname, $change_status));
                send_request();
                set_page_message(tr('Htaccess group successfully scheduled for addition.'), 'success');
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: added htaccess group: {$groupname}", E_USER_NOTICE);
                redirectTo('protected_user_manage.php');
            } else {
                set_page_message(tr('This htaccess group already exists.'), 'error');
                return;
            }
        } else {
            set_page_message(tr('Invalid htaccess group name.'), 'error');
            return;
        }
    } else {
        return;
    }
}
Beispiel #7
0
function get_uptime()
{
    global $passwords, $uptime, $cache_file;
    $all_time = send_request("summary.average/" . $passwords->pingdom->checkid . "?includeuptime=true");
    $last_month = send_request("summary.average/" . $passwords->pingdom->checkid . "?includeuptime=true&from=" . (time() - 2592000));
    $uptime = array("all_time" => $all_time->summary->status->totalup / ($all_time->summary->status->totalup + $all_time->summary->status->totaldown), "last_month" => $last_month->summary->status->totalup / ($last_month->summary->status->totalup + $last_month->summary->status->totaldown));
    file_put_contents($cache_file, "<?php\n  \$last_check = " . var_export(time(), true) . ";\n\n  \$uptime = " . var_export($uptime, true) . ";\n?" . ">");
}
 function died($error)
 {
     $data = "We are very sorry, but there were error(s) found with the form you submitted. ";
     $data .= "These errors appear below.<br />";
     $data .= $error;
     $data .= "Please go back and fix these errors.<br />";
     send_request($data, true);
 }
Beispiel #9
0
function make_request()
{
    $user = $_GET['login'];
    $password = md5($_GET['password']);
    $packet_id = wddx_packet_start("Authentication Request");
    wddx_add_vars($packet_id, 'user', 'password');
    $packet = wddx_packet_end($packet_id);
    // make a custom POST request to the server with the wddx packet
    return send_request($packet);
}
Beispiel #10
0
function get_api_data($url, $param = array())
{
    $url = API_URL . $url;
    $sign = encrypt($param);
    $param['sign'] = $sign;
    $api_str = send_request($url, $param);
    if (is_json($api_str)) {
        return json_decode($api_str, TRUE);
    } else {
        return return_format(array($api_str), "json_str 解析错误,这是api内部报错!请联系1162097842@qq.com", API_NORMAL_ERR);
    }
}
Beispiel #11
0
/**
 * Deactivate OpenDKIM for the given customer
 *
 * @param int $customerId Customer unique identifier
 * @return void
 */
function opendkim_deactivate($customerId)
{
    $stmt = exec_query('SELECT COUNT(admin_id) AS cnt FROM admin WHERE admin_id = ? AND created_by = ? AND admin_status = ?', array($customerId, $_SESSION['user_id'], 'ok'));
    $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
    if ($row['cnt']) {
        exec_query('UPDATE opendkim SET opendkim_status = ? WHERE admin_id = ?', array('todelete', $customerId));
        send_request();
        set_page_message(tr('OpenDKIM support scheduled for deactivation. This can take few seconds.'), 'success');
    } else {
        showBadRequestErrorPage();
    }
}
 public function submit()
 {
     //先接受get数组,然后再填充到conf里面
     $conf = ['rzm' => 2013214368, 'xm' => 'ling', 'ip' => '202.202.41.125', 'bt' => '这是测试数据,请穆老师处理', 'fwxmh' => 01, 'bxdh' => 18580024667, 'fwquy' => '', 'wxdd' => '27栋', 'bxnr' => '这是测试数据,请穆老师处理', 'wxdjh' => 'a66222d0-f5ba-4fe5-86d4-a3cd01815db4', 'hfmyd' => '满意', 'hfjy' => '这是测试数据,请穆老师处理'];
     $wxdh = send_request('RepairApp', $conf);
     //提交
     if ($wxdh) {
         $this->ajaxReturn(true);
     } else {
         $this->ajaxReturn(false);
     }
 }
Beispiel #13
0
 public function performTest($testName)
 {
     $testUri = testCase::BASE_SERVICE . $testName . '.' . testCase::RESPONSE_FORMAT;
     echo_line('<pre>');
     echo_line("Request:");
     echo_line("\t" . $testUri);
     echo_line("\nResponse:\n");
     $response = send_request($testUri, 'GET');
     $coder = new CJSON();
     $object = $coder->decode($response);
     print_as_json('', $object);
     echo_line('</pre>');
 }
 public function returnVisit()
 {
     if (session('stuId') && session('wx_djh') && I('post.hfmyd') && I('post.hfjy')) {
         $conf = ['rzm' => session('stuId'), 'wxdjh' => session('get.wx_djh'), 'hfmyd' => I('post.hfmyd'), 'hfjy' => I('post.hfjy')];
         if (send_request('PayReturnVisit', $conf)) {
             $this->ajaxReturn(true);
         } else {
             $this->ajaxReturn(false);
         }
     } else {
         $this->error('数据填写不完整');
     }
 }
 public function firstLoad()
 {
     $conf = ['id' => session('stuId')];
     $res = send_request('InfoById', $conf);
     //获取从接口拿到的保修单数据
     if ($res) {
         D('Globle')->cacheRefresh($res);
         //每次查询的时候跟新本地缓存
         $this->LoadUnfinishedData();
     } else {
         //查看是否为接口问题
         $this->LoadUnfinishedData();
     }
 }
Beispiel #16
0
 function data()
 {
     $params = array();
     $params['max_id'] = intval(v('max_id'));
     if ($content = send_request('notice_list', $params, token())) {
         //echo $content;
         $data = json_decode($content, 1);
         if (intval($data['err_code']) != 0) {
             return false;
         }
         return render($data, 'ajax', 'raw');
     }
     return null;
 }
Beispiel #17
0
 /**
  * onAfterAddDomainAlias listener
  *
  * @throws iMSCP_Exception
  * @throws iMSCP_Exception_Database
  * @param iMSCP_Events_Event $event
  * @throws Exception
  */
 public function onAfterAddDomainAlias(iMSCP_Events_Event $event)
 {
     $userIdentity = iMSCP_Authentication::getInstance()->getIdentity();
     if ($userIdentity->admin_type == 'user') {
         $disallowedDomains = (array) $this->getConfigParam('ignored_domains', array());
         $domainAliasNameAscii = $event->getParam('domainAliasName');
         # Only domain aliases which are not listed in the ignored_domains list are auto-approved
         if (!in_array(decode_idna($domainAliasNameAscii), $disallowedDomains)) {
             $username = decode_idna($userIdentity->admin_name);
             $approvalRule = $this->getConfigParam('approval_rule', true);
             $userAccounts = (array) $this->getConfigParam('user_accounts', array());
             if ($approvalRule) {
                 # Only domain aliases added by user accounts which are listed in the user_accounts list are
                 # auto-approved
                 if (!in_array($username, $userAccounts)) {
                     $username = false;
                 }
             } elseif (in_array($username, $userAccounts)) {
                 # Only domain aliases added by user accounts which are not listed in the user_accounts list are
                 # auto-approved
                 $username = false;
             }
             if ($username !== false) {
                 $db = iMSCP_Database::getInstance();
                 try {
                     $db->beginTransaction();
                     $domainAliasId = $event->getParam('domainAliasId');
                     exec_query('UPDATE domain_aliasses SET alias_status = ? WHERE alias_id = ?', array('toadd', $domainAliasId));
                     if (iMSCP_Registry::get('config')->CREATE_DEFAULT_EMAIL_ADDRESSES) {
                         if ($userIdentity->email) {
                             client_mail_add_default_accounts(get_user_domain_id($userIdentity->admin_id), $userIdentity->email, $domainAliasNameAscii, 'alias', $domainAliasId);
                         }
                     }
                     $db->commit();
                     send_request();
                     $domainAliasName = decode_idna($domainAliasNameAscii);
                     $username = decode_idna($username);
                     write_log(sprintf('DomainAutoApproval: The %s domain alias has been auto-approved', $domainAliasName), E_USER_NOTICE);
                     write_log(sprintf('DomainAutoApproval: %s scheduled addition of domain alias: %s', $username, $domainAliasName), E_USER_NOTICE);
                     set_page_message(tr('Domain alias successfully scheduled for addition.'), 'success');
                     redirectTo('domains_manage.php');
                 } catch (iMSCP_Exception $e) {
                     $db->rollBack();
                     throw $e;
                 }
             }
         }
     }
 }
 public function getInfo_by_wxdh()
 {
     //$wxdh = I('get.wxdh');
     // $conf = [
     // 	'id' => session('stuId'),
     // 	'appId' => $wxdh,
     // ];
     //需要替换的地方
     $conf = ['appId' => 'a66222d0-f5ba-4fe5-86d4-a3cd01815db4', 'id' => '1635841'];
     $message = send_request('Detail', $conf);
     if ($message) {
         $this->ajaxReturn($message, 'json');
     } else {
         $this->ajaxReturn(false);
     }
 }
function pedit_user(&$tpl, &$sql, &$dmn_id, &$user_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'modify_user') {
        // we have user to add
        if (isset($_POST['pass']) && isset($_POST['pass_rep'])) {
            if ($_POST['pass'] !== $_POST['pass_rep']) {
                set_page_message(tr('Passwords don\'t match!'));
                return;
            }
            $nadmin_password = crypt($_POST['pass']);
            $query = <<<SQL_QUERY
                    update
                        htaccess_users
                    set
                        upass = ?
                    where
                        dmn_id = ?
\t\t\t\t\tand
\t\t\t\t\t\tid = ?

SQL_QUERY;
            $rs = exec_query($sql, $query, array($nadmin_password, $dmn_id, $user_id));
            // lets update htaccess to rebuild the htaccess files#
            global $cfg;
            $change_status = $cfg['ITEM_CHANGE_STATUS'];
            $query = <<<SQL_QUERY
                    update
                        htaccess
                    set
                        status = ?
                    where
                         user_id = ?
\t\t\t\t\tand
\t\t\t\t\t\t dmn_id = ?
SQL_QUERY;
            $rs = exec_query($sql, $query, array($change_status, $user_id, $dmn_id));
            check_for_lock_file();
            send_request();
            $admin_login = $_SESSION['user_logged'];
            write_log("{$admin_login}: modify user ID (protected areas) -> {$user_id}");
            header("Location: puser_manage.php");
            die;
        }
    } else {
        return;
    }
}
Beispiel #20
0
function send_backup_restore_request(&$sql, $user_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'bk_restore') {
        check_for_lock_file();
        $query = <<<SQL_QUERY
        update
            domain
        set
            domain_status = 'restore'
        where
            domain_admin_id = ?
SQL_QUERY;
        $rs = exec_query($sql, $query, array($user_id));
        send_request();
        write_log($_SESSION['user_logged'] . " : restor backup files");
        set_page_message(tr('Backup archive scheduled for restoring!'));
    }
}
Beispiel #21
0
function padd_user($tpl, $sql, $dmn_id)
{
    $cfg = EasySCP_Registry::get('Config');
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_user') {
        // we have to add the user
        if (isset($_POST['username']) && isset($_POST['pass']) && isset($_POST['pass_rep'])) {
            if (!validates_username($_POST['username'])) {
                set_page_message(tr('Wrong username!'), 'warning');
                return;
            }
            if (!chk_password($_POST['pass'])) {
                if ($cfg->PASSWD_STRONG) {
                    set_page_message(sprintf(tr('The password must be at least %s chars long and contain letters and numbers to be valid.'), $cfg->PASSWD_CHARS), 'warning');
                } else {
                    set_page_message(sprintf(tr('Password data is shorter than %s signs or includes not permitted signs!'), $cfg->PASSWD_CHARS), 'warning');
                }
                return;
            }
            if ($_POST['pass'] !== $_POST['pass_rep']) {
                set_page_message(tr('Passwords do not match!'), 'warning');
                return;
            }
            $status = $cfg->ITEM_ADD_STATUS;
            $uname = clean_input($_POST['username']);
            $upass = crypt_user_pass_with_salt($_POST['pass']);
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tWHERE\n\t\t\t\t\t`uname` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($sql, $query, array($uname, $dmn_id));
            if ($rs->recordCount() == 0) {
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_users`\n\t\t\t\t\t\t(`dmn_id`, `uname`, `upass`, `status`)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(?, ?, ?, ?)\n\t\t\t\t";
                exec_query($sql, $query, array($dmn_id, $uname, $upass, $status));
                send_request('110 DOMAIN htaccess ' . $dmn_id);
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: add user (protected areas): {$uname}");
                user_goto('protected_user_manage.php');
            } else {
                set_page_message(tr('User already exist !'), 'error');
                return;
            }
        }
    } else {
        return;
    }
}
Beispiel #22
0
function note_page()
{
    //初始化数据库
    if (!get_data("SHOW TABLES LIKE 'note'")) {
        run_sql('CREATE TABLE IF NOT EXISTS `note` (
  			 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  			 `uid` int(11) unsigned NOT NULL,
 			 `content` varchar(255)  NOT NULL,
  			 PRIMARY KEY (`id`),
  			 KEY `uid` (`uid`)
			 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
    }
    //读取列表数据
    $note_list = send_request('note_list', array(), token());
    $ret = json_decode($note_list, true);
    //显示界面
    $data = array('top_title' => '工作笔记', 'token' => token(), 'data' => $ret['data']);
    $GLOBALS['c'] = 'dashboard';
    //让TUDO菜单为选中状态
    render($data, 'web', 'plugin', 'note');
}
/**
 * Deactivate autoresponder of the given mail account
 *
 * @param int $mailAccountId Mail account id
 * @return void
 */
function client_deactivateAutoresponder($mailAccountId)
{
    $db = iMSCP_Database::getInstance();
    try {
        $db->beginTransaction();
        $query = "SELECT `mail_addr` FROM `mail_users` WHERE `mail_id` = ?";
        $stmt = exec_query($query, $mailAccountId);
        $query = "UPDATE `mail_users` SET `status` = ?, `mail_auto_respond` = ? WHERE `mail_id` = ?";
        exec_query($query, array('tochange', 0, $mailAccountId));
        // Purge autoreplies log entries
        delete_autoreplies_log_entries();
        $db->commit();
        // Ask iMSCP daemon to trigger engine dispatcher
        send_request();
        write_log(sprintf("%s: deactivated auto-responder for the '%s' mail account", $_SESSION['user_logged'], $stmt->fields['mail_addr']), E_USER_NOTICE);
        set_page_message(tr('Auto-responder successfully scheduled for deactivation.'), 'success');
    } catch (iMSCP_Exception_Database $e) {
        $db->rollBack();
        throw $e;
    }
}
 /**
  * onAfterAddDomainAlias listener
  *
  * @throws iMSCP_Exception
  * @throws iMSCP_Exception_Database
  * @param iMSCP_Events_Event $event
  * @throws Exception
  * @return void
  */
 public function onAfterAddDomainAlias(iMSCP_Events_Event $event)
 {
     $userIdentity = iMSCP_Authentication::getInstance()->getIdentity();
     // 1. Do not act if the logged-in user is not the real client (due to changes in i-MSCP v1.2.12)
     // 2. Do not act if the event has been triggered from reseller interface
     if (isset($_SESSION['logged_from_type']) || $userIdentity->admin_type == 'reseller') {
         return;
     }
     $disallowedDomains = (array) $this->getConfigParam('ignored_domains', array());
     $domainAliasNameAscii = $event->getParam('domainAliasName');
     if (in_array(decode_idna($domainAliasNameAscii), $disallowedDomains)) {
         return;
         # Only domain aliases which are not listed in the ignored_domains list are auto-approved
     }
     $username = decode_idna($userIdentity->admin_name);
     $approvalRule = $this->getConfigParam('approval_rule', true);
     $userAccounts = (array) $this->getConfigParam('user_accounts', array());
     # 1. Only domain aliases added by user which are listed in the 'user_accounts' list are auto-approved
     # 2. Only domain aliases added by user which are not listed in the 'user_accounts' list are auto-approved
     if ($approvalRule && !in_array($username, $userAccounts) || in_array($username, $userAccounts)) {
         return;
     }
     $db = iMSCP_Database::getInstance();
     try {
         $db->beginTransaction();
         $domainAliasId = $event->getParam('domainAliasId');
         exec_query('UPDATE domain_aliasses SET alias_status = ? WHERE alias_id = ?', array('toadd', $domainAliasId));
         $config = iMSCP_Registry::get('config');
         if ($config['CREATE_DEFAULT_EMAIL_ADDRESSES'] && $userIdentity->email !== '') {
             client_mail_add_default_accounts(get_user_domain_id($userIdentity->admin_id), $userIdentity->email, $domainAliasNameAscii, 'alias', $domainAliasId);
         }
         $db->commit();
         send_request();
         write_log(sprintf('DomainAutoApproval plugin: The `%s` domain alias has been auto-approved', decode_idna($domainAliasNameAscii)), E_USER_NOTICE);
         set_page_message(tr('Domain alias auto-approved.'), 'success');
     } catch (iMSCP_Exception $e) {
         $db->rollBack();
         throw $e;
     }
 }
Beispiel #25
0
 function rand_page()
 {
     //这里开启页面的Basic 认证
     //$this -> check_superadmin();
     $params = array();
     $data = array();
     if ($content = send_request('lucky_list', $params)) {
         $jsonData = json_decode($content, 1);
         if ($jsonData['err_code'] == 0) {
             if (is_array($jsonData["data"])) {
                 $data["luckyList"] = $jsonData["data"];
             } else {
                 $data["luckyList"] = array();
             }
         } else {
             //
         }
     }
     $data['js'] = array('jquery.min.js');
     $data['css'] = array('style.css');
     render($data, 'web', 'rand');
 }
Beispiel #26
0
function write_street_selectbox()
{
    $i = 0;
    $street_selbox = "";
    $strassen = json_decode(send_request('/strassen.php/', 'get'));
    if ($strassen->strassen) {
        foreach ($strassen->strassen as $value) {
            $strasse = json_decode(send_request('/strassen.php/' . $value->id, 'get'));
            $result[$i]["id"] = $strasse->Strasse->id;
            $result[$i]["name"] = $strasse->Strasse->Name;
            $i++;
        }
    }
    $street_selbox .= '<select name="Strasse">\\n';
    for ($i = 0; $i < count($result); $i++) {
        $street_selbox .= '<option value="' . $result[$i]["id"] . '">';
        $street_selbox .= utf8_decode($result[$i]["name"]);
        $street_selbox .= '</option>';
    }
    $street_selbox .= '</select>\\n';
    echo $street_selbox;
}
/**
 * Add Htaccess user.
 *
 * @param int $domainId Domain unique identifier
 * @return
 */
function client_addHtaccessUser($domainId)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] == 'add_user') {
        // we have to add the user
        if (isset($_POST['username']) && isset($_POST['pass']) && isset($_POST['pass_rep'])) {
            if (!validates_username($_POST['username'])) {
                set_page_message(tr('Wrong username.'), 'error');
                return;
            }
            if (!checkPasswordSyntax($_POST['pass'])) {
                return;
            }
            if ($_POST['pass'] !== $_POST['pass_rep']) {
                set_page_message(tr("Passwords do not match."), 'error');
                return;
            }
            $status = 'toadd';
            $uname = clean_input($_POST['username']);
            $upass = cryptPasswordWithSalt($_POST['pass'], generateRandomSalt(true));
            $query = "\n\t\t\t\tSELECT\n\t\t\t\t\t`id`\n\t\t\t\tFROM\n\t\t\t\t\t`htaccess_users`\n\t\t\t\tWHERE\n\t\t\t\t\t`uname` = ?\n\t\t\t\tAND\n\t\t\t\t\t`dmn_id` = ?\n\t\t\t";
            $rs = exec_query($query, array($uname, $domainId));
            if ($rs->rowCount() == 0) {
                $query = "\n\t\t\t\t\tINSERT INTO `htaccess_users` (\n\t\t\t\t\t    `dmn_id`, `uname`, `upass`, `status`\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t    ?, ?, ?, ?\n\t\t\t\t\t)\n\t\t\t\t";
                exec_query($query, array($domainId, $uname, $upass, $status));
                send_request();
                set_page_message(tr('Htaccess user successfully scheduled for addition.'), 'success');
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: added new htaccess user: {$uname}", E_USER_NOTICE);
                redirectTo('protected_user_manage.php');
            } else {
                set_page_message(tr('This htaccess user already exist.'), 'error');
                return;
            }
        }
    } else {
        return;
    }
}
function send_message($apiKey, $regIDs)
{
    global $url;
    global $prev;
    $response = send_request(false, $url, array("Content-Type: application/json"));
    $x = json_decode($response);
    $sd = $x->Siri->ServiceDelivery;
    $rt = $sd->ResponseTimestamp;
    $msv = $sd->StopMonitoringDelivery[0]->MonitoredStopVisit;
    $s = '';
    foreach ($msv as $k => $v) {
        $mvj = $v->MonitoredVehicleJourney;
        $dist = $mvj->MonitoredCall->Extensions->Distances->PresentableDistance;
        $stopName = $mvj->MonitoredCall->StopPointName;
        switch ($dist) {
            case 'at stop':
            case 'approaching':
            case '1 stop away':
                $s .= "; {$mvj->PublishedLineName} {$dist}";
        }
    }
    if (!empty($s) && $s != $prev) {
        $prev = $s;
        $msg = substr($rt, 11, 8) . " -- " . substr($s, 2) . "@{$stopName}";
        echo "<hr>{$msg}";
        $data = <<<EOT
\t\t\t{
\t\t\t\t"data": {
\t\t\t\t\t"message": "{$msg}"
\t\t\t\t},
\t\t\t\t"registration_ids": [{$regIDs}],
\t\t\t\t"delay_while_idle": true,
\t\t\t\t"time_to_live": 600
\t\t\t}
EOT;
        send_request(true, "https://android.googleapis.com/gcm/send", array("Content-Type: application/json", "Authorization: key={$apiKey}"), $data);
    }
}
Beispiel #29
0
function todo_flow_item()
{
    $uid = intval(z(v(t('uid'))));
    if ($uid < 0) {
        return ajax_echo('BAD UID');
    }
    $params = array();
    $params['uid'] = $uid;
    $params['ord'] = 'desc';
    $params['by'] = 'last_action_at';
    $params['count'] = '20';
    if ($content = send_request('todo_list', $params, token())) {
        $data = json_decode($content, 1);
        $data['user'] = get_user_info_by_id($uid);
        if (isset($data['data'])) {
            foreach ($data['data'] as $k => $v) {
                if ($v['is_follow'] == 1) {
                    unset($data['data'][$k]);
                }
            }
        }
        return render($data, 'ajax', 'plugin', 'todo_flow');
    }
}
Beispiel #30
-1
function send_backup_restore_request($sql, $user_id)
{
    if (isset($_POST['uaction']) && $_POST['uaction'] === 'bk_restore') {
        $query = "\n\t\t\tUPDATE\n\t\t\t\t`domain`\n\t\t\tSET\n\t\t\t\t`status` = 'restore'\n\t\t\tWHERE\n\t\t\t\t`domain_admin_id` = ?\n\t\t";
        exec_query($sql, $query, $user_id);
        send_request();
        write_log($_SESSION['user_logged'] . ": restore backup files.");
        set_page_message(tr('Backup archive scheduled for restoring!'), 'success');
    }
}