From eb21e13dcdd038315d0ad1ff4941d1069af9b977 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Thu, 8 Sep 2011 13:45:49 +0200 Subject: kleine korrekturen --- library/Poolctrl/Functions.php | 64 +++++++++++++++++++++++ library/Poolctrl/Validator/DateGreaterThan.php | 71 ++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 library/Poolctrl/Functions.php create mode 100644 library/Poolctrl/Validator/DateGreaterThan.php (limited to 'library') diff --git a/library/Poolctrl/Functions.php b/library/Poolctrl/Functions.php new file mode 100644 index 0000000..0b89390 --- /dev/null +++ b/library/Poolctrl/Functions.php @@ -0,0 +1,64 @@ +1){ + $out = ''; + ob_start(); + echo "
"; + for($a=0;$a<$numargs;$a++) + print_a(func_get_arg($a)); + echo "
"; + $out .= ob_get_contents(); + ob_end_clean(); + echo $out; + }else{ + echo "
";
+		$a = func_get_arg(0);
+		$a = (is_bool($a))?(($a)?'true':'false'):$a;
+		print_r($a);
+		echo "
"; + } +} + +function PostToHost($host, $path, $referer, $userAgent, $dataToSend) { + $fp = @ fsockopen($host, 80); + @ fputs($fp, "POST $path HTTP/1.1\r\n"); + @ fputs($fp, "Host: $host\r\n"); + @ fputs($fp, "User-Agent: $userAgent\r\n"); + @ fputs($fp, "Referer: $referer\r\n"); + @ fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); + @ fputs($fp, "Content-length: ". strlen($dataToSend) ."\r\n"); + @ fputs($fp, "Connection: close\r\n\r\n"); + @ fputs($fp, $dataToSend); + $res = ""; + while(!@ feof($fp)) { + $res .= @ fgets($fp, 128); + } + @ fclose($fp); + + $res = @ explode("\r\n\r\n",$res); + $result['http-header'] = $res[0]; + $result['http-body'] = $res[1]; + return $result; +} \ No newline at end of file diff --git a/library/Poolctrl/Validator/DateGreaterThan.php b/library/Poolctrl/Validator/DateGreaterThan.php new file mode 100644 index 0000000..f6c1316 --- /dev/null +++ b/library/Poolctrl/Validator/DateGreaterThan.php @@ -0,0 +1,71 @@ + "'%value%' has to be greater than '%min%'", + ); + + protected $_messageVariables = array( + 'min' => '_min' + ); + + protected $_min; + protected $_minTimestamp; + + public function __construct($min) + { + if ($min instanceof Zend_Config) { + $min = $min->toArray(); + } + + if (is_array($min)) { + if (array_key_exists('min', $min)) { + $min = $min['min']; + $minTimestamp = strtotime($min); + } else { + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception("Missing option 'min'"); + } + } + + $this->setMin($min); + $this->setMinTimestamp($minTimestamp); + } + + public function getMin() + { + return $this->_min; + } + + public function setMin($min) + { + $this->_min = $min; + return $this; + } + + public function getMinTimestamp() + { + return $this->_minTimestamp; + } + + public function setMinTimestamp($_minTimestamp) + { + $this->_minTimestamp = $_minTimestamp; + } + + public function isValid($value) + { + $this->_setValue($value); + $valueTimestamp = strtotime($value); + + if ($this->getMinTimestamp() >= $valueTimestamp) { + $this->_error(self::NOT_GREATER); + return false; + } + return true; + } +} \ No newline at end of file -- cgit v1.2.3-55-g7522