# module actuel $okt->page->module = 'guestbook'; $okt->page->action = 'list'; # -- CORE TRIGGER : publicModuleGuestbookControllerStart $okt->triggers->callTrigger('publicModuleGuestbookControllerStart', $okt, $okt->guestbook->config->captcha); $aSigData = array('language' => $okt->user->language, 'message' => '', 'nom' => '', 'email' => '', 'url' => 'http://', 'note' => 'nc'); # formulaire envoyé if (!empty($_POST['sign'])) { $aSigData = array('language' => isset($_POST['language']) ? $_POST['language'] : $okt->user->language, 'message' => isset($_POST['msg']) ? $_POST['msg'] : null, 'nom' => isset($_POST['nom']) ? $_POST['nom'] : null, 'email' => isset($_POST['email']) ? $_POST['email'] : null, 'url' => isset($_POST['url']) ? $_POST['url'] : 'http://', 'note' => isset($_POST['note']) ? $_POST['note'] : null, 'ip' => http::realIP(), 'visible' => $okt->guestbook->config->validation ? 0 : 1); $aSigData = $okt->guestbook->handleUserData($aSigData); # -- CORE TRIGGER : publicModuleGuestbookControllerFormCheckValues $okt->triggers->callTrigger('publicModuleGuestbookControllerFormCheckValues', $okt); if (!$okt->error->hasError()) { if ($okt->guestbook->addSig($aSigData)) { if ($okt->guestbook->config->emails_list != '') { $oMail = new oktMail($okt); $oMail->setFrom(); $oMail->message->setSubject('Nouveau message sur le livre d’or de ' . util::getSiteTitle()); $mail_body = 'Bonjour,' . "\n\n" . 'Un utilisateur a laissé un nouveau message ' . 'sur le livre d’or de "' . util::getSiteTitle() . '".' . "\n\n"; if ($okt->guestbook->config->validation) { $mail_body .= 'Ce nouveau message peut être validé ' . 'en vous rendant sur l’administration.' . "\n\n"; } $mail_body .= 'Cordialement' . PHP_EOL . PHP_EOL . '--' . PHP_EOL . 'Email automatique,' . PHP_EOL . 'ne repondez pas à ce message'; $oMail->message->setBody($mail_body); $dests = array_map('trim', explode(',', $okt->guestbook->config->emails_list)); $oMail->message->setTo($dests); $oMail->send(); } http::redirect($okt->guestbook->config->url . '?added=1'); } }
/** * Affichage de la page de récapitulatif de demande de devis. * */ public function estimateSummary() { # module actuel $this->okt->page->module = 'estimate'; $this->okt->page->action = 'summary'; # si on as pas de données en session on renvoi sur le formulaire if (empty($_SESSION['okt_mod_estimate_form_data'])) { http::redirect($this->okt->page->getBaseUrl() . $this->okt->estimate->config->public_form_url[$this->okt->user->language]); } # récupération des produits et des accessoires $rsProducts = $this->okt->estimate->products->getProducts(); $aProducts = array(); $aProductsAccessories = array(); while ($rsProducts->fetch()) { $aProducts[$rsProducts->id] = html::escapeHTML($rsProducts->title); if ($this->okt->estimate->config->enable_accessories) { $rsAccessories = $this->okt->estimate->accessories->getAccessories(array('product_id' => $rsProducts->id)); if (!$rsAccessories->isEmpty()) { $aProductsAccessories[$rsProducts->id] = array(); while ($rsAccessories->fetch()) { $aProductsAccessories[$rsProducts->id][$rsAccessories->id] = html::escapeHTML($rsAccessories->title); } } unset($rsAccessories); } } unset($rsProducts); # formatage des données $aFormatedData = $_SESSION['okt_mod_estimate_form_data']; unset($aFormatedData['products'], $aFormatedData['product_quantity'], $aFormatedData['accessories'], $aFormatedData['accessory_quantity']); foreach ($_SESSION['okt_mod_estimate_form_data']['products'] as $iProductCounter => $iProductId) { $aFormatedData['products'][$iProductCounter] = array('title' => $aProducts[$iProductId], 'quantity' => $_SESSION['okt_mod_estimate_form_data']['product_quantity'][$iProductCounter], 'accessories' => array()); if (!empty($_SESSION['okt_mod_estimate_form_data']['accessories'][$iProductCounter])) { foreach ($_SESSION['okt_mod_estimate_form_data']['accessories'][$iProductCounter] as $iAccessoryCounter => $iAccessoryId) { $aFormatedData['products'][$iProductCounter]['accessories'][$iAccessoryCounter] = array('title' => $aProductsAccessories[$iProductId][$iAccessoryId], 'quantity' => $_SESSION['okt_mod_estimate_form_data']['accessory_quantity'][$iProductCounter][$iAccessoryCounter]); } } } # enregistrement de la demande if (!empty($_GET['send'])) { if (($iEstimateId = $this->okt->estimate->addEstimate($aFormatedData)) !== false) { unset($_SESSION['okt_mod_estimate_form_data']); # notifications if ($this->okt->estimate->config->enable_notifications) { $aRecipients = array(); if (!empty($this->okt->estimate->config->notifications_recipients)) { $aRecipients = array_map('trim', explode(',', $this->okt->estimate->config->notifications_recipients)); } if (empty($aRecipients)) { if (!empty($this->config->email['name'])) { $aRecipients = array($this->okt->config->email['to'] => html::escapeHTML($this->config->email['name'])); } else { $aRecipients = array($this->okt->config->email['to']); } } # construction du mail $sEstimateUrl = $this->okt->config->app_host . $this->okt->config->app_path . OKT_ADMIN_DIR . '/module.php?m=estimate&action=estimate&estimate_id=' . $iEstimateId; $oMail = new oktMail($this->okt); $oMail->setFrom(); $oMail->message->setTo($aRecipients); $oMail->useFile(dirname(__FILE__) . '/../locales/' . $this->okt->user->language . '/mails_tpl/admin_notification.tpl', array('SITE_TITLE' => html::escapeHTML(util::getSiteTitle()), 'USER_FIRSTNAME' => $aFormatedData['firstname'], 'USER_LASTNAME' => $aFormatedData['lastname'], 'ADMIN_ESTIMATE_URL' => html::escapeHTML($sEstimateUrl))); $oMail->send(); } http::redirect($this->okt->page->getBaseUrl() . $this->okt->estimate->config->public_form_url[$this->okt->user->language] . '?added=1'); } } # meta description if ($this->okt->estimate->config->meta_description[$this->okt->user->language] != '') { $this->okt->page->meta_description = $this->okt->estimate->config->meta_description[$this->okt->user->language]; } else { $this->okt->page->meta_description = util::getSiteMetaDesc(); } # meta keywords if ($this->okt->estimate->config->meta_keywords[$this->okt->user->language] != '') { $this->okt->page->meta_keywords = $this->okt->estimate->config->meta_keywords[$this->okt->user->language]; } else { $this->okt->page->meta_keywords = util::getSiteMetaKeywords(); } # title tag du module $this->okt->page->addTitleTag($this->okt->estimate->getTitle()); # fil d'ariane if (!$this->isDefaultRoute(__CLASS__, __FUNCTION__)) { $this->okt->page->breadcrumb->add($this->okt->estimate->getName(), $this->okt->estimate->config->url); } # titre de la page $this->okt->page->setTitle($this->okt->estimate->getName()); # titre SEO de la page $this->okt->page->setTitleSeo($this->okt->estimate->getNameSeo()); # affichage du template echo $this->okt->tpl->render('estimate/summary/' . $this->okt->estimate->config->templates['summary']['default'] . '/template', array('aEstimateData' => $aFormatedData)); }
/** * Réalise une inscription. * */ protected function performRegister() { # default data $this->aUserRegisterData = array('civility' => 1, 'username' => '', 'lastname' => '', 'firstname' => '', 'password' => '', 'password_confirm' => '', 'email' => '', 'group_id' => $this->okt->users->config->default_group, 'timezone' => $this->okt->config->timezone, 'language' => $this->okt->config->language); # Champs personnalisés if ($this->okt->users->config->enable_custom_fields) { $aPostedData = array(); # Liste des champs $this->rsUserFields = $this->okt->users->fields->getFields(array('status' => true, 'user_editable' => true, 'register' => true, 'language' => $this->okt->user->language)); # Valeurs des champs $rsFieldsValues = $this->okt->users->fields->getUserValues($this->okt->user->id); $aFieldsValues = array(); while ($rsFieldsValues->fetch()) { $aFieldsValues[$rsFieldsValues->field_id] = $rsFieldsValues->value; } # Initialisation des données des champs while ($this->rsUserFields->fetch()) { switch ($this->rsUserFields->type) { default: case 1: # Champ texte # Champ texte case 2: # Zone de texte $aPostedData[$this->rsUserFields->id] = !empty($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : ''); break; case 3: # Menu déroulant $aPostedData[$this->rsUserFields->id] = isset($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : ''); break; case 4: # Boutons radio $aPostedData[$this->rsUserFields->id] = isset($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : ''); break; case 5: # Cases à cocher $aPostedData[$this->rsUserFields->id] = !empty($_POST[$this->rsUserFields->html_id]) && is_array($_POST[$this->rsUserFields->html_id]) ? $_POST[$this->rsUserFields->html_id] : (!empty($aFieldsValues[$this->rsUserFields->id]) ? $aFieldsValues[$this->rsUserFields->id] : ''); break; } } } # ajout d'un utilisateur if (!empty($_POST['add_user'])) { $this->aUserRegisterData = array('active' => 1, 'username' => !empty($_POST['add_username']) ? $_POST['add_username'] : '', 'lastname' => !empty($_POST['add_lastname']) ? $_POST['add_lastname'] : '', 'firstname' => !empty($_POST['add_firstname']) ? $_POST['add_firstname'] : '', 'password' => !empty($_POST['add_password']) ? $_POST['add_password'] : '', 'password_confirm' => !empty($_POST['add_password_confirm']) ? $_POST['add_password_confirm'] : '', 'email' => !empty($_POST['add_email']) ? $_POST['add_email'] : '', 'group_id' => $this->okt->users->config->user_choose_group && !empty($_POST['add_group_id']) && in_array($_POST['add_group_id'], $this->getGroups()) ? $_POST['add_group_id'] : $this->okt->users->config->default_group, 'timezone' => !empty($_POST['add_timezone']) ? $_POST['add_timezone'] : $this->okt->config->timezone, 'language' => !empty($_POST['add_language']) && in_array($_POST['add_language'], $this->getLanguages()) ? $_POST['add_language'] : $this->okt->config->language, 'civility' => !empty($_POST['add_civility']) ? $_POST['add_civility'] : ''); if ($this->okt->users->config->merge_username_email) { $this->aUserRegisterData['username'] = $this->aUserRegisterData['email']; } # vérification des champs personnalisés obligatoires if ($this->okt->users->config->enable_custom_fields) { while ($this->rsUserFields->fetch()) { if ($this->rsUserFields->active == 2 && empty($aPostedData[$this->rsUserFields->id])) { $this->okt->error->set('Vous devez renseigner le champ "' . html::escapeHtml($this->rsUserFields->title) . '".'); } } } if (($new_id = $this->okt->users->addUser($this->aUserRegisterData)) !== false) { $_POST['user_id'] = $new_id; # -- CORE TRIGGER : adminModUsersRegisterProcess $this->okt->triggers->callTrigger('adminModUsersRegisterProcess', $this->okt, $_POST); $rsUser = $this->okt->users->getUser($new_id); if ($this->okt->users->config->enable_custom_fields) { while ($this->rsUserFields->fetch()) { $this->okt->users->fields->setUserValues($new_id, $this->rsUserFields->id, $aPostedData[$this->rsUserFields->id]); } } # Initialisation du mailer et envoi du mail $oMail = new oktMail($this->okt); $oMail->setFrom(); if ($this->okt->users->config->validate_users_registration) { $template_file = 'welcom_waiting.tpl'; } else { $template_file = 'welcom.tpl'; } $oMail->useFile(__DIR__ . '/../locales/' . $rsUser->language . '/templates/' . $template_file, array('SITE_TITLE' => util::getSiteTitle($rsUser->language), 'SITE_URL' => $this->okt->config->app_url, 'USER_CN' => oktAuth::getUserCN($rsUser->username, $rsUser->lastname, $rsUser->firstname), 'USERNAME' => $rsUser->username, 'PASSWORD' => $this->aUserRegisterData['password'])); $oMail->message->setTo($rsUser->email); $oMail->send(); # Initialisation du mailer et envoi du mail à l'administrateur if ($this->okt->users->config->mail_new_registration) { $oMail = new oktMail($this->okt); $oMail->setFrom(); if ($this->okt->users->config->validate_users_registration) { $template_file = 'registration_validate.tpl'; } else { $template_file = 'registration.tpl'; } $rsAdministrators = $this->okt->users->getUsers(array('group_id' => oktAuth::admin_group_id)); while ($rsAdministrators->fetch()) { $oMail->useFile(__DIR__ . '/../locales/' . $rsAdministrators->language . '/templates/' . $template_file, array('SITE_TITLE' => util::getSiteTitle($rsUser->language), 'SITE_URL' => $this->okt->config->app_url, 'USER_CN' => oktAuth::getUserCN($rsUser->username, $rsUser->lastname, $rsUser->firstname), 'PROFIL' => $this->okt->config->app_url . OKT_ADMIN_DIR . '/module.php?m=users&action=edit&id=' . $rsUser->id)); $oMail->message->setTo($rsAdministrators->email); $oMail->send(); } } # eventuel connexion du nouvel utilisateur if (!$this->okt->users->config->validate_users_registration && $this->okt->users->config->auto_log_after_registration) { $this->okt->user->login($this->aUserRegisterData['username'], $this->aUserRegisterData['password'], false); } $this->performRedirect(); // $this->unsetSessionRedirectUrl(); // http::redirect(usersHelpers::getRegisterUrl().'?registered=1'); } } }
$oMail->setFrom(); $oMail->useFile(__DIR__ . '/../../locales/' . $edit_language . '/templates/validate_user.tpl', array('SITE_TITLE' => util::getSiteTitle($edit_language), 'SITE_URL' => $okt->config->app_url)); $oMail->message->setTo($edit_email); $oMail->send(); $okt->page->flashMessages->addSuccess(__('m_users_validated_user')); $okt->redirect('module.php?m=users&action=edit&id=' . $aEditPageInfos['iUserId']); } } # Formulaire de changement de mot de passe if (!empty($_POST['change_password']) && $okt->checkPerm('change_password') && $okt->checkPerm('users_edit')) { $upd_params = array('id' => $aEditPageInfos['iUserId']); $upd_params['password'] = !empty($_POST['edit_password']) ? $_POST['edit_password'] : ''; $upd_params['password_confirm'] = !empty($_POST['edit_password_confirm']) ? $_POST['edit_password_confirm'] : ''; if ($okt->users->changeUserPassword($upd_params)) { if (!empty($_POST['send_password_mail'])) { $oMail = new oktMail($okt); $oMail->setFrom(); $oMail->useFile(__DIR__ . '/../../locales/' . $edit_language . '/templates/admin_change_user_password.tpl', array('SITE_TITLE' => util::getSiteTitle($edit_language), 'SITE_URL' => $okt->config->app_url, 'NEW_PASSWORD' => $upd_params['password'])); $oMail->message->setTo($edit_email); $oMail->send(); } $okt->page->flashMessages->addSuccess(__('m_users_user_edited')); $okt->redirect('module.php?m=users&action=edit&id=' . $aEditPageInfos['iUserId']); } } # Formulaire de modification de l'utilisateur envoyé if (!empty($_POST['form_sent']) && !isset($_POST['do']) && $okt->checkPerm('users_edit')) { $upd_params = array('id' => $aEditPageInfos['iUserId']); if (isset($_POST['edit_civility'])) { $upd_params['civility'] = $_POST['edit_civility']; }
/** * Envoi un email avec un nouveau mot de passe. * * @param string $sEmail L'adresse email où envoyer le nouveau mot de passe * @param string $sActivateUrl L'URL de la page de validation * @return boolean */ public function forgetPassword($sEmail, $sActivateUrl) { $sEmail = strtolower(trim($sEmail)); # validation de l'adresse fournie if (!text::isEmail($sEmail)) { $this->oError->set(__('c_c_auth_invalid_email')); return false; } # récupération des infos de l'utilisateur $sQuery = 'SELECT id, username, lastname, firstname, salt ' . 'FROM ' . $this->t_users . ' ' . 'WHERE email=\'' . $this->oDb->escapeStr($sEmail) . '\''; if (($rs = $this->oDb->select($sQuery)) === false) { return false; } if ($rs->isEmpty()) { $this->oError->set(__('c_c_auth_unknown_email')); return false; } while ($rs->fetch()) { # génération du nouveau mot de passe et du code d'activation $sNewPassword = util::random_key(8, true); $sNewPasswordKey = util::random_key(8); $sPasswordHash = password::hash($sNewPassword, PASSWORD_DEFAULT); $sQuery = 'UPDATE ' . $this->t_users . ' SET ' . 'activate_string=\'' . $sPasswordHash . '\', ' . 'activate_key=\'' . $sNewPasswordKey . '\' ' . 'WHERE id=' . (int) $rs->id; if (!$this->oDb->execute($sQuery)) { return false; } # Initialisation du mailer et envoi du mail $oMail = new oktMail($this->okt); $oMail->setFrom(); $oMail->message->setTo($sEmail); $oMail->useFile(OKT_LOCALES_PATH . '/' . $this->okt->user->language . '/templates/activate_password.tpl', array('SITE_TITLE' => util::getSiteTitle(), 'SITE_URL' => $this->okt->config->app_url, 'USERNAME' => self::getUserCN($rs->username, $rs->lastname, $rs->firstname), 'NEW_PASSWORD' => $sNewPassword, 'ACTIVATION_URL' => $sActivateUrl . '?action=validate_password&uid=' . $rs->id . '&key=' . rawurlencode($sNewPasswordKey))); $oMail->send(); } return true; }
/** * Affichage de la page guestbook. * */ public function guestbookPage() { # module actuel $this->okt->page->module = 'guestbook'; $this->okt->page->action = 'list'; # -- CORE TRIGGER : publicModuleGuestbookControllerStart $this->okt->triggers->callTrigger('publicModuleGuestbookControllerStart', $this->okt, $this->okt->guestbook->config->captcha); $aSigData = array('language' => $this->okt->user->language, 'message' => '', 'nom' => '', 'email' => '', 'url' => 'http://', 'note' => 'nc'); # formulaire envoyé if (!empty($_POST['sign'])) { $aSigData = array('language' => isset($_POST['language']) ? $_POST['language'] : $this->okt->user->language, 'message' => isset($_POST['msg']) ? $_POST['msg'] : null, 'nom' => isset($_POST['nom']) ? $_POST['nom'] : null, 'email' => isset($_POST['email']) ? $_POST['email'] : null, 'url' => isset($_POST['url']) ? $_POST['url'] : 'http://', 'note' => isset($_POST['note']) ? $_POST['note'] : null, 'ip' => http::realIP(), 'visible' => $this->okt->guestbook->config->validation ? 0 : 1); $aSigData = $this->okt->guestbook->handleUserData($aSigData); # -- CORE TRIGGER : publicModuleGuestbookControllerFormCheckValues $this->okt->triggers->callTrigger('publicModuleGuestbookControllerFormCheckValues', $this->okt, $this->okt->guestbook->config->captcha); if (!$this->okt->error->hasError()) { if ($this->okt->guestbook->addSig($aSigData)) { if ($this->okt->guestbook->config->emails_list != '') { $oMail = new oktMail($this->okt); $oMail->setFrom(); $oMail->message->setSubject('Nouveau message sur le livre d’or de ' . util::getSiteTitle()); $mail_body = 'Bonjour,' . "\n\n" . 'Un utilisateur a laissé un nouveau message ' . 'sur le livre d’or de "' . util::getSiteTitle() . '".' . "\n\n"; if ($this->okt->guestbook->config->validation) { $mail_body .= 'Ce nouveau message peut être validé ' . 'en vous rendant sur l’administration.' . "\n\n"; } $mail_body .= 'Cordialement' . PHP_EOL . PHP_EOL . '--' . PHP_EOL . 'Email automatique,' . PHP_EOL . 'ne repondez pas à ce message'; $oMail->message->setBody($mail_body); $dests = array_map('trim', explode(',', $this->okt->guestbook->config->emails_list)); $oMail->message->setTo($dests); $oMail->send(); } http::redirect($this->okt->guestbook->config->url . '?added=1'); } } } # signatures à afficher $aGuestbookParams = array('is_not_spam' => true, 'is_visible' => true, 'language' => $this->okt->user->language); # initialisation de la pagination $iPage = !empty($_GET['page']) ? intval($_GET['page']) : 1; $oGuestbookPager = new publicPager($iPage, $this->okt->guestbook->getSig($aGuestbookParams, true), $this->okt->guestbook->config->nbparpage_public); $iNumPages = $oGuestbookPager->getNbPages(); # récupération des signatures $aGuestbookParams['limit'] = ($iPage - 1) * $this->okt->guestbook->config->nbparpage_public . ',' . $this->okt->guestbook->config->nbparpage_public; $signaturesList = $this->okt->guestbook->getSig($aGuestbookParams); $aLanguages = array(); foreach ($this->okt->languages->list as $aLanguage) { if (isset($this->okt->guestbook->config->public_url[$aLanguage['code']])) { $aLanguages[$aLanguage['title']] = $aLanguage['code']; } } # formatage des données $num_sig = 0; while ($signaturesList->fetch()) { $signaturesList->number = ++$num_sig; # note if ($this->okt->guestbook->config->chp_note) { if (!is_numeric($signaturesList->note)) { $signaturesList->note = 'nc'; } else { $signaturesList->note = ceil($signaturesList->note) . '/20'; } } else { $signaturesList->note = null; } } # meta description if ($this->okt->guestbook->config->meta_description[$this->okt->user->language] != '') { $this->okt->page->meta_description = $this->okt->guestbook->config->meta_description[$this->okt->user->language]; } else { $this->okt->page->meta_description = util::getSiteMetaDesc(); } # meta keywords if ($this->okt->guestbook->config->meta_keywords[$this->okt->user->language] != '') { $this->okt->page->meta_keywords = $this->okt->guestbook->config->meta_keywords[$this->okt->user->language]; } else { $this->okt->page->meta_keywords = util::getSiteMetaKeywords(); } # ajout du numéro de page au title if ($iPage > 1) { $this->okt->page->addTitleTag(sprintf(__('c_c_Page_%s'), $iPage)); } # title tag $this->okt->page->addTitleTag($this->okt->guestbook->getTitle()); # titre de la page $this->okt->page->setTitle($this->okt->guestbook->getName()); # titre SEO de la page $this->okt->page->setTitleSeo($this->okt->guestbook->getNameSeo()); # fil d'ariane de la page if (!$this->isDefaultRoute(__CLASS__, __FUNCTION__)) { $this->okt->page->breadcrumb->add($this->okt->guestbook->getName(), $this->okt->guestbook->config->url); } # raccourcis $signaturesList->numPages = $iNumPages; $signaturesList->pager = $oGuestbookPager; # affichage du template echo $this->okt->tpl->render('guestbook_tpl', array('aSigData' => $aSigData, 'signaturesList' => $signaturesList, 'aLanguages' => $aLanguages)); }