public function get_group_list() { global $_M; if (!$this->grouplist[$this->lang]) { $this->grouplist[$this->lang] = cache::get("user/grouplist_{$this->lang}"); if (!$this->grouplist[$this->lang]) { $query = "SELECT * FROM {$_M['table']['user_group']} WHERE lang='{$this->lang}' order by access ASC"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { $this->grouplist[$this->lang][$list['id']] = $list; } cache::put("user/grouplist_{$this->lang}", $this->grouplist[$this->lang]); } } return $this->grouplist[$this->lang]; }
public function get_para_list($module, $class1, $class2, $class3) { global $_M; if (!$this->paralist[$module][$this->lang]) { $this->paralist[$module][$this->lang] = cache::get("para/paralist_{$module}_{$this->lang}"); if (!$this->paralist[$module][$this->lang]) { $query = "SELECT * FROM {$_M['table']['parameter']} WHERE module='{$module}' and lang='{$_M['lang']}' order by no_order ASC, id ASC"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { if ($list['options']) { $lists = explode("\$|\$", $list['options']); $list['list'] = $lists; } $this->paralist[$module][$this->lang][$list['id']] = $list; } cache::put("para/paralist_{$module}_{$this->lang}", $this->paralist[$module][$this->lang]); } } $re = $this->paralist[$module][$this->lang]; $paralists = array(); foreach ($re as $val) { if ($val['class1']) { if ($val['class1'] == $class1) { if ($val['class2'] == 0 && $val['class3'] == 0) { $paralists[] = $val; } if ($val['class2'] && $val['class2'] == $class2 && $val['class3'] == 0) { $paralists[] = $val; } if ($val['class3'] && $val['class3'] == $class3) { $paralists[] = $val; } } } else { $paralists[] = $val; } } $re = $paralists; return $re; }
public static function curl_multi_get($requests) { cache::$__LinkToFunc = array(); cache::$__TempResult = array(); cache::$__ApiTime = microtime(true); $rc = new RollingCurl(function ($response, $info, $request) { $url = $request->url; if ($response == null) { cache::log("CURL RESULT EMPTY for url: " . $url . " with HTTP code " . $info['http_code']); /*$response = file_get_contents($url); if( $response == false ) { cache::log("FILE_GET_CONTENTS failed for url: ".$url); }*/ } cache::log(sprintf("Got multi result for %s in %s sec, len %s", $url, number_format(microtime(true) - cache::$__ApiTime, 3), strlen($response))); $cbtime = microtime(true); if (cache::$__LinkToFunc[$url]) { call_user_func_array(cache::$__LinkToFunc[$url], array($response)); } cache::log(sprintf("Ran callback for URL in %s sec", number_format(microtime(true) - $cbtime, 3))); cache::$__TempResult[$url] = $response; cache::put($url, $response); }); foreach ($requests as $request) { cache::$__LinkToFunc[$request['url']] = $request['func']; $rc->request($request['url']); } $rc->window_size = count($requests); $rc->execute(); cache::log(sprintf("Multi API request took %s sec", number_format(microtime(true) - cache::$__ApiTime, 3))); return cache::$__TempResult; }