Пример #1
0
<?php

$a = -1;
$b = -1;
$c = -1;
mbereg($a, $b, $c);
var_dump($a, $b, $c);
mberegi($a, $b, $c);
var_dump($a, $b, $c);
mbereg_search_init($a, $b, $c);
var_dump($a, $b, $c);
echo "Done\n";
 /**
  * generate voting-form
  */
 protected function generateVotingForm()
 {
     if (!$this->loggedInUser || $this->loggedInUser->id == $this->ratedUser->id) {
         return;
     }
     $strFields = '';
     $scoreError = false;
     $this->Template->formId = 'tl_comments_' . $this->id;
     $this->Template->action = \Environment::get('indexFreeRequest');
     $this->Template->enctype = 'application/x-www-form-urlencoded';
     $arrFields = array();
     $objComment = new \CommentsModel();
     // Build the form
     $arrFF = array('comment', 'score', 'captcha');
     foreach ($arrFF as $field) {
         $arrData =& $GLOBALS['TL_DCA']['tl_comments']['fields'][$field];
         $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
         $arrData['eval']['tableless'] = 'true';
         $arrData['label'] = $GLOBALS['TL_LANG']['tl_comments'][$field][0];
         $varValue = '';
         $objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field, $varValue, '', '', $this));
         $objWidget->storeValues = true;
         // Validate the form data
         if (\Input::post('FORM_SUBMIT') == 'tl_comments_' . $this->id) {
             $objWidget->validate();
             $varValue = $objWidget->value;
             // check vor valid score interval
             if ($field == 'score') {
                 if (!mberegi('^(1|2|3|4|5)\\d{0}$', $varValue)) {
                     $doNotSubmit = true;
                     $scoreError = true;
                 }
             }
             // Do not submit the field if there are errors
             if ($objWidget->hasErrors()) {
                 $doNotSubmit = true;
             } elseif ($objWidget->submitInput()) {
                 $blnModified = true;
                 // Store the form data
                 $_SESSION['FORM_DATA'][$field] = $varValue;
                 // Set the correct empty value (see #6284, #6373)
                 if ($varValue === '') {
                     $varValue = $objWidget->getEmptyValue();
                 }
                 // Set the new value
                 if ($field !== 'captcha') {
                     $objComment->{$field} = $varValue;
                 }
             }
         }
         $temp = $objWidget->parse();
         // add a hidden field for the starrating
         if ($field == 'score') {
             $temp = '<input type="hidden" name="score" id="ctrl_score" value="">';
         }
         $strFields .= $temp;
         $arrFields[$field] = $temp;
     }
     // Save the model
     if ($doNotSubmit !== true && $blnModified && \Input::post('FORM_SUBMIT') == 'tl_comments_' . $this->id) {
         $objComment->owner = $this->loggedInUser->id;
         $objComment->dateOfCreation = time();
         $objComment->source = 'tl_member';
         $objComment->ip = \Environment::get('ip');
         $objComment->activation_token = md5(session_id() . time() . $this->loggedInUser->id);
         $objComment->parent = $this->ratedUser->id;
         $objComment->published = 0;
         $objComment->save();
         $this->log('A new entry "tl_comments.id=' . $objComment->id . '" has been created', __METHOD__, TL_GENERAL);
         // notify rated member
         if ($this->notifyRatedUser && $objComment->id > 0 && $objComment->comment != '') {
             $this->notifyUser($objComment);
         }
         $this->jumpToOrReload($this->jumpTo);
     }
     if ($scoreError) {
         $strFields = '<p class="error">Bitte eine g&uuml;ltige Punktzahl vergeben.</p>' . $strFields;
     }
     $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['saveData']);
     $this->Template->fields = $strFields;
     $this->Template->arrFields = $arrFields;
     // shit storm protection
     if ($this->blockingTime > 0) {
         $objRatings = $this->Database->prepare("SELECT * FROM tl_comments WHERE source = ? AND parent = ? AND owner = ? AND dateOfCreation > ? ORDER BY dateOfCreation DESC")->limit(1)->execute('tl_member', $this->ratedUser->id, $this->loggedInUser->id, time() - $this->blockingTime);
         if ($objRatings->numRows > 0) {
             $this->Template->commentFormLocked = true;
             $time = $this->blockingTime - (time() - $objRatings->dateOfCreation);
             $h = floor($time / 3600);
             $min = floor(($time / 3600 - $h) * 60);
             if ($time <= 60) {
                 $this->Template->commentFormLockedTime = $time . ' s';
             } else {
                 $this->Template->commentFormLockedTime = ($h > 0 ? $h . ' h  ' : '') . $min . ' min';
             }
         }
     }
 }