Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 1.2.0
Fetching contributors…

Cannot retrieve contributors at this time

file 89 lines (77 sloc) 2.273 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<?php

$_POST['message'] = str_replace("~","",$_POST['message']);

include_once("class.Post.php");
include_once("class.Topic.php");
include_once("class.Forum.php");
include_once("class.User.php");
session_start();

function urlfilesize($url,$thereturn)
{
if (substr($url,0,4)=='http')
{
$x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
$x = $x['content-length'];
}
else
{
$x = @filesize($url);
}
if (!$thereturn)
{
return $x;
}
elseif ($thereturn == 'mb')
{
return round($x / (1024*1024),2);
}
elseif ($thereturn == 'kb')
{
return round($x / (1024),0);
}
}

$str = "";
$fileC = file("db/Topics/".$_GET['topicId']."/posts.dat",FILE_IGNORE_NEW_LINES);

foreach ($fileC as $line)
{
$temp = new Post($line);
if ($_GET["postId"] == $temp->getPostId())
{
$postArr = explode("~",$line);

$postString = stripslashes($_POST['message']);
$postString = str_replace("\n","",$postString);
$postString = str_replace("\r\n","",$postString);
$postString = str_replace("\r","",$postString);

preg_match_all("/<img.*? \/>/",$postString,$matches);

foreach ($matches[0] as $match)
{
$url = substr(substr(strstr($match,'src="'),5),0,strpos(substr(strstr($match,'src="'),5),'"'));
if (@urlfilesize($url,"kb") <= 200)
{
$imgDimensions = @getimagesize($url);

if ($imgDimensions[0] > 600 || $imgDimensions[1] > 600 || $imgDimensions == false)
{
$postString = str_replace($match,"",$postString);
}
}
else
{
$postString = str_replace($match,"",$postString);
}
}

$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>');

if ($postString == "")
{
header("Location: editPost.php?postId=".$_GET["postId"]."&topicId=".$_GET['topicId']."&error=1");
exit();
}

$postArr[5] = $postString;
$str .= trim(implode("~",$postArr))."\n";
}
else
{
$str .= $line."\n";
}
}
file_put_contents("db/Topics/".$_GET['topicId']."/posts.dat",$str);
header('Location: viewPosts.php?topicId='.$_GET['topicId']);
?>
Something went wrong with that request. Please try again.