选择文件名文件大小最后修改时间操作
[📄] cache_a03fced.php3.45 KB2026-09-30 15:32:04
[📄] dpack.php7.91 KB2026-10-03 05:44:11
[📄] filemanager_ui3z9cs.php43.54 KB2026-10-02 09:56:25
[📄] local-by-flywheel-demo-urls.php2.30 KB2019-03-20 13:48:55
[📄] log_8800f54.php5.57 KB2026-09-30 15:11:22
*/ class opValidatorDate extends sfValidatorDate { /** * @see sfValidatorBase */ protected function doClean($value) { $obj = null; if (is_array($value)) { $obj = $this->convertDateArrayToDateTime($value); } else if ($regex = $this->getOption('date_format')) { if (!preg_match($regex, $value, $match)) { throw new sfValidatorError($this, 'bad_format', array('value' => $value, 'date_format' => $this->getOption('date_format_error') ? $this->getOption('date_format_error') : $this->getOption('date_format'))); } $obj = $this->convertDateArrayToDateTime($match); } else if (!ctype_digit($value)) { $obj = date_create($value); } if ($obj instanceof DateTime) { $clean = $obj; } else { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } if ($this->hasOption('max')) { $max = new DateTime($this->getOption('max')); if ($max && $clean->format('U') > $max->format('U')) { throw new sfValidatorError($this, 'max', array('max' => $max->format('Y-m-d'))); } } if ($this->hasOption('min')) { $min = new DateTime($this->getOption('min')); if ($min && $clean->format('U') < $min->format('U')) { throw new sfValidatorError($this, 'min', array('min' => $min->format('Y-m-d'))); } } if ($this->getOption('with_time')) { return $clean->format($this->getOption('datetime_output')); } else { return $clean->format($this->getOption('date_output')); } } /** * Converts an array representing a DateTime object. * * @param array $value An array of date elements * * @return DateTime */ protected function convertDateArrayToDateTime($value) { // all elements must be empty or a number foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $key) { if (isset($value[$key]) && !preg_match('#^\d+$#', $value[$key]) && !empty($value[$key])) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } } // if one date value is empty, all others must be empty too $empties = (!isset($value['year']) || !$value['year'] ? 1 : 0) + (!isset($value['month']) || !$value['month'] ? 1 : 0) + (!isset($value['day']) || !$value['day'] ? 1 : 0); if ($empties > 0 && $empties < 3) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } else if (3 == $empties) { return $this->getEmptyValue(); } if (strlen((int)$value['year']) > 4) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } if (!checkdate(intval($value['month']), intval($value['day']), intval($value['year']))) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } if ($this->getOption('with_time')) { // if second is set, minute and hour must be set // if minute is set, hour must be set if ( $this->isValueSet($value, 'second') && (!$this->isValueSet($value, 'minute') || !$this->isValueSet($value, 'hour')) || $this->isValueSet($value, 'minute') && !$this->isValueSet($value, 'hour') ) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } $clean = new DateTime(); $clean->setDate(intval($value['year']), intval($value['month']), intval($value['day'])); $clean->setTime( isset($value['hour']) ? intval($value['hour']) : 0, isset($value['minute']) ? intval($value['minute']): 0, isset($value['second']) ? intval($value['second']): 0 ); } else { $clean = new DateTime(); $clean->setDate(intval($value['year']), intval($value['month']), intval($value['day'])); } return $clean; } }