Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- include_once("config.php");
- $full_path=str_replace("submit.php","",$_SERVER[SCRIPT_FILENAME]);
- if($full_path==""){$full_path=str_replace("/submit.php","",$_SERVER[SCRIPT_FILENAME]);}
- if(!$_GET[a])
- {
- include_once("header.php");
- $categories="<select name=category>\n";
- $result=mysql_query("SELECT * FROM babeloggerv3_categories ORDER BY id");
- while($row=mysql_fetch_array($result))
- {
- $categories.="<option value=\"$row[name]\">$row[name]</option>\n";
- }
- $categories.="</select>\n";
- $temp=$template_submit;
- if(strstr($temp,"%url%")){$submit=str_replace("%url%","<input name=url size=45>",$temp);}else{$submit=$temp;}
- if(strstr($submit,"%title%")){$submit=str_replace("%title%","<input name=title size=30>",$submit);}else{$submit=$submit;}
- if(strstr($submit,"%description%")){$submit=str_replace("%description%","<textarea name=description cols=34 rows=5></textarea>",$submit);}else{$submit=$submit;}
- if(strstr($submit,"%username%")){$submit=str_replace("%username%","<input name=username value='$_COOKIE[username]'>",$submit);}else{$submit=$submit;}
- if(strstr($submit,"%password%")){$submit=str_replace("%password%","<input name=password value='$_COOKIE[password]' type=password> <input name=remember type=checkbox $_COOKIE[remember]> Remember Me",$submit);}else{$submit=$submit;}
- if(strstr($submit,"%categories%")){$submit=str_replace("%categories%",$categories,$submit);}else{$submit=$submit;}
- if(strstr($submit,"%image%")){$submit=str_replace("%image%","<input name=image type=radio value='1' checked> Image URL <span class=smallfont>(JPEG and JPG only, $max_image_filesize bytes max)</span>:<br><input name=imageurl size=45><br><b>OR</b><br><input name=image type=radio value='2'> Upload Image <span class=smallfont>(JPEG and JPG only, $max_image_filesize bytes max)</span>:<br><input name=uploadimg type=file size=33>",$submit);}else{$submit=$submit;}
- print $submit;
- include_once("footer.php");
- }
- elseif($_GET[a]=="submit")
- {
- $temp=$template_submit;
- $username=stripslashes($_POST[username]);
- $password=stripslashes($_POST[password]);
- $title=stripslashes(addslashes($_POST[title]));
- $description=stripslashes(addslashes($_POST[description]));
- $url=stripslashes($_POST[url]);
- $category=stripslashes($_POST[category]);
- if(strstr($temp,"%url%") && !$url){die(header("Location: $script_url/msgs.php?msg=submiterror"));}
- if(strstr($temp,"%title%") && !$title){die(header("Location: $script_url/msgs.php?msg=submiterror"));}
- if(strstr($temp,"%description%") && !$description){die(header("Location: $script_url/msgs.php?msg=submiterror"));}
- if(strstr($temp,"%categories%") && !$category){die(header("Location: $script_url/msgs.php?msg=submiterror"));}
- if(strstr($temp,"%image%") && (!$_POST[imageurl] && !$_FILES['uploadimg']['name'])){die(header("Location: $script_url/msgs.php?msg=submiterror"));}elseif(strstr($temp,"%image%")){$crop_image=true;}
- if(strstr($temp,"%username%") && !$username)
- {
- die(header("Location: $script_url/msgs.php?msg=submiterror"));
- }
- else
- {
- $result=mysql_query("SELECT username,password,preferred,count(*) as matches FROM babeloggerv3_users GROUP BY username HAVING username='$username'");
- $row=mysql_fetch_row($result);
- if(strstr($temp,"%password%") && $password)
- {
- if($password!=$row[1]){die(header("Location: $script_url/msgs.php?msg=invalidlogin"));}
- }
- if($row[3] && !$password){die(header("Location: $script_url/msgs.php?msg=registereduser"));}
- $poster=$username;
- if($row[2]=="yes"){$approved="yes";}
- }
- if($_POST[remember]=="on")
- {
- setcookie("username",$username,time()+$cookie_time);
- setcookie("password",$password,time()+$cookie_time);
- setcookie("remember","checked",time()+$cookie_time);
- }
- elseif(isset($_COOKIE['username']))
- {
- setcookie("username","",time()-$cookie_time);
- setcookie("password","",time()-$cookie_time);
- setcookie("remember","",time()-$cookie_time);
- }
- if($crop_image)
- {
- if($_POST[image]==1 && $_POST[imageurl])
- {
- if(!preg_match("/(.+)\.(jpeg|jpg)$/i", $_POST[imageurl], $matches)){die(header("Location: $script_url/msgs.php?msg=wrongimgfiletype"));}
- if(!$_POST[imageurl]){die(header("Location: $script_url/msgs.php?msg=submiterror"));}
- $rnd=rand(0,1000000).".jpg";
- save_image("$_POST[imageurl]",$full_path.$images_path.$rnd);
- }
- elseif($_POST[image]==2 && $_FILES['uploadimg']['name'])
- {
- $imgname=$_FILES['uploadimg']['name'];
- if(!preg_match("/(.+)\.(jpeg|jpg)$/i",$imgname,$matches)){die(header("Location: $script_url/msgs.php?msg=wrongimgfiletype"));}
- $extension=$matches[2];
- $rnd=rand(0,10000000).".$extension";
- copy($_FILES['uploadimg']['tmp_name'],$full_path.$images_path.$rnd) or die(header("Location: $script_url/msgs.php?msg=erroruploadingimage"));
- $filesize=filesize($full_path.$images_path.$rnd);
- if($filesize>$max_image_filesize){unlink($full_path.$images_path.$rnd);die(header("Location: $script_url/msgs.php?msg=errorimgsize"));}
- }
- $img_area=getimagesize($full_path.$images_path.$rnd);
- if(($img_area[0]==$max_image_width AND $img_area[1]==$max_image_height) OR $allow_cropping=="no"){$size_match=true;$crop=$approved;}else{$crop="cropping";}
- mysql_query("INSERT INTO babeloggerv3 (time,title,description,url,category,approved,poster,imgname) VALUES ('".time()."','$title','$description','$url','$category','$crop','$poster','$rnd')");
- if($allow_cropping=="yes" AND !$size_match)
- {
- ?>
- <link href='babeloggerv3.css' type=text/css rel=stylesheet>
- <body onload="initPage()" leftmargin="0" topmargin="0" class="body">
- <script language="JavaScript" src="babeloggerv3.js"></script>
- <table style="top: 556px; left: 610px; width: 200px; height: 300px;" id="img_cover" onmousedown="mouseDownImg(event);" onmousemove="mouseMoveImg(event)"><tbody><tr><td>
- </td></tr></tbody></table>
- <table style="top: 0pt; left: 0pt; width: 5px; height: 5px; cursor: move;" id="selection" onmousedown="mouseDownSel(event);" onmousemove="mouseMoveSel(event)"><tbody><tr><td>
- </td></tr></tbody></table>
- <table width=400 align=center cellspacing=0 cellpadding=3>
- <tr>
- <td class=tdheaderstyle colspan=2 align=center><b>Crop your image</b></td>
- </tr>
- <tr>
- <td align=center>
- <form style="display:inline" name="thumbForm" action="?a=crop_image" method="post" onsubmit="return fillForm();">
- <input id="thumbWidth" name="thumbWidth" value="<?php print $max_image_width;?>" size="3" onchange="changeWidth()" type="hidden">
- <input id="thumbHeight" name="thumbHeight" value="<?php print $max_image_height;?>" size="3" onchange="changeHeight()" type="hidden"></span>
- <input name="selX" type="hidden">
- <input name="selY" type="hidden">
- <input name="selWidth" type="hidden">
- <input name="selHeight" type="hidden">
- <input name="image" type="hidden" value="<?php print $rnd;?>">
- <input name="id" type="hidden" value="<?php print mysql_insert_id();?>">
- <input name="approved" type="hidden" value="<?php print $approved;?>">
- <input type="submit" value="crop image">
- </form><br />
- Thank you! Please take a moment to crop your image.<br />Click and drag your cursor on the image to crop<br />
- <img id="img_main" src="<?php print $script_url.$images_path.$rnd;?>" onload="imageLoaded()">
- </td>
- </tr>
- </table>
- <?php
- }
- else{header("Location: $script_url/msgs.php?msg=linksubmitted");}
- }
- else
- {
- mysql_query("INSERT INTO babeloggerv3 (time,title,description,url,category,approved,poster,imgname) VALUES ('".time()."','$title','$description','$url','$category','$approved','$poster','$rnd')");
- header("Location: $script_url/msgs.php?msg=linksubmitted");
- }
- }
- elseif($_GET[a]=="crop_image")
- {
- if(0>$_POST[selX] OR 0>$_POST[selY]){die(header("Location: $script_url/msgs.php?msg=didnotcrop"));}
- $file=$full_path.$images_path.$_POST[image];
- $image_p=imagecreatetruecolor($_POST[thumbWidth], $_POST[thumbHeight]);
- $image=imagecreatefromjpeg($file);
- imagecopyresampled($image_p, $image, 0, 0, $_POST[selX], $_POST[selY], $_POST[thumbWidth], $_POST[thumbHeight], $_POST[selWidth], $_POST[selHeight]);
- imagejpeg($image_p, $file, $image_quality);
- imagedestroy($image_p);
- imagedestroy($image);
- mysql_query("UPDATE babeloggerv3 SET approved='$_POST[approved]' WHERE id='$_POST[id]'");
- header("Location: $script_url/msgs.php?msg=linksubmitted");
- }
- function save_image($name,$filename)
- {
- global $script_url, $image_quality;
- $src_img=imagecreatefromjpeg($name) or die(header("Location: $script_url/msgs.php?msg=erroruploadingimage"));
- imagejpeg($src_img,$filename,$image_quality) or die(header("Location: $script_url/msgs.php?msg=erroruploadingimage"));
- imagedestroy($src_img);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement