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

Размер файла: 4.14Kb
  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 = substr(abs(intval($_POST['day'])), 0, 2);
  13. $month = substr(abs(intval($_POST['month'])), 0, 2);
  14. $year = substr(abs(intval($_POST['year'])), 0, 4);
  15. $device = substr(input($_POST['device']), 0, 65);
  16. $icq = substr(abs(intval($_POST['icq'])), 0, 9);
  17. $gender = ($_POST['gender'] == 1 || $_POST['gender'] == 2 ? abs(intval($_POST['gender'])) : 1);
  18. $city = substr(input($_POST['city']), 0, 65);
  19. $country = substr(input($_POST['country']), 0, 55);
  20. $site1 = substr(input($_POST['site']), 0, 40);
  21. $site = str_replace('http://', '', $site1);
  22. $about_me = substr(input($_POST['about_me']), 0, 1000);
  23. $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'] ."'");
  24. // print_r($db->errorInfo());
  25. go('/user/edit/?act=edited');
  26. }
  27. $locate = 'in_edit';
  28. $title = $lang->word('edit_profile');
  29. require_once(SYS.'/view/header.php');
  30. if($_GET['act']=='edited') {$tpl->div('block', $lang->word('succ_save'));}
  31. $tpl->div('title', $lang->word('edit_profile'));
  32. echo '<div class="post">
  33. <form action="?act=save" method="post">
  34. <b>'. $lang->word('name') .'</b>: <br/>
  35. <input type="text" name="name" value="'. $user['name'] .'" /><br/>
  36. <b>'. $lang->word('surname') .'</b>: <br/>
  37. <input type="text" name="surname" value="'. $user['surname'] .'" /><br/>
  38. <b>'. $lang->word('birth') .'</b>: <br/>
  39. <select name="day">
  40. <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
  41. for($d = 1; $d<=31; $d++) {
  42. echo "<option value=\"". $d ."\" ".($user['day'] == $d ? 'selected=\"selected\"' : NULL).">". $d ."</option>\n";
  43. }
  44. echo '</select>
  45. <select name="month">
  46. <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
  47. for($m = 1; $m<=12; $m++) {
  48. echo "<option value=\"". $m ."\" ".($user['month'] == $m ? 'selected=\"selected\"' : NULL).">". $m ."</option>\n";
  49. }
  50. echo '</select>
  51. <select name="year">
  52. <option value="0" '.($user['day'] == '0' ? 'selected="selected"' : NULL).'>0</option>';
  53. for($y = 1960; $y<=(date('Y')-1); $y++) {
  54. echo "<option value=\"". $y ."\" ".($user['year'] == $y ? 'selected=\"selected\"' : NULL).">". $y ."</option>\n";
  55. }
  56. echo '</select><br/>
  57. <b>'. $lang->word('gender') .'</b>: <br/>
  58. <select name="gender">
  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. ?>