Ejemplo n.º 1
0
 public function doWebScreen()
 {
     global $_W;
     $last = memcached_get('callnum');
     $calls = explode(',', $last);
     $callnum = sprintf('%03d', $calls[0]);
     $list = biz_getCalledGroup($_W['project']['id']);
     $groupnum = array_keys($list);
     $groupnum = array_reverse($groupnum);
     $json = json_encode($groupnum);
     include $this->template('screen');
 }
Ejemplo n.º 2
0
/**
 * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
 * - It may often "miss", so shouldn't be depended on.
 * - It supports the same as cache_put_data().
 *
 * @param string $key
 * @param int $ttl = 120
 */
function cache_get_data($key, $ttl = 120)
{
    global $cache_memcached, $memcached, $cache_hits, $cache_count, $db_show_debug;
    global $cache_accelerator, $cache_enable, $expired;
    if (empty($cache_enable)) {
        return;
    }
    $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count] = array('k' => $key, 'd' => 'get');
        $st = microtime(true);
    }
    $key = cache_get_key($key);
    switch ($cache_accelerator) {
        case 'memcached':
            // Okay, let's go for it memcached!
            if ((function_exists('memcache_get') || function_exists('memcached_get')) && !empty($cache_memcached)) {
                // Not connected yet?
                if (empty($memcached)) {
                    get_memcached_server();
                }
                if (!$memcached) {
                    return null;
                }
                $value = function_exists('memcache_get') ? memcache_get($memcached, $key) : memcached_get($memcached, $key);
            }
            break;
        case 'eaccelerator':
            // Again, eAccelerator.
            if (function_exists('eaccelerator_get')) {
                $value = eaccelerator_get($key);
            }
            break;
        case 'mmcache':
            // The older, but ever-stable, Turck MMCache...
            if (function_exists('mmcache_get')) {
                $value = mmcache_get($key);
            }
            break;
        case 'apc':
        case 'apcu':
            // This is the free APC or APCu from PECL.
            if (function_exists('apc_fetch')) {
                $value = apc_fetch($key . 'elkarte');
            }
            break;
        case 'zend':
            // Zend's pricey stuff.
            if (function_exists('zend_shm_cache_fetch')) {
                $value = zend_shm_cache_fetch('ELK::' . $key);
            } elseif (function_exists('output_cache_get')) {
                $value = output_cache_get($key, $ttl);
            }
            break;
        case 'xcache':
            if (function_exists('xcache_get') && ini_get('xcache.var_size') > 0) {
                $value = xcache_get($key);
            }
            break;
        default:
            // Otherwise it's ElkArte data!
            if (file_exists(CACHEDIR . '/data_' . $key . '.php') && filesize(CACHEDIR . '/data_' . $key . '.php') > 10) {
                // php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
                @(include CACHEDIR . '/data_' . $key . '.php');
                if (!empty($expired) && isset($value)) {
                    @unlink(CACHEDIR . '/data_' . $key . '.php');
                    unset($value);
                }
            }
            break;
    }
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count]['t'] = microtime(true) - $st;
        $cache_hits[$cache_count]['s'] = isset($value) ? strlen($value) : 0;
    }
    if (function_exists('call_integration_hook') && isset($value)) {
        call_integration_hook('cache_get_data', array($key, $ttl, $value));
    }
    return empty($value) ? null : @unserialize($value);
}
Ejemplo n.º 3
0
<?php

$project = $_W['project'];
$groups = biz_getWillCallGroup($project['id']);
$signset = biz_unserializer($project, 'signset');
if (empty($signset)) {
    message('未配置叫号相关选项!');
}
$maxselect = $signset['max'];
if (checksubmit()) {
    if (isset($_GPC['callnum'])) {
        $callnum = explode(',', $_GPC['callnum']);
    }
    $keys = array_keys($groups);
    if (empty($callnum)) {
        $callnum[] = $keys[0];
    }
    foreach ($callnum as $num) {
        biz_callSignGroup($num, $_W['pid']);
    }
    memcached_set('callnum', implode(',', $callnum));
    $groups = biz_getWillCallGroup($_W['pid']);
}
$last = memcached_get('callnum');
$called = biz_getCalledGroup($_W['pid']);
include $this->template('queuing_list');
Ejemplo n.º 4
0
/**
 * 通过token获取用户信息
 * @param $token
 * @return array|bool|mixed|string
 */
function biz_getUser($token)
{
    if (empty($token)) {
        return false;
    } else {
        $user = memcached_get('u_' . $token);
        return $user;
    }
}
Ejemplo n.º 5
0
require './framework/bootstrap.inc.php';
load()->web('business');
load()->web('app');
disableWebCache();
$func = strtolower($_GPC['func']);
$params = $_GPC['params'];
if (is_array($params)) {
    $params = array_change_key_case($params, CASE_LOWER);
}
$res = array('result' => false, 'msg' => '无效的功能调用');
//检查调用IP?
//cache()->flush();
if ($func == 'calllnum') {
    $res['msg'] = '';
    $res['result'] = true;
    $num = memcached_get('callnum');
    $res['data'] = sprintf('%03d', intval($num));
    returnJson($res);
}
if ($func == 'login') {
    $user = biz_login($params['usercode'], $params['password']);
    if (!empty($user)) {
        unset($user['Password']);
        $res['msg'] = '登录成功';
        $res['result'] = true;
        $res['data']['user'] = $user;
    } else {
        $res['msg'] = '无效的用户名或密码!';
    }
    returnJson($res);
}
Ejemplo n.º 6
0
/**
 *获得签到全局表信息
 * 自动增加组
 * @param $pid 项目id
 */
function getGlobalSign($project)
{
    global $_W;
    $key = 'sign_' . $project['projguid'];
    $singset = biz_unserializer($project, 'signset');
    $max = empty($singset['num']) ? 10 : $singset['num'];
    $info = memcached_get($key);
    $reset = empty($info) || $info['group']['maxnum'] >= $max;
    if ($reset) {
        memcached_delete($key);
        $index = 1;
        if (!empty($info['group']['dispnum'])) {
            $index = $info['group']['dispnum'];
        }
        //获取组号
        $callback = function () use($index, $max, $project) {
            $info['maxnum'] = $max;
            //获取未签到组列表
            $info['group'] = Sign_GetEmptyGroup($index, $max, $project['id']);
            $info['group']['maxnum']++;
            return $info;
        };
        $info = cache_GetData($key, $callback, 1800);
    } else {
        $info['group']['maxnum']++;
        memcached_set($key, $info, 1800);
    }
    return $info;
}
Ejemplo n.º 7
0
/**
 * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
 * - It may often "miss", so shouldn't be depended on.
 * - It supports the same as cache_put_data().
 *
 * @param string $key
 * @param int $ttl = 120
 * @return string
 */
function cache_get_data($key, $ttl = 120)
{
    global $boardurl, $sourcedir, $modSettings, $memcached;
    global $cache_hits, $cache_count, $db_show_debug, $cachedir;
    global $cache_accelerator, $cache_enable;
    if (empty($cache_enable)) {
        return;
    }
    $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count] = array('k' => $key, 'd' => 'get');
        $st = microtime();
    }
    $key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . strtr($key, ':/', '-_');
    switch ($cache_accelerator) {
        case 'memcache':
            // Okay, let's go for it memcached!
            if ((function_exists('memcache_get') || function_exists('memcached_get')) && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
                // Not connected yet?
                if (empty($memcached)) {
                    get_memcached_server();
                }
                if (!$memcached) {
                    return null;
                }
                $value = function_exists('memcache_get') ? memcache_get($cache['connection'], $key) : memcached_get($cache['connection'], $key);
            }
            break;
        case 'eaccelerator':
            // Again, eAccelerator.
            if (function_exists('eaccelerator_get')) {
                $value = eaccelerator_get($key);
            }
            break;
        case 'mmcache':
            // The older, but ever-stable, Turck MMCache...
            if (function_exists('mmcache_get')) {
                $value = mmcache_get($key);
            }
            break;
        case 'apc':
            // This is the free APC from PECL.
            if (function_exists('apc_fetch')) {
                $value = apc_fetch($key . 'smf');
            }
            break;
        case 'zend':
            // Zend's pricey stuff.
            if (function_exists('zend_shm_cache_fetch')) {
                $value = zend_shm_cache_fetch('SMF::' . $key, $ttl);
            } elseif (function_exists('output_cache_get')) {
                $value = output_cache_get($key, $ttl);
            }
            break;
        case 'xcache':
            if (function_exists('xcache_get') && ini_get('xcache.var_size') > 0) {
                $value = xcache_get($key);
            }
            break;
        default:
            // Otherwise it's SMF data!
            if (file_exists($cachedir . '/data_' . $key . '.php') && filesize($cachedir . '/data_' . $key . '.php') > 10) {
                // php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
                @(include $cachedir . '/data_' . $key . '.php');
                if (!empty($expired) && isset($value)) {
                    @unlink($cachedir . '/data_' . $key . '.php');
                    unset($value);
                }
            }
            break;
    }
    if (isset($db_show_debug) && $db_show_debug === true) {
        $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
        $cache_hits[$cache_count]['s'] = isset($value) ? strlen($value) : 0;
    }
    if (function_exists('call_integration_hook')) {
        call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
    }
    return empty($value) ? null : @unserialize($value);
}
Ejemplo n.º 8
0
        }
    } else {
        $res['msg'] = '此项目已有下载未完成,请等5分钟再试';
    }
    returnJson($res);
}
if ($func == 'release_token') {
    $token = $_GPC['token'];
    $data = memcached_get('sync_t_' . $token);
    memcached_delete('sync_' . $data['guid']);
    memcached_delete('sync_t_' . $token);
}
//获取数据接口
if ($func == 'get_data') {
    $token = $_GPC['token'];
    $data = memcached_get('sync_t_' . $token);
    $type = $_GPC['type'];
    $enable = !empty($data) && !empty($data['guid']);
    //$enable=$enable && ($data['ip']==CLIENT_IP);
    $list = array('project', 'build', 'room', 'chips', 'user');
    if ($enable && in_array($type, $list)) {
        $call = 'download_' . $type;
        $res['ok'] = true;
        $res['data'] = $call($data['guid']);
    } else {
        $res['msg'] = '无效调用';
    }
    returnJson($res);
}
$res['msg'] = '无效的功能调用';
returnJson($res);