Skip to content

Commit

Permalink
Feature 1244 resolved
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nikrou committed Nov 20, 2009
1 parent c020cd0 commit 924dd26
Show file tree
Hide file tree
Showing 78 changed files with 789 additions and 691 deletions.
4 changes: 2 additions & 2 deletions action.php
Expand Up @@ -71,7 +71,7 @@ function do_error( $code, $str )
;';

$result = pwg_query($query);
$element_info = mysql_fetch_assoc($result);
$element_info = pwg_db_fetch_assoc($result);
if ( empty($element_info) )
{
do_error(404, 'Requested id not found');
Expand All @@ -93,7 +93,7 @@ function do_error( $code, $str )
).'
LIMIT 1
;';
if ( mysql_num_rows(pwg_query($query))<1 )
if ( pwg_db_num_rows(pwg_query($query))<1 )
{
do_error(401, 'Access denied');
}
Expand Down
2 changes: 1 addition & 1 deletion admin/cat_list.php
Expand Up @@ -119,7 +119,7 @@ function save_categories_order($categories)
(!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']);
}
Expand Down
12 changes: 6 additions & 6 deletions admin/cat_modify.php
Expand Up @@ -193,7 +193,7 @@
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)
{
Expand All @@ -210,7 +210,7 @@
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(
Expand Down Expand Up @@ -373,7 +373,7 @@
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'];
Expand Down Expand Up @@ -461,9 +461,9 @@
;';

$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(
Expand Down Expand Up @@ -511,7 +511,7 @@
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'],
Expand Down
10 changes: 5 additions & 5 deletions admin/cat_perm.php
Expand Up @@ -45,7 +45,7 @@
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)
{
Expand All @@ -62,7 +62,7 @@
LIMIT 0,1
;';

list($page['cat']) = mysql_fetch_row(pwg_query($query));
list($page['cat']) = pwg_db_fetch_row(pwg_query($query));
}

// +-----------------------------------------------------------------------+
Expand Down Expand Up @@ -110,7 +110,7 @@
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']);
}
Expand Down Expand Up @@ -169,7 +169,7 @@
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']);
}
Expand Down Expand Up @@ -274,7 +274,7 @@
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']]))
{
Expand Down
2 changes: 1 addition & 1 deletion admin/comments.php
Expand Up @@ -145,7 +145,7 @@
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(
Expand Down
2 changes: 1 addition & 1 deletion admin/configuration.php
Expand Up @@ -138,7 +138,7 @@
{
//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']]))
{
Expand Down
2 changes: 1 addition & 1 deletion admin/element_set.php
Expand Up @@ -192,7 +192,7 @@
$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.'
Expand Down
6 changes: 3 additions & 3 deletions admin/element_set_global.php
Expand Up @@ -245,7 +245,7 @@
;';
$result = pwg_query($query);

while ($row = mysql_fetch_assoc($result))
while ($row = pwg_db_fetch_assoc($result))
{
$data = array();
$data['id'] = $row['id'];
Expand Down Expand Up @@ -337,7 +337,7 @@
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)
{
Expand Down Expand Up @@ -481,7 +481,7 @@

// template thumbnail initialization

while ($row = mysql_fetch_assoc($result))
while ($row = pwg_db_fetch_assoc($result))
{
$src = get_thumbnail_url($row);

Expand Down
4 changes: 2 additions & 2 deletions admin/element_set_ranks.php
Expand Up @@ -115,7 +115,7 @@ function save_images_order($category_id, $images)
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(
Expand Down Expand Up @@ -150,7 +150,7 @@ function save_images_order($category_id, $images)
// template thumbnail initialization
$current_rank = 1;

while ($row = mysql_fetch_assoc($result))
while ($row = pwg_db_fetch_assoc($result))
{
$src = get_thumbnail_url($row);

Expand Down
4 changes: 2 additions & 2 deletions admin/element_set_unit.php
Expand Up @@ -56,7 +56,7 @@
;';
$result = pwg_query($query);

while ($row = mysql_fetch_assoc($result))
while ($row = pwg_db_fetch_assoc($result))
{
$data = array();

Expand Down Expand Up @@ -200,7 +200,7 @@
;';
$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']);
Expand Down
12 changes: 6 additions & 6 deletions admin/group_list.php
Expand Up @@ -60,7 +60,7 @@
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 = '
Expand Down Expand Up @@ -94,7 +94,7 @@
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'));
Expand All @@ -107,7 +107,7 @@
INSERT INTO '.GROUPS_TABLE.'
(name)
VALUES
(\''.mysql_real_escape_string($_POST['groupname']).'\')
(\''.pwg_db_real_escape_string($_POST['groupname']).'\')
;';
pwg_query($query);

Expand All @@ -129,7 +129,7 @@
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 = '
Expand Down Expand Up @@ -175,14 +175,14 @@
$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',
Expand Down
6 changes: 3 additions & 3 deletions admin/group_perm.php
Expand Up @@ -79,7 +79,7 @@
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']);
}
Expand All @@ -96,7 +96,7 @@
;';
$result = pwg_query($query);

while ($row = mysql_fetch_assoc($result))
while ($row = pwg_db_fetch_assoc($result))
{
array_push($authorized_ids, $row['cat_id']);
}
Expand Down Expand Up @@ -157,7 +157,7 @@

$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']);
}
Expand Down
14 changes: 7 additions & 7 deletions admin/history.php
Expand Up @@ -110,7 +110,7 @@
$search['fields']['filename'] = str_replace(
'*',
'%',
mysql_real_escape_string($_POST['filename'])
pwg_db_real_escape_string($_POST['filename'])
);
}

Expand All @@ -136,7 +136,7 @@
;';
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
Expand Down Expand Up @@ -177,7 +177,7 @@
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);

Expand All @@ -198,7 +198,7 @@
;';
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
Expand Down Expand Up @@ -257,7 +257,7 @@
$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']);
}
Expand Down Expand Up @@ -305,7 +305,7 @@
$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'];

Expand Down Expand Up @@ -341,7 +341,7 @@
$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'];
}
Expand Down
6 changes: 3 additions & 3 deletions admin/include/c13y_internal.class.php
Expand Up @@ -42,8 +42,8 @@ function c13y_version($c13y)

$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)
{
Expand Down Expand Up @@ -126,7 +126,7 @@ function c13y_user($c13y)
$status = array();

$result = pwg_query($query);
while ($row = mysql_fetch_assoc($result))
while ($row = pwg_db_fetch_assoc($result))
{
$status[$row['id']] = $row['status'];
}
Expand Down

0 comments on commit 924dd26

Please sign in to comment.