<?php class mysql{ private $db; private $session = array(); private $post = array(); private $error = 0; private $meldung; private $mysqlTXT; public function __construct(){ global $datenbank,$_SESSION; $this->db = $datenbank; $this->session = $_SESSION; } private function make_array($post,$file){ foreach($post AS $key => $value){ if($key != '' && $key != 'run' && $value != ''){ $this->post[$key] = $value; } } } public function ausfuehren($post,$file){ $this->make_array($post,$file); if($this->session['admin'] != 1){ die("Nicht genemigter Zugriff");} $this->CheckUpload($file); if($this->error == 0){ $this->import(); $this->meldung = MYSQL_UPLOAD_TRUE; } meldung($this->error,$this->meldung); } private function CheckUpload($file){ if(isset($this->post['mysqltxt']) || !empty($this->post['mysqltxt']) ){ $this->post['mysqltxt'] = str_replace(array("\r\n","\n\r", "\n", "\r"),"",$this->post['mysqltxt']); $this->txt(); }elseif(isset($file)){ $this->file($file); } } private function txt(){ $this->mysqlTXT = str_replace("vms_",PREFIX, $this->post['mysqltxt']); } private function file($file){ $endung = strtolower(pathinfo($file['mysqldatei']['name'], PATHINFO_EXTENSION)); if(!in_array($endung,array("sql","txt"))){ $this->error = 1; $this->meldung = MYSQL_DATEITYPE_FALSE;} if($this->error == 0){ $this->mysqlTXT = str_replace("vms_",PREFIX , file_get_contents($file['mysqldatei']['tmp_name'],true)); } } private function import(){ $explode = explode(";",$this->mysqlTXT); for($i = 0; $i <= count($explode)-1; $i++){ $this->db->query($explode[$i]); } } }