aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2009-11-20 14:17:04 +0000
committernikrou <nikrou@piwigo.org>2009-11-20 14:17:04 +0000
commit924dd262ec3778277cf1efedee92fa5dd4fb2d32 (patch)
tree05176413aa5b4762dd72477099644c732389f971 /admin
parentc020cd0d7cb7710a6ffe04fc8b6d6ccfecb2c466 (diff)
Feature 1244 resolved
Replace all mysql functions in core code by ones independant of database engine Fix small php code synxtax : hash must be accessed with [ ] and not { }. git-svn-id: http://piwigo.org/svn/trunk@4325 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/cat_list.php2
-rw-r--r--admin/cat_modify.php12
-rw-r--r--admin/cat_perm.php10
-rw-r--r--admin/comments.php2
-rw-r--r--admin/configuration.php2
-rw-r--r--admin/element_set.php2
-rw-r--r--admin/element_set_global.php6
-rw-r--r--admin/element_set_ranks.php4
-rw-r--r--admin/element_set_unit.php4
-rw-r--r--admin/group_list.php12
-rw-r--r--admin/group_perm.php6
-rw-r--r--admin/history.php14
-rw-r--r--admin/include/c13y_internal.class.php6
-rw-r--r--admin/include/functions.php308
-rw-r--r--admin/include/functions_history.inc.php2
-rw-r--r--admin/include/functions_metadata.php4
-rw-r--r--admin/include/functions_notification_by_mail.inc.php4
-rw-r--r--admin/include/functions_permalinks.php8
-rw-r--r--admin/include/functions_upgrade.php6
-rw-r--r--admin/intro.php46
-rw-r--r--admin/notification_by_mail.php8
-rw-r--r--admin/permalinks.php6
-rw-r--r--admin/picture_modify.php8
-rw-r--r--admin/rating.php10
-rw-r--r--admin/site_manager.php6
-rw-r--r--admin/site_update.php58
-rw-r--r--admin/stats.php6
-rw-r--r--admin/tags.php4
-rw-r--r--admin/template/goto/intro.tpl2
-rw-r--r--admin/thumbnail.php2
-rw-r--r--admin/upload.php4
-rw-r--r--admin/user_list.php8
-rw-r--r--admin/user_perm.php10
33 files changed, 163 insertions, 429 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php
index 3a9a1fc46..5b7733df2 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -119,7 +119,7 @@ SELECT id, name
(!isset($_GET['parent_id']) ? 'IS NULL' : '= '.$_GET['parent_id']).'
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$categories[ $row['id'] ] = strtolower($row['name']);
}
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 1ca146aa6..06a001253 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -193,7 +193,7 @@ SELECT *
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$_GET['cat_id'].'
;';
-$category = mysql_fetch_assoc( pwg_query( $query ) );
+$category = pwg_db_fetch_assoc( pwg_query( $query ) );
// nullable fields
foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
{
@@ -210,7 +210,7 @@ $query = 'SELECT DISTINCT category_id
WHERE category_id = '.$_GET['cat_id'].'
LIMIT 1';
$result = pwg_query($query);
-$category['has_images'] = mysql_num_rows($result)>0 ? true : false;
+$category['has_images'] = pwg_db_num_rows($result)>0 ? true : false;
// Navigation path
$navigation = get_cat_display_name_cache(
@@ -373,7 +373,7 @@ SELECT id,tn_ext,path
FROM '.IMAGES_TABLE.'
WHERE id = '.$category['representative_picture_id'].'
;';
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
$src = get_thumbnail_url($row);
$url = get_root_url().'admin.php?page=picture_modify';
$url.= '&amp;image_id='.$category['representative_picture_id'];
@@ -461,9 +461,9 @@ SELECT id, file, path, tn_ext
;';
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
- $element = mysql_fetch_assoc($result);
+ $element = pwg_db_fetch_assoc($result);
$img_url = '<a href="'.
make_picture_url(array(
@@ -511,7 +511,7 @@ SELECT
FROM '.GROUPS_TABLE.'
WHERE id = '.$_POST['group'].'
;';
- list($group_name) = mysql_fetch_row(pwg_query($query));
+ list($group_name) = pwg_db_fetch_row(pwg_query($query));
array_push(
$page['infos'],
diff --git a/admin/cat_perm.php b/admin/cat_perm.php
index 0107d6cc7..91711ddf1 100644
--- a/admin/cat_perm.php
+++ b/admin/cat_perm.php
@@ -45,7 +45,7 @@ SELECT status
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$_GET['cat'].'
;';
- list($status) = mysql_fetch_row(pwg_query($query));
+ list($status) = pwg_db_fetch_row(pwg_query($query));
if ('private' == $status)
{
@@ -62,7 +62,7 @@ SELECT id
LIMIT 0,1
;';
- list($page['cat']) = mysql_fetch_row(pwg_query($query));
+ list($page['cat']) = pwg_db_fetch_row(pwg_query($query));
}
// +-----------------------------------------------------------------------+
@@ -110,7 +110,7 @@ SELECT group_id, cat_id
AND group_id IN ('.implode(',', $_POST['grant_groups']).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($granteds[$row['cat_id']], $row['group_id']);
}
@@ -169,7 +169,7 @@ SELECT user_id, cat_id
AND user_id IN ('.implode(',', $_POST['grant_users']).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($granteds[$row['cat_id']], $row['user_id']);
}
@@ -274,7 +274,7 @@ SELECT user_id, group_id
WHERE group_id IN ('.implode(',', $group_granted_ids).')
';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
if (!isset($granted_groups[$row['group_id']]))
{
diff --git a/admin/comments.php b/admin/comments.php
index d4fc89a66..84006088e 100644
--- a/admin/comments.php
+++ b/admin/comments.php
@@ -145,7 +145,7 @@ $conf['user_fields']['username'].' AS username, c.content, i.path, i.tn_ext
ORDER BY c.date DESC
;';
$result = pwg_query($query);
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$thumb = get_thumbnail_url(
array(
diff --git a/admin/configuration.php b/admin/configuration.php
index d193f9f8d..9b4a7f0c2 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -138,7 +138,7 @@ if (isset($_POST['submit']) and !is_adviser())
{
//echo '<pre>'; print_r($_POST); echo '</pre>';
$result = pwg_query('SELECT param FROM '.CONFIG_TABLE);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
if (isset($_POST[$row['param']]))
{
diff --git a/admin/element_set.php b/admin/element_set.php
index 9cbdb7eec..1c84854d5 100644
--- a/admin/element_set.php
+++ b/admin/element_set.php
@@ -192,7 +192,7 @@ elseif ('recent'== $_GET['cat'])
$page['title'] = l10n('recent_pics_cat');
$query = 'SELECT MAX(date_available) AS date
FROM '.IMAGES_TABLE;
- if ($row = mysql_fetch_assoc( pwg_query($query) ) )
+ if ($row = pwg_db_fetch_assoc( pwg_query($query) ) )
{
$query = 'SELECT id
FROM '.IMAGES_TABLE.'
diff --git a/admin/element_set_global.php b/admin/element_set_global.php
index 20a4c658b..3676309e5 100644
--- a/admin/element_set_global.php
+++ b/admin/element_set_global.php
@@ -245,7 +245,7 @@ SELECT id
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$data = array();
$data['id'] = $row['id'];
@@ -337,7 +337,7 @@ SELECT
WHERE id IN ('.implode(',', $page['cat_elements_id']).')
AND storage_category_id IS NULL
;';
- list($counter) = mysql_fetch_row(pwg_query($query));
+ list($counter) = pwg_db_fetch_row(pwg_query($query));
if ($counter > 0)
{
@@ -481,7 +481,7 @@ SELECT id,path,tn_ext,file,filesize,level
// template thumbnail initialization
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$src = get_thumbnail_url($row);
diff --git a/admin/element_set_ranks.php b/admin/element_set_ranks.php
index 1bc0ab57f..57a1f6e0b 100644
--- a/admin/element_set_ranks.php
+++ b/admin/element_set_ranks.php
@@ -115,7 +115,7 @@ SELECT uppercats
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$page['category_id'].'
;';
-$category = mysql_fetch_assoc(pwg_query($query));
+$category = pwg_db_fetch_assoc(pwg_query($query));
// Navigation path
$navigation = get_cat_display_name_cache(
@@ -150,7 +150,7 @@ $result = pwg_query($query);
// template thumbnail initialization
$current_rank = 1;
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$src = get_thumbnail_url($row);
diff --git a/admin/element_set_unit.php b/admin/element_set_unit.php
index 7bc0e54b0..65206aba4 100644
--- a/admin/element_set_unit.php
+++ b/admin/element_set_unit.php
@@ -56,7 +56,7 @@ SELECT id, date_creation
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$data = array();
@@ -200,7 +200,7 @@ SELECT id,path,tn_ext,name,date_creation,comment,author,file
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
// echo '<pre>'; print_r($row); echo '</pre>';
array_push($element_ids, $row['id']);
diff --git a/admin/group_list.php b/admin/group_list.php
index 97ee5a8f3..eff20031d 100644
--- a/admin/group_list.php
+++ b/admin/group_list.php
@@ -60,7 +60,7 @@ SELECT name
FROM '.GROUPS_TABLE.'
WHERE id = '.$_GET['delete'].'
;';
- list($groupname) = mysql_fetch_row(pwg_query($query));
+ list($groupname) = pwg_db_fetch_row(pwg_query($query));
// destruction of the group
$query = '
@@ -94,7 +94,7 @@ SELECT COUNT(*)
FROM '.GROUPS_TABLE.'
WHERE name = \''.$_POST['groupname'].'\'
;';
- list($count) = mysql_fetch_row(pwg_query($query));
+ list($count) = pwg_db_fetch_row(pwg_query($query));
if ($count != 0)
{
array_push($page['errors'], l10n('group_add_error2'));
@@ -107,7 +107,7 @@ SELECT COUNT(*)
INSERT INTO '.GROUPS_TABLE.'
(name)
VALUES
- (\''.mysql_real_escape_string($_POST['groupname']).'\')
+ (\''.pwg_db_real_escape_string($_POST['groupname']).'\')
;';
pwg_query($query);
@@ -129,7 +129,7 @@ SELECT name, is_default
FROM '.GROUPS_TABLE.'
WHERE id = '.$_GET['toggle_is_default'].'
;';
- list($groupname, $is_default) = mysql_fetch_row(pwg_query($query));
+ list($groupname, $is_default) = pwg_db_fetch_row(pwg_query($query));
// update of the group
$query = '
@@ -175,14 +175,14 @@ $del_url = $admin_url.'group_list&amp;delete=';
$members_url = $admin_url.'user_list&amp;group=';
$toggle_is_default_url = $admin_url.'group_list&amp;toggle_is_default=';
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$query = '
SELECT COUNT(*)
FROM '.USER_GROUP_TABLE.'
WHERE group_id = '.$row['id'].'
;';
- list($counter) = mysql_fetch_row(pwg_query($query));
+ list($counter) = pwg_db_fetch_row(pwg_query($query));
$template->append(
'groups',
diff --git a/admin/group_perm.php b/admin/group_perm.php
index 89a8b43ae..f664854e7 100644
--- a/admin/group_perm.php
+++ b/admin/group_perm.php
@@ -79,7 +79,7 @@ SELECT id
AND status = \'private\'
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($private_uppercats, $row['id']);
}
@@ -96,7 +96,7 @@ SELECT cat_id
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($authorized_ids, $row['cat_id']);
}
@@ -157,7 +157,7 @@ display_select_cat_wrapper($query_true,array(),'category_option_true');
$result = pwg_query($query_true);
$authorized_ids = array();
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
array_push($authorized_ids, $row['id']);
}
diff --git a/admin/history.php b/admin/history.php
index afc1712e1..86014fc7b 100644
--- a/admin/history.php
+++ b/admin/history.php
@@ -110,7 +110,7 @@ if (isset($_POST['submit']))
$search['fields']['filename'] = str_replace(
'*',
'%',
- mysql_real_escape_string($_POST['filename'])
+ pwg_db_real_escape_string($_POST['filename'])
);
}
@@ -136,7 +136,7 @@ INSERT INTO '.SEARCH_TABLE.'
;';
pwg_query($query);
- $search_id = mysql_insert_id();
+ $search_id = pwg_db_insert_id();
redirect(
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
@@ -177,7 +177,7 @@ SELECT rules
FROM '.SEARCH_TABLE.'
WHERE id = '.$page['search_id'].'
;';
- list($serialized_rules) = mysql_fetch_row(pwg_query($query));
+ list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
$page['search'] = unserialize($serialized_rules);
@@ -198,7 +198,7 @@ INSERT INTO '.SEARCH_TABLE.'
;';
pwg_query($query);
- $search_id = mysql_insert_id();
+ $search_id = pwg_db_insert_id();
redirect(
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
@@ -257,7 +257,7 @@ SELECT '.$conf['user_fields']['id'].' AS id
$result = pwg_query($query);
$username_of = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$username_of[$row['id']] = stripslashes($row['username']);
}
@@ -305,7 +305,7 @@ SELECT
$tn_ext_of_image = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$label_of_image[ $row['id'] ] = $row['label'];
@@ -341,7 +341,7 @@ SELECT
$name_of_tag = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$name_of_tag[ $row['id'] ] = $row['name'];
}
diff --git a/admin/include/c13y_internal.class.php b/admin/include/c13y_internal.class.php
index 6402c6516..1fe83c0df 100644
--- a/admin/include/c13y_internal.class.php
+++ b/admin/include/c13y_internal.class.php
@@ -42,8 +42,8 @@ class c13y_internal
$check_list[] = array('type' => 'PHP', 'current' => phpversion(), 'required' => REQUIRED_PHP_VERSION);
- list($mysql_version) = mysql_fetch_row(pwg_query('SELECT VERSION();'));
- $check_list[] = array('type' => 'MySQL', 'current' => $mysql_version, 'required' => REQUIRED_MYSQL_VERSION);
+ $db_version = pwg_get_db_version();
+ $check_list[] = array('type' => 'MySQL', 'current' => $db_version, 'required' => REQUIRED_MYSQL_VERSION);
foreach ($check_list as $elem)
{
@@ -126,7 +126,7 @@ class c13y_internal
$status = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$status[$row['id']] = $row['status'];
}
diff --git a/admin/include/functions.php b/admin/include/functions.php
index d1e82f15f..2b6bffa98 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -36,7 +36,7 @@ SELECT id
;';
$result = pwg_query($query);
$category_ids = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($category_ids, $row['id']);
}
@@ -77,7 +77,7 @@ SELECT id
;';
$result = pwg_query($query);
$element_ids = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($element_ids, $row['id']);
}
@@ -159,7 +159,7 @@ SELECT
AND storage_category_id IS NULL
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$file_path = $row['path'];
$thumbnail_path = get_thumbnail_path($row);
@@ -409,210 +409,6 @@ function get_fs_directories($path, $recursive = true)
}
/**
- * inserts multiple lines in a table
- *
- * @param string table_name
- * @param array dbfields
- * @param array inserts
- * @return void
- */
-function mass_inserts($table_name, $dbfields, $datas)
-{
- if (count($datas) != 0)
- {
- $first = true;
-
- $query = 'SHOW VARIABLES LIKE \'max_allowed_packet\'';
- list(, $packet_size) = mysql_fetch_row(pwg_query($query));
- $packet_size = $packet_size - 2000; // The last list of values MUST not exceed 2000 character*/
- $query = '';
-
- foreach ($datas as $insert)
- {
- if (strlen($query) >= $packet_size)
- {
- pwg_query($query);
- $first = true;
- }
-
- if ($first)
- {
- $query = '
-INSERT INTO '.$table_name.'
- ('.implode(',', $dbfields).')
- VALUES';
- $first = false;
- }
- else
- {
- $query .= '
- , ';
- }
-
- $query .= '(';
- foreach ($dbfields as $field_id => $dbfield)
- {
- if ($field_id > 0)
- {
- $query .= ',';
- }
-
- if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
- {
- $query .= 'NULL';
- }
- else
- {
- $query .= "'".$insert[$dbfield]."'";
- }
- }
- $query .= ')';
- }
- pwg_query($query);
- }
-}
-
-define('MASS_UPDATES_SKIP_EMPTY', 1);
-/**
- * updates multiple lines in a table
- *
- * @param string table_name
- * @param array dbfields
- * @param array datas
- * @param int flags - if MASS_UPDATES_SKIP_EMPTY - empty values do not overwrite existing ones
- * @return void
- */
-function mass_updates($tablename, $dbfields, $datas, $flags=0)
-{
- if (count($datas) == 0)
- return;
- // depending on the MySQL version, we use the multi table update or N update queries
- if (count($datas) < 10 or version_compare(mysql_get_server_info(), '4.0.4') < 0)
- { // MySQL is prior to version 4.0.4, multi table update feature is not available
- foreach ($datas as $data)
- {
- $query = '
-UPDATE '.$tablename.'
- SET ';
- $is_first = true;
- foreach ($dbfields['update'] as $key)
- {
- $separator = $is_first ? '' : ",\n ";
-
- if (isset($data[$key]) and $data[$key] != '')
- {
- $query.= $separator.$key.' = \''.$data[$key].'\'';
- }
- else
- {
- if ($flags & MASS_UPDATES_SKIP_EMPTY )
- continue; // next field
- $query.= "$separator$key = NULL";
- }
- $is_first = false;
- }
- if (!$is_first)
- {// only if one field at least updated
- $query.= '
- WHERE ';
- $is_first = true;
- foreach ($dbfields['primary'] as $key)
- {
- if (!$is_first)
- {
- $query.= ' AND ';
- }
- if ( isset($data[$key]) )
- {
- $query.= $key.' = \''.$data[$key].'\'';
- }
- else
- {
- $query.= $key.' IS NULL';
- }
- $is_first = false;
- }
- pwg_query($query);
- }
- } // foreach update
- } // if mysql_ver or count<X
- else
- {
- // creation of the temporary table
- $query = '
-SHOW FULL COLUMNS FROM '.$tablename;
- $result = pwg_query($query);
- $columns = array();
- $all_fields = array_merge($dbfields['primary'], $dbfields['update']);
- while ($row = mysql_fetch_assoc($result))
- {
- if (in_array($row['Field'], $all_fields))
- {
- $column = $row['Field'];
- $column.= ' '.$row['Type'];
-
- $nullable = true;
- if (!isset($row['Null']) or $row['Null'] == '' or $row['Null']=='NO')
- {
- $column.= ' NOT NULL';
- $nullable = false;
- }
- if (isset($row['Default']))
- {
- $column.= " default '".$row['Default']."'";
- }
- elseif ($nullable)
- {
- $column.= " default NULL";
- }
- if (isset($row['Collation']) and $row['Collation'] != 'NULL')
- {
- $column.= " collate '".$row['Collation']."'";
- }
- array_push($columns, $column);
- }
- }
-
- $temporary_tablename = $tablename.'_'.micro_seconds();
-
- $query = '
-CREATE TABLE '.$temporary_tablename.'
-(
- '.implode(",\n ", $columns).',
- UNIQUE KEY the_key ('.implode(',', $dbfields['primary']).')
-)';
-
- pwg_query($query);
- mass_inserts($temporary_tablename, $all_fields, $datas);
- if ( $flags & MASS_UPDATES_SKIP_EMPTY )
- $func_set = create_function('$s', 'return "t1.$s = IFNULL(t2.$s, t1.$s)";');
- else
- $func_set = create_function('$s', 'return "t1.$s = t2.$s";');
-
- // update of images table by joining with temporary table
- $query = '
-UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
- SET '.
- implode(
- "\n , ",
- array_map($func_set,$dbfields['update'])
- ).'
- WHERE '.
- implode(
- "\n AND ",
- array_map(
- create_function('$s', 'return "t1.$s = t2.$s";'),
- $dbfields['primary']
- )
- );
- pwg_query($query);
- $query = '
-DROP TABLE '.$temporary_tablename;
- pwg_query($query);
- }
-}
-
-/**
* order categories (update categories.rank and global_rank database fields)
* so that rank field are consecutive integers starting at 1 for each child
* @return void
@@ -630,7 +426,7 @@ SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat, uppercats, r
$current_uppercat = '';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
if ($row['id_uppercat'] != $current_uppercat)
{
@@ -776,7 +572,7 @@ SELECT uppercats
WHERE id IN ('.implode(',', $cat_ids).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$uppercats = array_merge($uppercats,
explode(',', $row['uppercats']));
@@ -803,7 +599,7 @@ SELECT image_id
ORDER BY RAND()
LIMIT 0,1
;';
- list($representative) = mysql_fetch_row(pwg_query($query));
+ list($representative) = pwg_db_fetch_row(pwg_query($query));
array_push(
$datas,
@@ -863,7 +659,7 @@ SELECT id, uppercats, site_id
'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($categories, $row);
}
@@ -1139,7 +935,7 @@ SELECT element_id,
$datas = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push(
$datas,
@@ -1206,7 +1002,7 @@ SELECT id, id_uppercat, status, uppercats
WHERE id IN ('.implode(',', $category_ids).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$categories[$row['id']] =
array(
@@ -1225,7 +1021,7 @@ SELECT uppercats
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$new_parent.'
;';
- list($new_parent_uppercats) = mysql_fetch_row(pwg_query($query));
+ list($new_parent_uppercats) = pwg_db_fetch_row(pwg_query($query));
foreach ($categories as $category)
{
@@ -1270,7 +1066,7 @@ SELECT status
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$new_parent.'
;';
- list($parent_status) = mysql_fetch_row(pwg_query($query));
+ list($parent_status) = pwg_db_fetch_row(pwg_query($query));
}
if ('private' == $parent_status)
@@ -1355,7 +1151,7 @@ SELECT MAX(rank)
FROM '.CATEGORIES_TABLE.'
WHERE id_uppercat '.(is_numeric($parent_id) ? '= '.$parent_id : 'IS NULL').'
;';
- list($current_rank) = mysql_fetch_row(pwg_query($query));
+ list($current_rank) = pwg_db_fetch_row(pwg_query($query));
$insert = array(
'name' => $category_name,
@@ -1371,7 +1167,7 @@ SELECT id, uppercats, global_rank, visible, status
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$parent_id.'
;';
- $parent = mysql_fetch_assoc(pwg_query($query));
+ $parent = pwg_db_fetch_assoc(pwg_query($query));
$insert['id_uppercat'] = $parent['id'];
$insert['global_rank'] = $parent['global_rank'].'.'.$insert['rank'];
@@ -1417,7 +1213,7 @@ SELECT id, uppercats, global_rank, visible, status
array($insert)
);
- $inserted_id = mysql_insert_id();
+ $inserted_id = pwg_db_insert_id();
$query = '
UPDATE
@@ -1550,7 +1346,7 @@ SELECT id
)
);
- $page['tag_id_from_tag_name_cache'][$tag_name] = mysql_insert_id();
+ $page['tag_id_from_tag_name_cache'][$tag_name] = pwg_db_insert_id();
}
else
{
@@ -1596,70 +1392,6 @@ DELETE
}
/**
- * Do maintenance on all PWG tables
- *
- * @return none
- */
-function do_maintenance_all_tables()
-{
- global $prefixeTable, $page;
-
- $all_tables = array();
-
- // List all tables
- $query = 'SHOW TABLES LIKE \''.$prefixeTable.'%\'';
- $result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
- {
- array_push($all_tables, $row[0]);
- }
-
- // Repair all tables
- $query = 'REPAIR TABLE '.implode(', ', $all_tables);
- $mysql_rc = pwg_query($query);
-
- // Re-Order all tables
- foreach ($all_tables as $table_name)
- {
- $all_primary_key = array();
-
- $query = 'DESC '.$table_name.';';
- $result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
- {
- if ($row['Key'] == 'PRI')
- {
- array_push($all_primary_key, $row['Field']);
- }
- }
-
- if (count($all_primary_key) != 0)
- {
- $query = 'ALTER TABLE '.$table_name.' ORDER BY '.implode(', ', $all_primary_key).';';
- $mysql_rc = $mysql_rc && pwg_query($query);
- }
- }
-
- // Optimize all tables
- $query = 'OPTIMIZE TABLE '.implode(', ', $all_tables);
- $mysql_rc = $mysql_rc && pwg_query($query);
- if ($mysql_rc)
- {
- array_push(
- $page['infos'],
- l10n('Optimizations completed')
- );
- }
- else
- {
- array_push(
- $page['errors'],
- l10n('Optimizations errors')
- );
- }
-}
-
-/**
* Associate a list of images to a list of categories.
*
* The function will not duplicate links
@@ -1889,7 +1621,7 @@ SELECT id
)
);
- $inserted_id = mysql_insert_id();
+ $inserted_id = pwg_db_insert_id();
return array(
'info' => sprintf(
@@ -2075,9 +1807,9 @@ SELECT name
WHERE id = '.intval($group_id).'
;';
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
- list($groupname) = mysql_fetch_row($result);
+ list($groupname) = pwg_db_fetch_row($result);
}
else
{
@@ -2103,9 +1835,9 @@ SELECT '.$conf['user_fields']['username'].'
WHERE '.$conf['user_fields']['id'].' = '.intval($user_id).'
;';
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
- list($username) = mysql_fetch_row($result);
+ list($username) = pwg_db_fetch_row($result);
}
else
{
diff --git a/admin/include/functions_history.inc.php b/admin/include/functions_history.inc.php
index bad4a0de5..824caed42 100644
--- a/admin/include/functions_history.inc.php
+++ b/admin/include/functions_history.inc.php
@@ -165,7 +165,7 @@ SELECT
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($data, $row);
}
diff --git a/admin/include/functions_metadata.php b/admin/include/functions_metadata.php
index 5bf36439d..f1e9f2549 100644
--- a/admin/include/functions_metadata.php
+++ b/admin/include/functions_metadata.php
@@ -259,7 +259,7 @@ SELECT id
$query.= '
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($cat_ids, $row['id']);
}
@@ -284,7 +284,7 @@ SELECT id, path
$query.= '
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$files[$row['id']] = $row['path'];
}
diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php
index 6a674c5e0..e50321de4 100644
--- a/admin/include/functions_notification_by_mail.inc.php
+++ b/admin/include/functions_notification_by_mail.inc.php
@@ -59,7 +59,7 @@ from
where
check_key = \''.$key.'\';';
- list($count) = mysql_fetch_row(pwg_query($query));
+ list($count) = pwg_db_fetch_row(pwg_query($query));
if ($count == 0)
{
return $key;
@@ -167,7 +167,7 @@ order by';
$result = pwg_query($query);
if (!empty($result))
{
- while ($nbm_user = mysql_fetch_assoc($result))
+ while ($nbm_user = pwg_db_fetch_assoc($result))
{
array_push($data_users, $nbm_user);
}
diff --git a/admin/include/functions_permalinks.php b/admin/include/functions_permalinks.php
index 85820dba2..f619e3b08 100644
--- a/admin/include/functions_permalinks.php
+++ b/admin/include/functions_permalinks.php
@@ -51,8 +51,8 @@ SELECT c.id
LIMIT 1';
$result = pwg_query($query);
$cat_id = null;
- if ( mysql_num_rows($result) )
- list( $cat_id ) = mysql_fetch_row($result);
+ if ( pwg_db_num_rows($result) )
+ list( $cat_id ) = pwg_db_fetch_row($result);
return $cat_id;
}
@@ -72,9 +72,9 @@ SELECT permalink
WHERE id="'.$cat_id.'"
;';
$result = pwg_query($query);
- if ( mysql_num_rows($result) )
+ if ( pwg_db_num_rows($result) )
{
- list($permalink) = mysql_fetch_row($result);
+ list($permalink) = pwg_db_fetch_row($result);
}
if ( !isset($permalink) )
{// no permalink; nothing to do
diff --git a/admin/include/functions_upgrade.php b/admin/include/functions_upgrade.php
index 1d0fbd969..6c653fe98 100644
--- a/admin/include/functions_upgrade.php
+++ b/admin/include/functions_upgrade.php
@@ -112,7 +112,7 @@ AND id NOT IN ("' . implode('","', $standard_plugins) . '")
$result = pwg_query($query);
$plugins = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($plugins, $row['id']);
}
@@ -138,7 +138,7 @@ function check_upgrade_access_rights($current_release, $username, $password)
if(!@get_magic_quotes_gpc())
{
- $username = mysql_real_escape_string($username);
+ $username = pwg_db_real_escape_string($username);
}
if (version_compare($current_release, '2.0', '<'))
@@ -165,7 +165,7 @@ ON u.'.$conf['user_fields']['id'].'=ui.user_id
WHERE '.$conf['user_fields']['username'].'="'.$username.'"
;';
}
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
if (!isset($conf['pass_convert']))
{
diff --git a/admin/intro.php b/admin/intro.php
index d2549b5db..c081e8918 100644
--- a/admin/intro.php
+++ b/admin/intro.php
@@ -53,24 +53,24 @@ if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
// if the current version is a BSF (development branch) build, we check
// the first line, for stable versions, we check the second line
- if (preg_match('/^BSF/', $versions{'current'}))
+ if (preg_match('/^BSF/', $versions['current']))
{
- $versions{'latest'} = trim($lines[0]);
+ $versions['latest'] = trim($lines[0]);
// because integer are limited to 4,294,967,296 we need to split BSF
// versions in date.time
foreach ($versions as $key => $value)
{
- $versions{$key} =
+ $versions[$key] =
preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
}
}
else
{
- $versions{'latest'} = trim($lines[1]);
+ $versions['latest'] = trim($lines[1]);
}
- if ('' == $versions{'latest'})
+ if ('' == $versions['latest'])
{
array_push(
$page['errors'],
@@ -79,14 +79,14 @@ if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
}
// concatenation needed to avoid automatic transformation by release
// script generator
- else if ('%'.'PWGVERSION'.'%' == $versions{'current'})
+ else if ('%'.'PWGVERSION'.'%' == $versions['current'])
{
array_push(
$page['infos'],
l10n('You are running on development sources, no check possible.')
);
}
- else if (version_compare($versions{'current'}, $versions{'latest'}) < 0)
+ else if (version_compare($versions['current'], $versions['latest']) < 0)
{
array_push(
$page['infos'],
@@ -125,69 +125,70 @@ if ($conf['show_newsletter_subscription']) {
}
$php_current_timestamp = date("Y-m-d H:i:s");
-list($mysql_version, $db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT VERSION(), CURRENT_TIMESTAMP;'));
+$db_version = pwg_get_db_version();
+list($db_current_timestamp) = pwg_db_fetch_row(pwg_query('SELECT CURRENT_TIMESTAMP;'));
$query = '
SELECT COUNT(*)
FROM '.IMAGES_TABLE.'
;';
-list($nb_elements) = mysql_fetch_row(pwg_query($query));
+list($nb_elements) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.CATEGORIES_TABLE.'
;';
-list($nb_categories) = mysql_fetch_row(pwg_query($query));
+list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.CATEGORIES_TABLE.'
WHERE dir IS NULL
;';
-list($nb_virtual) = mysql_fetch_row(pwg_query($query));
+list($nb_virtual) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.CATEGORIES_TABLE.'
WHERE dir IS NOT NULL
;';
-list($nb_physical) = mysql_fetch_row(pwg_query($query));
+list($nb_physical) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.IMAGE_CATEGORY_TABLE.'
;';
-list($nb_image_category) = mysql_fetch_row(pwg_query($query));
+list($nb_image_category) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.TAGS_TABLE.'
;';
-list($nb_tags) = mysql_fetch_row(pwg_query($query));
+list($nb_tags) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.IMAGE_TAG_TABLE.'
;';
-list($nb_image_tag) = mysql_fetch_row(pwg_query($query));
+list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.USERS_TABLE.'
;';
-list($nb_users) = mysql_fetch_row(pwg_query($query));
+list($nb_users) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.GROUPS_TABLE.'
;';
-list($nb_groups) = mysql_fetch_row(pwg_query($query));
+list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.COMMENTS_TABLE.'
;';
-list($nb_comments) = mysql_fetch_row(pwg_query($query));
+list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
$template->assign(
array(
@@ -195,7 +196,8 @@ $template->assign(
'PWG_VERSION' => PHPWG_VERSION,
'OS' => PHP_OS,
'PHP_VERSION' => phpversion(),
- 'MYSQL_VERSION' => $mysql_version,
+ 'DB_ENGINE' => 'MySQL',
+ 'DB_VERSION' => $db_version,
'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements),
'DB_CATEGORIES' =>
l10n_dec('cat_inclu_part1_S', 'cat_inclu_part1_P',
@@ -223,7 +225,7 @@ if ($nb_elements > 0)
SELECT MIN(date_available)
FROM '.IMAGES_TABLE.'
;';
- list($first_date) = mysql_fetch_row(pwg_query($query));
+ list($first_date) = pwg_db_fetch_row(pwg_query($query));
$template->assign(
'first_added',
@@ -243,7 +245,7 @@ SELECT COUNT(*)
FROM '.WAITING_TABLE.'
WHERE validated=\'false\'
;';
-list($nb_waiting) = mysql_fetch_row(pwg_query($query));
+list($nb_waiting) = pwg_db_fetch_row(pwg_query($query));
if ($nb_waiting > 0)
{
@@ -262,7 +264,7 @@ SELECT COUNT(*)
FROM '.COMMENTS_TABLE.'
WHERE validated=\'false\'
;';
-list($nb_comments) = mysql_fetch_row(pwg_query($query));
+list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
if ($nb_comments > 0)
{
diff --git a/admin/notification_by_mail.php b/admin/notification_by_mail.php
index 95aea99ae..a165d54ea 100644
--- a/admin/notification_by_mail.php
+++ b/admin/notification_by_mail.php
@@ -145,12 +145,12 @@ order by
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
$inserts = array();
$check_key_list = array();
- while ($nbm_user = mysql_fetch_assoc($result))
+ while ($nbm_user = pwg_db_fetch_assoc($result))
{
// Calculate key
$nbm_user['check_key'] = find_available_check_key();
@@ -238,7 +238,7 @@ function do_action_send_mail_notification($action = 'list_to_send', $check_key_l
if (in_array($action, array('list_to_send', 'send')))
{
- list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
+ list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
$is_action_send = ($action == 'send');
@@ -512,7 +512,7 @@ switch ($page['mode'])
$updated_param_count = 0;
// Update param
$result = pwg_query('select param, value from '.CONFIG_TABLE.' where param like \'nbm\\_%\'');
- while ($nbm_user = mysql_fetch_assoc($result))
+ while ($nbm_user = pwg_db_fetch_assoc($result))
{
if (isset($_POST[$nbm_user['param']]))
{
diff --git a/admin/permalinks.php b/admin/permalinks.php
index bd56e69d8..b937a8016 100644
--- a/admin/permalinks.php
+++ b/admin/permalinks.php
@@ -99,7 +99,7 @@ DELETE FROM '.OLD_PERMALINKS_TABLE.'
WHERE permalink="'.$_GET['delete_permanent'].'"
LIMIT 1';
pwg_query($query);
- if (mysql_affected_rows()==0)
+ if (pwg_db_affected_rows()==0)
array_push($page['errors'], 'Cannot delete the old permalink !');
}
@@ -134,7 +134,7 @@ if ( $sort_by[0]=='id' or $sort_by[0]=='permalink' )
}
$categories=array();
$result=pwg_query($query);
-while ( $row=mysql_fetch_assoc($result) )
+while ( $row = pwg_db_fetch_assoc($result) )
{
$row['name'] = get_cat_display_name_cache( $row['uppercats'] );
$categories[] = $row;
@@ -162,7 +162,7 @@ if ( count($sort_by) )
}
$result = pwg_query($query);
$deleted_permalinks=array();
-while ( $row=mysql_fetch_assoc($result) )
+while ( $row = pwg_db_fetch_assoc($result) )
{
$row['name'] = get_cat_display_name_cache($row['cat_id']);
$row['U_DELETE'] =
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index 30b9db972..912a94c1c 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -44,7 +44,7 @@ SELECT path
FROM '.IMAGES_TABLE.'
WHERE id = '.$_GET['image_id'].'
;';
- list($path) = mysql_fetch_row(pwg_query($query));
+ list($path) = pwg_db_fetch_row(pwg_query($query));
update_metadata(array($_GET['image_id'] => $path));
array_push($page['infos'], l10n('Metadata synchronized from file'));
@@ -175,7 +175,7 @@ SELECT *
FROM '.IMAGES_TABLE.'
WHERE id = '.$_GET['image_id'].'
;';
-$row = mysql_fetch_assoc(pwg_query($query));
+$row = pwg_db_fetch_assoc(pwg_query($query));
$storage_category_id = null;
if (!empty($row['storage_category_id']))
@@ -324,7 +324,7 @@ SELECT category_id, uppercats
;';
$result = pwg_query($query);
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$name =
get_cat_display_name_cache(
@@ -417,7 +417,7 @@ if (isset($storage_category_id))
{
array_push($associateds, $storage_category_id);
}
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
array_push($associateds, $row['id']);
}
diff --git a/admin/rating.php b/admin/rating.php
index 99d703c72..5f3f93fa3 100644
--- a/admin/rating.php
+++ b/admin/rating.php
@@ -94,7 +94,7 @@ SELECT '.$conf['user_fields']['username'].' as username, '.$conf['user_fields'][
FROM '.USERS_TABLE.'
;';
$result = pwg_query($query);
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$users[$row['id']]=stripslashes($row['username']);
}
@@ -104,7 +104,7 @@ $query = 'SELECT COUNT(DISTINCT(i.id))
FROM '.RATE_TABLE.' AS r, '.IMAGES_TABLE.' AS i
WHERE r.element_id=i.id'. $page['user_filter'] .
';';
-list($nb_images) = mysql_fetch_row(pwg_query($query));
+list($nb_images) = pwg_db_fetch_row(pwg_query($query));
// +-----------------------------------------------------------------------+
@@ -181,7 +181,7 @@ SELECT i.id,
$images = array();
$result = pwg_query($query);
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
array_push($images, $row);
}
@@ -199,7 +199,7 @@ FROM '.RATE_TABLE.' AS r
WHERE r.element_id='.$image['id'] . '
ORDER BY date DESC;';
$result = pwg_query($query);
- $nb_rates = mysql_num_rows($result);
+ $nb_rates = pwg_db_num_rows($result);
$tpl_image =
array(
@@ -214,7 +214,7 @@ ORDER BY date DESC;';
'rates' => array()
);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$url_del = PHPWG_ROOT_PATH.'admin.php'.
diff --git a/admin/site_manager.php b/admin/site_manager.php
index faec41166..2cc77bfbb 100644
--- a/admin/site_manager.php
+++ b/admin/site_manager.php
@@ -98,7 +98,7 @@ SELECT COUNT(id) AS count
FROM '.SITES_TABLE.'
WHERE galleries_url = \''.$url.'\'
;';
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
if ($row['count'] > 0)
{
array_push($page['errors'],
@@ -167,7 +167,7 @@ SELECT galleries_url
FROM '.SITES_TABLE.'
WHERE id = '.$page['site'].'
;';
- list($galleries_url) = mysql_fetch_row(pwg_query($query));
+ list($galleries_url) = pwg_db_fetch_row(pwg_query($query));
switch($_GET['action'])
{
case 'generate' :
@@ -236,7 +236,7 @@ SELECT *
;';
$result = pwg_query($query);
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$is_remote = url_is_remote($row['galleries_url']);
$base_url = PHPWG_ROOT_PATH.'admin.php';
diff --git a/admin/site_update.php b/admin/site_update.php
index 543c7f718..84c6a8f87 100644
--- a/admin/site_update.php
+++ b/admin/site_update.php
@@ -43,14 +43,14 @@ $query='
SELECT galleries_url
FROM '.SITES_TABLE.'
WHERE id = '.$site_id;
-list($site_url) = mysql_fetch_row(pwg_query($query));
+list($site_url) = pwg_db_fetch_row(pwg_query($query));
if (!isset($site_url))
{
die('site '.$site_id.' does not exist');
}
$site_is_remote = url_is_remote($site_url);
-list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
+list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
define('CURRENT_DATE', $dbnow);
$error_labels = array(
@@ -185,7 +185,7 @@ SELECT id, uppercats, global_rank, status, visible
SELECT id
FROM '.CATEGORIES_TABLE;
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$next_rank[$row['id']] = 1;
}
@@ -196,7 +196,7 @@ SELECT id_uppercat, MAX(rank)+1 AS next_rank
FROM '.CATEGORIES_TABLE.'
GROUP BY id_uppercat';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
// for the id_uppercat NULL, we write 'NULL' and not the empty string
if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
@@ -210,7 +210,7 @@ SELECT id_uppercat, MAX(rank)+1 AS next_rank
$query = '
SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_id
FROM '.CATEGORIES_TABLE;
- list($next_id) = mysql_fetch_row(pwg_query($query));
+ list($next_id) = pwg_db_fetch_row(pwg_query($query));
// retrieve sub-directories fulldirs from the site reader
$fs_fulldirs = $site_reader->get_full_directories($basedir);
@@ -246,34 +246,34 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_id
'uploadable' => $site_is_remote
? 'false'
: boolean_to_string($conf['newcat_default_uploadable']),
- 'status' => $conf{'newcat_default_status'},
- 'visible' => boolean_to_string($conf{'newcat_default_visible'}),
+ 'status' => $conf['newcat_default_status'],
+ 'visible' => boolean_to_string($conf['newcat_default_visible']),
);
if (isset($db_fulldirs[dirname($fulldir)]))
{
$parent = $db_fulldirs[dirname($fulldir)];
- $insert{'id_uppercat'} = $parent;
- $insert{'uppercats'} =
- $db_categories[$parent]['uppercats'].','.$insert{'id'};
- $insert{'rank'} = $next_rank[$parent]++;
- $insert{'global_rank'} =
- $db_categories[$parent]['global_rank'].'.'.$insert{'rank'};
+ $insert['id_uppercat'] = $parent;
+ $insert['uppercats'] =
+ $db_categories[$parent]['uppercats'].','.$insert['id'];
+ $insert['rank'] = $next_rank[$parent]++;
+ $insert['global_rank'] =
+ $db_categories[$parent]['global_rank'].'.'.$insert['rank'];
if ('private' == $db_categories[$parent]['status'])
{
- $insert{'status'} = 'private';
+ $insert['status'] = 'private';
}
if ('false' == $db_categories[$parent]['visible'])
{
- $insert{'visible'} = 'false';
+ $insert['visible'] = 'false';
}
}
else
{
- $insert{'uppercats'} = $insert{'id'};
+ $insert['uppercats'] = $insert['id'];
$insert{'rank'} = $next_rank['NULL']++;
- $insert{'global_rank'} = $insert{'rank'};
+ $insert['global_rank'] = $insert['rank'];
}
array_push($inserts, $insert);
@@ -288,13 +288,13 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_id
// add the new category to $db_categories and $db_fulldirs array
$db_categories[$insert{'id'}] =
array(
- 'id' => $insert{'id'},
- 'status' => $insert{'status'},
- 'visible' => $insert{'visible'},
- 'uppercats' => $insert{'uppercats'},
- 'global_rank' => $insert{'global_rank'}
+ 'id' => $insert['id'],
+ 'status' => $insert['status'],
+ 'visible' => $insert['visible'],
+ 'uppercats' => $insert['uppercats'],
+ 'global_rank' => $insert['global_rank']
);
- $db_fulldirs[$fulldir] = $insert{'id'};
+ $db_fulldirs[$fulldir] = $insert['id'];
$next_rank[$insert{'id'}] = 1;
}
else
@@ -386,7 +386,7 @@ SELECT file,storage_category_id
'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
AND validated = \'false\'';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push(
$db_unvalidated,
@@ -402,7 +402,7 @@ SELECT file,storage_category_id
$query = '
SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
FROM '.IMAGES_TABLE;
- list($next_element_id) = mysql_fetch_row(pwg_query($query));
+ list($next_element_id) = pwg_db_fetch_row(pwg_query($query));
$start = get_moment();
@@ -470,7 +470,7 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
array_push(
$insert_links,
array(
- 'image_id' => $insert{'id'},
+ 'image_id' => $insert['id'],
'category_id' => $insert['storage_category_id'],
)
);
@@ -478,7 +478,7 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
array_push(
$infos,
array(
- 'path' => $insert{'path'},
+ 'path' => $insert['path'],
'info' => l10n('update_research_added')
)
);
@@ -555,7 +555,7 @@ SELECT id,file,storage_category_id,infos
$waiting_to_delete = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$data = array();
@@ -564,7 +564,7 @@ SELECT id
FROM '.IMAGES_TABLE.'
WHERE storage_category_id = '.$row['storage_category_id'].'
AND file = \''.$row['file'].'\'';
- list($data['id']) = mysql_fetch_row(pwg_query($query));
+ list($data['id']) = pwg_db_fetch_row(pwg_query($query));
foreach ($fields['update'] as $field)
{
diff --git a/admin/stats.php b/admin/stats.php
index 600cfcb6e..7a71e5927 100644
--- a/admin/stats.php
+++ b/admin/stats.php
@@ -95,7 +95,7 @@ SELECT
$result = pwg_query($query);
$output = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($output, $row);
}
@@ -133,7 +133,7 @@ $max_id = 0;
$is_first = true;
$first_time_key = null;
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$time_keys = array(
substr($row['date'], 0, 4), //yyyy
@@ -204,7 +204,7 @@ SELECT *
)
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$key = sprintf('%4u', $row['year']);
if ( isset($row['month']) )
diff --git a/admin/tags.php b/admin/tags.php
index 94c5bcb3d..949ccc22c 100644
--- a/admin/tags.php
+++ b/admin/tags.php
@@ -49,7 +49,7 @@ SELECT id, name
WHERE id IN ('.$_POST['edit_list'].')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$current_name_of[ $row['id'] ] = $row['name'];
}
@@ -220,7 +220,7 @@ SELECT id, name
WHERE id IN ('.implode(',', $_POST['tags']).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$name_of[ $row['id'] ] = $row['name'];
}
diff --git a/admin/template/goto/intro.tpl b/admin/template/goto/intro.tpl
index e529f3084..7d1d5b079 100644
--- a/admin/template/goto/intro.tpl
+++ b/admin/template/goto/intro.tpl
@@ -30,7 +30,7 @@ jQuery().ready(function(){ldelim}
<li>{'Operating system'|@translate}: {$OS}</li>
<li>PHP: {$PHP_VERSION} (<a href="{$U_PHPINFO}" onclick="window.open(this.href, '');
return false;">{'Show info'|@translate}</a>) [{$PHP_DATATIME}]</li>
- <li>MySQL: {$MYSQL_VERSION} [{$DB_DATATIME}]</li>
+ <li>{$DB_ENGINE}: {$DB_VERSION} [{$DB_DATATIME}]</li>
</ul>
</dd>
diff --git a/admin/thumbnail.php b/admin/thumbnail.php
index 635110303..7fc81dc3d 100644
--- a/admin/thumbnail.php
+++ b/admin/thumbnail.php
@@ -178,7 +178,7 @@ SELECT galleries_url FROM '.SITES_TABLE.'
WHERE galleries_url NOT LIKE "http://%"
;';
$result = pwg_query($query);
-while ( $row=mysql_fetch_assoc($result) )
+while ( $row=pwg_db_fetch_assoc($result) )
{
$basedir = preg_replace('#/*$#', '', $row['galleries_url']);
$fs = get_fs($basedir);
diff --git a/admin/upload.php b/admin/upload.php
index 94e526a35..12472810a 100644
--- a/admin/upload.php
+++ b/admin/upload.php
@@ -100,7 +100,7 @@ SELECT id, storage_category_id, file, tn_ext
WHERE id IN ('.implode(',', $to_reject).')
;';
$result = pwg_query($query);
- while($row = mysql_fetch_assoc($result))
+ while($row = pwg_db_fetch_assoc($result))
{
$dir = get_complete_dir($row['storage_category_id']);
unlink($dir.$row['file']);
@@ -153,7 +153,7 @@ $query.= " WHERE validated = 'false'";
$query.= ' ORDER BY storage_category_id';
$query.= ';';
$result = pwg_query( $query );
-while ( $row = mysql_fetch_assoc( $result ) )
+while ( $row = pwg_db_fetch_assoc( $result ) )
{
if ( !isset( $cat_names[$row['storage_category_id']] ) )
{
diff --git a/admin/user_list.php b/admin/user_list.php
index f679d95ce..c3956dc7b 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -49,7 +49,7 @@ function get_filtered_user_list()
if (isset($_GET['username']) and !empty($_GET['username']))
{
$username = str_replace('*', '%', $_GET['username']);
- $filter['username'] = mysql_real_escape_string($username);
+ $filter['username'] = pwg_db_real_escape_string($username);
}
if (isset($_GET['group'])
@@ -115,7 +115,7 @@ SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$user = $row;
$user['groups'] = array();
@@ -139,7 +139,7 @@ SELECT user_id, group_id
WHERE user_id IN ('.implode(',', $user_ids).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push(
$users[$user_nums[$row['user_id']]]['groups'],
@@ -492,7 +492,7 @@ SELECT id, name
;';
$result = pwg_query($query);
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$groups[$row['id']] = $row['name'];
}
diff --git a/admin/user_perm.php b/admin/user_perm.php
index 1d3b300f0..2156982c0 100644
--- a/admin/user_perm.php
+++ b/admin/user_perm.php
@@ -78,7 +78,7 @@ SELECT id
AND status = \'private\'
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($private_uppercats, $row['id']);
}
@@ -95,7 +95,7 @@ SELECT cat_id
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($authorized_ids, $row['cat_id']);
}
@@ -155,10 +155,10 @@ SELECT DISTINCT cat_id, c.uppercats, c.global_rank
;';
$result = pwg_query($query);
-if (mysql_num_rows($result) > 0)
+if (pwg_db_num_rows($result) > 0)
{
$cats = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($cats, $row);
array_push($group_authorized, $row['cat_id']);
@@ -191,7 +191,7 @@ display_select_cat_wrapper($query_true,array(),'category_option_true');
$result = pwg_query($query_true);
$authorized_ids = array();
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
array_push($authorized_ids, $row['id']);
}