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


PHP gs_db_master_connect函数代码示例

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


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

示例1: gs_huntgroups_get

function gs_huntgroups_get()
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get queues
    #
    $rs = $db->execute('SELECT
	`number`
FROM
	`huntgroups`
GROUP BY `number`
ORDER BY `number`');
    if (!$rs) {
        return new GsError('Error.');
    }
    $huntgroups = array();
    while ($r = $rs->fetchRow()) {
        $huntgroups[] = $r;
    }
    return $huntgroups;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:25,代码来源:gs_huntgroups_get.php

示例2: gs_clir_get

function gs_clir_get($user)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if (!$user_id) {
        return new GsError('Unknown user.');
    }
    # get state
    #
    $rs = $db->execute('SELECT `internal_restrict`, `external_restrict` FROM `clir` WHERE `user_id`=' . $user_id);
    if ($r = $rs->fetchRow()) {
        if (!in_array($r['internal_restrict'], array('no', 'yes', 'once'), true)) {
            $r['internal_restrict'] = 'no';
        }
        if (!in_array($r['external_restrict'], array('no', 'yes', 'once'), true)) {
            $r['external_restrict'] = 'no';
        }
        return $r;
    }
    return array('internal_restrict' => 'no', 'external_restrict' => 'no');
}
开发者ID:rkania,项目名称:GS3,代码行数:31,代码来源:gs_clir_get.php

示例3: gs_vm_activate

function gs_vm_activate($user, $source, $active)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    if (!in_array($source, array('internal', 'external'), true)) {
        return new GsError('Source must be internal|external.');
    }
    $active = (bool) $active;
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if (!$user_id) {
        return new GsError('Unknown user.');
    }
    # check if has mailbox
    #
    $num = $db->executeGetOne('SELECT COUNT(*) FROM `vm` WHERE `user_id`=' . $user_id);
    if ($num < 1) {
        return new GsError('User does not have a mailbox.');
    }
    # (de)activate
    #
    $ok = $db->execute('UPDATE `vm` SET `' . $source . '_active`=' . (int) $active . ' WHERE `user_id`=' . $user_id);
    if (!$ok) {
        return new GsError('Failed to set state.');
    }
    return true;
}
开发者ID:rkania,项目名称:GS3,代码行数:35,代码来源:gs_vm_activate.php

示例4: gs_agents_get

function gs_agents_get()
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get users
    #
    $rs = $db->execute('SELECT
	`id`, `name`, `firstname`, `number`,`pin`,`user_id`
FROM
	`agents`
ORDER BY
	`name`');
    if (!$rs) {
        return new GsError('Error.');
    }
    $agents = array();
    while ($r = $rs->fetchRow()) {
        $agents[] = $r;
    }
    return $agents;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:25,代码来源:gs_agents_get.php

示例5: gs_callwaiting_get

function gs_callwaiting_get($user)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if (!$user_id) {
        return new GsError('Unknown user.');
    }
    # get state
    #
    $rs = $db->execute('SELECT `active` FROM `callwaiting` WHERE `user_id`=' . $user_id);
    if ($r = $rs->fetchRow()) {
        return (bool) $r['active'];
    }
    return false;
}
开发者ID:rkania,项目名称:GS3,代码行数:25,代码来源:gs_callwaiting_get.php

示例6: gs_hosts_get

function gs_hosts_get($foreign = false, $group_id = null)
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get hosts
    #
    $where = array();
    if ($foreign !== null) {
        $where[] = '`is_foreign`=' . ($foreign ? '1' : '0');
    }
    if ($group_id !== null) {
        $where[] = '`group_id`=' . (int) $group_id;
    }
    $query = 'SELECT `id`, `host`, `comment`, `is_foreign`, `group_id`
FROM `hosts`
' . (count($where) === 0 ? '' : 'WHERE ' . implode(' AND ', $where)) . '
ORDER BY `is_foreign`,`host`';
    $rs = $db->execute($query);
    if (!$rs) {
        return new GsError('Error.');
    }
    $hosts = array();
    while ($r = $rs->fetchRow()) {
        $hosts[] = $r;
    }
    return $hosts;
}
开发者ID:rkania,项目名称:GS3,代码行数:31,代码来源:gs_hosts_get.php

示例7: gs_queues_get

function gs_queues_get()
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get queues
    #
    $rs = $db->execute('SELECT
	`q`.`_id` `id`, `q`.`name`, `q`.`_title` `title`, `q`.`maxlen`,
	COUNT(`m`.`_user_id`) `num_members`
FROM
	`ast_queues` `q` LEFT JOIN
	`ast_queue_members` `m` ON (m._queue_id=q._id)
GROUP BY `q`.`_id`
ORDER BY `q`.`name`');
    if (!$rs) {
        return new GsError('Error.');
    }
    $queues = array();
    while ($r = $rs->fetchRow()) {
        $queues[] = $r;
    }
    return $queues;
}
开发者ID:rkania,项目名称:GS3,代码行数:27,代码来源:gs_queues_get.php

示例8: gs_host_del

function gs_host_del($host, $force = FALSE)
{
    if (!preg_match('/^[0-9\\.]+$/', $host)) {
        return new GsError('Host must be a numeric ID or IP address.');
    }
    $host = gs_host_by_id_or_ip($host);
    if (isGsError($host)) {
        return new GsError($host->getMsg());
    }
    if (!is_array($host)) {
        return new GsError('Cannot retrieve host ID.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    $count_users = $db->executeGetOne('SELECT COUNT(`id`) FROM `users` WHERE `host_id`=\'' . $db->escape($host['id']) . '\'');
    if ($count_users > 0) {
        return new GsError('Cannot delete host. Delete ' . $count_users . ' user(s) on this host first.');
    }
    #delete host from all groups
    #
    gs_group_members_purge_by_type('host', array($host['id']));
    # delete host
    #
    $rs = $db->execute('DELETE from `hosts` WHERE `id`=\'' . $db->escape($host['id']) . '\'');
    if (!$rs) {
        return new GsError('Could not delete host ' . $host['id']);
    }
    return true;
}
开发者ID:rkania,项目名称:GS3,代码行数:33,代码来源:gs_host_del.php

示例9: gs_screensaver_get

function gs_screensaver_get($user)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if (!$user_id) {
        return new GsError('Unknown user.');
    }
    $screensaver = array();
    # get screensaver picture's
    #
    $rs = $db->execute('SELECT `pic_nr`, `file` FROM `screensaver` WHERE `user_id`=' . $user_id . ' ORDER BY `pic_nr` ASC');
    if (!$rs) {
        return new GsError('Failed to get screensaver pictures.');
    }
    while ($r = $rs->fetchRow()) {
        $pic_nr = (int) $r['pic_nr'];
        $screensaver[$pic_nr] = $r['file'];
    }
    return $screensaver;
}
开发者ID:sebastianertz,项目名称:gemeinschaft-grandstream,代码行数:30,代码来源:gs_screensaver_get.php

示例10: gs_queue_agent_del

function gs_queue_agent_del($queue_id, $agent)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $agent)) {
        return new GsError('User must be alphanumeric.');
    }
    $queue_id = (int) $queue_id;
    if ($queue_id < 1) {
        return new GsError('Bad queue ID.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # check queue id
    #
    $num = (int) $db->executeGetOne('SELECT COUNT(*) FROM `ast_queues` WHERE `_id`=' . $queue_id);
    if ($num < 1) {
        return new GsError('Unknown queue ID.');
    }
    # get agent_id
    #
    $agent_id = (int) $db->executeGetOne('SELECT `id` FROM `agents` WHERE `number`=\'' . $db->escape($agent) . '\'');
    if (!$agent_id) {
        return new GsError('Unknown agent.');
    }
    # delete agent to the queue
    #
    $ok = $db->execute('DELETE FROM `agent_queues` WHERE `agent_id`=' . $agent_id . ' AND `queue_id`= ' . $queue_id);
    if (!$ok) {
        return new GsError('Failed to delete agent from queue.');
    }
    return true;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:35,代码来源:gs_queue_agent_del.php

示例11: gs_user_comment_set

function gs_user_comment_set($user, $comment = '')
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    $comment = mb_subStr($comment, 0, 200);
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if (!$user_id) {
        return new GsError('Unknown user.');
    }
    # set comment
    #
    $ok = $db->execute('UPDATE `users` SET `user_comment`=\'' . $db->escape($comment) . '\' WHERE `id`=' . $user_id);
    if (!$ok) {
        return new GsError('Failed to set comment.');
    }
    return true;
}
开发者ID:rkania,项目名称:GS3,代码行数:26,代码来源:gs_user_comment_set.php

示例12: gs_user_phonemodel_get

function gs_user_phonemodel_get($user)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = (int) $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if ($user_id < 1) {
        return new GsError('Unknown user.');
    }
    # get phone-model
    #
    $type = $db->executeGetOne('SELECT `type` FROM `phones` WHERE `user_id`=' . $user_id);
    if (!$type) {
        return 'none';
    }
    return $type;
}
开发者ID:rkania,项目名称:GS3,代码行数:25,代码来源:gs_user_phonemodel_get.php

示例13: gs_huntgroup_del

function gs_huntgroup_del($hgroup_number)
{
    $hgroup_number = (int) $hgroup_number;
    if ($hgroup_number < 1) {
        return new GsError('Bad group ID.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # check group id
    #
    $num = (int) $db->executeGetOne('SELECT COUNT(*) FROM `huntgroups` WHERE `number`=' . $hgroup_number);
    if ($num < 1) {
        return new GsError('Unknown hunt group.');
    }
    # delete hun group
    #
    $ok = $db->execute('DELETE FROM `huntgroups` WHERE `number`=' . $hgroup_number);
    if (!$ok) {
        return new GsError('Failed to remove hunt group.');
    }
    return true;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:26,代码来源:gs_huntgroup_del.php

示例14: gs_agent_del

function gs_agent_del($agent)
{
    if (!preg_match('/^\\d+$/', $agent)) {
        return new GsError('Agent-number must be numeric.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $agent_id = (int) $db->executeGetOne('SELECT `id` FROM `agents` WHERE `number`=\'' . $db->escape($agent) . '\'');
    if (!$agent_id) {
        return new GsError('Unknown agent.');
    }
    # delete agent_queues
    #
    $ok = $db->execute('DELETE FROM `agent_queues` WHERE `agent_id`=' . $agent_id);
    # delete user
    #
    $ok = $db->execute('DELETE FROM `agents` WHERE `id`=' . $agent_id);
    return true;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:25,代码来源:gs_agent_del.php

示例15: gs_agent_pause_unpause

function gs_agent_pause_unpause($agent_id, $pause, $reason = '')
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `user_id` FROM `agents` WHERE `id`=\'' . $db->escape($agent_id) . '\'');
    if (!$user_id || $user_id <= 0) {
        return new GsError('Unknown agent.');
    }
    # get sip user
    #
    $user_name = $db->executeGetOne('SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`=\'' . $db->escape($user_id) . '\'');
    if (!$user_name) {
        return new GsError('Unknown user.');
    }
    # switch pause state
    #
    gs_queuepause_unpause($user_name, $pause, $reason);
    return true;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:25,代码来源:gs_agent_pause_unpause.php


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