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


PHP gs_db_slave_connect函数代码示例

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


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

示例1: getOurHostID

function getOurHostID()
{
    $db = gs_db_slave_connect();
    $rs = $db->execute('SELECT `id`, `host` FROM `hosts`');
    $hosts = array();
    while ($r = $rs->fetchRow()) {
        $hosts[] = $r;
    }
    $ips = array();
    foreach ($hosts as $h) {
        $h['host'] = trim(normalizeIPs($h['host']));
        if (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $h['host'])) {
            $ips[$h['host']] = $h['id'];
        } else {
            $tmp = getHostByNameL($h['host']);
            if (is_array($tmp)) {
                foreach ($tmp as $ip) {
                    $ips[normalizeIPs($ip)] = $h['id'];
                }
            }
        }
    }
    unset($hosts);
    $ifconfig = normalizeIPs(trim(@shell_exec('ifconfig 2>>/dev/null')));
    foreach ($ips as $ip => $hostid) {
        if (strPos($ifconfig, $ip) !== false) {
            return $hostid;
        }
    }
    return false;
}
开发者ID:rkania,项目名称:GS3,代码行数:31,代码来源:_get_our_host_id.php

示例2: gs_user_ip_by_ext

function gs_user_ip_by_ext($ext)
{
    if (!preg_match('/^[\\d]+$/', $ext)) {
        return new GsError('Extension must be numeric.');
    }
    # connect to db
    #
    $db = gs_db_slave_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = (int) $db->executeGetOne('SELECT `_user_id` FROM `ast_sipfriends` WHERE `name`=\'' . $db->escape($ext) . '\'');
    if (!$user_id) {
        return new GsError('Unknown extension.');
    }
    # get IP address
    #
    $current_ip = $db->executeGetOne('SELECT `current_ip` FROM `users` WHERE `id`=' . $user_id);
    if (!$current_ip) {
        return null;
    }
    # check if the user is actually logged in at a phone (or if that
    # IP address is an outdated entry)
    #
    $phone_id = (int) $db->executeGetOne('SELECT `id` FROM `phones` WHERE `user_id`=' . $user_id . ' LIMIT 1');
    if ($phone_id < 1) {
        return null;
    }
    return $current_ip;
}
开发者ID:rkania,项目名称:GS3,代码行数:32,代码来源:gs_user_ip_by_ext.php

示例3: gs_user_missedcalls_get

function gs_user_missedcalls_get($user, $queue = false)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    # connect to db
    #
    $db = gs_db_slave_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 count
    #
    if (!$queue) {
        $count = $db->executeGetOne('SELECT Count(*) FROM `dial_log` WHERE `queue_id` IS NULL AND `read`=0 AND `type`=\'missed\' AND `user_id`=' . $user_id);
    } else {
        $count = $db->executeGetOne('SELECT Count(*) FROM `dial_log` WHERE `queue_id` IS NOT NULL AND `read`=0 AND `type`=\'missed\' AND `user_id`=' . $user_id);
    }
    if (!$count) {
        return 0;
    }
    return $count;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:29,代码来源:gs_user_missedcalls_get.php

示例4: _get_user

function _get_user()
{
    $db = gs_db_slave_connect();
    $remote_addr = @$_SERVER['REMOTE_ADDR'];
    //FIXME
    $user_name = (string) $db->executeGetOne('SELECT `user`, `nobody_index` FROM `users` WHERE `current_ip`=\'' . $db->escape($remote_addr) . '\'');
    return gs_user_get($user_name);
}
开发者ID:rkania,项目名称:GS3,代码行数:8,代码来源:login.php

示例5: gs_get_listen_to_ids

function gs_get_listen_to_ids($primary_only = false)
{
    /*
    if (gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
    	# return special host ID
    	return array(-1);
    }
    */
    $GS_INSTALLATION_TYPE_SINGLE = gs_get_conf('GS_INSTALLATION_TYPE_SINGLE');
    if (!$GS_INSTALLATION_TYPE_SINGLE) {
        # get our IPs
        #
        $ips = @gs_get_listen_to_ips($primary_only);
        if (!is_array($ips)) {
            # kann entweder passieren wenn wir ein Gemeinschaft-Node sind
            # (dann ist es extrem schlecht wenn die Datei fehlt) oder wenn
            # wir ein Web-Server ohne Asterisk sind (dann ist es ok)
            gs_log(GS_LOG_DEBUG, "Failed to get our IP addresses");
            return array();
        }
        if (count($ips) < 1) {
            gs_log(GS_LOG_DEBUG, "We're not configured to listen to any IP addresses");
            return array();
        }
    }
    # connect to db
    # must be to slave db so we can tell our IDs even if the master is down
    #
    $db = gs_db_slave_connect();
    if (!$db) {
        gs_log(GS_LOG_WARNING, "Failed to connect to the database!");
        return array();
    }
    if (!$GS_INSTALLATION_TYPE_SINGLE) {
        # find the corresponding IDs
        #
        $ips_escaped = array();
        foreach ($ips as $ip) {
            $ips_escaped[] = '\'' . $db->escape($ip) . '\'';
        }
        // count($ips) guaranteed to be > 0
        $query = 'SELECT `id` FROM `hosts` WHERE `host` IN (' . implode(',', $ips_escaped) . ')';
    } else {
        $query = 'SELECT `id` FROM `hosts`';
    }
    $rs = $db->execute($query);
    if (!$rs) {
        gs_log(GS_LOG_WARNING, "Database error!");
        return array();
    }
    $ids = array();
    while ($r = $rs->fetchRow()) {
        $ids[] = (int) $r['id'];
    }
    return $ids;
}
开发者ID:rkania,项目名称:GS3,代码行数:56,代码来源:get-listen-to-ids.php

示例6: _get_user_ext

function _get_user_ext($user_id)
{
    $db = gs_db_slave_connect();
    $user_ext = $db->executeGetOne('SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`=\'' . $db->escape($user_id) . '\'');
    if (!$user_ext) {
        snom_textscreen(__('Fehler'), __('Unbekannter Benutzer.'));
        return false;
    }
    return $user_ext;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:10,代码来源:login.php

示例7: gs_sysrec_hash_get

function gs_sysrec_hash_get($sysrec_id)
{
    if (!preg_match('/^[0-9]+$/', $sysrec_id)) {
        return new GsError('Sysrecid must be numeric.');
    }
    # connect to db
    #
    $db = gs_db_slave_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    $filename = $db->executeGetOne('SELECT `md5hashname` FROM `systemrecordings` WHERE id =' . $sysrec_id);
    if (strlen($filename) > 0) {
        return $filename;
    } else {
        return new GsError('No such sysrec.');
    }
}
开发者ID:rkania,项目名称:GS3,代码行数:18,代码来源:gs_sysrec_hash_get.php

示例8: gs_user_name_by_ext

function gs_user_name_by_ext($ext)
{
    if (!preg_match('/^[\\d]+$/', $ext)) {
        return new GsError('Extension must be numeric.');
    }
    # connect to db
    #
    $db = gs_db_slave_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_name = $db->executeGetOne('SELECT `user` FROM `users` `u`, `ast_sipfriends` `a` WHERE `a`.`name`=\'' . $db->escape($ext) . '\' AND `a`.`_user_id` = `u`.`id`');
    if (!$user_name) {
        return new GsError('Unknown user for extension ' . $ext . '.');
    }
    return $user_name;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:19,代码来源:gs_user_name_by_ext.php

示例9: _getUser

 function _getUser()
 {
     $user_entered = strToLower(trim(@$_REQUEST['login_user']));
     $pwd_entered = @$_REQUEST['login_pwd'];
     if ($user_entered == '' || $pwd_entered == '') {
         return false;
     }
     if ($user_entered === 'sysadmin' && in_array(gs_get_conf('GS_INSTALLATION_TYPE'), array('gpbx', 'single'), true)) {
         //FIXME
         //Quickhack: sysadmin only valid for /gemeinschaft/setup
         $pin = false;
     } else {
         $db = gs_db_slave_connect();
         if (!$db) {
             return false;
         }
         $pin = $db->executeGetOne('SELECT `pin` FROM `users` WHERE `user`=\'' . $db->escape($user_entered) . '\'');
     }
     return $pin === $pwd_entered ? $user_entered : false;
 }
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:20,代码来源:gemeinschaft.php

示例10: get_all_room_states

function get_all_room_states()
{
    ## connect to db
    #
    $db = gs_db_slave_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    $rs = $db->execute('SELECT
	`extension`, `state`
FROM
	`room_state`');
    if (!$rs) {
        return new GsError('DB-Error.');
    }
    $result = array();
    while ($res = $rs->fetchRow()) {
        $result[] = $res;
    }
    return $result;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:21,代码来源:gs_room_state_fns.php

示例11: gs_callforward_get

function gs_callforward_get($user)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    # connect to db
    #
    $db = gs_db_slave_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 states
    #
    $sources = array('internal', 'external');
    $cases = array('always', 'busy', 'unavail', 'offline');
    $forwards = array();
    foreach ($sources as $source) {
        foreach ($cases as $case) {
            $rs = $db->execute('SELECT `active`, `number_std`, `number_var`, `number_vml`, `timeout`, `vm_rec_id` FROM `callforwards` WHERE `user_id`=' . $user_id . ' AND `source`=\'' . $source . '\' AND `case`=\'' . $case . '\'');
            if ($r = $rs->fetchRow()) {
                if (!in_array($r['active'], array('no', 'std', 'var', 'vml', 'ano', 'trl', 'par'), true)) {
                    $r['active'] = 'no';
                }
                $forwards[$source][$case] = $r;
            } else {
                $forwards[$source][$case] = array('active' => 'no', 'number_std' => '', 'number_var' => '', 'number_vml' => '', 'timeout' => 20, 'vm_rec_id' => 0);
            }
            if ($case != 'unavail') {
                $forwards[$source][$case]['timeout'] = null;
            }
        }
    }
    return $forwards;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:40,代码来源:gs_callforward_get.php

示例12: get_alert_tagets_by_time

function get_alert_tagets_by_time($hour, $minute)
{
    ## test input
    #
    if (!preg_match('/^[0-9]{1,2}$/', $hour)) {
        return new GsError('Hours are not numeric.');
    }
    $hour = (int) $hour;
    if ($hour < 0 || $hour >= 24) {
        return new GsError('Hours are out of bounds.');
    }
    if (!preg_match('/^[0-9]{1,2}$/', $minute)) {
        return new GsError('Minutes are not numeric.');
    }
    $minute = (int) $minute;
    if ($minute < 0 || $minute >= 60) {
        return new GsError('Minutes are out of bounds.');
    }
    ## connect to db
    #
    $db = gs_db_slave_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    $rs = $db->execute('SELECT
	`wakeup_calls`.`target`
FROM
	`wakeup_calls`
WHERE
	`hour` = ' . $db->escape($hour) . ' AND `minute` =' . $db->escape($minute));
    if (!$rs) {
        return new GsError('Error.');
    }
    $targets = array();
    while ($r = $rs->fetchRow()) {
        $targets[] = $r['target'];
    }
    return $targets;
}
开发者ID:rkania,项目名称:GS3,代码行数:39,代码来源:gs_wake_up_call_fns.php

示例13: _getUser_gemeinschaft

function _getUser_gemeinschaft()
{
    $user_entered = strToLower(trim(@$_REQUEST['login_user']));
    $pwd_entered = @$_REQUEST['login_pwd'];
    if ($user_entered == '' || $pwd_entered == '') {
        return false;
    }
    if ($user_entered === 'sysadmin' && in_array(gs_get_conf('GS_INSTALLATION_TYPE'), array('gpbx', 'single'), true)) {
        require_once GS_DIR . 'inc/keyval.php';
        $pin = trim(gs_keyval_get('setup_pwd'));
        if ($pin == '') {
            $pin = false;
        }
    } else {
        $db = gs_db_slave_connect();
        if (!$db) {
            return false;
        }
        $pin = $db->executeGetOne('SELECT `pin` FROM `users` WHERE `user`=\'' . $db->escape($user_entered) . '\'');
    }
    return $pin === $pwd_entered ? $user_entered : false;
}
开发者ID:rkania,项目名称:GS3,代码行数:22,代码来源:functions.php

示例14: _err

    if ($user_id < 1) {
        _err('Unknown user.');
    }
    return $user_id;
}
$type = trim(@$_REQUEST['t']);
if (!in_array($type, array('gs', 'prv', 'imported', 'gss', 'prvs', 'importeds'), true)) {
    $type = false;
}
$page = (int) trim(@$_REQUEST['p']);
$entry = (int) trim(@$_REQUEST['e']);
$search = trim(@$_REQUEST['s']);
$name_search = trim(@$_REQUEST['n']);
//$per_page = (int)gs_get_conf('GS_AASTRA_PROV_PB_NUM_RESULTS', 10);
$per_page = 4;
$db = gs_db_slave_connect();
$tmp = array(15 => array('k' => 'gs', 'v' => gs_get_conf('GS_PB_INTERNAL_TITLE', __("Intern"))), 25 => array('k' => 'prv', 'v' => gs_get_conf('GS_PB_PRIVATE_TITLE', __("Persönlich"))));
if (gs_get_conf('GS_PB_IMPORTED_ENABLED')) {
    $pos = (int) gs_get_conf('GS_PB_IMPORTED_ORDER', 9) * 10;
    $tmp[$pos] = array('k' => 'imported', 'v' => gs_get_conf('GS_PB_IMPORTED_TITLE', __("Extern")));
}
kSort($tmp);
foreach ($tmp as $arr) {
    $typeToTitle[$arr['k']] = $arr['v'];
}
$url_aastra_pb = GS_PROV_SCHEME . '://' . GS_PROV_HOST . (GS_PROV_PORT ? ':' . GS_PROV_PORT : '') . GS_PROV_PATH . 'aastra/pb.php';
#################################### SEARCH SCREEN {
if ($search) {
    $xml = '<AastraIPPhoneInputScreen type = "string">' . "\n";
    $xml .= '<Title>' . __('Suchen') . '</Title>' . "\n";
    $xml .= '<Prompt>' . __('Name') . ':</Prompt>' . "\n";
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:31,代码来源:pb.php

示例15: gs_extstate_callable

function gs_extstate_callable($ext)
{
    include_once GS_DIR . 'inc/db_connect.php';
    $db = @gs_db_slave_connect();
    if (!$db) {
        gs_log(GS_LOG_FATAL, 'Could not connect to slave DB!');
        return AST_MGR_EXT_UNKNOWN;
    }
    //user and parallel call
    $rs = $db->execute('SELECT `a`.`_user_id`, `a`.`host`, `c`.`active` FROM `ast_sipfriends` `a`
	LEFT JOIN `callforwards` `c` ON ( `a`.`_user_id`= `c`.`user_id` 
		AND `c`.`source`="internal" AND `c`.`case`="always")
	WHERE `a`.`name`="' . $ext . '"');
    if (!$rs) {
        return new GsError('DB Error.');
    }
    if (!($user = $rs->FetchRow())) {
        return new GsError('No extension ' . $ext);
    }
    if ($user['active'] == '' || $user['active'] == 'no') {
        //this is a user, no callforwards
        $state = gs_extstate($user['host'], $ext);
        return gs_ast_extstate_try_cc($state);
    } else {
        if ($user['active'] == 'par') {
            //this is a user, parallel call enabled
            $rs = $db->execute('SELECT `a`.`name`, `a`.`host` 
	FROM `ast_sipfriends` `a`, `cf_parallelcall` `c` 
	WHERE `c`.`_user_id`= ' . $user['_user_id'] . ' AND
		`c`.`number`=`a`.`name`');
            if (!$rs) {
                return new GsError('DB Error.' . $ext);
            }
            $count = 0;
            $hosts = array();
            while ($peer = $rs->FetchRow()) {
                $count++;
                $host_id = $peer['host_id'];
                $hosts[$host_id][] = $peer['name'];
            }
            //no callforward users
            if ($count == 0) {
                return false;
            }
            $allstates = array();
            foreach ($hosts as $host => $peers) {
                $states = gs_extstate($host, $peers);
                if (is_array($states)) {
                    $allstates = array_merge($allstates, $states);
                }
            }
            foreach ($allstates as $singlestate) {
                if ($singlestate != AST_MGR_EXT_IDLE) {
                    return false;
                }
            }
            return true;
        } else {
            //any other callforward
            return false;
        }
    }
    return false;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:64,代码来源:extension-state.php


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