 |
boardom b2 message board
|
View previous topic :: View next topic |
Author |
Message |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Mon May 27, 2002 9:38 am Post subject: |
|
|
Mmmm I don't have any error
You should check the code above my part... I think it comes from here...
Or send me your PHP file, I'll do what I can
Benjy. |
|
Back to top |
|
 |
tricky
Joined: 22 May 2002 Posts: 7
|
Posted: Mon May 27, 2002 2:09 pm Post subject: Here ya go |
|
|
Code: |
<?php
/* b2 File Upload - original hack by shockingbird.com */
$standalone="1";
include_once("./b2header.php");
if ($user_level == 0) //Checks to see if user has logged in
die ("Cheatin' uh ?");
if (!$use_fileupload) //Checks if file upload is enabled in the config
die ("The admin disabled this function");
?><html>
<head>
<title>b2 > upload images/files</title>
<link rel="stylesheet" href="<?php echo $b2inc; ?>/b2.css" type="text/css">
<?php if ($use_spellchecker) { ?>
<script type="text/javascript" language="javascript" src="<?php echo $spch_url; ?>"></script><?php } ?>
<style type="text/css">
<!--
body {
background-image: url('<?php
if ($is_gecko || $is_macIE) {
?>b2-img/bgbookmarklet1.gif<?php
} else {
?>b2-img/bgbookmarklet3.gif<?php
}
?>');
background-repeat: no-repeat;
margin: 30px;
}
<?php
if (!$is_NS4) {
?>
textarea,input,select {
background-color: white;
/*<?php if ($is_gecko || $is_macIE) { ?>
background-image: url('b2-img/bgbookmarklet.png');
<?php } elseif ($is_winIE) { ?>
background-color: #cccccc;
filter: alpha(opacity:80);
<?php } ?>
*/ border-width: 1px;
border-color: #cccccc;
border-style: solid;
padding: 2px;
margin: 1px;
}
<?php if (!$is_gecko) { ?>
.checkbox {
border-width: 0px;
border-color: transparent;
border-style: solid;
padding: 0px;
margin: 0px;
}
.uploadform {
background-color: white;
<?php if ($is_winIE) { ?>
filter: alpha(opacity:100);
<?php } ?>
border-width: 1px;
border-color: #333333;
border-style: solid;
padding: 2px;
margin: 1px;
width: 265px;
height: 24px;
}
<?php } ?>
<?php
}
?>
-->
</style>
<script type="text/javascript">
<!-- // idocs.com's popup tutorial rules !
function targetopener(blah, closeme, closeonly) {
if (! (window.focus && window.opener))return true;
window.opener.focus();
if (! closeonly)window.opener.document.post.content.value += blah;
if (closeme)window.close();
return false;
}
//-->
</script>
</head>
<body>
<table align="center" width="100%" height="100%" cellpadding="15" cellspacing="0" border="1" style="border-width: 1px; border-color: #cccccc;">
<tbody>
<tr>
<td valign="top" style="background-color: transparent; <?php if ($is_gecko || $is_macIE) { ?>background-image: url('b2-img/bgbookmarklet.png');<?php } elseif ($is_winIE) { ?>background-color: #cccccc; filter: alpha(opacity:60);<?php } ?>;">
<?php
if (!$HTTP_POST_VARS["submit"]) {
$i = explode(" ",$fileupload_allowedtypes);
$i = implode(", ",array_slice($i, 1, count($i)-2));
?>
<p><strong>File upload</strong></p>
<p>You can upload files of type:<br /><em><?php echo $i ?></em></p>
<p>The maximum size of the file should be:<br /><em><?php echo $fileupload_maxk ?> KB</em></p>
<form action="b2upload.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $fileupload_maxk*1024 ?>" />
<input type="file" name="img1" size="30" class="uploadform" />
<br />
<input type="submit" name="submit" value="upload !" class="search" />
</form>
</td>
</tr>
</tbody>
</table>
</body>
</html><?php die();
}
?>
<?php //Makes sure they choose a file
function RatioResizeImgGD($src_file, $dest_file, $newWidth) {
// find the image size & type
if(!function_exists('imagecreate')){return $src_file;}
$imginfo = @getimagesize($src_file);
switch($imginfo[2]) {
case 1: $type = IMG_GIF; break;
case 2: $type = IMG_JPG; break;
case 3: $type = IMG_PNG; break;
case 4: $type = IMG_WBMP; break;
default: return $src_file; break;
}
switch($type) {
case IMG_GIF:
if(!function_exists('imagecreatefromgif')){return $src_file;}
$srcImage = @imagecreatefromgif("$src_file");
break;
case IMG_JPG:
if(!function_exists('imagecreatefromjpeg')){return $src_file;}
$srcImage = @ImageCreateFromJpeg($src_file);
break;
case IMG_PNG:
if(!function_exists('imagecreatefrompng')){return $src_file;}
$srcImage = @imagecreatefrompng("$src_file");
break;
case IMG_WBMP:
if(!function_exists('imagecreatefromwbmp')){return $src_file;}
$srcImage = @imagecreatefromwbmp("$src_file");
break;
default: return $src_file;
}
if($srcImage){
// height/width
$srcWidth = $imginfo[0];
$srcHeight = $imginfo[1];
$ratioWidth = $srcWidth/$newWidth;
$destWidth = $newWidth;
$destHeight = $srcHeight / $ratioWidth;
// resize
$destImage = @imagecreate($destWidth, $destHeight);
imagecopyresized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
// create and save final picture
switch($type){
case IMG_GIF: @imagegif($destImage, "$dest_file"); break;
case IMG_JPG: @imagejpeg($destImage, "$dest_file"); break;
case IMG_PNG: @imagepng($destImage, "$dest_file"); break;
case IMG_WBMP: @imagewbmp($destImage, "$dest_file"); break;
}
// free the memory
@imagedestroy($srcImage);
@imagedestroy($destImage);
return $dest_file;
}
else
{
return $src_file;
}
}
if ($img1_name != "") {
$imgtype = explode(".",$img1_name);
$imgtype = " ".$imgtype[count($imgtype)-1]." ";
if (!ereg($imgtype, $fileupload_allowedtypes)) {
die("This file type $imgtype is not allowed by the admin of this blog.");
}
$pathtofile = $fileupload_realpath."/".$img1_name;
$pathtothumb = $fileupload_realpath."/tn_".$img1_name;
$newWidth = 100; //Thumbnail's width
copy("$img1" , "$pathtofile") //Path to your images directory, chmod the dir to 777
or die("Couldn't Upload Your File to $pathtofile.");
RatioResizeImgGD($img1, $pathtothumb, $newWidth);
}
$img_info = @getimagesize($img1);
$img_width = $img_info[0] + 40;
$img_height = $img_info[1] + 40;
$piece_of_code = "<a href="#" onClick="window.open(\'$fileupload_url/$img1_name\',\'b2Image\',\'width=$img_width,height=$img_height,location=0,menubar=0,resizable=1,scrollbars=yes,status=0,toolbar=0\')"><img src="$fileupload_url/tn_$img1_name" border="0" alt="" /></a>";
?>
<p><strong>File uploaded !</strong></p>
<p>Your file <b><?php echo "$img1_name"; ?></b> was uploaded successfully !</p>
<p>Here's the code to display it:</p>
<p><form>
<!--<textarea cols="25" rows="3" wrap="virtual"><?php echo "<img src="$fileupload_url/$img1_name" border="0" alt="" />"; ?></textarea>-->
<input type="text" name="imgpath" value="<?php echo $piece_of_code; ?>" size="38" style="padding: 5px; margin: 2px;" /><br />
<input type="button" name="close" value="Add the code to your post !" class="search" onClick="targetopener('<?php echo $piece_of_code; ?>')" style="margin: 2px;" />
</form>
</p>
<p><strong>Image Details</strong>: <br />
name:
<?php echo "$img1_name"; ?>
<br />
size:
<?php echo round($img1_size/1024,2); ?> KB
<br />
type:
<?php echo "$img1_type"; ?>
</p>
<p align="right">
<form>
<input type="button" name="close" value="Close this window" class="search" onClick="window.close()" />
</form>
</p>
</td>
</tr>
</tbody>
</table>
</body>
</html>
|
|
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Mon May 27, 2002 5:17 pm Post subject: |
|
|
Well, right now I see 2 things which could give you errors:
- the blank lines between } and ?>, after your die();
- pasting from here on the forum adds (at least for me) spaces at the end of each line...
Benjy. |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Thu May 30, 2002 10:09 am Post subject: |
|
|
I updated the values added to the image size so that the popup window includes almost perfectly the image, with no scrolling (tested in IE6) : Quote: | $img_width = $img_info[0] + 14;
$img_height = $img_info[1] + 32; |
|
|
Back to top |
|
 |
incite
Joined: 20 Jun 2002 Posts: 2 Location: warren ohio
|
Posted: Thu Jun 20, 2002 9:08 pm Post subject: Argggghhh :\ |
|
|
Okay I tried that code out, and this is probably a newbie question, well, it is... but everytime i try to load a freakin gif or jpg it gives me:
"This file type jpg is not allowed by the admin of this blog."
Now I assume this is because on the signup form it says: You can upload files of type: and is just blank after that... question is, how do i get it so it will allow those types? thanks. |
|
Back to top |
|
 |
nessahead
Joined: 12 Mar 2002 Posts: 312 Location: Los Angeles, CA
|
Posted: Thu Jun 20, 2002 11:22 pm Post subject: |
|
|
Add in the file extensions of the files you'd like to upload, I think Like this:
Code: | $fileupload_allowedtypes = " jpg gif png "; |
_________________ raar! |
|
Back to top |
|
 |
incite
Joined: 20 Jun 2002 Posts: 2 Location: warren ohio
|
Posted: Fri Jun 21, 2002 2:02 am Post subject: Okay thanks... one other thing |
|
|
okay I got it uploading and thumbnailing, but its only working for jpg files... is this how its supposed to work? thought it was supposed tow ork for jpg / gif and a couple others.. |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Sat Jun 22, 2002 2:33 pm Post subject: |
|
|
It all depends on the options set by your host on the GD library...
Benjy. |
|
Back to top |
|
 |
mysteryman
Joined: 15 May 2002 Posts: 54 Location: Texas
|
Posted: Mon Jun 24, 2002 4:00 am Post subject: |
|
|
Here's my problem, I had to change copy to move_upload_file and it uploads, but it does not create a thumbnail, nor does the click on the add code to blog do anything when clicked. The server is Linux and GD is enabled. When I preview the page, there is nothing on it, when I go to the original b2upload.php, I can upload and see the pictures, so why doesn't it create a thumbnail and post it in my blog?
|
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Mon Jun 24, 2002 12:49 pm Post subject: |
|
|
Sorry but I'm not a linux fan, so someone else will have to help you on this |
|
Back to top |
|
 |
mysteryman
Joined: 15 May 2002 Posts: 54 Location: Texas
|
Posted: Tue Jun 25, 2002 12:14 am Post subject: |
|
|
I also tried something similar with a script in my b2 image folder that was supposed to creat a thumbnail from an uploaded image and it didn't work either. At least I can upload images and it will add the code to the blog.
 |
|
Back to top |
|
 |
mysteryman
Joined: 15 May 2002 Posts: 54 Location: Texas
|
Posted: Fri Jun 28, 2002 3:09 am Post subject: |
|
|
Just a thought here, but maybe the reason that it wont upload and make thumbs is because the server is in safe mode. Has anyone using a server that is in safe mode got this hack to work?
|
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Fri Jun 28, 2002 9:52 am Post subject: Try this for safe_upload... |
|
|
Replace Quote: | copy("$img1" , "$pathtofile") //Path to your images directory, chmod the dir to 777
or die("Couldn't Upload Your File to $pathtofile."); | with Quote: | if (function_exists("is_uploaded_file")) {
if (is_uploaded_file("$img1")) {
if (move_uploaded_file("$img1", "$pathtofile")) {
$img1 = $pathtofile;
}
else die("File move impossible.");
}
else die("File upload impossible.");
}
else die("Upload function doesn't exist."); |
Let us now if it worked
Benjy. |
|
Back to top |
|
 |
mysteryman
Joined: 15 May 2002 Posts: 54 Location: Texas
|
Posted: Fri Jun 28, 2002 11:07 am Post subject: Thumbnail |
|
|
It is closer to working now. It uploads, but the click to add code to blog does not work, but I can select it and copy and paste and it does thumbnail on the blog. I will not go to the full size when the thumbnail is clicked though, also the only quick tag that works now is the smilies. |
|
Back to top |
|
 |
.Chris
Joined: 30 Apr 2002 Posts: 186 Location: Hawaii
|
Posted: Mon Aug 26, 2002 4:49 am Post subject: |
|
|
Is anyone going to update this to work with the newer version of B2? |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2 © 2001, 2002 phpBB Group
|