PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/01.Source/01.CORE/admincp/modules/settings/uploadconfig.php

http://creative-portal.googlecode.com/
PHP | 135 lines | 121 code | 8 blank | 6 comment | 8 complexity | 72413eaa3fa9f2b7817c2b10c8d78a0f 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-9-2010 14:43
  7. */
  8. if ( ! defined( 'NV_ADMIN' ) or ! defined( 'NV_MAINFILE' ) or ! defined( 'NV_IS_MODADMIN' ) ) die( 'Stop!!!' );
  9. $page_title = $lang_module['uploadconfig'];
  10. if ( $nv_Request->isset_request( 'submit', 'post' ) )
  11. {
  12. $type = $nv_Request->get_array( 'type', 'post' );
  13. $type = implode( ',', $type );
  14. $ext = $nv_Request->get_array( 'ext', 'post' );
  15. $ext[]= "php";
  16. $ext[]= "php3";
  17. $ext[]= "php4";
  18. $ext[]= "php5";
  19. $ext[]= "phtml";
  20. $ext[]= "inc";
  21. $ext = array_unique($ext);
  22. $ext = implode( ',', $ext );
  23. $mime = $nv_Request->get_array( 'mime', 'post' );
  24. $mime = implode( ',', $mime );
  25. $nv_max_size = $nv_Request->get_int( 'nv_max_size', 'post', $global_config['nv_max_size'] );
  26. $nv_max_size = min( nv_converttoBytes( ini_get( 'upload_max_filesize' ) ), nv_converttoBytes( ini_get( 'post_max_size' ) ), $nv_max_size );
  27. $db->sql_query( "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value`=" . $db->dbescape_string( $type ) . " WHERE `config_name` = 'file_allowed_ext' AND `lang` = 'sys' AND `module`='global' LIMIT 1" );
  28. $db->sql_query( "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value`=" . $db->dbescape_string( $ext ) . " WHERE `config_name` = 'forbid_extensions' AND `lang` = 'sys' AND `module`='global' LIMIT 1" );
  29. $db->sql_query( "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value`=" . $db->dbescape_string( $mime ) . " WHERE `config_name` = 'forbid_mimes' AND `lang` = 'sys' AND `module`='global' LIMIT 1" );
  30. $db->sql_query( "UPDATE `" . NV_CONFIG_GLOBALTABLE . "` SET `config_value`=" . $db->dbescape_string( $nv_max_size ) . " WHERE `config_name` = 'nv_max_size' AND `lang` = 'sys' AND `module`='global' LIMIT 1" );
  31. nv_save_file_config_global();
  32. Header( 'Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&rand=' . nv_genpass() );
  33. die();
  34. }
  35. $ini = parse_ini_file( NV_ROOTDIR . '/includes/ini/mime.ini', true );
  36. $types = array_keys( $ini );
  37. $extmime = array_values( $ini );
  38. $mimes = $exts = array();
  39. for ( $i = 0; $i < count( $extmime ); $i ++ )
  40. {
  41. $exts = array_merge( $exts, array_keys( $extmime[$i] ) );
  42. for ( $j = 0; $j < count( $exts ); $j ++ )
  43. {
  44. if ( isset( $extmime[$i][$exts[$j]] ) )
  45. {
  46. $mimes = array_merge( ( array )$mimes, ( array )array_values( ( array )$extmime[$i][$exts[$j]] ) );
  47. }
  48. }
  49. }
  50. $mimes = array_unique( $mimes );
  51. sort( $types );
  52. sort( $exts );
  53. sort( $mimes );
  54. $contents .= "<form action='' method='post'>\n";
  55. $contents .= "<table class=\"tab1\" style='width:830px'>\n";
  56. $contents .= "<tbody class='second'>\n";
  57. $contents .= "<tr>\n";
  58. $contents .= "<td colspan='2'><strong>" . $lang_module['uploadconfig'] . "</strong></td>\n";
  59. $contents .= "</tr>\n";
  60. $contents .= "</tbody>\n";
  61. $contents .= "<tr>\n";
  62. $contents .= "<td style='width:130px'><strong>" . $lang_module['uploadconfig_types'] . "</strong></td>\n";
  63. $contents .= "<td>";
  64. foreach ( $types as $type )
  65. {
  66. $contents .= "<label style='display:inline-block;width:100px'><input type='checkbox' name='type[]' value='" . $type . "' " . ( in_array( $type, $global_config['file_allowed_ext'] ) ? 'checked=checked' : '' ) . "/> " . $type . "&nbsp;&nbsp;</label>";
  67. }
  68. $contents .= "</td>\n";
  69. $contents .= "</tr>\n";
  70. $contents .= "<tbody class='second'>\n";
  71. $contents .= "<tr>\n";
  72. $contents .= "<td style='vertical-align:top'><strong>" . $lang_module['uploadconfig_ban_ext'] . "</strong></td>\n";
  73. $contents .= "<td>";
  74. foreach ( $exts as $ext )
  75. {
  76. $contents .= "<label style='display:inline-block;width:100px'><input type='checkbox' name='ext[]' value='" . $ext . "' " . ( in_array( $ext, $global_config['forbid_extensions'] ) ? 'checked=checked' : '' ) . "/> " . $ext . "&nbsp;&nbsp;</label>";
  77. }
  78. $contents .= "</td>\n";
  79. $contents .= "</td>\n";
  80. $contents .= "</tr>\n";
  81. $contents .= "</tbody>\n";
  82. $contents .= "<tbody>\n";
  83. $contents .= "<tr>\n";
  84. $contents .= "<td style='vertical-align:top'><strong>" . $lang_module['uploadconfig_ban_mime'] . "</strong></td>\n";
  85. $contents .= "<td>";
  86. foreach ( $mimes as $mime )
  87. {
  88. $contents .= "<label style='display:inline-block;width:320px'><input type='checkbox' name='mime[]' value='" . $mime . "' " . ( in_array( $mime, $global_config['forbid_mimes'] ) ? 'checked=checked' : '' ) . "/> " . $mime . "&nbsp;&nbsp;</label>";
  89. }
  90. $contents .= "</td>\n";
  91. $contents .= "</tr>\n";
  92. $contents .= "</tbody>\n";
  93. $contents .= "<tbody class='second'>";
  94. $contents .= "<tr>";
  95. $contents .= "<td align=\"right\"><strong>" . $lang_module['nv_max_size'] . ": </strong></td>\n";
  96. $contents .= "<td>";
  97. $contents .= "<select name=\"nv_max_size\">\n";
  98. $sys_max_size = min( nv_converttoBytes( ini_get( 'upload_max_filesize' ) ), nv_converttoBytes( ini_get( 'post_max_size' ) ) );
  99. $p_size = $sys_max_size / 100;
  100. for ( $index = 100; $index > 0; $index -- )
  101. {
  102. $size = floor( $index * $p_size );
  103. $sl = "";
  104. if ( $size == $global_config['nv_max_size'] )
  105. {
  106. $sl = " selected=\"selected\"";
  107. }
  108. $contents .= "<option value=\"" . $size . "\" " . $sl . ">" . nv_convertfromBytes( $size ) . "</option>\n";
  109. }
  110. $contents .= "</select> \n";
  111. $contents .= " (".$lang_module['sys_max_size'].": ".nv_convertfromBytes($sys_max_size).")";
  112. $contents .= "</td>";
  113. $contents .= "</tr>";
  114. $contents .= "</tbody>";
  115. $contents .= "<tbody>\n";
  116. $contents .= "<tr>\n";
  117. $contents .= "<td colspan='2' style='text-align:center'>";
  118. $contents .= "<input type='submit' value='" . $lang_module['banip_confirm'] . "' name='submit'/>\n";
  119. $contents .= "</td>\n";
  120. $contents .= "</tr>\n";
  121. $contents .= "</tbody>\n";
  122. $contents .= "</table>\n";
  123. $contents .= "</form>\n";
  124. include ( NV_ROOTDIR . "/includes/header.php" );
  125. echo nv_admin_theme( $contents );
  126. include ( NV_ROOTDIR . "/includes/footer.php" );
  127. ?>