<html><body><h1>Article Update</h1>
<?php
require_once("root.inc");
require_once($cbDirInclude."db.php");
$artSelect = mysql_query("SELECT * FROM ".TABLE."_article");
while($artRow = mysql_fetch_array($artSelect)) {
/* if (checkIfExist (TABLE."_art_general",array("mediaID"),array($artRow["mediaID"])) >= 0) {
echo "<b>Ignore-Note:" . $artRow['title'] . "</b> wurde bereits frueher nach ".TABLE."_art_general importiert<p>\n";
continue;
}
*/ if($artRow['print'] == 1) {
$options = 1;
} else {
$options = 0;
}
if(ereg("^([0-9]*)$", $artRow[folder]) && $artRow[folder] < 65536) {
if (checkIfExist (TABLE."_art_general",array("mediaID"),array($artRow["mediaID"])) >= 0) {
echo "<b>Ignore-Note:" . $artRow['title'] . "</b> wurde bereits frueher nach ".TABLE."_art_general importiert (checked via mediaID '".$artRow["mediaID"]."'aus ".TABLE."_article)<p>\n";
continue;
}
if (mysql_query("INSERT INTO ".TABLE."_art_general (folderID, userID, mediaID, iconID, title, datetime, publishFrom, publishTo, stage, parse, options, languages, template) VALUES ('".$artRow['folder']."', '".$artRow['userid']."', '".$artRow['mediaID']."', '".$artRow['iconID']."', '".$artRow['title']."', '".$artRow['datum']."', '".$artRow['publishfrom']."', '".$artRow['publishto']."', '".$artRow['stage']."', '".$artRow['parse']."', '$options', '1', '".$artRow['template']."')")) {
echo "<b>" . $artRow['title'] . "</b> wurde nach ".TABLE."_art_general importiert<br>\n";
}else{
echo "<b>Fehler: " . $artRow['title'] . "</b> nicht nach ".TABLE."_art_general importiert<br>\n";
}
$thisID = mysql_insert_id();
mysql_query("UPDATE ".TABLE."_art_general SET rootID = '$thisID' WHERE ide = '$thisID'");
$meta = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_metainfo WHERE x_id = '".$artRow[ide]."'"));
$sql = "INSERT INTO ".TABLE."_art_content (ide, language, title, intro, content, description, keywords) ";
$sql .= " VALUES ('$thisID', '1', '".addslashes($artRow['title'])."', '".addslashes($artRow['intro'])."', '".addslashes($artRow['content'])."', '".addslashes($meta['x_description'])."', '".addslashes($meta['x_keywords'])."')";
if (mysql_query($sql)) {
echo "<b>" . $artRow['title'] . "</b> wurde nach ".TABLE."_art_content importiert<p>\n";
}else{
echo "<b>Fehler: " . $artRow['title'] . "</b> nicht nach ".TABLE."_art_content importiert<p>\n";
}
$old_new_array[$artRow[ide]] = $thisID;
} else {
echo "<font color='red'>Folder-Fehler</font><b>: " . $artRow['title'] . "</b> konnte komplett nicht fuer '".$artRow[folder]."' importiert werden (falsche Rubrik-ID).<p>\n";
}
} // while
$commentQuery = mysql_query("SELECT * FROM ".TABLE."_comment WHERE type = 'article'");
while($commentRow = mysql_fetch_array($commentQuery)) {
if($old_new_array[$commentRow[entryID]] != "") {
mysql_query("INSERT INTO ".TABLE."_comment (type, entryID, author, title, text, datetime, homepage, email) VALUES ('article2', '".$old_new_array[$commentRow[entryID]]."', '".$commentRow[author]."', '".$commentRow[title]."', '".$commentRow[text]."', '".$commentRow[datetime]."', '".$commentRow[homepage]."', '".$commentRow[email]."')");
}
}
/**
* @return int ( 0 = Error, 1 = Datensatz-Identifier existiert bereits, -1 Datensatz existiert nicht
* @param string $tname Tabellenname
* @param array of string $tIndexFields Identifierer-Felder in der DB-Tabelle
* @param array of mixed $tValues die Werte nach denen in $tIndexFields gesucht werden soll
* @desc Enter description here...
*/
function checkIfExist($tname,$tIndexFields,$tValues) {
if (! is_array($tIndexFields)) return 0;
if (! is_array($tValues) || ( count($tIndexFields) != count($tValues)) ) return 0;
$sql = "select " . implode(",", $tIndexFields) . " from ".$tname." where ";
for ($i=0; $i<count($tIndexFields); $i++) {
$sql .= $tIndexFields[$i] . "='" . $tValues[$i] . "' and ";
}
$sql = substr($sql, 0 , count($sql)-5);
if ( $res = mysql_query($sql)) {
if ($row = mysql_fetch_array($res)) {
if ( isset($row[$tIndexFields[0]])) {
return 1;
}else {
return -1;
}
}else {
return -1;
}
}else {
return 0;
}
}
?>
</BODY></HTML>