index.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. define('IN_MOBILE', true);
  7. require '../framework/bootstrap.inc.php';
  8. require IA_ROOT . '/app/common/bootstrap.app.inc.php';
  9. $acl = array(
  10. 'home' => array(
  11. 'default' => 'home',
  12. ),
  13. 'mc' => array(
  14. 'default' => 'home'
  15. )
  16. );
  17. if ($_W['setting']['copyright']['status'] == 1) {
  18. $_W['siteclose'] = true;
  19. message('抱歉,站点已关闭,关闭原因:' . $_W['setting']['copyright']['reason']);
  20. }
  21. $multiid = intval($_GPC['t']);
  22. if(empty($multiid)) {
  23. $multiid = intval($unisetting['default_site']);
  24. unset($setting);
  25. }
  26. $multi = table('site_multi')->getById($multiid, $_W['uniacid']);
  27. $multi['site_info'] = @iunserializer($multi['site_info']);
  28. $styleid = !empty($_GPC['s']) ? intval($_GPC['s']) : intval($multi['styleid']);
  29. $style = table('site_styles')->getById($styleid, $_W['uniacid']);
  30. $templates = uni_templates();
  31. $templateid = intval($style['templateid']);
  32. $template = $templates[$templateid];
  33. $_W['template'] = !empty($template) ? $template['name'] : 'default';
  34. $_W['styles'] = array();
  35. if(!empty($template) && !empty($style)) {
  36. $stylevars = table('site_styles_vars')
  37. ->select(array('variable', 'content'))
  38. ->where(array(
  39. 'uniacid' => $_W['uniacid'],
  40. 'styleid' => $styleid
  41. ))
  42. ->getall();
  43. if(!empty($stylevars)) {
  44. foreach($stylevars as $row) {
  45. if (strexists($row['variable'], 'img')) {
  46. $row['content'] = tomedia($row['content']);
  47. }
  48. $_W['styles'][$row['variable']] = $row['content'];
  49. }
  50. }
  51. unset($stylevars, $row, $sql, $params);
  52. }
  53. $_W['page'] = array();
  54. $_W['page']['title'] = $multi['title'];
  55. if(is_array($multi['site_info'])) {
  56. $_W['page'] = array_merge($_W['page'], $multi['site_info']);
  57. }
  58. unset($multi, $styleid, $style, $templateid, $template, $templates);
  59. if ($controller == 'wechat' && $action == 'card' && $do == 'use') {
  60. header("location: index.php?i={$_W['uniacid']}&c=entry&m=paycenter&do=consume&encrypt_code={$_GPC['encrypt_code']}&card_id={$_GPC['card_id']}&openid={$_GPC['openid']}&source={$_GPC['source']}");
  61. exit;
  62. }
  63. $controllers = array();
  64. $handle = opendir(IA_ROOT . '/app/source/');
  65. if(!empty($handle)) {
  66. while($dir = readdir($handle)) {
  67. if($dir != '.' && $dir != '..') {
  68. $controllers[] = $dir;
  69. }
  70. }
  71. }
  72. if(!in_array($controller, $controllers)) {
  73. $controller = 'home';
  74. }
  75. $init = IA_ROOT . "/app/source/{$controller}/__init.php";
  76. if(is_file($init)) {
  77. require $init;
  78. }
  79. $actions = array();
  80. $handle = opendir(IA_ROOT . '/app/source/' . $controller);
  81. if(!empty($handle)) {
  82. while($dir = readdir($handle)) {
  83. if($dir != '.' && $dir != '..' && strexists($dir, '.ctrl.php')) {
  84. $dir = str_replace('.ctrl.php', '', $dir);
  85. $actions[] = $dir;
  86. }
  87. }
  88. }
  89. if(empty($actions)) {
  90. $str = '';
  91. if(uni_is_multi_acid()) {
  92. $str = "&j={$_W['acid']}";
  93. }
  94. header("location: index.php?i={$_W['uniacid']}{$str}&c=home?refresh");
  95. }
  96. if(!in_array($action, $actions)) {
  97. $action = $acl[$controller]['default'];
  98. }
  99. if(!in_array($action, $actions)) {
  100. $action = $actions[0];
  101. }
  102. require _forward($controller, $action);
  103. function _forward($c, $a) {
  104. $file = IA_ROOT . '/app/source/' . $c . '/' . $a . '.ctrl.php';
  105. return $file;
  106. }