PageRenderTime 26ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/01.Source/01.CORE/admincp/modules/language/data.php

http://creative-portal.googlecode.com/
PHP | 247 lines | 221 code | 19 blank | 7 comment | 27 complexity | 7d722749f4f85e5689629171b43e1eb7 MD5 | raw file
Possible License(s): BSD-3-Clause
  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. nv_save_file_config_global();
  38. $contents = "<br><br><br><p align=\"center\">" . $lang_module['nv_setting_save'] . "</p>";
  39. $contents .= "<META HTTP-EQUIV=\"refresh\" content=\"1;URL=" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op . "\">";
  40. include ( NV_ROOTDIR . "/includes/header.php" );
  41. echo nv_admin_theme( $contents );
  42. include ( NV_ROOTDIR . "/includes/footer.php" );
  43. exit();
  44. }
  45. elseif ( $checksess == md5( $keylang . session_id() ) and in_array( $keylang, $global_config['allow_adminlangs'] ) )
  46. {
  47. if ( isset( $array_lang_setup[$keylang] ) and $array_lang_setup[$keylang] == 1 )
  48. {
  49. info_die( $lang_module['nv_data_setup'] );
  50. }
  51. else
  52. {
  53. 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'" ) );
  54. $global_config['site_theme'] = $site_theme;
  55. require_once ( NV_ROOTDIR . '/includes/sqldata.php' );
  56. $sql_create_table = nv_create_table_sys( $keylang );
  57. foreach ( $sql_create_table as $query )
  58. {
  59. $db->sql_query( $query );
  60. }
  61. $db->sql_query( "REPLACE INTO `" . $db_config['prefix'] . "_setup_language` (`lang`, `setup`) VALUES ('" . $keylang . "', '1')" );
  62. $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_" . $keylang . "_modules` SET `act` = '0'" );
  63. if ( defined( 'NV_MODULE_SETUP_DEFAULT' ) )
  64. {
  65. $lang_module['modules'] = "";
  66. $lang_module['vmodule_add'] = "";
  67. $lang_module['blocks'] = "";
  68. $lang_module['autoinstall'] = "";
  69. $lang_global['mod_modules'] = "";
  70. require_once ( NV_ROOTDIR . "/" . NV_ADMINDIR . "/modules/modules/functions.php" );
  71. $array_module_setup = explode( ",", NV_MODULE_SETUP_DEFAULT );
  72. foreach ( $array_module_setup as $setmodule )
  73. {
  74. $sm = nv_setup_data_module( $keylang, $setmodule );
  75. if ( $sm == "OK_" . $setmodule )
  76. {
  77. $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_" . $keylang . "_modules` SET `act` = '1'WHERE `title`='" . $setmodule . "'" );
  78. }
  79. }
  80. $db->sql_query( "DELETE FROM `" . $db_config['prefix'] . "_" . $keylang . "_modules` WHERE `act` = '0'" );
  81. //cai dat du lieu mau
  82. $filesavedata = $keylang;
  83. $lang_data = $keylang;
  84. if ( ! file_exists( NV_ROOTDIR . "/install/data_" . $keylang . ".php" ) )
  85. {
  86. $filesavedata = "en";
  87. }
  88. include_once ( NV_ROOTDIR . "/install/data_" . $filesavedata . ".php" );
  89. if ( ! file_exists( NV_ROOTDIR . "/install/data_" . $lang_data . ".php" ) )
  90. {
  91. $filesavedata = "en";
  92. }
  93. include_once ( NV_ROOTDIR . "/install/data_" . $filesavedata . ".php" );
  94. foreach ( $sql_create_table as $query )
  95. {
  96. if ( ! $db->sql_query( $query ) )
  97. {
  98. die( $query );
  99. }
  100. }
  101. $result = $db->sql_query( "SELECT catid FROM `" . $db_config['prefix'] . "_" . $lang_data . "_news_cat` ORDER BY `order` ASC" );
  102. while ( list( $catid_i ) = $db->sql_fetchrow( $result ) )
  103. {
  104. nv_create_table_news( $catid_i );
  105. }
  106. $db->sql_freeresult();
  107. $result = $db->sql_query( "SELECT id, listcatid FROM `" . $db_config['prefix'] . "_" . $lang_data . "_news_rows` ORDER BY `id` ASC" );
  108. while ( list( $id, $listcatid ) = $db->sql_fetchrow( $result ) )
  109. {
  110. $arr_catid = explode( ",", $listcatid );
  111. foreach ( $arr_catid as $catid )
  112. {
  113. $db->sql_query( "INSERT INTO `" . $db_config['prefix'] . "_" . $lang_data . "_news_" . $catid . "` SELECT * FROM `" . $db_config['prefix'] . "_" . $lang_data . "_news_rows` WHERE `id`=" . $id . "" );
  114. }
  115. }
  116. $db->sql_freeresult();
  117. }
  118. $nv_Request->set_Cookie( 'data_lang', $keylang, NV_LIVE_COOKIE_TIME );
  119. $contents_setup = "<br><br><center><br><b>" . $lang_module['nv_data_setup_ok'] . "</b></center>";
  120. $contents_setup .= "<META HTTP-EQUIV=\"refresh\" content=\"5;URL=" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=settings&" . NV_OP_VARIABLE . "=main\">";
  121. include ( NV_ROOTDIR . "/includes/header.php" );
  122. nv_admin_theme( $contents_setup );
  123. include ( NV_ROOTDIR . "/includes/footer.php" );
  124. exit();
  125. }
  126. }
  127. elseif ( $checksess == md5( $deletekeylang . session_id() . "deletekeylang" ) and ! in_array( $deletekeylang, $global_config['allow_sitelangs'] ) )
  128. {
  129. define( 'NV_IS_FILE_MODULES', true );
  130. $lang = $deletekeylang;
  131. $sql = "SELECT title, module_file, module_data FROM `" . $db_config['prefix'] . "_" . $lang . "_modules` ORDER BY `weight` ASC";
  132. $result_del_module = $db->sql_query( $sql );
  133. while ( list( $title, $module_file, $module_data ) = $db->sql_fetchrow( $result_del_module ) )
  134. {
  135. if ( file_exists( NV_ROOTDIR . '/modules/' . $module_file . '/action.php' ) )
  136. {
  137. $sql_drop_module = array();
  138. include ( NV_ROOTDIR . '/modules/' . $module_file . '/action.php' );
  139. if ( ! empty( $sql_drop_module ) )
  140. {
  141. foreach ( $sql_drop_module as $sql )
  142. {
  143. $db->sql_query( $sql );
  144. }
  145. }
  146. }
  147. }
  148. require_once ( NV_ROOTDIR . '/includes/sqldata.php' );
  149. $sql_drop_table = nv_delete_table_sys( $deletekeylang );
  150. foreach ( $sql_drop_table as $query )
  151. {
  152. $db->sql_query( $query );
  153. }
  154. $db->sql_query( "DELETE FROM `" . NV_CONFIG_GLOBALTABLE . "` WHERE `lang` = '" . $deletekeylang . "'" );
  155. $db->sql_query( "DELETE FROM `" . $db_config['prefix'] . "_setup_language` WHERE `lang` = '" . $deletekeylang . "'" );
  156. nv_save_file_config_global();
  157. 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() );
  158. exit();
  159. }
  160. $contents .= "<table summary=\"\" class=\"tab1\">\n";
  161. $contents .= " <thead>\n";
  162. $contents .= " <tr>";
  163. $contents .= " <td>" . $lang_module['nv_lang_key'] . "</td>";
  164. $contents .= " <td>" . $lang_module['nv_lang_name'] . "</td>";
  165. $contents .= " <td style=\"width: 120px\">" . $lang_module['nv_lang_slsite'] . "</td>";
  166. $contents .= " <td></td>";
  167. $contents .= " </thead>\n";
  168. $contents .= " </tr>";
  169. $a = 0;
  170. foreach ( $global_config['allow_adminlangs'] as $keylang )
  171. {
  172. $delete = "";
  173. $allow_sitelangs = "";
  174. if ( isset( $array_lang_setup[$keylang] ) and $array_lang_setup[$keylang] == 1 )
  175. {
  176. if ( ! in_array( $keylang, $global_config['allow_sitelangs'] ) )
  177. {
  178. $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 . "&deletekeylang=" . $keylang . "&amp;checksess=" . md5( $keylang . session_id() . "deletekeylang" ) . "\">" . $lang_module['nv_setup_delete'] . "</a></span>";
  179. }
  180. else
  181. {
  182. $setup = $lang_module['nv_setup'];
  183. }
  184. if ( $keylang != $global_config['site_lang'] )
  185. {
  186. $selected_yes = $selected_no = "";
  187. if ( in_array( $keylang, $global_config['allow_sitelangs'] ) )
  188. {
  189. $selected_yes = "selected=\"selected\"";
  190. }
  191. else
  192. {
  193. $selected_no = "selected=\"selected\"";
  194. }
  195. $allow_sitelangs = "<select onchange=\"top.location.href=this.options[this.selectedIndex].value;return;\">
  196. <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>
  197. <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>
  198. </select>";
  199. }
  200. else
  201. {
  202. $allow_sitelangs = $lang_module['site_lang'];
  203. }
  204. }
  205. else
  206. {
  207. $setup = "<span class=\"default_icon\"><a href=\"" . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op . "&keylang=" . $keylang . "&amp;checksess=" . md5( $keylang . session_id() ) . "\">" . $lang_module['nv_setup_new'] . "</a></span>";
  208. }
  209. $class = ( $a % 2 ) ? " class=\"second\"" : "";
  210. $contents .= "<tbody" . $class . ">\n";
  211. $contents .= " <tr>";
  212. $contents .= " <td>" . $keylang . "</td>";
  213. $contents .= " <td>" . $language_array[$keylang]['name'] . "</td>";
  214. $contents .= " <td style=\"text-align: center;\">" . $allow_sitelangs . "</td>";
  215. $contents .= " <td>" . $setup . "</td>";
  216. $contents .= " </tr>";
  217. $contents .= " </tbody>\n";
  218. $a ++;
  219. }
  220. $contents .= " </table>\n";
  221. $contents .= "<div class=\"quote\" style=\"width:97.5%;\">\n";
  222. $contents .= "<blockquote><span>" . $lang_module['nv_data_note'] . "</span></blockquote>\n";
  223. $contents .= "</div>\n";
  224. $contents .= "<div class=\"clear\"></div>\n";
  225. include ( NV_ROOTDIR . "/includes/header.php" );
  226. echo nv_admin_theme( $contents );
  227. include ( NV_ROOTDIR . "/includes/footer.php" );
  228. ?>