function _rex_installDump($file, $debug = false) { $sql = new sql(); $sql->debugsql = $debug; $error = ''; foreach (readSqlDump($file) as $query) { $sql->setQuery($query); if (($sqlerr = $sql->getError()) != '') { $error .= $sqlerr . "\n<br/>"; } } return $error; }
/** * @access protected * @return Returns <code>true</code> on success or <code>false</code> on error */ function _delete() { global $REX; $qry = 'DELETE FROM ' . $this->_getTableName() . ' WHERE file_id = ' . $this->getId() . ' LIMIT 1'; $sql = new sql(); // $sql->debugsql = true; $sql->query($qry); ### todo - loeschen des files unlink($REX['INCLUDE_PATH'] . "/../../files/" . $this->getFileName()); return $sql->getError(); }
/** * @access protected * @return Returns <code>true</code> on success or <code>false</code> on error */ function _delete($recurse = false) { // Rekursiv löschen? if ($recurse) { if ($this->hasChildren()) { $childs = $this->getChildren(); foreach ($childs as $child) { $child->_delete($recurse); } } } // Alle Dateien löschen if ($this->hasFiles()) { $files = $this->getFiles(); foreach ($files as $file) { $file->_delete(); } } $qry = 'DELETE FROM ' . $this->_getTableName() . ' WHERE id = ' . $this->getId() . ' LIMIT 1'; $sql = new sql(); // $sql->debugsql = true; // echo $qry; // return; $sql->query($qry); return $sql->getError(); }
/** * Importiert den SQL Dump $filename in die Datenbank * * @param string Pfad + Dateinamen zur SQL-Datei * * @return array Gibt ein Assoc. Array zurück. * 'state' => boolean (Status ob fehler aufgetreten sind) * 'message' => Evtl. Status/Fehlermeldung */ function rex_a1_import_db($filename, $replace_rex = false) { global $REX, $I18N_IM_EXPORT; $return = array(); $return['state'] = false; $return['message'] = ''; $msg = ''; $error = ''; if ($filename == '') { $return['message'] = $I18N_IM_EXPORT->msg('no_import_file_chosen_or_wrong_version') . '<br>'; return $return; } $h = fopen($filename, "r"); $conts = fread($h, filesize($filename)); fclose($h); // Versionsstempel prüfen // ## Redaxo Database Dump Version x.x $rex_version = strpos($conts, "## Redaxo Database Dump Version " . $REX['VERSION']); if ($rex_version === FALSE) { $return['message'] = $I18N_IM_EXPORT->msg("no_valid_import_file") . ". [## Redaxo Database Dump Version " . $REX['VERSION'] . "] is missing"; return $return; } else { // Versionsstempel entfernen $conts = trim(str_replace("## Redaxo Database Dump Version " . $REX['VERSION'], "", $conts)); } // Prefix prüfen // ## Prefix rex_ $rex_prefix = strpos($conts, "## Prefix " . $REX['TABLE_PREFIX']); if ($replace_rex) { $conts = trim(str_replace("## Prefix rex_", "", $conts)); $conts = str_replace("TABLE rex_", "TABLE " . $REX['TABLE_PREFIX'], $conts); $conts = str_replace("INTO rex_", "INTO " . $REX['TABLE_PREFIX'], $conts); $conts = str_replace("EXISTS rex_", "EXISTS " . $REX['TABLE_PREFIX'], $conts); } elseif ($rex_prefix === FALSE) { $return['message'] = $I18N_IM_EXPORT->msg("no_valid_import_file") . ". [## Prefix " . $REX['TABLE_PREFIX'] . "] does not match config in master.inc.php"; return $return; } else { // Prefix entfernen $conts = trim(str_replace("## Prefix " . $REX['TABLE_PREFIX'], "", $conts)); } // Ordner /generated komplett leeren rex_deleteDir($REX['INCLUDE_PATH'] . '/generated/articles'); rex_deleteDir($REX['INCLUDE_PATH'] . '/generated/files'); rex_deleteDir($REX['INCLUDE_PATH'] . '/generated/templates'); // Datei aufteilen $lines = explode("\n", $conts); $add = new sql(); // $add->debugsql = 1; foreach ($lines as $line) { $line = trim($line, "\r"); // Windows spezifische extras $line = trim($line, ";"); // mysql 3.x $add->setquery($line); $add->flush(); } $msg .= $I18N_IM_EXPORT->msg("database_imported") . ". " . $I18N_IM_EXPORT->msg("entry_count", count($lines)) . "<br>"; // CLANG Array aktualisieren unset($REX['CLANG']); $db = new sql(); $db->setQuery("select * from " . $REX['TABLE_PREFIX'] . "clang"); for ($i = 0; $i < $db->getRows(); $i++) { $id = $db->getValue("id"); $name = $db->getValue("name"); $REX['CLANG'][$id] = $name; $db->next(); } // prüfen, ob eine user tabelle angelegt wurde $result = $db->get_array('SHOW TABLES'); $user_table_found = false; foreach ($result as $row) { if (in_array($REX['TABLE_PREFIX'] . 'user', $row)) { $user_table_found = true; break; } } if (!$user_table_found) { $create_user_table = ' CREATE TABLE ' . $REX['TABLE_PREFIX'] . 'user ( user_id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL, description text NOT NULL, login varchar(50) NOT NULL, psw varchar(50) NOT NULL, status varchar(5) NOT NULL, rights text NOT NULL, login_tries tinyint(4) NOT NULL DEFAULT 0, createuser varchar(255) NOT NULL, updateuser varchar(255) NOT NULL, createdate int(11) NOT NULL DEFAULT 0, updatedate int(11) NOT NULL DEFAULT 0, lasttrydate int(11) NOT NULL DEFAULT 0, session_id varchar(255) NOT NULL, PRIMARY KEY(user_id) ) TYPE=MyISAM;'; $db->setQuery($create_user_table); $error = $db->getError(); if ($error != '') { // evtl vorhergehende meldungen löschen, damit nur der fehler angezeigt wird $msg = ''; $msg .= $error; } } // generated neu erstellen, wenn kein Fehler aufgetreten ist if ($error == '') { $msg .= rex_generateAll(); $return['state'] = true; } $return['message'] = $msg; return $return; }