PageRenderTime 40ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/NukeViet3.2/admin/modules/language/main.php

http://nuke-viet.googlecode.com/
PHP | 297 lines | 257 code | 26 blank | 14 comment | 30 complexity | 292c2949dc8c6842b582a59e83022e07 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 (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 2-2-2010 12:55
  7. */
  8. if ( ! defined( 'NV_IS_FILE_LANG' ) ) die( 'Stop!!!' );
  9. $page_title = $lang_module['nv_lang_data'];
  10. $sql = "SELECT lang, setup FROM `" . $db_config['prefix'] . "_setup_language`";
  11. $result = $db->sql_query( $sql );
  12. $array_lang_setup = array();
  13. while ( $row = $db->sql_fetchrow( $result ) )
  14. {
  15. $array_lang_setup[$row['lang']] = intval( $row['setup'] );
  16. }
  17. $checksess = filter_text_input( 'checksess', 'get', '' );
  18. $keylang = filter_text_input( 'keylang', 'get', '', 1, 2 );
  19. $deletekeylang = filter_text_input( 'deletekeylang', 'get', '', 1, 2 );
  20. if ( $nv_Request->isset_request( 'activelang', 'get' ) and $checksess == md5( "activelang_" . $keylang . session_id() ) )
  21. {
  22. $activelang = $nv_Request->get_int( 'activelang', 'get', 0 );
  23. $allow_sitelangs = $global_config['allow_sitelangs'];
  24. if ( $activelang )
  25. {
  26. $allow_sitelangs[] = $keylang;
  27. }
  28. elseif ( $keylang != $global_config['site_lang'] )
  29. {
  30. $allow_sitelangs = array_diff( $allow_sitelangs, array(
  31. $keylang
  32. ) );
  33. }
  34. $allow_sitelangs = array_unique( $allow_sitelangs );
  35. $query = "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value` = " . $db->dbescape( implode( ",", $allow_sitelangs ) ) . " WHERE `lang`='sys' AND `module` = 'global' AND `config_name` = 'allow_sitelangs'";
  36. $result = $db->sql_query( $query );
  37. $temp = ( $activelang == 1 ) ? $lang_global['yes'] : $lang_global['no'];
  38. nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['nv_lang_slsite'], " langkey : " . $keylang . " [ " . $temp . " ]", $admin_info['userid'] );
  39. nv_save_file_config_global();
  40. $contents = "<br /><br /><br /><p align=\"center\">" . $lang_module['nv_setting_save'] . "</p>";
  41. $contents .= "<meta http-equiv=\"Refresh\" content=\"1;URL=" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op . "\" />";
  42. include ( NV_ROOTDIR . "/includes/header.php" );
  43. echo nv_admin_theme( $contents );
  44. include ( NV_ROOTDIR . "/includes/footer.php" );
  45. exit();
  46. }
  47. elseif ( $checksess == md5( $keylang . session_id() ) and in_array( $keylang, $global_config['allow_adminlangs'] ) )
  48. {
  49. if ( isset( $array_lang_setup[$keylang] ) and $array_lang_setup[$keylang] == 1 )
  50. {
  51. info_die( $lang_module['nv_data_setup'] );
  52. }
  53. else
  54. {
  55. nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['nv_setup_new'] . " " . $lang_module['nv_lang_data'], " langkey : " . $keylang, $admin_info['userid'] );
  56. list( $site_theme ) = $db->sql_fetchrow( $db->sql_query( "SELECT `config_value` FROM `" . NV_CONFIG_GLOBALTABLE . "` where `lang`='" . $global_config['site_lang'] . "' AND `module`='global' AND `config_name`='site_theme'" ) );
  57. $global_config['site_theme'] = $site_theme;
  58. require_once ( NV_ROOTDIR . '/includes/sqldata.php' );
  59. $sql_create_table = nv_create_table_sys( $keylang );
  60. foreach ( $sql_create_table as $query )
  61. {
  62. $db->sql_query( $query );
  63. }
  64. $db->sql_query( "REPLACE INTO `" . $db_config['prefix'] . "_setup_language` (`lang`, `setup`) VALUES ('" . $keylang . "', '1')" );
  65. $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_" . $keylang . "_modules` SET `act` = '0'" );
  66. if ( defined( 'NV_MODULE_SETUP_DEFAULT' ) )
  67. {
  68. $lang_module['modules'] = "";
  69. $lang_module['vmodule_add'] = "";
  70. $lang_module['blocks'] = "";
  71. $lang_module['autoinstall'] = "";
  72. $lang_global['mod_modules'] = "";
  73. $module_name = "modules";
  74. require_once ( NV_ROOTDIR . "/" . NV_ADMINDIR . "/modules/modules/functions.php" );
  75. $module_name = "";
  76. $array_module_setup = explode( ",", NV_MODULE_SETUP_DEFAULT );
  77. $modules_exit = nv_scandir( NV_ROOTDIR . "/modules", $global_config['check_module'] );
  78. $modules_exit[] = 'global';
  79. foreach ( $array_module_setup as $setmodule )
  80. {
  81. if ( in_array( $setmodule, $modules_exit ) )
  82. {
  83. $sm = nv_setup_data_module( $keylang, $setmodule );
  84. if ( $sm == "OK_" . $setmodule )
  85. {
  86. $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_" . $keylang . "_modules` SET `act` = '1'WHERE `title`='" . $setmodule . "'" );
  87. }
  88. }
  89. }
  90. $db->sql_query( "DELETE FROM `" . $db_config['prefix'] . "_" . $keylang . "_modules` WHERE `act` = '0'" );
  91. //cai dat du lieu mau
  92. $filesavedata = "";
  93. $lang_data = $keylang;
  94. if ( file_exists( NV_ROOTDIR . "/install/data_" . $keylang . ".php" ) )
  95. {
  96. $filesavedata = $keylang;
  97. }
  98. elseif ( file_exists( NV_ROOTDIR . "/install/data_en.php" ) )
  99. {
  100. $filesavedata = "en";
  101. }
  102. if ( ! empty( $filesavedata ) )
  103. {
  104. $sql_create_table = array();
  105. include_once ( NV_ROOTDIR . "/install/data_" . $filesavedata . ".php" );
  106. foreach ( $sql_create_table as $query )
  107. {
  108. if ( ! $db->sql_query( $query ) )
  109. {
  110. include ( NV_ROOTDIR . "/includes/header.php" );
  111. echo nv_admin_theme( "ERROR SETUP SQL: <br />" . $query );
  112. include ( NV_ROOTDIR . "/includes/footer.php" );
  113. exit();
  114. }
  115. }
  116. //xoa du lieu tai bang nv3_vi_blocks
  117. $sql = "DELETE FROM `" . $db_config['prefix'] . "_" . $lang_data . "_blocks_weight` WHERE `bid` in (SELECT `bid` FROM `" . $db_config['prefix'] . "_" . $lang_data . "_blocks_groups` WHERE `module` NOT IN ('" . implode( "', '", $modules_exit ) . "'))";
  118. $db->sql_query( $sql );
  119. //xoa du lieu tai bang nv3_vi_blocks_groups
  120. $sql = "DELETE FROM `" . $db_config['prefix'] . "_" . $lang_data . "_blocks_groups` WHERE `module` NOT IN ('" . implode( "', '", $modules_exit ) . "')";
  121. $db->sql_query( $sql );
  122. //xoa du lieu tai bang nv3_vi_modthemes
  123. $sql = "DELETE FROM `" . $db_config['prefix'] . "_" . $lang_data . "_modthemes` WHERE `func_id` in (SELECT `func_id` FROM `" . $db_config['prefix'] . "_" . $lang_data . "_modfuncs` WHERE `in_module` NOT IN ('" . implode( "', '", $modules_exit ) . "'))";
  124. $db->sql_query( $sql );
  125. //xoa du lieu tai bang nv3_vi_modfuncs
  126. $sql = "DELETE FROM `" . $db_config['prefix'] . "_" . $lang_data . "_modfuncs` WHERE `in_module` NOT IN ('" . implode( "', '", $modules_exit ) . "')";
  127. $db->sql_query( $sql );
  128. //xoa du lieu tai bang nv3_vi_modules
  129. $sql = "DELETE FROM `" . $db_config['prefix'] . "_" . $lang_data . "_modules` WHERE `title` NOT IN ('" . implode( "', '", $modules_exit ) . "')";
  130. $db->sql_query( $sql );
  131. //xoa du lieu tai bang nv3_setup_modules
  132. $sql = "DELETE FROM `" . $db_config['prefix'] . "_setup_modules` WHERE `title` NOT IN ('" . implode( "', '", $modules_exit ) . "')";
  133. $db->sql_query( $sql );
  134. ///xoa du lieu tai bang nv3_config
  135. $sql = "DELETE FROM `" . $db_config['prefix'] . "_config` WHERE `lang`=" . $db->dbescape( $lang_data ) . " AND `module` NOT IN ('" . implode( "', '", $modules_exit ) . "')";
  136. $db->sql_query( $sql );
  137. $sql = "SELECT * FROM `" . $db_config['prefix'] . "_" . $lang_data . "_modules` WHERE `title`='news'";
  138. $result = $db->sql_query( $sql );
  139. if ( $db->sql_numrows( $result ) )
  140. {
  141. $result = $db->sql_query( "SELECT catid FROM `" . $db_config['prefix'] . "_" . $lang_data . "_news_cat` ORDER BY `order` ASC" );
  142. while ( list( $catid_i ) = $db->sql_fetchrow( $result ) )
  143. {
  144. nv_create_table_news( $catid_i );
  145. }
  146. $db->sql_freeresult();
  147. $result = $db->sql_query( "SELECT id, listcatid FROM `" . $db_config['prefix'] . "_" . $lang_data . "_news_rows` ORDER BY `id` ASC" );
  148. while ( list( $id, $listcatid ) = $db->sql_fetchrow( $result ) )
  149. {
  150. $arr_catid = explode( ",", $listcatid );
  151. foreach ( $arr_catid as $catid )
  152. {
  153. $db->sql_query( "INSERT INTO `" . $db_config['prefix'] . "_" . $lang_data . "_news_" . $catid . "` SELECT * FROM `" . $db_config['prefix'] . "_" . $lang_data . "_news_rows` WHERE `id`=" . $id . "" );
  154. }
  155. }
  156. $db->sql_freeresult();
  157. }
  158. }
  159. }
  160. $nv_Request->set_Cookie( 'data_lang', $keylang, NV_LIVE_COOKIE_TIME );
  161. $contents_setup = "<br /><br /><center><br /><b>" . $lang_module['nv_data_setup_ok'] . "</b></center>";
  162. $contents_setup .= "<meta http-equiv=\"Refresh\" content=\"5;URL=" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=settings&" . NV_OP_VARIABLE . "=main\" />";
  163. include ( NV_ROOTDIR . "/includes/header.php" );
  164. echo nv_admin_theme( $contents_setup );
  165. include ( NV_ROOTDIR . "/includes/footer.php" );
  166. exit();
  167. }
  168. }
  169. elseif ( $checksess == md5( $deletekeylang . session_id() . "deletekeylang" ) and ! in_array( $deletekeylang, $global_config['allow_sitelangs'] ) )
  170. {
  171. define( 'NV_IS_FILE_MODULES', true );
  172. $lang = $deletekeylang;
  173. $sql = "SELECT title, module_file, module_data FROM `" . $db_config['prefix'] . "_" . $lang . "_modules` ORDER BY `weight` ASC";
  174. $result_del_module = $db->sql_query( $sql );
  175. while ( list( $title, $module_file, $module_data ) = $db->sql_fetchrow( $result_del_module ) )
  176. {
  177. if ( file_exists( NV_ROOTDIR . '/modules/' . $module_file . '/action.php' ) )
  178. {
  179. $sql_drop_module = array();
  180. include ( NV_ROOTDIR . '/modules/' . $module_file . '/action.php' );
  181. if ( ! empty( $sql_drop_module ) )
  182. {
  183. foreach ( $sql_drop_module as $sql )
  184. {
  185. $db->sql_query( $sql );
  186. }
  187. }
  188. }
  189. }
  190. require_once ( NV_ROOTDIR . '/includes/sqldata.php' );
  191. $sql_drop_table = nv_delete_table_sys( $deletekeylang );
  192. foreach ( $sql_drop_table as $query )
  193. {
  194. $db->sql_query( $query );
  195. }
  196. $db->sql_query( "DELETE FROM `" . NV_CONFIG_GLOBALTABLE . "` WHERE `lang` = '" . $deletekeylang . "'" );
  197. $db->sql_query( "DELETE FROM `" . $db_config['prefix'] . "_setup_language` WHERE `lang` = '" . $deletekeylang . "'" );
  198. nv_save_file_config_global();
  199. nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['nv_setup_delete'], " langkey : " . $deletekeylang, $admin_info['userid'] );
  200. Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&' . NV_LANG_VARIABLE . '=' . $global_config['site_lang'] . '&rand=' . nv_genpass() );
  201. exit();
  202. }
  203. $contents .= "<table summary=\"\" class=\"tab1\">\n";
  204. $contents .= " <thead>\n";
  205. $contents .= " <tr>";
  206. $contents .= " <td>" . $lang_module['nv_lang_key'] . "</td>";
  207. $contents .= " <td>" . $lang_module['nv_lang_name'] . "</td>";
  208. $contents .= " <td style=\"width: 120px\">" . $lang_module['nv_lang_slsite'] . "</td>";
  209. $contents .= " <td></td>";
  210. $contents .= " </tr>";
  211. $contents .= " </thead>\n";
  212. $a = 0;
  213. foreach ( $global_config['allow_adminlangs'] as $keylang )
  214. {
  215. $delete = "";
  216. $allow_sitelangs = "";
  217. if ( isset( $array_lang_setup[$keylang] ) and $array_lang_setup[$keylang] == 1 )
  218. {
  219. if ( ! in_array( $keylang, $global_config['allow_sitelangs'] ) )
  220. {
  221. $setup = "<span class=\"delete_icon\"><a onclick=\"return confirm(nv_is_del_confirm[0])\" href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op . "&amp;deletekeylang=" . $keylang . "&amp;checksess=" . md5( $keylang . session_id() . "deletekeylang" ) . "\">" . $lang_module['nv_setup_delete'] . "</a></span>";
  222. }
  223. else
  224. {
  225. $setup = $lang_module['nv_setup'];
  226. }
  227. if ( $keylang != $global_config['site_lang'] )
  228. {
  229. $selected_yes = $selected_no = "";
  230. if ( in_array( $keylang, $global_config['allow_sitelangs'] ) )
  231. {
  232. $selected_yes = "selected=\"selected\"";
  233. }
  234. else
  235. {
  236. $selected_no = "selected=\"selected\"";
  237. }
  238. $allow_sitelangs = "<select onchange=\"top.location.href=this.options[this.selectedIndex].value;return;\">
  239. <option " . $selected_yes . " value=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op . "&amp;keylang=" . $keylang . "&amp;activelang=1&amp;checksess=" . md5( "activelang_" . $keylang . session_id() ) . "\">" . $lang_global['yes'] . "</option>
  240. <option " . $selected_no . " value=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op . "&amp;keylang=" . $keylang . "&amp;activelang=0&amp;checksess=" . md5( "activelang_" . $keylang . session_id() ) . "\">" . $lang_global['no'] . "</option>
  241. </select>";
  242. }
  243. else
  244. {
  245. $allow_sitelangs = $lang_module['site_lang'];
  246. }
  247. }
  248. else
  249. {
  250. $setup = "<span class=\"default_icon\"><a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op . "&amp;keylang=" . $keylang . "&amp;checksess=" . md5( $keylang . session_id() ) . "\">" . $lang_module['nv_setup_new'] . "</a></span>";
  251. }
  252. $class = ( $a % 2 ) ? " class=\"second\"" : "";
  253. $contents .= "<tbody" . $class . ">\n";
  254. $contents .= " <tr>";
  255. $contents .= " <td>" . $keylang . "</td>";
  256. $contents .= " <td>" . $language_array[$keylang]['name'] . "</td>";
  257. $contents .= " <td style=\"text-align: center;\">" . $allow_sitelangs . "</td>";
  258. $contents .= " <td>" . $setup . "</td>";
  259. $contents .= " </tr>";
  260. $contents .= " </tbody>\n";
  261. $a ++;
  262. }
  263. $contents .= " </table>\n";
  264. $contents .= "<div class=\"quote\" style=\"width:97.5%;\">\n";
  265. $contents .= "<blockquote><span>" . $lang_module['nv_data_note'] . "</span></blockquote>\n";
  266. $contents .= "</div>\n";
  267. $contents .= "<div class=\"clear\"></div>\n";
  268. include ( NV_ROOTDIR . "/includes/header.php" );
  269. echo nv_admin_theme( $contents );
  270. include ( NV_ROOTDIR . "/includes/footer.php" );
  271. ?>