From 8c03f6859c452738aafd554f8dc42cc636a4a1e9 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Mon, 10 Feb 2020 19:19:45 +0100 Subject: new feature : page redirection, close #44 --- app/class/Page.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'app/class/Page.php') diff --git a/app/class/Page.php b/app/class/Page.php index c30352c..c57ecc4 100644 --- a/app/class/Page.php +++ b/app/class/Page.php @@ -44,6 +44,8 @@ class Page extends Dbitem protected $editcount; protected $editby; protected $sleep; + protected $redirection; + protected $refresh; const LEN = 255; @@ -103,6 +105,9 @@ class Page extends Dbitem $this->seteditcount(0); $this->seteditby([]); $this->setsleep(0); + $this->setredirection(''); + $this->setrefresh(0); + } public static function classvarlist() @@ -383,6 +388,16 @@ class Page extends Dbitem return $this->sleep; } + public function redirection($type = 'string') + { + return $this->redirection; + } + + public function refresh($type = 'int') + { + return $this->refresh; + } + @@ -707,6 +722,32 @@ class Page extends Dbitem } } + public function setredirection($redirection) + { + if(is_string($redirection) && strlen($redirection) <= 64) { + $redirection = strip_tags($redirection); + if(preg_match('%https?:\/\/\S*%', $redirection, $out)) { + $this->redirection = $out[0]; + } else { + $redirection = idclean($redirection); + if ($redirection !== $this->id) { + $this->redirection = $redirection; + } + } + } + } + + public function setrefresh($refresh) + { + $refresh = intval($refresh); + if($refresh > 180) { + $refresh = 180; + } elseif ($refresh < 0) { + $refresh = 0; + } + $this->refresh = $refresh; + } + // __________________________________ C O U N T E R S ______________________________ -- cgit v1.2.3