Posted by Thomas on Fri 7 Mar 09:58
report abuse | download | new post
- <?php
- class tsk_template {
- public $folder = 'templates/';
- public $ending = '.tpl.htm';
- public $loggedIn = false;
- public $top = '';
- public $btm = '';
- public $main = '';
- function top($var) {
- }
- function btm($var) {
- }
- function setDefault() {
- $this->top('overall_top');
- $this->btm('overall_btm');
- }
- function main($var) {
- }
- function loginout() {
- if($this->loggedIn == false) {
- $this->main = preg_replace("#<!-- Logged_In START -->.*?<!-- Logged_In END -->#is", '', $this->main);
- }
- else{
- $this->top = preg_replace("#<!-- Logged_Out START -->.*?<!-- Logged_Out END -->#is", '', $this->top);
- $this->main = preg_replace("#<!-- Logged_Out START -->.*?<!-- Logged_Out END -->#is", '', $this->main);
- $this->btm = preg_replace("#<!-- Logged_Out START -->.*?<!-- Logged_Out END -->#is", '', $this->btm);
- }
- }
- function OnlyLogout($redirect = 'index.php') {
- if($this->loggedIn == true) {
- return 0;
- }
- else
- return 1;
- }
- function OnlyLogin($redirect = 'index.php?side=registrer') {
- if($this->loggedIn == false) {
- return 0;
- }
- else
- return 1;
- }
- function output() {
- }
- function format() {
- }
- function loop($array, $name, $content) {
- $temp = '';
- $var = '';
- foreach ($array as $array2) {
- $this->temp = $var[1];
- foreach ($array2 as $n => $v) {
- }
- $temp .= $this->temp;
- }
- $content = preg_replace("#<!-- START ". $name ." -->.*?<!-- END ". $name ." -->#is", $temp, $content);
- return $content;
- }
- function setData($array) {
- foreach($array as $n => $v)
- $this->data[$n] = $v;
- }
- }
- function setSData($array) {
- foreach($array as $n => $v)
- $this->sdata[$n] = $v;
- }
- }
- function replace($array, $var)
- {
- switch($array)
- {
- case 'GET':
- return $_GET[$var];
- case 'POST':
- return $_POST[$var];
- case 'DATA':
- return $this->data[$var];
- case 'SDATA':
- return $this->sdata[$var];
- case 'TPL':
- return $this->templates[$var];
- case 'FORM':
- }
- return '';
- }
- function loadTPL($name, $file) {
- }
- function createLeftBar($type = 'offline') {
- $leftBar = new leftBar($type);
- $leftBar->run();
- $this->templates['leftBar'] = $leftBar->get();
- }
- function createFormElement($var) {
- if($var[1] == 'select') {
- if($var[3] == 'loop'){
- $t = '<select name="'. $var[2] .'" style="width:'. $var[6] .'px" id="'. $var[2] .'">';
- for($i = $var[4]; $i <= $var[5]; $i++) {
- $t .= '<option value="'. $i .'"';
- if($i == $_POST[$var[2]] || (!$_POST && $i == $var[7]))
- $t .= ' selected';
- $t .= '>'. $i .'</option>'."\n";
- }
- $t .= '</select>';
- return $t;
- }
- // {FORM:select,school_type,data,school_types,40}
- elseif($var[3] == 'data') {
- $t = '<select name="'. $var[2] .'" style="width:'. $var[5] .'px" id="'. $var[2] .'">';
- foreach($this->data[$var[4]] as $n => $v )
- {
- $t .= '<option value="'. $n .'"';
- $t .= ' selected';
- $t .= '>'. $v .'</option>'."\n";
- }
- $t .= '</select>';
- return $t;
- }
- }
- elseif($var[1] == 'text') {
- $t = '<input type="text" name="'. $var[2] .'" id="'. $var[2] .'" value="';
- $t .= (!$_POST[$var[2]]) ? $var[3] : $_POST[$var[2]];
- $t .= '">';
- return $t;
- }
- elseif($var[1] == 'checkbox') {
- $t = '<input type="checkbox" name="'. $var[2] .'" id="'. $var[2] .'" value="'. $var[3] .'"';
- $t .= ' checked';
- $t .= ' style="width:auto;">';
- return $t;
- }
- return '';
- }
- function debug() {
- </pre><hr>'. $this->btm;
- }
- function eregs($ereg, $str, $min = 1, $max = 100){
- // Enter other valid characters below
- return 3;
- else return 2;
- }
- else return 1;
- }
- function checkHack($valid, $against) {
- foreach($against as $n => $v)
- $this->hackAttempt();
- }
- function hackAttempt() {
- die('<h1>Hacking forsøk</h1>Din IP er lagret. Hvis dette ikke var et ment hacke-forsøk; ignorer denne meldingen og prøv igjen.');
- }
- }
- ?>
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.