Пример #1
0
        break;
    case 'kword':
        jsonp_echo(handle_bind_keyword($PARAMS));
        break;
    case 'bind':
        jsonp_echo(handle_bind_account($PARAMS));
        break;
    case 'debug':
        jsonp_echo(handle_debug_cmd());
        break;
    default:
        jsonp_echo(['status' => 'error', 'error' => 'unreconized cmd.']);
}
fastcgi_finish_request();
sync_job();
put_device_saved($DEVSAV);
exit;
/***************** ---------- *****************/
/*****************  异步处理  *****************/
/***************** ---------- *****************/
function sync_job($job_type = null, $cmd_arr = null)
{
    global $CONFIGS, $DEVSAV, $PARAMS, $SYNJOBS;
    if ($job_type && $cmd_arr) {
        return group_list($SYNJOBS, $job_type, $cmd_arr);
    }
    foreach ($SYNJOBS as $job_type => $cmd_datas) {
        foreach ($cmd_datas as $cmd_data) {
            switch ($job_type) {
                case 'kword_title':
                case 'kword_interest':
Пример #2
0
function get_device_saved($create = false)
{
    if ($create) {
        $device = null;
    } else {
        $device = get_device();
    }
    if (empty($device)) {
        $device = gen_uuid();
        setcookie(COOKIE_DEVICE_ID, $device, time() + COOKIE_TIMEOUT, '/', COOKIE_DOMAIN);
        $_COOKIE[COOKIE_DEVICE_ID] = $device;
        $UA_infos = get_ua_infos();
        $device_saved = ['device' => $device, 'need_save' => true, 'first_pageview' => time(), 'last_pageview' => time(), 'pageview_count' => 0, 'is_first_pageview' => true, 'first_session' => time(), 'start_session' => time(), 'session_pv' => 0, 'session_count' => 0, 'is_first_session' => true, 'is_first_day' => true, 'is_first_session_pv' => true, 'staytime' => 0, 'popup_private' => [], 'popup_tasks' => [], 'popup_times' => 0, 'popup_lasttime' => 0, 'replace_private' => [], 'replace_tasks' => [], 'replace_times' => 0, 'replace_lasttime' => 0, 'UserAgent' => $UA_infos['UserAgent'], 'ismobiledevice' => $UA_infos['ismobiledevice'], 'browser' => $UA_infos['browser'], 'platform' => $UA_infos['platform'], 'device_name' => $UA_infos['device_name'], 'is_registed' => false, 'kword_title' => [], 'kword_account' => [], 'kword_interest' => [], 'kword_submit' => [], 'kword_cart' => [], 'kword_favorite' => []];
        put_device_saved($device_saved);
        return $device_saved;
    } else {
        $device_file = device_file($device);
        if (!file_exists($device_file)) {
            return get_device_saved(true);
        }
        $device_saved = unserialize(file_get_contents($device_file));
        $device_saved['need_save'] = true;
        return $device_saved;
    }
}