Ejemplo n.º 1
0
 /**
  * Surcharge de la fonction de vérification de l'enregistrement pour avoir les bons libellés.
  * @param	DAORecord	$pRecord	L'enregistrement à vérifier
  */
 public function check($pRecord)
 {
     //vérifications standards.
     if (($arErrors = $this->_compiled_check($pRecord)) === true) {
         $arErrors = array();
     }
     //vérification du format du mail
     try {
         if (isset($pRecord->authoremail_comment)) {
             CopixFormatter::getMail($pRecord->authoremail_comment);
         }
     } catch (Exception $e) {
         $arErrors[] = $e->getMessage();
     }
     // vérification de l'antispam
     if (CopixConfig::get('comments|captcha') != 0 && !isset($pRecord->noCaptcha)) {
         $results = _ioDAO('commentscaptcha')->findBy(_ioDAOSp()->addCondition("captcha_id", "=", $pRecord->captcha_id));
         if (!(isset($results[0]) && $results[0]->captcha_answer == $pRecord->captcha_answer)) {
             $arErrors[] = _i18n('comments.admin.captcha.error');
         }
     }
     //on remplace avec les bons libellés
     foreach ($arErrors as $key => $error) {
         $arErrors[$key] = str_replace(array('"content_comment"', '"authoremail_comment"', '"authorsite_comment"', '"authorlogin_comment"'), array(_i18n('comments.list.content'), _i18n('comments.list.mail'), _i18n('comments.list.site'), _i18n('comments.list.author')), $error);
     }
     //erreurs s'il en existe, true sinon
     return count($arErrors) == 0 ? true : $arErrors;
 }
 /**
  * Applique les changements sur le paramètre
  */
 public function processValid()
 {
     CopixRequest::assert('idFirst', 'idSecond', 'value');
     // si la config existe bien
     if (CopixConfig::exists(CopixRequest::get('idFirst') . '|' . CopixRequest::get('idSecond'))) {
         // initialisation de variables
         $id = CopixRequest::get('idFirst') . '|' . CopixRequest::get('idSecond');
         $params = CopixConfig::getParams(CopixRequest::get('idFirst'));
         $config = $params[$id];
         $value = CopixRequest::get('value');
         $error = false;
         // type int
         if ($config['Type'] == 'int') {
             // chiffre invalide
             if ((string) intval($value) != (string) $value) {
                 $error = 'typeInt';
                 // chiffre trop petit
             } elseif (!is_null($config['MinValue']) && $config['MinValue'] > intval($value)) {
                 $error = 'typeIntMin';
                 // chiffre trop grand
             } elseif (!is_null($config['MaxValue']) && $config['MaxValue'] < intval($value)) {
                 $error = 'typeIntMax';
             }
             // type email
         } elseif ($config['Type'] == 'email') {
             // email invalide
             try {
                 CopixFormatter::getMail($value);
             } catch (CopixException $e) {
                 $error = 'typeEmail';
             }
             // e-mail trop long
             if (!is_null($config['MaxLength']) && strlen($value) > $config['MaxLength']) {
                 $error = 'typeEmailMax';
             }
             // type text
         } elseif ($config['Type'] == 'text') {
             // texte trop long
             if (!is_null($config['MaxLength']) && strlen($value) > $config['MaxLength']) {
                 $error = 'typeTextMax';
             }
         }
         // si il y a eu une erreur
         if ($error !== false) {
             return _arRedirect(_url('admin|parameters|', array('choiceModule' => CopixRequest::get('choiceModule'), 'editParam' => CopixRequest::get('idSecond'), 'error' => $error)));
         }
         // modification de la config
         CopixConfig::set($id, $value);
     }
     return _arRedirect(_url('admin|parameters|', array('choiceModule' => CopixRequest::get('choiceModule'))));
 }
 /**
  * Methode qui fait les tests sur la $pValue
  *
  * @param mixed $pValue La valeur
  */
 protected function _validate($pValue)
 {
     try {
         CopixFormatter::getMail($pValue);
     } catch (CopixException $e) {
         return $e->getMessage();
     }
     if ($this->getParam('tld')) {
         $arValue = explode('.', $pValue);
         $pExt = $arValue[count($arValue) - 1];
         if (!$this->_isTldValid($pExt)) {
             return _i18n('copix:copixformatter.error.badmail', $pValue);
         }
     }
     return true;
 }
 /**
  * Validation des modification sur le profil de log
  */
 public function processValid()
 {
     $profile = CopixSession::get('admin|log|edit');
     if (_request('enabled')) {
         $profile['enabled'] = true;
     } else {
         $profile['enabled'] = false;
     }
     $profile['strategy'] = _request('strategy');
     if (_request('strategy_class', null, true)) {
         $profile['strategy'] = _request('strategy_class');
     }
     $profile['level'] = _request('level');
     if ($handle = _request('handle', null, true)) {
         if (is_array($profile['handle'])) {
             if (!in_array($handle, $profile['handle'])) {
                 $profile['handle'][] = $handle;
             }
         } else {
             $profile['handle'] = array($handle);
         }
     }
     if (!isset($profile['handleExcept'])) {
         $profile['handleExcept'] = array();
     }
     if (!is_array($profile['handle'])) {
         if ($handleExcept = _request('handleExcept', null, true)) {
             if (is_array($profile['handleExcept'])) {
                 if (!in_array($handleExcept, $profile['handleExcept'])) {
                     $profile['handleExcept'][] = $handleExcept;
                 }
             } else {
                 $profile['handleExcept'] = array($handleExcept);
             }
         }
     } else {
         if (is_array($profile['handleExcept'])) {
             unset($profile['handleExcept']);
         }
     }
     // email de destination dans le cas d'une stratégie de profil de type email
     if ($profile['strategy'] == 'email') {
         $emails = explode(';', _request('email'));
         foreach ($emails as $email) {
             try {
                 $email = CopixFormatter::getMail($email);
             } catch (CopixException $e) {
                 return _arRedirect(_url('log|edit', array('profile' => $profile['name'], 'error' => 'invalidEMail')));
             }
         }
         $profile['email'] = _request('email');
     }
     CopixSession::set('admin|log|edit', $profile);
     if (_request('save')) {
         $profiles = CopixConfig::instance()->copixlog_getRegisteredProfiles();
         $profiles[$profile['name']] = $profile;
         _class('LogConfigurationFile')->write($profiles);
         CopixSession::set('admin|log|edit', null);
         if (strtoupper($profile['strategy']) == "FIREBUG") {
             if (!CopixPluginRegistry::isRegistered("admin|firebug")) {
                 //on récupère la liste des plugins enregistrés et on ajoute le nouveau plugin
                 $arPlugins = CopixConfig::instance()->plugin_getRegistered();
                 $arPlugins[] = "admin|firebug";
                 //écriture du fichier
                 _class('PluginsConfigurationFile')->write($arPlugins);
             }
         }
         return _arRedirect(_url('log|admin'));
     } else {
         return _arRedirect(_url('log|edit'));
     }
 }
 /**
  * Validation des modifications apportées sur un utilisateur
  */
 public function processValid()
 {
     //$user = new stdClass ();
     $user = _record('dbuser');
     $user->login_dbuser = _request('login_dbuser', '');
     $user->email_dbuser = _request('email_dbuser');
     $errors = array();
     //on vérifie si le login n'est pas déja pris
     $sp = _daoSp();
     $sp->addCondition('login_dbuser', '=', $user->login_dbuser);
     if ($user->login_dbuser === '') {
         $errors['loginEmpty'] = 1;
     }
     if (count(_ioDAO('dbuser')->findBy($sp))) {
         $errors['loginNotAvailable'] = 1;
     }
     //on vérifie si un mot de passe est donné qu'ils soient bien identiques
     if (CopixRequest::get('password_dbuser')) {
         if (CopixRequest::get('password_dbuser') != CopixRequest::get('password_confirmation_dbuser')) {
             $errors['passwordDoNotMatch'] = 1;
         } else {
             $user->password_dbuser = md5(CopixRequest::get('password_dbuser'));
         }
     } else {
         //Comme c'est automatiquement un nouvel utilisateur, il est obligatoire de saisir un nouveau mot de passe.
         $errors['passwordEmpty'] = 1;
     }
     if (Copixconfig::get('auth|typeConfirm') == "email") {
         if (!$user->email_dbuser) {
             $errors['emailEmpty'] = 1;
         } else {
             try {
                 CopixFormatter::getMail($user->email_dbuser);
             } catch (CopixException $e) {
                 $errors['emailIsBad'] = 1;
             }
         }
     }
     if (Copixconfig::get('auth|typeConfirm') == "email") {
         $user->enabled_dbuser = 0;
     } else {
         $user->enabled_dbuser = 1;
     }
     //Si le module imageprotect est activé test la protection anti-spam
     if (CopixModule::isEnabled('antispam')) {
         CopixRequest::assert('confirmcode_dbuser');
         CopixRequest::assert('idcode_dbuser');
         $code = _request('confirmcode_dbuser');
         $idCode = _request('idcode_dbuser');
         // Test si le code de ssession est valide
         _classInclude('antispam|imageprotect');
         if (!ImageProtect::getCode($idCode, $code)) {
             $errors['confirmCodeBad'] = 1;
         }
     }
     //redirige vers l'éditeur si il y a des erreurs
     if (count($errors) != 0) {
         $errors['idForm'] = uniqid();
         CopixSession::set('auth|createForm', $user, $errors['idForm']);
         return _arRedirect(_url('auth|usersregister|edit', $errors));
     }
     //sauvegarde de l'utilisateur
     _ioDAO('dbuser')->insert($user);
     return _arRedirect(_url(''));
 }
 public function sendmail($mail)
 {
     $arrErrors = array();
     if ($mail['dest'] == null || $mail['dest'] == "") {
         $arrErrors[] = _i18n('email.error.nodest');
     } else {
         $arrTmp = explode(",", $mail['dest']);
         try {
             foreach ($arrTmp as $key => $tmpMail) {
                 if ($tmpMail != "") {
                     CopixFormatter::getMail($tmpMail);
                 }
             }
         } catch (CopixException $e) {
             $arrErrors[] = _i18n('email.error.baddest');
         }
     }
     if ($mail['cc'] != "") {
         $arrTmp = explode(",", $mail['cc']);
         try {
             foreach ($arrTmp as $key => $tmpMail) {
                 if ($tmpMail != "") {
                     CopixFormatter::getMail($tmpMail);
                 }
             }
         } catch (CopixException $e) {
             $arrErrors[] = _i18n('email.error.badcc');
         }
     } else {
         $mail['cc'] = "";
     }
     if ($mail['cci'] != "") {
         $arrTmp = explode(",", $mail['cci']);
         try {
             foreach ($arrTmp as $key => $tmpMail) {
                 if ($tmpMail != "") {
                     CopixFormatter::getMail($tmpMail);
                 }
             }
         } catch (CopixException $e) {
             $arrErrors[] = _i18n('email.error.badcci');
         }
     } else {
         $mail['cci'] = "";
     }
     if ($mail['subject'] == null || $mail['subject'] == "") {
         $arrErrors[] = _i18n('email.error.nosubject');
     }
     if ($mail['msg'] == null || $mail['msg'] == "") {
         $arrErrors[] = _i18n('email.error.nomsg');
     }
     if ($mail['from'] == null || $mail['from'] == "") {
         $arrErrors[] = _i18n('email.error.nofrom');
     } else {
         $arrTmp = explode(",", $mail['from']);
         try {
             foreach ($arrTmp as $tmpMail) {
                 if ($tmpMail != "") {
                     CopixFormatter::getMail($tmpMail);
                 }
             }
         } catch (CopixException $e) {
             $arrErrors[] = _i18n('email.error.badfrom');
         }
     }
     if ($mail['fromname'] == null || $mail['fromname'] == "") {
         $arrErrors[] = _i18n('email.error.nofromname');
     }
     if (count($arrErrors) == 0) {
         $monMail = new CopixTextEMail($mail['dest'], $mail['cc'], $mail['cci'], utf8_decode($mail['subject']), utf8_decode($mail['msg']));
         $monMail->send($mail['from'], $mail['fromname']);
         CopixSession::set('admin|email|donnees', $this->newMail());
     }
     return $arrErrors;
 }