private function getCommentCursor($cur) { if ($cur->comment_content !== null && $cur->comment_content == '') { throw new Exception(__('You must provide a comment')); } if ($cur->comment_author !== null && $cur->comment_author == '') { throw new Exception(__('You must provide an author name')); } if ($cur->comment_email != '' && !text::isEmail($cur->comment_email)) { throw new Exception(__('Email address is not valid.')); } if ($cur->comment_site !== null && $cur->comment_site != '') { if (!preg_match('|^http(s?)://|i', $cur->comment_site, $matches)) { $cur->comment_site = 'http://' . $cur->comment_site; } else { $cur->comment_site = strtolower($matches[0]) . substr($cur->comment_site, strlen($matches[0])); } } if ($cur->comment_status === null) { $cur->comment_status = (int) $this->settings->system->comments_pub; } # Words list if ($cur->comment_content !== null) { $cur->comment_words = implode(' ', text::splitWords($cur->comment_content)); } }
if ($can_install && !empty($_POST)) { $u_email = !empty($_POST['u_email']) ? $_POST['u_email'] : null; $u_firstname = !empty($_POST['u_firstname']) ? $_POST['u_firstname'] : null; $u_name = !empty($_POST['u_name']) ? $_POST['u_name'] : null; $u_login = !empty($_POST['u_login']) ? $_POST['u_login'] : null; $u_pwd = !empty($_POST['u_pwd']) ? $_POST['u_pwd'] : null; $u_pwd2 = !empty($_POST['u_pwd2']) ? $_POST['u_pwd2'] : null; try { # Check user information if (empty($u_login)) { throw new Exception(__('No user ID given')); } if (!preg_match('/^[A-Za-z0-9@._-]{2,}$/', $u_login)) { throw new Exception(__('User ID must contain at least 2 characters using letters, numbers or symbols.')); } if ($u_email && !text::isEmail($u_email)) { throw new Exception(__('Invalid email address')); } if (empty($u_pwd)) { throw new Exception(__('No password given')); } if ($u_pwd != $u_pwd2) { throw new Exception(__("Passwords don't match")); } if (strlen($u_pwd) < 6) { throw new Exception(__('Password must contain at least 6 characters.')); } # Try to guess timezone $default_tz = 'Europe/London'; if (!empty($_POST['u_date']) && function_exists('timezone_open')) { if (preg_match('/\\((.+)\\)$/', $_POST['u_date'], $_tz)) {
if (!empty($_POST['form_sent'])) { $p_recipients_to = !empty($_POST['p_recipients_to']) && is_array($_POST['p_recipients_to']) ? array_unique(array_filter(array_map('trim', $_POST['p_recipients_to']))) : array(); $p_recipients_cc = !empty($_POST['p_recipients_cc']) && is_array($_POST['p_recipients_cc']) ? array_unique(array_filter(array_map('trim', $_POST['p_recipients_cc']))) : array(); $p_recipients_bcc = !empty($_POST['p_recipients_bcc']) && is_array($_POST['p_recipients_bcc']) ? array_unique(array_filter(array_map('trim', $_POST['p_recipients_bcc']))) : array(); foreach ($p_recipients_to as $mail) { if (!text::isEmail($mail)) { $okt->error->set(sprintf(__('m_contact_email_address_$s_is_invalid')), html::escapeHTML($mail)); } } foreach ($p_recipients_cc as $mail) { if (!text::isEmail($mail)) { $okt->error->set(sprintf(__('m_contact_email_address_$s_is_invalid')), html::escapeHTML($mail)); } } foreach ($p_recipients_bcc as $mail) { if (!text::isEmail($mail)) { $okt->error->set(sprintf(__('m_contact_email_address_$s_is_invalid')), html::escapeHTML($mail)); } } if ($okt->error->isEmpty()) { $new_conf = array('recipients_to' => (array) $p_recipients_to, 'recipients_cc' => (array) $p_recipients_cc, 'recipients_bcc' => (array) $p_recipients_bcc); try { $okt->contact->config->write($new_conf); $okt->page->flashMessages->addSuccess(__('c_c_confirm_configuration_updated')); $okt->redirect('module.php?m=contact&action=index'); } catch (InvalidArgumentException $e) { $okt->error->set(__('c_c_error_writing_configuration')); $okt->error->set($e->getMessage()); } } }
/** * Vérifie si l'email est valide * * @param $sEmail * @return void */ public function isEmail($sEmail) { if (!text::isEmail($sEmail)) { $this->error->set(sprintf(__('c_c_error_invalid_email'), html::escapeHTML($sEmail))); } }
public static function post($args) { if ($args == '') { # No entry was specified. self::p404(); } else { $_ctx =& $GLOBALS['_ctx']; $core =& $GLOBALS['core']; $core->blog->withoutPassword(false); $params = new ArrayObject(); $params['post_url'] = $args; $_ctx->posts = $core->blog->getPosts($params); $_ctx->comment_preview = new ArrayObject(); $_ctx->comment_preview['content'] = ''; $_ctx->comment_preview['rawcontent'] = ''; $_ctx->comment_preview['name'] = ''; $_ctx->comment_preview['mail'] = ''; $_ctx->comment_preview['site'] = ''; $_ctx->comment_preview['preview'] = false; $_ctx->comment_preview['remember'] = false; $core->blog->withoutPassword(true); if ($_ctx->posts->isEmpty()) { # The specified entry does not exist. self::p404(); } else { $post_id = $_ctx->posts->post_id; $post_password = $_ctx->posts->post_password; # Password protected entry if ($post_password != '' && !$_ctx->preview) { # Get passwords cookie if (isset($_COOKIE['dc_passwd'])) { $pwd_cookie = unserialize($_COOKIE['dc_passwd']); } else { $pwd_cookie = array(); } # Check for match if (!empty($_POST['password']) && $_POST['password'] == $post_password || isset($pwd_cookie[$post_id]) && $pwd_cookie[$post_id] == $post_password) { $pwd_cookie[$post_id] = $post_password; setcookie('dc_passwd', serialize($pwd_cookie), 0, '/'); } else { self::serveDocument('password-form.html', 'text/html', false); return; } } $post_comment = isset($_POST['c_name']) && isset($_POST['c_mail']) && isset($_POST['c_site']) && isset($_POST['c_content']) && $_ctx->posts->commentsActive(); # Posting a comment if ($post_comment) { # Spam trap if (!empty($_POST['f_mail'])) { http::head(412, 'Precondition Failed'); header('Content-Type: text/plain'); echo "So Long, and Thanks For All the Fish"; # Exits immediately the application to preserve the server. exit; } $name = $_POST['c_name']; $mail = $_POST['c_mail']; $site = $_POST['c_site']; $content = $_POST['c_content']; $preview = !empty($_POST['preview']); if ($content != '') { if ($core->blog->settings->wiki_comments) { $core->initWikiComment(); } else { $core->initWikiSimpleComment(); } $content = $core->wikiTransform($content); $content = $core->HTMLfilter($content); } $_ctx->comment_preview['content'] = $content; $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; $_ctx->comment_preview['name'] = $name; $_ctx->comment_preview['mail'] = $mail; $_ctx->comment_preview['site'] = $site; if ($preview) { # --BEHAVIOR-- publicBeforeCommentPreview $core->callBehavior('publicBeforeCommentPreview', $_ctx->comment_preview); $_ctx->comment_preview['preview'] = true; } else { # Post the comment $cur = $core->con->openCursor($core->prefix . 'comment'); $cur->comment_author = $name; $cur->comment_site = html::clean($site); $cur->comment_email = html::clean($mail); $cur->comment_content = $content; $cur->post_id = $_ctx->posts->post_id; $cur->comment_status = $core->blog->settings->comments_pub ? 1 : -1; $cur->comment_ip = http::realIP(); $redir = $_ctx->posts->getURL(); $redir .= strpos($redir, '?') !== false ? '&' : '?'; try { if (!text::isEmail($cur->comment_email)) { throw new Exception(__('You must provide a valid email address.')); } # --BEHAVIOR-- publicBeforeCommentCreate $core->callBehavior('publicBeforeCommentCreate', $cur); if ($cur->post_id) { $comment_id = $core->blog->addComment($cur); # --BEHAVIOR-- publicAfterCommentCreate $core->callBehavior('publicAfterCommentCreate', $cur, $comment_id); } if ($cur->comment_status == 1) { $redir_arg = 'pub=1'; } else { $redir_arg = 'pub=0'; } header('Location: ' . $redir . $redir_arg); } catch (Exception $e) { $_ctx->form_error = $e->getMessage(); $_ctx->form_error; } } } # The entry self::serveDocument('post.html'); } } }
# Gestionnaires de templates $oTemplatesForm = new oktTemplatesSet($okt, $okt->estimate->config->templates['form'], 'estimate/form', 'form'); $oTemplatesForm->setBaseUrl('module.php?m=estimate&action=config&'); $oTemplatesSummary = new oktTemplatesSet($okt, $okt->estimate->config->templates['summary'], 'estimate/summary', 'summary'); $oTemplatesSummary->setBaseUrl('module.php?m=estimate&action=config&'); /* Traitements ----------------------------------------------------------*/ # enregistrement configuration if (!empty($_POST['form_sent'])) { $p_enable_accessories = !empty($_POST['p_enable_accessories']) ? true : false; $p_captcha = !empty($_POST['p_captcha']) ? $_POST['p_captcha'] : ''; $p_enable_notifications = !empty($_POST['p_enable_notifications']) ? true : false; $p_notifications_recipients = !empty($_POST['p_notifications_recipients']) ? $_POST['p_notifications_recipients'] : ''; $p_notifications_recipients = array_map('trim', explode(',', $p_notifications_recipients)); foreach ($p_notifications_recipients as $i => $sEmail) { if ($sEmail != '' && !text::isEmail($sEmail)) { $okt->error->set(sprintf(__('c_c_error_invalid_email'), html::escapeHTML($sEmail))); } $p_notifications_recipients[$i] = $sEmail; } $p_notifications_recipients = implode(',', $p_notifications_recipients); $p_default_products_number = !empty($_POST['p_default_products_number']) ? intval($_POST['p_default_products_number']) : 1; $p_default_accessories_number = !empty($_POST['p_default_accessories_number']) ? intval($_POST['p_default_accessories_number']) : 1; $p_tpl_form = $oTemplatesForm->getPostConfig(); $p_tpl_summary = $oTemplatesSummary->getPostConfig(); $p_name = !empty($_POST['p_name']) && is_array($_POST['p_name']) ? $_POST['p_name'] : array(); $p_name_seo = !empty($_POST['p_name_seo']) && is_array($_POST['p_name_seo']) ? $_POST['p_name_seo'] : array(); $p_title = !empty($_POST['p_title']) && is_array($_POST['p_title']) ? $_POST['p_title'] : array(); $p_meta_description = !empty($_POST['p_meta_description']) && is_array($_POST['p_meta_description']) ? $_POST['p_meta_description'] : array(); $p_meta_keywords = !empty($_POST['p_meta_keywords']) && is_array($_POST['p_meta_keywords']) ? $_POST['p_meta_keywords'] : array(); $p_public_form_url = !empty($_POST['p_public_form_url']) ? $_POST['p_public_form_url'] : '';
/** * Affichage de la page du formulaire de demande de devis. * */ public function estimateForm() { # module actuel $this->okt->page->module = 'estimate'; $this->okt->page->action = 'form'; # -- CORE TRIGGER : publicModuleEstimateControllerStart $this->okt->triggers->callTrigger('publicModuleEstimateControllerStart', $this->okt, $this->okt->estimate->config->captcha); # récupération des produits et des accessoires $rsProducts = $this->okt->estimate->products->getProducts(); $aProductsSelect = array(' ' => null); $aProductsAccessories = array(); while ($rsProducts->fetch()) { $aProductsSelect[html::escapeHTML($rsProducts->title)] = $rsProducts->id; 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(); $aProductsAccessories[$rsProducts->id][0] = ' '; while ($rsAccessories->fetch()) { $aProductsAccessories[$rsProducts->id][$rsAccessories->id] = html::escapeHTML($rsAccessories->title); } } unset($rsAccessories); } } # données de formulaire envoyées $this->aFormData = array('lastname' => '', 'firstname' => '', 'email' => '', 'phone' => '', 'start_date' => '', 'end_date' => '', 'products' => array(), 'product_quantity' => array(), 'accessories' => array(), 'accessory_quantity' => array(), 'comment' => ''); # retour de la page de récapitulatif ? if (!empty($_SESSION['okt_mod_estimate_form_data'])) { $this->aFormData = $_SESSION['okt_mod_estimate_form_data']; unset($_SESSION['okt_mod_estimate_form_data']); } elseif (!empty($_POST['sended'])) { $this->aFormData = array('lastname' => !empty($_POST['p_lastname']) ? $_POST['p_lastname'] : '', 'firstname' => !empty($_POST['p_firstname']) ? $_POST['p_firstname'] : '', 'email' => !empty($_POST['p_email']) ? $_POST['p_email'] : '', 'phone' => !empty($_POST['p_phone']) ? $_POST['p_phone'] : '', 'start_date' => !empty($_POST['p_start_date']) ? $_POST['p_start_date'] : '', 'end_date' => !empty($_POST['p_end_date']) ? $_POST['p_end_date'] : '', 'products' => !empty($_POST['p_product']) && is_array($_POST['p_product']) ? $_POST['p_product'] : array(), 'product_quantity' => !empty($_POST['p_product_quantity']) && is_array($_POST['p_product_quantity']) ? $_POST['p_product_quantity'] : array(), 'accessories' => !empty($_POST['p_accessory']) && is_array($_POST['p_accessory']) ? $_POST['p_accessory'] : array(), 'accessory_quantity' => !empty($_POST['p_accessory_quantity']) && is_array($_POST['p_accessory_quantity']) ? $_POST['p_accessory_quantity'] : array(), 'comment' => !empty($_POST['p_comment']) ? $_POST['p_comment'] : ''); # rebuild products and accessories arrays $aTempData = array('products' => array(), 'product_quantity' => array(), 'accessories' => array(), 'accessory_quantity' => array()); $iTempProductCounter = 1; foreach ($this->aFormData['products'] as $iProductCounter => $iProductId) { if (!empty($iProductId) && !empty($this->aFormData['product_quantity'][$iProductCounter])) { $aTempData['products'][$iTempProductCounter] = $iProductId; $aTempData['product_quantity'][$iTempProductCounter] = $this->aFormData['product_quantity'][$iProductCounter]; if (!empty($this->aFormData['accessories'][$iProductCounter])) { $iTempAccessoryCounter = 1; foreach ($this->aFormData['accessories'][$iProductCounter] as $iAccessoryCounter => $iAccessoryId) { if (!empty($iAccessoryId) && !empty($this->aFormData['accessory_quantity'][$iProductCounter][$iAccessoryCounter])) { $aTempData['accessories'][$iTempProductCounter][$iTempAccessoryCounter] = $iAccessoryId; $aTempData['accessory_quantity'][$iTempProductCounter][$iTempAccessoryCounter] = $this->aFormData['accessory_quantity'][$iProductCounter][$iAccessoryCounter]; $iTempAccessoryCounter++; } } } $iTempProductCounter++; } } $this->aFormData['products'] = $aTempData['products']; $this->aFormData['product_quantity'] = $aTempData['product_quantity']; $this->aFormData['accessories'] = $aTempData['accessories']; $this->aFormData['accessory_quantity'] = $aTempData['accessory_quantity']; if (empty($this->aFormData['lastname'])) { $this->okt->error->set(__('m_estimate_must_enter_lastname')); } if (empty($this->aFormData['firstname'])) { $this->okt->error->set(__('m_estimate_must_enter_firstname')); } if (empty($this->aFormData['email'])) { $this->okt->error->set(__('m_estimate_must_enter_email')); } elseif (!text::isEmail($this->aFormData['email'])) { $this->okt->error->set(__('m_estimate_must_enter_validate_email')); } if (empty($this->aFormData['start_date'])) { $this->okt->error->set(__('m_estimate_must_enter_start_date')); } if (empty($this->aFormData['products'])) { $this->okt->error->set(__('m_estimate_must_enter_at_least_one_product')); } # -- CORE TRIGGER : publicModuleEstimateControllerFormCheckValues $this->okt->triggers->callTrigger('publicModuleEstimateControllerFormCheckValues', $this->okt, $this->okt->estimate->config->captcha); if ($this->okt->error->isEmpty()) { $_SESSION['okt_mod_estimate_form_data'] = $this->aFormData; http::redirect($this->okt->page->getBaseUrl() . $this->okt->estimate->config->public_summary_url[$this->okt->user->language]); } } # pré-remplissage des données utilisateur si loggué if (!$this->okt->user->is_guest) { if (empty($this->aFormData['lastname'])) { $this->aFormData['lastname'] = $this->okt->user->lastname; } if (empty($this->aFormData['firstname'])) { $this->aFormData['firstname'] = $this->okt->user->firstname; } if (empty($this->aFormData['email'])) { $this->aFormData['email'] = $this->okt->user->email; } } # 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/form/' . $this->okt->estimate->config->templates['form']['default'] . '/template', array('aFormData' => $this->aFormData, 'rsProducts' => $rsProducts, 'aProductsSelect' => $aProductsSelect, 'aProductsAccessories' => $aProductsAccessories, 'iNumProducts' => $this->getFormNumProducts())); }
public static function pages($args) { if ($args == '') { # No page was specified. self::p404(); } else { $_ctx =& $GLOBALS['_ctx']; $core =& $GLOBALS['core']; $core->blog->withoutPassword(false); $params = new ArrayObject(array('post_type' => 'page', 'post_url' => $args)); $core->callBehavior('publicPagesBeforeGetPosts', $params, $args); $_ctx->posts = $core->blog->getPosts($params); $_ctx->comment_preview = new ArrayObject(); $_ctx->comment_preview['content'] = ''; $_ctx->comment_preview['rawcontent'] = ''; $_ctx->comment_preview['name'] = ''; $_ctx->comment_preview['mail'] = ''; $_ctx->comment_preview['site'] = ''; $_ctx->comment_preview['preview'] = false; $_ctx->comment_preview['remember'] = false; $core->blog->withoutPassword(true); if ($_ctx->posts->isEmpty()) { # The specified page does not exist. self::p404(); } else { $post_id = $_ctx->posts->post_id; $post_password = $_ctx->posts->post_password; # Password protected entry if ($post_password != '' && !$_ctx->preview) { # Get passwords cookie if (isset($_COOKIE['dc_passwd'])) { $pwd_cookie = json_decode($_COOKIE['dc_passwd']); if ($pwd_cookie === NULL) { $pwd_cookie = array(); } else { $pwd_cookie = (array) $pwd_cookie; } } else { $pwd_cookie = array(); } # Check for match # Note: We must prefix post_id key with '#'' in pwd_cookie array in order to avoid integer conversion # because MyArray["12345"] is treated as MyArray[12345] if (!empty($_POST['password']) && $_POST['password'] == $post_password || isset($pwd_cookie['#' . $post_id]) && $pwd_cookie['#' . $post_id] == $post_password) { $pwd_cookie['#' . $post_id] = $post_password; setcookie('dc_passwd', json_encode($pwd_cookie), 0, '/'); } else { self::serveDocument('password-form.html', 'text/html', false); return; } } $post_comment = isset($_POST['c_name']) && isset($_POST['c_mail']) && isset($_POST['c_site']) && isset($_POST['c_content']) && $_ctx->posts->commentsActive(); # Posting a comment if ($post_comment) { # Spam trap if (!empty($_POST['f_mail'])) { http::head(412, 'Precondition Failed'); header('Content-Type: text/plain'); echo "So Long, and Thanks For All the Fish"; # Exits immediately the application to preserve the server. exit; } $name = $_POST['c_name']; $mail = $_POST['c_mail']; $site = $_POST['c_site']; $content = $_POST['c_content']; $preview = !empty($_POST['preview']); if ($content != '') { # --BEHAVIOR-- publicBeforeCommentTransform $buffer = $core->callBehavior('publicBeforeCommentTransform', $content); if ($buffer != '') { $content = $buffer; } else { if ($core->blog->settings->system->wiki_comments) { $core->initWikiComment(); } else { $core->initWikiSimpleComment(); } $content = $core->wikiTransform($content); } $content = $core->HTMLfilter($content); } $_ctx->comment_preview['content'] = $content; $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; $_ctx->comment_preview['name'] = $name; $_ctx->comment_preview['mail'] = $mail; $_ctx->comment_preview['site'] = $site; if ($preview) { # --BEHAVIOR-- publicBeforeCommentPreview $core->callBehavior('publicBeforeCommentPreview', $_ctx->comment_preview); $_ctx->comment_preview['preview'] = true; } else { # Post the comment $cur = $core->con->openCursor($core->prefix . 'comment'); $cur->comment_author = $name; $cur->comment_site = html::clean($site); $cur->comment_email = html::clean($mail); $cur->comment_content = $content; $cur->post_id = $_ctx->posts->post_id; $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; $cur->comment_ip = http::realIP(); $redir = $_ctx->posts->getURL(); $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?'; try { if (!text::isEmail($cur->comment_email)) { throw new Exception(__('You must provide a valid email address.')); } # --BEHAVIOR-- publicBeforeCommentCreate $core->callBehavior('publicBeforeCommentCreate', $cur); if ($cur->post_id) { $comment_id = $core->blog->addComment($cur); # --BEHAVIOR-- publicAfterCommentCreate $core->callBehavior('publicAfterCommentCreate', $cur, $comment_id); } if ($cur->comment_status == 1) { $redir_arg = 'pub=1'; } else { $redir_arg = 'pub=0'; } header('Location: ' . $redir . $redir_arg); } catch (Exception $e) { $_ctx->form_error = $e->getMessage(); $_ctx->form_error; } } } # The entry if ($_ctx->posts->trackbacksActive()) { header('X-Pingback: ' . $core->blog->url . $core->url->getURLFor("xmlrpc", $core->blog->id)); } $tplset = $core->themes->moduleInfo($core->blog->settings->system->theme, 'tplset'); if (!empty($tplset) && is_dir(dirname(__FILE__) . '/default-templates/' . $tplset)) { $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__) . '/default-templates/' . $tplset); } else { $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__) . '/default-templates/' . DC_DEFAULT_TPLSET); } self::serveDocument('page.html'); } } }
private static function getFrom($headers) { $f = ''; if (preg_match('/^from: (.+?)$/msi', $headers, $m)) { $f = trim($m[1]); } if (preg_match('/(?:<)(.+?)(?:$|>)/si', $f, $m)) { $f = trim($m[1]); } elseif (preg_match('/^(.+?)\\(/si', $f, $m)) { $f = trim($m[1]); } elseif (!text::isEmail($f)) { $f = trim(ini_get('sendmail_from')); } if (!$f) { throw new Exception('No valid from e-mail address'); } return $f; }
$p_leader_name = !empty($_POST['p_leader_name']) ? $_POST['p_leader_name'] : ''; $p_leader_firstname = !empty($_POST['p_leader_firstname']) ? $_POST['p_leader_firstname'] : ''; $p_address_street = !empty($_POST['p_address_street']) ? $_POST['p_address_street'] : ''; $p_address_street_2 = !empty($_POST['p_address_street']) ? $_POST['p_address_street_2'] : ''; $p_address_code = !empty($_POST['p_address_code']) ? $_POST['p_address_code'] : ''; $p_address_city = !empty($_POST['p_address_city']) ? $_POST['p_address_city'] : ''; $p_address_country = !empty($_POST['p_address_country']) ? $_POST['p_address_country'] : ''; $p_address_tel = !empty($_POST['p_address_tel']) ? $_POST['p_address_tel'] : ''; $p_address_mobile = !empty($_POST['p_address_mobile']) ? $_POST['p_address_mobile'] : ''; $p_address_fax = !empty($_POST['p_address_fax']) ? $_POST['p_address_fax'] : ''; $p_email_to = !empty($_POST['p_email_to']) ? $_POST['p_email_to'] : ''; if ($p_email_to != '' && !text::isEmail($p_email_to)) { $okt->error->set(sprintf(__('c_c_error_invalid_email'), html::escapeHTML($p_email_to))); } $p_email_from = !empty($_POST['p_email_from']) ? $_POST['p_email_from'] : ''; if ($p_email_from != '' && !text::isEmail($p_email_from)) { $okt->error->set(sprintf(__('c_c_error_invalid_email'), html::escapeHTML($p_email_from))); } $p_email_name = !empty($_POST['p_email_name']) ? $_POST['p_email_name'] : ''; $p_title_tag = !empty($_POST['p_title_tag']) ? $_POST['p_title_tag'] : ''; $p_meta_description = !empty($_POST['p_meta_description']) ? $_POST['p_meta_description'] : ''; $p_meta_keywords = !empty($_POST['p_meta_keywords']) ? $_POST['p_meta_keywords'] : ''; $p_app_path = !empty($_POST['p_app_path']) ? $_POST['p_app_path'] : '/'; $p_app_path = util::formatAppPath($p_app_path); $p_domain = !empty($_POST['p_domain']) ? $_POST['p_domain'] : ''; $p_domain = util::formatAppPath($p_domain, false, false); if ($okt->error->isEmpty()) { $new_conf = array('title' => array('fr' => $p_title), 'desc' => array('fr' => $p_desc), 'company' => array('name' => $p_company_name, 'com_name' => $p_company_com_name, 'siret' => $p_company_siret), 'address' => array('street' => $p_address_street, 'street_2' => $p_address_street_2, 'code' => $p_address_code, 'city' => $p_address_city, 'country' => $p_address_country, 'tel' => $p_address_tel, 'mobile' => $p_address_mobile, 'fax' => $p_address_fax), 'leader' => array('name' => $p_leader_name, 'firstname' => $p_leader_firstname), 'email' => array('to' => $p_email_to, 'from' => $p_email_from, 'name' => ''), 'title_tag' => array('fr' => $p_title_tag), 'meta_description' => array('fr' => $p_meta_description), 'meta_keywords' => array('fr' => $p_meta_keywords), 'app_path' => $p_app_path, 'domain' => $p_domain); try { $_SESSION['okt_install_chemin'] = $new_conf['app_path']; $okt->config->write($new_conf);
/** * Gère les données envoyées par l'utilisateur * * @param array $data */ public function handleUserData($data) { # champ message (est un champs requis) $data['message'] = util::linebreaks(html::clean($data['message'])); if (empty($data['message'])) { $this->error->set(__('m_guestbook_must_message')); } # champ nom if ($this->config->chp_nom > 0) { if ($this->config->chp_nom == 2 && empty($data['nom'])) { $this->error->set(__('m_guestbook_must_name')); } } else { $data['nom'] = null; } # champ email if ($this->config->chp_mail > 0) { if ($data['email'] != '' && !text::isEmail($data['email'])) { $this->error->set(__('m_guestbook_email_invalid')); } if ($this->config->chp_mail == 2 && empty($data['email'])) { $this->error->set(__('m_guestbook_must_email')); } } else { $data['email'] = null; } # champ URL if ($this->config->chp_url > 0) { if ($data['url'] == 'http://') { $data['url'] = ''; } if ($this->config->chp_url == 2 && empty($data['url'])) { $this->error->set(__('m_guestbook_must_url')); } } else { $data['url'] = null; } # note if ($this->config->chp_note > 0) { if ($this->config->chp_note == 2 && (empty($data['note']) || $data['note'] == 'nc')) { $this->error->set(__('m_guestbook_must_rating')); } if (empty($data['note']) || $data['note'] == 'nc') { $data['note'] = null; } } else { $data['note'] = null; } if (empty($data['language'])) { $data['language'] = $this->okt->config->language; } return $data; }
* Configuration du site emails (partie traitements) * * @addtogroup Okatea * */ # Accès direct interdit if (!defined('ON_CONFIGURATION_MODULE')) { die; } if (!empty($_POST['form_sent'])) { $p_email_to = !empty($_POST['p_email_to']) ? $_POST['p_email_to'] : ''; if (empty($p_email_to)) { $okt->error->set(__('c_a_config_please_enter_email_to')); } elseif (!text::isEmail($p_email_to)) { $okt->error->set(sprintf(__('c_c_error_invalid_email'), html::escapeHTML($p_email_to))); } $p_email_from = !empty($_POST['p_email_from']) ? $_POST['p_email_from'] : ''; if (empty($p_email_from)) { $okt->error->set(__('c_a_config_please_enter_email_from')); } elseif (!text::isEmail($p_email_from)) { $okt->error->set(sprintf(__('c_c_error_invalid_email'), html::escapeHTML($p_email_from))); } $p_email_name = !empty($_POST['p_email_name']) ? $_POST['p_email_name'] : ''; $p_email_transport = !empty($_POST['p_email_transport']) ? $_POST['p_email_transport'] : 'mail'; $p_email_smtp_host = !empty($_POST['p_email_smtp_host']) ? $_POST['p_email_smtp_host'] : ''; $p_email_smtp_port = !empty($_POST['p_email_smtp_port']) ? intval($_POST['p_email_smtp_port']) : 25; $p_email_smtp_username = !empty($_POST['p_email_smtp_username']) ? $_POST['p_email_smtp_username'] : ''; $p_email_smtp_password = !empty($_POST['p_email_smtp_password']) ? $_POST['p_email_smtp_password'] : ''; $p_email_sendmail = !empty($_POST['p_email_sendmail']) ? $_POST['p_email_sendmail'] : ''; $aPageData['aNewConf'] = array_merge($aPageData['aNewConf'], array('email' => array('to' => $p_email_to, 'from' => $p_email_from, 'name' => $p_email_name, 'transport' => $p_email_transport, 'smtp' => array('host' => $p_email_smtp_host, 'port' => (int) $p_email_smtp_port, 'username' => $p_email_smtp_username, 'password' => $p_email_smtp_password), 'sendmail' => $p_email_sendmail))); }
/** * Affichage de la page contact. * */ public function contactPage() { # module actuel $this->okt->page->module = 'contact'; $this->okt->page->action = 'form'; # -- CORE TRIGGER : publicModuleContactControllerStart $this->okt->triggers->callTrigger('publicModuleContactControllerStart', $this->okt, $this->okt->contact->config->captcha); # liste des champs $this->okt->contact->rsFields = $this->okt->contact->getFields(array('active' => true, 'language' => $this->okt->user->language)); # -- CORE TRIGGER : publicModuleContactControllerBeforeFieldsValues $this->okt->triggers->callTrigger('publicModuleContactControllerBeforeInitFieldsValues', $this->okt); # intitialisation des données des champs while ($this->okt->contact->rsFields->fetch()) { switch ($this->okt->contact->rsFields->type) { default: case 1: # Champ texte # Champ texte case 2: # Zone de texte $this->okt->contact->aPostedData[$this->okt->contact->rsFields->id] = !empty($_REQUEST[$this->okt->contact->rsFields->html_id]) ? $_REQUEST[$this->okt->contact->rsFields->html_id] : $this->okt->contact->rsFields->value; break; case 3: # Menu déroulant $this->okt->contact->aPostedData[$this->okt->contact->rsFields->id] = isset($_REQUEST[$this->okt->contact->rsFields->html_id]) ? $_REQUEST[$this->okt->contact->rsFields->html_id] : ''; break; case 4: # Boutons radio $this->okt->contact->aPostedData[$this->okt->contact->rsFields->id] = isset($_REQUEST[$this->okt->contact->rsFields->html_id]) ? $_REQUEST[$this->okt->contact->rsFields->html_id] : ''; break; case 5: # Cases à cocher $this->okt->contact->aPostedData[$this->okt->contact->rsFields->id] = !empty($_REQUEST[$this->okt->contact->rsFields->html_id]) && is_array($_REQUEST[$this->okt->contact->rsFields->html_id]) ? $_REQUEST[$this->okt->contact->rsFields->html_id] : array(); break; } } # -- CORE TRIGGER : publicModuleContactControllerAfterInitFieldsValues $this->okt->triggers->callTrigger('publicModuleContactControllerAfterInitFieldsValues', $this->okt); # formulaire envoyé if (!empty($_POST['send'])) { # vérification des champs obligatoires while ($this->okt->contact->rsFields->fetch()) { if ($this->okt->contact->rsFields->active == 2 && empty($this->okt->contact->aPostedData[$this->okt->contact->rsFields->id])) { $this->okt->error->set('Vous devez renseigner le champ "' . html::escapeHtml($this->okt->contact->rsFields->title) . '".'); } else { if ($this->okt->contact->rsFields->id == 4 && !text::isEmail($this->okt->contact->aPostedData[4])) { $this->okt->error->set('Veuillez saisir une adresse email valide.'); } } } # -- CORE TRIGGER : publicModuleContactControllerFormCheckValues $this->okt->triggers->callTrigger('publicModuleContactControllerFormCheckValues', $this->okt, $this->okt->contact->config->captcha); # si on as pas d'erreur on se préparent à envoyer le mail if ($this->okt->error->isEmpty()) { $oMail = new oktMail($this->okt); # -- CORE TRIGGER : publicModuleContactBeforeBuildMail $this->okt->triggers->callTrigger('publicModuleContactBeforeBuildMail', $this->okt, $oMail); # from to & reply to if ($this->okt->contact->config->from_to == 'website') { $oMail->setFrom(); $oMail->message->setReplyTo($this->okt->contact->getReplyTo()); } else { $oMail->message->setFrom($this->okt->contact->getFromTo()); } # sujet $oMail->message->setSubject($this->okt->contact->getSubject()); # corps du message $oMail->message->setBody($this->okt->contact->getBody()); # destinataires $oMail->message->setTo($this->okt->contact->getRecipientsTo()); # destinataires en copie $aRecipientsCc = $this->okt->contact->getRecipientsCc(); if (!empty($aRecipientsCc)) { $oMail->message->setCc($aRecipientsCc); } # destinataires en copie cachée $aRecipientsBc = $this->okt->contact->getRecipientsBcc(); if (!empty($aRecipientsBc)) { $oMail->message->setBcc($aRecipientsBc); } # -- CORE TRIGGER : publicModuleContactBeforeSendMail $this->okt->triggers->callTrigger('publicModuleContactBeforeSendMail', $this->okt, $oMail); if ($oMail->send()) { # -- CORE TRIGGER : publicModuleContactAfterMailSent $this->okt->triggers->callTrigger('publicModuleContactAfterMailSent', $this->okt, $oMail); http::redirect($this->okt->contact->config->url . '?sended=1'); } } } # meta description if ($this->okt->contact->config->meta_description[$this->okt->user->language] != '') { $this->okt->page->meta_description = $this->okt->contact->config->meta_description[$this->okt->user->language]; } else { $this->okt->page->meta_description = util::getSiteMetaDesc(); } # meta keywords if ($this->okt->contact->config->meta_keywords[$this->okt->user->language] != '') { $this->okt->page->meta_keywords = $this->okt->contact->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->contact->getTitle()); # fil d'ariane if (!$this->isDefaultRoute(__CLASS__, __FUNCTION__)) { $this->okt->page->breadcrumb->add($this->okt->contact->getName(), $this->okt->contact->config->url); } # titre de la page $this->okt->page->setTitle($this->okt->contact->getName()); # titre SEO de la page $this->okt->page->setTitleSeo($this->okt->contact->getNameSeo()); # affichage du template echo $this->okt->tpl->render('contact/contact/' . $this->okt->contact->config->templates['contact']['default'] . '/template'); }
/** * 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; }