function smarty_function_url($params) { if (isset($params['ignore'])) { return Swoole_tools::url_merge($params['key'], $params['value'], $params['ignore']); } else { return Swoole_tools::url_merge($params['key'], $params['value']); } }
function call($param, $post = null) { foreach ($param as &$m) { if (is_array($m) or is_object($m)) { $m = serialize($m); } } $url = $this->server_url . Swoole_tools::combine_query($param); if ($post === null) { $res = $this->http->get($url); } else { $res = $this->http->post($url, $post); } if ($this->debug) { echo $url, BL, $res; } return json_decode($res); }
/** * 主函数 * @param $cmd * @return unknown_type */ function main($param) { $cmd = $param['cmd']; switch ($cmd) { case 'install': case 'setup': $project = $param['name']; $strlen = strlen($project); $end_char = $project[$strlen - 1]; if ($end_char == "\\" or $end_char == '/') { $project = substr($project, 0, $strlen - 1); } if (!is_dir($project)) { mkdir($project, 0755, true); } Swoole_tools::dir_copy(dirname(__FILE__), $project . '/libs'); copy('../index.php', WEBPATH . '/index.php'); copy('../config.php', WEBPATH . '/config.php'); echo "Install Swoole to {$project}!\n"; echo $project; break; //初始化项目 //初始化项目 case 'create': case 'init': create_require_dir(); echo "craete require directory success!\n"; break; case 'addc': create_controllerclass($param['name']); echo "create a new controller {$param['name']}!\n"; break; case 'addm': create_modelclass($param['name'], $argv[2]); echo "create a new model {$param['name']}!\n"; break; case 'debug': require LIBPATH . '/code/console.php'; break; default: break; } }
function runAjax() { if (!preg_match('/^[a-z0-9_]+$/i', $_GET['method'])) { return false; } $method = 'ajax_' . $_GET['method']; if (!function_exists($method)) { echo 'Error: Function not found!'; exit; } header('Cache-Control: no-cache, must-revalidate'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-type: application/json'); $data = call_user_func($method); if (DBCHARSET != 'utf8') { $data = Swoole_tools::array_iconv(DBCHARSET, 'utf-8', $data); } echo json_encode($data); }
/** * 为指定的页面返回地址值 * * @param int $pageno * @return string $url */ function _get_url($pageno = 1) { if (empty($this->page_tpl)) { return Swoole_tools::url_merge('page', $pageno, 'mvc,q'); } else { return sprintf($this->page_tpl, $pageno); } }
function smarty_modifier_howLongAgo($string) { return Swoole_tools::howLongAgo($string); }
function __construct($cache_url) { $config = Swoole_tools::uri($cache_url); $this->cache = self::get_cache($config); }