Index: /trunk/admin/cat_modify.php
===================================================================
--- /trunk/admin/cat_modify.php	(revision 4384)
+++ /trunk/admin/cat_modify.php	(revision 4385)
@@ -243,7 +243,7 @@
 
     'CAT_STATUS'        => $category['status'],
-    'CAT_VISIBLE'       => $category['visible'],
-    'CAT_COMMENTABLE'   => $category['commentable'],
-    'CAT_UPLOADABLE'    => $category['uploadable'],
+    'CAT_VISIBLE'       => boolean_to_string($category['visible']),
+    'CAT_COMMENTABLE'   => boolean_to_string($category['commentable']),
+    'CAT_UPLOADABLE'    => boolean_to_string($category['uploadable']),
 
     'IMG_ORDER_DEFAULT'  => empty($category['image_order']) ?
Index: /trunk/admin/include/c13y_internal.class.php
===================================================================
--- /trunk/admin/include/c13y_internal.class.php	(revision 4384)
+++ /trunk/admin/include/c13y_internal.class.php	(revision 4385)
@@ -39,4 +39,6 @@
   function c13y_version($c13y)
   {
+    global $conf;
+
     $check_list = array();
 
@@ -44,5 +46,8 @@
 
     $db_version = pwg_get_db_version();
-    $check_list[] = array('type' => 'MySQL', 'current' => $db_version, 'required' => REQUIRED_MYSQL_VERSION);
+    $check_list[] = array('type' => $conf['dblayer'],
+			  'current' => $db_version, 
+			  'required' => constant('REQUIRED_'.strtoupper($conf['dblayer']).'_VERSION')
+			  );
 
     foreach ($check_list as $elem)
Index: /trunk/admin/include/functions.php
===================================================================
--- /trunk/admin/include/functions.php	(revision 4384)
+++ /trunk/admin/include/functions.php	(revision 4385)
@@ -417,5 +417,5 @@
 {
   $query = '
-SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat, uppercats, rank, global_rank
+SELECT id, id_uppercat, uppercats, rank, global_rank
   FROM '.CATEGORIES_TABLE.'
   ORDER BY id_uppercat,rank,name';
Index: /trunk/admin/include/plugins.class.php
===================================================================
--- /trunk/admin/include/plugins.class.php	(revision 4384)
+++ /trunk/admin/include/plugins.class.php	(revision 4385)
@@ -81,6 +81,6 @@
         {
           $query = '
-INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("'
-. $plugin_id . '","' . $this->fs_plugins[$plugin_id]['version'] . '"
+INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES (\''
+. $plugin_id . '\',\'' . $this->fs_plugins[$plugin_id]['version'] . '\'
 )';
           pwg_query($query);
@@ -111,6 +111,6 @@
           $query = '
 UPDATE ' . PLUGINS_TABLE . '
-SET state="active", version="'.$this->fs_plugins[$plugin_id]['version'].'"
-WHERE id="' . $plugin_id . '"';
+SET state=\'active\', version=\''.$this->fs_plugins[$plugin_id]['version'].'\'
+WHERE id=\'' . $plugin_id . '\'';
           pwg_query($query);
         }
@@ -127,5 +127,5 @@
         }
         $query = '
-UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE id="' . $plugin_id . '"';
+UPDATE ' . PLUGINS_TABLE . ' SET state=\'inactive\' WHERE id=\'' . $plugin_id . '\'';
         pwg_query($query);
         if (file_exists($file_to_include))
@@ -145,5 +145,5 @@
         }
         $query = '
-DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
+DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
         pwg_query($query);
         if (file_exists($file_to_include))
Index: /trunk/admin/intro.php
===================================================================
--- /trunk/admin/intro.php	(revision 4384)
+++ /trunk/admin/intro.php	(revision 4385)
@@ -197,5 +197,5 @@
     'OS' => PHP_OS,
     'PHP_VERSION' => phpversion(),
-    'DB_ENGINE' => 'MySQL',
+    'DB_ENGINE' => $conf['dblayer'],
     'DB_VERSION' => $db_version,
     'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements),
Index: /trunk/comments.php
===================================================================
--- /trunk/comments.php	(revision 4384)
+++ /trunk/comments.php	(revision 4385)
@@ -322,5 +322,6 @@
   WHERE '.implode('
     AND ', $page['where_clauses']).'
-  GROUP BY comment_id
+  GROUP BY comment_id, com.image_id, ic.category_id, com.author, 
+           com.author_id, com.date, com.content, com.validated
   ORDER BY '.$page['sort_by'].' '.$page['sort_order'];
 if ('all' != $page['items_number'])
Index: /trunk/include/common.inc.php
===================================================================
--- /trunk/include/common.inc.php	(revision 4384)
+++ /trunk/include/common.inc.php	(revision 4385)
@@ -93,5 +93,5 @@
 include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
 @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
-include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
+include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
 
 if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
Index: /trunk/include/dblayer/functions_mysql.inc.php
===================================================================
--- /trunk/include/dblayer/functions_mysql.inc.php	(revision 4384)
+++ /trunk/include/dblayer/functions_mysql.inc.php	(revision 4385)
@@ -539,4 +539,77 @@
 }
 
+/**
+ *
+ * interval and date functions 
+ *
+ */
+
+
+function pwg_db_get_recent_period_expression($period, $date='CURRENT_DATE')
+{
+  if ($date!='CURRENT_DATE')
+  {
+    $date = '\''.$date.'\'';
+  }
+
+  return 'SUBDATE('.$date.',INTERVAL '.$period.' DAY)';
+}
+
+function pwg_db_get_recent_period($period, $date='CURRENT_DATE')
+{
+  $query = '
+SELECT '.pwg_db_get_recent_period_expression($period);
+  list($d) = pwg_db_fetch_row(pwg_query($query));
+
+  return $d;
+}
+
+function pwg_db_get_date_YYYYMM($date)
+{
+  return 'DATE_FORMAT('.$date.', \'%Y%m\')';
+}
+
+function pwg_db_get_date_MMDD($date)
+{
+  return 'DATE_FORMAT('.$date.', \'%m%d\')';
+}
+
+function pwg_db_get_year($date)
+{
+  return 'YEAR('.$date.')';
+}
+
+function pwg_db_get_month($date)
+{
+  return 'MONTH('.$date.')';
+}
+
+function pwg_db_get_week($date, $mode=null)
+{
+  if ($mode)
+  {
+    return 'WEEK('.$date.', '.$mode.')';
+  }
+  else
+  {
+    return 'WEEK('.$date.')';
+  }
+}
+
+function pwg_db_get_dayofmonth($date)
+{
+  return 'DAYOFMONTH('.$date.')';
+}
+
+function pwg_db_get_dayofweek($date)
+{
+  return 'DAYOFWEEK('.$date.')';
+}
+
+function pwg_db_get_weekday($date)
+{
+  return 'WEEKDAY('.$date.')';
+}
+
 // my_error returns (or send to standard output) the message concerning the
 // error occured for the last mysql query.
Index: /trunk/include/functions_calendar.inc.php
===================================================================
--- /trunk/include/functions_calendar.inc.php	(revision 4384)
+++ /trunk/include/functions_calendar.inc.php	(revision 4385)
@@ -259,5 +259,5 @@
   if ($must_show_list)
   {
-    $query = 'SELECT DISTINCT(id)';
+    $query = 'SELECT id';
     $query .= $calendar->inner_sql.'
   '.$calendar->get_date_where();
@@ -285,8 +285,7 @@
   '.$order_by;
     }
-    $page['items']              = array_from_query($query, 'id');
+    $page['items'] = array_from_query($query, 'id');
   }
   pwg_debug('end initialize_calendar');
 }
-
 ?>
Index: /trunk/include/functions_user.inc.php
===================================================================
--- /trunk/include/functions_user.inc.php	(revision 4384)
+++ /trunk/include/functions_user.inc.php	(revision 4385)
@@ -643,5 +643,5 @@
 
   $query.= '
-  GROUP BY c.id';
+  GROUP BY c.id, c.global_rank';
 
   $result = pwg_query($query);
Index: /trunk/include/section_init.inc.php
===================================================================
--- /trunk/include/section_init.inc.php	(revision 4384)
+++ /trunk/include/section_init.inc.php	(revision 4385)
@@ -123,4 +123,5 @@
 
 $page = array_merge( $page, parse_section_url( $tokens, $next_token) );
+
 if ( !isset($page['section']) )
 {
@@ -157,8 +158,5 @@
 }
 
-
 $page = array_merge( $page, parse_well_known_params_url( $tokens, $next_token) );
-
-
 if ( script_basename()=='picture' and 'categories'==$page['section'] and
       !isset($page['category']) and !isset($page['chronology_field']) )
Index: /trunk/install.php
===================================================================
--- /trunk/install.php	(revision 4384)
+++ /trunk/install.php	(revision 4385)
@@ -293,4 +293,5 @@
     $step = 2;
     $file_content = '<?php
+$conf[\'dblayer\'] = \'mysql\';
 $conf[\'db_base\'] = \''.$dbname.'\';
 $conf[\'db_user\'] = \''.$dbuser.'\';
Index: /trunk/random.php
===================================================================
--- /trunk/random.php	(revision 4384)
+++ /trunk/random.php	(revision 4385)
@@ -39,5 +39,5 @@
 
 $query = '
-SELECT DISTINCT(id)
+SELECT id
   FROM '.IMAGES_TABLE.'
     INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
Index: /trunk/upgrade.php
===================================================================
--- /trunk/upgrade.php	(revision 4384)
+++ /trunk/upgrade.php	(revision 4385)
@@ -44,5 +44,5 @@
 include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
 @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
-include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
+include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
 
 prepare_conf_upgrade();
Index: /trunk/upgrade_feed.php
===================================================================
--- /trunk/upgrade_feed.php	(revision 4384)
+++ /trunk/upgrade_feed.php	(revision 4385)
@@ -36,5 +36,5 @@
 include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
 @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
-include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
+include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
 
 // +-----------------------------------------------------------------------+
