Load images into comments

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 01-21-2008, 03:04 PM
New Pligger
Pligg Version: 9.9
Pligg Template: Default
 
Join Date: Jan 2008
Posts: 13
I am trying to put image upload capability into comments however I am having trouble with the code below.

the comment ID section is not working.
Can anyone help me with this.
I have this on comment_show.tpl

PHP Code:
{php}include('addphoto.php');{/php
and this is addtophoto.php

PHP Code:
      <?php
      mkdir
("images/commentimg/new7/{$comment_id}"0755);
        
mkdir("images/commentimg/thumb/new7/{$comment_id}"0755);
      
$idir "images/commentimg/new7/{$comment_id}";   // Path To Images Directory
      
$tdir "images/commentimg/thumb/new7/{$comment_id}";   // Path To Thumbnails Directory
      
$twidth "125";   // Maximum Width For Thumbnail Images
      
$theight "100";   // Maximum Height For Thumbnail Images
      
if (!isset($_GET['subpage'])) {   // Image Upload Form Below   ?>
        <form method="post" action="addphoto.php?subpage=upload" enctype="multipart/form-data">
         File:<br />
        <input type="file" name="imagefile" class="form">
        <br /><br />
        <input name="submit" type="submit" value="Sumbit" class="form">  <input type="reset" value="Clear" class="form">
        </form>
      <? } else  if (isset($_GET['subpage']) && $_GET['subpage'] == 'upload') {   // Uploading/Resizing Script
        
$url $_FILES['imagefile']['name'];   // Set $url To Equal The Filename For Later Use
        
if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") {
          
$file_ext strrchr($_FILES['imagefile']['name'], '.');   // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php
          
$copy copy($_FILES['imagefile']['tmp_name'], "$idir" $_FILES['imagefile']['name']);   // Move Image From Temporary Location To Permanent Location
          
if ($copy) {   // If The Script Was Able To Copy The Image To It's Permanent Location
            
print 'Image uploaded successfully.<br />';   // Was Able To Successfully Upload Image
            
$simg imagecreatefromjpeg("$idir" $url);   // Make A New Temporary Image To Create The Thumbanil From
            
$currwidth imagesx($simg);   // Current Image Width
            
$currheight imagesy($simg);   // Current Image Height
            
if ($currheight $currwidth) {   // If Height Is Greater Than Width
               
$zoom $twidth $currheight;   // Length Ratio For Width
               
$newheight $theight;   // Height Is Equal To Max Height
               
$newwidth $currwidth $zoom;   // Creates The New Width
            
} else {    // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height)
              
$zoom $twidth $currwidth;   // Length Ratio For Height
              
$newwidth $twidth;   // Width Is Equal To Max Width
              
$newheight $currheight $zoom;   // Creates The New Height
            
}
            
$dimg imagecreate($newwidth$newheight);   // Make New Image For Thumbnail
            
imagetruecolortopalette($simgfalse256);   // Create New Color Pallete
            
$palsize ImageColorsTotal($simg);
            for (
$i 0$i $palsize$i++) {   // Counting Colors In The Image
             
$colors ImageColorsForIndex($simg$i);   // Number Of Colors Used
             
ImageColorAllocate($dimg$colors['red'], $colors['green'], $colors['blue']);   // Tell The Server What Colors This Image Will Use
            
}
            
imagecopyresized($dimg$simg0000$newwidth$newheight$currwidth$currheight);   // Copy Resized Image To The New Image (So We Can Save It)
            
imagejpeg($dimg"$tdir" $url);   // Saving The Image
            
imagedestroy($simg);   // Destroying The Temporary Image
            
imagedestroy($dimg);   // Destroying The Other Temporary Image
            
print 'Image thumbnail created successfully.';   // Resize successful
          
} else {
            print 
'<font color="#FF0000">ERROR: Unable to upload image.</font>';   // Error Message If Upload Failed
          
}
        } else {
          print 
'<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg. Yours is ';   // Error Message If Filetype Is Wrong
          
print $file_ext;   // Show The Invalid File's Extention
          
print '.</font>';
        }

      } 
?>
Reply With Quote
  #2 (permalink)  
Old 01-21-2008, 09:59 PM
Banned
Pligg Version: 9.8.
Pligg Template: Custom
 
Join Date: Feb 2007
Location: Canada
Posts: 796
I tried to get it to work as well.

I got it to load the form in the comment form, but not attach an image.

Will keep working on it.

Geoserv.
Reply With Quote
  #3 (permalink)  
Old 03-13-2010, 04:10 PM
Ascendancy's Avatar
Constant Pligger/Coder
Pligg Version: 1.2.0
Pligg Template: Custom
 
Join Date: Jan 2008
Location: Boston, MA
Posts: 131
Send a message via AIM to Ascendancy
I know this is 2 years old, but this is a very interesting concept and I'd like to add this to my site as well. Did either of you end up finishing development on this add-in? If not I'd like to give it a shot, maybe I can develop something working

Pligg Developer for ~2 years
Snoggle News
Reply With Quote
  #4 (permalink)  
Old 03-13-2010, 08:01 PM
chuckroast's Avatar
Pligg Developer/Coder/Designer
Pligg Version: SVN
Pligg Template: Social Pro Kit
 
Join Date: Jun 2006
Posts: 5,448
Quote:
Originally Posted by Ascendancy View Post
I know this is 2 years old, but this is a very interesting concept and I'd like to add this to my site as well. Did either of you end up finishing development on this add-in? If not I'd like to give it a shot, maybe I can develop something working
The people what were discussing this are no longer with us. One by choice and one by being forced out of the community for being a complete tool.

The problem with this situation is, it would allow for people to add devious things to your site. It's a complete security hole.
This why no one has brought it up in 2 years. It's a ridiculous idea from a developers stand point.
Reply With Quote
  #5 (permalink)  
Old 03-13-2010, 08:55 PM
Ascendancy's Avatar
Constant Pligger/Coder
Pligg Version: 1.2.0
Pligg Template: Custom
 
Join Date: Jan 2008
Location: Boston, MA
Posts: 131
Send a message via AIM to Ascendancy
Maybe I'm missing something, but how would it be a destructive security hole? Especially if the upload field checked and only allowed specific images (PNG, JPG, or BMP) and displayed a thumbnail or something next to a comment? I am interested in spending time on developing this, I just don't see where the problem of security comes into play

EDIT:
I'm thinking a similar idea of comments on imageboards such as 4chan and 7chan

Pligg Developer for ~2 years
Snoggle News
Reply With Quote
  #6 (permalink)  
Old 03-13-2010, 09:11 PM
chuckroast's Avatar
Pligg Developer/Coder/Designer
Pligg Version: SVN
Pligg Template: Social Pro Kit
 
Join Date: Jun 2006
Posts: 5,448
First because there is no upload field to check.. It's a text comment box.
You could do this, but you would need to create a complete module for it, and in Pliggs' current form there isn't the module hooks in place to make at a complete module. IE: you would need to modify multiple core files.

Its hard enough to make Pligg so people can't place manipulative code. Once you open comments up for people to add code as they please, you will be constantly chasing, closing holes, fixing, patching,.. It just becomes a nightmare. There is a reason why you don't see many open source CMS projects that will allow any kind of user uploading or embedding, let alone in a comment section.

There are some things as developers we do not wish to jump into.
Reply With Quote
  #7 (permalink)  
Old 03-15-2010, 02:00 AM
imic's Avatar
New Pligger
 
Join Date: Mar 2010
Posts: 7
loading images into comments is such a desirable feature, i really don't see why that was not considered. as for security; you have teh ban hammer for a reason
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
select images for submission in development ivytony Questions and Comments 74 02-20-2010 05:26 PM
Module. Load comments automatick with rss feeds MarioF Questions and Comments 8 05-27-2009 10:52 AM
[Solution] Limit Comments in Story page. manya1011 Questions and Comments 9 03-12-2008 07:26 PM
Comments, MYSQL Queries Simon Questions and Comments 7 05-06-2007 10:10 AM
[A Fix] Random Images Fail to Load Biomech Questions and Comments 0 03-07-2007 06:54 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development