Results 1 to 10 of 10
-
19th Jul 2011, 04:36 PM #1OPBannedWebsite's:
WarezRelease.org ThatHosting.coremote upload checks
okay
for local uploading i do checks like:
PHP Code:$name = $_FILES['imagefile']['name']; //file name
$type = $_FILES['imagefile']['type']; // type of file
$size = $_FILES['imagefile']['size']; //size of the mage in bytes
$imageKB = round(($size / 1024), 2); // bytes to KB
$imageMB = round(($size / 1048576), 2); // bytes to MB
$tmp_name = $_FILES['imagefile']['tmp_name']; //temp file name and location
/* // FILE SIZES
$file_gb = round(($filesize / 1073741824), 2); // bytes to GB
// PHP does funny thing for files larger than 2GB */
$ext = substr($name, strrpos($name, '.')); //grab file extension
// Requirements
$dimension = getimagesize($tmp_name);
$width = $dimension[0]; // uploaded image width
$height = $dimension[1]; // uploaded image height
// get the extension of the file in a lower case format
$ext = strtolower($ext);
if (in_array($type, $allowed) && ($size <= $maxfileSize) && ( $width < $maxWidth && $height < $maxHeight )) {
$name = time().''.$ext; //we will give an unique name, for example the time in unix time format
move_uploaded_file($tmp_name, $uploadDir.'/'.$name); // upload the image, eventually i want to force the image on server to use my preferred file type
}
PHP Code:if (in_array($type, $allowed) && ($size <= $maxfileSize) && ( $width < $maxWidth && $height < $maxHeight )) {
PHP Code:$urls = explode("\n", $_POST['remoteimage']);
$imgarray = array();
foreach ($urls as $url) {
$imgname = basename($url);
$localimg = $uploadDir .'/'. $imgname;
$img = file_get_contents($url);
file_put_contents($localimg, $img);
$exten = substr($url, strrpos($url, '.') + 1); // The "strrpos" approach to get the extension.
$ch = curl_init($url); // Get the filesize using curl
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$remoteSize = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$remoteSize = (int)$matches[1];
}
$imageKB = round(($remoteSize / 1024), 2); // bytes to KB
$imageMB = round(($remoteSize / 1048576), 2); // bytes to MB
$newname = time().'.'.$exten; // Got the file type, works ok, not ideal way but we need to check to see its valid t ype. really should use curl.
$newImage = $uploadDir .'/'.$newname;
rename($localimg, $newImage);
}
Chris2k Reviewed by Chris2k on . remote upload checks okay for local uploading i do checks like: $name = $_FILES; //file name $type = $_FILES; // type of file $size = $_FILES; //size of the mage in bytes $imageKB = round(($size / 1024), 2); // bytes to KB $imageMB = round(($size / 1048576), 2); // bytes to MB Rating: 5
-
19th Jul 2011, 05:43 PM #2Respected MemberWebsite's:
DL4Everything.com Soft2050.inHere you go for the whole code:
PHP Code:$urls = explode("\n", $_POST['remoteimage']);
$imgarray = array();
foreach ($urls as $url) {
$imgname = basename($url);
$localimg = $uploadDir .'/'. $imgname;
$allowed = array("jpg", "jpeg", "png", "gif");
$imgsizecheck = getimagesize($url);
$widthofimg = $imgsizecheck[0];
$heightofimg = $imgsizecheck[1];
$exten = substr($imgname, strrpos($imgname, '.') + 1);
if (in_array($exten, $allowed) && ( $widthofimg < $maxWidth && $heightofimg < $maxHeight )) { // Checks for width and extension of filetype
$ch = curl_init($url); // Get the filesize using curl
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$remoteSize = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$remoteSize = (int)$matches[1];
}
$imageKB = round(($remoteSize / 1024), 2); // bytes to KB
$imageMB = round(($remoteSize / 1048576), 2); // bytes to MB
if ($imageMB <= $maxfileSize) { // Checks for Filesize of the image
file_put_contents($localimg, $img);
$newname = time().'.'.$exten; // Got the file type, works ok, not ideal way but we need to check to see its valid t ype. really should use curl.
$newImage = $uploadDir .'/'.$newname;
rename($localimg, $newImage);
}
}
}
-
19th Jul 2011, 10:35 PM #3OPBannedWebsite's:
WarezRelease.org ThatHosting.coHi m8,
i figured it a few mins after, but when i add this line:
PHP Code:if (in_array($exten, $allowed) && ( $imageKB <= $maxfileSize ) && ( $width2 < $maxWidth && $height2 < $maxHeight )) {
now i need to add an ending brace } , ive tried adding it after tha line above and the bottom line, heres my code:
PHP Code:elseif (isset($_POST['remoteUpload'])) {
$urls = explode("\n", $_POST['remoteimage']);
$imgarray = array();
foreach ($urls as $url) {
$imgname = basename($url);
$localimg = $uploadDir .'/'. $imgname;
// Requirements
$pixels = getimagesize($url); // Get image size in pixels for remote.
$width2 = $pixels[0];
$height2 = $pixels[1];
$exten = substr($url, strrpos($url, '.') + 1); // The "strrpos" approach to get the extension.
$ch = curl_init($url); // Get the filesize using curl
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$remoteSize = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$remoteSize = (int)$matches[1];
}
$imageKB = round(($remoteSize / 1024), 2); // bytes to KB
$imageMB = round(($remoteSize / 1048576), 2); // bytes to MB
$img = file_get_contents($url);
file_put_contents($localimg, $img);
$newname = time().'.'.$exten;
$newImage = $uploadDir .'/'.$newname;
rename($localimg, $newImage);
}
$param = '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
$BBCode2 = htmlspecialchars_decode($param);
//Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
$newThumbImg = imagecreatefromstring(file_get_contents($fileURL));
$ratio = $width2 / $height2; // calculate the ratio
if ($ratio > 1 ) {
$newW = $thumbPixels;
$newH = $thumbPixels / $ratio;
} else {
$newH = $thumbPixels;
$newW = $thumbPixels * $ratio;
}
//function for resize image.
if ( function_exists ( 'imagecreatetruecolor' ) ) {
$newImg = imagecreatetruecolor($newW, $newH);
} else {
die("Error: Please make sure you have GD library ver 2+");
}
//the resizing is going on here!
imagecopyresized($newImg, $newThumbImg, 0, 0, 0, 0, $newW, $newH, $width2, $height2);
$imageFileClean = preg_replace("/Resource id #6/", "", $newname);
//finally, save the image
ImageJpeg ($newImg, $thumbDir . $newname);
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
echo "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
<div align='center'><a href='$uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
<table width='100%' style='margin: 0 auto;'>
<tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
<tr><td class='select_text' align='right'>Direct Image Link:</td>
<td><input tabindex='1' value='$siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
<tr><td class='select_text' align='right'>HTML Link:</td>
<td><input tabindex='2' value='".htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
<tr><td class='select_text' align='right'>Code:</td>
<td><input tabindex='1' value='".$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
<tr><td class='select_text' align='right'>Thumbnail (90px):</td>
<td><input tabindex='1' value='$siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
<td><input tabindex='1' value='$siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
}
-
20th Jul 2011, 12:22 PM #4OPBannedWebsite's:
WarezRelease.org ThatHosting.cofixed, stupid me, obvious fix LOL..
I was tryna use the types array tht i used for the local uploads, i needed a seperate array 4 just extensions... so heres my code:
PHP Code:elseif (isset($_POST['remoteUpload'])) {
$urls = explode("\n", $_POST['remoteimage']);
$imgarray = array();
foreach ($urls as $url) {
$imgname = basename($url);
$localimg = $uploadDir .'/'. $imgname;
// Requirements
$pixels = getimagesize($url); // Get image size in pixels for remote.
$width2 = $pixels[0];
$height2 = $pixels[1];
$exten = substr($url, strrpos($url, '.') + 1); // The "strrpos" approach to get the extension.
$ch = curl_init($url); // Get the filesize using curl
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$remoteSize = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$remoteSize = (int)$matches[1];
}
$imageKB = round(($remoteSize / 1024), 2); // bytes to KB
$imageMB = round(($remoteSize / 1048576), 2); // bytes to MB
$allowedext = array("jpg", "jpeg", "png", "x-png", "gif", "bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
if (in_array($exten, $allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 < $maxWidth && $height2 < $maxHeight )) {
$img = file_get_contents($url);
file_put_contents($localimg, $img);
$newname = time().'.'.$exten;
$newImage = $uploadDir .'/'.$newname;
rename($localimg, $newImage);
}
$param = '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
$BBCode2 = htmlspecialchars_decode($param);
//Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
$newThumbImg = imagecreatefromstring(file_get_contents($fileURL));
$ratio = $width2 / $height2; // calculate the ratio
if ($ratio > 1 ) {
$newW = $thumbPixels;
$newH = $thumbPixels / $ratio;
} else {
$newH = $thumbPixels;
$newW = $thumbPixels * $ratio;
}
//function for resize image.
if ( function_exists ( 'imagecreatetruecolor' ) ) {
$newImg = imagecreatetruecolor($newW, $newH);
} else {
die("Error: Please make sure you have GD library ver 2+");
}
//the resizing is going on here!
imagecopyresized($newImg, $newThumbImg, 0, 0, 0, 0, $newW, $newH, $width2, $height2);
$imageFileClean = preg_replace("/Resource id #6/", "", $newname);
//finally, save the image
ImageJpeg ($newImg, $thumbDir . $newname);
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
echo "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
<div align='center'><a href='$uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
<table width='100%' style='margin: 0 auto;'>
<tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
<tr><td class='select_text' align='right'>Direct Image Link:</td>
<td><input tabindex='1' value='$siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
<tr><td class='select_text' align='right'>HTML Link:</td>
<td><input tabindex='2' value='".htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
<tr><td class='select_text' align='right'>Code:</td>
<td><input tabindex='1' value='".$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
<tr><td class='select_text' align='right'>Thumbnail (90px):</td>
<td><input tabindex='1' value='$siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
<td><input tabindex='1' value='$siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
}
} // < attempting a remote upload and all checks.
PHP Code:else
echo "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>";
any1 can help?
-
21st Jul 2011, 12:48 PM #5Respected MemberWebsite's:
DL4Everything.com Soft2050.inTry this:
PHP Code:elseif (isset($_POST['remoteUpload'])) {
$urls = explode("\n", $_POST['remoteimage']);
$imgarray = array();
foreach ($urls as $url) {
$imgname = basename($url);
$localimg = $uploadDir .'/'. $imgname;
// Requirements
$pixels = getimagesize($url); // Get image size in pixels for remote.
$width2 = $pixels[0];
$height2 = $pixels[1];
$exten = substr($url, strrpos($url, '.') + 1); // The "strrpos" approach to get the extension.
$ch = curl_init($url); // Get the filesize using curl
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$remoteSize = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$remoteSize = (int)$matches[1];
}
$imageKB = round(($remoteSize / 1024), 2); // bytes to KB
$imageMB = round(($remoteSize / 1048576), 2); // bytes to MB
$allowedext = array("jpg", "jpeg", "png", "x-png", "gif", "bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
if (in_array($exten, $allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 < $maxWidth && $height2 < $maxHeight )) {
$img = file_get_contents($url);
file_put_contents($localimg, $img);
$newname = time().'.'.$exten;
$newImage = $uploadDir .'/'.$newname;
rename($localimg, $newImage);
$param = '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
$BBCode2 = htmlspecialchars_decode($param);
//Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
$newThumbImg = imagecreatefromstring(file_get_contents($fileURL));
$ratio = $width2 / $height2; // calculate the ratio
if ($ratio > 1 ) {
$newW = $thumbPixels;
$newH = $thumbPixels / $ratio;
} else {
$newH = $thumbPixels;
$newW = $thumbPixels * $ratio;
}
//function for resize image.
if ( function_exists ( 'imagecreatetruecolor' ) ) {
$newImg = imagecreatetruecolor($newW, $newH);
} else {
die("Error: Please make sure you have GD library ver 2+");
}
//the resizing is going on here!
imagecopyresized($newImg, $newThumbImg, 0, 0, 0, 0, $newW, $newH, $width2, $height2);
$imageFileClean = preg_replace("/Resource id #6/", "", $newname);
//finally, save the image
ImageJpeg ($newImg, $thumbDir . $newname);
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
echo "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
<div align='center'><a href='$uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
<table width='100%' style='margin: 0 auto;'>
<tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
<tr><td class='select_text' align='right'>Direct Image Link:</td>
<td><input tabindex='1' value='$siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
<tr><td class='select_text' align='right'>HTML Link:</td>
<td><input tabindex='2' value='".htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
<tr><td class='select_text' align='right'>Code:</td>
<td><input tabindex='1' value='".$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
<tr><td class='select_text' align='right'>Thumbnail (90px):</td>
<td><input tabindex='1' value='$siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
<td><input tabindex='1' value='$siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
}
}
else
echo "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>";
} // < attempting a remote upload and all checks.
-
21st Jul 2011, 01:03 PM #6OPBannedWebsite's:
WarezRelease.org ThatHosting.costill getting parse error m8... it seems to be 2nd to last line, when im ending the other check statement .
-
21st Jul 2011, 01:08 PM #7Respected MemberWebsite's:
DL4Everything.com Soft2050.inYou might be including some file
Check all the files included syntax for mistakes
Edit: What line you getting error on?
Edit again: try this naw:
PHP Code:elseif (isset($_POST['remoteUpload'])) {
$urls = explode("\n", $_POST['remoteimage']);
$imgarray = array();
foreach ($urls as $url) {
$imgname = basename($url);
$localimg = $uploadDir .'/'. $imgname;
// Requirements
$pixels = getimagesize($url); // Get image size in pixels for remote.
$width2 = $pixels[0];
$height2 = $pixels[1];
$exten = substr($url, strrpos($url, '.') + 1); // The "strrpos" approach to get the extension.
$ch = curl_init($url); // Get the filesize using curl
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$remoteSize = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$remoteSize = (int)$matches[1];
}
$imageKB = round(($remoteSize / 1024), 2); // bytes to KB
$imageMB = round(($remoteSize / 1048576), 2); // bytes to MB
$allowedext = array("jpg", "jpeg", "png", "x-png", "gif", "bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
if (in_array($exten, $allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 < $maxWidth && $height2 < $maxHeight )) {
$img = file_get_contents($url);
file_put_contents($localimg, $img);
$newname = time().'.'.$exten;
$newImage = $uploadDir .'/'.$newname;
rename($localimg, $newImage);
$param = '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
$BBCode2 = htmlspecialchars_decode($param);
//Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
$newThumbImg = imagecreatefromstring(file_get_contents($fileURL));
$ratio = $width2 / $height2; // calculate the ratio
if ($ratio > 1 ) {
$newW = $thumbPixels;
$newH = $thumbPixels / $ratio;
} else {
$newH = $thumbPixels;
$newW = $thumbPixels * $ratio;
}
//function for resize image.
if ( function_exists ( 'imagecreatetruecolor' ) ) {
$newImg = imagecreatetruecolor($newW, $newH);
} else {
die("Error: Please make sure you have GD library ver 2+");
}
//the resizing is going on here!
imagecopyresized($newImg, $newThumbImg, 0, 0, 0, 0, $newW, $newH, $width2, $height2);
$imageFileClean = preg_replace("/Resource id #6/", "", $newname);
//finally, save the image
ImageJpeg ($newImg, $thumbDir . $newname);
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
echo "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
<div align='center'><a href='$uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
<table width='100%' style='margin: 0 auto;'>
<tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
<tr><td class='select_text' align='right'>Direct Image Link:</td>
<td><input tabindex='1' value='$siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
<tr><td class='select_text' align='right'>HTML Link:</td>
<td><input tabindex='2' value='".htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
<tr><td class='select_text' align='right'>Code:</td>
<td><input tabindex='1' value='".$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
<tr><td class='select_text' align='right'>Thumbnail (90px):</td>
<td><input tabindex='1' value='$siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
<td><input tabindex='1' value='$siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
}
else
echo "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>";
}
} // < attempting a remote upload and all checks.
-
21st Jul 2011, 01:17 PM #8OPBannedWebsite's:
WarezRelease.org ThatHosting.coLine 334 which wud be the bit wheere it says else
-
21st Jul 2011, 01:18 PM #9Respected MemberWebsite's:
DL4Everything.com Soft2050.inPHP Code:elseif (isset($_POST['remoteUpload'])) {
$urls = explode("\n", $_POST['remoteimage']);
$imgarray = array();
foreach ($urls as $url) {
$imgname = basename($url);
$localimg = $uploadDir .'/'. $imgname;
// Requirements
$pixels = getimagesize($url); // Get image size in pixels for remote.
$width2 = $pixels[0];
$height2 = $pixels[1];
$exten = substr($url, strrpos($url, '.') + 1); // The "strrpos" approach to get the extension.
$ch = curl_init($url); // Get the filesize using curl
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
echo 'cURL failed';
exit;
}
$remoteSize = 'unknown';
$status = 'unknown';
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {
$status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {
$remoteSize = (int)$matches[1];
}
$imageKB = round(($remoteSize / 1024), 2); // bytes to KB
$imageMB = round(($remoteSize / 1048576), 2); // bytes to MB
$allowedext = array("jpg", "jpeg", "png", "x-png", "gif", "bmp"); // only these for remote files, why we can't use the $allowed array is beyond me, -prolly a simple thing to do LOL.
if (in_array($exten, $allowedext) && ( $imageKB <= $maxfileSize ) && ( $width2 < $maxWidth && $height2 < $maxHeight )) {
$img = file_get_contents($url);
file_put_contents($localimg, $img);
$newname = time().'.'.$exten;
$newImage = $uploadDir .'/'.$newname;
rename($localimg, $newImage);
$param = '[IMG]'.$siteURL.'/'.$uploadDir.'/'.$newname.'[/IMG]';
$BBCode2 = htmlspecialchars_decode($param);
//Make a 90x90px thumbnail......
$fileURL = ($uploadDir . '/' . $newname);
//echo $fileURL;
$newThumbImg = imagecreatefromstring(file_get_contents($fileURL));
$ratio = $width2 / $height2; // calculate the ratio
if ($ratio > 1 ) {
$newW = $thumbPixels;
$newH = $thumbPixels / $ratio;
} else {
$newH = $thumbPixels;
$newW = $thumbPixels * $ratio;
}
//function for resize image.
if ( function_exists ( 'imagecreatetruecolor' ) ) {
$newImg = imagecreatetruecolor($newW, $newH);
} else {
die("Error: Please make sure you have GD library ver 2+");
}
//the resizing is going on here!
imagecopyresized($newImg, $newThumbImg, 0, 0, 0, 0, $newW, $newH, $width2, $height2);
$imageFileClean = preg_replace("/Resource id #6/", "", $newname);
//finally, save the image
ImageJpeg ($newImg, $thumbDir . $newname);
ImageDestroy ($newImg);
ImageDestroy ($newThumbImg);
echo "<div align='center'><h1>You've just successfully uploaded <a href='$uploadDir/$newname'>$newname</a> with the following specifications ($imageKB KB / $imageMB MB and $width2 x $height2 pixels).</h1></div><br />
<div align='center'><a href='$uploadDir/$newname' rel='lightbox'><img src='$uploadDir/$newname' width='95%' alt='$newname'></a></div><br />
<table width='100%' style='margin: 0 auto;'>
<tr><td><h1><img src='site_images/IMGHost.png'> Direct Image Links</h1></td></tr>
<tr><td class='select_text' align='right'>Direct Image Link:</td>
<td><input tabindex='1' value='$siteURL/$uploadDir/$newname' onclick='this.focus();this.select();' size='65' /></td><tr>
<tr><td class='select_text' align='right'>HTML Link:</td>
<td><input tabindex='2' value='".htmlspecialchars_decode("<a href=\"$siteURL/$uploadDir/$newname\"><img src=\"$siteURL/$uploadDir/$newname\" border=\"0\"></a>")."' onclick='this.focus();this.select();' size='65'/></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> BBCode (Forums)</h1></td></tr>
<tr><td class='select_text' align='right'>Code:</td>
<td><input tabindex='1' value='".$BBCode2."' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td><h1><img src='site_images/IMGHost.png'> Avatar/Profile Thumbnail</h1></td></tr>
<tr><td class='select_text' align='right'>Thumbnail (90px):</td>
<td><input tabindex='1' value='$siteURL/$thumbDir$newname' onclick='this.focus();this.select();' size='65' /></td></tr>
<tr><td class='select_text' align='right'>Your Custom Thumbnail:</td>
<td><input tabindex='1' value='$siteURL/$customThumbDir/Custom_$newname' onclick='this.focus();this.select();' size='65' /></td></tr></table>";
}
else {
echo "<p align='center' classs='select_text'>You have submitted an invalid extension/larger file size than we accept or the dimensions are too big.</p>";
}
}
} // < attempting a remote upload and all checks.
-
21st Jul 2011, 01:32 PM #10OPBannedWebsite's:
WarezRelease.org ThatHosting.coThat works gr8, ty...
ps. i forgot, did i donate to u? if not pm me ur PP id i can send a few $$.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Remote Upload VS FTP VS Z-o-o-m
By simoestcoool in forum Polling PlazaReplies: 17Last Post: 29th Aug 2012, 01:00 PM -
filesonic not pass between them and the fileserve remote file upload to upload the ot
By uvb76 in forum File Host DiscussionReplies: 3Last Post: 28th Apr 2011, 12:28 PM -
Torrent upload in Shareflare.net. High-speed remote upload on the server
By Shareflare in forum File Host DiscussionReplies: 10Last Post: 27th Mar 2011, 05:06 AM -
HF remote upload
By tut2tut in forum Technical Help Desk SupportReplies: 8Last Post: 1st Mar 2011, 07:52 PM -
FileMo - $10 for 1000 downloads - Remote Upload - Huge Upload limit - All Countries!!
By awaisuk in forum Affiliate Programs PromotionReplies: 7Last Post: 11th Jun 2010, 04:41 AM
themaCreator - create posts from...
Version 3.20 released. Open older version (or...