PageRenderTime 26ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Quản lý website trường trung học phổ thông PHP/lc1/modules/about/admin/content.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 168 lines | 146 code | 16 blank | 6 comment | 16 complexity | ca55c01392b9bba019d1a447da7d6088 MD5 | raw file
  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_IS_FILE_ADMIN' ) ) die( 'Stop!!!' );
  9. $id = $nv_Request->get_int( 'id', 'post,get', 0 );
  10. if ( $id )
  11. {
  12. $query = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  13. $result = $db->sql_query( $query );
  14. $numrows = $db->sql_numrows( $result );
  15. if ( empty( $numrows ) )
  16. {
  17. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  18. die();
  19. }
  20. $row = $db->sql_fetchrow( $result );
  21. define( 'IS_EDIT', true );
  22. $page_title = $lang_module ['aabout12'];
  23. $action = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op . "&amp;id=" . $id;
  24. }
  25. else
  26. {
  27. $page_title = $lang_module ['aabout1'];
  28. $action = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $op;
  29. }
  30. $error = "";
  31. if ( defined( 'NV_EDITOR' ) )
  32. {
  33. require_once ( NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php' );
  34. }
  35. if ( $nv_Request->get_int( 'save', 'post' ) == '1' )
  36. {
  37. $title = filter_text_input( 'title', 'post', '', 1 );
  38. $alias = filter_text_input( 'alias', 'post', '', 1 );
  39. $bodytext = nv_editor_filter_textarea( 'bodytext', '', NV_ALLOWED_HTML_TAGS );
  40. if ( empty( $title ) )
  41. {
  42. $error = $lang_module ['aabout9'];
  43. }
  44. elseif ( strip_tags( $bodytext ) == "" )
  45. {
  46. $error = $lang_module ['aabout10'];
  47. }
  48. else
  49. {
  50. $bodytext = nv_editor_nl2br( $bodytext );
  51. $alias = empty( $alias ) ? change_alias( $title ) : change_alias( $alias );
  52. if ( defined( 'IS_EDIT' ) )
  53. {
  54. $query = "UPDATE`" . NV_PREFIXLANG . "_" . $module_data . "` SET
  55. `title`=" . $db->dbescape( $title ) . ", `alias` = " . $db->dbescape( $alias ) . ",
  56. `bodytext`=" . $db->dbescape( $bodytext ) . ", `keywords`='', `edit_time`=" . NV_CURRENTTIME . " WHERE `id` =" . $id;
  57. }
  58. else
  59. {
  60. list( $weight ) = $db->sql_fetchrow( $db->sql_query( "SELECT MAX(`weight`) FROM `" . NV_PREFIXLANG . "_" . $module_data . "`" ) );
  61. $weight = intval( $weight ) + 1;
  62. $query = "INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "` VALUES (
  63. NULL, " . $db->dbescape( $title ) . ", " . $db->dbescape( $alias ) . ", " . $db->dbescape( $bodytext ) . ", '',
  64. " . $weight . ", " . $admin_info ['admin_id'] . ", " . NV_CURRENTTIME . ", " . NV_CURRENTTIME . ", 1);";
  65. }
  66. $db->sql_query( $query );
  67. nv_del_moduleCache( $module_name );
  68. if ( $db->sql_affectedrows() > 0 )
  69. {
  70. if ( defined( 'IS_EDIT' ) )
  71. {
  72. nv_insert_logs( NV_LANG_DATA, $module_name, 'log_edit_about', "aboutid " . $id, $admin_info ['userid'] );
  73. }
  74. else
  75. {
  76. nv_insert_logs( NV_LANG_DATA, $module_name, 'log_add_about', " ", $admin_info ['userid'] );
  77. }
  78. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=main" );
  79. die();
  80. }
  81. else
  82. {
  83. $error = $lang_module ['errorsave'];
  84. }
  85. }
  86. }
  87. else
  88. {
  89. if ( defined( 'IS_EDIT' ) )
  90. {
  91. $title = $row ['title'];
  92. $alias = $row ['alias'];
  93. $bodytext = nv_editor_br2nl( $row ['bodytext'] );
  94. }
  95. else
  96. {
  97. $title = $alias = $bodytext = "";
  98. }
  99. }
  100. if ( ! empty( $bodytext ) ) $bodytext = nv_htmlspecialchars( $bodytext );
  101. if ( ! empty( $error ) )
  102. {
  103. $contents .= "<div class=\"quote\" style=\"width:780px;\">\n";
  104. $contents .= "<blockquote class=\"error\"><span>" . $error . "</span></blockquote>\n";
  105. $contents .= "</div>\n";
  106. $contents .= "<div class=\"clear\"></div>\n";
  107. }
  108. $contents .= "<form action=\"" . $action . "\" method=\"post\">\n";
  109. $contents .= "<input name=\"save\" type=\"hidden\" value=\"1\" />\n";
  110. $contents .= "<table summary=\"\" class=\"tab1\" style=\"margin-top:8px;margin-bottom:8px;\">\n";
  111. $contents .= "<col valign=\"top\" width=\"150px\" />\n";
  112. $contents .= "<tr>\n";
  113. $contents .= "<td>" . $lang_module ['aabout2'] . ":</td>\n";
  114. $contents .= "<td><input style=\"width:400px\" name=\"title\" id=\"idtitle\" type=\"text\" value=\"" . $title . "\" maxlength=\"255\" /></td>\n";
  115. $contents .= "</tr>\n";
  116. $contents .= "<tr>\n";
  117. $contents .= "<td>" . $lang_module ['alias'] . ":</td>\n";
  118. $contents .= "<td><input style=\"width:380px\" name=\"alias\" id=\"idalias\" type=\"text\" value=\"" . $alias . "\" maxlength=\"255\" />&nbsp;&nbsp;";
  119. $contents .= " <img src=\"" . NV_BASE_SITEURL . "images/refresh.png\" width=\"16\" style=\"cursor: pointer; vertical-align: middle;\" onclick=\"get_alias(" . $id . ");\" alt=\"\" height=\"16\" />\n";
  120. $contents .= "</td>\n";
  121. $contents .= "</tr>\n";
  122. $contents .= "<tr>\n";
  123. $contents .= "<td colspan=\"2\">" . $lang_module ['aabout11'] . ":</td>\n";
  124. $contents .= "</tr>\n";
  125. $contents .= "<tr>\n";
  126. $contents .= "<td colspan=\"2\">\n";
  127. if ( defined( 'NV_EDITOR' ) and nv_function_exists( 'nv_aleditor' ) )
  128. {
  129. $contents .= nv_aleditor( "bodytext", '100%', '300px', $bodytext );
  130. }
  131. else
  132. {
  133. $contents .= "<textarea style=\"width:100%;height:300px\" name=\"bodytext\" id=\"bodytext\">" . $bodytext . "</textarea>";
  134. }
  135. $contents .= "</td>\n";
  136. $contents .= "</tr>\n";
  137. $contents .= "</table>\n";
  138. $contents .= "<br />\n";
  139. $contents .= "<div style=\"text-align:center\"><input name=\"submit1\" type=\"submit\" value=\"" . $lang_module ['save'] . "\" /></div>\n";
  140. $contents .= "</form>\n";
  141. $contents .= "<script type=\"text/javascript\">\n";
  142. if ( empty( $alias ) )
  143. {
  144. $contents .= '$("#idtitle").change(function () {
  145. get_alias(' . $id . ');
  146. });';
  147. }
  148. $contents .= "</script>";
  149. include ( NV_ROOTDIR . "/includes/header.php" );
  150. echo nv_admin_theme( $contents );
  151. include ( NV_ROOTDIR . "/includes/footer.php" );
  152. ?>