Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 67 lines (54 sloc) 1.881 kb
01a7f58 @rosslagerwall Initial commit
authored
1 <?php
2
3 $_POST['message'] = str_replace("~","",$_POST['message']);
4
5 include_once("class.Post.php");
6 include_once("class.Topic.php");
7 include_once("class.Forum.php");
8 include_once("class.User.php");
9 session_start();
10
07326f1 @rosslagerwall Refactor repeated function urlfilesize() into its own file.
authored
11 include_once("function.misc.php");
01a7f58 @rosslagerwall Initial commit
authored
12
13 $str = "";
14 $fileC = file("db/Topics/".$_GET['topicId']."/posts.dat",FILE_IGNORE_NEW_LINES);
15
16 foreach ($fileC as $line)
17 {
18 $temp = new Post($line);
19 if ($_GET["postId"] == $temp->getPostId())
20 {
21 $postArr = explode("~",$line);
22
23 $postString = stripslashes($_POST['message']);
24 $postString = str_replace("\n","",$postString);
25 $postString = str_replace("\r\n","",$postString);
26 $postString = str_replace("\r","",$postString);
27
28 preg_match_all("/<img.*? \/>/",$postString,$matches);
29
30 foreach ($matches[0] as $match)
31 {
32 $url = substr(substr(strstr($match,'src="'),5),0,strpos(substr(strstr($match,'src="'),5),'"'));
33 if (@urlfilesize($url,"kb") <= 200)
34 {
35 $imgDimensions = @getimagesize($url);
36
37 if ($imgDimensions[0] > 600 || $imgDimensions[1] > 600 || $imgDimensions == false)
38 {
39 $postString = str_replace($match,"",$postString);
40 }
41 }
42 else
43 {
44 $postString = str_replace($match,"",$postString);
45 }
46 }
47
48 $postString = strip_tags($postString,'<p><br><b><i><u><strong><em><li><ul><ol><img><table><tr><td><hr><font><span><sub><sup><tbody><blockquote>');
49
50 if ($postString == "")
51 {
52 header("Location: editPost.php?postId=".$_GET["postId"]."&topicId=".$_GET['topicId']."&error=1");
53 exit();
54 }
55
56 $postArr[5] = $postString;
57 $str .= trim(implode("~",$postArr))."\n";
58 }
59 else
60 {
61 $str .= $line."\n";
62 }
63 }
64 file_put_contents("db/Topics/".$_GET['topicId']."/posts.dat",$str);
65 header('Location: viewPosts.php?topicId='.$_GET['topicId']);
66 ?>
Something went wrong with that request. Please try again.