コード例 #1
0
 /**
  * class constructor
  *
  * @param stdClass $p_params
  * @return OdaDate $this
  */
 public function __construct($p_params = NULL)
 {
     self::$config = SimpleObject\OdaConfig::getInstance();
     self::$config->isOK();
     $params_bd = new stdClass();
     $params_bd->bd_conf = self::$config->BD_ENGINE;
     $this->BD_ENGINE = new OdaLibBd($params_bd);
     $this->params = $p_params;
 }
コード例 #2
0
ファイル: config.php プロジェクト: Happykiller/ODA_FW_SERVER
<?php

$config = \Oda\SimpleObject\OdaConfig::getInstance();
$config->urlServer = "http://localhost/server/";
$config->resourcesPath = "resources/";
//for bd engine
$config->BD_ENGINE->base = 'base';
$config->BD_ENGINE->user = '******';
$config->BD_ENGINE->mdp = 'pass';
コード例 #3
0
<?php

namespace Oda;

require '../../../../../header.php';
require '../../../../../vendor/autoload.php';
require '../../../../../config/config.php';
use stdClass, Oda\SimpleObject\OdaPrepareInterface, Oda\SimpleObject\OdaConfig;
//--------------------------------------------------------------------------
//Build the interface
$params = new OdaPrepareInterface();
$params->arrayInput = array("email_mails_dest", "message_html", "sujet");
$params->arrayInputOpt = array("email_mail_ori" => "*****@*****.**", "email_labelle_ori" => "ODA Service Mail", "email_mail_reply" => null, "email_labelle_reply" => null, "email_mails_copy" => null, "email_mails_cache" => null, "message_txt" => "HTML not supported");
$ODA_INTERFACE = new OdaLibInterface($params);
//--------------------------------------------------------------------------
// API/script/send_mail.php?milis=123450&email_mail_ori=admin@mail.com&email_labelle_ori=ServiceMailOda&email_mail_reply=admin@mail.com&email_labelle_reply=ServiceMailOda&email_mails_dest=fabrice.rosito@gmail.com&email_mails_copy=fabrice.rosito@gmail.com&email_mails_cache=fabrice.rosito@gmail.com&message_txt=Anomalie avec le support du HTML.&message_html=<html><head></head><body><b>Merci</b> de repondre à ce mail en moins de 37min</body></html>&sujet=Hey mon ami !
//--------------------------------------------------------------------------
$config = OdaConfig::getInstance();
if ($config->MAILGUN->isOK()) {
    $result = OdaLib::sendMailGun($ODA_INTERFACE->inputs);
} else {
    $result = OdaLib::sendMail($ODA_INTERFACE->inputs);
}
//--------------------------------------------------------------------------
$params = new stdClass();
$params->label = "resultat";
$params->value = $result;
$ODA_INTERFACE->addDataStr($params);
コード例 #4
0
 /**
  * @param type \Oda\OdaPrepareInterface
  * @return \Oda\OdaLibInterface
  */
 public function __construct(SimpleObject\OdaPrepareInterface $params)
 {
     try {
         $this->params = $params;
         $this->modeDebug = $params->modeDebug;
         $this->modePublic = $params->modePublic;
         $this->modeSortie = $params->modeSortie;
         $this->fileName = $params->fileName;
         $this->object_retour = new SimpleObject\OdaRetourInterface();
         $this->callerMethode = $_SERVER['REQUEST_METHOD'];
         $this->name = $this->getInstanceName();
         self::$config = SimpleObject\OdaConfig::getInstance();
         self::$config->isOK();
         $params_bd = new stdClass();
         $params_bd->bd_conf = self::$config->BD_ENGINE;
         $params_bd->modeDebug = $this->modeDebug;
         $this->BD_ENGINE = new OdaLibBd($params_bd);
         if (is_null(self::$config->BD_AUTH->base)) {
             $this->BD_AUTH = $this->BD_ENGINE;
         } else {
             $params_bd = new stdClass();
             $params_bd->bd_conf = self::$config->BD_AUTH;
             $params_bd->modeDebug = $this->modeDebug;
             $this->BD_AUTH = new OdaLibBd($params_bd);
         }
         $this->object_retour->statut = self::STATE_CONSTRUCT;
         $this->inputs = $this->recupInputs($params->arrayInput, $params->arrayInputOpt);
         $debut = new SimpleObject\OdaDate();
         $this->startMicro = SimpleObject\OdaDate::getMicro();
         $this->object_retour->metro["ODABegin"] = $debut->getDateTimeWithMili();
         $this->transactionRecord = $this->getParameter('transaction_record');
         $this->_initTransaction($this->inputs, $debut);
         $this->checkKey();
         $this->object_retour->statut = self::STATE_READY;
         return $this;
     } catch (Exception $ex) {
         $this->object_retour->strErreur = $ex . '';
         $this->object_retour->statut = self::STATE_ERROR;
         die;
     }
 }
コード例 #5
0
ファイル: OdaLib.php プロジェクト: Happykiller/ODA_FW_SERVER
 /**
  * @name sendMailGun
  * @return null|string
  * @throws \Exception
  * @p_param sdtClass $p_params
  */
 static function sendMailGun($p_params)
 {
     try {
         $config = SimpleObject\OdaConfig::getInstance();
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
         curl_setopt($ch, CURLOPT_USERPWD, 'api:' . $config->MAILGUN->api_key);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
         curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v2/' . $config->MAILGUN->domaine . '/messages');
         $params = array('from' => $p_params["email_labelle_ori"] . '<' . $p_params["email_mail_ori"] . '>', 'to' => $p_params["email_mails_dest"], 'subject' => $p_params["sujet"], 'html' => $p_params["message_html"], 'text' => $p_params["message_txt"]);
         if (!is_null($p_params["email_mails_copy"])) {
             $params['cc'] = $p_params["email_mails_copy"];
         }
         if (!is_null($p_params["email_mails_cache"])) {
             $params['bcc'] = $p_params["email_mails_cache"];
         }
         curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
         $result = curl_exec($ch);
         curl_close($ch);
         $return = $result ? "OK" : "KO";
         return $return;
     } catch (Exception $e) {
         $msg = $e->getMessage();
         throw new \Exception('Erreur dans ' . __CLASS__ . ' : ' . $msg);
         return null;
     }
 }