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

/siteadmin/profile.php

http://pacercms.googlecode.com/
PHP | 216 lines | 197 code | 15 blank | 4 comment | 15 complexity | 06187a05224370f64cd6c8850d09a305 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. // Loads everything needed to run PacerCMS
  3. include('cm-includes/cm-header.php');
  4. // Declare the current module
  5. $module = "profile";
  6. $mode = "edit"; // Locked.
  7. $id = $_SESSION['user_data']['id']; // Locked.
  8. // SECURITY - User must be authenticated to view page //
  9. cm_auth_module($module);
  10. // If posted, call edit function
  11. if ($_GET['action'] == "edit")
  12. {
  13. $user['login'] = $_POST['login'];
  14. $user['password'] = $_POST['password'];
  15. $user['first_name'] = prep_string($_POST['first_name']);
  16. $user['middle_name'] = prep_string($_POST['middle_name']);
  17. $user['last_name'] = prep_string($_POST['last_name']);
  18. $user['job_title'] = prep_string($_POST['job_title']);
  19. $user['email'] = prep_string($_POST['email']);
  20. $user['telephone'] = prep_string($_POST['telephone']);
  21. $user['mobile'] = prep_string($_POST['mobile']);
  22. $user['classification'] = prep_string($_POST['classification']);
  23. $user['address'] = prep_string($_POST['address']);
  24. $user['city'] = prep_string($_POST['city']);
  25. $user['state'] = prep_string($_POST['state']);
  26. $user['zipcode'] = prep_string($_POST['zipcode']);
  27. $user['im_aol'] = prep_string($_POST['im_aol']);
  28. $user['im_msn'] = prep_string($_POST['im_msn']);
  29. $user['im_yahoo'] = prep_string($_POST['im_yahoo']);
  30. $user['im_jabber'] = prep_string($_POST['im_jabber']);
  31. $user['profile'] = prep_string($_POST['profile']);
  32. $password_new = $_POST['password_new'];
  33. $password_confirm = $_POST['password_confirm'];
  34. if ($password_new == "$password_confirm" && !empty($password_new)) {
  35. $user['password'] = md5($password_new);
  36. }
  37. if ($password_new != "$password_confirm") {
  38. cm_error(gettext("Passwords did not match."));
  39. exit;
  40. }
  41. $stat = cm_edit_profile($user);
  42. if ($stat) {
  43. header("Location: $module.php?msg=updated");
  44. exit;
  45. } else {
  46. cm_error(gettext("Error in 'cm_edit_profile' function."));
  47. exit;
  48. }
  49. }
  50. $query = "SELECT * FROM cm_users WHERE id = $id; ";
  51. $result = cm_run_query($query);
  52. if ($result->RecordCount() != 1)
  53. {
  54. cm_error(gettext("User does not exist."));
  55. }
  56. $id = $result->Fields('id');
  57. $login = $result->Fields('user_login');
  58. $password = $result->Fields('user_password');
  59. $first_name = $result->Fields('user_first_name');
  60. $middle_name = $result->Fields('user_middle_name');
  61. $last_name = $result->Fields('user_last_name');
  62. $job_title = $result->Fields('user_job_title');
  63. $email = $result->Fields('user_email');
  64. $telephone = $result->Fields('user_telephone');
  65. $mobile = $result->Fields('user_mobile');
  66. $address = $result->Fields('user_address');
  67. $city = $result->Fields('user_city');
  68. $state = $result->Fields('user_state');
  69. $zipcode = $result->Fields('user_zipcode');
  70. $im_aol = $result->Fields('user_im_aol');
  71. $im_msn = $result->Fields('user_im_msn');
  72. $im_yahoo = $result->Fields('user_im_yahoo');
  73. $im_jabber = $result->Fields('user_im_jabber');
  74. $profile = $result->Fields('user_profile');
  75. get_cm_header();
  76. ?>
  77. <h2>User Profile</h2>
  78. <?php
  79. $msg = $_GET['msg'];
  80. if ($msg == "updated") {
  81. echo "<p class=\"infoMessage\">" . gettext("Your user profile has been updated.") . "</p>";
  82. } else {
  83. echo "<p class=\"alertMessage\">" . gettext("You cannot change your name or job title. Please contact an administrator to correct any errors.") . "</p>";
  84. }
  85. ?>
  86. <form action="<?php echo "$module.php?action=$mode"; ?>" method="post">
  87. <fieldset class="<?php echo "$module-form"; ?>">
  88. <legend><?php echo gettext("Basic Profile"); ?></legend>
  89. <div class="sidebar">
  90. <p><strong><?php echo gettext("Passwords must match."); ?></strong></p>
  91. <p style="width:200px;"><?php echo gettext("It is recommended that your password be longer than 6 characters, and a mix of letters and numbers."); ?></p>
  92. <p>
  93. <label for="password_new"><?php echo gettext("Password"); ?></label>
  94. <br />
  95. <input type="password" name="password_new" id="password_new" />
  96. </p>
  97. <p>
  98. <label for="password_confirm"><?php echo gettext("Confirm Password"); ?></label>
  99. <br />
  100. <input type="password" name="password_confirm" id="password_confirm" />
  101. </p>
  102. <p style="width:200px;"><em><?php echo gettext("Leave blank if you do not wish to change your password."); ?></em></p>
  103. </div>
  104. <p>
  105. <label for="first_name"><?php echo gettext("First Name"); ?></label>
  106. <br />
  107. <big><?php echo $first_name; ?>&nbsp;</big>
  108. </p>
  109. <p>
  110. <label for="middle_name"><?php echo gettext("Middle Name"); ?></label>
  111. <br />
  112. <big><?php echo $middle_name; ?>&nbsp;</big>
  113. </p>
  114. <p>
  115. <label for="last_name"><?php echo gettext("Last Name"); ?></label>
  116. <br />
  117. <big><?php echo $last_name; ?></big>&nbsp;
  118. </p>
  119. <p>
  120. <label for="job_title"><?php echo gettext("Job Title"); ?></label>
  121. <br />
  122. <big><?php echo $job_title; ?></big>&nbsp;
  123. </p>
  124. </fieldset>
  125. <fieldset class="<?php echo "$module-form"; ?>">
  126. <legend><?php echo gettext("Contact Information"); ?></legend>
  127. <div class="sidebar">
  128. <p><?php echo gettext("Internet Messengers"); ?></p>
  129. <p>
  130. <label for="im_aol"><?php echo gettext("AOL Instant Messenger"); ?></label>
  131. <br />
  132. <input type="text" name="im_aol" id="im_aol" value="<?php echo $im_aol; ?>" />
  133. </p>
  134. <p>
  135. <label for="im_msn"><?php echo gettext("Microsoft Messenger"); ?></label>
  136. <br />
  137. <input type="text" name="im_msn" id="im_msn" value="<?php echo $im_msn; ?>" />
  138. </p>
  139. <p>
  140. <label for="im_yahoo"><?php echo gettext("Yahoo! Messenger"); ?></label>
  141. <br />
  142. <input type="text" name="im_yahoo" id="im_yahoo" value="<?php echo $im_yahoo; ?>" />
  143. </p>
  144. <p>
  145. <label for="im_jabber"><?php echo gettext("Jabber Services"); ?></label>
  146. <br />
  147. <input type="text" name="im_jabber" id="im_jabber" value="<?php echo $im_jabber; ?>" />
  148. </p>
  149. </div>
  150. <p>
  151. <label for="email"><?php echo gettext("E-mail"); ?></label>
  152. <br />
  153. <input type="text" name="email" id="email" value="<?php echo $email; ?>" class="text" />
  154. </p>
  155. <p>
  156. <label for="telephone"><?php echo gettext("Telephone (Local)"); ?></label>
  157. <br />
  158. <input type="text" name="telephone" id="telephone" value="<?php echo $telephone; ?>" class="text" />
  159. </p>
  160. <p>
  161. <label for="mobile"><?php echo gettext("Mobile"); ?></label>
  162. <br />
  163. <input type="text" name="mobile" id="mobile" value="<?php echo $mobile; ?>" class="text" />
  164. </p>
  165. <p>
  166. <label for="address"><?php echo gettext("Address"); ?></label>
  167. <br />
  168. <input type="text" name="address" id="address" value="<?php echo $address; ?>" class="text" />
  169. </p>
  170. <p>
  171. <label for="City"><?php echo gettext("City"); ?></label>
  172. <br />
  173. <input type="text" name="city" id="city" value="<?php echo $city; ?>" class="text" />
  174. </p>
  175. <p>
  176. <label for="state"><?php echo gettext("State"); ?></label>
  177. <br />
  178. <input type="text" name="state" id="state" value="<?php echo $state; ?>" class="text" />
  179. </p>
  180. <p>
  181. <label for="zipcode"><?php echo gettext("Zip Code"); ?></label>
  182. <br />
  183. <input type="text" name="zipcode" id="zipcode" value="<?php echo $zipcode; ?>" class="text" />
  184. </p>
  185. </fieldset>
  186. <fieldset class="<?php echo "$module-form"; ?>">
  187. <legend><?php echo gettext("Additional Information"); ?></legend>
  188. <p>
  189. <label for="profile"><?php echo gettext("Profile"); ?></label>
  190. <br />
  191. <textarea name="profile" id="profile" rows="10"><?php echo $profile; ?></textarea>
  192. </p>
  193. <p>
  194. <input type="submit" value="<?php echo gettext("Update Profile"); ?>" name="update" id="update" class="button" />
  195. <input type="hidden" name="login" id="login" value="<?php echo $login; ?>" />
  196. <input type="hidden" name="password" id="password" value="<?php echo $password; ?>" />
  197. <input type="button" value="<?php echo gettext("Cancel"); ?>" name="cancel_modify" id="cancel_modify" class="button" onClick="javascript:history.back();" />
  198. </p>
  199. </fieldset>
  200. </form>
  201. <?php get_cm_footer(); ?>