PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/gforge/www/account/index.php

https://github.com/mathieu/fusionforge
PHP | 294 lines | 201 code | 48 blank | 45 comment | 24 complexity | 72b0cbd2d4c5ca3e9ca330b1348a9dbe MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-2.0
  1. <?php
  2. /**
  3. * User account main page - show settings with means to change them
  4. *
  5. * Copyright 1999-2001 (c) VA Linux Systems
  6. *
  7. * @version $Id$
  8. *
  9. * This file is part of GForge.
  10. *
  11. * GForge is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * GForge is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with GForge; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. require_once('../env.inc.php');
  26. require_once $gfwww.'include/pre.php';
  27. require_once $gfcommon.'include/timezones.php';
  28. $feedback = '';
  29. if (!session_loggedin()) {
  30. exit_not_logged_in();
  31. }
  32. // get global users vars
  33. $u =& user_get_object(user_getid());
  34. if (!$u || !is_object($u)) {
  35. exit_error('Error','Could Not Get User');
  36. } elseif ($u->isError()) {
  37. exit_error('Error',$u->getErrorMessage());
  38. }
  39. if (getStringFromRequest('submit')) {
  40. if (!form_key_is_valid(getStringFromRequest('form_key'))) {
  41. exit_form_double_submit();
  42. }
  43. $firstname = getStringFromRequest('firstname');
  44. $lastname = getStringFromRequest('lastname');
  45. $language = getIntFromRequest('language');
  46. $timezone = getStringFromRequest('timezone');
  47. $theme_id = getIntFromRequest('theme_id');
  48. $ccode = getStringFromRequest('ccode');
  49. $address = getStringFromRequest('address');
  50. $address2 = getStringFromRequest('address2');
  51. $phone = getStringFromRequest('phone');
  52. $fax = getStringFromRequest('fax');
  53. $title = getStringFromRequest('title');
  54. $jabber_address = getStringFromRequest('jabber');
  55. $jabber_only = getStringFromRequest('jabber');
  56. $mail_site = getStringFromRequest('mail_site');
  57. $mail_va = getStringFromRequest('mail_va');
  58. $remember_user = getStringFromRequest('remember_user');
  59. $use_ratings = getStringFromRequest('use_ratings');
  60. /*
  61. //needs security audit
  62. if ($remember_user) {
  63. // set cookie, expire in 3 months
  64. setcookie("sf_user_hash",$u->getID().'_'.substr($u->getMD5Passwd(),0,16),time()+90*24*60*60,'/');
  65. } else {
  66. // remove cookie
  67. setcookie("sf_user_hash",'',0,'/');
  68. }
  69. */
  70. // Refresh page if language or theme changed
  71. $refresh = ($language != $u->getLanguage() || $theme_id != $u->getThemeID());
  72. if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, $use_ratings,
  73. $jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode)) {
  74. form_release_key(getStringFromRequest('form_key'));
  75. $feedback .= $u->getErrorMessage().'<br />';
  76. } else {
  77. $feedback .= _('Updated').'<br />';
  78. }
  79. if ($refresh) {
  80. session_redirect("/account/?feedback=".urlencode($feedback));
  81. }
  82. }
  83. site_user_header(array('title'=>_('Account Maintenance')));
  84. echo '<form action="'.getStringFromServer('PHP_SELF').'" method="post">';
  85. echo '<input type="hidden" name="form_key" value="'.form_generate_key().'"/>';
  86. echo $HTML->boxTop(_('Account Maintenance'));
  87. ?>
  88. <p> <?php echo _('Welcome'); ?> <strong><?php print $u->getRealName(); ?></strong>. </p>
  89. <p>
  90. <?php echo _('Account options:'); ?>
  91. </p>
  92. <ul>
  93. <li><?php echo util_make_link_u ($u->getUnixName(),$u->getId(),'<strong>'._('View My Developer Profile').'</strong>'); ?></a></li>
  94. <?php if($GLOBALS['sys_use_people']) { ?>
  95. <li><?php echo util_make_link ('/people/editprofile.php','<strong>'._('Edit My Skills Profile').'</strong>'); ?></a></li>
  96. <?php } ?>
  97. </ul>
  98. <?php echo $HTML->boxBottom(); ?>
  99. &nbsp;<br />
  100. <table width="100%" border="0">
  101. <tr valign="top">
  102. <td><?php echo _('Member since:'); ?> </td>
  103. <td><strong><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></strong></td>
  104. </tr>
  105. <tr valign="top">
  106. <td><?php echo _('User ID:'); ?> </td>
  107. <td><strong><?php print $u->getID(); ?></strong></td>
  108. </tr>
  109. <tr valign="top">
  110. <td><?php echo _('Login name:'); ?> </td>
  111. <td><strong><?php print $u->getUnixName(); ?></strong>
  112. <br /><a href="change_pw.php">[<?php echo _('Change Password'); ?>]</a></td>
  113. </tr>
  114. <tr valign="top">
  115. <td><?php echo _('First Name:'); ?></td>
  116. <td><input type="text" name="firstname" value="<?php print $u->getFirstName(); ?>" />
  117. </td>
  118. </tr>
  119. <tr valign="top">
  120. <td><?php echo _('Last Name:'); ?></td>
  121. <td><input type="text" name="lastname" value="<?php print $u->getLastName(); ?>" />
  122. </td>
  123. </tr>
  124. <tr valign="top">
  125. <td><?php echo _('Language:'); ?> </td>
  126. <td><?php echo html_get_language_popup ('language',$u->getLanguage()); ?>
  127. </td>
  128. </tr>
  129. <tr valign="top">
  130. <td><?php echo _('Timezone:'); ?> </td>
  131. <td><?php echo html_get_timezone_popup('timezone', $u->getTimeZone()); ?>
  132. </td>
  133. </tr>
  134. <tr valign="top">
  135. <td><?php echo _('Theme:'); ?> </td>
  136. <td><?php echo html_get_theme_popup('theme_id', $u->getThemeID()); ?>
  137. </td>
  138. </tr>
  139. <tr valign="top">
  140. <td><?php echo _('Country:'); ?> </td>
  141. <td><?php echo html_get_ccode_popup('ccode', $u->getCountryCode()); ?>
  142. </td>
  143. </tr>
  144. <tr valign="top">
  145. <td><?php echo _('Email Addr:'); ?> </td>
  146. <td><strong><?php print $u->getEmail(); ?></strong>
  147. <br /><a href="change_email.php">[<?php echo _('Change Email Addr'); ?>]</a>
  148. </td>
  149. </tr>
  150. <tr valign="top">
  151. <td><?php echo _('Address:'); ?></td>
  152. <td><input type="text" name="address" value="<?php echo $u->getAddress(); ?>" size="80"/></td>
  153. </tr>
  154. <tr valign="top">
  155. <td><?php echo _('Address:'); ?></td>
  156. <td><input type="text" name="address2" value="<?php echo $u->getAddress2(); ?>" size="80"/></td>
  157. </tr>
  158. <tr valign="top">
  159. <td><?php echo _('Phone:'); ?></td>
  160. <td><input type="text" name="phone" value="<?php echo $u->getPhone(); ?>" size="20"/></td>
  161. </tr>
  162. <tr valign="top">
  163. <td><?php echo _('FAX:'); ?></td>
  164. <td><input type="text" name="fax" value="<?php echo $u->getFax(); ?>" size="20"/></td>
  165. </tr>
  166. <tr valign="top">
  167. <td><?php echo _('Title:'); ?></td>
  168. <td><input type="text" name="title" value="<?php echo $u->getTitle(); ?>" size="10"/></td>
  169. </tr>
  170. <?php
  171. if ($sys_use_jabber) {
  172. echo '<tr valign="top">
  173. <td>'. _('Jabber Address:') .'</td>
  174. <td>
  175. <input size=30 type="text" name="jabber_address" value="'. $u->getJabberAddress() .'" /><p />
  176. <input type="checkbox" name="jabber_only" value="1" '.(($u->getJabberOnly()) ? 'checked="CHECKED"' : '' ).' />
  177. '._('Send auto-generated notices only to my Jabber address').'.
  178. </td></tr>';
  179. }
  180. ?>
  181. <tr>
  182. <td colspan="2">
  183. <?php
  184. // ############################# Preferences
  185. echo $HTML->boxTop(_('Preferences')); ?>
  186. <input type="checkbox" name="mail_site" value="1"<?php
  187. if ($u->getMailingsPrefs('site')) print " checked=\"checked\""; ?> />
  188. <?php echo _('Receive Email about Site Updates <i>(Very low traffic and includes security notices. Highly Recommended.)</i>'); ?>
  189. <p /><input type="checkbox" name="mail_va" value="1"<?php
  190. if ($u->getMailingsPrefs('va')) print " checked=\"checked\""; ?> />
  191. <?php echo _('Receive additional community mailings. <i>(Low traffic.)</i>'); ?>
  192. <?php /*
  193. <p /><input type="checkbox" name="remember_user" value="1"<?php
  194. if ($sf_user_hash) print " checked=\"checked\""; ?> />
  195. <?php printf(_('"Remember me". <i>(Allows to access your <a href="%s">personal page</a> without being logged in. You will still need to login explicitly before making any changes.)</i>'),util_make_url ('/my/'));
  196. */ ?>
  197. <p />
  198. <?php if ($sys_use_ratings) { ?>
  199. <input type="checkbox" name="use_ratings" value="1"<?php
  200. if ($u->usesRatings()) print ' checked="checked"'; ?> />
  201. <?php printf(_('Participate in peer ratings. <i>(Allows you to rate other users using several criteria as well as to be rated by others. More information is available on your <a href="%s">user page</a> if you have chosen to participate in ratings.)</i>'),util_make_url_u ($u->getUnixName(),$u->getId()));
  202. } ?>
  203. </td></tr>
  204. <?php
  205. $hookParams['user']= user_get_object(user_getid());
  206. if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
  207. plugin_hook("userisactivecheckboxpost", $hookParams);
  208. } else {
  209. plugin_hook("userisactivecheckbox", $hookParams);
  210. }
  211. ?>
  212. <tr><td>
  213. <?php echo $HTML->boxBottom();
  214. // ############################### Shell Account
  215. if (($u->getUnixStatus() == 'A') && ($sys_use_shell)) {
  216. echo $HTML->boxTop(_('Shell Account Information')."");
  217. print '&nbsp;
  218. <br />'._('Shell box').': <strong>'.$u->getUnixBox().'</strong>
  219. <br />'._('SSH Shared Authorized Keys').': <strong>';
  220. // get shared key count from db
  221. $expl_keys = explode("\n", $u->getAuthorizedKeys());
  222. if ($expl_keys[0]) {
  223. print (sizeof($expl_keys));
  224. } else {
  225. print '0';
  226. }
  227. print '</strong>';
  228. print '<br />' . util_make_link ("account/editsshkeys.php",_('Edit Keys')) ;
  229. echo $HTML->boxBottom();
  230. }
  231. ?>
  232. </td>
  233. </tr>
  234. </table>
  235. <div align="center">
  236. <input type="submit" name="submit" value="<?php echo _('Update'); ?>" />
  237. <input type="reset" name="reset" value="<?php echo _('Reset Changes'); ?>" />
  238. </div>
  239. </form>
  240. <?php
  241. site_user_footer(array());
  242. // Local Variables:
  243. // mode: php
  244. // c-file-style: "bsd"
  245. // End:
  246. ?>