From df5c74f04cafb5d1f6d086f3da061ab0671be221 Mon Sep 17 00:00:00 2001 From: Christian Haschek Date: Mon, 2 Nov 2015 12:18:28 +0100 Subject: [PATCH] cleanup --- classes/html.php | 501 ++--------------------------------------------- 1 file changed, 19 insertions(+), 482 deletions(-) diff --git a/classes/html.php b/classes/html.php index 3e4d070..03ff4a5 100644 --- a/classes/html.php +++ b/classes/html.php @@ -2,493 +2,30 @@ class HTML { - private $js = array(); - - function shortenUrls($data) { - $data = preg_replace_callback('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', array(get_class($this), '_fetchTinyUrl'), $data); - return $data; + function sanatizeString($string) + { + return preg_replace("/[^a-zA-Z0-9._]+/", "", $string); } - private function _fetchTinyUrl($url) { - $ch = curl_init(); - $timeout = 5; - curl_setopt($ch, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url=' . $url[0]); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); - $data = curl_exec($ch); - curl_close($ch); - return '' . $data . ''; - } - - function code($data,$class='markdown') + function renderSize($byte) { - return '
'.$data.'
'; - } - - function form($data,$submitvalue="Speichern",$action="",$submitname="submit") - { - return '
'.$data.'
'; - } - - function number($z,$nachkommastellen=0) - { - return number_format($z, $nachkommastellen, ',', '.'); - } - - function span($data,$id="",$class="",$zusatz="") - { - return ''.$data.''; - } - - function textarea($name,$data='',$cols=50,$rows=10,$forcewysiwyg=false) - { - $cs = new CubeshopModel; - if($_SESSION['user'] && ($cs->hasUserItem('bbcode') || $forcewysiwyg)) - $textarea = $this->getWYSIWYGEditor($name,$data); - else $textarea = ''; - - return $textarea; - } - - function center($data) - { - return '
'.$data.'
'; - } - - function displayError($e) - { - $text = addslashes($this->error($e)); - return ''; - } - - function displaySuccess($e) - { - $text = addslashes($this->success($e)); - return ''; - } - - function clear() - { - return '
'; - } - - function menu($arr, $id = "", $class = "") - { - aasort($arr, 'priority'); - $o = ''; - return $o; - } - function strong($text,$id = "", $class = "") - { - return ''.$text.''; - } - - function dfn($text,$desc,$id = "", $class = "") - { - return ''.$text.''; - } - - function tip($text,$id = "", $class = "") - { - return ''.$text.''; - } - - function submenu($arr, $id = "", $class = "") { - if (!is_array($arr)) - return false; - $o = ''; - return $o; - } - - /** - * $timestamp = zeitpunt des ablaufens in unix timestamp - */ - function countdown($timestamp,$prestring="",$id=0,$allownegative=false) - { - $a = new Algorithms(); - if(!$id) $id = $a->getRandomHash(8); - $seconds = $timestamp-time(); - //return ''; - return ''; - } - - function sanitize($data) - { - return mysql_real_escape_string($data); - } - - function specialchars($text,$utf8=0) - { - return htmlspecialchars($text); - } - - /* - * @param string $name - * @param string $value - * @param string $type - * @param string $id - * @param string $class - * @param int $size - */ - function input($name, $value = '', $type = 'text', $id = '', $class = '', $size = '20',$onClick='',$extra='') - { - return ''; - } - - function button($name,$value,$onclick="return true;",$id='',$class="button") - { - return ''; - } - - function buttonGoTo($value,$link,$id='',$class='') - { - return ''.$value.''; - } - - /* - * @param array $data the multidimensional array - * @param bool $header should the first line be a element instead of ? - * @param string $width - * @param string $id the ID of the table - * @param string $class the class of the table - * @param string $tdclass the class of every td element - */ - function table($data, $header = 1, $width = '100%', $id = '', $class = '', $tdclass = 'text_top', $evenwidth=1,$trclass='') - { - if (!is_array($data)) - return false; - $t = ''; - foreach ($data as $key => $val) - { - if ($key == 0 && $header) - $td = 'th'; else - $td = 'td class="' . $tdclass . '"'; - $t.=''; - if($evenwidth) $w = floor(100/count($val)).'%'; - foreach ($val as $j => $tdata) - { - if($evenwidth) $w = floor(100/count($val)).'%'; - else $w = 'auto'; - if(is_array($tdata)) - { - $text = $tdata['text']; - if($tdata['header']) $td = 'th'; - if($tdata['width']) $w=$tdata['width']; - if($tdata['class']) $tdclass .= ' '.$tdata['class']; - if($tdata['id']) $tid = $tdata['id']; - if($tdata['colspan']) $colspan = 'colspan="'.$tdata['colspan'].'"'; - $tdata = $text; - } - $t.='<' . $td . ' '.$colspan.' width="'.$w.'" class="'.$tclass.'" id="'.$tid.'">' . $tdata . ''; - $class=''; - $tid=''; - $colspan=''; - } - $t.=''; - } - $t.='
'; - - return $t; - } - - /* - * @param $err is the error code equivalent of /config/errors.php - * if $err is not numeric or not found in errors.php, its printed as text - * @param $class is the html tag class - */ - - function error($err, $class = 'error',$backbutton=false) - { - global $error; - if (is_numeric($err) && $error[$err]) - $err = $error[$err]; - if($backbutton) - $bb = '
Zurück..'; - return '' . $err . ''.$bb; - } - - function arrayToString($arr) - { - if(!is_array($arr)) return false; - foreach($arr as $a) - { - $o.=$a.';'; - } - $o = substr($o,0,-1); - - return $o; - } - - function success($msg, $class = 'success') - { - return '' . $msg . ''; - } - - function goToLocation($location = '/', $force = true) { - $script = ''; - if ($force) - exit($script); - else - return $script; - } - - function link($text, $path, $prompt = null, $confirmMessage = "Bist du sicher?",$class="") - { - $path = str_replace(' ', '-', $path); - if ($prompt) { - $data = '' . $text . ''; - } else { - $data = '' . $text . ''; - } - return $data; - } - - function liste($lines,$ulid='') - { - if(!is_array($lines)) return false; - $o = ''; - - return $o; - } - - function getArrowRight() - { - return ' '; - } - - function includeJs($fileName) { - $data = ''; - return $data; - } - - function includeCss($fileName) { - $data = '