Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

update_profile.php 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. require_once('config.php');
  3. //initialize php variables used in the form
  4. $current_password = "";
  5. $password = "";
  6. $password_confirm = "";
  7. $theme = "";
  8. $minecraft = "";
  9. $website = "";
  10. $profile_image = "";
  11. $quote = "";
  12. $about = "";
  13. $blog_title = "";
  14. $blog_description = "";
  15. $error = "";
  16. //check to see that the form has been submitted
  17. if(isset($_POST))
  18. {
  19. array_filter($_POST, 'trim_value'); // the data in $_POST is trimmed
  20. $postfilter = // set up the filters to be used with the trimmed post array
  21. array(
  22. 'website' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW),
  23. 'quote' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW),
  24. 'about' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => !FILTER_FLAG_STRIP_LOW),
  25. 'blog_title' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW),
  26. 'blog_desc' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => !FILTER_FLAG_STRIP_LOW)
  27. );
  28. $revised_post_array = filter_var_array($_POST, $postfilter); // must be referenced via a variable which is now an array that takes the place of $_POST[]
  29. //retrieve the $_POST variables
  30. $current_password = rawurldecode($_POST['current_password']);
  31. $password = rawurldecode($_POST['password']);
  32. $password_confirm = rawurldecode($_POST['password_confirm']);
  33. $theme = rawurldecode($_POST['theme']);
  34. //$minecraft = rawurldecode($revised_post_array['minecraft']);
  35. $website = rawurldecode($revised_post_array['website']);
  36. $quote = rawurldecode($revised_post_array['quote']);
  37. $about = rawurldecode($revised_post_array['about']);
  38. $blog_title = rawurldecode($revised_post_array['blog_title']);
  39. $blog_description = rawurldecode($revised_post_array['blog_desc']);
  40. //initialize variables for form validation
  41. $success = true;
  42. if($success && !$logged_in)
  43. {
  44. $error = "You must be logged in to update your profile.";
  45. $success = false;
  46. }
  47. if($success && strlen($quote) > 140)
  48. {
  49. $error = "The maximum length for your quote is 140 characters.";
  50. $success = false;
  51. }
  52. if($success && strlen($blog_title) > 50)
  53. {
  54. $error = "The maximum length for your blog title is 50 characters.";
  55. $success = false;
  56. }
  57. if($success && strlen($blog_description) > 140)
  58. {
  59. $error = "The maximum length for your blog description is 140 characters.";
  60. $success = false;
  61. }
  62. $change_password = false;
  63. if($success && $current_password)
  64. {
  65. //check to see if passwords match
  66. if($success && hashPassword($current_password, $CONF) != $user->hashedPassword)
  67. {
  68. $error = "Current Password does not match.";
  69. $success = false;
  70. }
  71. //check to see if passwords match
  72. if($success && !$password)
  73. {
  74. $error = "You need to specify a new password.";
  75. $success = false;
  76. }
  77. //check to see if passwords match
  78. if($success && $password != $password_confirm)
  79. {
  80. $error = "New Passwords do not match.";
  81. $success = false;
  82. }
  83. if($success)
  84. {
  85. $change_password = true;
  86. }
  87. }
  88. if(!array_key_exists($theme, $CONF['themes']))
  89. {
  90. $error = "Invalid Theme Choice.";
  91. $success = false;
  92. }
  93. if($success)
  94. {
  95. //prep the data for saving in a new user object
  96. if ($change_password)
  97. {
  98. $user->hashedPassword = hashPassword($password, $CONF); //encrypt the password for storage
  99. if (!$CONF['dev_env'])
  100. {
  101. $obBaseApp = new COM("hMailServer.Application");
  102. $obBaseApp->Connect();
  103. $obBaseApp->Authenticate($CONF['mail_admin_user'], $CONF['mail_admin_pass']);
  104. $domain = $obBaseApp->Domains->ItemByName($CONF['host']);
  105. $account = $domain->Accounts->ItemByAddress($user->username . "@" . $CONF['host']);
  106. $account->Password = $password;
  107. $account->Save();
  108. }
  109. }
  110. /*
  111. if ($minecraft != $user->minecraft_user)
  112. {
  113. // code to add/remove user from permissionsex
  114. // Connect to the server
  115. $r = new minecraftRcon($CONF['minecraft_server'], $CONF['rcon_port'], $CONF['rcon_pass']);
  116. // Authenticate, and if so, execute command(s)
  117. if ( $r->Auth() ) {
  118. $r->mcRconCommand('pex user '.$user->minecraft_user." group remove Member");
  119. $r->mcRconCommand('pex user '.$minecraft." group add Member");
  120. }
  121. }
  122. */
  123. $user->theme = $theme;
  124. //$user->minecraft_user = $minecraft;
  125. $user->website = $website;
  126. $user->quote = $quote;
  127. $user->about = $about;
  128. $user->blog_title = $blog_title;
  129. $user->blog_desc = $blog_description;
  130. //update the user in the database
  131. $user->save($db);
  132. unset($_POST);
  133. echo "true";
  134. }
  135. else
  136. {
  137. unset($_POST);
  138. echo $error;
  139. }
  140. }
  141. else
  142. {
  143. echo "$_POST is not set.";
  144. }
  145. ?>