gzuncompress
|
Server IP : 172.19.0.2 / Your IP : 216.73.216.178 Web Server : Apache/2.4 System : Linux 880f91b28fd7 5.15.0-117-generic #127~20.04.1-Ubuntu SMP Thu Jul 11 15:36:12 UTC 2024 x86_64 User : tomlinde ( 155017) PHP Version : 5.6.40 Disable Function : dl, syslog, opcache_get_status MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0700) : /home/webpages/lima-city/tomlinde/html/videoandreagallery/internals/classes/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] | [ Lock Shell ] | [ Logout ] |
|---|
<?php
require_once("page.class.php");
class InputPage extends Page {
private $checks = array();
private $allMatch = true;
function __construct(){
parent::__construct();
}
public function addInputFieldCheck($name, $regex, $required, $advise = ""){
// to avoid an error with newer PHP versions
// if someone manipulates the form this check is needed
if(array_key_exists($name, $_POST))
$value = $_POST[$name];
else if(array_key_exists($name, $_GET))
$value = $_GET[$name];
else
$value = "";
//do not check the field if it is empty and not required
if($value == "" and ! $required){
$num=1;
} else {
$num = preg_match($regex, $value);
if($num != 1) $this->allMatch = false;
}
$this->checks[$name] = array( "value" => $value,
"regex" => $regex,
"required" => $required,
"advise" => $advise,
"match" => ($num == 1));
}
public function checkInput($name){
//FIXME: report error if field gets requested which doesn't exist
// because then the program is buggy
return $this->checks[$name]["match"];
}
public function checkAll(){
return $this->allMatch;
}
public function getInput($name){
//FIXME: report error if field gets requested which doesn't exist
// because then the program is buggy
if($this->checkInput($name)){
return strip_tags($this->checks[$name]["value"]);
} else {
//FIXME: should be an empty string
return "DIRTY-VALUE";
}
}
public function setSpecialReason($name, $reason){
$this->checks[$name]["advice"] = $reason;
$this->checks[$name]["match"] = false;
}
public function writePreviousInput(){
// FIXME: whats about output escaping of user data in XML files (htmlspecialchars?)
$this->addTagToPath("/page", "previousInput");
foreach($this->checks as $key => $check){
$element = $this->createElement("input");
$tag = $this->createElement("tagname", $key);
$element->appendChild($tag);
$tag = $this->createElement("value", $this->getInput($key));
$element->appendChild($tag);
$tag = $this->createElement("required", $check["required"] ? "1" : "0");
$element->appendChild($tag);
$tag = $this->createElement("advise", $check["advise"]);
$element->appendChild($tag);
$tag = $this->createElement("match", $check["match"] ? "1" : "0");
$element->appendChild($tag);
$this->addSubtreeToPath("/page/previousInput", $element);
}
}
}
?>