本文整理汇总了PHP中rex_generateAll函数的典型用法代码示例。如果您正苦于以下问题:PHP rex_generateAll函数的具体用法?PHP rex_generateAll怎么用?PHP rex_generateAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rex_generateAll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rex_a62_metainfo_cleanup
/**
* Alle Metafelder löschen, nicht das nach einem Import in der Parameter Tabelle
* noch Datensätze zu Feldern stehen, welche nicht als Spalten in der
* rex_article angelegt wurden!
*/
function rex_a62_metainfo_cleanup($params)
{
global $REX;
// Cleanup nur durchführen, wenn auch die rex_article Tabelle neu angelegt wird
if (isset($params['force']) && $params['force'] != true && strpos($params['content'], 'CREATE TABLE `' . $REX['TABLE_PREFIX'] . 'article`') === false && strpos($params['content'], 'CREATE TABLE ' . $REX['TABLE_PREFIX'] . 'article') === false) {
return;
}
require_once $REX['INCLUDE_PATH'] . '/addons/metainfo/classes/class.rex_table_manager.inc.php';
$sql = new rex_sql();
$sql->setQuery('SELECT name FROM ' . $REX['TABLE_PREFIX'] . '62_params');
for ($i = 0; $i < $sql->getRows(); $i++) {
if (substr($sql->getValue('name'), 0, 4) == 'med_') {
$tableManager = new rex_a62_tableManager($REX['TABLE_PREFIX'] . 'file');
} else {
$tableManager = new rex_a62_tableManager($REX['TABLE_PREFIX'] . 'article');
}
$tableManager->deleteColumn($sql->getValue('name'));
$sql->next();
}
// evtl reste aufräumen
$tablePrefixes = array('article' => array('art_', 'cat_'), 'file' => array('med_'));
foreach ($tablePrefixes as $table => $prefixes) {
$table = $REX['TABLE_PREFIX'] . $table;
$tableManager = new rex_a62_tableManager($table);
foreach (rex_sql::showColumns($table) as $column) {
$column = $column['name'];
if (in_array(substr($column, 0, 4), $prefixes)) {
$tableManager->deleteColumn($column);
}
}
}
$sql = new rex_sql();
$sql->setQuery('DELETE FROM ' . $REX['TABLE_PREFIX'] . '62_params');
rex_generateAll();
}
示例2: rex_addCLang
/**
* Erstellt eine Clang
*
* @param $id Id der Clang
* @param $name Name der Clang
*/
function rex_addCLang($id, $name)
{
global $REX;
$REX['CLANG'][$id] = $name;
$content = "// --- DYN\n\r";
reset($REX['CLANG']);
for ($i = 0; $i < count($REX['CLANG']); $i++) {
$cur = key($REX['CLANG']);
$val = current($REX['CLANG']);
$content .= "\n\r\$REX['CLANG']['{$cur}'] = \"{$val}\";";
next($REX['CLANG']);
}
$content .= "\n\r// --- /DYN";
$file = $REX['INCLUDE_PATH'] . "/clang.inc.php";
$h = fopen($file, "r");
$fcontent = fread($h, filesize($file));
$fcontent = ereg_replace("(\\/\\/.---.DYN.*\\/\\/.---.\\/DYN)", $content, $fcontent);
fclose($h);
$h = fopen($file, "w+");
fwrite($h, $fcontent, strlen($fcontent));
fclose($h);
@chmod($file, 0777);
$add = new sql();
$add->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where clang='0'");
$fields = $add->getFieldnames();
for ($i = 0; $i < $add->getRows(); $i++) {
$adda = new sql();
// $adda->debugsql = 1;
$adda->setTable($REX['TABLE_PREFIX'] . "article");
reset($fields);
while (list($key, $value) = each($fields)) {
if ($value == "pid") {
echo "";
} else {
if ($value == "clang") {
$adda->setValue("clang", $id);
} else {
if ($value == "status") {
$adda->setValue("status", "0");
} else {
$adda->setValue($value, rex_addslashes($add->getValue("{$value}")));
}
}
}
// createuser
// updateuser
}
$adda->insert();
$add->next();
}
$add = new sql();
$add->query("insert into " . $REX['TABLE_PREFIX'] . "clang set id='{$id}',name='{$name}'");
// ----- EXTENSION POINT
rex_register_extension_point('CLANG_ADDED', '', array('id' => $id, 'name' => $name));
rex_generateAll();
}
示例3: generateAll
public function generateAll()
{
global $REX;
// set rex vars for this website
$this->switchRexVars();
// do generate all
rex_generateAll();
// restore rex vars for current website
$REX['WEBSITE_MANAGER']->getCurrentWebsite()->switchRexVars();
// temporary workaround for seo42 master website empty pathlist problem
rex_generateAll();
}
示例4: rex_addCLang
/**
* Erstellt eine Clang
*
* @param $id Id der Clang
* @param $name Name der Clang
*
* @return TRUE bei Erfolg, sonst FALSE
*/
function rex_addCLang($id, $name)
{
global $REX;
if (isset($REX['CLANG'][$id])) {
return false;
}
$REX['CLANG'][$id] = $name;
$file = $REX['INCLUDE_PATH'] . '/clang.inc.php';
rex_replace_dynamic_contents($file, "\$REX['CLANG'] = " . var_export($REX['CLANG'], true) . ";\n");
$firstLang = rex_sql::factory();
$firstLang->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article where clang='0'");
$fields = $firstLang->getFieldnames();
$newLang = rex_sql::factory();
// $newLang->debugsql = 1;
while ($firstLang->hasNext()) {
$newLang->setTable($REX['TABLE_PREFIX'] . 'article');
foreach ($fields as $key => $value) {
if ($value == 'pid') {
echo '';
} elseif ($value == 'clang') {
$newLang->setValue('clang', $id);
} elseif ($value == 'status') {
$newLang->setValue('status', '0');
} else {
$newLang->setValue($value, $firstLang->escape($firstLang->getValue($value)));
}
}
$newLang->insert();
$firstLang->next();
}
$firstLang->freeResult();
$newLang = rex_sql::factory();
$newLang->setQuery('insert into ' . $REX['TABLE_PREFIX'] . "clang set id='{$id}',name='{$name}'");
rex_generateAll();
// ----- EXTENSION POINT
rex_register_extension_point('CLANG_ADDED', '', array('id' => $id, 'name' => $name));
return true;
}
示例5: save
function save()
{
global $I18N_META_INFOS;
$fieldName = $this->getFieldValue('name');
if ($fieldName == '') {
return $I18N_META_INFOS->msg('field_error_name');
}
if (preg_match('/[^a-zA-Z0-9\\_]/', $fieldName)) {
return $I18N_META_INFOS->msg('field_error_chars_name');
}
// Prüfen ob schon eine Spalte mit dem Namen existiert (nur beim add nötig)
if (!$this->isEditMode()) {
$sql = new rex_sql();
$sql->setQuery('SELECT * FROM ' . $this->tableName . ' WHERE name="' . $this->addPrefix($fieldName) . '" LIMIT 1');
if ($sql->getRows() == 1) {
return $I18N_META_INFOS->msg('field_error_unique_name');
}
}
// Den alten Wert aus der DB holen
// Dies muss hier geschehen, da in parent::save() die Werte für die DB mit den
// POST werten überschrieben werden!
$fieldOldName = '';
$fieldOldPrior = 9999999999999;
// dirty, damit die prio richtig läuft...
$fieldOldDefault = '';
if ($this->sql->getRows() == 1) {
$fieldOldName = $this->sql->getValue('name');
$fieldOldPrior = $this->sql->getValue('prior');
$fieldOldDefault = $this->sql->getValue('default');
}
if (parent::save()) {
global $REX, $I18N;
$this->organizePriorities($this->getFieldValue('prior'), $fieldOldPrior);
rex_generateAll();
$fieldName = $this->addPrefix($fieldName);
$fieldType = $this->getFieldValue('type');
$fieldDefault = $this->getFieldValue('default');
$sql = rex_sql::getInstance();
$result = $sql->getArray('SELECT `dbtype`, `dblength` FROM `' . $REX['TABLE_PREFIX'] . '62_type` WHERE id=' . $fieldType);
$fieldDbType = $result[0]['dbtype'];
$fieldDbLength = $result[0]['dblength'];
// TEXT Spalten dürfen in MySQL keine Defaultwerte haben
if ($fieldDbType == 'text') {
$fieldDefault = null;
}
if ($this->isEditMode()) {
// Spalte in der Tabelle verändern
$tmRes = $this->tableManager->editColumn($fieldOldName, $fieldName, $fieldDbType, $fieldDbLength, $fieldDefault);
} else {
// Spalte in der Tabelle anlegen
$tmRes = $this->tableManager->addColumn($fieldName, $fieldDbType, $fieldDbLength, $fieldDefault);
}
if ($tmRes) {
// DefaultWerte setzen
if ($fieldDefault != $fieldOldDefault) {
$qry = 'UPDATE `' . $this->tableManager->getTableName() . '` SET `' . $fieldName . '`="' . $fieldDefault . '" WHERE `' . $fieldName . '`="' . $fieldOldDefault . '"';
return $sql->setQuery($qry);
}
// Default werte haben schon zuvor gepasst, daher true zurückgeben
return true;
}
}
return false;
}
示例6: rex_sql
<?php
$myself = 'open_graph';
$sql = new rex_sql();
$sql->debugsql = true;
// rex_article
$sql->setQuery('ALTER TABLE `' . $REX['TABLE_PREFIX'] . 'article` DROP `art_open_graph`, DROP `art_open_graph_title`, DROP `art_open_graph_type`, DROP `art_open_graph_typevalues`, DROP `art_open_graph_description`, DROP `art_open_graph_site_name`, DROP `art_open_graph_images`');
$sql->setQuery("DELETE FROM " . $REX['TABLE_PREFIX'] . "62_params WHERE name='art_open_graph' OR name='art_open_graph_title' OR name='art_open_graph_type' OR name='art_open_graph_typevalues' OR name='art_open_graph_description' OR name='art_open_graph_site_name' OR name='art_open_graph_images'");
rex_generateAll();
$REX['ADDON']['install'][$myself] = 0;
示例7: rex_get_file_contents
$info = '';
$warning = '';
if ($func == 'setup') {
// REACTIVATE SETUP
$master_file = $REX['INCLUDE_PATH'] . '/master.inc.php';
$cont = rex_get_file_contents($master_file);
$cont = ereg_replace("(REX\\['SETUP'\\].?\\=.?)[^;]*", '\\1true', $cont);
// echo nl2br(htmlspecialchars($cont));
if (rex_put_file_contents($master_file, $cont) !== false) {
$info = $I18N->msg('setup_error1', '<a href="index.php">', '</a>');
} else {
$warning = $I18N->msg('setup_error2');
}
} elseif ($func == 'generate') {
// generate all articles,cats,templates,caches
$info = rex_generateAll();
} elseif ($func == 'updateinfos') {
$neu_startartikel = rex_post('neu_startartikel', 'int');
$neu_notfoundartikel = rex_post('neu_notfoundartikel', 'int');
$neu_defaulttemplateid = rex_post('neu_defaulttemplateid', 'int');
$neu_lang = rex_post('neu_lang', 'string');
// ' darf nichtg escaped werden, da in der Datei der Schlüssel nur zwischen " steht
$neu_error_emailaddress = str_replace("\\'", "'", rex_post('neu_error_emailaddress', 'string'));
$neu_SERVER = str_replace("\\'", "'", rex_post('neu_SERVER', 'string'));
$neu_SERVERNAME = str_replace("\\'", "'", rex_post('neu_SERVERNAME', 'string'));
$neu_modrewrite = rex_post('neu_modrewrite', 'string');
$startArt = OOArticle::getArticleById($neu_startartikel);
$notFoundArt = OOArticle::getArticleById($neu_notfoundartikel);
$REX['LANG'] = $neu_lang;
$master_file = $REX['INCLUDE_PATH'] . '/master.inc.php';
$cont = rex_get_file_contents($master_file);
示例8: rex_a1_import_db
/**
* 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)
{
global $REX, $I18N_IM_EXPORT;
$return = array();
$return['state'] = false;
$return['message'] = '';
$msg = '';
$error = '';
if ($filename == '' || substr($filename, -4, 4) != ".sql") {
$return['message'] = $I18N_IM_EXPORT->msg('no_import_file_chosen_or_wrong_version') . '<br>';
return $return;
}
$conts = rex_get_file_contents($filename);
// Versionsstempel prüfen
// ## Redaxo Database Dump Version x.x
$version = strpos($conts, '## Redaxo Database Dump Version ' . $REX['VERSION']);
if ($version === false) {
$return['message'] = $I18N_IM_EXPORT->msg('no_valid_import_file') . '. [## Redaxo Database Dump Version ' . $REX['VERSION'] . '] is missing';
return $return;
}
// Versionsstempel entfernen
$conts = trim(str_replace('## Redaxo Database Dump Version ' . $REX['VERSION'], '', $conts));
// Prefix prüfen
// ## Prefix xxx_
if (preg_match('/^## Prefix ([a-zA-Z0-9\\_]*)/', $conts, $matches) && isset($matches[1])) {
// prefix entfernen
$prefix = $matches[1];
$conts = trim(str_replace('## Prefix ' . $prefix, '', $conts));
} else {
// Prefix wurde nicht gefunden
$return['message'] = $I18N_IM_EXPORT->msg('no_valid_import_file') . '. [## Prefix ' . $REX['TABLE_PREFIX'] . '] is missing';
return $return;
}
// Prefix im export mit dem der installation angleichen
if ($REX['TABLE_PREFIX'] != $prefix) {
// Hier case-insensitiv ersetzen, damit alle möglich Schreibweisen (TABLE TablE, tAblE,..) ersetzt werden
// Dies ist wichtig, da auch SQLs innerhalb von Ein/Ausgabe der Module vom rex-admin verwendet werden
$conts = preg_replace('/(TABLE `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
$conts = preg_replace('/(INTO `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
$conts = preg_replace('/(EXISTS `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
}
// Inhalt der /generated Ordner komplett leeren
rex_generateAll();
// ----- EXTENSION POINT
$filesize = filesize($filename);
$msg = rex_register_extension_point('A1_BEFORE_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize));
// Datei aufteilen
$lines = explode("\n", $conts);
$add = new rex_sql();
$error = '';
foreach ($lines as $line) {
$line = trim($line, "\r");
// Windows spezifische extras
$line = trim($line, ";");
// mysql 3.x
if ($line == '') {
continue;
}
$add->setQuery($line);
if ($add->hasError()) {
$error .= "\n" . $add->getError();
}
}
if ($error != '') {
$return['message'] = trim($error);
return $return;
}
$msg .= $I18N_IM_EXPORT->msg('database_imported') . '. ' . $I18N_IM_EXPORT->msg('entry_count', count($lines)) . '<br />';
// CLANG Array aktualisieren
unset($REX['CLANG']);
$db = new rex_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->getArray('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
(
//.........这里部分代码省略.........
示例9: rex_deleteCLang
/**
* Löscht eine Clang
*
* @param $id Zu löschende ClangId
*
* @return TRUE bei Erfolg, sonst FALSE
*/
function rex_deleteCLang($clang)
{
global $REX;
if ($clang == 0 || !isset($REX['CLANG'][$clang])) {
return FALSE;
}
$clangName = $REX['CLANG'][$clang];
unset($REX['CLANG'][$clang]);
$del = rex_sql::factory();
$del->setQuery("delete from " . $REX['TABLE_PREFIX'] . "article where clang='{$clang}'");
$del->setQuery("delete from " . $REX['TABLE_PREFIX'] . "article_slice where clang='{$clang}'");
$del->setQuery("delete from " . $REX['TABLE_PREFIX'] . "clang where id='{$clang}'");
// ----- EXTENSION POINT
rex_register_extension_point('CLANG_DELETED', '', array('id' => $clang, 'name' => $clangName));
rex_generateAll();
return TRUE;
}
示例10: rex_addCLang
/**
* Erstellt eine Clang
*
* @param $id Id der Clang
* @param $name Name der Clang
*/
function rex_addCLang($id, $name)
{
global $REX;
$REX['CLANG'][$id] = $name;
$content = "";
foreach ($REX['CLANG'] as $cur => $val) {
$content .= "\$REX['CLANG']['{$cur}'] = \"{$val}\";\n";
}
$file = $REX['INCLUDE_PATH'] . "/clang.inc.php";
rex_replace_dynamic_contents($file, $content);
$add = new rex_sql();
$add->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where clang='0'");
$fields = $add->getFieldnames();
$adda = new rex_sql();
// $adda->debugsql = 1;
for ($i = 0; $i < $add->getRows(); $i++) {
$adda->setTable($REX['TABLE_PREFIX'] . "article");
foreach ($fields as $key => $value) {
if ($value == 'pid') {
echo '';
} else {
if ($value == 'clang') {
$adda->setValue('clang', $id);
} else {
if ($value == 'status') {
$adda->setValue('status', '0');
} else {
$adda->setValue($value, rex_addslashes($add->getValue($value)));
}
}
}
}
$adda->insert();
$add->next();
}
$add = new rex_sql();
$add->setQuery("insert into " . $REX['TABLE_PREFIX'] . "clang set id='{$id}',name='{$name}'");
// ----- EXTENSION POINT
rex_register_extension_point('CLANG_ADDED', '', array('id' => $id, 'name' => $name));
rex_generateAll();
}
示例11: sql
$add = new sql();
foreach ($all as $hier) {
$add->setquery(Trim(str_replace("||||||+N+||||||", "\n", $hier), ";"));
$add->flush();
}
$msg = $I18N_ADDON->msg("database_imported") . ". " . $I18N_ADDON->msg("entry_count", count($all)) . "<br>";
unset($REX[CLANG]);
$gl = new sql();
$gl->setQuery("select * from rex_clang");
for ($i = 0; $i < $gl->getRows(); $i++) {
$id = $gl->getValue("id");
$name = $gl->getValue("name");
$REX[CLANG][$id] = $name;
$gl->next();
}
$msg .= rex_generateAll();
}
if ($impname == "") {
@unlink($file_temp);
}
} else {
$msg = $I18N_ADDON->msg("file_could_not_be_uploaded") . " " . $I18N_ADDON->msg("you_have_no_write_permission_in", "addons/{$page}/files/") . " <br>";
}
}
} elseif ($function == "fileimport") {
// ------------------------------ FUNC FILEIMPORT
if ($_FILES['FORM']['size']['importfile'] < 1 && $impname == "") {
$msg = $I18N_ADDON->msg("no_import_file_chosen") . "<br>";
} else {
if ($impname != "") {
$file_temp = $REX[INCLUDE_PATH] . "/addons/{$page}/files/{$impname}";
示例12: fread
// REACTIVATE SETUP
$h = @fopen($REX[INCLUDE_PATH] . "/master.inc.php", "r");
$cont = fread($h, filesize($REX[INCLUDE_PATH] . "/master.inc.php"));
$cont = ereg_replace("(REX\\[SETUP\\].?\\=.?)[^;]*", "\\1" . "true", $cont);
fclose($h);
// echo nl2br(htmlentities($cont));
$h = @fopen($REX[INCLUDE_PATH] . "/master.inc.php", "w+");
if (fwrite($h, $cont, strlen($cont)) > 0) {
$MSG = $I18N->msg("setup_error1");
} else {
$MSG = $I18N->msg("setup_error2");
}
fclose($h);
} elseif ($func == "generate") {
// generate all articles,cats,templates,caches
$MSG = rex_generateAll();
} elseif ($func == "linkchecker") {
unset($LART);
for ($j = 1; $j < 11; $j++) {
$LC = new sql();
// $LC->debugsql = 1;
$LC->setQuery("select rex_article_slice.article_id,rex_article_slice.id from rex_article_slice\r\n\t\t\t\t\tleft join rex_article on rex_article_slice.link{$j}=rex_article.id\r\n\t\t\t\t\twhere\r\n\t\t\t\t\trex_article_slice.link{$j}>0 and rex_article.id IS NULL");
for ($i = 0; $i < $LC->getRows(); $i++) {
$LART[$LC->getValue("rex_article_slice.article_id")] = 1;
$LSLI[$LC->getValue("rex_article_slice.article_id")] = $LC->getValue("rex_article_slice.id");
$LC->next();
}
}
if (count($LART) > 0) {
reset($LART);
}
示例13: fread
// REACTIVATE SETUP
$h = @fopen($REX['INCLUDE_PATH'] . '/master.inc.php', 'r');
$cont = fread($h, filesize($REX['INCLUDE_PATH'] . '/master.inc.php'));
$cont = ereg_replace("(REX\\['SETUP'\\].?\\=.?)[^;]*", '\\1true', $cont);
fclose($h);
// echo nl2br(htmlspecialchars($cont));
$h = @fopen($REX['INCLUDE_PATH'] . '/master.inc.php', 'w+');
if (fwrite($h, $cont, strlen($cont)) > 0) {
$message = $I18N->msg('setup_error1', '<a href="index.php">', '</a>');
} else {
$message = $I18N->msg('setup_error2');
}
fclose($h);
} elseif ($func == 'generate') {
// generate all articles,cats,templates,caches
$message = rex_generateAll();
} elseif ($func == 'updateinfos') {
$REX['LANG'] = $neu_lang;
$master = $REX['INCLUDE_PATH'] . '/master.inc.php';
$h = fopen($master, 'r');
$cont = fread($h, filesize($master));
$neu_startartikel = rex_post('neu_startartikel', 'int');
$neu_notfoundartikel = rex_post('neu_notfoundartikel', 'int');
$neu_lang = rex_post('neu_lang', 'string');
// ' muss darf nichtg escaped werden, da in der Datei der Schlüssel nur zwischen " steht
$neu_error_emailaddress = str_replace("\\'", "'", rex_post('neu_error_emailaddress', 'string'));
$neu_SERVER = str_replace("\\'", "'", rex_post('neu_SERVER', 'string'));
$neu_SERVERNAME = str_replace("\\'", "'", rex_post('neu_SERVERNAME', 'string'));
$neu_modrewrite = rex_post('neu_modrewrite', 'string');
$cont = ereg_replace("(REX\\['START_ARTICLE_ID'\\].?\\=.?)[^;]*", "\\1" . strtolower($neu_startartikel), $cont);
$cont = ereg_replace("(REX\\['NOTFOUND_ARTICLE_ID'\\].?\\=.?)[^;]*", "\\1" . strtolower($neu_notfoundartikel), $cont);
示例14: rex_a1_import_db
//.........这里部分代码省略.........
$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;
}
示例15: rex_a1_import_db
//.........这里部分代码省略.........
$prefix = $matches[1];
$conts = trim(str_replace('## Prefix ' . $prefix, '', $conts));
} else {
// Prefix wurde nicht gefunden
$return['message'] = $I18N->msg('im_export_no_valid_import_file') . '. [## Prefix ' . $REX['TABLE_PREFIX'] . '] is missing';
return $return;
}
// Charset prüfen
// ## charset xxx_
if (preg_match('/^## charset ([a-zA-Z0-9\\_\\-]*)/', $conts, $matches) && isset($matches[1])) {
// charset entfernen
$charset = $matches[1];
$conts = trim(str_replace('## charset ' . $charset, '', $conts));
if ($I18N->msg('htmlcharset') == 'utf-8' and $charset != 'utf-8') {
$conts = utf8_encode($conts);
} elseif ($I18N->msg('htmlcharset') != $charset) {
$return['message'] = $I18N->msg('im_export_no_valid_charset') . '. ' . $I18N->msg('htmlcharset') . ' != ' . $charset;
return $return;
}
}
// Prefix im export mit dem der installation angleichen
if ($REX['TABLE_PREFIX'] != $prefix) {
// Hier case-insensitiv ersetzen, damit alle möglich Schreibweisen (TABLE TablE, tAblE,..) ersetzt werden
// Dies ist wichtig, da auch SQLs innerhalb von Ein/Ausgabe der Module vom rex-admin verwendet werden
$conts = preg_replace('/(TABLES? `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
$conts = preg_replace('/(INTO `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
$conts = preg_replace('/(EXISTS `?)' . preg_quote($prefix, '/') . '/i', '$1' . $REX['TABLE_PREFIX'], $conts);
}
// ----- EXTENSION POINT
$filesize = filesize($filename);
$msg = rex_register_extension_point('A1_BEFORE_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize));
// require import skript to do some userside-magic
rex_a1_import_skript(str_replace('.sql', '.php', $filename), REX_A1_IMPORT_DB, REX_A1_IMPORT_EVENT_PRE);
if (!function_exists('PMA_splitSqlFile')) {
include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_addons.inc.php';
}
// Datei aufteilen
$lines = array();
PMA_splitSqlFile($lines, $conts, 0);
$sql = rex_sql::factory();
foreach ($lines as $line) {
$line['query'] = trim($line['query']);
if (strpos($line['query'], 'CREATE TABLE') === 0 and !strpos($line['query'], 'DEFAULT CHARSET')) {
$line['query'] .= ' DEFAULT CHARSET=utf8';
}
$sql->setQuery($line['query']);
if ($sql->hasError()) {
$error .= "\n" . $sql->getError();
}
}
if ($error != '') {
$return['message'] = trim($error);
return $return;
}
$msg .= $I18N->msg('im_export_database_imported') . '. ' . $I18N->msg('im_export_entry_count', count($lines)) . '<br />';
unset($lines);
// prüfen, ob eine user tabelle angelegt wurde
$tables = rex_sql::showTables();
$user_table_found = in_array($REX['TABLE_PREFIX'] . 'user', $tables);
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)
) ENGINE=MyISAM DEFAULT CHARSET=utf8';
$db = rex_sql::factory();
$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 == '') {
// ----- EXTENSION POINT
$msg = rex_register_extension_point('A1_AFTER_DB_IMPORT', $msg, array('content' => $conts, 'filename' => $filename, 'filesize' => $filesize));
// require import skript to do some userside-magic
rex_a1_import_skript(str_replace('.sql', '.php', $filename), REX_A1_IMPORT_DB, REX_A1_IMPORT_EVENT_POST);
$msg .= rex_generateAll();
$return['state'] = true;
}
$return['message'] = $msg;
return $return;
}