Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 95 lines (79 sloc) 2.447 kb
01a7f58 @rosslagerwall Initial commit
authored
1 <?php
2
3 function isValidEmail($email)
4 {
5 $pattern = "/^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$/";
6
7 if (preg_match($pattern,$email) == 1)
8 {
9 return true;
10 }
11 else
12 {
13 return false;
14 }
15 }
16
07326f1 @rosslagerwall Refactor repeated function urlfilesize() into its own file.
authored
17 include_once("function.misc.php");
01a7f58 @rosslagerwall Initial commit
authored
18
19 include_once("class.User.php");
20 session_start();
21
22 if (strlen(trim(stripslashes($_POST['password']))) < 3)
23 {
24 header("Location: editUser.php?userId=".$_SESSION['user']->getUserId()."&error=2");
25 exit();
26 }
27 if (!isValidEmail(trim(stripslashes($_POST['email']))))
28 {
29 header("Location: editUser.php?userId=".$_SESSION['user']->getUserId()."&error=1");
30 exit();
31 }
32
33 $sigStr = stripslashes($_POST['sig']);
34 $sigStr = str_replace("\n","",$sigStr);
35 $sigStr = str_replace("\r\n","",$sigStr);
36 $sigStr = str_replace("\r","",$sigStr);
37
38 preg_match_all("/<img.*? \/>/",$sigStr,$matches);
39
40 foreach ($matches[0] as $match)
41 {
42 $url = substr(substr(strstr($match,'src="'),5),0,strpos(substr(strstr($match,'src="'),5),'"'));
43 if (@urlfilesize($url,"kb") <= 200)
44 {
45 $imgDimensions = @getimagesize($url);
46
47 if ($imgDimensions[0] > 600 || $imgDimensions[1] > 600 || $imgDimensions == false)
48 {
49 $sigStr = str_replace($match,"",$sigStr);
50 }
51 }
52 else
53 {
54 $sigStr = str_replace($match,"",$sigStr);
55 }
56 }
57
58 $sigStr = strip_tags($sigStr,'<p><br><b><i><u><strong><em><li><ul><ol><img><table><tr><td><hr><font><span><sub><sup><tbody><blockquote>');
59
60 if ($_POST['hideEmail'] == 'yes')
61 {
62 $hideEmail = 1;
63 }
64 else
65 {
66 $hideEmail = 0;
67 }
68
69 if (@urlfilesize($_POST['avatar'],"kb") <= 100)
70 {
71 $imgDimensions = @getimagesize($_POST['avatar']);
72 if ($imgDimensions[0] <= 70 && $imgDimensions[1] <= 70 && $imgDimensions != false)
73 {
74 $img = $_POST['avatar'];
75 }
76 else
77 {
78 $img = "";
79 }
80 }
81 else
82 {
83 $img = "";
84 }
85
86 $newUserStr = $_SESSION['user']->getUserId()."\n".trim(stripslashes($_POST['password']))."\nfalse\n".$_SESSION['user']->getNoTopics()."\n".$_SESSION['user']->getNoPosts()."\n".$_SESSION['user']->getJoinDate()."\n".$_SESSION['user']->getLevel()."\n".$sigStr."\n".trim(stripslashes($_POST['email']))."\n".$hideEmail."\n".$img;
87
88 file_put_contents("db/Users/".$_SESSION['user']->getUserId().".dat",$newUserStr);
89
90 $temp = new User($newUserStr);
91 $_SESSION['loggedIn'] = true;
92 $_SESSION['user'] = $temp;
93 header("location: editUser.php?userId=".$_SESSION['user']->getUserId());
94 ?>
Something went wrong with that request. Please try again.