PageRenderTime 36ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/NukeViet3.3/admin/index.php

http://nuke-viet.googlecode.com/
PHP | 226 lines | 184 code | 30 blank | 12 comment | 24 complexity | e2135b466df875f627abafca6c4264ff MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @copyright 2009
  6. * @createdate 12/30/2009 6:18
  7. */
  8. define( 'NV_ADMIN', true );
  9. //Ket noi den mainfile.php nam o thu muc goc.
  10. $realpath_mainfile = $set_active_op = "";
  11. $temp_dir = str_replace( DIRECTORY_SEPARATOR, '/', dirname( __file__ ) );
  12. $temp_path = "/../";
  13. for ( $i = 0; $i < 10; ++$i )
  14. {
  15. $realpath_mainfile = @realpath( $temp_dir . $temp_path . 'mainfile.php' );
  16. if ( ! empty( $realpath_mainfile ) ) break;
  17. $temp_path .= "../";
  18. }
  19. unset( $temp_dir, $temp_path );
  20. if ( empty( $realpath_mainfile ) ) die();
  21. require ( $realpath_mainfile );
  22. ob_start();
  23. //Admin dang nhap
  24. if ( ! defined( 'NV_IS_ADMIN' ) or ! isset( $admin_info ) or empty( $admin_info ) )
  25. {
  26. require ( NV_ROOTDIR . "/includes/core/admin_access.php" );
  27. require ( NV_ROOTDIR . "/includes/core/admin_login.php" );
  28. exit();
  29. }
  30. if ( file_exists( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/admin_global.php" ) )
  31. {
  32. require ( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/admin_global.php" );
  33. }
  34. elseif ( file_exists( NV_ROOTDIR . "/language/" . NV_LANG_DATA . "/admin_global.php" ) )
  35. {
  36. require ( NV_ROOTDIR . "/language/" . NV_LANG_DATA . "/admin_global.php" );
  37. }
  38. elseif ( file_exists( NV_ROOTDIR . "/language/en/admin_global.php" ) )
  39. {
  40. require ( NV_ROOTDIR . "/language/en/admin_global.php" );
  41. }
  42. include_once ( NV_ROOTDIR . "/includes/core/admin_functions.php" );
  43. $admin_mods = array();
  44. $admin_mods['siteinfo'] = array(
  45. 'custom_title' => $lang_global['mod_siteinfo']
  46. );
  47. $admin_mods['authors'] = array(
  48. 'custom_title' => $lang_global['mod_authors']
  49. );
  50. if ( defined( 'NV_IS_SPADMIN' ) )
  51. {
  52. if ( defined( 'NV_IS_GODADMIN' ) )
  53. {
  54. $admin_mods['database'] = array(
  55. 'custom_title' => $lang_global['mod_database']
  56. );
  57. $admin_mods['settings'] = array(
  58. 'custom_title' => $lang_global['mod_settings']
  59. );
  60. $admin_mods['webtools'] = array(
  61. 'custom_title' => $lang_global['mod_webtools']
  62. );
  63. }
  64. $admin_mods['language'] = array(
  65. 'custom_title' => $lang_global['mod_language']
  66. );
  67. $admin_mods['modules'] = array(
  68. 'custom_title' => $lang_global['mod_modules']
  69. );
  70. $admin_mods['themes'] = array(
  71. 'custom_title' => $lang_global['mod_themes']
  72. );
  73. }
  74. $admin_mods['upload'] = array(
  75. 'custom_title' => $lang_global['mod_upload']
  76. );
  77. $module_name = strtolower( filter_text_input( NV_NAME_VARIABLE, 'post,get', 'siteinfo' ) );
  78. if ( ! empty( $module_name ) )
  79. {
  80. $include_functions = $include_file = $lang_file = $mod_theme_file = "";
  81. $module_data = $module_file = $module_name;
  82. $op = filter_text_input( NV_OP_VARIABLE, 'post,get', 'main' );
  83. if ( empty( $op ) or $op == "functions" )
  84. {
  85. $op = "main";
  86. }
  87. $site_mods = nv_site_mods();
  88. if ( empty( $site_mods ) and $module_name != "language" )
  89. {
  90. $sql = "SELECT `setup` FROM `" . $db_config['prefix'] . "_setup_language` WHERE `lang`='" . NV_LANG_DATA . "' LIMIT 1";
  91. $result = $db->sql_query( $sql );
  92. list( $setup ) = $db->sql_fetchrow( $result );
  93. if ( empty( $setup ) )
  94. {
  95. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=language" );
  96. exit();
  97. }
  98. }
  99. $menu_top = array();
  100. if ( isset( $admin_mods[$module_name] ) )
  101. {
  102. $module_info = $admin_mods[$module_name];
  103. $module_file = $module_name;
  104. $include_functions = NV_ROOTDIR . "/" . NV_ADMINDIR . "/modules/" . $module_file . "/functions.php";
  105. $include_file = NV_ROOTDIR . "/" . NV_ADMINDIR . "/modules/" . $module_file . "/" . $op . ".php";
  106. //ket noi voi file ngon ngu cua module
  107. if ( file_exists( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/admin_" . $module_file . ".php" ) )
  108. {
  109. require ( NV_ROOTDIR . "/language/" . NV_LANG_INTERFACE . "/admin_" . $module_file . ".php" );
  110. }
  111. elseif ( file_exists( NV_ROOTDIR . "/language/" . NV_LANG_DATA . "/admin_" . $module_file . ".php" ) )
  112. {
  113. require ( NV_ROOTDIR . "/language/" . NV_LANG_DATA . "/admin_" . $module_file . ".php" );
  114. }
  115. elseif ( file_exists( NV_ROOTDIR . "/language/en/admin_" . $module_file . ".php" ) )
  116. {
  117. require ( NV_ROOTDIR . "/language/en/admin_" . $module_file . ".php" );
  118. }
  119. }
  120. elseif ( isset( $site_mods[$module_name] ) )
  121. {
  122. $module_info = $site_mods[$module_name];
  123. $module_file = $module_info['module_file'];
  124. $module_data = $module_info['module_data'];
  125. $include_functions = NV_ROOTDIR . "/modules/" . $module_file . "/admin.functions.php";
  126. $include_file = NV_ROOTDIR . "/modules/" . $module_file . "/admin/" . $op . ".php";
  127. //Ket noi ngon ngu cua module
  128. if ( file_exists( NV_ROOTDIR . "/modules/" . $module_file . "/language/admin_" . NV_LANG_INTERFACE . ".php" ) )
  129. {
  130. require ( NV_ROOTDIR . "/modules/" . $module_file . "/language/admin_" . NV_LANG_INTERFACE . ".php" );
  131. }
  132. elseif ( file_exists( NV_ROOTDIR . "/modules/" . $module_file . "/language/admin_" . NV_LANG_DATA . ".php" ) )
  133. {
  134. require ( NV_ROOTDIR . "/modules/" . $module_file . "/language/admin_" . NV_LANG_DATA . ".php" );
  135. }
  136. elseif ( file_exists( NV_ROOTDIR . "/modules/" . $module_file . "/language/admin_en.php" ) )
  137. {
  138. require ( NV_ROOTDIR . "/modules/" . $module_file . "/language/admin_en.php" );
  139. }
  140. }
  141. if ( file_exists( $include_functions ) and file_exists( $include_file ) )
  142. {
  143. define( 'NV_IS_MODADMIN', true );
  144. $array_lang_admin = array();
  145. if ( $global_config['lang_multi'] )
  146. {
  147. foreach ( $global_config['allow_adminlangs'] as $lang_i )
  148. {
  149. if ( file_exists( NV_ROOTDIR . "/language/" . $lang_i . "/global.php" ) )
  150. {
  151. $array_lang_admin[$lang_i] = $language_array[$lang_i]['name'];
  152. }
  153. }
  154. }
  155. //ket noi voi giao dien chung cua admin
  156. require ( NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/theme.php" );
  157. // Ket noi giao dien cua module
  158. $global_config['module_theme'] = "";
  159. if ( is_dir( NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/modules/" . $module_file . "/" ) )
  160. {
  161. $global_config['module_theme'] = $global_config['admin_theme'];
  162. }
  163. elseif ( is_dir( NV_ROOTDIR . "/themes/admin_default/modules/" . $module_file . "/" ) )
  164. {
  165. $global_config['module_theme'] = "admin_default";
  166. }
  167. $allow_func = array();
  168. require ( $include_functions );
  169. if ( in_array( $op, $allow_func ) )
  170. {
  171. $admin_menu_mods = array();
  172. if ( ! empty( $menu_top ) and ! empty( $submenu ) )
  173. {
  174. $admin_menu_mods[$module_name] = $menu_top['custom_title'];
  175. }
  176. foreach ( $site_mods as $key => $value )
  177. {
  178. if($value['admin_file']) $admin_menu_mods[$key] = $value['custom_title'];
  179. }
  180. require ( $include_file );
  181. exit();
  182. }
  183. else
  184. {
  185. nv_info_die( $lang_global['error_404_title'], $lang_global['error_404_title'], $lang_global['admin_no_allow_func'] );
  186. }
  187. }
  188. elseif ( isset( $site_mods[$module_name] ) and $op == "main" )
  189. {
  190. $sql = "UPDATE `" . NV_MODULES_TABLE . "` SET `admin_file`='0' WHERE `title`=" . $db->dbescape( $module_name );
  191. $db->sql_query( $sql );
  192. nv_del_moduleCache( 'modules' );
  193. }
  194. }
  195. nv_info_die( $lang_global['error_404_title'], $lang_global['error_404_title'], $lang_global['error_404_content'] );
  196. ?>