Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once("../library/config.inc.php");
- session_start();
- include_once("myconnect.php");
- if(isset($_POST['submit']) && $_POST['key'] == $_SESSION['key']) {
- include_once("inc/easyphpthumbnail.class.php");
- include_once("inc/watermark.php");
- $replace_values = array(" ", "'", "\"", "\\", "/", "?", "|", "@", "#", "~", "!", "£", "$", "%", "^", "&", "*", "(", ")", "[", "]", "{", "}", "+", "=", "-", ":", ";", ",");
- $imageURL = $_POST['url'];
- $dir = "../pictures/";
- $randvar = mt_rand(1,100);
- settype($randvar,"string");
- $image = ImageCreateFromString(file_get_contents($imageURL));
- $newimagename = $randvar.str_replace($replace_values, "_", basename($imageURL));
- $fimagename = $dir.$randvar.str_replace($replace_values, "_", basename($imageURL));
- if (is_resource($image) === true)
- {
- imagejpeg($image, $dir.$newimagename, 300);
- }
- else
- {
- echo "Please Try With Valid Url .";
- die();
- }
- $width = imagesx($image);
- $height = imagesy($image);
- $newwidth = $width;
- $newheight = $height;
- if($newwidth > 500)
- {
- $newwidth = 500;
- $newheight = (($height * $newwidth) / $width);
- }
- else if($_POST['pmcat_id'] == 2)
- {
- $newwidth = 320;
- $newheight = (($height * $newwidth) / $width);
- }
- $thumbs = imagecreatetruecolor($newwidth, $newheight);
- imagecopyresized($thumbs, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
- imagejpeg($thumbs, $fimagename); //save image as jpg
- imagedestroy($thumbs);
- imagedestroy($image);
- include("watermark.php");
- $thumb = new easyphpthumbnail;
- $thumb -> Thumbheight = 200;
- $thumb -> Thumbwidth = 200;
- $thumb -> Cropimage = array(3,0,0,0,0,0);
- $thumb -> Thumblocation = "../pictures/";
- $thumb -> Thumbprefix = 'tb_';
- $thumb -> Thumbsaveas = 'jpg';
- $thumb -> Thumbfilename = $fimagename;
- $thumb -> Createthumb($fimagename,'file');
- $pmgadget_title=str_replace("$","\$",addslashes($_REQUEST["subject"]));
- $pmcat_id=$_POST["pmcat_id"];
- $tags = implode(',', $pmcat_id);
- $pmpic_path = $newimagename;
- date_default_timezone_set("Asia/Karachi");
- $pmsubmit_date = date("YmdHis", time());
- $pmapproved="yes";
- $pmuser_id="1";
- $pmuser_name="Admin";
- mysql_query("insert into pmgadget_gadget(pmcat_id, pmpic_path, pmuser_id, pmuser_name, pmgadget_title, pmsubmit_date, pmapproved) VALUES('$tags', '$pmpic_path', $pmuser_id, '$pmuser_name', '$pmgadget_title', $pmsubmit_date, '$pmapproved') ");
- $lastid = mysql_insert_id();
- $ext = pathinfo($newimagename, PATHINFO_EXTENSION); //$ext will be gif
- $newname=$lastid.'.'.$ext;
- echo 'before '.$newimagename.'<br />';
- $oldt = $_SERVER['DOCUMENT_ROOT'].'/'.$thumbs_dir.'/tb_'.$newimagename;
- $newt = $_SERVER['DOCUMENT_ROOT'].'/'.$thumbs_dir.'/tb_'.$lastid.'.'.$ext;
- rename($oldt, $newt) or die("Unable to rename ".$oldt." to ".$newt.".");;
- $old = $_SERVER['DOCUMENT_ROOT'].'/'.$pic_dir.'/'.$newimagename;
- $new = $_SERVER['DOCUMENT_ROOT'].'/'.$pic_dir.'/'.$lastid.'.'.$ext;
- rename($old, $new) or die("Unable to rename ".$old." to ".$new.".");;
- echo 'after '.$lastid.'.'.$ext.'<br />';
- $update = mysql_query("UPDATE $db_table SET $ppic_url='".$newname."' WHERE $approved='yes' AND $post_id=$lastid") or die("Error");
- echo "<br /> Subject of Uploaded Content : ".
- $pmgadget_title." <br />";
- echo "In ".$tags."<br />";
- echo "<img src='http://".$_SERVER["SERVER_NAME"] ."/pictures/tb_".$newimagename."' width='150' height='135'> <br /> Image Has Been Posted Successfully .";
- $tags = explode(',',$tags);
- foreach($tags as $tag){
- mysql_query("update $category_table SET post_counts = post_counts+1 WHERE $category_id ='.$tag.'");
- }
- }
- $_SESSION['key'] = mt_rand(1, 1000);
- ?>
- <html>
- <head>
- <title>Submit Via Url</title>
- <script src="<?php echo $site_path;?>library/jquery.js" type="text/javascript"></script>
- <script src="<?php echo $site_path;?>library/jquery.validate.js" type="text/javascript"></script>
- <script src="inc/main.js" type="text/javascript"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $("#form1").validate();
- });
- </script>
- </head>
- <body>
- <?php
- echo'<b>Upload Picture Via URL</b>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement