db_host=$db_host; $this->db_user=$db_user; $this->db_pass=$db_pass; $this->db_name=$db_name; $this->db = mysql_connect($this->db_host, $this->db_user, $this->db_pass); mysql_select_db ($this->db_name) or die ("Cannot connect to database"); } function create ($tablename){ $query = "CREATE TABLE $tablename (`id` int(11) NOT NULL auto_increment,`titel` varchar(75) default NULL, `username` varchar(75),`datum` varchar(30),`post` text,`quote` text,`newpost` tinytext,`timestamp` int,PRIMARY KEY (`id`))"; $result = mysql_query($query); } #----------------------------------------------------------------------------------------------- function showColumns($tablename){ global $rec; $query = "SHOW COLUMNS FROM $tablename"; $result = mysql_query($query); while($r=mysql_fetch_array($result)) { $cols[]=$r[0]; } $rec->deBug("showColumns ~".$tablename); return $cols; } function get_id($tablename, $where) { $query = "SELECT * FROM $tablename $where"; $result = mysql_query($query); while($r=mysql_fetch_array($result)) { $id=$r["id"]; } return $id; } function getLastId($tablename) { $query = "SELECT * FROM $tablename ORDER BY id desc LIMIT 1"; $result = mysql_query($query); while($r=mysql_fetch_array($result)) { $id=$r["id"]; } global $rec; $rec->deBug("query get last id~ $query > result $id"); return $id; } function get($tablename, $where, $order, $modus, $limit) { $query = "SELECT * FROM $tablename $where order by $order $modus $limit"; $result = mysql_query($query); $this->resultGet=$result; while($r=mysql_fetch_array($this->resultGet)) { $dataColl[] = $r; } global $rec; $rec->deBug("query~ $query"); $rec->data['aantalWhere'] = mysql_num_rows($result); $rec->deBug("get query~ totaal aantal where = ".$rec->data['aantalWhere']); return $dataColl; } function getExtended($query) { $result = mysql_query($query); while($r=mysql_fetch_array($result,MYSQL_ASSOC)) { $dataColl[] = $r; } $aantalWhere = mysql_num_rows($result); global $rec; $rec->data['aantalWhere'] = $aantalWhere; $rec->deBug("extended query~ $query"); $rec->deBug("extended query~ totaal aantal where = $aantalWhere"); return $dataColl; } function getVisitors($table,$id) { $query = "SELECT * FROM $table WHERE client_id='$id' order by id desc "; $result = mysql_query($query); global $rec; $rec->deBug("query getVisitors~ $query"); $this->getVisitorsResult=$result; //return $result; } function exist($tablename, $where, $order, $modus, $limit) { $aantalWhere = "SELECT * FROM $tablename $where order by $order $modus $limit"; $result = mysql_query($aantalWhere); $this->resultGet=$result; $aantalWhere = mysql_num_rows(mysql_query($aantalWhere)); if($aantalWhere == "" || $aantalWhere == 0) return false; else return true; } #----------------------------------------------------------------------------------------------- function forumlogin($username, $password) { $query = "SELECT * FROM forum_users Where naam='$username' AND password='$password'"; $result = mysql_query($query); $this->aantal = mysql_num_rows($result); $this->result=$result; } #----------------------------------------------------------------------------------------------- function addQueryCustom($query){ mysql_query($query); global $rec; $rec->deBug("add queryCustom~ $query"); } function addQuery($tablename, $id=""){ $hit=false; $cols = $this->showColumns($tablename); global $rec; if($id=="") { $query = "INSERT INTO $tablename ("; for($i=0;$idata[$cols[$i]])) { if($hit==true) $query .= ","; $query .= $cols[$i]; $hit=true; } } $hit=false; $query .= ") VALUES ("; for($i=0;$idata[$cols[$i]])) { if($hit==true) $query .= ","; $query .= "'".$rec->data[$cols[$i]]."'"; $hit=true; } } $query .= ")"; mysql_query($query); $which = "nieuwe entry"; } else { $query = "UPDATE $tablename SET "; for($i=0;$idata[$cols[$i]])) { if($hit==true) $query .= ","; $query .= $cols[$i]."='".$rec->data[$cols[$i]]."'"; $hit=true; } } $query .= " WHERE id='".$id."'"; mysql_query($query); $which = "update entry"; } global $rec; $rec->deBug("add $which query~ $query"); if($which=="nieuwe entry") $id = $this->getLastId($tablename); return $id; } #----------------------------------------------------------------------------------------------- # insert into database table # $sql->insert("blaaa", "(titel)", "('titel')"); # $columns example - (titel, actueel, actueelgroot) # $values example - ('".$_POST['titel']."','$actueel') function insert($tablename, $column, $values){ $query = "INSERT INTO $tablename $column VALUES $values"; //echo $query; mysql_query($query); } #----------------------------------------------------------------------------------------------- function update($tablename, $input, $where){ $query = "UPDATE $tablename SET $input $where"; //echo $query; mysql_query($query); } #----------------------------------------------------------------------------------------------- function delete($tablename, $where) { $query = "DELETE FROM $tablename $where"; mysql_query($query); } function deleteQuery($tablename, $where) { $query = "DELETE FROM $tablename $where"; mysql_query($query); global $rec; $rec->deBug("delete query~ $query"); } #----------------------------------------------------------------------------------------------- function dropTable($tablename){ $query = "DROP TABLE $tablename"; mysql_query($query); $this->sqlclose(); } #----------------------------------------------------------------------------------------------- function sqlclose() { mysql_close($this->db); global $rec; $rec->deBug("close MySQL~ database ".$this->db_name); } } ?>strttime = $this->getmicrotime(); while (@list($var, $value) = each($hash)) { if($value!="") { //$value = str_replace ('"',""",$value); //$value = str_replace ("'","´",$value); $this->data[$var] = $value; $this->deBug("data array~ rec->data['$var'] = $value"); } } } #------------------------------------------------------- function getmicrotime(){ list($usec, $sec) = explode(" ",microtime()); return ( (float)$sec + (float)$usec); } function deBug($string) { $strttime = $this->getmicrotime(); $string=str_replace('"',""",$string); $parts = split("~",$string); $t = $this->getmicrotime() - $this->strttime; $parts[1] = str_replace("<","[",$parts[1]); $parts[1] = str_replace(">","]",$parts[1]); $parts[1] = str_replace("","[td]",$parts[1]); $parts[1] = str_replace("","[/td]",$parts[1]); $parts[1] = str_replace("","[tr]",$parts[1]); $parts[1] = str_replace("","[/tr]",$parts[1]); $parts[1] = str_replace("[br]","
",$parts[1]); $parts[1] = str_replace("[BR]","
",$parts[1]); $parts[1] = str_replace("\n","
",$parts[1]); $this->data['debug'].= "".$t."".$parts[0]."".$parts[1].$parts[2].""; } } ?> niveau=0; $this->index=0; $this->niveau_lager=0; } function niveauLager() { if($this->niveau != 0) $this->niveau_lager=$this->niveau-1; else $this->niveau_lager=0; } //almost obsolete function loadFile($map,$template) { $filelocation = "../templates/$map/$template"; $handle = fopen ($filelocation , "r"); $content = fread ($handle, filesize ($filelocation)); fclose ($handle); $this->output[0]=$content; $this->import(); global $rec; $rec->deBug("laden template~ $filelocation"); //echo $filelocation.$content; } function import() { global $rec; $patroon = "//smU"; preg_match_all($patroon, $this->output[0], $match); for($i=0;$i<=count($match);$i++) { $this->matchBlokControllers($match[0][$i]); $import = $this->loadData($rec->data['src']); $this->output[0] = str_replace($match[0][$i],$import,$this->output[0]); $rec->deBug("zoek import blok~ ".$match[0][$i]); } } function removeDelimiters($varToReplace) { $this->varToReplace = $varToReplace; $this->varToReplace = str_replace("{","",$this->varToReplace); $this->varToReplace = str_replace("}","",$this->varToReplace); return $this->varToReplace; } function loadData($file) { $filelocation = "../templates/$file"; $handle = fopen ($filelocation , "r"); $content = fread ($handle, filesize ($filelocation)); fclose ($handle); global $rec; $rec->deBug("import template~ src = $filelocation"); return $content; } function load($map,$template,$pagina=true) { //empty tpl object $this->niveau=0; $this->index=0; $this->niveau_lager=0; $this->patronen=array(); $this->match=array(); $this->pre_output=array(); $this->output=array(); $filelocation = "../templates/$map/$template"; $handle = fopen ($filelocation , "r"); $content = fread ($handle, filesize ($filelocation)); fclose ($handle); if($pagina){ preg_match("//sm", $content, $dtd); $content = preg_replace($dtd[0],"", $content); $content = preg_replace("/<>/sm",$dtd[0]."", $content); $content=$content.""; } $this->output[0]=$content; //$this->import(); global $rec; $rec->deBug("laden template~ $filelocation"); } function loadFileNB($map,$template) { $filelocation = "$map/$template"; $handle = fopen ($filelocation , "r"); $content = fread ($handle, filesize ($filelocation)); fclose ($handle); $this->output[0]=$content; //echo $filelocation.$content; } function patroon($bloknaam) { global $rec; if($bloknaam=="") $patroon="//sm"; else $patroon = "//sm"; $this->patronen[$this->niveau][$this->index] = $patroon; $rec->deBug("inladen patroon~ $patroon"); $this->matchBlock($this->niveau, $this->index); $this->index = $this->index+1; } function matchBlock($niveau, $index) { if($niveau != 0) $niveau_lager=$niveau-1; else $niveau_lager=0; preg_match($this->patronen[$niveau][$index], $this->output[$niveau_lager], $match); $this->match = $match; $this->matchBlokControllers(); global $rec; //$rec->deBug("match Blok~ ".$match[0]); if(isset($match[0])) $rec->deBug("match Blok~ match"); else $rec->deBug("match Blok~ NO-match"); } function matchBlokControllers($src="") { global $rec; if($src!="") $this->match[0] = $src; $patroon_controller="/[a-z]+=[a-z0-9]+\/[a-z0-9]+_[a-z0-9]+.[a-z0-9]+/"; preg_match_all($patroon_controller,$this->match[0],$match_controller); for($i=0;$idata[$controller_array[0]]=$controller_array[1]; //echo "rec->data[".$controller_array[0]."]=".$controller_array[1]."
"; $rec->deBug("blok controller~ rec->data[".$controller_array[0]."]=".$controller_array[1]); } } } function def($tmp){ global $rec; $rec->deBug("init~ function IFDEF / IFNDEF"); $ifdefpatroon = "/(.*)/smU"; //single match vs. dubble match // U for ungreedy //preg_match($ifdefpatroon, $tmp, $ifdefmatches); preg_match_all($ifdefpatroon, $tmp, $ifdefmatchess); for($i=0;$ideBug("IFDEF~ rec->data[".$ifdefmatchess[1][$i]."]==".$rec->data[$ifdefmatchess[1][$i]]); if($rec->data[$ifdefmatchess[1][$i]]=="") { $tmp = str_replace($ifdefmatchess[0][$i],"",$tmp); $rec->deBug("IFDEF~ ".$ifdefmatchess[1][$i]); } } //---- unset($ifdefmatchess); $ifdefpatroon = "/(.*)/smU"; preg_match_all($ifdefpatroon, $tmp, $ifdefmatchess); for($i=0;$idata[$ifdefmatchess[1][$i]]!="") { $tmp = str_replace($ifdefmatchess[0][$i],"",$tmp); $rec->deBug("IFNDEF~ ".$ifdefmatchess[1][$i]); } } return $tmp; } function defForFill($tmp,$index){ global $rec; $rec->deBug("init~ function IFDEF / IFNDEF"); $ifdefpatroon = "/(.*)/smU"; //single match vs. dubble match // U for ungreedy //preg_match($ifdefpatroon, $tmp, $ifdefmatches); preg_match_all($ifdefpatroon, $tmp, $ifdefmatchess); for($i=0;$idata['coll']==false) { $rec->deBug("IFDEF test~ this->data[".$ifdefmatchess[1][$i]."]=".$this->data[$ifdefmatchess[1][$i]]); if($this->data[$ifdefmatchess[1][$i]]=="") { $tmp = str_replace($ifdefmatchess[0][$i],"",$tmp); $rec->deBug("IFDEF verwijderd~ ".$ifdefmatchess[1][$i]." bestaat niet"); } else $tmp = str_replace($ifdefmatchess[0][$i],$ifdefmatchess[2][$i],$tmp); } else { $rec->deBug("IFDEF test~ this->data[".$ifdefmatchess[1][$i]."]==".$rec->data[$ifdefmatchess[1][$i]]."
this->data[".$ifdefmatchess[1][$i]."]==".$rec->data[$ifdefmatchess[1][$i]]); if($this->data[$ifdefmatchess[1][$i]][$index]=="") { $tmp = str_replace($ifdefmatchess[0][$i],"",$tmp); $rec->deBug("IFDEF in Coll verwijderd~ ".$ifdefmatchess[1][$i]." bestaat niet"); } } } //---- unset($ifdefmatchess); $ifdefpatroon = "/(.*)/smU"; preg_match_all($ifdefpatroon, $tmp, $ifdefmatchess); for($i=0;$idata['coll']==false) { $rec->deBug("IFNDEF test~ this->data[".$ifdefmatchess[1][$i]."]!=".$rec->data[$ifdefmatchess[1][$i]]); if($this->data[$ifdefmatchess[1][$i]]!="") { $tmp = str_replace($ifdefmatchess[0][$i],"",$tmp); $rec->deBug("IFNDEF verwijderd~ ".$ifdefmatchess[1][$i]." bestaat"); } else $tmp = str_replace($ifdefmatchess[0][$i],$ifdefmatchess[2][$i],$tmp); } else { $rec->deBug("IFNDEF test~ this->data[".$ifdefmatchess[1][$i]."]!=".$rec->data[$ifdefmatchess[1][$i]]); if($this->data[$ifdefmatchess[1][$i]][$index]!="") { $tmp = str_replace($ifdefmatchess[0][$i],"",$tmp); $rec->deBug("IFNDEF in Coll verwijderd~ ".$ifdefmatchess[1][$i]." bestaat"); } } } $rec->deBug("IFDEF matched~ uitgevoerd"); $tmp = str_replace("