Пример #1
0
 public static function show()
 {
     $date_fin = Config::get("maintenance.date_fin");
     $firstLine = Config::get("maintenance.firstLine");
     $secondLine = Config::get("maintenance.secondLine");
     $mapText = Config::get("maintenance.mapText");
     $mapCoord = Config::get("maintenance.mapCoord");
     $view = array("view" => 'maintenance.index', "backend" => true);
     $data = array('date_fin' => $date_fin, 'firstLine' => $firstLine, 'secondLine' => $secondLine, 'mapText' => $mapText, 'mapCoord' => $mapCoord);
     View::make($view, $data);
 }
Пример #2
0
 public static function add_shortcode($string)
 {
     $shortcode = self::get($string);
     if (is_array($shortcode) && $shortcode != false) {
         if (count($shortcode) > 1) {
         } else {
             if (!self::checkModule($shortcode[0]['module'], $shortcode[0]['backend'])) {
                 echo "[View introuvable]";
             } else {
                 $view = array("view" => $shortcode[0]['module'] . "." . $shortcode[0]['view'], "backend" => $shortcode[0]['backend']);
                 $content = View::get($view, null);
                 echo $content;
             }
         }
     } else {
         echo "Erreur";
     }
 }
Пример #3
0
 public static function send($view, $array, $callback)
 {
     //include "../core/Associates/PHPMailer/class.phpmailer.php";
     include "../core/Associates/SwiftMailer/vendor/autoload.php";
     //
     $selfmail = new self();
     $callback($selfmail);
     //
     //get The View
     if ($selfmail->type == "text") {
         $body = $view;
         $type = "text/plain";
     } else {
         if ($selfmail->type == "html") {
             $body = View::get($view, $array);
             $type = "text/html";
         } else {
             $body = $view;
             $type = "text/plain";
         }
     }
     //
     if (!self::configured($selfmail)) {
         $selfmail->host = Config::get("mail.host");
         $selfmail->port = Config::get("mail.port");
         $selfmail->secure = Config::get("mail.encryption");
         $selfmail->type = "html";
         $selfmail->username = Config::get("mail.username");
         $selfmail->password = Config::get("mail.password");
         $selfmail->from['adresse'] = Config::get("mail.from")['adresse'];
         $selfmail->from['name'] = Config::get("mail.from")['name'];
     }
     //
     self::check($selfmail);
     //
     $selfmail->transport = \Swift_SmtpTransport::newInstance($selfmail->host, $selfmail->port, $selfmail->secure)->setUsername($selfmail->username)->setPassword($selfmail->password);
     // $message = Swift_Message::newInstance('Activation de compte Touhfat Al Arouss')
     //   ->setFrom(array('*****@*****.**' => 'Équipe Touhfat Al Arouss'))
     //   ->setTo(array('*****@*****.**'))
     //   ->setBody($body , "text/html");
     //var_dump($selfmail->transport);
     $mailer = \Swift_Mailer::newInstance($selfmail->transport);
     $subject = is_null($selfmail->subject) ? Config::get('mail.subject') : $selfmail->subject;
     //
     //The Message
     $message = \Swift_Message::newInstance($subject);
     $message->setBody($body, $type);
     $message->setFrom(array($selfmail->from['adresse'] => $selfmail->from['name']));
     // Check to
     //
     if (!is_null($selfmail->too) && !empty($selfmail->too)) {
         $message->setTo($selfmail->too);
     } else {
         throw new \InvalidArgumentException("Missing mail to", 1);
     }
     //
     // Attaches
     if (!is_null($selfmail->attachmnt) && count($selfmail->attachmnt) > 0) {
         foreach ($selfmail->attachmnt as $key => $value) {
             $name = "";
             $filee = "";
             //
             foreach ($value as $key2 => $value2) {
                 if ($key2 == 0) {
                     $filee = $value2;
                 } else {
                     if ($key2 == 1) {
                         $name = $value2;
                     }
                 }
             }
             if (empty($name)) {
                 $message->attach(\Swift_Attachment::fromPath($filee));
             } else {
                 $message->attach(\Swift_Attachment::fromPath($filee)->setFilename($name));
             }
         }
     }
     //
     // CC
     if (!is_null($selfmail->cc) && count($selfmail->cc) > 0) {
         $r = array();
         //
         foreach ($selfmail->cc as $key => $value) {
             $name = "";
             $mail = "";
             //
             foreach ($value as $key2 => $value2) {
                 if ($key2 == "mail") {
                     $mail = $value2;
                 } else {
                     if ($key2 == "name") {
                         $name = $value2;
                     }
                 }
             }
             //
             if (empty($name)) {
                 $r[] = $mail;
             } else {
                 $r[$mail] = $name;
             }
         }
         //
         $message->setCC($r);
     }
     //
     // CCI
     if (!is_null($selfmail->cci) && count($selfmail->cci) > 0) {
         $r = array();
         //
         foreach ($selfmail->cci as $key => $value) {
             $name = "";
             $mail = "";
             //
             foreach ($value as $key2 => $value2) {
                 if ($key2 == "mail") {
                     $mail = $value2;
                 } else {
                     if ($key2 == "name") {
                         $name = $value2;
                     }
                 }
             }
             //
             if (empty($name)) {
                 $r[] = $mail;
             } else {
                 $r[$mail] = $name;
             }
         }
         //
         $message->setBcc($r);
     }
     //
     // Send
     $result = $mailer->send($message);
     return $result;
     // $mail->IsSMTP();
     // $mail->SMTPDebug=1;
     // $mail->SMTPAuth=true;
     // $mail->SMTPSecure=Config::get("mail.encryption");
     // $mail->Host=Config::get("mail.host");
     // $mail->Port=Config::get("mail.port");
     // $mail->Username=Config::get("mail.username");
     // $mail->Password=Config::get("mail.password");
     // if(is_null($selfmail->froms)) $selfmail->froms=Config::get("mail.from.adresse");
     // $mail->SetFrom($selfmail->froms);
     // $mail->Subject=$selfmail->subject;
     // $mail->Body=$view2;
     // //
     // foreach ($selfmail->too as $key => $value)
     // {
     // 	$name="";
     // 	$maile="";
     // 	//
     // 	foreach ($value as $key2 => $value2) {
     // 		if($key2=="name") $name=$value2;
     // 		else if($key2=="mail") $maile=$value2;
     // 	}
     // 	//
     // 	if(empty($name)) { $mail->AddAddress($maile); }
     // 	else { $mail->AddAddress($maile,$name); }
     // }
     // //
     // // atachement
     // if(!is_null($selfmail->atachmnt) && count($selfmail->atachmnt)>0)
     // foreach ($selfmail->atachmnt as $key => $value)
     // {
     // 	$name="";
     // 	$filee="";
     // 	//
     // 	foreach ($value as $key2 => $value2) {
     // 		if($key2==1) $name=$value2;
     // 		else if($key2==0) $filee=$value2;
     // 	}
     // 	//
     // 	if(empty($name)) { $mail->addAttachment($filee); }
     // 	else { $mail->addAttachment($filee,$name); }
     // }
     // //
     // // CC
     // if(!is_null($selfmail->cc))
     // foreach ($selfmail->cc as $key => $value)
     // {
     // 	$mail->addCC($value);
     // }
     // //
     // // CCB
     // if(!is_null($selfmail->cci))
     // foreach ($selfmail->cci as $key => $value)
     // {
     // 	$mail->addBCC($value);
     // }
     // if(!$mail->Send())
     // {
     // 	self::$error=$mail->ErrorInfo;
     // 	return false;
     // }
     // else return true;
 }