[Unsupported]: Email images to your gallery - Page 7 [Unsupported]: Email images to your gallery - Page 7
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

[Unsupported]: Email images to your gallery

Started by rphMedia, July 17, 2006, 08:30:16 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

radmofo

No belittling, intended. The files I uploaded do the same thing as your originals with refinements.  I simply named them something else to prevent utter confusion. (or cause it). As far as the basis for this functionality it works the same way.
If a MOD wants to move it to a new thread thats fine. Or just delete them, I was only trying to help.
Please give me some negative Karma. :)

rphMedia


jecepede

Aloha !!!!


As so many of you I thought it would be very nice to be able to mail my piccies to the gallery.
Well my computer apparently has other plans...

I have an e-mail account set up for my gallery : ongein (AT) wabbit-wion DOT nl
And my gallery resides at : http://ongein.wabbit-wion.nl
I made an album in with visitors can upload (without approval) and vote named : Mailed-Stuff (album 45)
Which resides in the category : Things

Now the first thing that hits me as weird, when I run the newcam.php script from the browser I get :

Warning: imap_fetchstructure() [function.imap-fetchstructure]:
Bad message number in /home/www/ongein/htdocs/attachmentread.class.php on line 62


And the mail is gone from the account.

So I thought maybe my way of attaching files was incorrect so I tested it with sending a mail to the Muvipix gallery and it arrived.
It is the "Stupid Dad" pic, thank you for letting me (us) test...

Also, when I logout and browse as a Guest, I do not see an [UPLOAD] button in the Mailed-Stuff folder ?
Hey I tought I turned that on ?

I am completely at a loss ?
Could some one please push me in the right direction ???

I run CPG 1.4.18(Stable)


Thank you sooooooooooo much in advance....


Jessy


OH PS :

Here is my newcam.php
Quote<?php
define('IN_COPPERMINE', true);
require('include/picmgmt.inc.php');
require_once("attachmentread.class.php");
$host="{imap.wabbit-wion.nl:143/imap4/novalidate-cert}"; // imap4host
$login="ongein (AT) wabbit-wion DOT nl"; //imap4 login
$password="nothingspecialhere"; //imap4 password
$filepath=$_SERVER["DOCUMENT_ROOT"]."/albums/pix/";  ; // attachement will save in same directory where scripts run, otherwise give abs path
$album="45"; // album id #
$folder = "pix/"; // foldername with a /
$jk=new readattachment(); // Creating instance of class####
$jk->getdata($host,$login,$password,$filepath,$album,$folder); // calling member function
?>

And my attachment.class.php
Quote<?
                        ######################################

                        #Coded By Jijo Last Update Date[Jan/19/06]
                        #http://phpclasses.org

                        #####################################




                        ##########################################################


                        ###################### Class readattachment ###############
class readattachment
{
                function getdecodevalue($message,$coding)
                {
                if ($coding == 0)
                {
                   $message = imap_8bit($message);
                }
                elseif ($coding == 1)
                {
                  $message = imap_8bit($message);
                }
                elseif ($coding == 2)
                {
                   $message = imap_binary($message);
                }
                elseif ($coding == 3)
                {
           $message=imap_base64($message);
           }
                elseif ($coding == 4)
                {
                   $message = imap_qprint($message);
                }
                elseif ($coding == 5)
                {
                 $message = imap_base64($message);
                }
                return $message;
                }

                        function getdata($host,$login,$password,$filepath,$album,$folder)
                        {
                        $mbox = imap_open ($host,  $login, $password) or die("can't connect: " . imap_last_error());
                        $message = array();
                        $message["attachment"]["type"][0] = "text";
                        $message["attachment"]["type"][1] = "multipart";
                        $message["attachment"]["type"][2] = "message";
                        //$message["attachment"]["type"][3] = "application";
                        $message["attachment"]["type"][4] = "audio";
                        $message["attachment"]["type"][5] = "image";
                        $message["attachment"]["type"][6] = "video";
                        $message["attachment"]["type"][7] = "other";

                        for ($jk = 1; $jk <= imap_num_msg($mbox); $jk++)
                        {
                        $structure = imap_fetchstructure($mbox, $jk , FT_UID);
                        $parts = $structure->parts;
                        $fpos=2;
                                        for($i = 1; $i < count($parts); $i++)
                                           {
                                                $message["pid"][$i] = ($i);
                                                $part = $parts[$i];

                                                if($part->disposition == "ATTACHMENT")
                                                        {
                                                $message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
                                                        $message["subtype"][$i] = strtolower($part->subtype);
                                                        $ext=$part->subtype;
                                                        $params = $part->dparameters;
                                                        $filename=$part->dparameters[0]->value;

                                                                $mege="";
                                                                        $data="";
                                                                        $mege = imap_fetchbody($mbox,$jk,$fpos);
                                                                        $fp=fopen($filepath . $filename,w);
                                                                        $data=$this->getdecodevalue($mege,$part->type);

                                                                        fputs($fp,$data);
                                                                        fclose($fp);
                                                                        add_picture($album, $folder, $filename);
                                                                        $fpos+=1;

                                                        }

                                        }
                        imap_delete($mbox,$jk);
                        }
                        imap_expunge($mbox);
                        imap_close($mbox);
                        }
}
?>

jecepede

Okie


I am very sorry to bother everyone...

$album="45"; // album id #

Didn't do the trick...
It should of been :

$album="54"; // album id #


CHEEEEEEEEEEEEEEEERS !


GREAT mod, works out-of-the-box :D



Jessy


radmofo

Glad to hear you ironed it out! Good work.
Please give me some negative Karma. :)

stuffradio

I'm not using the script for coppermine, but I am using it for another gallery website thing... and I'm trying to figure out why it won't read alternative files with the content type "multipart/related".


<?php

            
######################################

            #Coded By Jijo Last Update Date[Jan/19/06]

            #####################################




            ##########################################################


            ###################### Class readattachment ###############
class Readattachment
{
 var 
$username;
 var 
$encrypted;
 var 
$pic;
 var 
$time;
 var 
$url;
 var 
$caption;
 var 
$tag;
 var 
$mes;

     function 
Readattachment()
     {
       
$this->CI=& get_instance();

     }
     
     function 
checkExists($username$password)
     {
       
$query $this->CI->db->get_where('project_users', array('username' => $username'password' => $password));
       if (
$query->num_rows() > 0)
       {
         return 
true;
       } else {
         return 
false;
         exit;
       }
     }


     function 
checkAndUpload($arg$pic)
     {

preg_match("#username: ([a-zA-Z0-9]+)#i",$arg,$username);
$username $username[1];
preg_match("#password: ([a-zA-Z0-9]+)#i",$arg,$password);
$password $password[1];
preg_match("#caption: ([a-zA-Z0-9]+)#i",$arg,$caption);
$caption 'Default';
$encrypted md5($password);
$this->checkExists($username$encrypted);
$this->uploadData($username$encrypted$pictime(), ''$caption'nsfw');
     }


        function 
getdecodevalue($message,$coding)
        {
        if (
$coding == 0)
        {
           
$message imap_8bit($message);
        }
        elseif (
$coding == 1)
        {
          
$message imap_8bit($message);
        }
        elseif (
$coding == 2)
        {
           
$message imap_binary($message);
        }
        elseif (
$coding == 3)
        {
       
$message=imap_base64($message);
       }
        elseif (
$coding == 4)
        {
           
$message imap_qprint($message);
        }
        elseif (
$coding == 5)
        {
         
$message imap_base64($message);
        }
        return 
$message;
        }

            function 
getdata($host,$login,$password,$savedirpath)
            {
 
$mbox imap_open ($host,  $login$password) or die("can't connect: " imap_last_error());
         
$message = array();
         
$message["attachment"]["type"][0] = "text";
         
$message["attachment"]["type"][1] = "multipart";
         
$message["attachment"]["type"][2] = "message";
         
//$message["attachment"]["type"][3] = "application";
         //$message["attachment"]["type"][4] = "audio";
         
$message["attachment"]["type"][5] = "image";
         
//$message["attachment"]["type"][6] = "video";
         
$message["attachment"]["type"][7] = "other";
         
         for (
$jk 1$jk <= imap_num_msg($mbox); $jk++)
         {
        
$headerinfo imap_header($mbox$jk);

        
$subject $headerinfo->Subject;
                        
$matches = array();
                        if (
preg_match('/^=\?[^?]*\?B\?(.*)\?=/m'$subject$matches))
                                
$subject base64_decode($matches[1]);

         
$structure imap_fetchstructure($mbox$jk FT_UID);   
         
$parts $structure->parts;
         
$fpos=1;
    for(
$i 0$i count($parts); $i++)
{
                  
$message["pid"][$i] = ($i);
                  
$part $parts[$i];
if (
$part->type == 0) {
        
$fpos+=1;
        continue;
    }


                  if(
TRUE)
                     {
                      
                      
$message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" strtolower($part->subtype);
                     
$message["subtype"][$i] = strtolower($part->subtype);
                     
$ext=$part->subtype;
                if (
$part->ifdparameters)
                  foreach(
$part->dparameters as $dparam)
                    if (
strtolower($dparam->attribute) == 'filename'$filename $dparam->value;
                if (empty(
$filename))
                  if (
$part->ifparameters)
                    foreach(
$part->parameters as $param)
                      if (
strtolower($param->attribute) == 'name'$filename $param->value;

if (empty(
$filename) && $part->ifid)
        
$filename trim($part->id'<>');


     if (empty(
$filename)) $filename 'nfn' rand() . '.' strtolower($part->subtype);



                               
$mege="";
                               
$data="";
                               
$mege imap_fetchbody($mbox,$jk,$fpos);
                               
$body imap_body($mbox$jk);

                           
$fp=fopen($savedirpath $filename,w);
                           
$data=$this->getdecodevalue($mege,$part->type);
                           
fputs($fp,$data);
                           
fclose($fp);
                           
$this->checkAndUpload($body$filename);
                           
$fpos+=1;



                     }

               }
         
imap_delete($mbox,$jk);
         }
         
imap_expunge($mbox);
         
imap_close($mbox);
         }

         
           function 
uploadData($username$encrypted$pic$time$url$caption$tag)
            {
        
$this->CI->db->insert('pb_photos', array('time' => time(), 'pic' => $pic'url' => base_url() . 'system/application/views/uploads/''caption' => $caption'poster' => $username'tag' => $tag));

            }


            }
?>


I commented out a couple attachment types because I only want images to be uploaded. If you see any easy solution to this, please let me know. It downloads the attachment from the multipart/related, but saves as something like nfn242525.alternative. So the folder path isn't what's wrong here... it's the saving part that is wrong.

rphMedia

I am no longer supporting this mod/hack. I've removed the email address as some people still want to send humongous images to try to take my test gallery down. It's pretty senseless because once I see that the image is larger than most monitor resolutions ( don't know what they're thinking sending 4000px X 3000px rez images ??? ), the email was immediately deleted and subsequently the image never made it to the album.

Well, no more extra work managing the email account.

You may lock this thread, guys.

Joachim Müller

It's sad to see this nice little mod go down because of jerks misbehaving, but I guess this is how the internet works. So I'm locking this thread as per suggestion. To everyone else: rphMedia said the mod will go unsupported, so there is no point in starting another thread asking for support on this mod. "Unsupported" means exactly what the word says: no support at all.