163 |
|
|
164 |
|
|
165 |
|
|
|
/** |
|
|
* Cette methode permet de charger les differents fichiers de configs dans |
|
|
* des attributs de la classe |
|
|
* |
|
|
* @return void |
|
|
*/ |
|
|
function setParamsFromFiles() { |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/config.inc.php")) { |
|
|
include_once("../dyn/config.inc.php"); |
|
|
} |
|
|
if (isset($config)) { |
|
|
$this->config = $config; |
|
|
} |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/database.inc.php")) { |
|
|
include("../dyn/database.inc.php"); |
|
|
} |
|
|
|
|
|
if (isset($conn)) { |
|
|
$this->conn = $conn; |
|
|
// |
|
|
foreach($this->conn as $key => $conn) { |
|
|
$this->database[$key] = array( |
|
|
'title' => $conn[0], |
|
|
'phptype' => $conn[1], |
|
|
'dbsyntax' => $conn[2], |
|
|
'username' => $conn[3], |
|
|
'password' => $conn[4], |
|
|
'protocol' => $conn[5], |
|
|
'hostspec' => $conn[6], |
|
|
'port' => $conn[7], |
|
|
'socket' => $conn[8], |
|
|
'database' => $conn[9], |
|
|
'formatdate' => $conn[10], |
|
|
'schema' => $conn[11], |
|
|
'prefixe' => (isset($conn[12]) ? $conn[12]: ""), |
|
|
'directory' => (isset($conn[13]) ? $conn[13]: ""), |
|
|
'mail' => (isset($conn[14]) ? $conn[14]: ""), |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/directory.inc.php")) { |
|
|
include_once("../dyn/directory.inc.php"); |
|
|
} |
|
|
if (isset($directory)) { |
|
|
$this->directory = $directory; |
|
|
} |
|
166 |
|
|
|
// |
|
|
if (file_exists("../dyn/mail.inc.php")) { |
|
|
include_once("../dyn/mail.inc.php"); |
|
|
} |
|
|
if (isset($mail)) { |
|
|
$this->mail = $mail; |
|
|
} |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/menu.inc.php")) { |
|
|
include_once("../dyn/menu.inc.php"); |
|
|
} |
|
|
if (isset($menu)) { |
|
|
$this->menu = $menu; |
|
|
} |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/actions.inc.php")) { |
|
|
include_once("../dyn/actions.inc.php"); |
|
|
} |
|
|
if (isset($actions)) { |
|
|
$this->actions = $actions; |
|
|
} |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/shortlinks.inc.php")) { |
|
|
include_once("../dyn/shortlinks.inc.php"); |
|
|
} |
|
|
if (isset($shortlinks)) { |
|
|
$this->shortlinks = $shortlinks; |
|
|
} |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/footer.inc.php")) { |
|
|
include_once("../dyn/footer.inc.php"); |
|
|
} |
|
|
if (isset($footer)) { |
|
|
$this->footer = $footer; |
|
|
} |
|
|
|
|
|
// |
|
|
if (file_exists("../dyn/version.inc.php")) { |
|
|
include_once("../dyn/version.inc.php"); |
|
|
} |
|
|
if (isset($version)) { |
|
|
$this->version = $version; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
167 |
/** |
/** |
168 |
* Cette méthode permet de vérifier si l'utilisateur est autorisé ou non à |
* Cette méthode permet de vérifier si l'utilisateur est autorisé ou non à |
169 |
* accéder à un élément et permet d'agir en conséquence |
* accéder à un élément et permet d'agir en conséquence |
217 |
// On recupere la liste des cles du tableau associatif de configuration |
// On recupere la liste des cles du tableau associatif de configuration |
218 |
// de la connexion aux bases de donnees |
// de la connexion aux bases de donnees |
219 |
$database_keys = array_keys($this->database); |
$database_keys = array_keys($this->database); |
|
//print ' database keys:'; |
|
|
//print_r($database_keys); |
|
220 |
// Si il y a plusieurs cles |
// Si il y a plusieurs cles |
221 |
if (count($database_keys) != 0) { |
if (count($database_keys) != 0) { |
222 |
// On configure la premiere par defaut |
// On configure la premiere par defaut |
254 |
} |
} |
255 |
|
|
256 |
// On renvoi le tableau de parametres pour la connexion a la base |
// On renvoi le tableau de parametres pour la connexion a la base |
|
//print ' $coll:'.$coll.' '; |
|
|
//print ' database:'; |
|
|
//print_r($this->database[$coll]); |
|
257 |
$this->database_config = $this->database[$coll]; |
$this->database_config = $this->database[$coll]; |
258 |
} |
} |
259 |
|
|
292 |
$this->display(); |
$this->display(); |
293 |
} |
} |
294 |
// On arrete le script |
// On arrete le script |
|
//print 'and we die'; |
|
295 |
die(); |
die(); |
296 |
} else { |
} else { |
297 |
// On affecte la resource a l'attribut de la classe du meme nom |
// On affecte la resource a l'attribut de la classe du meme nom |
389 |
} |
} |
390 |
} |
} |
391 |
|
|
392 |
|
/** |
393 |
|
* Envoie un mail avec piece jointe |
394 |
|
* |
395 |
|
* @param string $title Titre du mail |
396 |
|
* @param string $message Corps du mail |
397 |
|
* @param string $recipient Destinataire du mail |
398 |
|
* @param array $file Destinataire du mail |
399 |
|
* @access public |
400 |
|
* @return bool True si le mail est correctement envoye, false sinon. |
401 |
|
*/ |
402 |
|
public function sendMail($title, $message, $recipient, $file = array()) { |
403 |
|
|
404 |
|
@include_once "../php/phpmailer/class.phpmailer.php"; |
405 |
|
|
406 |
|
if (!class_exists("PHPMailer")) { |
407 |
|
$this->addToLog("sendMail(): !class_exists(\"PHPMailer\")", DEBUG_MODE); |
408 |
|
return false; |
409 |
|
} |
410 |
|
|
411 |
|
// |
412 |
|
$this->setMailConfig(); |
413 |
|
|
414 |
|
// |
415 |
|
if ($this->mail_config == false) { |
416 |
|
$this->addToLog("sendMail(): aucune configuration mail", DEBUG_MODE); |
417 |
|
return false; |
418 |
|
} |
419 |
|
|
420 |
|
// |
421 |
|
$mail = new PHPMailer(true); |
422 |
|
|
423 |
|
// |
424 |
|
$mail->IsSMTP(); |
425 |
|
|
426 |
|
$mail->SMTPAuth = true; // enable SMTP authentication |
427 |
|
$mail->SMTPSecure = "tls"; |
428 |
|
$mail->Username = $this->mail_config["mail_username"]; |
429 |
|
$mail->Password = $this->mail_config["mail_pass"]; |
430 |
|
if ($this->mail_config["mail_username"] == '') { |
431 |
|
$mail->SMTPAuth = false; |
432 |
|
} else { |
433 |
|
$mail->SMTPAuth = true; |
434 |
|
} |
435 |
|
$mail->Port = $this->mail_config["mail_port"]; |
436 |
|
$mail->Host = $this->mail_config["mail_host"]; |
437 |
|
$mail->AddReplyTo($this->mail_config["mail_from"], $this->mail_config["mail_from_name"]); |
438 |
|
$mail->From = $this->mail_config["mail_from"]; |
439 |
|
$mail->FromName = $this->mail_config["mail_from_name"]; |
440 |
|
foreach (explode(",",$recipient) as $adresse) { |
441 |
|
if (!$this->checkValidEmailAddress($adresse)) { |
442 |
|
$this->addToLog("sendMail(): courriel incorrect ".$adresse, DEBUG_MODE); |
443 |
|
return false; |
444 |
|
} else |
445 |
|
$mail->AddAddress(trim($adresse)); |
446 |
|
} |
447 |
|
$mail->IsHTML(true); |
448 |
|
|
449 |
|
// Corps du message |
450 |
|
$mail_body ="<html>"; |
451 |
|
$mail_body .= "<head><title>".$title."</title></head>"; |
452 |
|
$mail_body .= "<body>".$message."</body>"; |
453 |
|
$mail_body .= "</html>"; |
454 |
|
|
455 |
|
$mail->Subject = $title; |
456 |
|
$mail->MsgHTML($mail_body); |
457 |
|
foreach($file as $oneFile) { |
458 |
|
|
459 |
|
if($oneFile['stream']){ |
460 |
|
$mail->AddStringAttachment($oneFile['content'], $oneFile['title'], $oneFile['encoding'] = 'base64',$oneFile['type'] = 'application/octet-stream'); |
461 |
|
} else{ |
462 |
|
$mail->AddAttachment($oneFile['url']); |
463 |
|
} |
464 |
|
} |
465 |
|
// Envoie de l'email |
466 |
|
if ($mail->Send()) { |
467 |
|
return true; |
468 |
|
} else { |
469 |
|
$this->addToLog("sendMail(): ".$mail->ErrorInfo, DEBUG_MODE); |
470 |
|
return false; |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
} |
} |
475 |
|
|