mobile.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: mobile.php 35114 2014-11-27 01:07:53Z nemohou $
  7. */
  8. define('IN_MOBILE_API', 1);
  9. define('IN_MOBILE', 1);
  10. chdir('../../../');
  11. require_once 'source/plugin/mobile/mobile.class.php';
  12. $modules = array('extends', 'buyattachment', 'buythread', 'checkpost', 'connect',
  13. 'favforum', 'favthread', 'forumdisplay', 'forumindex',
  14. 'forumnav', 'forumupload', 'friend', 'hotforum', 'hotthread',
  15. 'login', 'myfavforum', 'myfavthread', 'mypm', 'mythread',
  16. 'newthread', 'profile', 'publicpm', 'register', 'seccode',
  17. 'secure', 'sendpm', 'sendreply', 'sub_checkpost', 'sublist',
  18. 'toplist', 'viewthread', 'uploadavatar', 'pollvote', 'mynotelist', 'credit', 'profiles',
  19. 'modcp', 'topicadmin', 'forumimage', 'newthreads', 'signin', 'smiley', 'threadrecommend', 'check', 'mobilesign',
  20. 'wsqindex', 'wsqsiteinfo', 'recommend',
  21. 'wechat', 'wechat_clearlogin', 'checkinfo', 'seccodehtml',
  22. 'showactivity', 'bestanswer', 'forummisc', 'checkcookie', 'viewcomment', 'plugin');
  23. $defaultversions = array(
  24. 'wechat' => 4,
  25. );
  26. if(!isset($_GET['module']) || !in_array($_GET['module'], $modules)) {
  27. mobile_core::result(array('error' => 'module_not_exists'));
  28. }
  29. $_GET['version'] = !empty($_GET['version']) ? intval($_GET['version']) : (!$defaultversions[$_GET['module']] ? 1 : $defaultversions[$_GET['module']]);
  30. $_GET['version'] = $_GET['version'] > MOBILE_PLUGIN_VERSION ? MOBILE_PLUGIN_VERSION : $_GET['version'];
  31. if(empty($_GET['module']) || empty($_GET['version']) || !preg_match('/^[\w\.]+$/', $_GET['module']) || !preg_match('/^[\d\.]+$/', $_GET['version'])) {
  32. mobile_core::result(array('error' => 'param_error'));
  33. }
  34. if($_GET['module'] == 'extends') {
  35. require_once 'source/plugin/mobile/mobile_extends.php';
  36. return;
  37. }
  38. if(!empty($_GET['_auth'])) {
  39. unset($_GET['formhash'], $_POST['formhash']);
  40. }
  41. $apifile = 'source/plugin/mobile/api/'.$_GET['version'].'/'.$_GET['module'].'.php';
  42. if(file_exists($apifile)) {
  43. require_once $apifile;
  44. } else {
  45. if($_GET['version'] > 1) {
  46. for($i = $_GET['version']; $i >= 1; $i--) {
  47. $apifile = 'source/plugin/mobile/api/'.$i.'/'.$_GET['module'].'.php';
  48. if(file_exists($apifile)) {
  49. $_GET['version'] = $i;
  50. require_once $apifile;
  51. break;
  52. } elseif($i==1 && !file_exists($apifile)) {
  53. mobile_core::result(array('error' => 'module_not_exists'));
  54. }
  55. }
  56. } else {
  57. mobile_core::result(array('error' => 'module_not_exists'));
  58. }
  59. }
  60. ?>