diff options
author | nikrou <nikrou@piwigo.org> | 2009-11-29 12:35:19 +0000 |
---|---|---|
committer | nikrou <nikrou@piwigo.org> | 2009-11-29 12:35:19 +0000 |
commit | c96097529e49943eddba78d70e23e38c0eac494d (patch) | |
tree | 5925d92bcad222348680a3ea6253d5743dbe38a4 | |
parent | 13ea9d50e35d9dd8cf7235a39d97a344e6091ea0 (diff) |
Feature_1255 :
- single quotes in queries
- start using $conf['dblayer']
git-svn-id: http://piwigo.org/svn/trunk@4385 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/cat_modify.php | 6 | ||||
-rw-r--r-- | admin/include/c13y_internal.class.php | 7 | ||||
-rw-r--r-- | admin/include/functions.php | 2 | ||||
-rw-r--r-- | admin/include/plugins.class.php | 12 | ||||
-rw-r--r-- | admin/intro.php | 2 | ||||
-rw-r--r-- | comments.php | 3 | ||||
-rw-r--r-- | include/common.inc.php | 2 | ||||
-rw-r--r-- | include/dblayer/functions_mysql.inc.php | 73 | ||||
-rw-r--r-- | include/functions_calendar.inc.php | 5 | ||||
-rw-r--r-- | include/functions_user.inc.php | 2 | ||||
-rw-r--r-- | include/section_init.inc.php | 4 | ||||
-rw-r--r-- | install.php | 1 | ||||
-rw-r--r-- | random.php | 2 | ||||
-rw-r--r-- | upgrade.php | 2 | ||||
-rw-r--r-- | upgrade_feed.php | 2 |
15 files changed, 101 insertions, 24 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 5dc39954c..17b23ce6c 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -242,9 +242,9 @@ $template->assign( 'status_values' => array('public','private'), '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']) ? 'checked="checked"' : '', diff --git a/admin/include/c13y_internal.class.php b/admin/include/c13y_internal.class.php index 1fe83c0df..7b20e24db 100644 --- a/admin/include/c13y_internal.class.php +++ b/admin/include/c13y_internal.class.php @@ -38,12 +38,17 @@ class c13y_internal */ function c13y_version($c13y) { + global $conf; + $check_list = array(); $check_list[] = array('type' => 'PHP', 'current' => phpversion(), 'required' => REQUIRED_PHP_VERSION); $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) { diff --git a/admin/include/functions.php b/admin/include/functions.php index b0d5da945..e503e17a8 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -416,7 +416,7 @@ function get_fs_directories($path, $recursive = true) function update_global_rank() { $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'; diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php index 9c5b238df..fb9db0c88 100644 --- a/admin/include/plugins.class.php +++ b/admin/include/plugins.class.php @@ -80,8 +80,8 @@ class plugins if (empty($errors)) { $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); } @@ -110,8 +110,8 @@ INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("' { $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); } break; @@ -126,7 +126,7 @@ WHERE id="' . $plugin_id . '"'; die('invalid current state ' . $crt_db_plugin['state']); } $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)) { @@ -144,7 +144,7 @@ UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE id="' . $plugin_id . '"' die ('CANNOT UNINSTALL - NOT INSTALLED'); } $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)) { diff --git a/admin/intro.php b/admin/intro.php index c081e8918..2d2310da7 100644 --- a/admin/intro.php +++ b/admin/intro.php @@ -196,7 +196,7 @@ $template->assign( 'PWG_VERSION' => PHPWG_VERSION, '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), 'DB_CATEGORIES' => diff --git a/comments.php b/comments.php index 3d8c9cccf..c020a84ce 100644 --- a/comments.php +++ b/comments.php @@ -321,7 +321,8 @@ SELECT com.id AS comment_id ON u.'.$conf['user_fields']['id'].' = com.author_id 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']) { diff --git a/include/common.inc.php b/include/common.inc.php index 9fdc014d5..1ec1d38c7 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -92,7 +92,7 @@ foreach( array( 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'])) { diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php index f21ace0f3..e47119535 100644 --- a/include/dblayer/functions_mysql.inc.php +++ b/include/dblayer/functions_mysql.inc.php @@ -538,6 +538,79 @@ function boolean_to_string($var) } } +/** + * + * 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. function my_error($header, $die) diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index 74c366f8c..362c4cf14 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -258,7 +258,7 @@ WHERE id IN (' . implode(',',$page['items']) .')'; if ($must_show_list) { - $query = 'SELECT DISTINCT(id)'; + $query = 'SELECT id'; $query .= $calendar->inner_sql.' '.$calendar->get_date_where(); if ( isset($page['super_order_by']) ) @@ -284,9 +284,8 @@ WHERE id IN (' . implode(',',$page['items']) .')'; $query .= ' '.$order_by; } - $page['items'] = array_from_query($query, 'id'); + $page['items'] = array_from_query($query, 'id'); } pwg_debug('end initialize_calendar'); } - ?>
\ No newline at end of file diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 2a2ed79e9..850fad110 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -642,7 +642,7 @@ FROM '.CATEGORIES_TABLE.' as c } $query.= ' - GROUP BY c.id'; + GROUP BY c.id, c.global_rank'; $result = pwg_query($query); diff --git a/include/section_init.inc.php b/include/section_init.inc.php index 5cc0fbb35..c6576f1ea 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -122,6 +122,7 @@ if (script_basename() == 'picture') // basename without file extention } $page = array_merge( $page, parse_section_url( $tokens, $next_token) ); + if ( !isset($page['section']) ) { $page['section'] = 'categories'; @@ -156,10 +157,7 @@ if ( !isset($page['section']) ) } } - $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']) ) { //access a picture only by id, file or id-file without given section diff --git a/install.php b/install.php index ee824715f..727d1f954 100644 --- a/install.php +++ b/install.php @@ -292,6 +292,7 @@ if ( isset( $_POST['install'] )) { $step = 2; $file_content = '<?php +$conf[\'dblayer\'] = \'mysql\'; $conf[\'db_base\'] = \''.$dbname.'\'; $conf[\'db_user\'] = \''.$dbuser.'\'; $conf[\'db_password\'] = \''.$dbpasswd.'\'; diff --git a/random.php b/random.php index f1adfada5..47d3506a4 100644 --- a/random.php +++ b/random.php @@ -38,7 +38,7 @@ check_status(ACCESS_GUEST); // +-----------------------------------------------------------------------+ $query = ' -SELECT DISTINCT(id) +SELECT id FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id '.get_sql_condition_FandF diff --git a/upgrade.php b/upgrade.php index 817f8db93..0a5cf704d 100644 --- a/upgrade.php +++ b/upgrade.php @@ -43,7 +43,7 @@ include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php'); include(PHPWG_ROOT_PATH.'include/config_database.inc.php'); 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(); diff --git a/upgrade_feed.php b/upgrade_feed.php index ccb91e681..e78c676c4 100644 --- a/upgrade_feed.php +++ b/upgrade_feed.php @@ -35,7 +35,7 @@ include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php'); include(PHPWG_ROOT_PATH.'include/config_database.inc.php'); 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'); // +-----------------------------------------------------------------------+ // | Check Access and exit when it is not ok | |