心理咨询网
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

controller.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // header('Access-Control-Allow-Origin: http://www.baidu.com'); //设置http://www.baidu.com允许跨域访问
  3. // header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); //设置允许的跨域header
  4. // date_default_timezone_set("Asia/chongqing");
  5. // error_reporting(E_ERROR);
  6. // header("Content-Type: text/html; charset=utf-8");
  7. require_once '../../../init.php';
  8. error_reporting(0);
  9. // 启动会话
  10. if (! session('sid')) {
  11. die('权限不足');
  12. }
  13. $CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents("config.json")), true);
  14. $action = $_GET['action'];
  15. switch ($action) {
  16. case 'config':
  17. $result = json_encode($CONFIG);
  18. break;
  19. /* 上传图片 */
  20. case 'uploadimage':
  21. /* 上传涂鸦 */
  22. case 'uploadscrawl':
  23. /* 上传视频 */
  24. case 'uploadvideo':
  25. /* 上传文件 */
  26. case 'uploadfile':
  27. $result = include ("action_upload.php");
  28. break;
  29. /* 列出图片 */
  30. case 'listimage':
  31. $result = include ("action_list.php");
  32. break;
  33. /* 列出文件 */
  34. case 'listfile':
  35. $result = include ("action_list.php");
  36. break;
  37. /* 抓取远程文件 */
  38. case 'catchimage':
  39. $result = include ("action_crawler.php");
  40. break;
  41. default:
  42. $result = json_encode(array(
  43. 'state' => '请求地址出错'
  44. ));
  45. break;
  46. }
  47. /* 输出结果 */
  48. if (isset($_GET["callback"])) {
  49. if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
  50. echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
  51. } else {
  52. echo json_encode(array(
  53. 'state' => 'callback参数不合法'
  54. ));
  55. }
  56. } else {
  57. echo $result;
  58. }