1
0

add_subuser-exec.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. //Open Game Panel Subusers Addon By
  25. // OwN-3m-All
  26. require_once("includes/functions.php");
  27. function exec_ogp_module()
  28. {
  29. global $db,$view;
  30. $errmsg_arr = array();
  31. //Array to store input values
  32. $input = array();
  33. //Validation error flag
  34. $errflag = false;
  35. //Function to sanitize values received from the form. Prevents SQL injection
  36. function clean($str) {
  37. $str = @trim($str);
  38. if(get_magic_quotes_gpc_wrapper()) {
  39. $str = stripslashes($str);
  40. }
  41. return $str;
  42. }
  43. //Sanitize the POST values
  44. $users_login = sanitizeInputStr($_POST['users_login']);
  45. $users_passwd = clean($_POST['users_passwd']);
  46. $users_cpasswd = clean($_POST['users_cpasswd']);
  47. $parent_user = clean($_SESSION['user_id']);
  48. if( !empty($users_login) ) {
  49. $input['users_login'] = $users_login;
  50. }
  51. //Input Validations
  52. if($users_login == '') {
  53. $errmsg_arr[] = get_lang('err_login_name');
  54. $errflag = true;
  55. }
  56. if($users_passwd == '') {
  57. $errmsg_arr[] = get_lang('err_password');
  58. $errflag = true;
  59. }
  60. if($users_cpasswd == '') {
  61. $errmsg_arr[] = get_lang('err_confirm_password');
  62. $errflag = true;
  63. }
  64. if( strcmp($users_passwd, $users_cpasswd) != 0 ) {
  65. $errmsg_arr[] = get_lang('err_password_mismatch');
  66. $errflag = true;
  67. }
  68. if(empty($parent_user)){
  69. $errmsg_arr[] = get_lang('err_parent_user');
  70. $errflag = true;
  71. }
  72. //Create INSERT query
  73. if( !$errflag )
  74. {
  75. if(!$db->addUser($users_login,$users_passwd,"subuser",NULL,$parent_user))
  76. {
  77. $errmsg_arr[] = get_lang('err_login_name');
  78. $errflag = true;
  79. }
  80. echo "<p>" . get_lang_f('subuser_added',$users_login) . "</p>";
  81. $view->refresh("?m=subusers&p=submanage", 5);
  82. }
  83. //If there are input validations, redirect back to the registration form
  84. if($errflag) {
  85. $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
  86. $_SESSION['INPUT'] = $input;
  87. $view->refresh("home.php?m=subusers&p=add",0);
  88. }
  89. }
  90. ?>