<?php include 'config.php'; include 'constant.php'; include 'conn.php'; include 'utils.php'; $query = get_param_query(array('line', 'bus')); $type = get_param_type(); $reversed = get_param_num('reversed', 0); $key = get_param_key('key'); main($query, $type, $reversed, $key); include 'close.php'; /******************************************************************** * 函数定义 ********************************************************************/ // 主函数 function main($query, $type, $reversed, $key) { $line = get_bus_line($key); if (count($line) == 0) { write_error($GLOBALS['ERR_NOT_BUS']); } else { if ($type == 'text') { write_text($query, $reversed, $line); } elseif ($type == 'json') { write_json($query, $reversed, $line); } else { write_error($GLOBALS['ERR_PARAMS_TYPE']); } } }
<?php include 'config.php'; include 'constant.php'; include 'conn.php'; include 'utils.php'; $query = get_param_query(array('cat', 'joke')); $type = get_param_type(); $joke_id = get_param_num('joke_id', 0); $cat_id = get_param_num('cat_id', -1); $limit = get_param_num('limit', 1); main($query, $type, $joke_id, $cat_id, $limit); include 'close.php'; /******************************************************************** * 函数定义 ********************************************************************/ // 主函数 function main($query, $type, $joke_id, $cat_id, $limit) { if ($query == 'cat') { get_cat($type); } elseif ($query == 'joke') { get_joke($type, $joke_id, $cat_id, $limit); } else { write_error($GLOBALS['ERR_PARAMS_QUERY']); } } // 获取分类 function get_cat($type) { $sql = "select `cat`, `cat_id` from `joke_cat` where `cat_id`<>0";