PageRenderTime 27ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/ php-ppcms/includes/fronts_common.php

http://php-ppcms.googlecode.com/
PHP | 254 lines | 142 code | 19 blank | 93 comment | 33 complexity | 9cee5078349fdef4225075c1d2d94944 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. * (c) 2009, jianyuzhu@gmail.com
  5. * All rights reserved
  6. * This script is part of the PPEMI project.
  7. ***************************************************************/
  8. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. //process
  10. $error = false;
  11. $action = (isset($_GET['action']) ? $_GET['action'] : '');
  12. $mainpart = '';
  13. $content_wrap = array();
  14. //request uri
  15. //$request_uri = SYS_RT_REQUEST_URI;
  16. if( strpos(SYS_RT_REQUEST_URI, '?') == false ) {
  17. $request_uri = SYS_RT_REQUEST_URI;
  18. } else {
  19. $request_uri = substr(SYS_RT_REQUEST_URI, 0, strpos(SYS_RT_REQUEST_URI, '?'));
  20. }
  21. //filter
  22. $request_uri = ereg_replace("(\/{2,})", "/", $request_uri);
  23. $request_uri = ereg_replace("(^\/)", "", $request_uri);
  24. //friendly
  25. if( CONFIG_URL_DIRECTORY == true ) {
  26. } else {
  27. $request_uri = str_replace('~', '/', $request_uri);
  28. }
  29. //
  30. //if( util_not_null($request_uri)
  31. //do not use the function util_xxx
  32. if( strlen($request_uri) > 0 && (substr($request_uri, 0, strlen('index.php')) != 'index.php') ) {
  33. $link_result = util_parse_link($request_uri);
  34. $request_type = $link_result['type'];
  35. $request_link = $link_result['link'];
  36. } else {
  37. $request_type = '';
  38. $request_link = '';
  39. }
  40. $request_path = $request_type;
  41. $request_param = $_SERVER['QUERY_STRING'];
  42. //$request_redirect = substr($_SERVER['REDIRECT_URL'], strlen(CONFIG_URL_PREFIX));
  43. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. $request_link_class = '';
  45. $request_link_subclass = '';
  46. $request_link_param = array();
  47. $request_link_parse = str_replace(CONFIG_URL_SUFFIX, '', $request_link);
  48. if( strpos($request_link_parse, '?') == false ) {
  49. $request_link_parse_array = explode('/', $request_link_parse);
  50. } else {
  51. $request_link_parse_array = explode('/', substr($request_link_parse, 0, strpos($request_link_parse, '?')));
  52. }
  53. $request_link_class = $request_link_parse_array['0'];
  54. $request_link_subclass = $request_link_parse_array['1'];
  55. if( sizeof($request_link_parse_array) > 2 ) {
  56. $request_link_param = array_slice($request_link_parse_array, 2);
  57. }
  58. if( $request_link_class != '' ) {
  59. $request_path = $request_type . '/' . $request_link_class . '/';
  60. }
  61. //
  62. $id = trim(strtolower(util_get_param($_REQUEST, 'id')));
  63. $action = trim(strtolower(util_get_param($_REQUEST, 'action')));
  64. $type = trim(strtolower(util_get_param($_REQUEST, 'type')));
  65. $operation = trim(strtolower(util_get_param($_REQUEST, 'op')));
  66. $page = trim(strtolower(util_get_param($_GET, 'page')));
  67. if( !is_numeric($page) ) {
  68. $page = 1;
  69. }
  70. $length = trim(strtolower(util_get_param($_REQUEST, 'length')));
  71. if( !is_numeric($length) || $length < 10 ) {
  72. $length = 10;
  73. } else {
  74. $length = 10;
  75. }
  76. //
  77. $limit_page = $page;
  78. $limit_length = $length;
  79. $limit_start = ($limit_page - 1) * $limit_length;
  80. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  81. //INJECTION
  82. if( $request_type == 'admin' ) {
  83. //
  84. } else {
  85. //
  86. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/news/news.class.php');
  87. $mObj = new NewsBase();
  88. $mObj->format = true;
  89. $mObj->setQueryLimitLength(5);
  90. $news_items = $mObj->cache('getItems', array('', 0));
  91. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'lc_news_items', $news_items);
  92. //
  93. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/product/product.category.class.php');
  94. $mObj = new ProductCategoryBase();
  95. $mObj->format = true;
  96. $mObj->setQueryLimitLength(10);
  97. $categories = $mObj->cache('getCategories', array('', 0));
  98. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'lc_categories', $categories);
  99. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'tm_ps_categories', $categories);
  100. /*
  101. //
  102. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/gallery/gallery.category.class.php');
  103. $mObj = new GalleryCategoryBase();
  104. $mObj->format = true;
  105. $mObj->setQueryLimitLength(5);
  106. $categories = $mObj->cache('getCategories', array('', 0));
  107. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'tm_gs_categories', $categories);
  108. //
  109. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/gallery/gallery.album.class.php');
  110. $mObj = new GalleryAlbumBase();
  111. $mObj->format = true;
  112. $mObj->setQueryLimitLength(5);
  113. $items = $mObj->cache('getItems', array('', 0));
  114. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'tm_gs_albums', $items);
  115. */
  116. /*
  117. //
  118. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/content/content.category.class.php');
  119. $mcObj = new ContentCategoryBase();
  120. $mcObj->format = true;
  121. $mcObj->setQueryLimitLength(10);
  122. $categories = $mcObj->cache('getCategories', array('', 0));
  123. //
  124. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/content/content.class.php');
  125. $mObj = new ContentBase();
  126. $mObj->format = true;
  127. $mObj->setQueryLimitLength(10);
  128. foreach($categories as $k => $category) {
  129. $categories[$k]['items'] = $mObj->getItems(array('cid' => $category['categories_id']));
  130. }
  131. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'tm_categories', $categories);
  132. */
  133. //
  134. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/menu/menu.tree.class.php');
  135. $mObj = new MenuTreeBase();
  136. $mObj->format = true;
  137. $mObj->setQueryLimitLength(10);
  138. $tm_items = $mObj->cache('getItemsThreeLevel', array(0, '', 0));
  139. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'tm_items', $tm_items);
  140. /*
  141. //
  142. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/content/content.class.php');
  143. $mObj = new ContentBase();
  144. $mObj->format = true;
  145. $item = $mObj->getItem($request_type, 'link');
  146. if( $item['id'] > 0 ) {
  147. $request_link_class = $request_type;
  148. $request_type = 'a';
  149. }
  150. */
  151. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/url/url.class.php');
  152. $mObj = new URLBase();
  153. $mObj->format = true;
  154. $mObj->dispatch();
  155. }
  156. //GLOBAL
  157. $param = array(
  158. 'name' => 'context_wrap',
  159. 'value' => array(
  160. 'IMAGEURL' => CONFIG_URL_HTTP . CONFIG_DIR_IMAGES,
  161. 'PRODUCTURL' => CONFIG_URL_HTTP . 'product/',
  162. 'PRODUCTSURL' => CONFIG_URL_HTTP . 'products/',
  163. 'PITEMURL' => CONFIG_URL_HTTP . 'product/item/',
  164. 'CATEGORYURL' => CONFIG_URL_HTTP . 'autoitem/',
  165. 'CARTURL' => CONFIG_URL_HTTP . 'cart/',
  166. 'CHECKOUTURL' => CONFIG_URL_HTTP . 'checkout/',
  167. 'SHOPURL' => CONFIG_URL_HTTP . 'shop/',
  168. 'MYURL' => CONFIG_URL_HTTP . SYS_RT_LANG_URI . 'my/',
  169. 'ADMINURL' => CONFIG_URL_HTTP . SYS_RT_LANG_URI . 'admin/',
  170. 'MEMBERURL' => CONFIG_URL_HTTP . SYS_RT_LANG_URI . 'member/',
  171. //
  172. 'PRODUCTIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_PRODUCTS_IMAGES,
  173. 'PRODUCTORIGINIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_PRODUCTS_ORIGINIMAGES,
  174. 'PRODUCTTHUMBIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_PRODUCTS_THUMBIMAGES,
  175. 'PRODUCTRESIZEIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_PRODUCTS_RESIZEIMAGES,
  176. //
  177. 'PRODUCTIMAGEFS' => CONFIG_PATH . CONFIG_DIR_PRODUCTS_IMAGES,
  178. 'PRODUCTORIGINIMAGEFS' => CONFIG_PATH . CONFIG_DIR_PRODUCTS_ORIGINIMAGES,
  179. 'PRODUCTTHUMBIMAGEFS' => CONFIG_PATH . CONFIG_DIR_PRODUCTS_THUMBIMAGES,
  180. 'PRODUCTRESIZEIMAGEFS' => CONFIG_PATH . CONFIG_DIR_PRODUCTS_RESIZEIMAGES,
  181. //
  182. 'PRODUCTCATEGORYIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_PRODUCTS_CATEGORIES_IMAGES,
  183. //
  184. 'PRODUCTBRANDIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_BRANDS_IMAGES,
  185. 'PRODUCTBRANDIMAGEFS' => CONFIG_PATH . CONFIG_DIR_BRANDS_IMAGES,
  186. //
  187. 'RESOURCEIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_RESOURCES,
  188. 'ALBUMIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_ALBUMS_IMAGES,
  189. 'ALBUMORIGINIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_ALBUMS_ORIGINIMAGES,
  190. 'ALBUMTHUMBIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_ALBUMS_THUMBIMAGES,
  191. 'ALBUMRESIZEIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_ALBUMS_RESIZEIMAGES,
  192. //
  193. 'PLAYER' => array(
  194. 'URL' => CONFIG_URL_HTTP . 'player/v1/player.swf',
  195. ),
  196. //
  197. 'STYLEURL' => CONFIG_URL_HTTP . CONFIG_DIR_STYLES . CONFIG_STYLE . '/',
  198. 'STYLEIMG' => CONFIG_URL_HTTP . CONFIG_DIR_STYLES . CONFIG_STYLE . '/img/',
  199. 'STYLEIMAGE' => CONFIG_URL_HTTP . CONFIG_DIR_STYLES . CONFIG_STYLE . '/images/',
  200. 'STYLEICON' => CONFIG_URL_HTTP . CONFIG_DIR_STYLES . CONFIG_STYLE . '/images/icons/',
  201. ));
  202. $injectObj->add('func_get_tpl_pagelayout_content', $param);
  203. //
  204. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'category_image_url', CONFIG_URL_HTTP . CONFIG_DIR_PRODUCTS_CATEGORIES_IMAGES);
  205. $injectObj->addb('func_get_tpl_pagelayout_content', 'content_wrap', 'product_category_image_url', CONFIG_URL_HTTP . CONFIG_DIR_PRODUCTS_CATEGORIES_IMAGES);
  206. //
  207. if( is_array($_GET) ) $_GET = func_db_prepare_input($_GET);
  208. if( is_array($_POST) ) $_POST = func_db_prepare_input($_POST);
  209. if( is_array($_REQUEST) ) $_REQUEST = func_db_prepare_input($_REQUEST);
  210. if( is_array($_COOKIE) ) $_COOKIE = func_db_prepare_input($_COOKIE);
  211. //
  212. $rt_current_userid = $_SESSION['suser']->userid;
  213. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  214. //
  215. $tpl->register_block("checklogin", "func_tpl_checklogin");
  216. $tpl->register_block("haslogin", "func_tpl_haslogin");
  217. $tpl->register_block("notlogin", "func_tpl_notlogin");
  218. //$tpl->register_outputfilter("func_tpl_outputfilter");
  219. //
  220. if( $SETTINGS['bs_closed'] == '1' && ($request_type != 'admin' && $request_type != 'ws.php') ) {
  221. include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'frontend.main.class.php');
  222. $feObj = new FrontendMainBase();
  223. $feObj->close();
  224. exit();
  225. }
  226. //crons
  227. //include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.cron.class.php');
  228. //$cronObj = new CoreCronBase();
  229. //$cronObj->run();
  230. //
  231. ?>