当前位置: 首页>>代码示例>>PHP>>正文


PHP get_user_domain_id函数代码示例

本文整理汇总了PHP中get_user_domain_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_user_domain_id函数的具体用法?PHP get_user_domain_id怎么用?PHP get_user_domain_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_user_domain_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: client_generateDirectoriesList

/**
 * Generates directories list.
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @return void
 */
function client_generateDirectoriesList($tpl)
{
    // Initialize variables
    $path = isset($_GET['cur_dir']) ? clean_input($_GET['cur_dir']) : '';
    $domain = $_SESSION['user_logged'];
    // Create the virtual file system and open it so it can be used
    $vfs = new iMSCP_VirtualFileSystem($domain);
    // Get the directory listing
    $list = $vfs->ls($path);
    if (!$list) {
        set_page_message(tr('Unable to retrieve directories list for your domain. Please contact your reseller.'), 'error');
        $tpl->assign('FTP_CHOOSER', '');
        return;
    }
    // Show parent directory link
    $parent = explode('/', $path);
    array_pop($parent);
    $parent = implode('/', $parent);
    $tpl->assign(array('ACTION_LINK' => '', 'ACTION' => '', 'ICON' => 'parent', 'DIR_NAME' => tr('Parent directory'), 'LINK' => "ftp_choose_dir.php?cur_dir={$parent}"));
    $tpl->parse('DIR_ITEM', '.dir_item');
    // Show directories only
    foreach ($list as $entry) {
        $directory = $path . '/' . $entry['file'];
        if ($entry['type'] != iMSCP_VirtualFileSystem::VFS_TYPE_DIR || ($entry['file'] == '.' || $entry['file'] == '..') || !isAllowedDir(get_user_domain_id($_SESSION['user_id']), $directory)) {
            continue;
        }
        // Create the directory link
        $tpl->assign(array('DIR_NAME' => tohtml($entry['file']), 'CHOOSE_IT' => $directory, 'LINK' => 'ftp_choose_dir.php?cur_dir=' . $directory));
        $tpl->parse('ACTION_LINK', 'action_link');
        $tpl->parse('DIR_ITEM', '.dir_item');
    }
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:38,代码来源:ftp_choose_dir.php

示例2: gen_db_list

function gen_db_list(&$tpl, &$sql, $user_id)
{
    $dmn_id = get_user_domain_id($sql, $user_id);
    $query = <<<SQL_QUERY
        select
            sqld_id, sqld_name
        from
            sql_database
        where
            domain_id = ?
        order by
            sqld_name
SQL_QUERY;
    $rs = exec_query($sql, $query, array($dmn_id));
    if ($rs->RecordCount() == 0) {
        set_page_message(tr('Database list is empty!'));
        $tpl->assign('DB_LIST', '');
    } else {
        while (!$rs->EOF) {
            $db_id = $rs->fields['sqld_id'];
            $db_name = $rs->fields['sqld_name'];
            gen_db_user_list($tpl, $sql, $db_id);
            $tpl->assign(array('DB_ID' => "{$db_id}", 'DB_NAME' => "{$db_name}"));
            $tpl->parse('DB_LIST', '.db_list');
            $rs->MoveNext();
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:28,代码来源:manage_sql.php

示例3: onAfterAddDomainAlias

 /**
  * 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;
                 }
             }
         }
     }
 }
开发者ID:nciftci,项目名称:plugins,代码行数:57,代码来源:DomainAutoApproval.php

示例4: generatePage

/**
 * Generate statistics for the given period
 *
 * @param iMSCP_pTemplate $tpl Template engine instance
 * @return void
 */
function generatePage($tpl)
{
    $domainId = get_user_domain_id($_SESSION['user_id']);
    if (isset($_POST['month']) && isset($_POST['year'])) {
        $year = intval($_POST['year']);
        $month = intval($_POST['month']);
    } else {
        if (isset($_GET['month']) && isset($_GET['year'])) {
            $month = intval($_GET['month']);
            $year = intval($_GET['year']);
        } else {
            $month = date('m');
            $year = date('Y');
        }
    }
    $stmt = exec_query('SELECT dtraff_time FROM domain_traffic WHERE domain_id = ? ORDER BY dtraff_time ASC LIMIT 1', $domainId);
    if ($stmt->rowCount()) {
        $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
        $numberYears = date('y') - date('y', $row['dtraff_time']);
        $numberYears = $numberYears ? $numberYears + 1 : 1;
    } else {
        $numberYears = 1;
    }
    generateMonthsAndYearsHtmlList($tpl, $month, $year, $numberYears);
    $stmt = exec_query('SELECT domain_id FROM domain_traffic WHERE domain_id = ? AND dtraff_time >= ? AND dtraff_time <= ? LIMIT 1', array($domainId, getFirstDayOfMonth($month, $year), getLastDayOfMonth($month, $year)));
    if ($stmt->rowCount()) {
        $requestedPeriod = getLastDayOfMonth($month, $year);
        $toDay = $requestedPeriod < time() ? date('j', $requestedPeriod) : date('j');
        $all = array_fill(0, 8, 0);
        $dateFormat = iMSCP_Registry::get('config')->DATE_FORMAT;
        for ($fromDay = 1; $fromDay <= $toDay; $fromDay++) {
            $beginTime = mktime(0, 0, 0, $month, $fromDay, $year);
            $endTime = mktime(23, 59, 59, $month, $fromDay, $year);
            list($webTraffic, $ftpTraffic, $smtpTraffic, $popTraffic) = _getUserTraffic($domainId, $beginTime, $endTime);
            $tpl->assign(array('DATE' => tohtml(date($dateFormat, strtotime($year . '-' . $month . '-' . $fromDay))), 'WEB_TRAFF' => tohtml(bytesHuman($webTraffic)), 'FTP_TRAFF' => tohtml(bytesHuman($ftpTraffic)), 'SMTP_TRAFF' => tohtml(bytesHuman($smtpTraffic)), 'POP_TRAFF' => tohtml(bytesHuman($popTraffic)), 'SUM_TRAFF' => tohtml(bytesHuman($webTraffic + $ftpTraffic + $smtpTraffic + $popTraffic))));
            $all[0] += $webTraffic;
            $all[1] += $ftpTraffic;
            $all[2] += $smtpTraffic;
            $all[3] += $popTraffic;
            $tpl->parse('TRAFFIC_TABLE_ITEM', '.traffic_table_item');
        }
        $tpl->assign(array('WEB_ALL' => tohtml(bytesHuman($all[0])), 'FTP_ALL' => tohtml(bytesHuman($all[1])), 'SMTP_ALL' => tohtml(bytesHuman($all[2])), 'POP_ALL' => tohtml(bytesHuman($all[3])), 'SUM_ALL' => tohtml(bytesHuman(array_sum($all)))));
    } else {
        set_page_message(tr('No statistics found for the given period. Try another period.'), 'static_info');
        $tpl->assign('STATISTICS_BLOCK', '');
    }
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:53,代码来源:traffic_statistics.php

示例5: gen_db_list

/**
 * @param EasySCP_TemplateEngine $tpl
 * @param EasySCP_Database $sql
 * @param int $user_id
 */
function gen_db_list($tpl, $sql, $user_id)
{
    $dmn_id = get_user_domain_id($user_id);
    $query = "\n\t\tSELECT\n\t\t\t`sqld_id`, `sqld_name`\n\t\tFROM\n\t\t\t`sql_database`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\tORDER BY\n\t\t\t`sqld_name`\n\t";
    $rs = exec_query($sql, $query, $dmn_id);
    if ($rs->recordCount() == 0) {
        set_page_message(tr('Database list is empty!'), 'info');
        $tpl->assign('DB_LIST', '');
    } else {
        while (!$rs->EOF) {
            $db_id = $rs->fields['sqld_id'];
            $db_name = $rs->fields['sqld_name'];
            $num = gen_db_user_list($tpl, $sql, $db_id);
            $tpl->append(array('DB_ID' => $db_id, 'DB_NAME' => tohtml($db_name), 'DB_NAME_JS' => tojs($db_name), 'DB_MSG' => $num ? '' : tr('Database user list is empty!')));
            $rs->moveNext();
        }
    }
}
开发者ID:gOOvER,项目名称:EasySCP,代码行数:23,代码来源:sql_manage.php

示例6: onAfterAddDomainAlias

 /**
  * 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;
     }
 }
开发者ID:reneschuster,项目名称:plugins,代码行数:49,代码来源:DomainAutoApproval.php

示例7: exec_query

                $rs = exec_query($sql, $query, array($dmn_id, $uname, $upass));
                $admin_login = $_SESSION['user_logged'];
                write_log("{$admin_login}: add user (protected areas) -> {$uname}");
                header('Location: puser_manage.php');
                die;
            } else {
                set_page_message(tr('User already exist !'));
                return;
            }
        }
    } else {
        return;
    }
}
/*
 *
 * static page messages.
 *
 */
gen_client_menu($tpl);
gen_logged_from($tpl);
check_permissions($tpl);
padd_user($tpl, $sql, get_user_domain_id($sql, $_SESSION['user_id']));
$tpl->assign(array('TR_HTACCESS' => tr('Protected areas'), 'TR_ACTION' => tr('Action'), 'TR_USER_MANAGE' => tr('Manage user'), 'TR_USERS' => tr('User'), 'TR_USERNAME' => tr('Username'), 'TR_ADD_USER' => tr('Add user'), 'TR_GROUPNAME' => tr('Group name'), 'TR_GROUP_MEMBERS' => tr('Group members'), 'TR_ADD_GROUP' => tr('Add group'), 'TR_EDIT' => tr('Edit'), 'TR_GROUP' => tr('Group'), 'TR_DELETE' => tr('Delete'), 'TR_GROUPS' => tr('Groups'), 'TR_PASSWORD' => tr('Password'), 'TR_PASSWORD_REPEAT' => tr('Password repeat'), 'TR_CANCEL' => tr('Cancel')));
gen_page_message($tpl);
$tpl->parse('PAGE', 'page');
$tpl->prnt();
if (isset($cfg['DUMP_GUI_DEBUG'])) {
    dump_gui_debug();
}
unset_messages();
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:31,代码来源:puser_uadd.php

示例8: add_domain_alias

function add_domain_alias(&$sql, &$err_al)
{
    global $cr_user_id, $alias_name, $domain_ip, $forward, $mount_point;
    $cr_user_id = $domain_id = get_user_domain_id($sql, $_SESSION['user_id']);
    $alias_name = strtolower($_POST['ndomain_name']);
    $mount_point = strtolower($_POST['ndomain_mpoint']);
    $forward = $_POST['forward'];
    $query = <<<SQL_QUERY
        select
            domain_ip_id
        from
            domain
        where
            domain_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($cr_user_id));
    $domain_ip = $rs->fields['domain_ip_id'];
    $alias_name = get_punny($alias_name);
    //$mount_point = "/".$mount_point;
    // Fisrt check is the data correct
    if (chk_dname($alias_name) > 0) {
        $err_al = tr("Incorrect domain name syntax");
    } else {
        if (vhcs_domain_exists($alias_name, 0)) {
            $err_al = tr('Domain with that name already exists on the system!');
        } else {
            if (chk_mountp($mount_point) > 0) {
                $err_al = tr("Incorrect mount point syntax");
            } else {
                if ($forward != 'no') {
                    if (chk_url($forward) > 0) {
                        $err_al = tr("Incorrect forward syntax");
                    }
                } else {
                    $query = "select domain_id from domain_aliasses where alias_name=?";
                    $res = exec_query($sql, $query, array($alias_name));
                    $query = "select domain_id from domain where domain_name=?";
                    $res2 = exec_query($sql, $query, array($alias_name));
                    if ($res->RowCount() > 0 or $res2->RowCount() > 0) {
                        // we already have domain with this name
                        $err_al = tr("Domain with this name already exist");
                    }
                    // all seems ok - add it
                    $query = "select count(alias_id) as cnt from domain_aliasses where domain_id=? and alias_mount=?";
                    $mres = exec_query($sql, $query, array($cr_user_id, $mount_point));
                    $mdata = $mres->FetchRow();
                    $query = "select count(subdomain_id) as cnt from subdomain where domain_id=? and subdomain_mount=?";
                    $subdomres = exec_query($sql, $query, array($cr_user_id, $mount_point));
                    $subdomdata = $subdomres->FetchRow();
                    if ($mdata['cnt'] > 0 || $subdomdata['cnt'] > 0) {
                        // whe have alias with same mount point !!! ERROR
                        $err_al = tr("There are alias with same mount point");
                    }
                }
            }
        }
    }
    if ('_off_' !== $err_al) {
        return;
    }
    // Begin add new alias domain
    $alias_name = htmlspecialchars($alias_name, ENT_QUOTES, "UTF-8");
    check_for_lock_file();
    global $cfg;
    $status = $cfg['ITEM_ADD_STATUS'];
    $query = "insert into domain_aliasses(domain_id, alias_name, alias_mount, alias_status, alias_ip_id, url_forward) values (?, ?, ?, ?, ?, ?)";
    exec_query($sql, $query, array($cr_user_id, $alias_name, $mount_point, $status, $domain_ip, $forward));
    send_request();
    $admin_login = $_SESSION['user_logged'];
    write_log("{$admin_login}: add domain alias -> {$alias_name}");
    set_page_message(tr('Alias scheduled for addition!'));
    header("Location: manage_domains.php");
    die;
}
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:74,代码来源:add_alias.php

示例9: check_login

 * isp Control Panel. All Rights Reserved.
 *
 * Portions created by the i-MSCP Team are Copyright (C) 2010-2016 by
 * i-MSCP - internet Multi Server Control Panel. All Rights Reserved.
 */
/***********************************************************************************************************************
 * Main
 */
require_once 'imscp-lib.php';
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
check_login('user');
if (!customerHasFeature('domain_aliases') || !isset($_GET['id'])) {
    showBadRequestErrorPage();
}
$id = clean_input($_GET['id']);
$stmt = exec_query("\n        SELECT\n            t1.subdomain_alias_id, CONCAT(t1.subdomain_alias_name, '.', t2.alias_name) AS subdomain_alias_name\n        FROM\n            subdomain_alias AS t1\n        INNER JOIN\n            domain_aliasses AS t2 ON (t2.alias_id = t1.alias_id)\n        WHERE\n            t2.domain_id = ?\n        AND\n            t1.subdomain_alias_id = ?\n    ", array(get_user_domain_id($_SESSION['user_id']), $id));
if (!$stmt->rowCount()) {
    showBadRequestErrorPage();
}
$row = $stmt->fetchRow(PDO::FETCH_ASSOC);
$name = $row['subdomain_alias_name'];
$stmt = exec_query('SELECT mail_id FROM mail_users WHERE (mail_type LIKE ? OR mail_type = ?) AND sub_id = ? LIMIT 1', array(MT_ALSSUB_MAIL . '%', MT_ALSSUB_FORWARD, $id));
if ($stmt->rowCount()) {
    set_page_message(tr('Subdomain you are trying to remove has email accounts. Please remove them first.'), 'error');
    redirectTo('domains_manage.php');
}
$stmt = exec_query('SELECT userid FROM ftp_users WHERE userid LIKE ? LIMIT 1', "%@{$name}");
if ($stmt->rowCount()) {
    set_page_message(tr('Subdomain alias you are trying to remove has Ftp accounts. Please remove them first.'), 'error');
    redirectTo('domains_manage.php');
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:31,代码来源:alssub_delete.php

示例10: add_sql_user

function add_sql_user(&$sql, $user_id, $db_id)
{
    global $cfg;
    if (!isset($_POST['uaction'])) {
        return;
    }
    //
    // let's check user input;
    //
    if ($_POST['user_name'] === '' && !isset($_POST['Add_Exist'])) {
        set_page_message(tr('Please type user name!'));
        return;
    }
    if ($_POST['pass'] === '' && $_POST['pass_rep'] === '' && !isset($_POST['Add_Exist'])) {
        set_page_message(tr('Please type user password!'));
        return;
    }
    if ($_POST['pass'] !== $_POST['pass_rep'] && !isset($_POST['Add_Exist'])) {
        set_page_message(tr('Entered passwords does not match!'));
        return;
    }
    if (strlen($_POST['pass']) > $cfg['MAX_SQL_PASS_LENGTH'] && !isset($_POST['Add_Exist'])) {
        set_page_message(tr('Too user long password!'));
        return;
    }
    if (isset($_POST['Add_Exist'])) {
        $query = "SELECT sqlu_pass FROM sql_user WHERE sqlu_id = ?";
        $rs = exec_query($sql, $query, array($_POST['sqluser_id']));
        if ($rs->RecordCount() == 0) {
            set_page_message(tr('SQL-user not found! Maybe it was deleted by another user!'));
            return;
        }
        $user_pass = $rs->fields['sqlu_pass'];
    } else {
        $user_pass = $_POST['pass'];
    }
    $dmn_id = get_user_domain_id($sql, $user_id);
    if (!isset($_POST['Add_Exist'])) {
        //
        // we'll use domain_id in the name of the database;
        //
        if (isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] === 'on' && isset($_POST['id_pos']) && $_POST['id_pos'] === 'start') {
            $db_user = $dmn_id . "_" . $_POST['user_name'];
        } else {
            if (isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] === 'on' && isset($_POST['id_pos']) && $_POST['id_pos'] === 'end') {
                $db_user = $_POST['user_name'] . "_" . $dmn_id;
            } else {
                $db_user = $_POST['user_name'];
            }
        }
    } else {
        if (isset($_POST['Add_Exist'])) {
            $query = "SELECT sqlu_name FROM sql_user WHERE sqlu_id = ?";
            $rs = exec_query($sql, $query, array($_POST['sqluser_id']));
            $db_user = $rs->fields['sqlu_name'];
        }
    }
    if (strlen($db_user) > $cfg['MAX_SQL_USER_LENGTH']) {
        set_page_message(tr('User name too long!'));
        return;
    }
    // are wildcards used?
    //
    if (ereg("\\%|\\?", $db_user)) {
        set_page_message(tr('Wildcards as % and ? are not allowed!'));
        return;
    }
    //
    // have we such sql user in the system?!
    //
    if (check_db_user($sql, $db_user) && !isset($_POST['Add_Exist'])) {
        set_page_message(tr('Specified SQL username name already exists!'));
        return;
    }
    //
    // add user in the vhcs table;
    //
    $query = <<<SQL_QUERY
        insert into sql_user
            (sqld_id, sqlu_name, sqlu_pass)
        values
            (?, ?, ?)
SQL_QUERY;
    $rs = exec_query($sql, $query, array($db_id, $db_user, $user_pass));
    $query = <<<SQL_QUERY
        select
            sqld_name as db_name
        from
            sql_database
        where
            sqld_id = ?
          and
            domain_id = ?
SQL_QUERY;
    $rs = exec_query($sql, $query, array($db_id, $dmn_id));
    $db_name = $rs->fields['db_name'];
    //
    // add user in the mysql system tables;
    //
    $new_db_name = ereg_replace("_", "\\_", $db_name);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:101,代码来源:sql_add_user.php

示例11: execute_sql_query

function execute_sql_query(&$tpl, &$sql, $user_id, $db_user_id)
{
    // add_sql_user($sql, $_SESSION['user_id'], $db_id);
    // $query = "insert into log (log_time, log_message) values ('2', 'def')";
    // $query = "select * from mail_users;";
    // $rs = execute_query($sql, $query);
    // $query_tbl_result = sql_rs2html($rs);
    global $cfg;
    if (!isset($_POST['uaction'])) {
        return;
    }
    //
    // let's check user input;
    //
    if ($_POST['sql_query'] === '') {
        set_page_message(tr('Please enter SQL query!'));
        $tpl->assign('SQL_RESULT', '');
        return;
    }
    $dmn_id = get_user_domain_id($sql, $user_id);
    $query = <<<SQL_QUERY
       select
           t1.*,
           t2.sqld_name
       from
           sql_user as t1,
           sql_database as t2
       where
           t1.sqld_id = t2.sqld_id
         and
           t1.sqlu_id = ?
         and
           t2.domain_id = ?
\t\t ORDER BY
\t\t   t2.sqld_name asc,
\t\t   t1.sqlu_name asc 
SQL_QUERY;
    $rs = exec_query($sql, $query, array($db_user_id, $dmn_id));
    $db_user_name = $rs->fields['sqlu_name'];
    $db_user_pass = $rs->fields['sqlu_pass'];
    $db_name = $rs->fields['sqld_name'];
    $sql_user =& ADONewConnection('mysql');
    if (!@$sql_user->Connect($cfg['DB_HOST'], $db_user_name, $db_user_pass, $db_name)) {
        set_page_message(tr('Cannot connect as MySQL administrator!'));
        $tpl->assign('SQL_RESULT', '');
        return;
    }
    $query = $_POST['sql_query'];
    $query = stripslashes($query);
    $rs = $sql_user->Execute($query);
    if (!$rs) {
        $tpl->assign(array('QUERY_STATUS' => tr('SQL query has error'), 'QUERY_RESULT' => $sql_user->ErrorMsg()));
    } else {
        write_log($_SESSION['user_logged'] . " : execute SQL query");
        $tpl->assign(array('QUERY_STATUS' => tr('SQL query is ok'), 'QUERY_RESULT' => sql_rs2html($rs)));
    }
}
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:57,代码来源:sql_execute_query.php

示例12: updateDomainStatuses

 /**
  * Update domain statuses and send request to i-MSCP daemon
  *
  * @throws iMSCP_Exception
  * @throws iMSCP_Exception_Database
  * @param string $configLevel PHP configuration level (per_user|per_domain|per_site)
  * @param int $adminId Owner uique identifier
  * @param int $domainId Domain unique identifier
  * @param string $domainType Domain type (dmn|als|sub|subals)
  */
 public function updateDomainStatuses($configLevel, $adminId, $domainId, $domainType)
 {
     if ($configLevel == 'per_user') {
         $domainId = get_user_domain_id($adminId);
         exec_query("UPDATE domain SET domain_status = ? WHERE domain_id = ? AND domain_status NOT IN('disabled', 'todelete')", array('tochange', $domainId));
         exec_query("\n                    UPDATE domain_aliasses SET alias_status = ?\n                    WHERE domain_id = ? AND alias_status NOT IN ('disabled', 'todelete')\n                ", array('tochange', $domainId));
     } else {
         switch ($domainType) {
             case 'dmn':
                 $query = "\n                        UPDATE domain SET domain_status = 'tochange'\n                        WHERE domain_admin_id = ? AND domain_id = ? AND domain_status NOT IN ('disabled', 'todelete')\n                    ";
                 break;
             case 'sub':
                 $query = "\n                        UPDATE subdomain INNER JOIN domain USING(domain_id) SET subdomain_status = 'tochange'\n                        WHERE domain_admin_id = ? AND subdomain_id = ?\n                        AND subdomain_status NOT IN ('disabled','todelete')\n                    ";
                 break;
             case 'als':
                 $query = "\n                        UPDATE domain_aliasses INNER JOIN domain USING(domain_id) SET alias_status = 'tochange'\n                        WHERE domain_admin_id = ? AND alias_id = ? AND alias_status NOT IN ('disabled','todelete')\n                    ";
                 break;
             case 'subals':
                 $query = "\n                        UPDATE subdomain_alias INNER JOIN domain_aliasses USING(alias_id) INNER JOIN domain USING(domain_id)\n                        SET subdomain_alias_status = 'tochange'\n                        WHERE domain_admin_id = ? AND subdomain_alias_id = ? AND subdomain_alias_status NOT IN ('disabled','todelete')\n                    ";
                 break;
             default:
                 throw new iMSCP_Exception('Unknown domain type');
         }
         exec_query($query, array($adminId, $domainId));
     }
 }
开发者ID:svenjantzen,项目名称:imscp,代码行数:36,代码来源:PHPini.php

示例13: exec_query

\t\t\tid = ?
\t\tand
\t\t\tuser_id = ?
\t\tand 
\t\t\tstatus = 'update'
SQL_QUERY;
    $rs = exec_query($sql, $query, array($order_id, $reseller_id));
}
if ($rs->RecordCount() == 0) {
    set_page_message(tr('Permission deny!'));
    header('Location: orders.php');
    die;
}
$hpid = $rs->fields['plan_id'];
$customer_id = $rs->fields['customer_id'];
$dmn_id = get_user_domain_id($sql, $customer_id);
//lets check the reseller limits
$err_msg = '_off_';
if (isset($cfg['HOSTING_PLANS_LEVEL']) && $cfg['HOSTING_PLANS_LEVEL'] === 'admin') {
    $query = "select props from hosting_plans where id = ?";
    $res = exec_query($sql, $query, array($hpid));
} else {
    $query = "select props from hosting_plans where reseller_id = ? and id = ?";
    $res = exec_query($sql, $query, array($reseller_id, $hpid));
}
$data = $res->FetchRow();
$props = $data['props'];
$_SESSION["ch_hpprops"] = $props;
reseller_limits_check($sql, $err_msg, $reseller_id, $hpid);
if ($err_msg != '_off_') {
    set_page_message($err_msg);
开发者ID:BackupTheBerlios,项目名称:vhcs-svn,代码行数:31,代码来源:orders_update.php

示例14: client_addSqlUser

/**
 * Add SQL user for the given database
 *
 * @throws Exception
 * @throws iMSCP_Exception_Database
 * @param int $customerId Customer unique identifier
 * @param int $dbId
 * @return void
 */
function client_addSqlUser($customerId, $dbId)
{
    if (empty($_POST)) {
        return;
    }
    if (!isset($_POST['uaction'])) {
        showBadRequestErrorPage();
    }
    $dmnId = get_user_domain_id($customerId);
    if (!isset($_POST['Add_Exist'])) {
        $needUserCreate = true;
        if (!isset($_POST['user_name']) || !isset($_POST['user_host']) || !isset($_POST['pass']) || !isset($_POST['pass_rep'])) {
            showBadRequestErrorPage();
        }
        $user = clean_input($_POST['user_name']);
        $host = clean_input($_POST['user_host']);
        $password = clean_input($_POST['pass']);
        $passwordConf = clean_input($_POST['pass_rep']);
        if ($user === '') {
            set_page_message(tr('Please enter an username.'), 'error');
            return;
        }
        if (preg_match('/[%|\\?]+/', $user)) {
            set_page_message(tr("Wildcards such as '%s' and '%s' are not allowed in username.", '%', '?'), 'error');
            return;
        }
        if ($host === '') {
            set_page_message(tr('Please enter an SQL user host.'), 'error');
            return;
        }
        $host = encode_idna(clean_input($_POST['user_host']));
        if ($host !== '%' && $host !== 'localhost' && !iMSCP_Validate::getInstance()->hostname($host, array('allow' => Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_IP))) {
            set_page_message(tr('Invalid SQL user host: %s', iMSCP_Validate::getInstance()->getLastValidationMessages()), 'error');
            return;
        }
        if ($password === '') {
            set_page_message(tr('Please enter a password.'), 'error');
            return;
        }
        if ($password !== $passwordConf) {
            set_page_message(tr("Passwords do not match."), 'error');
            return;
        }
        if (strlen($password) > 32) {
            set_page_message(tr('Password is too long.'), 'error');
            return;
        }
        if (!checkPasswordSyntax($password)) {
            set_page_message(tr('Only printable characters from the ASCII table (not extended), excepted the space, are allowed.'), 'error');
            return;
        }
        if (isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] == 'on' && isset($_POST['id_pos']) && $_POST['id_pos'] == 'start') {
            $user = $dmnId . '_' . clean_input($_POST['user_name']);
        } elseif (isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] == 'on' && isset($_POST['id_pos']) && $_POST['id_pos'] == 'end') {
            $user = clean_input($_POST['user_name']) . '_' . $dmnId;
        } else {
            $user = clean_input($_POST['user_name']);
        }
        if (strlen($user) > 16) {
            set_page_message(tr('Username is too long.'), 'error');
            return;
        }
        if (client_isSqlUser($user, $host)) {
            set_page_message(tr('SQL user %s already exits.', $user . '@' . decode_idna($host)), 'error');
            return;
        }
    } elseif (isset($_POST['sqluser_id'])) {
        // Using existing SQL user as specified in input data
        $needUserCreate = false;
        $userId = intval($_POST['sqluser_id']);
        $stmt = exec_query('SELECT sqlu_name, sqlu_host, sqlu_pass FROM sql_user WHERE sqlu_id = ?', $userId);
        if (!$stmt->rowCount()) {
            showBadRequestErrorPage();
        }
        $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
        $user = $row['sqlu_name'];
        $host = $row['sqlu_host'];
        $password = $row['sqlu_pass'];
    } else {
        showBadRequestErrorPage();
        return;
    }
    # Retrieve database to which SQL user should be assigned
    $stmt = exec_query('SELECT sqld_name FROM sql_database WHERE sqld_id = ? AND domain_id = ?', array($dbId, $dmnId));
    if (!$stmt->rowCount()) {
        showBadRequestErrorPage();
    }
    $row = $stmt->fetchRow(PDO::FETCH_ASSOC);
    $dbName = $row['sqld_name'];
    $dbName = preg_replace('/([_%\\?\\*])/', '\\\\$1', $dbName);
    $config = iMSCP_Registry::get('config');
//.........这里部分代码省略.........
开发者ID:svenjantzen,项目名称:imscp,代码行数:101,代码来源:sql_user_add.php

示例15: client_addSqlDb

/**
 * Add SQL database
 *
 * @param int $userId
 * @return void
 */
function client_addSqlDb($userId)
{
    if (!isset($_POST['uaction'])) {
        return;
    }
    if (!isset($_POST['db_name'])) {
        showBadRequestErrorPage();
    }
    $dbName = clean_input($_POST['db_name']);
    if ($_POST['db_name'] === '') {
        set_page_message(tr('Please type database name.'), 'error');
        return;
    }
    $mainDmnId = get_user_domain_id($userId);
    if (isset($_POST['use_dmn_id']) && $_POST['use_dmn_id'] === 'on') {
        if (isset($_POST['id_pos']) && $_POST['id_pos'] === 'start') {
            $dbName = $mainDmnId . '_' . $dbName;
        } elseif (isset($_POST['id_pos']) && $_POST['id_pos'] === 'end') {
            $dbName = $dbName . '_' . $mainDmnId;
        }
    }
    if (strlen($dbName) > 64) {
        set_page_message(tr('Database name is too long.'), 'error');
        return;
    }
    if ($dbName === 'test' || client_isDatabase($dbName)) {
        set_page_message(tr('Database name is unavailable.'), 'error');
        return;
    }
    if (preg_match('/[%|\\?]+/', $dbName)) {
        set_page_message(tr("Wildcards such as 's%' and 's%' are not allowed.", '%', '?'), 'error');
        return;
    }
    $responses = iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onBeforeAddSqlDb, array('dbName' => $dbName));
    if (!$responses->isStopped()) {
        execute_query(sprintf('CREATE DATABASE IF NOT EXISTS %s', quoteIdentifier($dbName)));
        exec_query('INSERT INTO sql_database (domain_id, sqld_name) VALUES (?, ?)', array($mainDmnId, $dbName));
        set_page_message(tr('SQL database successfully created.'), 'success');
        write_log(sprintf('%s added new SQL database: %s', decode_idna($_SESSION['user_logged']), $dbName), E_USER_NOTICE);
        iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAfterAddSqlDb, array('dbName' => $dbName));
    }
    redirectTo('sql_manage.php');
}
开发者ID:svenjantzen,项目名称:imscp,代码行数:49,代码来源:sql_database_add.php


注:本文中的get_user_domain_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。