b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: install ] [ index: install ] [ all elements ]

Source for file _functions_install.php

Documentation is available at _functions_install.php

  1. <?php
  2. /**
  3.  * This file implements support functions for the installer
  4.  *
  5.  * b2evolution - {@link http://b2evolution.net/}
  6.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  7.  * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  8.  *
  9.  * @package install
  10.  */
  11. if!defined('DB_USER') ) die'Please, do not access this page directly.' );
  12.  
  13. /**
  14.  * check_db_version(-)
  15.  *
  16.  * Note: version number 8000 once meant 0.8.00.0, but I decided to switch to sequential
  17.  * increments of 10 (in case we ever need to introduce intermediate versions for intermediate
  18.  * bug fixes...)
  19.  */
  20. function check_db_version()
  21. {
  22.     global $DB$old_db_version$new_db_version$tablesettings;
  23.  
  24.     echo '<p>'.T_('Checking DB schema version...').' ';
  25.     $DB->query"SELECT * FROM $tablesettings LIMIT 1);
  26.     
  27.     if$DB->get_col_info('name'0== 'set_name' )
  28.     // we have new table format
  29.         $old_db_version $DB->get_var"SELECT set_value FROM $tablesettings WHERE set_name = 'db_version');
  30.     }
  31.     else
  32.     {
  33.         $old_db_version $DB->get_var"SELECT db_version FROM $tablesettings);
  34.     }
  35.     
  36.     if$old_db_version == NULL dieT_('NOT FOUND! This is not a b2evolution database.') );
  37.     
  38.     echo $old_db_version' : ';
  39.     
  40.     if$old_db_version 8000 dieT_('This version is too old!') );
  41.     if$old_db_version $new_db_version dieT_('This version is too recent! We cannot downgrade to it!') );
  42.     echo "OK.<br />\n";
  43. }
  44.  
  45.  
  46. /**
  47.  * Clean up extra quotes in posts
  48.  */
  49. {
  50.   global $DB;
  51.  
  52.     echo "Checking for extra quote escaping in posts... ";
  53.     $query "SELECT ID, post_title, post_content
  54.                             FROM T_posts
  55.                          WHERE post_title LIKE '%\\\\\\\\\'%'
  56.                                  OR post_title LIKE '%\\\\\\\\\"%'
  57.                                  OR post_content LIKE '%\\\\\\\\\'%'
  58.                                  OR post_content LIKE '%\\\\\\\\\"%' ";
  59.     /* FP: the above looks overkill, but mySQL is really full of surprises...
  60.                     tested on 4.0.14-nt */
  61.     // echo $query;
  62.     $rows $DB->get_results$queryARRAY_A );
  63.     if$DB->num_rows )
  64.     {
  65.         echo 'Updating '.$DB->num_rows.' posts... ';
  66.         foreach$rows as $row )
  67.         {
  68.             // echo '<br />'.$row['post_title'];
  69.             $query "UPDATE T_posts
  70.                                 SET post_title = ".$DB->quotestripslashes$row['post_title') ).",
  71.                                         post_content = ".$DB->quotestripslashes$row['post_content') )."
  72.                                 WHERE ID = ".$row['ID'];
  73.             // echo '<br />'.$query;
  74.             $DB->query$query );
  75.         }
  76.     }
  77.     echo "OK.<br />\n";
  78.  
  79. }
  80.  
  81. /**
  82.  * Clean up extra quotes in comments
  83.  */
  84. {
  85.   global $DB;
  86.  
  87.     echo "Checking for extra quote escaping in comments... ";
  88.     $query "SELECT comment_ID, comment_content
  89.                             FROM T_comments
  90.                          WHERE comment_content LIKE '%\\\\\\\\\'%'
  91.                                  OR comment_content LIKE '%\\\\\\\\\"%' ";
  92.     /* FP: the above looks overkill, but mySQL is really full of surprises...
  93.                     tested on 4.0.14-nt */
  94.     // echo $query;
  95.     $rows $DB->get_results$queryARRAY_A );
  96.     if$DB->num_rows )
  97.     {
  98.         echo 'Updating '.$DB->num_rows.' comments... ';
  99.         foreach$rows as $row )
  100.         {
  101.             $query "UPDATE T_comments
  102.                                 SET comment_content = ".$DB->quotestripslashes$row['comment_content') )."
  103.                                 WHERE comment_ID = ".$row['comment_ID'];
  104.             // echo '<br />'.$query;
  105.             $DB->query$query );
  106.         }
  107.     }
  108.     echo "OK.<br />\n";
  109.  
  110. }
  111.  
  112.  
  113. ?>

Documentation generated on Tue, 20 May 2008 01:54:56 +0200 by phpDocumentor 1.4.2