index.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 20190527114543 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 = pdo_fetch("SELECT * FROM ".tablename('site_multi')." WHERE id=:id AND uniacid=:uniacid", array(':id' => $multiid, ':uniacid' => $_W['uniacid']));
  27. $multi['site_info'] = @iunserializer($multi['site_info']);
  28. $styleid = !empty($_GPC['s']) ? intval($_GPC['s']) : intval($multi['styleid']);
  29. $style = pdo_fetch("SELECT * FROM ".tablename('site_styles')." WHERE id = :id", array(':id' => $styleid));
  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. $sql = "SELECT `variable`, `content` FROM " . tablename('site_styles_vars') . " WHERE `uniacid`=:uniacid AND `styleid`=:styleid";
  37. $params = array();
  38. $params[':uniacid'] = $_W['uniacid'];
  39. $params[':styleid'] = $styleid;
  40. $stylevars = pdo_fetchall($sql, $params);
  41. if(!empty($stylevars)) {
  42. foreach($stylevars as $row) {
  43. if (strexists($row['variable'], 'img')) {
  44. $row['content'] = tomedia($row['content']);
  45. }
  46. $_W['styles'][$row['variable']] = $row['content'];
  47. }
  48. }
  49. unset($stylevars, $row, $sql, $params);
  50. }
  51. $_W['page'] = array();
  52. $_W['page']['title'] = $multi['title'];
  53. if(is_array($multi['site_info'])) {
  54. $_W['page'] = array_merge($_W['page'], $multi['site_info']);
  55. }
  56. unset($multi, $styleid, $style, $templateid, $template, $templates);
  57. if ($controller == 'wechat' && $action == 'card' && $do == 'use') {
  58. 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']}");
  59. exit;
  60. }
  61. $controllers = array();
  62. $handle = opendir(IA_ROOT . '/app/source/');
  63. if(!empty($handle)) {
  64. while($dir = readdir($handle)) {
  65. if($dir != '.' && $dir != '..') {
  66. $controllers[] = $dir;
  67. }
  68. }
  69. }
  70. if(!in_array($controller, $controllers)) {
  71. $controller = 'home';
  72. }
  73. $init = IA_ROOT . "/app/source/{$controller}/__init.php";
  74. if(is_file($init)) {
  75. require $init;
  76. }
  77. $actions = array();
  78. $handle = opendir(IA_ROOT . '/app/source/' . $controller);
  79. if(!empty($handle)) {
  80. while($dir = readdir($handle)) {
  81. if($dir != '.' && $dir != '..' && strexists($dir, '.ctrl.php')) {
  82. $dir = str_replace('.ctrl.php', '', $dir);
  83. $actions[] = $dir;
  84. }
  85. }
  86. }
  87. if(empty($actions)) {
  88. $str = '';
  89. if(uni_is_multi_acid()) {
  90. $str = "&j={$_W['acid']}";
  91. }
  92. header("location: index.php?i={$_W['uniacid']}{$str}&c=home?refresh");
  93. }
  94. if(!in_array($action, $actions)) {
  95. $action = $acl[$controller]['default'];
  96. }
  97. if(!in_array($action, $actions)) {
  98. $action = $actions[0];
  99. }
  100. require _forward($controller, $action);
  101. function _forward($c, $a) {
  102. $file = IA_ROOT . '/app/source/' . $c . '/' . $a . '.ctrl.php';
  103. return $file;
  104. }