(Italiano) Impaginare tabelle con i CSS

Sorry, this entry is only available in Italiano.

Embedding images in phplist messages

From phplist version 2.10.8 (maybe from some version earlier), there's the possibility to embed images directly into the email messages, avoiding the usage of the external link. You have just to put the following statement into config/config.php:

# Aggiunta di Gabo per permettere di inserire le immagini nel corpo del messaggio
define("EMBEDUPLOADIMAGES",1);

The problem was that it didn't work for me. No way. So I had a look into the code and I found the problem. There where no way to embed images stored in any subdirectory of what stated in:

# If you want to upload images to the FCKeditor, you need to specify the location
# of the directory where the images go. This needs to be writable by the webserver,
# and it needs to be in your public document (website) area
# the directory is relative to the root of PHPlist as set above
# This is a potential security risk, so read README.security for more information
define("FCKIMAGES_DIR","uploadimages");

Substituting filesystem_image_exists() and get_filesystem_image() functions (both in admin/class.phplistmailer.php) whith the code below worked, allowing me to embed images in mails even if them are in a directory different from uploadimages.

First of all, I added the following to the config file, just to permit embedding images when sending through cronjob and PHP-cli:

//ADDED BY GABO
$phplistRoot = '/home/mysite/public_html';
//END ADDED BY GABO
[/code]

Ecco le funzioni modificate:

[code lang="php"]
## addition for filesystem images - MODIFYED BY GABO
    function filesystem_image_exists($filename) {
      ##  find the image referenced and see if it's on the server

      $elements = parse_url($filename);
      $localfile = basename($elements['path']);

      // search for subdirectory
      $basePath = $GLOBALS['phplistRoot'].$GLOBALS['pageroot'].'/'.FCKIMAGES_DIR;
      $dir = substr($elements['path'],
                    strpos($elements['path'],FCKIMAGES_DIR)+strlen(FCKIMAGES_DIR),
                    strlen($elements['path']) -
                       strpos($elements['path'],FCKIMAGES_DIR) -
                       strlen(FCKIMAGES_DIR)-strlen($localfile));

      return is_file($basePath.$dir.$localfile);
    }

    function get_filesystem_image($filename) {
      ## get the image contents
      $elements = parse_url($filename);
      $localfile = basename($elements['path']);

      $basePath = $GLOBALS['phplistRoot'].$GLOBALS['pageroot'].'/'.FCKIMAGES_DIR;
      $dir = substr($elements['path'],
                    strpos($elements['path'],FCKIMAGES_DIR)+strlen(FCKIMAGES_DIR),
                    strlen($elements['path']) -
                       strpos($elements['path'],FCKIMAGES_DIR) -
                       strlen(FCKIMAGES_DIR)-strlen($localfile));

      if (is_file($basePath.$dir.$localfile)) {
        return base64_encode( file_get_contents($basePath.$dir.$localfile) );
      }
      return 0;
    }
    ## end addition - MODIFYED BY GABO

Hope it helps saving time to someone :)

(Italiano) GDate – Gestire le date in PHP

Sorry, this entry is only available in Italiano.

(Italiano) Gabo scala Google

Sorry, this entry is only available in Italiano.

(Italiano) Risolto l’enigma di via Messina

Sorry, this entry is only available in Italiano.