function creerEntite($login) { $idEntite = "rien"; $nom = $_POST['nom']; $data = $_POST['data']; $arch = new Archiviste(); $entite = new Entite(); $entite->set('nom', $nom); $entite->set('data', $data); $entite->set('userName', $login); $entite->set('date', time()); if ($nom && $nom != "") { $idEntite = $arch->archiver($entite); } return array('idEntite' => $idEntite); }
public static function enregistrerComment($id, $pseudo, $message) { $nomSite = Config::getVal('nom', 'core/data/'); $adresseSite = Config::getVal('adresse', 'core/data/'); $message = str_replace("<", "<", $message); $message = str_replace(">", ">", $message); $message = str_replace("\\'", "'", $message); $message = str_replace('\\"', '"', $message); $message = str_replace(CHR(10), "<br>", $message); $pseudo = str_replace("<", "<", $pseudo); $pseudo = str_replace(">", ">", $pseudo); $pseudo = str_replace("\\'", "'", $pseudo); $pseudo = str_replace('\\"', '"', $pseudo); //date_default_timezone_set('Europe/Paris'); //$date = date('Y-m-d H\hi'); $date = time(); $comment = new Archivable('Commentaire'); $comment->set('ip', $_SERVER['REMOTE_ADDR']); $comment->set('id_article', $id); $comment->set('pseudo', $pseudo); $comment->set('texte', $message); //verification que le commentaire n'a as déja été enregistré $arch = new Archiviste(Commentaire::$dbSite); $commsTest = $arch->restituer($comment); $retour = false; if (count($commsTest) == 0) { $comment->set('date', $date); $arch->archiver($comment); //on informe l'admin qu'un commentaire a été posté $corps_message = 'Nouveau commentaire de ' . $pseudo . ' (<a href="http://' . $adresseSite . '/?mod=site&art=' . $id . '">lien vers l\'article</a>)' . PHP_EOL . '<br />' . PHP_EOL . $message; $headers = 'Content-type: text/html; charset=UTF-8' . "\r\n" . 'From: "' . $nomSite . '"<robot@' . $adresseSite . '>' . "\r\n"; mail(Config::getVal('mail', 'core/data/'), 'Nouveau commentaire', $corps_message, $headers); $retour = true; } return $retour; }
function postCom(&$vueAgenda, $estModerateur, $idUser, $login) { $texteCom = ''; $idEvent = ''; $nomEvent = ''; $dateEvent = '0'; if (isset($_POST['textCom'])) { $texteCom = $_POST['textCom']; } if (isset($_GET['id'])) { $idEvent = $_GET['id']; } if (isset($_POST['nomEvent'])) { $nomEvent = $_POST['nomEvent']; } if (isset($_POST['dateEvent'])) { $dateEvent = $_POST['dateEvent']; } if ($idEvent && $texteCom) { $arch = new Archiviste(); $postEvent = new EventCom(); $postEvent->set('idEvent', $idEvent); $postEvent->set('texte', $texteCom); $postEvent->set('login', $login); $postEvent->set('date', time()); $arch->archiver($postEvent); mailCom($idEvent, $nomEvent, $dateEvent, $texteCom, $login); } $vueAgenda->postCommentOk($idEvent); }
function ajoutFil() { $idSection = $_REQUEST['idSection']; $texte = convertDataSent($_REQUEST['texte']); $titre = convertDataSent($_REQUEST['titre']); //recherche de tentative d'intrusion $intrusion = Securisator::checkIntrusion($texte); if (!$intrusion) { $intrusion = preg_match('/<\\/*\\s*script.*>/', $titre); } if ($intrusion) { $reponse = array('statut' => 'intrusion'); } else { $reponse = array('statut' => 'ok'); $arch = new Archiviste(); $fil = new Fil(); $fil->set('nom', $titre); $fil->set('idSection', $idSection); $fil->set('idUser', $_SESSION['id']); $idFil = $arch->archiver($fil); $post = new Post(); date_default_timezone_set('Europe/Paris'); $date = time(); $post->set('idUser', $_SESSION['id']); $post->set('texte', $texte); $post->set('idFil', $idFil); $post->set('date', $date); $idPost = $arch->archiver($post); $reponse['idFil'] = $idFil; $fil = new Fil(); $fil->set('id', $idFil); $filNew = new Fil(); $filNew->set('idPost', $idPost); $arch->modifier($fil, $filNew); $section = new Section(); $section->set('id', $idSection); $sectionNew = new Section(); $sectionNew->set('idFil', $idFil); $arch->modifier($section, $sectionNew); } return $reponse; }
function ajoutUser() { $retour = array('statut' => 'ok'); $login = $_REQUEST['login']; $pass = md5($_REQUEST['pass']); $droits = $_REQUEST['droits']; $arch = new Archiviste('../../auth/data/'); $user = new Archivable('User'); $user->set('login', $login); $users = $arch->restituer($user); if (count($users) > 0) { $retour = array('statut' => 'doublon'); } else { $user->set('pass', $pass); $user->set('droits', $droits); $arch->archiver($user); } return $retour; }
public function checkActivation($cle) { $this->cleanExpire(); $retour = 'nok'; $arch = new Archiviste(); $token = new Token(); $token->set('cle', $cle); $tokens = $arch->restituer($token); if (count($tokens) > 0) { $login = $tokens[0]->get('login'); $pass = $tokens[0]->get('pass'); $mail = $tokens[0]->get('mail'); $user = new User(); $user->set('login', $login); $users1 = $arch->restituer($user); $user = new User(); $user->set('mail', $mail); $users2 = $arch->restituer($user); if (count($users1) == 0 && count($users2) == 0) { $user->set('login', $login); $user->set('pass', md5($pass)); $user->set('droits', "standard"); $arch->archiver($user); $arch->supprimer($token); $retour = 'ok'; } else { $retour = 'duplicate'; } } return $retour; }