人人商城

index.php 3.3KB

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