useConn($sql); $article = mysql_fetch_array($liste); $unMenu = new menu(0); $unMenu->copierA($article); $unMenu->refaireListeMets(); return($unMenu); } function liste_evenements_a_venir() { $evenement = new evenement(""); return($evenement->listeAuto("Date DESC LIMIT 3", "Date>=NOW()")); } function liste_evenements_recents() { $evenement = new evenement(""); return($evenement->listeAuto("Date DESC LIMIT 4", "Dateread())) { if(!is_dir("./" . $fichier) and !in_array($fichier,array(".", "..", ".DAV"))) { $this->liste[] = $repertoire_de_base . $fichier; } } sort($this->liste); } function nombre() { return count($this->liste); } } class mets extends cadeul { function mets($entree, $id="") { $this->nomTable = "pub_menu_mets"; $this->nomID = "MetsID"; if($entree==0) $this->a = ""; elseif(is_array($entree)) { $num = $this->creer($entree, $id); $this->selectionner($num); } elseif(is_numeric($entree)) $this->selectionner($entree); } function afficher() { $afficher = $this->a["Mets"]; if(strstr($afficher,"(repas santé)")) { $afficher = str_replace("(repas santé)", "", $afficher); $classe = "sante"; } else $classe = "normal"; $afficher = "$afficher"; return($afficher); } function getCout() { return number_format($this->a["Cout"], 2, ',', ' '); } } class menu extends cadeul { var $listeMets; function menu($entree) { $this->nomTable = "pub_menu"; $this->nomID = "MenuID"; if($entree==0) $this->a = ""; elseif(is_array($entree)) { $num = $this->creerMenu($entree); $this->selectionner($num); } elseif(is_numeric($entree)) { $this->selectionner($entree); $this->refaireListeMets(); } } function parDate($date) { $sql = "SELECT * FROM " . $this->nomTable . " WHERE Date='$date'"; $liste = $this->useConn($sql); $this->a = mysql_fetch_array($liste); } function refaireListeMets() { $this->listeMets = ""; $mets = new mets(0); $sql = "SELECT * FROM " . $mets->nomTable . " WHERE MenuID=" . $this->a["MenuID"] . " ORDER BY Num"; $liste = $this->useConn($sql); while($article = mysql_fetch_array($liste)) { $mets = new mets(0); $mets->copierA($article); $this->listeMets[$mets->a["Num"]] = $mets; } } function creerMenu($post) { $menuID = $this->creer($post); for($cpt=1;$cpt<=6;$cpt++) { $post["pub_menu_mets-" . $cpt . "num_MenuID"] = $menuID; $this->listeMets[$cpt] = new mets($post, $cpt); } return($menuID); } function supprimerMenu() { for($cpt=1;$cpt<=8;$cpt++) { $unMets = $this->listeMets[$cpt]; $unMets->supprimer(); } $this->supprimer(); } function afficher($papier = "") { if(!$this->a) $chaine = "Nous sommes désolés, mais le menu n'est pas disponible actuellement. Veuillez revenir un peu plus tard."; else { if(!$this->listeMets) $this->refaireListeMets(); $chaine = ""; $chaine .= ""; foreach($this->listeMets as $mets) $chaine .= $mets->afficher($papier) . " "; $chaine .= "
"; } return($chaine); } function afficherPouce($papier="") { $chaine .= ""; $mets = $this->listeMets[1]; if($mets) $chaine .= $mets->afficherPouce($papier) . " "; $chaine .= "
"; return($chaine); } function afficherDate() { $chaine = strftime("%A %d %B %Y", strtotime($this->a["Date"])); $chaine = str_replace(" 0", " ", $chaine); return($chaine); } function modifierMenu($donnees) { $this->refaireListeMets(); $this->modifier($donnees); for($cpt=1;$cpt<=8;$cpt++) { $unMets = $this->listeMets[$cpt]; if($unMets) $unMets->modifier($donnees); } } function envoyerCourriel() { //require_once('sec.class.inc.php'); $sec = new sec('Liste menu du jour du PUB', 'pub-menu@cadeul.ulaval.ca', "PUB universitaire", "cadeul@cadeul.ulaval.ca"); //$sec = new sec('Liste menu du jour du PUB', 'yanick.landry.1@ulaval.ca', "PUB universitaire", "cadeul@cadeul.ulaval.ca"); $img = array(); $img[0] = 'images/spacer.gif'; for($cpt=1; $cpt<15; $cpt++) { if(!in_array($cpt, array(5,7,8,9,10,11))) $img[$cpt] = 'images/menudujourinternet_' . ($cpt<10?"0":"") . $cpt . '.png'; } foreach($img as $clef=>$valeur) $images[$clef] = $sec->embed($valeur); $sujet = "PUB - menu du jour (" . $this->afficherDate() . ")"; $message = $this->afficherInternet($images); $sec->buildMessage($sujet, $message); #build and send the email if($sec->sendmail()) { //return(true); //echo 'Your Email Was Sent'; return($message); } else { return(false); //echo 'Your Email Failed to be Sent'; } } /* $unCourriel = new courriel(); $unCourriel->de = "PUB universitaire "; //$unCourriel->pour = "pub-menu@cadeul.ulaval.ca"; $unCourriel->pour = "webmestre@cadeul.ulaval.ca"; $unCourriel->sujet = "PUB - menu du jour (" . $this->afficherDate() . ")"; $unCourriel->message = $this->afficherInternet(); $unCourriel->repBaseLocal = "/var/www/vhosts/cadeul/pub/images/"; $unCourriel->repBaseWeb = "http://www.cadeul.ulaval.ca/pub/images/"; for($cpt = 1; $cpt<=15; $cpt++) { $chaine = ($cpt<10?"0":"") . $cpt; $unCourriel->ajouterFichier("menudujourinternet_$chaine.png"); } $erreur = $unCourriel->envoyer(); } */ } class evenement extends cadeul { function evenement($entree) { $this->nomTable = "pub_evenement"; $this->nomID = "Chaine"; if($entree==0 and is_numeric($entree)) $this->a = ""; elseif($entree=="en_vedette") { $vieilID = $this->nomID; $this->nomID = "EnVedette"; $this->selectionner(1); $this->nomID = $vieilID; } elseif(is_array($entree)) $this->a = $entree; elseif(is_string($entree)) $this->selectionnerChaine($entree); elseif(is_numeric($entree)) { $vieilID = $this->nomID; $this->nomID = "ID"; $this->selectionner($entree); $this->nomID = $vieilID; } } function estRecent() { $sql = "SELECT COUNT(*) as nb FROM pub_evenement WHERE DateuseConn($sql); $article = mysql_fetch_array($liste); if($article and $article["nb"] >0) return(true); else return(false); } function affiche() { $base = "../img/Bannieres/PUB/330_Affiche/" . $this->a["Chaine"] . "."; if(file_exists($base . "png")) return($base . "png"); elseif(file_exists($base . "jpg")) return($base . "jpg"); else return(""); } function afficherDate() { $chaine = strftime("%A %d %B %Y", strtotime($this->a["Date"])); $chaine = str_replace(" 0", " ", $chaine); $chaine = htmlentities($chaine); return($chaine); } } $lePub = new lePub(); ?>