class Mail
{
/*
list of To addresses
@var array
*/
var $sendto = array();
/*
@var array
*/
var $acc = array();
/*
@var array
*/
var $abcc = array();
/*
paths of attached files
@var array
*/
var $aattach = array();
/*
list of message headers
@var array
*/
var $xheaders = array();
/*
message priorities referential
@var array
*/
var $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' );
/*
character set of message
@var string
*/
var $charset = "us-ascii";
var $ctencoding = "7bit";
var $receipt = 0;
var $content_type='';
/*
Mail contructor
*/
function Mail()
{
$this->autoCheck( true );
$this->boundary= "--" . md5( uniqid("myboundary") );
}
function Content_type($contenttype){
$this->content_type=$contenttype;
//echo $this->content_type;
//echo '
';
//exit();
}
/*
activate or desactivate the email addresses validator
ex: autoCheck( true ) turn the validator on
by default autoCheck feature is on
@param boolean $bool set to true to turn on the auto validation
@access public
*/
function autoCheck( $bool )
{
if( $bool )
$this->checkAddress = true;
else
$this->checkAddress = false;
}
/*
Define the subject line of the email
@param string $subject any monoline string
*/
function Subject( $subject )
{
$this->xheaders['Subject'] = strtr( $subject, "\r\n" , " " );
}
/*
set the sender of the mail
@param string $from should be an email address
*/
function From( $from )
{
if( ! is_string($from) ) {
echo "Class Mail: error, From is not a string";
exit;
}
$this->xheaders['From'] = $from;
}
/*
set the Reply-to header
@param string $email should be an email address
*/
function ReplyTo( $address )
{
if( ! is_string($address) )
return false;
$this->xheaders["Reply-To"] = $address;
}
/*
add a receipt to the mail ie. a confirmation is returned to the "From" address (or "ReplyTo" if defined)
when the receiver opens the message.
@warning this functionality is *not* a standard, thus only some mail clients are compliants.
*/
function Receipt()
{
$this->receipt = 1;
}
/*
set the mail recipient
@param string $to email address, accept both a single address or an array of addresses
*/
function To( $to )
{
// TODO : test validité sur to
if( is_array( $to ) )
$this->sendto= $to;
else
$this->sendto[] = $to;
if( $this->checkAddress == true )
$this->CheckAdresses( $this->sendto );
}
/* Cc()
* set the CC headers ( carbon copy )
* $cc : email address(es), accept both array and string
*/
function Cc( $cc )
{
if( is_array($cc) )
$this->acc= $cc;
else
$this->acc[]= $cc;
if( $this->checkAddress == true )
$this->CheckAdresses( $this->acc );
}
/* Bcc()
* set the Bcc headers ( blank carbon copy ).
* $bcc : email address(es), accept both array and string
*/
function Bcc( $bcc )
{
if( is_array($bcc) ) {
$this->abcc = $bcc;
} else {
$this->abcc[]= $bcc;
}
if( $this->checkAddress == true )
$this->CheckAdresses( $this->abcc );
}
/* Body( text [, charset] )
* set the body (message) of the mail
* define the charset if the message contains extended characters (accents)
* default to us-ascii
* $mail->Body( "mél en français avec des accents", "iso-8859-1" );
*/
function Body( $body, $charset="" )
{
$this->body = $body;
if( $charset != "" ) {
$this->charset = strtolower($charset);
if( $this->charset != "us-ascii" )
$this->ctencoding = "8bit";
}
}
/* Organization( $org )
* set the Organization header
*/
function Organization( $org )
{
if( trim( $org != "" ) )
$this->xheaders['Organization'] = $org;
}
/* Priority( $priority )
* set the mail priority
* $priority : integer taken between 1 (highest) and 5 ( lowest )
* ex: $mail->Priority(1) ; => Highest
*/
function Priority( $priority )
{
if( ! intval( $priority ) )
return false;
if( ! isset( $this->priorities[$priority-1]) )
return false;
$this->xheaders["X-Priority"] = $this->priorities[$priority-1];
return true;
}
/*
Attach a file to the mail
@param string $filename : path of the file to attach
@param string $filetype : MIME-type of the file. default to 'application/x-unknown-content-type'
@param string $disposition : instruct the Mailclient to display the file if possible ("inline") or always as a link ("attachment") possible values are "inline", "attachment"
*/
function Attach($filename,$filetype = "",$disposition = "inline")
{
if( $filetype == "" )
$filetype = "application/x-unknown-content-type";
//$filetype = "text/plain";
$this->aattach[] = $filename;
$this->actype[] = $filetype;
$this->adispo[] = $disposition;
}
/*
Build the email message
@access protected
*/
function BuildMail()
{
// build the headers
$this->headers = "";
// $this->xheaders['To'] = implode( ", ", $this->sendto );
if( count($this->acc) > 0 )
$this->xheaders['CC'] = implode( ", ", $this->acc );
if( count($this->abcc) > 0 )
$this->xheaders['BCC'] = implode( ", ", $this->abcc );
if( $this->receipt ) {
if( isset($this->xheaders["Reply-To"] ) )
$this->xheaders["Disposition-Notification-To"] = $this->xheaders["Reply-To"];
else
$this->xheaders["Disposition-Notification-To"] = $this->xheaders['From'];
}
if( $this->charset != "" ) {
//global $contenttype;
$content_type=$this->content_type;
$this->xheaders["Mime-Version"] = "1.0";
$this->xheaders["Content-Type"] = "$content_type; charset=$this->charset";
$this->xheaders["Content-Transfer-Encoding"] = $this->ctencoding;
}
$this->xheaders["X-Mailer"] = "RLSP Mailer";
// include attached files
if( count( $this->aattach ) > 0 ) {
$this->_build_attachement();
} else {
$this->fullBody = $this->body;
}
reset($this->xheaders);
while( list( $hdr,$value ) = each( $this->xheaders ) ) {
if( $hdr != "Subject" )
$this->headers .= "$hdr: $value\n";
}
}
/*
fornat and send the mail
@access public
*/
function Send()
{
//global $filename;
$this->BuildMail();
$this->strTo = implode( ", ", $this->sendto );
$res = @mail( $this->strTo, $this->xheaders['Subject'], $this->fullBody, $this->headers );
return $res;
}
/*
* return the whole e-mail , headers + message
* can be used for displaying the message in plain text or logging it
*/
function Get()
{
$this->BuildMail();
$mail = "To: " . $this->strTo . "\n";
$mail .= $this->headers . "\n";
$mail .= $this->fullBody;
return $mail;
}
/*
check an email address validity
@access public
@param string $address : email address to check
@return true if email adress is ok
*/
function ValidEmail($address)
{
/*
if( ereg( ".*<(.+)>", $address, $regs ) ) {
$address = $regs[1];
}
if(ereg( "^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$address) )
return true;
else
return false;
*/
return true;
}
/*
check validity of email addresses
@param array $aad -
@return if unvalid, output an error message and exit, this may -should- be customized
*/
function CheckAdresses( $aad )
{
for($i=0;$i< count( $aad); $i++ ) {
if( ! $this->ValidEmail( $aad[$i]) ) {
echo "Class Mail, method Mail : invalid address $aad[$i]";
exit;
}
}
}
/*
check and encode attach file(s) . internal use only
*/
function _build_attachement()
{
$this->xheaders["Content-Type"] = "multipart/mixed;\n boundary=\"$this->boundary\"";
$this->fullBody = "This is a multi-part message in MIME format.\n--$this->boundary\n";
$this->fullBody .= "Content-Type: text/html; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n" . $this->body ."\n";
$sep= chr(13) . chr(10);
$ata= array();
$k=0;
// for each attached file, do...
for( $i=0; $i < count( $this->aattach); $i++ ) {
$filename = $this->aattach[$i];
$basename = basename($filename);
$ctype = $this->actype[$i]; // content-type
$disposition = $this->adispo[$i];
/*getting the original name of the file */
//echo $original_filename;
if( ! file_exists( $filename) ) {
echo "Class Mail, method attach : file $filename can't be found"; exit;
}
/* echo 'filename--'.$filename;
echo '
';
*/
/*
the semicolon after the Content-type : $basename is important
since it was not there.This mail program
was not able to see the attachment for the past 1 month
--Saravanan 20/04/02
*/
$subhdr= "--$this->boundary\nContent-Type: $ctype;\n name=\"$basename\";\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n filename=\"$basename\"\n";
//$subhdr= "--$this->boundary\nContent-type: $ctype;\n name=\"$filename\"\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n filename=\"$filename\"\n";
$ata[$k++] = $subhdr;
// non encoded line length
$linesz= filesize( $filename)+1;
$fp= fopen( $filename, 'r' );
$ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
fclose($fp);
}
$this->fullBody .= implode($sep, $ata);
//echo $this->fullBody;
}
} // class Mail
/* funktion zum auffuellen von strings mit beliebigen zeichen
------------------------------------------------------------------*/
function cx_sfs($str_to_fill,$int_max_stellen=4,$str_letter="0",$str_stelle="vor")
{
for($i=strlen($str_to_fill);$i<$int_max_stellen;$i++)
{
($str_stelle == "vor") ? $str_to_fill = $str_letter.$str_to_fill : $str_to_fill .= $str_letter;
}
return $str_to_fill;
}
?>
function cx_benutzer($id_benutzer,$arr_felder)
{
$arr_benutzer = Array();
$arr_benutzer["id0"] = Array();
$arr_benutzer["id0"]["VORNAME"] = "{anonym}";
$arr_benutzer["id0"]["NACHNAME"] = "{anonym}";
$arr_benutzer["id0"]["USER"] = "{anonym}";
$arr_benutzer = Array();
$arr_benutzer["id9999"] = Array();
$arr_benutzer["id9999"]["VORNAME"] = "Super";
$arr_benutzer["id9999"]["NACHNAME"] = "Admin";
$arr_benutzer["id9999"]["USER"] = "superadmin";
if($id_benutzer && $id_benutzer != 9999)
{
$obj_benutzer = new cx_tupel($id_benutzer);
$arr_benutzer["id".$id_benutzer] = Array();
$arr_benutzer["id".$id_benutzer]["VORNAME"] = $obj_benutzer->ge("VORNAME");
$arr_benutzer["id".$id_benutzer]["NACHNAME"] = $obj_benutzer->ge("NACHNAME");
$arr_benutzer["id".$id_benutzer]["USER"] = $obj_benutzer->ge("cx_bez");
}
$str = "";
for($i=0;$i
function cx_media_generate_crop_max($pfad,$breite,$hoehe,$int_qualitaet=100,$skalieren=0,$str_output="",$cropping=0,$cropping_without_resize=0,$pfad_wm="")
{
if(isset($pfad) && file_exists($pfad))
{
// pfad originalbild
$pfad_original = $pfad;
// gewuenschte breite
$int_breite = $breite;
// gewuenschte hoehe
$int_hoehe = $hoehe;
//--------------------------------------------------------------
// originalwerte
//--------------------------------------------------------------
$img_data = getimagesize($pfad);
// originalbreite
$int_breite_orig = $img_data[0];
// originalhoehe
$int_hoehe_orig = $img_data[1];
if(!$int_breite && !$int_hoehe)
{
$int_breite = $int_breite_orig;
$int_hoehe = $int_hoehe_orig;
$breite = $int_breite_orig;
$hoehe = $int_hoehe_orig;
}
$arr_dummy = explode(".",$pfad_original);
$endung = array_pop($arr_dummy);
$int_breite_neu = $int_breite;
$int_hoehe_neu = $int_hoehe;
//--------------------------------------------------------------
// berechnen
//--------------------------------------------------------------
if(($int_breite_orig > $int_breite && $int_breite > 0))
{
$int_breite_neu = $int_breite;
$int_hoehe_neu = ($int_breite/$int_breite_orig)*$int_hoehe_orig;
}
if(($int_hoehe_neu > $int_hoehe && $int_hoehe > 0))
{
$int_breite_neu = ($int_hoehe/$int_hoehe_neu)*$int_breite_neu;
$int_hoehe_neu = $int_hoehe;
}
$breite_ohne_skalierung = $int_breite_neu;
$hoehe_ohne_skalierung = $int_hoehe_neu;
//--------------------------------------------------------------
// breite oder hoehe = 0
//--------------------------------------------------------------
if(!$int_breite_neu)
{
$int_breite_neu = $int_breite_orig*($int_hoehe_neu/$int_hoehe_orig);
}
if(!$int_hoehe_neu)
{
$int_hoehe_neu = $int_hoehe_orig*($int_breite_neu/$int_breite_orig);
}
//--------------------------------------------------------------
// max
//--------------------------------------------------------------
if($int_hoehe_neu < $int_hoehe)
{
$int_breite_neu = ($int_hoehe/$int_hoehe_neu)*$int_breite_neu;
$int_hoehe_neu = $int_hoehe;
}
if($int_breite_neu < $int_breite)
{
$int_hoehe_neu = ($int_breite/$int_breite_neu)*$int_hoehe_neu;
$int_breite_neu = $int_breite;
}
$int_breite_neu = (integer)$int_breite_neu;
$int_hoehe_neu = (integer)$int_hoehe_neu;
$top = max(0,$int_hoehe_neu-((integer)(($int_hoehe_neu+$hoehe)/2)));
$left = max(0,$int_breite_neu-((integer)(($int_breite_neu+$breite)/2)));
//--------------------------------------------------------------
// ausgabe
//--------------------------------------------------------------
switch(strtolower($endung))
{
case "gif" :
$src = imagecreatefromgif($pfad_original);
break;
case "png" :
$src = imagecreatefrompng($pfad_original);
break;
default :
$src = imagecreatefromjpeg($pfad_original);
break;
}
if((!$skalieren && ($int_breite_orig < $int_breite_neu || $int_hoehe_orig < $int_hoehe_neu)) || !$cropping)
{
$im = imagecreatetruecolor(min($int_breite_orig,$breite_ohne_skalierung),min($int_hoehe_orig,$hoehe_ohne_skalierung));
imagecopyresized($im,$src,0,0,0,0,min($int_breite_orig,$breite_ohne_skalierung),min($int_hoehe_orig,$hoehe_ohne_skalierung),$int_breite_orig,$int_hoehe_orig);
imagejpeg($im,$str_output,$int_qualitaet);
}
else
{
$im = imagecreatetruecolor($int_breite_neu,$int_hoehe_neu);
if($cropping_without_resize == 1)
{
imagecopyresized($im,$src,0,0,0,0,$int_breite_orig,$int_hoehe_orig,$int_breite_orig,$int_hoehe_orig);
}
else
{
imagecopyresized($im,$src,0,0,0,0,$int_breite_neu,$int_hoehe_neu,$int_breite_orig,$int_hoehe_orig);
}
$dateiname_dummy = md5(date("YmdHisYmdHis")).".jpg";
if($pfad_wm != "")
{
$imgzeichen = imagecreatefrompng("../../../".$pfad_wm);
$wwidth = imagesx($imgzeichen);
$wheight = imagesy($imgzeichen);
imagecopy($im, $imgzeichen, $breite-$wwidth, $hoehe-$wheight, 0, 0, $wwidth, $wheight);
}
imagejpeg($im,$dateiname_dummy,$int_qualitaet);
imagedestroy($im);
$arr_dateiname_dummy = explode(".",$dateiname_dummy);
$endung_dummy = array_pop($arr_dateiname_dummy);
switch(strtolower($endung_dummy))
{
case "gif" :
$src = imagecreatefromgif($dateiname_dummy);
break;
case "png" :
$src = imagecreatefrompng($dateiname_dummy);
break;
default :
$src = imagecreatefromjpeg($dateiname_dummy);
break;
}
//$src = imagecreatefromjpeg($dateiname_dummy);
$im = imagecreatetruecolor($breite,$hoehe);
imagecopyresampled($im,$src,0,0,$left,$top,$breite,$hoehe,$breite,$hoehe);
imagejpeg($im,$str_output,$int_qualitaet);
@unlink($dateiname_dummy);
}
imagedestroy($im);
}
}
?>
function cx_datum($tsDatum,$intCase=100)
{
$strReturn = "Fehlender Funktionscode";
if($tsDatum == "")
{
$strReturn = "";
}
else
{
switch($intCase)
{
case "en" :
if(strpos($tsDatum," ") > 0)
{
//----------------------------------------------------------
//format: 2006-06-02 18:57:39
//----------------------------------------------------------
$strTag = substr($tsDatum,8,2);
$strMonat = substr($tsDatum,5,2);
$strJahr = substr($tsDatum,0,4);
}
else
{
//----------------------------------------------------------
//format: 20060602185739
//----------------------------------------------------------
$strTag = substr($tsDatum,6,2);
$strMonat = substr($tsDatum,4,2);
$strJahr = substr($tsDatum,0,4);
}
$strReturn = $strJahr."-".$strMonat."-".$strTag;
break;
case "de_tag":
if(strpos($tsDatum," ") > 0)
{
//----------------------------------------------------------
//format: 2006-06-02 18:57:39
//----------------------------------------------------------
$strTag = substr($tsDatum,8,2);
$strMonat = substr($tsDatum,5,2);
$strJahr = substr($tsDatum,0,4);
}
else
{
//----------------------------------------------------------
//format: 20060602185739
//----------------------------------------------------------
$strTag = substr($tsDatum,6,2);
$strMonat = substr($tsDatum,4,2);
$strJahr = substr($tsDatum,0,4);
}
$tag = date("w",mktime(0,0,0,$strMonat,$strTag,$strJahr));
$strReturn = $arr_tage_kurz[$tag].", ".$strTag.".".$strMonat.".".$strJahr;
break;
case "YYYYMMDD":
$arr_datum = explode(".",$tsDatum);
$strReturn = $arr_datum[2].cx_sfs($arr_datum[1],2).cx_sfs($arr_datum[0],2);
break;
case "modern":
if(strpos($tsDatum," ") > 0)
{
//----------------------------------------------------------
//format: 2006-06-02 18:57:39
//----------------------------------------------------------
$strTag = substr($tsDatum,8,2);
$strMonat = substr($tsDatum,5,2);
$strJahr = substr($tsDatum,0,4);
$strStunde = substr($tsDatum,11,2);
$strMinute = substr($tsDatum,14,2);
$strSekunde = substr($tsDatum,17,2);
}
else
{
//----------------------------------------------------------
//format: 20060602185739
//----------------------------------------------------------
$strTag = substr($tsDatum,6,2);
$strMonat = substr($tsDatum,4,2);
$strJahr = substr($tsDatum,0,4);
$strStunde = substr($tsDatum,8,2);
$strMinute = substr($tsDatum,10,2);
$strSekunde = substr($tsDatum,12,2);
}
$mktime = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"));
$mktime_tupel = mktime($strStunde,$strMinute,$strSekunde,$strMonat,$strTag,$strJahr);
$mktime_gestern = mktime($strStunde,$strMinute,$strSekunde,$strMonat,$strTag-1,$strJahr);
$diff = ($mktime-$mktime_tupel);
if($diff < 60)
{
$strReturn = "vor ".((integer)($diff))." Sekunden";
}
else if((integer)($diff/60) == 1)
{
$strReturn = "vor ".((integer)($diff/60))." Minute";
}
else if($diff/60 < 120)
{
$strReturn = "vor ".((integer)($diff/60))." Minuten";
}
else if($diff/60 < 60*4)
{
$strReturn = "vor ".((integer)($diff/60/60))." Stunden";
}
else if($strTag == date("d") && $strMonat == date("m") && $strJahr == date("Y"))
{
$strReturn = "heute, ".$strStunde.":".$strMinute." Uhr";
}
else if($strTag == date("d",$mktime_gestern) && $strMonat == date("m",$mktime_gestern) && $strJahr == date("Y",$mktime_gestern))
{
$strReturn = "gestern, ".$strStunde.":".$strMinute." Uhr";
}
else
{
$strReturn = $strTag.".".$strMonat.".".$strJahr.", ".$strStunde.":".$strMinute." Uhr";
}
break;
default:
if(strpos($tsDatum," ") > 0)
{
//----------------------------------------------------------
//format: 2006-06-02 18:57:39
//----------------------------------------------------------
$strTag = substr($tsDatum,8,2);
$strMonat = substr($tsDatum,5,2);
$strJahr = substr($tsDatum,0,4);
}
else
{
//----------------------------------------------------------
//format: 20060602185739
//----------------------------------------------------------
$strTag = substr($tsDatum,6,2);
$strMonat = substr($tsDatum,4,2);
$strJahr = substr($tsDatum,0,4);
}
$strReturn = $strTag.".".$strMonat.".".$strJahr;
break;
}
}
return $strReturn;
}
?>
Produkte
/media/