68 Classifieds Forums  

Go Back   68 Classifieds Forums > v3.1.x Help & Support > v3.1 Modules
Register Projects FAQ Members List Calendar Search Today's Posts Mark Forums Read

v3.1 Modules A forum for discussions, questions, implementation and development of modules. Questions here are beyond "typical" 68classifieds support and not supported by the 68classifieds team.

 
Thread Tools Display Modes
  #21  
Old 08-13-2007, 04:54 PM
free2take's Avatar
free2take free2take is offline
Senior Member
 
Join Date: Mar 2006
Location: Ireland
Posts: 172
Default

Basically if I highlight the file and chmo it to 777 in filezilla it'll work but I think the bit that it needs is public write access.

Am I correct in thinking though if I give this any joe bloggs can come along and edit someone elses photo just by browsing to the site link ?
__________________
www.free2take.net
Don't lose it just reuse it!
V 3.1
Reply With Quote
  #22  
Old 08-13-2007, 04:56 PM
suzkaw suzkaw is offline
Trained to break arms!
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 2,472
Default

I was thinking you just used GD to place an image overlay if it was already sold. Are you doing this some other way?
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Knowledge Base | User Manuals | My Blog
Reply With Quote
  #23  
Old 08-13-2007, 05:02 PM
free2take's Avatar
free2take free2take is offline
Senior Member
 
Join Date: Mar 2006
Location: Ireland
Posts: 172
Default

I have a php class (hacked from the web based on litestamp) which uses the imagecopymerge function to put my stamp over the original photo and thumbnail this is combined with a class of my own to call the functionality from the userbrowselistings template.

It works pretty well but it just doesn't seem to run if the photo or thumb file in question does not have that write access.

I've attached the stamping class. The stampPicture function does the nuts and bolts of it and takes your original pic, stamp image to merge and if you want you can rename the output file - I haven't though.

PHP Code:
class LiteStamp{

        
// class variables
        
var $fileHandle = null;
        var
$newPictureName = null;
        var
$pictureInfo = null;
        var
$pictureName = null;
        var
$prefix = null;
        var
$stampInfo = null;
        var
$stampName = null;
        var
$stampXpos = null;
        var
$stampYpos = null;
                
                
//PHP 4 doesn't like this
    //   function __construct($picture, $stamp, $prefix = ''){
//
//               $this->pictureName = $picture; // original picture to place stamp/watermark on
  //              $this->stampName = $stamp; // stamp/watermark picture
   //             $this->prefix = $prefix; // prefix of new stamped picture

        //} end of construct

//        public static function GDversion(){

                // GD 2.0.28 or newer is recommended version to use
                // http://www.php.net/manual/en/function.gd-info.php
                //var_dump(gd_info()); // dump information about your GD version

//        return true;
//       }// end of GDversion

        
function openImage($fileName, $type){

                
// open picture with correct image function. Add more types if needed.
                // GIF: http://php.net/manual/en/function.imagecreatefromgif.php
                // JPG/JPEG: http://php.net/manual/en/function.imagecreatefromjpeg.php
                // PNG: http://php.net/manual/en/function.imagecreatefrompng.php
                
switch ($type){

                case
1: // GIF
                        
$this->fileHandle = imagecreatefromgif($fileName);
                        break;
// case 1

                
case 2: // JPG/JPEG
                        
$this->fileHandle = imagecreatefromjpeg($fileName);
                        break;
// case 2

                
case 3: // PNG
                        
$this->fileHandle = imagecreatefrompng($fileName);
                        break;
// case 3

                
default:
                        die(
'Unsupported filetype: '.$fileName);
                }

        return
$this->fileHandle;
        }
// end of openImage                
                

        
function stampPicture($picture, $stamp, $prefix){
                
                                
$this->pictureName = $picture; // original picture to place stamp/watermark on
                
$this->stampName = $stamp; // stamp/watermark picture
                
$this->prefix = $prefix; // prefix of new stamped picture

                // get picture info such as width, height and extension
                // http://php.net/manual/en/function.getimagesize.php

                                
echo $this->pictureInfo;
                
$this->pictureInfo = getimagesize($this->pictureName) or die($this->pictureInfo.' Error getting picture info. Double check file path.');
                
$this->stampInfo = getimagesize($this->stampName) or die('Error getting stamp info. Double check file path.');
                                
                
// open images with class method openImage()
                
$this->pictureFile = $this->openImage($this->pictureName, $this->pictureInfo[2]);
                
$this->stampFile = $this->openImage($this->stampName, $this->stampInfo[2]);                                                                                                                                        
                                
                                
// alpha blending: http://php.net/manual/en/function.imagealphablending.php
                
imagealphablending($this->pictureFile, true);                                                            

                
//middle
                
if( $pos == 0 )
                {
                    
$dest_x = ( $sourcefile_width / 2 ) - ( $insertfile_width / 2 );
                    
$dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 );
                }

                                
$this->stampXpos = ($this->pictureInfo[0] / 2) - ($this->stampInfo[0] / 2);
                                
$this->stampYpos = ($this->pictureInfo[1] / 2) - ($this->stampInfo[1] / 2);             

                
// set a new name for the stamped picture and keep the original picture intact
                
$this->newPictureName = $this->prefix.$this->pictureName;

                
// merge the two images: http://php.net/manual/en/function.imagecopymerge.php
                
imagecopymerge($this->pictureFile, $this->stampFile, $this->stampXpos, $this->stampYpos, 0, 0, $this->stampInfo[0], $this->stampInfo[1], 100);
                                                                
                
// output the stamped image as GIF, JPG/JPEG or PNG. Add more types if needed.
                // default type is the same as the original file
                // GIF: http://php.net/manual/en/function.imagegif.php
                // JPG/JPEG: http://php.net/manual/en/function.imagejpeg.php
                // PNG: http://php.net/manual/en/function.imagepng.php
                
switch ($this->pictureInfo[2]){

                case
1: // GIF
                        
imagegif($this->pictureFile, $this->newPictureName);
                        break;
// case 1

                
case 2:// JPG/JPEG
                        
imagejpeg($this->pictureFile, $this->newPictureName);
                        break;
// case 2

                
case 3: // PNG
                        
imagepng($this->pictureFile, $this->newPictureName);
                        break;
// case 3

                
default:
                        die(
'Unsupported filetype: '.$fileName);

            }

        return
true;
        }
// end of stampPicture

        

        
function destruct(){
                unset(
$fileHandle, $newPictureName, $pictureInfo, $pictureName, $prefix, $stampInfo, $stampName, $stampXpos, $stampYpos);
        }
// end of destruct



}// end of class
__________________
www.free2take.net
Don't lose it just reuse it!
V 3.1
Reply With Quote
  #24  
Old 08-13-2007, 05:10 PM
suzkaw suzkaw is offline
Trained to break arms!
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 2,472
Default

Well I though that would work without being chmod to 777. Maybe I am wrong.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Knowledge Base | User Manuals | My Blog
Reply With Quote
  #25  
Old 08-13-2007, 05:19 PM
free2take's Avatar
free2take free2take is offline
Senior Member
 
Join Date: Mar 2006
Location: Ireland
Posts: 172
Default

I just retried there - unfortunately not it only seems to let this merge happen if you change the file to public access.
__________________
www.free2take.net
Don't lose it just reuse it!
V 3.1
Reply With Quote
  #26  
Old 08-14-2007, 03:45 PM
free2take's Avatar
free2take free2take is offline
Senior Member
 
Join Date: Mar 2006
Location: Ireland
Posts: 172
Default

Hmmh very strange.

When ftp'd into site as admin I cannot chmod photos which I did not post, surely as admin I should be able to change the permissions on any photos I choose.

You are right about the write permission the class_upload.php file sets the photos to chmod 0644 (tried just changing this to 0777 makes no diff) which should be fine to write to provided they are in a folder which is at 777 so I shouldn't get this issue, but the upload must do something to mean that only the owner of the file can change its settings there after.

Additionally if I just try and chmod the photo prior to stamping it, it won't let me do it.

Any ideas, anyone ? anywhere ? anyhow ? have all the code here ready to post this up for all this is pretty much the last hurdle, I hope....
__________________
www.free2take.net
Don't lose it just reuse it!
V 3.1

Last edited by free2take : 08-14-2007 at 03:56 PM.
Reply With Quote
  #27  
Old 08-14-2007, 04:16 PM
suzkaw suzkaw is offline
Trained to break arms!
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 2,472
Default

From what I have seen a lot of web servers will set the owner of file uploads to NOBODY. Which means you can't change the chmod or delete it unless through the file system.

I just took a few minutes and found an article for using an overlay and you can see the results here:
http://www.68classifieds.com/v4/test...e=habitacl.jpg
http://www.68classifieds.com/v4/test...e=moteurr1.jpg

That may be a better system but you would have to call the image like this:
<img src="test.php?image=myimage.jpg" />

Basically pass a variable for the original image that you want to overlay.

Here is a link to that article if you want it:
http://www.codewalkers.com/c/a/Misce...mages-with-GD/

And here is a copy of the script:
PHP Code:
<?php
  
// The header line informs the server of what to send the output
  // as. In this case, the server will see the output as a .png
  // image and send it as such

  
header ("Content-type: image/png");


  
// Defining the background image. Optionally, a .jpg image could
  // could be used using imagecreatefromjpeg, but I personally
  // prefer working with png

  
$orig = $_GET['image'];
  
$background = imagecreatefromjpeg("http://www.68classifieds.com/v4/thumbs/small_".$orig);


  
// Defining the overlay image to be added or combined.

  
$insert = imagecreatefrompng("http://www.68classifieds.com/v4/sold.png");


  
// Select the first pixel of the overlay image (at 0,0) and use
  // it's color to define the transparent color

  
imagecolortransparent($insert,imagecolorat($insert,0,0));


  
// Get overlay image width and hight for later use

  
$insert_x = imagesx($insert);
  
$insert_y = imagesy($insert);


  
// Combine the images into a single output image. Some people
  // prefer to use the imagecopy() function, but more often than
  // not, it sometimes does not work. (could be a bug)

  
imagecopymerge($background,$insert,50,10,0,0,$insert_x,$insert_y,100);


  
// Output the results as a png image, to be sent to viewer's
  // browser. The results can be displayed within an HTML document
  // as an image tag or background image for the document, tables,
  // or anywhere an image URL may be acceptable.

  
imagepng($background,"",100);
?>
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Knowledge Base | User Manuals | My Blog
Reply With Quote
  #28  
Old 08-15-2007, 04:14 AM
free2take's Avatar
free2take free2take is offline
Senior Member
 
Join Date: Mar 2006
Location: Ireland
Posts: 172
Default

Thanks for that will be a handy reference going forward. I like the sold banner you are using looks much neater than mine I think any chance of a copy ??

I managed to get my original code working, the issue surrounded the fact that you need write access on the original uploaded photos but for some reason I didn't have it.

To side step this and its probably its a better solution anyhows I just copy the original photo and then work on the copy this way there are no issues doing the merge. The code also allows for gif \ png and jpg files.

**remove spaces in link address

You can see the results here http://www.e buy ni.com/viewlisting.php?view=492

I have allowed for several aspects in my code in relation to overall 'Mark As Sold' functionality such as if the sale falls through and the users wishes to relist, then his original photos are automatically reused without having to upload again.
When marking sold, the title of the ad and expiration date are changed as well as the status.
Also the user can easily control for how long the sold ad gets displayed.
Lastly if an uploaded photo does not match the baner size for performing the merge it will automatically be resized to suit.

If anyone is interested let me know and I can post code for this although be aware it is not a small change to make.
__________________
www.free2take.net
Don't lose it just reuse it!
V 3.1

Last edited by free2take : 08-15-2007 at 04:19 AM.
Reply With Quote
  #29  
Old 08-15-2007, 09:50 AM
suzkaw suzkaw is offline
Trained to break arms!
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 2,472
Default

Here is the image I used:
http://www.68classifieds.com/v4/sold.png
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Knowledge Base | User Manuals | My Blog
Reply With Quote
  #30  
Old 09-23-2007, 02:43 PM
donjh donjh is offline
Junior Member
 
Join Date: Mar 2007
Posts: 2
Default Sold Code

I would be interested in the code for marking items as sold.

Thanks

Dhamann
__________________
donjh
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with Featured items display sedonagate v3.1 Questions & Support 2 09-18-2006 12:18 PM
Adding Lines Between Items art v3.1 Questions & Support 6 07-23-2006 11:09 PM
We are sorry no items were found. Link CB v3.1 Questions & Support 2 06-28-2006 01:53 PM


All times are GMT -4. The time now is 07:56 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.