Exemple #1
0
 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);
 }