Просмотр файла modules/user/edit.php

Размер файла: 4.12Kb
  1. <?
  2. /**********************************
  3. * @package: PerfCMS *
  4. * @year: 2012 *
  5. * @author: Artas *
  6. * @link: http://perfcms.pp.ua *
  7. **********************************/
  8. if(isset($user)) {
  9. if(isset($_POST['save']) && $_GET['act']== 'save') {
  10. $name = substr(input($_POST['name']), 0, 35);
  11. $surname = substr(input($_POST['surname']), 0, 35);
  12. $day = abs(intval($_POST['day']));
  13. $month = abs(intval($_POST['month']));
  14. $year = abs(intval($_POST['year']));
  15. $device = substr(input($_POST['device']), 0, 65);
  16. $icq = substr(abs(intval($_POST['icq'])), 0, 9);
  17. $gender = abs(intval($_POST['gender']));
  18. $city = substr(input($_POST['city']), 0, 65);
  19. $country = substr(input($_POST['country']), 0, 55);
  20. $site = substr(input($_POST['site']), 0, 40);
  21. $about_me = substr(input($_POST['about_me']), 0, 1000);
  22. $db->query("UPDATE `users` SET `name` = '". $name."', `surname` = '". $surname."', `day` = '". $day."', `month` = '". $month."', `year` = '". $year."', `device` = '". $device."', `icq` = '". $icq."', `city` = '". $city."', `country` = '". $country."', `site` = '". $site."', `gender` = '". $gender."', `info` = '". $about_me."' WHERE `id` = '".$user['id'] ."'");
  23. // print_r($db->errorInfo());
  24. go('/user/edit/?act=edited');
  25. }
  26. $locate = 'in_edit';
  27. $title = $lang->word('edit_profile');
  28. require_once(SYS.'/view/header.php');
  29. if($_GET['act']=='edited') {$tpl->div('block', $lang->word('succ_save'));}
  30. $tpl->div('title', $lang->word('edit_profile'));
  31. echo '<div class="post">
  32. <form action="?act=save" method="post">
  33. <b>'. $lang->word('name') .'</b>: <br/>
  34. <input type="text" name="name" value="'. $user['name'] .'" /><br/>
  35. <b>'. $lang->word('surname') .'</b>: <br/>
  36. <input type="text" name="surname" value="'. $user['surname'] .'" /><br/>
  37. <b>'. $lang->word('birth') .'</b>: <br/>
  38. <select name="day">
  39. <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
  40. for($d = 1; $d<=31; $d++) {
  41. echo "<option value=\"". $d ."\" ".($user['day'] == $d ? 'selected=\"selected\"' : NULL).">". $d ."</option>\n";
  42. }
  43. echo '</select>
  44. <select name="month">
  45. <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
  46. for($m = 1; $m<=12; $m++) {
  47. echo "<option value=\"". $m ."\" ".($user['month'] == $m ? 'selected=\"selected\"' : NULL).">". $m ."</option>\n";
  48. }
  49. echo '</select>
  50. <select name="year">
  51. <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
  52. for($y = 1960; $y<=(date('Y')-1); $y++) {
  53. echo "<option value=\"". $y ."\" ".($user['year'] == $y ? 'selected=\"selected\"' : NULL).">". $y ."</option>\n";
  54. }
  55. echo '</select><br/>
  56. <b>'. $lang->word('gender') .'</b>: <br/>
  57. <select name="gender">
  58. <option value="0" '.($user['gender'] == '0' ? 'selected="selected"' : NULL).'>'. $lang->word('unknown') .'</option>
  59. <option value="1" '.($user['gender'] == '1' ? 'selected="selected"' : NULL).'>'. $lang->word('male') .'</option>
  60. <option value="2" '.($user['gender'] == '2' ? 'selected="selected"' : NULL).'>'. $lang->word('female') .'</option>
  61. </select><br/>
  62. <b>'. $lang->word('device') .'</b>: <br/>
  63. <input type="text" name="device" value="'. $user['device'] .'" /><br/>
  64. <b>ICQ</b>: <br/>
  65. <input type="text" name="icq" value="'. $user['icq'] .'" /><br/>
  66. <b>'. $lang->word('city') .'</b>: <br/>
  67. <input type="text" name="city" value="'. $user['city'] .'" /><br/>
  68. <b>'. $lang->word('country') .'</b>: <br/>
  69. <input type="text" name="country" value="'. $user['country'] .'" /><br/>
  70. <b>'. $lang->word('site') .'</b>: <br/>
  71. <input type="text" name="site" value="'. (empty($user['site']) ? 'http://' : $user['site']).'" /><br/>
  72. <b>'. $lang->word('about_me') .'</b>: <br/>
  73. <textarea rows="5" cols="30" name="about_me">'. $user['info'] .'</textarea><br/>
  74. <input name="save" type="submit" value="'. $lang->word('save') .'" />
  75. </form>
  76. </div>
  77. ';
  78. $tpl->div('block', NAV.'<a href="/user/panel/">'.$lang->word('user_panel').'</a><br/>'. HICO .'<a href="/">'. $lang->word('home') .'</a>');
  79. require_once(SYS.'/view/footer.php');
  80. } else { go('/'); }
  81. ?>