PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 222 lines | 178 code | 36 blank | 8 comment | 20 complexity | 3b9de9db2be43e7339e57ab1c61b4ecf MD5 | raw file
  1. <?php
  2. /**
  3. * @Project NUKEVIET CMS 3.0
  4. * @Author VINADES (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES. All rights reserved
  6. * @Createdate 04/05/2010
  7. */
  8. if ( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' );
  9. //Xoa thanh vien
  10. if ( $nv_Request->isset_request( 'del', 'post' ) )
  11. {
  12. $userid = $nv_Request->get_int( 'userid', 'post', 0 );
  13. $sql = "DELETE FROM `" . NV_USERS_GLOBALTABLE . "_reg` WHERE `userid`=" . $userid;
  14. $result = $db->sql_query( $sql );
  15. if ( ! $result )
  16. {
  17. die( "NO" );
  18. }
  19. die( "OK" );
  20. }
  21. //Kich hoat thanh vien
  22. if ( $nv_Request->isset_request( 'act', 'get' ) )
  23. {
  24. $userid = $nv_Request->get_int( 'userid', 'get', 0 );
  25. if ( ! $userid )
  26. {
  27. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  28. die();
  29. }
  30. $sql = "SELECT * FROM `" . NV_USERS_GLOBALTABLE . "_reg` WHERE `userid`=" . $userid;
  31. $result = $db->sql_query( $sql );
  32. $numrows = $db->sql_numrows( $result );
  33. if ( $numrows != 1 )
  34. {
  35. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  36. die();
  37. }
  38. $row = $db->sql_fetchrow( $result );
  39. $sql = "INSERT INTO `" . NV_USERS_GLOBALTABLE . "` (
  40. `userid`, `username`, `md5username`, `password`, `email`, `full_name`, `gender`, `photo`, `birthday`,
  41. `regdate`, `website`, `location`, `yim`, `telephone`, `fax`, `mobile`, `question`,
  42. `answer`, `passlostkey`, `view_mail`, `remember`, `in_groups`, `active`, `checknum`,
  43. `last_login`, `last_ip`, `last_agent`, `last_openid`
  44. ) VALUES (
  45. NULL,
  46. " . $db->dbescape( $row['username'] ) . ",
  47. " . $db->dbescape( md5( $row['username'] ) ) . ",
  48. " . $db->dbescape( $row['password'] ) . ",
  49. " . $db->dbescape( $row['email'] ) . ",
  50. " . $db->dbescape( $row['full_name'] ) . ",
  51. '', '', 0, " . $row['regdate'] . ", '', '', '', '', '', '',
  52. " . $db->dbescape( $row['question'] ) . ",
  53. " . $db->dbescape( $row['answer'] ) . ",
  54. '', 0, 0, '', 1, '', 0, '', '', '')";
  55. $userid = $db->sql_query_insert_id( $sql );
  56. if ( $userid )
  57. {
  58. $db->sql_query( "DELETE FROM `" . NV_USERS_GLOBALTABLE . "_reg` WHERE `userid`=" . $row['userid'] );
  59. $full_name = ( ! empty( $row['full_name'] ) ) ? $row['full_name'] : $row['username'];
  60. $subject = $lang_module['adduser_register'];
  61. $message = sprintf( $lang_module['adduser_register_info'], $full_name, $global_config['site_name'], NV_MY_DOMAIN . NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name, $row['username'] );
  62. $message .= "<br /><br />------------------------------------------------<br /><br />";
  63. $message .= nv_EncString( $message );
  64. @nv_sendmail( $global_config['site_email'], $row['email'], $subject, $message );
  65. }
  66. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=user_waiting" );
  67. die();
  68. }
  69. $page_title = $table_caption = $lang_module['member_wating'];
  70. $sql = "FROM `" . NV_USERS_GLOBALTABLE . "_reg`";
  71. $base_url = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting";
  72. $methods = array( //
  73. 'userid' => array(
  74. 'key' => 'userid', 'value' => $lang_module['search_id'], 'selected' => ''
  75. ), //
  76. 'username' => array(
  77. 'key' => 'username', 'value' => $lang_module['search_account'], 'selected' => ''
  78. ), //
  79. 'full_name' => array(
  80. 'key' => 'full_name', 'value' => $lang_module['search_name'], 'selected' => ''
  81. ), //
  82. 'email' => array(
  83. 'key' => 'email', 'value' => $lang_module['search_mail'], 'selected' => ''
  84. ) //
  85. );
  86. $method = $nv_Request->isset_request( 'method', 'post' ) ? $nv_Request->get_string( 'method', 'post', '' ) : ( $nv_Request->isset_request( 'method', 'get' ) ? urldecode( $nv_Request->get_string( 'method', 'get', '' ) ) : '' );
  87. $methodvalue = $nv_Request->isset_request( 'value', 'post' ) ? $nv_Request->get_string( 'value', 'post' ) : ( $nv_Request->isset_request( 'value', 'get' ) ? urldecode( $nv_Request->get_string( 'value', 'get', '' ) ) : '' );
  88. $orders = array(
  89. 'userid', 'username', 'full_name', 'email', 'regdate'
  90. );
  91. $orderby = $nv_Request->get_string( 'sortby', 'get', '' );
  92. $ordertype = $nv_Request->get_string( 'sorttype', 'get', '' );
  93. if ( $ordertype != "ASC" ) $ordertype = "DESC";
  94. if ( ! empty( $method ) and isset( $methods[$method] ) and ! empty( $methodvalue ) )
  95. {
  96. $sql .= " WHERE `" . $method . "` LIKE '%" . $db->dblikeescape( $methodvalue ) . "%'";
  97. $base_url .= "&amp;method=" . urlencode( $method ) . "&amp;value=" . urlencode( $methodvalue );
  98. $methods[$method]['selected'] = " selected=\"selected\"";
  99. $table_caption = $lang_module['search_page_title'];
  100. }
  101. if ( ! empty( $orderby ) and in_array( $orderby, $orders ) )
  102. {
  103. $sql .= " ORDER BY `" . $orderby . "` " . $ordertype;
  104. $base_url .= "&amp;sortby=" . $orderby . "&amp;sorttype=" . $ordertype;
  105. }
  106. $page = $nv_Request->get_int( 'page', 'get', 0 );
  107. $per_page = 30;
  108. $sql2 = "SELECT SQL_CALC_FOUND_ROWS * " . $sql . " LIMIT " . $page . ", " . $per_page;
  109. $query2 = $db->sql_query( $sql2 );
  110. $result_all = $db->sql_query( "SELECT FOUND_ROWS()" );
  111. list( $numf ) = $db->sql_fetchrow( $result_all );
  112. $all_page = ( $numf ) ? $numf : 1;
  113. $users_list = array();
  114. while ( $row = $db->sql_fetchrow( $query2 ) )
  115. {
  116. $users_list[$row['userid']] = array( //
  117. 'userid' => ( int )$row['userid'], //
  118. 'username' => ( string )$row['username'], //
  119. 'full_name' => ( string )$row['full_name'], //
  120. 'email' => ( string )$row['email'], //
  121. 'regdate' => date( "d/m/Y H:i", $row['regdate'] ) //
  122. );
  123. }
  124. $generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page );
  125. $head_tds = array();
  126. $head_tds['userid']['title'] = $lang_module['userid'];
  127. $head_tds['userid']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;sortby=userid&amp;sorttype=ASC";
  128. $head_tds['username']['title'] = $lang_module['account'];
  129. $head_tds['username']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;sortby=username&amp;sorttype=ASC";
  130. $head_tds['full_name']['title'] = $lang_module['name'];
  131. $head_tds['full_name']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;sortby=full_name&amp;sorttype=ASC";
  132. $head_tds['email']['title'] = $lang_module['email'];
  133. $head_tds['email']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;sortby=email&amp;sorttype=ASC";
  134. $head_tds['regdate']['title'] = $lang_module['register_date'];
  135. $head_tds['regdate']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;sortby=regdate&amp;sorttype=ASC";
  136. foreach ( $orders as $order )
  137. {
  138. if ( $orderby == $order and $ordertype == 'ASC' )
  139. {
  140. $head_tds[$order]['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;sortby=" . $order . "&amp;sorttype=DESC";
  141. $head_tds[$order]['title'] .= " &darr;";
  142. }
  143. elseif ( $orderby == $order and $ordertype == 'DESC' )
  144. {
  145. $head_tds[$order]['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;sortby=" . $order . "&amp;sorttype=ASC";
  146. $head_tds[$order]['title'] .= " &uarr;";
  147. }
  148. }
  149. $xtpl = new XTemplate( "user_waitting.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
  150. $xtpl->assign( 'LANG', $lang_module );
  151. $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting" );
  152. $xtpl->assign( 'SORTURL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  153. $xtpl->assign( 'SEARCH_VALUE', $methodvalue );
  154. $xtpl->assign( 'TABLE_CAPTION', $table_caption );
  155. if ( defined( 'NV_IS_USER_FORUM' ) )
  156. {
  157. $xtpl->parse( 'main.is_forum' );
  158. }
  159. foreach ( $methods as $m )
  160. {
  161. $xtpl->assign( 'METHODS', $m );
  162. $xtpl->parse( 'main.method' );
  163. }
  164. foreach ( $head_tds as $head_td )
  165. {
  166. $xtpl->assign( 'HEAD_TD', $head_td );
  167. $xtpl->parse( 'main.head_td' );
  168. }
  169. foreach ( $users_list as $u )
  170. {
  171. $xtpl->assign( 'CONTENT_TD', $u );
  172. $xtpl->assign( 'ACTIVATE_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;act=1&amp;userid=" . $u['userid'] );
  173. $xtpl->assign( 'EDIT_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=user_waiting&amp;del&amp;userid=" . $u['userid'] );
  174. $xtpl->parse( 'main.xusers' );
  175. }
  176. if ( ! empty( $generate_page ) )
  177. {
  178. $xtpl->assign( 'GENERATE_PAGE', $generate_page );
  179. $xtpl->parse( 'main.generate_page' );
  180. }
  181. $xtpl->parse( 'main' );
  182. $contents = $xtpl->text( 'main' );
  183. include ( NV_ROOTDIR . "/includes/header.php" );
  184. echo nv_admin_theme( $contents );
  185. include ( NV_ROOTDIR . "/includes/footer.php" );
  186. ?>