Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- error_reporting(0);
- $host = "localhost";
- $username = "toxxicc_fake";
- $password = "fake";
- $db_name = "toxxicc_forum";
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- if(!isset($_POST['board']))
- {
- echo "Error! <a href=index.php>Return to abyxChan?</a>";
- exit;
- }
- if($_POST['post'] == "")
- {
- echo "Error! Post needs contents! <a href=index.php?board=". $_POST['board'] .">Return to abyxChan?</a>";
- exit;
- }
- define ("MAX_SIZE","5120");
- function getExtension($str) {
- $i = strrpos($str,".");
- if (!$i) { return ""; }
- $l = strlen($str) - $i;
- $ext = substr($str,$i+1,$l);
- return $ext;
- }
- $errors=0;
- $image = $_FILES['image']['name'];
- if ($image)
- {
- $filename = stripslashes($_FILES['image']['name']);
- $extension = getExtension($filename);
- $extension = strtolower($extension);
- if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
- {
- echo "Error! Bad extension! <a href=index.php?board=". $_POST['board'] .">Return to abyxChan?</a>";
- $errors=1;
- }
- else
- {
- $size=filesize($_FILES['image']['tmp_name']);
- if ($size > MAX_SIZE*1024)
- {
- echo "Error! Size limit exceeded! <a href=index.php?board=". $_POST['board'] .">Return to abyxChan?</a>";
- $errors=1;
- }
- $image_name=time().'.'.$extension;
- $newname="img/".$image_name;
- $copied = copy($_FILES['image']['tmp_name'], $newname);
- include('thumb.php');
- if($_POST['name'] == "")
- {
- $name = "Anonymous";
- }
- else
- {
- $name = $_POST['name'];
- $name = str_replace (" ", "", $name);
- $name = htmlspecialchars($name, ENT_QUOTES);
- $_SESSION['name'] = $name;
- }
- list($name,$trip) = explode("#", $name);
- if($trip != "")
- {
- $trip = mb_convert_encoding($trip,"SJIS");
- $salt = substr($trip."H.",1,2);
- $salt = ereg_replace("[^\.-z]",".",$salt);
- $salt = strtr($salt,":;<=>?@[\\]^_`","ABCDEFGabcdef");
- $trip = substr(crypt($trip,$salt),-10)."";
- $trip = mb_convert_encoding($trip,"UTF-8");
- }
- $_SESSION['email'] = $_POST['email'];
- $email = htmlspecialchars($_POST['email'], ENT_QUOTES);
- $subject = htmlspecialchars($_POST['subject'], ENT_QUOTES);
- $post = htmlspecialchars($_POST['post'], ENT_QUOTES);
- $post = wordwrap($post, 50, "\n", true);
- $post = nl2br($post);
- $board = $_POST['board'];
- $date = date("m/d/y(D) G:i");
- $ip = $_SERVER['REMOTE_ADDR'];
- $file = $image_name;
- $bump = time();
- $ismod = 0;
- if(isset($_SESSION['admin']))
- {
- $ismod = 2;
- }
- if(isset($_SESSION['moderator']))
- {
- if($_SESSION['moderator'] == $board || $_SESSION['moderator'] == "global")
- {
- $ismod = 1;
- }
- }
- $pathfile = "img/". $file;
- $filehash = md5_file($pathfile);
- $result = mysql_query("SELECT * FROM posts") or die(mysql_error());
- while($row = mysql_fetch_array( $result ))
- {
- if($filehash == $row['filehash'])
- {
- echo "Hash: ". $filehash ."<br />";
- echo "Existing Hash: ". $row['filehash'] ."<br />";
- echo "Duplicate file detected! <a href=index.php>Return?</a>";
- unlink('img/'.$file);
- unlink('img/thumbs/t'.$file);
- exit;
- }
- }
- $result = mysql_query("SELECT * FROM replies") or die(mysql_error());
- while($row = mysql_fetch_array( $result ))
- {
- if($filehash == $row['filehash'])
- {
- echo "Hash: ". $filehash ."<br />";
- echo "Existing Hash: ". $row['filehash'] ."<br />";
- echo "Duplicate file detected! <a href=index.php>Return?</a>";
- unlink('img/'.$file);
- unlink('img/thumbs/t'.$file);
- exit;
- }
- }
- mysql_query("INSERT INTO posts (board, date, author, trip, file, ip, email, subject, post, bump, replies, ismod, filehash) VALUES('$board', '$date', '$name', '$trip', '$file', '$ip', '$email', '$subject', '$post', '$bump', '0', '$ismod', '$filehash') ") or die(mysql_error());
- if (!$copied)
- {
- echo "Error! Image could not be uploaded! <a href=index.php?board=". $_POST['board'] .">Return to abyxChan?</a>";
- $errors=1;
- }
- }
- }
- else
- {
- echo "Error! No image selected! <a href=index.php?board=". $_POST['board'] .">Return to abyxChan?</a>";
- $errors=1;
- }
- if(!$errors)
- {
- echo "Image upload successful! <a href=index.php?board=". $_POST['board'] .">Return to abyxChan?</a>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement