<?php
  $Updates = array(
    // version
    );
  $AmountUpdates = count($Updates);
  $AmountErrors = 0;
  for ($i=0; $i<$AmountUpdates; $i++)
  {
    $sql = $Updates[$i];
    $resultat = mysql_db_query($DB_NAME, $sql);
    if (!$resultat)
    {
      echo '<span style="font-size:0.8em" class="ErrorMessage">ERROR: update.sql.php: Database update ['.$i.'] failed: '.$sql.'</span><br/>';
      $AmountErrors++;
    }
  }
  // Delete files
    if (is_file("update.sql.php.old")) unlink("update.sql.php.old");

  if ($AmountErrors==0)
  {
    // Rewrite Feeds
      include_once ('news/functions.php');
      writeAllFeeds();
    // Clear Cache
      clearCache();
    echo '<span style="font-size:0.8em" class="ErrorMessage">Database updated sucessfully!</span><br />';
    // Rename update script
      if (!rename("update.sql.php", "update.sql.php.old"))
        echo '<span style="font-size:0.8em" class="ErrorMessage">
                ERROR: Wrong permissions ('.substr(decoct(fileperms("update.sql.php")),3).'):
                Please rename update.sql.php into update.sql.php.old manually.</span><br />';
  }
?>