Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php// +------------------------------------------------------------------------+// | Email_Safe |// +------------------------------------------------------------------------+// | Copyright (c) 2000-2007 Markus Niewerth |// | Email markus@niewerth.com |// | Web http://www.gamerzzone.de |// | Mirror http://rapidtemplates.immony.de |// +------------------------------------------------------------------------+// | This source file is subject to version 3.00 of the PHP License, |// | that is available at http://www.php.net/license/3_0.txt. |// | If you did not receive a copy of the PHP license and are unable to |// | obtain it through the world-wide-web, please send a note to |// | license@php.net so we can mail you a copy immediately. |// +------------------------------------------------------------------------+// | License Informations |// +------------------------------------------------------------------------+// | Copyright (c) 2000-2007,Markus Niewerth |// | All rights reserved. |// | |// | Redistribution and use in source and binary forms, with or without |// | modification, are permitted provided that the following conditions |// | are met: |// | |// | o Redistributions of source code must retain the above copyright |// | notice, this list of conditions and the following disclaimer. |// | o Redistributions in binary form must reproduce the above copyright |// | notice, this list of conditions and the following disclaimer in the |// | documentation and/or other materials provided with the distribution. |// | o The names of the authors may not be used to endorse or promote |// | products derived from this software without specific prior written |// | permission. |// | |// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |// | |// +------------------------------------------------------------------------+// | Author: Markus Niewerth <markus@niewerth.com> |// +------------------------------------------------------------------------+/*** This file is part of the Content-Active CMS System.* This class is available in other abstractions.** This class handles template formates written in* Rapid_Template syntax. The syntax is shown in the* method itself. Or you could have a look in the* templates folder {@see templates/}.** PHP versions 4 and 5** LICENSE: This source file is subject to version 3.0 of the PHP license* that is available through the world-wide-web at the following URI:* http://www.php.net/license/3_0.txt. If you did not receive a copy of* the PHP License and are unable to obtain it through the web, please* send a note to license@php.net so we can mail you a copy immediately.** @category crypt* @package Email_Safe* @author Markus Niewerth <markus@weban.de>* @copyright 1997-2005 The PHP Group* @license http://www.php.net/license/3_0.txt PHP License 3.0* @since File available since Release 1.0.1*/// {{{ constantsdefine("EMAIL_SAFE_ERROR_MESSAGE" , "Can't read config file: %s");define("EMAIL_SAFE_DEFAULT_CONFIG" , "local_s/__classes/emailconfig.default.inc.php");// Image Einstellungen und Verzeichniskonfigurationendefine('EMAIL_SAFE_EMAIL_IMAGE_CONTENT_TYPE' , "image/png");define('EMAIL_SAFE_DIRECTORY' , "/usr/share/php/module/Email_Safe");define('EMAIL_SAFE_IMAGE_POPUP_TAG' , file_get_contents(EMAIL_SAFE_DIRECTORY."/templates/image.htm", true));define('EMAIL_SAFE_IMAGE_EMAIL_INPUT' , EMAIL_SAFE_DIRECTORY."/images/inp_email_200x37.jpg");define('EMAIL_SAFE_GD_TTF_FONT_DIR' , EMAIL_SAFE_DIRECTORY."/fonts/ttf/");define('EMAIL_SAFE_IMAGE_SYMLINK' , EMAIL_SAFE_DIRECTORY."/mailimage.php");// }}}// {{{ GLOBALS// vorhandene Schriften$GLOBALS['fonts'] = array('VERDANA_0.TTF','He__h___.TTF','framd.ttf','slipf.ttf','artro.ttf','FRG55__C.TTF','FRANKC__.TTF','He__h__o.TTF','frank.ttf','fesf____.ttf','denmark.ttf','Headache.TTF','Swz921n.ttf','FRABK.TTF','Marlbo.ttf','FRADM.TTF','Swz924n.ttf','swissc.ttf','FRAHV.TTF','OfficinaSerifCTT.ttf','FRAHVIT.TTF','arial.ttf','adbxtra.TTF','ariblk.ttf','HE______.TTF','adbxtsc.TTF','adbecnd.TTF','tahomabd.ttf','Marlboc.ttf','OFFSETUP.TTF','Marlbow.ttf','adbxtrab.TTF','ARIALBD.TTF','ARIALBI.TTF','adbecsc.TTF','AARVC___.ttf','erasure.ttf','Sw721bci.ttf','Sw721bco.ttf','FRANST_U.TTF','HELIOB.TTF','HE_CH___.TTF','OfficinaSansCTT.ttf','FRADMCN.TTF','Swz911uc.ttf','He__l___.TTF','He_ch__o.TTF','adbnorm.TTF','He__l__o.TTF','xfiles.ttf','FRAMDCN.TTF','Frakturn.ttf','dexgothn.ttf','FRADMIT.TTF','GALSBOLD.TTF','HE___ULT.TTF','dotmatrix.ttf','He___eex.TTF','SWZ911XC.TTF','GALSLIGH.TTF','He_____b.TTF','He_____o.TTF','HE__CMPR.TTF','FLX_GIRL.TTF','FRG65__C.TTF','He____bo.TTF','Swz721bc.ttf','Swz721be.ttf','Swz721bi.ttf','Swz721bo.ttf','TAHOMA.TTF','Swz721br.ttf','Swz721ci.ttf','Sw721kci.ttf','PupularScript.ttf','Swz721k2.ttf','trebucbd.TTF','Swz721hi.ttf','trebucbi.TTF','framdit0.ttf','Swz721kc.ttf','Swz721ke.ttf','Swz721ki.ttf','Swz721lc.ttf','trebuc.ttf','Swz721ko.ttf','Swz721le.ttf','Swz721kr.ttf','Swz721li.ttf','Swz721mi.ttf','boombox.ttf','earth.ttf','He_cl___.TTF','adbcond.TTF','trebucit.TTF','He_cl__o.TTF','Sw721lci.ttf','framdit.ttf','swisscb.ttf','swisscbi.ttf','swissci.ttf','swisscbo.ttf','swissck.ttf','swisscl.ttf','hoog0555_cyr.TTF','Swz721ti.ttf','TAHOMA_0.TTF','Swz721b.ttf','Swz721c.ttf','Swz721e.ttf','RADIOSTA.TTF','Swz721h.ttf','Swz721i.ttf','Swz721k.ttf','Swz721l.ttf','Swz721m.ttf','Swz721n.ttf','Swz721t.ttf','swisscki.ttf','HE_CN__B.TTF','swisscli.ttf','AGENO___.ttf','adbscaps.TTF','FRABKIT.TTF');// -------------------// IF any put in here!// -------------------function listTTFFonts($dir) {if ($handle = opendir($dir)) {$fontArray = "\$fonts = array (%s);";/* Das ist der korrekte Weg, ein Verzeichnis zu durchlaufen. */while (false !== ($file = readdir($handle))) {if (eregi(".ttf",$file)) {$buf[] = "'".$file."'";}}$buf = implode(",", $buf);closedir($handle);return sprintf($fontArray,$buf);}}// }}}// {{{ Email_Safe/*** This file is part of the Content-Active CMS System.* This class is available in other abstractions.** This class handles template formates written in* Rapid_Template syntax. The syntax is shown in the* method itself. Or you could have a look in the* templates folder {@see templates/}.** PHP versions 4 and 5** LICENSE: This source file is subject to version 3.0 of the PHP license* that is available through the world-wide-web at the following URI:* http://www.php.net/license/3_0.txt. If you did not receive a copy of* the PHP License and are unable to obtain it through the web, please* send a note to license@php.net so we can mail you a copy immediately.** @category crypt* @package Email_Safe* @author Markus Niewerth <markus@weban.de>* @copyright 1997-2005 The PHP Group* @license http://www.php.net/license/3_0.txt PHP License 3.0* @since File available since Release 1.0.1*/class Email_Safe {// {{{ properties/*** @var array $configContents Contents from email config*/var $configContents;var $configFile;// }}}// {{{ Email_Safe()/*** Email_Safe** Email_Safe Basis Constructor** @param int $contextId Id for multi site parsing* (needed for e.g. portal sites)** @access public*/function Email_Safe($configFile=false){if ($configFile) {$this->configFile = $configFile;$this->read($this->configFile);}}// }}}// {{{ read()/*** read** Liest die Konfiguration in den Speicher.** @param string email** @access public*/function read($configFile=false){if (isset($GLOBALS['email_config'])) {unset($GLOBALS['email_config']);}if ($configFile) {$this->configFile = $configFile;}if (file_exists($this->configFile) && is_readable($this->configFile)) {// read the config ontents$this->configContents = file($this->configFile);} else {return false;}return true;}// }}}// {{{ copyConfig()/*** copyConfig** Kopiert die Konfiguration eines Templates.** @param string email** @access public*/function copyConfig($destFile=false,$baseConfig=EMAIL_SAFE_DEFAULT_CONFIG){if (!$destFile) {$destFile = $this->configFile;}if (!$destFile) {return false;}$stdConf = $this->readStdConfig($baseConfig);$filler = array('file' => $destFile,'date' => date("Y/m/d h:i:s"),'config' => "\$GLOBALS['email_config'] = array();\r\n");$newConf = sprintf($stdConf,$filler['file'],$filler['date'],$filler['config']);$pathinfo = pathinfo($this->configFile);// --------// Temporaere Datei erzeugen// Und config schreiben$tmpf = tempnam ("/tmp", "EMAIL_CONF");$hnd = fopen($tmpf, "w");fwrite($hnd, $newConf);fclose($hnd);if (!copy($tmpf,$filler['file'])) {unlink($tmpf);return false;}// Symlink erzeugensymlink (EMAIL_SAFE_IMAGE_SYMLINK, $pathinfo["dirname"]."/mailimage.php" );unlink($tmpf);// --------return true;}// }}}// {{{ readStdConfig()/*** add** Adds an email address to config file** @param string email** @access public*/function readStdConfig($baseConfig) {return file_get_contents($baseConfig);}// }}}// {{{ add()/*** add** Hinzufuegen einer Email zur Konfiguration.** @param string email** @access public*/function add($email){if (!$email) {return $this->read($this->configFile);}$this->read($this->configFile);// copy last tag$endTag = $this->configContents[sizeof($this->configContents)-1];$this->configContents[sizeof($this->configContents)-1] = "// added on: ".date("Y/m/d h:i:s")."\r\n";$this->configContents[sizeof($this->configContents)] = "\$GLOBALS['email_config']['".md5($email)."'] = \"$email\";\r\n";$this->configContents[sizeof($this->configContents)] = $endTag;$newContents = implode("",$this->configContents);if ($this->writeContentsToFile($newContents)) {$this->read($this->configFile);return $this->configContents;}}// }}}// {{{ writeContentsToFile()/*** add** Schreibt den uebermittelten Inhalt in* die Konfigurations Datei. Wenn nichts uebergeben* wird, so wird die Konfigurations- Voreinstellung* des Konstruktors uebernommen.* {@see $this->configFile}*** @param string contents** @access public*/function writeContentsToFile($contents=false){if (!$contents || !is_writable($this->configFile)) {return false;}if (is_array($contents)) {$contents = implode("",$contents);}$fp = fopen($this->configFile,"w");if (!fwrite($fp,$contents)) {fclose($fp);return false;}fclose($fp);return true;}// }}}// {{{ remove()/*** remove** Entfernen einer Email Adresse von der* Konfiguration.** @param string email** @access public*/function remove($email){$key = md5($email);$this->read($this->configFile);foreach (array_keys($this->configContents) as $aKey) {if (eregi("$key",$this->configContents[$aKey])) {unset($this->configContents[$aKey-1]);unset($this->configContents[$aKey]);}}if ($this->writeContentsToFile($this->configContents)) {$this->read($this->configFile);return $this->configContents;}}// }}}// {{{ createEmailImage()/*** createEmailImage** Erstellt ein Bild zu einer angegebenen Adresse.* Sieht einem Formular Textfeld sehr aehnlich.** @param string email** @access public*/function createEmailImage ($code, $fontSize=8, $fontType=0, $fontColor='255,255,255', $backColor='0,0,0',$createFromImage=true){if (file_exists($_SERVER['DOCUMENT_ROOT']."/emailconfig.default.inc.php")){include($_SERVER['DOCUMENT_ROOT']."/emailconfig.default.inc.php");} else {return false;}if (eregi("[a-z0-9]{32}",$code)){$email = $GLOBALS['email_config'][$code];} else {$email = $code;}$fontColor = explode(",",$fontColor);$backColor = explode(",",$backColor);$code = md5($email);header ("Content-type: ".EMAIL_SAFE_EMAIL_IMAGE_CONTENT_TYPE);if ($createFromImage){$cp_im = imagecreatefromjpeg(EMAIL_SAFE_IMAGE_EMAIL_INPUT);} else {$cp_im = imagecreate ( ((100)+(strlen($email)*($fontSize/4))) , $fontSize+(10));}$back = ImageColorAllocate ($cp_im, $backColor[0], $backColor[1], $backColor[2]);$font = ImageColorAllocate ($cp_im, $fontColor[0], $fontColor[1], $fontColor[2]);$y = $fontSize+(5);$x = 2;imagettftext ($cp_im , $fontSize , 0, $x, $y, $font, EMAIL_SAFE_GD_TTF_FONT_DIR.$GLOBALS['fonts'][$fontType], $email);imagepng ($cp_im);imagedestroy ($cp_im);return true;}// }}}}// }}}/** Local variables:* tab-width: 4* c-basic-offset: 4* c-hanging-comment-ender-p: nil* End:*/?>