Guest User

Untitled

a guest
Mar 4th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. <?php
  2.  
  3. ob_start();
  4.  
  5. include_once('modules/session.php');
  6.  
  7. Session::start();
  8.  
  9. include_once('modules/user.php');
  10.  
  11. include_once('modules/account.php');
  12.  
  13. include_once('modules/data_validation.php');
  14.  
  15. include_once('modules/database.php');
  16.  
  17. include_once('modules/error_codes.php');
  18.  
  19. include_once('modules/msg_codes.php');
  20.  
  21. include_once('config.php');
  22.  
  23. //error_reporting(1);
  24.  
  25. include_once('modules/template.php');
  26.  
  27. include_once('modules/most_interesting_topics.php');
  28.  
  29.  
  30.  
  31. try {
  32.  
  33. $db = new Database($db_host, $db_user, $db_password, $db_name);
  34.  
  35. }
  36.  
  37. catch (Exception $e) {
  38.  
  39. echo $e->getMessage();
  40.  
  41. die();
  42.  
  43. }
  44.  
  45.  
  46.  
  47. $user = new User(Session::get_user_id(), $db);
  48.  
  49.  
  50.  
  51. Template::showHead($config_site_name);
  52.  
  53. Template::showBody();
  54.  
  55. Template::showUserMenuBlock($user);
  56.  
  57. Template::showMostInterestingBlockTop();
  58.  
  59. $more_interesting_topics = new MostInterestingTopics(5, $db);
  60.  
  61. $more_interesting_topics->getMostInterestingTopics();
  62.  
  63. $more_interesting_topics->showMostInterestingTopics();
  64.  
  65. Template::showMostInterestingBlockBottom();
  66.  
  67. Template::showPollsBlock();
  68.  
  69.  
  70.  
  71.  
  72.  
  73. if(isset($_POST['fl']) && !empty($_POST['fl'])) {
  74.  
  75.  
  76.  
  77. Validator::removeSlashes();
  78.  
  79. if($_POST['old_pass']!=="" && $_POST['new_pass']!=="" && $_POST['new_pass2']!=="") {
  80.  
  81. $old_pass=$_POST['old_pass'];
  82.  
  83. $new_pass=$_POST['new_pass'];
  84.  
  85. $new_pass2=$_POST['new_pass2'];
  86.  
  87. try {
  88.  
  89. $query = 'SELECT password FROM users WHERE id='.$user->get_id().' LIMIT 1';
  90.  
  91. $db->query($query);
  92.  
  93. }
  94.  
  95. catch(Exception $e) {
  96.  
  97. $e->getMessage();
  98.  
  99. die();
  100.  
  101. }
  102.  
  103. if ($db->num_rows()>0){
  104.  
  105.  
  106.  
  107. $row=$db->next_row();
  108.  
  109. $pass=$row['password'];
  110.  
  111. }
  112.  
  113.  
  114.  
  115. if(strcmp($new_pass,$new_pass2)==0 && strcmp(md5(md5($old_pass)),$pass)==0){
  116.  
  117.  
  118.  
  119. $name=$_POST['name'];
  120.  
  121. $email=$_POST['email'];
  122.  
  123. $country=$_POST['country'];
  124.  
  125. $city=$_POST['city'];
  126.  
  127. $about=$_POST['about'];
  128.  
  129.  
  130.  
  131. $err_Arr=Validator::getErrorsArray($email,$name,$country,$city,'a','1');
  132.  
  133. if(!Validator::full_info_validation($err_Arr)) {
  134.  
  135. echo '<div id="mid">'.Validator::getErrorMessage($err_Arr).'</div>';
  136.  
  137. Template::showChangeProfileForm($name,$email,$country,$city,$about);
  138.  
  139. }
  140.  
  141. else {
  142.  
  143. $var=Account::change_password($db,$user->get_login(),$old_pass,$new_pass)*Account::change_profile_info($db,$user->get_id(),$name,$email,$country,$city,$about);
  144.  
  145. if($var){
  146.  
  147. echo '<div id="mid">'.MSG0002.'</div>';
  148.  
  149. }
  150.  
  151. else
  152.  
  153. echo ERR0021;
  154.  
  155. }
  156.  
  157.  
  158.  
  159. }
  160.  
  161. else {
  162.  
  163. echo ERR0020;
  164.  
  165. }
  166.  
  167. }
  168.  
  169. else {
  170.  
  171. $name=$_POST['name'];
  172.  
  173. $email=$_POST['email'];
  174.  
  175. $country=$_POST['country'];
  176.  
  177. $city=$_POST['city'];
  178.  
  179. $about=$_POST['about'];
  180.  
  181. $err_Arr=Validator::getErrorsArray($email,$name,$country,$city,'a','1');
  182.  
  183. if(!Validator::full_info_validation($err_Arr)) {
  184.  
  185. echo '<div id="mid">'.Validator::getErrorMessage($err_Arr).'</div>';
  186.  
  187. Template::showChangeProfileForm($name,$email,$country,$city,$about);
  188.  
  189. }
  190.  
  191. else {
  192.  
  193. if(Account::change_profile_info($db,$user->get_id(),$name,$email,$country,$city,$about))
  194.  
  195. echo '<div id="mid">'.MSG0002.'</div>';
  196.  
  197. else echo ERR0003;
  198.  
  199. }
  200.  
  201. }
  202.  
  203.  
  204.  
  205. }
  206.  
  207. else {
  208.  
  209. Template::showChangeProfileForm($user->get_name(),$user->get_email(),$user->get_country(),$user->get_city(),$user->get_about());
  210.  
  211. }
  212.  
  213. Template::showFooter();
  214.  
  215. $db->close();
  216.  
  217.  
  218.  
  219. ?>
Add Comment
Please, Sign In to add comment