From 4488965f91209ea433f69e60ac3bee508ab34e06 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 3 Jun 2011 18:12:18 +1000 Subject: [PATCH] news --- kusabax.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kusabax.php b/kusabax.php index 983bf21e..b2f6322f 100755 --- a/kusabax.php +++ b/kusabax.php @@ -246,6 +246,25 @@ $query->execute() or $log[] = 'Error: ' . db_error($query); } + // News + $k_query = $kusabax->query('SELECT * FROM `' . $kusabaxc['db']['prefix'] . 'front` WHERE `page` = 0'); + while($news = $k_query->fetch()) { + // Check if already exists + $query = prepare("SELECT 1 FROM `news` WHERE `body` = :body AND `time` = :time"); + $query->bindValue(':time', $news['timestamp'], PDO::PARAM_INT); + $query->bindValue(':body', $news['message'], PDO::PARAM_STR); + $query->execute() or error(db_error($query)); + if($query->fetch()) + continue; + + $query = prepare("INSERT INTO `news` VALUES (NULL, :name, :time, :subject, :body)"); + $query->bindValue(':name', $news['poster'], PDO::PARAM_STR); + $query->bindValue(':time', $news['timestamp'], PDO::PARAM_INT); + $query->bindValue(':subject', $news['subject'], PDO::PARAM_STR); + $query->bindValue(':body', $news['message'], PDO::PARAM_STR); + $query->execute() or $log[] = 'Error: ' . db_error($query); + } + $page['body'] = '

Migrating…

'; foreach($log as &$l) { $page['body'] .= $l . '
';