connection = @mysql_pconnect(DB_HOST,DB_USER,DB_PASS) or die ("

Konnte keine Verbindung zur Datenbank herstellen!

\n".mysql_errno() . ': ' . mysql_error()); $this->select_database = @mysql_select_db(DB_NAME,$this->connection); } function _get_db () { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; echo "fuck"; } function _close_con () { $this->connection = @mysql_close(); } function _query ($querystring) { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; $res = mysql_query($querystring, $this->connection) or die("{$querystring} Database Error : ".mysql_errno()." : ".mysql_error()); return $res; } function __destruct () { $this->_close_con(); } //interaktionsfunktionen function _add ($name, $job, $short, $detail, $image, $love, $draft, $email=NULL) { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; $crdate=time(); $query = "INSERT INTO $this->table (name, job, short, detail, image, draft, crdate, love,email) VALUES ('$name', '$job', '$short', '$detail', '$image', '$draft', '$crdate', '$love', '$email')"; $this->_query($query); return true; } function _update ($ID, $name, $job, $short, $detail, $image, $love) { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; $query = "UPDATE $this->table SET name = '$name', job = '$job', short = '$short', detail = '$detail', image = '$image', love = '$love' WHERE ID = $ID"; $this->_query($query); return true; } function _del ($ID) { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; $query = "DELETE FROM $this->table WHERE ID = $ID"; $this->_query($query); return true; } function _confirm ($ID, $state) { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; $query = "UPDATE $this->table SET draft = '$state' WHERE ID = $ID"; $this->_query($query); return true; } //upload function _upload ($raw,$dir=NULL) { if(!$dir) $dir = "../fotos/"; $file = $raw['name']; if (empty($file)) { #empty check #echo "

Keine Datei angegeben.

\n"; } else { if (file_exists($dir.$file)) { #exist check #echo "

$file existiert bereits!

\n"; do { $temp = explode(".", $file); #split by . $cnt = count($temp); $arr = $cnt -2; if ($exst = strstr($temp[$arr], "_")) { $ink = explode("_", $temp[$arr]); #split by _ $cnt2 = count($ink); $arr2 = $cnt2 -1; if (is_numeric($ink[$arr2])) { #count up or add _1 $ink[$arr2]++; $ink[$arr2] = "_".$ink[$arr2]."."; } else { $ink[$arr2] = $ink[$arr2]."_1."; } $new = ""; foreach ($ink as $var) { #get it together $new.= $var; } $temp[$arr] = $new; } else { $temp[$arr] = $temp[$arr]."_1."; #just add _1 } $file2 = ""; foreach ($temp as $var) { #get it together $file2.= $var; } $file = $file2; } while (file_exists($dir.$file)); #echo "

Benutze $file sattdessen.

\n"; } if (move_uploaded_file($raw['tmp_name'], $dir.$file)) { chmod ($dir.$file, 0777); return $file; } else { #print_r($_FILES); die("

Fehler: Konnte $file nicht hochladen!

\n"); } } } //get funktionen function _get_voices ($type = '', $id = '') { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; switch ($type) { default: $query = "SELECT * FROM $this->table ORDER BY crdate"; break; case 'fe': $query = "SELECT * FROM $this->table WHERE draft = '0' ORDER BY crdate"; break; case 'drafts': $query = "SELECT * FROM $this->table WHERE draft = '1' ORDER BY crdate"; break; case 'name': $query = "SELECT * FROM $this->table ORDER BY name"; break; case 'one': $query = "SELECT * FROM $this->table WHERE ID = $id"; break; /* zensur views */ case 'l3': $query = "SELECT * FROM $this->table WHERE love = '3' AND draft = '0' ORDER BY crdate"; break; case 'l2': $query = "SELECT * FROM $this->table WHERE love = '2' OR love = '3' AND draft = '0' ORDER BY crdate"; break; } $res = $this->_query($query); $output = array(); while ($row = mysql_fetch_assoc($res)) { array_push($output, $row); } mysql_free_result($res); return $output; } function _get_count () { if ($this->connection == false) $this->__construct(); if ($this->connection == false) return; $query = "SELECT COUNT( ID ) FROM $this->table"; $res = $this->_query($query); $output = array(); while ($row = mysql_fetch_assoc($res)) { array_push($output, $row); } mysql_free_result($res); return $output['0']['COUNT( ID )']; } } // funktionen function message ($status, $text) { if ($status == '+') $class="success"; else $class="error"; return "

$text

\n"; } ?>