*/ if (!class_exists('guestbook_database')) { class guestbook_database { var $db = null; var $direct_post = null; var $notify = false; var $parent = null; var $show_max = 10; function guestbook_database($parent=NULL) { //$this->direct_post = 1; // uncomment if you want the posts to be directly visible if ( !is_null($parent) ) { $this->parent = $parent; $this->direct_post = $parent->getConf('direct_post'); $this->notify = $parent->getConf('notify'); $this->post_url = $parent->getConf('post_url'); $this->show_max = $parent->getConf('show_max'); } } function connect_db($parent=NULL, $admin=NULL) { if ( is_null($this->parent) && !is_null($parent)) $this->parent = $parent; $db_server = $this->parent->getConf('db_server'); $db_user = $this->parent->getConf('db_user'); $db_name = $this->parent->getConf('db_name'); $db_password = $this->parent->getConf('db_passwd'); $this->direct_post = $this->parent->getConf('direct_post'); $this->notify = $this->parent->getConf('notify'); $this->post_url = $parent->getConf('post_url'); $this->db = @mysql_connect($db_server, $db_user, $db_password) or die ("Konnte keine Verbindung zur Datenbank herstellen"); @mysql_select_db($db_name, $this->db); } function close_db() { @mysql_close($this->db); $this->db = null; } function quote_smart($value) { // stripslashes, falls nötig if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // quotieren, falls kein integer if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } function checkStatus($parent) { global $INFO; if ( $INFO['perm'] == AUTH_ADMIN) { $name="wiki_guestbook"; if ( !empty($name) ) { $this->connect_db($parent); $sql = "SHOW TABLES"; $result = mysql_query($sql); $tables = array(); $guestbookExists = NULL; while ($data=mysql_fetch_row($result)) if ($data[0] == $name) $guestbookExists = 1; if ( is_null($guestbookExists) ) { $sql1 = "CREATE TABLE `wiki_guestbook` (". "`ID` int(11) NOT NULL auto_increment,". "`messagehead` varchar(50) default NULL,". "`messagetext` longtext,". "`name` varchar(50) default NULL,". // "`url` varchar(255) default NULL,". "`date` datetime NOT NULL default '0000-00-00 00:00:00',". "`active` tinyint(1) default 0,". "PRIMARY KEY (`ID`)". ") ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=70 ;"; mysql_query($sql1); } $this->close_db(); } } else { $name = ereg_replace("[ \t\r.]", "_", htmlentities($_SERVER['REMOTE_USER'])); } return $name; } } } if (!class_exists('guestbook')) { class guestbook { var $admin; function guestbook($admin=false) { $this->admin = $admin; } function html($parent) { global $ID; $output = ""; $nav = $this->navBar($parent); $output .= '
'; $output .= $nav[0]; $start = $nav[1]; $row = $nav[2]; $guestbook_database = new guestbook_database($parent); $guestbook_database->connect_db($parent, TRUE); $sql="SELECT messagehead, messagetext, name, date, ID, active FROM wiki_guestbook " . (!$this->admin?'WHERE active=1 ':'') . "ORDER BY date DESC LIMIT $start, " . intval($guestbook_database->show_max); $result = mysql_query($sql); while($data = mysql_fetch_array($result)) { $output .= ' '; } $guestbook_database->close_db; $output .= $nav[0]; if ( mysql_num_rows($result)>0 ) $output .= ''; else $output .= '