mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 19:29:58 +03:00
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
This commit is contained in:
parent
c020cd0d7c
commit
924dd262ec
78 changed files with 789 additions and 691 deletions
|
@ -71,7 +71,7 @@ SELECT * FROM '. IMAGES_TABLE.'
|
|||
;';
|
||||
|
||||
$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');
|
||||
|
@ -93,7 +93,7 @@ SELECT id
|
|||
).'
|
||||
LIMIT 1
|
||||
;';
|
||||
if ( mysql_num_rows(pwg_query($query))<1 )
|
||||
if ( pwg_db_num_rows(pwg_query($query))<1 )
|
||||
{
|
||||
do_error(401, 'Access denied');
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
|
|
@ -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.= '&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'],
|
||||
|
|
|
@ -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']]))
|
||||
{
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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']]))
|
||||
{
|
||||
|
|
|
@ -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.'
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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&delete=';
|
|||
$members_url = $admin_url.'user_list&group=';
|
||||
$toggle_is_default_url = $admin_url.'group_list&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',
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -408,210 +408,6 @@ function get_fs_directories($path, $recursive = true)
|
|||
return $dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -1595,70 +1391,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.
|
||||
*
|
||||
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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']))
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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']]))
|
||||
{
|
||||
|
|
|
@ -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'] =
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
|
|
@ -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'.
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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']) )
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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']] ) )
|
||||
{
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ SELECT COUNT(DISTINCT(com.id))
|
|||
WHERE '.implode('
|
||||
AND ', $page['where_clauses']).'
|
||||
;';
|
||||
list($counter) = mysql_fetch_row(pwg_query($query));
|
||||
list($counter) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$url = PHPWG_ROOT_PATH
|
||||
.'comments.php'
|
||||
|
@ -331,7 +331,7 @@ if ('all' != $page['items_number'])
|
|||
$query.= '
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($comments, $row);
|
||||
array_push($element_ids, $row['image_id']);
|
||||
|
@ -348,7 +348,7 @@ SELECT id, name, file, path, tn_ext
|
|||
WHERE id IN ('.implode(',', $element_ids).')
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$elements[$row['id']] = $row;
|
||||
}
|
||||
|
|
4
feed.php
4
feed.php
|
@ -75,7 +75,7 @@ SELECT user_id,
|
|||
FROM '.USER_FEED_TABLE.'
|
||||
WHERE id = \''.$feed_id.'\'
|
||||
;';
|
||||
$feed_row = mysql_fetch_assoc(pwg_query($query));
|
||||
$feed_row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
if ( empty($feed_row) )
|
||||
{
|
||||
page_not_found('Unknown/missing feed identifier');
|
||||
|
@ -97,7 +97,7 @@ else
|
|||
// Check the status now after the user has been loaded
|
||||
check_status(ACCESS_GUEST);
|
||||
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ function build_global_calendar(&$tpl_var)
|
|||
|
||||
$result = pwg_query($query);
|
||||
$items=array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$y = substr($row['period'], 0, 4);
|
||||
$m = (int)substr($row['period'], 4, 2);
|
||||
|
@ -283,7 +283,7 @@ function build_year_calendar(&$tpl_var)
|
|||
|
||||
$result = pwg_query($query);
|
||||
$items=array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$m = (int)substr($row['period'], 0, 2);
|
||||
$d = substr($row['period'], 2, 2);
|
||||
|
@ -333,7 +333,7 @@ function build_month_calendar(&$tpl_var)
|
|||
|
||||
$items=array();
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$d = (int)$row['period'];
|
||||
$items[$d] = array('nb_images'=>$row['count']);
|
||||
|
@ -351,7 +351,7 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a
|
|||
LIMIT 0,1';
|
||||
unset ( $page['chronology_date'][CDAY] );
|
||||
|
||||
$row = mysql_fetch_assoc(pwg_query($query));
|
||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
$items[$day]['tn_url'] = get_thumbnail_url($row);
|
||||
$items[$day]['file'] = $row['file'];
|
||||
$items[$day]['path'] = $row['path'];
|
||||
|
|
|
@ -75,7 +75,7 @@ $categories = array();
|
|||
$category_ids = array();
|
||||
$image_ids = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['is_child_date_last'] = @$row['max_date_last']>@$row['date_last'];
|
||||
|
||||
|
@ -108,9 +108,9 @@ SELECT image_id
|
|||
LIMIT 0,1
|
||||
;';
|
||||
$subresult = pwg_query($query);
|
||||
if (mysql_num_rows($subresult) > 0)
|
||||
if (pwg_db_num_rows($subresult) > 0)
|
||||
{
|
||||
list($image_id) = mysql_fetch_row($subresult);
|
||||
list($image_id) = pwg_db_fetch_row($subresult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ SELECT image_id
|
|||
LIMIT 0,1
|
||||
;';
|
||||
$subresult = pwg_query($query);
|
||||
if (mysql_num_rows($subresult) > 0)
|
||||
if (pwg_db_num_rows($subresult) > 0)
|
||||
{
|
||||
list($image_id) = mysql_fetch_row($subresult);
|
||||
list($image_id) = pwg_db_fetch_row($subresult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ SELECT
|
|||
GROUP BY category_id
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$dates_of_category[ $row['category_id'] ] = array(
|
||||
'from' => $row['date_creation_min'],
|
||||
|
@ -202,7 +202,7 @@ SELECT id, path, tn_ext
|
|||
WHERE id IN ('.implode(',', $image_ids).')
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ SELECT *
|
|||
WHERE id IN ('.implode(',', $selection).')
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['rank'] = $rank_of[ $row['id'] ];
|
||||
|
||||
|
|
|
@ -92,6 +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');
|
||||
|
||||
if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
|
||||
{
|
||||
|
@ -104,22 +105,11 @@ include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
|
|||
include( PHPWG_ROOT_PATH .'include/template.class.php');
|
||||
|
||||
// Database connection
|
||||
@mysql_connect( $conf['db_host'], $conf['db_user'], $conf['db_password'] ) or my_error( 'mysql_connect', true );
|
||||
@mysql_select_db( $conf['db_base'] ) or my_error( 'mysql_select_db', true );
|
||||
$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
|
||||
$conf['db_password'], $conf['db_base'])
|
||||
or my_error('pwg_db_connect', true);
|
||||
|
||||
defined('PWG_CHARSET') and defined('DB_CHARSET')
|
||||
or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined');
|
||||
if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
|
||||
{
|
||||
if (DB_CHARSET!='')
|
||||
{
|
||||
pwg_query('SET NAMES "'.DB_CHARSET.'"');
|
||||
}
|
||||
}
|
||||
elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
|
||||
{
|
||||
fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
|
||||
}
|
||||
pwg_db_check_charset();
|
||||
|
||||
load_conf_from_db();
|
||||
load_plugins();
|
||||
|
|
463
include/dblayer/functions_mysql.inc.php
Normal file
463
include/dblayer/functions_mysql.inc.php
Normal file
|
@ -0,0 +1,463 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Piwigo - a PHP based picture gallery |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org |
|
||||
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
*
|
||||
* simple functions
|
||||
*
|
||||
*/
|
||||
|
||||
function pwg_db_connect($host, $user, $password, $database)
|
||||
{
|
||||
$link = mysql_connect($host, $user, $password) or my_error('mysql_connect', true);
|
||||
mysql_select_db($database, $link) or my_error('mysql_select_db', true);
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
function pwg_db_check_charset()
|
||||
{
|
||||
defined('PWG_CHARSET') and defined('DB_CHARSET')
|
||||
or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined');
|
||||
if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
|
||||
{
|
||||
if (DB_CHARSET!='')
|
||||
{
|
||||
pwg_query('SET NAMES "'.DB_CHARSET.'"');
|
||||
}
|
||||
}
|
||||
elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
|
||||
{
|
||||
fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
|
||||
}
|
||||
}
|
||||
|
||||
function pwg_get_db_version()
|
||||
{
|
||||
list($mysql_version) = pwg_db_fetch_row(pwg_query('SELECT VERSION();'));
|
||||
|
||||
return $mysql_version;
|
||||
}
|
||||
|
||||
function pwg_query($query)
|
||||
{
|
||||
global $conf,$page,$debug,$t2;
|
||||
|
||||
$start = get_moment();
|
||||
($result = mysql_query($query)) or my_error($query, $conf['die_on_sql_error']);
|
||||
|
||||
$time = get_moment() - $start;
|
||||
|
||||
if (!isset($page['count_queries']))
|
||||
{
|
||||
$page['count_queries'] = 0;
|
||||
$page['queries_time'] = 0;
|
||||
}
|
||||
|
||||
$page['count_queries']++;
|
||||
$page['queries_time']+= $time;
|
||||
|
||||
if ($conf['show_queries'])
|
||||
{
|
||||
$output = '';
|
||||
$output.= '<pre>['.$page['count_queries'].'] ';
|
||||
$output.= "\n".$query;
|
||||
$output.= "\n".'(this query time : ';
|
||||
$output.= '<b>'.number_format($time, 3, '.', ' ').' s)</b>';
|
||||
$output.= "\n".'(total SQL time : ';
|
||||
$output.= number_format($page['queries_time'], 3, '.', ' ').' s)';
|
||||
$output.= "\n".'(total time : ';
|
||||
$output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
|
||||
if ( $result!=null and preg_match('/\s*SELECT\s+/i',$query) )
|
||||
{
|
||||
$output.= "\n".'(num rows : ';
|
||||
$output.= mysql_num_rows($result).' )';
|
||||
}
|
||||
elseif ( $result!=null
|
||||
and preg_match('/\s*INSERT|UPDATE|REPLACE|DELETE\s+/i',$query) )
|
||||
{
|
||||
$output.= "\n".'(affected rows : ';
|
||||
$output.= mysql_affected_rows().' )';
|
||||
}
|
||||
$output.= "</pre>\n";
|
||||
|
||||
$debug .= $output;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function pwg_db_changes($result)
|
||||
{
|
||||
return mysql_affected_rows($result);
|
||||
}
|
||||
|
||||
function pwg_db_num_rows($result)
|
||||
{
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function pwg_db_fetch_assoc($result)
|
||||
{
|
||||
return mysql_fetch_assoc($result);
|
||||
}
|
||||
|
||||
function pwg_db_fetch_row($result)
|
||||
{
|
||||
return mysql_fetch_row($result);
|
||||
}
|
||||
|
||||
function pwg_db_fetch_object($result)
|
||||
{
|
||||
return mysql_fetch_object($result);
|
||||
}
|
||||
|
||||
function pwg_free_result($result)
|
||||
{
|
||||
return mysql_free_result($result);
|
||||
}
|
||||
|
||||
function pwg_db_real_escape_string($s)
|
||||
{
|
||||
return mysql_real_escape_string($s);
|
||||
}
|
||||
|
||||
function pwg_db_insert_id()
|
||||
{
|
||||
return mysql_insert_id();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* complex functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* creates an array based on a query, this function is a very common pattern
|
||||
* used here
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $fieldname
|
||||
* @return array
|
||||
*/
|
||||
function array_from_query($query, $fieldname)
|
||||
{
|
||||
$array = array();
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
array_push($array, $row[$fieldname]);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
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 = pwg_db_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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) = pwg_db_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 .= ')';
|
||||
}
|
||||
Log::getInstance()->debug($query);
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = pwg_db_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 = pwg_db_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')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// my_error returns (or send to standard output) the message concerning the
|
||||
// error occured for the last mysql query.
|
||||
function my_error($header, $die)
|
||||
{
|
||||
$error = "[mysql error ".mysql_errno().'] '.mysql_error()."\n";
|
||||
$error .= $header;
|
||||
|
||||
if ($die)
|
||||
{
|
||||
fatal_error($error);
|
||||
}
|
||||
echo("<pre>");
|
||||
trigger_error($error, E_USER_WARNING);
|
||||
echo("</pre>");
|
||||
}
|
||||
|
||||
?>
|
|
@ -44,7 +44,7 @@ function get_enums($table, $field)
|
|||
// retrieving the properties of the table. Each line represents a field :
|
||||
// columns are 'Field', 'Type'
|
||||
$result = pwg_query('desc '.$table);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
// we are only interested in the the field given in parameter for the
|
||||
// function
|
||||
|
@ -59,7 +59,7 @@ function get_enums($table, $field)
|
|||
}
|
||||
}
|
||||
}
|
||||
mysql_free_result($result);
|
||||
pwg_db_free_result($result);
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
@ -596,54 +596,6 @@ function format_date($date, $show_time = false)
|
|||
return $formated_date;
|
||||
}
|
||||
|
||||
function pwg_query($query)
|
||||
{
|
||||
global $conf,$page,$debug,$t2;
|
||||
|
||||
$start = get_moment();
|
||||
($result = mysql_query($query)) or my_error($query, $conf['die_on_sql_error']);
|
||||
|
||||
$time = get_moment() - $start;
|
||||
|
||||
if (!isset($page['count_queries']))
|
||||
{
|
||||
$page['count_queries'] = 0;
|
||||
$page['queries_time'] = 0;
|
||||
}
|
||||
|
||||
$page['count_queries']++;
|
||||
$page['queries_time']+= $time;
|
||||
|
||||
if ($conf['show_queries'])
|
||||
{
|
||||
$output = '';
|
||||
$output.= '<pre>['.$page['count_queries'].'] ';
|
||||
$output.= "\n".$query;
|
||||
$output.= "\n".'(this query time : ';
|
||||
$output.= '<b>'.number_format($time, 3, '.', ' ').' s)</b>';
|
||||
$output.= "\n".'(total SQL time : ';
|
||||
$output.= number_format($page['queries_time'], 3, '.', ' ').' s)';
|
||||
$output.= "\n".'(total time : ';
|
||||
$output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
|
||||
if ( $result!=null and preg_match('/\s*SELECT\s+/i',$query) )
|
||||
{
|
||||
$output.= "\n".'(num rows : ';
|
||||
$output.= mysql_num_rows($result).' )';
|
||||
}
|
||||
elseif ( $result!=null
|
||||
and preg_match('/\s*INSERT|UPDATE|REPLACE|DELETE\s+/i',$query) )
|
||||
{
|
||||
$output.= "\n".'(affected rows : ';
|
||||
$output.= mysql_affected_rows().' )';
|
||||
}
|
||||
$output.= "</pre>\n";
|
||||
|
||||
$debug .= $output;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function pwg_debug( $string )
|
||||
{
|
||||
global $debug,$t2,$page;
|
||||
|
@ -905,44 +857,6 @@ function get_thumbnail_title($element_info)
|
|||
return $thumbnail_title;
|
||||
}
|
||||
|
||||
// my_error returns (or send to standard output) the message concerning the
|
||||
// error occured for the last mysql query.
|
||||
function my_error($header, $die)
|
||||
{
|
||||
$error = "[mysql error ".mysql_errno().'] '.mysql_error()."\n";
|
||||
$error .= $header;
|
||||
|
||||
if ($die)
|
||||
{
|
||||
fatal_error($error);
|
||||
}
|
||||
echo("<pre>");
|
||||
trigger_error($error, E_USER_WARNING);
|
||||
echo("</pre>");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* creates an array based on a query, this function is a very common pattern
|
||||
* used here
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $fieldname
|
||||
* @return array
|
||||
*/
|
||||
function array_from_query($query, $fieldname)
|
||||
{
|
||||
$array = array();
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
{
|
||||
array_push($array, $row[$fieldname]);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* fill the current user caddie with given elements, if not already in
|
||||
* caddie
|
||||
|
@ -1121,7 +1035,7 @@ SELECT '.$conf['user_fields']['email'].'
|
|||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
|
||||
;';
|
||||
list($email) = mysql_fetch_row(pwg_query($query));
|
||||
list($email) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
return $email;
|
||||
}
|
||||
|
@ -1142,12 +1056,12 @@ SELECT param, value
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
if ((mysql_num_rows($result) == 0) and !empty($condition))
|
||||
if ((pwg_db_num_rows($result) == 0) and !empty($condition))
|
||||
{
|
||||
fatal_error('No configuration data');
|
||||
}
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
|
||||
|
||||
|
@ -1192,7 +1106,7 @@ function simple_hash_from_query($query, $keyname, $valuename)
|
|||
$array = array();
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$array[ $row[$keyname] ] = $row[$valuename];
|
||||
}
|
||||
|
@ -1213,7 +1127,7 @@ function hash_from_query($query, $keyname)
|
|||
{
|
||||
$array = array();
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$array[ $row[$keyname] ] = $row;
|
||||
}
|
||||
|
@ -1584,7 +1498,7 @@ function get_icon($date, $is_child_date = false)
|
|||
{
|
||||
// Use MySql date in order to standardize all recent "actions/queries"
|
||||
list($cache['get_icon']['sql_recent_date']) =
|
||||
mysql_fetch_row(pwg_query('select SUBDATE(
|
||||
pwg_db_fetch_row(pwg_query('select SUBDATE(
|
||||
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ WHERE '.$where.'
|
|||
$result = pwg_query($query);
|
||||
$cats = array();
|
||||
$selected_category = isset($page['category']) ? $page['category'] : null;
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$child_date_last = @$row['max_date_last']> @$row['date_last'];
|
||||
$row = array_merge($row,
|
||||
|
@ -165,7 +165,7 @@ SELECT *
|
|||
FROM '.CATEGORIES_TABLE.'
|
||||
WHERE id = '.$id.'
|
||||
;';
|
||||
$cat = mysql_fetch_assoc(pwg_query($query));
|
||||
$cat = pwg_db_fetch_assoc(pwg_query($query));
|
||||
if (empty($cat))
|
||||
return null;
|
||||
|
||||
|
@ -240,7 +240,7 @@ function get_local_dir( $category_id )
|
|||
$query = 'SELECT uppercats';
|
||||
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id;
|
||||
$query.= ';';
|
||||
$row = mysql_fetch_assoc( pwg_query( $query ) );
|
||||
$row = pwg_db_fetch_assoc( pwg_query( $query ) );
|
||||
$uppercats = $row['uppercats'];
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ function get_local_dir( $category_id )
|
|||
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$uppercats.')';
|
||||
$query.= ';';
|
||||
$result = pwg_query( $query );
|
||||
while( $row = mysql_fetch_assoc( $result ) )
|
||||
while( $row = pwg_db_fetch_assoc( $result ) )
|
||||
{
|
||||
$database_dirs[$row['id']] = $row['dir'];
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ SELECT galleries_url
|
|||
WHERE s.id = c.site_id
|
||||
AND c.id = '.$category_id.'
|
||||
;';
|
||||
$row = mysql_fetch_assoc(pwg_query($query));
|
||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
return $row['galleries_url'];
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ function display_select_cat_wrapper($query, $selecteds, $blockname,
|
|||
$categories = array();
|
||||
if (!empty($result))
|
||||
{
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($categories, $row);
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ SELECT DISTINCT(id)
|
|||
$result = pwg_query($query);
|
||||
|
||||
$subcats = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($subcats, $row['id']);
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ WHERE
|
|||
).'
|
||||
LIMIT 1';
|
||||
|
||||
$show_link = mysql_num_rows(pwg_query($query)) <> 0;
|
||||
$show_link = pwg_db_num_rows(pwg_query($query)) <> 0;
|
||||
}
|
||||
}
|
||||
if ($show_link)
|
||||
|
|
|
@ -100,7 +100,7 @@ function insert_user_comment( &$comm, $key, &$infos )
|
|||
SELECT COUNT(*) AS user_exists
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."'";
|
||||
$row = mysql_fetch_assoc( pwg_query( $query ) );
|
||||
$row = pwg_db_fetch_assoc( pwg_query( $query ) );
|
||||
if ( $row['user_exists'] == 1 )
|
||||
{
|
||||
array_push($infos, l10n('comment_user_exists') );
|
||||
|
@ -138,7 +138,7 @@ SELECT COUNT(*) AS user_exists
|
|||
SELECT id FROM '.COMMENTS_TABLE.'
|
||||
WHERE date > FROM_UNIXTIME('.$reference_date.')
|
||||
AND author_id = '.$comm['author_id'];
|
||||
if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
|
||||
if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
|
||||
{
|
||||
array_push( $infos, l10n('comment_anti-flood') );
|
||||
$comment_action='reject';
|
||||
|
@ -168,7 +168,7 @@ INSERT INTO '.COMMENTS_TABLE.'
|
|||
|
||||
pwg_query($query);
|
||||
|
||||
$comm['id'] = mysql_insert_id();
|
||||
$comm['id'] = pwg_db_insert_id();
|
||||
|
||||
if (($comment_action=='validate' and $conf['email_admin_on_comment']) or
|
||||
($comment_action!='validate' and $conf['email_admin_on_comment_validation']))
|
||||
|
@ -266,7 +266,7 @@ function update_user_comment($comment, $post_key)
|
|||
SELECT id FROM '.COMMENTS_TABLE.'
|
||||
WHERE date > FROM_UNIXTIME('.$reference_date.')
|
||||
AND author_id = '.$comm['author_id'];
|
||||
if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
|
||||
if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
|
||||
{
|
||||
//?? array_push( $infos, l10n('comment_anti-flood') );
|
||||
$comment_action='reject';
|
||||
|
|
|
@ -351,7 +351,7 @@ order by
|
|||
$datas = pwg_query($query);
|
||||
if (!empty($datas))
|
||||
{
|
||||
while ($admin = mysql_fetch_assoc($datas))
|
||||
while ($admin = pwg_db_fetch_assoc($datas))
|
||||
{
|
||||
if (!empty($admin['mail_address']))
|
||||
{
|
||||
|
@ -447,10 +447,10 @@ WHERE
|
|||
|
||||
$result = pwg_query($query);
|
||||
|
||||
if (mysql_num_rows($result) > 0)
|
||||
if (pwg_db_num_rows($result) > 0)
|
||||
{
|
||||
$list = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['template_theme'] = $row['template'];
|
||||
list($row['template'], $row['theme']) = explode('/', $row['template_theme']);
|
||||
|
@ -476,10 +476,10 @@ WHERE
|
|||
|
||||
$result = pwg_query($query);
|
||||
|
||||
if (mysql_num_rows($result) > 0)
|
||||
if (pwg_db_num_rows($result) > 0)
|
||||
{
|
||||
$Bcc = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if (!empty($row['mail_address']))
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ function custom_notification_query($action, $type, $start, $end)
|
|||
}
|
||||
$query = 'SELECT count(distinct '.$field_id.') as CountId
|
||||
'.$query;
|
||||
list($count) = mysql_fetch_row(pwg_query($query));
|
||||
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||
return $count;
|
||||
|
||||
break;
|
||||
|
@ -178,7 +178,7 @@ function custom_notification_query($action, $type, $start, $end)
|
|||
|
||||
$infos = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($infos, $row);
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ SELECT date_available,
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
$dates = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($dates, $row);
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ SELECT DISTINCT id, path, name, tn_ext, file
|
|||
;';
|
||||
$dates[$i]['elements'] = array();
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($dates[$i]['elements'], $row);
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
|
|||
;';
|
||||
$dates[$i]['categories'] = array();
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($dates[$i]['categories'], $row);
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ SELECT * FROM '.PLUGINS_TABLE;
|
|||
|
||||
$result = pwg_query($query);
|
||||
$plugins = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($plugins, $row);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ SELECT COUNT(rate) AS count
|
|||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$image_id.'
|
||||
;';
|
||||
$row = mysql_fetch_assoc(pwg_query($query));
|
||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
$query = '
|
||||
UPDATE '.IMAGES_TABLE.'
|
||||
SET average_rate = '.$row['average'].'
|
||||
|
|
|
@ -41,7 +41,7 @@ SELECT rules
|
|||
FROM '.SEARCH_TABLE.'
|
||||
WHERE id = '.$search_id.'
|
||||
;';
|
||||
list($serialized_rules) = mysql_fetch_row(pwg_query($query));
|
||||
list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
return unserialize($serialized_rules);
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ SELECT i.id,
|
|||
|
||||
$by_weights=array();
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{ // weight is important when sorting images by relevance
|
||||
if ($row['weight'])
|
||||
{
|
||||
|
@ -489,7 +489,7 @@ SELECT image_id, COUNT(tag_id) AS weight
|
|||
WHERE tag_id IN ('.implode(',',array_keys($tags)).')
|
||||
GROUP BY image_id';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{ // weight is important when sorting images by relevance
|
||||
$image_id=(int)$row['image_id'];
|
||||
@$by_weights[$image_id] += $row['weight'];
|
||||
|
@ -510,7 +510,7 @@ SELECT id, name, permalink, nb_images
|
|||
array( 'visible_categories' => 'cat_id' ), "\n AND"
|
||||
);
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{ // weight is important when sorting images by relevance
|
||||
if ($row['nb_images']==0)
|
||||
{
|
||||
|
|
|
@ -121,7 +121,7 @@ SELECT data
|
|||
$result = pwg_query($query);
|
||||
if ($result)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$row = pwg_db_fetch_assoc($result);
|
||||
return $row['data'];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -63,7 +63,7 @@ SELECT *
|
|||
FROM '.TAGS_TABLE;
|
||||
$result = pwg_query($query);
|
||||
$tags = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$counter = @$tag_counters[ $row['id'] ];
|
||||
if ( $counter )
|
||||
|
@ -88,7 +88,7 @@ SELECT *
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
$tags = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($tags, $row);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ SELECT t.*, count(*) counter
|
|||
|
||||
$result = pwg_query($query);
|
||||
$tags = array();
|
||||
while($row = mysql_fetch_assoc($result))
|
||||
while($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($tags, $row);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ SELECT *
|
|||
|
||||
$result = pwg_query($query);
|
||||
$tags = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($tags, $row);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ from '.USERS_TABLE.'
|
|||
where upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\')
|
||||
'.(is_numeric($user_id) ? 'and '.$conf['user_fields']['id'].' != \''.$user_id.'\'' : '').'
|
||||
;';
|
||||
list($count) = mysql_fetch_row(pwg_query($query));
|
||||
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||
if ($count != 0)
|
||||
{
|
||||
return l10n('reg_err_mail_address_dbl');
|
||||
|
@ -110,12 +110,12 @@ function register_user($login, $password, $mail_address,
|
|||
SELECT MAX('.$conf['user_fields']['id'].') + 1
|
||||
FROM '.USERS_TABLE.'
|
||||
;';
|
||||
list($next_id) = mysql_fetch_row(pwg_query($query));
|
||||
list($next_id) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$insert =
|
||||
array(
|
||||
$conf['user_fields']['id'] => $next_id,
|
||||
$conf['user_fields']['username'] => mysql_real_escape_string($login),
|
||||
$conf['user_fields']['username'] => pwg_db_real_escape_string($login),
|
||||
$conf['user_fields']['password'] => $conf['pass_convert']($password),
|
||||
$conf['user_fields']['email'] => $mail_address
|
||||
);
|
||||
|
@ -134,7 +134,7 @@ SELECT id
|
|||
$result = pwg_query($query);
|
||||
|
||||
$inserts = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push
|
||||
(
|
||||
|
@ -249,7 +249,7 @@ SELECT ';
|
|||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\'';
|
||||
|
||||
$row = mysql_fetch_assoc(pwg_query($query));
|
||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -259,7 +259,7 @@ SELECT ui.*, uc.*
|
|||
ON ui.user_id = uc.user_id
|
||||
WHERE ui.user_id = \''.$user_id.'\'';
|
||||
$result = pwg_query($query);
|
||||
if (mysql_num_rows($result) > 0)
|
||||
if (pwg_db_num_rows($result) > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ SELECT ui.*, uc.*
|
|||
}
|
||||
}
|
||||
|
||||
$row = array_merge($row, mysql_fetch_assoc($result));
|
||||
$row = array_merge($row, pwg_db_fetch_assoc($result));
|
||||
|
||||
foreach ($row as $key => $value)
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ SELECT COUNT(DISTINCT(image_id)) as total
|
|||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
WHERE category_id NOT IN ('.$userdata['forbidden_categories'].')
|
||||
AND image_id '.$userdata['image_access_type'].' ('.$userdata['image_access_list'].')';
|
||||
list($userdata['nb_total_images']) = mysql_fetch_row(pwg_query($query));
|
||||
list($userdata['nb_total_images']) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
|
||||
// now we update user cache categories
|
||||
|
@ -428,7 +428,7 @@ SELECT DISTINCT f.image_id
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
$authorizeds = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($authorizeds, $row['image_id']);
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ SELECT image_id
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
$favorites = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($favorites, $row['image_id']);
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ SELECT id
|
|||
WHERE status = \'private\'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($private_array, $row['id']);
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ SELECT id
|
|||
WHERE visible = \'false\'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($forbidden_array, $row['id']);
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ FROM '.CATEGORIES_TABLE.' as c
|
|||
$result = pwg_query($query);
|
||||
|
||||
$cats = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['user_id'] = $userdata['id'];
|
||||
$row['count_categories'] = 0;
|
||||
|
@ -692,7 +692,7 @@ function get_userid($username)
|
|||
{
|
||||
global $conf;
|
||||
|
||||
$username = mysql_real_escape_string($username);
|
||||
$username = pwg_db_real_escape_string($username);
|
||||
|
||||
$query = '
|
||||
SELECT '.$conf['user_fields']['id'].'
|
||||
|
@ -701,13 +701,13 @@ SELECT '.$conf['user_fields']['id'].'
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
if (mysql_num_rows($result) == 0)
|
||||
if (pwg_db_num_rows($result) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
list($user_id) = mysql_fetch_row($result);
|
||||
list($user_id) = pwg_db_fetch_row($result);
|
||||
return $user_id;
|
||||
}
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ SELECT COUNT(*)
|
|||
FROM '.USER_FEED_TABLE.'
|
||||
WHERE id = \''.$key.'\'
|
||||
;';
|
||||
list($count) = mysql_fetch_row(pwg_query($query));
|
||||
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||
if (0 == $count)
|
||||
{
|
||||
return $key;
|
||||
|
@ -750,7 +750,7 @@ function get_default_user_info($convert_str = true)
|
|||
' WHERE user_id = '.$conf['default_user_id'].';';
|
||||
|
||||
$result = pwg_query($query);
|
||||
$cache['default_user'] = mysql_fetch_assoc($result);
|
||||
$cache['default_user'] = pwg_db_fetch_assoc($result);
|
||||
|
||||
if ($cache['default_user'] !== false)
|
||||
{
|
||||
|
@ -865,7 +865,7 @@ function create_user_infos($arg_id, $override_values = null)
|
|||
if (!empty($user_ids))
|
||||
{
|
||||
$inserts = array();
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
||||
|
||||
$default_user = get_default_user_info(false);
|
||||
if ($default_user === false)
|
||||
|
@ -930,9 +930,9 @@ SELECT '.$conf['user_fields']['username'].' AS username
|
|||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = '.$user_id;
|
||||
$result = pwg_query($query);
|
||||
if (mysql_num_rows($result) > 0)
|
||||
if (pwg_db_num_rows($result) > 0)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$row = pwg_db_fetch_assoc($result);
|
||||
$username = stripslashes($row['username']);
|
||||
$data = $time.stripslashes($row['username']).$row['password'];
|
||||
$key = base64_encode(
|
||||
|
@ -1041,7 +1041,7 @@ SELECT '.$conf['user_fields']['id'].' AS id,
|
|||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['username'].' = \''.mysql_real_escape_string($username).'\'
|
||||
;';
|
||||
$row = mysql_fetch_assoc(pwg_query($query));
|
||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
if ($row['password'] == $conf['pass_convert']($password))
|
||||
{
|
||||
log_user($row['id'], $remember_me);
|
||||
|
|
|
@ -93,7 +93,7 @@ if ($page['show_comments'])
|
|||
SELECT COUNT(*) AS nb_comments
|
||||
FROM '.COMMENTS_TABLE.'
|
||||
WHERE image_id='.$page['image_id']." AND validated = 'true'";
|
||||
$row = mysql_fetch_assoc( pwg_query( $query ) );
|
||||
$row = pwg_db_fetch_assoc( pwg_query( $query ) );
|
||||
|
||||
// navigation bar creation
|
||||
if (!isset($page['start']))
|
||||
|
@ -140,7 +140,7 @@ $validated_clause.'
|
|||
;';
|
||||
$result = pwg_query( $query );
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if (!empty($row['author']))
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ SELECT COUNT(rate) AS count
|
|||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$picture['current']['id'].'
|
||||
;';
|
||||
$row = mysql_fetch_assoc(pwg_query($query));
|
||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
}
|
||||
else
|
||||
{ // avg rate null -> no rate -> no need to query db
|
||||
|
@ -67,9 +67,9 @@ SELECT COUNT(rate) AS count
|
|||
}
|
||||
|
||||
$result = pwg_query($query);
|
||||
if (mysql_num_rows($result) > 0)
|
||||
if (pwg_db_num_rows($result) > 0)
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$row = pwg_db_fetch_assoc($result);
|
||||
$user_rate = $row['rate'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ SELECT id, name, permalink, image_order
|
|||
AND ', $where_clauses);
|
||||
$result = pwg_query($query);
|
||||
$cats = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['id'] = (int)$row['id'];
|
||||
$cats[ $row['id'] ] = $row;
|
||||
|
@ -295,7 +295,7 @@ GROUP BY i.id
|
|||
LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page'];
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$image = array();
|
||||
foreach ( array('id', 'width', 'height', 'hit') as $k )
|
||||
|
@ -405,7 +405,7 @@ SELECT id, name, permalink, uppercats, global_rank,
|
|||
$result = pwg_query($query);
|
||||
|
||||
$cats = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['url'] = make_index_url(
|
||||
array(
|
||||
|
@ -471,7 +471,7 @@ SELECT
|
|||
$result = pwg_query($query);
|
||||
$cats = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$id = $row['id'];
|
||||
$row['nb_images'] = isset($nb_images_of[$id]) ? $nb_images_of[$id] : 0;
|
||||
|
@ -517,7 +517,7 @@ SELECT DISTINCT image_id
|
|||
),
|
||||
' AND'
|
||||
);
|
||||
if ( !mysql_num_rows( pwg_query( $query ) ) )
|
||||
if ( !pwg_db_num_rows( pwg_query( $query ) ) )
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ SELECT * FROM '.IMAGES_TABLE.'
|
|||
).'
|
||||
LIMIT 1';
|
||||
|
||||
$image_row = mysql_fetch_assoc(pwg_query($query));
|
||||
$image_row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
if ($image_row==null)
|
||||
{
|
||||
return new PwgError(404, "image_id not found");
|
||||
|
@ -598,7 +598,7 @@ SELECT id, name, permalink, uppercats, global_rank, commentable
|
|||
$result = pwg_query($query);
|
||||
$is_commentable = false;
|
||||
$related_categories = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if ($row['commentable']=='true')
|
||||
{
|
||||
|
@ -655,7 +655,7 @@ SELECT COUNT(rate) AS count
|
|||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$image_row['id'].'
|
||||
;';
|
||||
$rating = mysql_fetch_assoc(pwg_query($query));
|
||||
$rating = pwg_db_fetch_assoc(pwg_query($query));
|
||||
$rating['count'] = (int)$rating['count'];
|
||||
|
||||
//---------------------------------------------------------- related comments
|
||||
|
@ -686,7 +686,7 @@ SELECT id, date, author, content
|
|||
','.(int)$params['comments_per_page'];
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['id']=(int)$row['id'];
|
||||
array_push($related_comments, $row);
|
||||
|
@ -757,7 +757,7 @@ SELECT DISTINCT id FROM '.IMAGES_TABLE.'
|
|||
' AND'
|
||||
).'
|
||||
LIMIT 1';
|
||||
if ( mysql_num_rows( pwg_query($query) )==0 )
|
||||
if ( pwg_db_num_rows( pwg_query($query) )==0 )
|
||||
{
|
||||
return new PwgError(404, "Invalid image_id or access denied" );
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ SELECT * FROM '.IMAGES_TABLE.'
|
|||
|
||||
$image_ids = array_flip($image_ids);
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$image = array();
|
||||
foreach ( array('id', 'width', 'height', 'hit') as $k )
|
||||
|
@ -870,7 +870,7 @@ UPDATE '.IMAGES_TABLE.'
|
|||
SET level='.(int)$params['level'].'
|
||||
WHERE id IN ('.implode(',',$params['image_id']).')';
|
||||
$result = pwg_query($query);
|
||||
$affected_rows = mysql_affected_rows();
|
||||
$affected_rows = pwg_db_affected_rows();
|
||||
if ($affected_rows)
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
@ -1007,13 +1007,13 @@ SELECT
|
|||
FROM '.IMAGES_TABLE.'
|
||||
WHERE md5sum = \''.$params['original_sum'].'\'
|
||||
;';
|
||||
list($counter) = mysql_fetch_row(pwg_query($query));
|
||||
list($counter) = pwg_db_fetch_row(pwg_query($query));
|
||||
if ($counter != 0) {
|
||||
return new PwgError(500, 'file already exists');
|
||||
}
|
||||
|
||||
// current date
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
|
||||
|
||||
// upload directory hierarchy
|
||||
|
@ -1199,7 +1199,7 @@ SELECT
|
|||
array($insert)
|
||||
);
|
||||
|
||||
$image_id = mysql_insert_id();
|
||||
$image_id = pwg_db_insert_id();
|
||||
|
||||
// let's add links between the image and the categories
|
||||
if (isset($params['categories']))
|
||||
|
@ -1358,7 +1358,7 @@ SELECT image_id, GROUP_CONCAT(tag_id) tag_ids
|
|||
WHERE tag_id IN ('.implode(',',$tag_ids).')
|
||||
GROUP BY image_id';
|
||||
$result = pwg_query($query);
|
||||
while ( $row=mysql_fetch_assoc($result) )
|
||||
while ( $row=pwg_db_fetch_assoc($result) )
|
||||
{
|
||||
$row['image_id'] = (int)$row['image_id'];
|
||||
array_push( $image_ids, $row['image_id'] );
|
||||
|
@ -1401,7 +1401,7 @@ SELECT DISTINCT i.* FROM '.IMAGES_TABLE.' i
|
|||
LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page'];
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$image = array();
|
||||
foreach ( array('id', 'width', 'height', 'hit') as $k )
|
||||
|
@ -1572,7 +1572,7 @@ SELECT *
|
|||
WHERE id = '.$params['image_id'].'
|
||||
;';
|
||||
|
||||
$image_row = mysql_fetch_assoc(pwg_query($query));
|
||||
$image_row = pwg_db_fetch_assoc(pwg_query($query));
|
||||
if ($image_row == null)
|
||||
{
|
||||
return new PwgError(404, "image_id not found");
|
||||
|
|
|
@ -364,7 +364,7 @@ define(\'DB_COLLATE\', \'\');
|
|||
// Available upgrades must be ignored after a fresh installation. To
|
||||
// make PWG avoid upgrading, we must tell it upgrades have already been
|
||||
// made.
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
||||
define('CURRENT_DATE', $dbnow);
|
||||
$datas = array();
|
||||
foreach (get_available_upgrade_ids() as $upgrade_id)
|
||||
|
|
|
@ -32,7 +32,7 @@ $upgrade_description = 'Just a beginning test';
|
|||
// | Upgrade content |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
list($now) = mysql_fetch_row(pwg_query('SELECT NOW()'));
|
||||
list($now) = pwg_db_fetch_row(pwg_query('SELECT NOW()'));
|
||||
echo
|
||||
$now
|
||||
."\n"
|
||||
|
|
|
@ -66,7 +66,7 @@ $result = pwg_query($query);
|
|||
|
||||
$datas = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push(
|
||||
$datas,
|
||||
|
|
|
@ -47,7 +47,7 @@ $result = pwg_query($query);
|
|||
|
||||
$datas = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push(
|
||||
$datas,
|
||||
|
|
|
@ -68,7 +68,7 @@ SELECT id, keywords
|
|||
WHERE keywords IS NOT NULL
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
foreach(preg_split('/[,]+/', $row['keywords']) as $keyword)
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ SELECT category_id, image_id
|
|||
$result = pwg_query($query);
|
||||
|
||||
$datas = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push(
|
||||
$datas,
|
||||
|
|
|
@ -108,7 +108,7 @@ if ( !defined('PWG_CHARSET') )
|
|||
SELECT language, COUNT(user_id) AS count FROM '.USER_INFOS_TABLE.'
|
||||
GROUP BY language';
|
||||
$result = pwg_query($query);
|
||||
while ( $row=mysql_fetch_assoc($result) )
|
||||
while ( $row=pwg_db_fetch_assoc($result) )
|
||||
{
|
||||
$language = $row["language"];
|
||||
$lang_def = explode('.', $language);
|
||||
|
@ -141,7 +141,7 @@ SELECT language, COUNT(user_id) AS count FROM '.USER_INFOS_TABLE.'
|
|||
SELECT language FROM '.USER_INFOS_TABLE.'
|
||||
WHERE user_id='.$conf['webmaster_id'];
|
||||
$result = pwg_query($query);
|
||||
if (mysql_num_rows($result)==0)
|
||||
if (pwg_db_num_rows($result)==0)
|
||||
{
|
||||
$query='
|
||||
SELECT language FROM '.USER_INFOS_TABLE.'
|
||||
|
@ -150,7 +150,7 @@ SELECT language FROM '.USER_INFOS_TABLE.'
|
|||
$result = pwg_query($query);
|
||||
}
|
||||
|
||||
if ( $row=mysql_fetch_assoc($result) )
|
||||
if ( $row=pwg_db_fetch_assoc($result) )
|
||||
{
|
||||
$admin_charset = $all_langs[$row['language']]['charset'];
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ SELECT language FROM '.USER_INFOS_TABLE.'
|
|||
$all_tables = array();
|
||||
$query = 'SHOW TABLES LIKE "'.$prefixeTable.'%"';
|
||||
$result = pwg_query($query);
|
||||
while ( $row=mysql_fetch_assoc($result) )
|
||||
while ( $row=pwg_db_fetch_assoc($result) )
|
||||
{
|
||||
array_push($all_tables, $row[0]);
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ SELECT language FROM '.USER_INFOS_TABLE.'
|
|||
$query = 'SHOW FULL COLUMNS FROM '.$table;
|
||||
$result = pwg_query($query);
|
||||
$field_definitions=array();
|
||||
while ( $row=mysql_fetch_assoc($result) )
|
||||
while ( $row=pwg_db_fetch_assoc($result) )
|
||||
{
|
||||
if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
|
||||
continue;
|
||||
|
|
|
@ -60,7 +60,7 @@ $conf = $conf_save;
|
|||
// +-Do I already have them in DB ?----------------------------------------+
|
||||
$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
unset( $params[ $row['param'] ] );
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ $result = pwg_query($query);
|
|||
|
||||
$datas = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push(
|
||||
$datas,
|
||||
|
|
|
@ -84,7 +84,7 @@ SELECT id, id_uppercat
|
|||
FROM '.CATEGORIES_TABLE.'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ $query = '
|
|||
SELECT prefix_thumbnail, mail_webmaster
|
||||
FROM '.PREFIX_TABLE.'config
|
||||
;';
|
||||
$save = mysql_fetch_assoc(pwg_query($query));
|
||||
$save = pwg_db_fetch_assoc(pwg_query($query));
|
||||
|
||||
$queries = array(
|
||||
"
|
||||
|
@ -344,7 +344,7 @@ SHOW INDEX
|
|||
FROM '.PREFIX_TABLE.$table.'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if ($row['Key_name'] != 'PRIMARY')
|
||||
{
|
||||
|
@ -536,7 +536,7 @@ SELECT DISTINCT(storage_category_id) AS unique_storage_category_id
|
|||
FROM '.IMAGES_TABLE.'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($cat_ids, $row['unique_storage_category_id']);
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ SELECT id
|
|||
WHERE status = \'private\'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($cat_ids, $row['id']);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ SELECT value
|
|||
FROM '.CONFIG_TABLE.'
|
||||
WHERE param = \'prefix_thumbnail\'
|
||||
;';
|
||||
list($prefix_thumbnail) = mysql_fetch_row(pwg_query($query));
|
||||
list($prefix_thumbnail) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
// delete obsolete configuration
|
||||
$query = '
|
||||
|
@ -191,10 +191,10 @@ SELECT *
|
|||
;';
|
||||
|
||||
$datas = array();
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$row['user_id'] = $row['id'];
|
||||
$row['registration_date'] = $dbnow;
|
||||
|
|
|
@ -79,7 +79,7 @@ SELECT id, keywords
|
|||
WHERE keywords IS NOT NULL
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
foreach(preg_split('/[,]+/', $row['keywords']) as $keyword)
|
||||
{
|
||||
|
@ -351,7 +351,7 @@ $conf = $conf_save;
|
|||
// Do I already have them in DB ?
|
||||
$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
unset( $params[ $row['param'] ] );
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ DESC '.PREFIX_TABLE.'users
|
|||
|
||||
$result = pwg_query($query);
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if (!in_array($row['Field'], $to_keep))
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ else
|
|||
|
||||
define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
|
||||
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
||||
define('CURRENT_DATE', $dbnow);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -56,7 +56,7 @@ if (isset($_POST['submit']))
|
|||
}
|
||||
else if (isset($_POST['mail_address']) and !empty($_POST['mail_address']))
|
||||
{
|
||||
$mail_address = mysql_real_escape_string($_POST['mail_address']);
|
||||
$mail_address = pwg_db_real_escape_string($_POST['mail_address']);
|
||||
|
||||
$query = '
|
||||
SELECT '.$conf['user_fields']['id'].' AS id
|
||||
|
@ -74,12 +74,12 @@ WHERE '
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
if (mysql_num_rows($result) > 0)
|
||||
if (pwg_db_num_rows($result) > 0)
|
||||
{
|
||||
$error_on_mail = false;
|
||||
$datas = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$new_password = generate_key(6);
|
||||
|
||||
|
|
10
picture.php
10
picture.php
|
@ -57,7 +57,7 @@ SELECT id, file, level
|
|||
str_replace(array('_','%'), array('/_','/%'), $page['image_file'] ).
|
||||
'.%" ESCAPE "/" LIMIT 1';
|
||||
}
|
||||
if ( ! ( $row = mysql_fetch_assoc(pwg_query($query)) ) )
|
||||
if ( ! ( $row = pwg_db_fetch_assoc(pwg_query($query)) ) )
|
||||
{// element does not exist
|
||||
page_not_found( 'The requested image does not exist',
|
||||
duplicate_index_url()
|
||||
|
@ -93,7 +93,7 @@ SELECT id
|
|||
" AND"
|
||||
).'
|
||||
LIMIT 1';
|
||||
if ( mysql_num_rows( pwg_query($query) ) == 0 )
|
||||
if ( pwg_db_num_rows( pwg_query($query) ) == 0 )
|
||||
{
|
||||
access_denied();
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ SELECT category_id,uppercats,commentable,global_rank
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
$related_categories = array();
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($related_categories, $row);
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ SELECT *
|
|||
|
||||
$result = pwg_query($query);
|
||||
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
|
||||
{
|
||||
|
@ -767,7 +767,7 @@ SELECT COUNT(*) AS nb_fav
|
|||
AND user_id = '.$user['id'].'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$row = pwg_db_fetch_assoc($result);
|
||||
|
||||
if ($row['nb_fav'] == 0)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ SELECT '.implode(',', $fields).'
|
|||
WHERE user_id = '.$conf['default_user_id'].'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
$default_user = mysql_fetch_assoc($result);
|
||||
$default_user = pwg_db_fetch_assoc($result);
|
||||
$userdata = array_merge($userdata, $default_user);
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ function save_profile_from_post($userdata, &$errors)
|
|||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = \''.$userdata['id'].'\'
|
||||
;';
|
||||
list($current_password) = mysql_fetch_row(pwg_query($query));
|
||||
list($current_password) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
if ($conf['pass_convert']($_POST['password']) != $current_password)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ INSERT INTO '.SEARCH_TABLE.'
|
|||
(\''.addslashes(serialize($search)).'\', NOW() )
|
||||
;';
|
||||
pwg_query($query);
|
||||
$search_id = mysql_insert_id();
|
||||
$search_id = pwg_db_insert_id();
|
||||
}
|
||||
|
||||
redirect(
|
||||
|
|
|
@ -136,7 +136,7 @@ INSERT INTO '.SEARCH_TABLE.'
|
|||
;';
|
||||
pwg_query($query);
|
||||
|
||||
$search_id = mysql_insert_id();
|
||||
$search_id = pwg_db_insert_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -135,7 +135,7 @@ SELECT id, uppercats, global_rank
|
|||
$categories = array();
|
||||
if (!empty($result))
|
||||
{
|
||||
while ($row = mysql_fetch_assoc($result))
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($categories, $row);
|
||||
}
|
||||
|
|
17
upgrade.php
17
upgrade.php
|
@ -43,6 +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');
|
||||
|
||||
prepare_conf_upgrade();
|
||||
|
||||
|
@ -50,13 +51,11 @@ include_once(PHPWG_ROOT_PATH.'include/constants.php');
|
|||
define('PREFIX_TABLE', $prefixeTable);
|
||||
|
||||
// Database connection
|
||||
mysql_connect( $conf['db_host'], $conf['db_user'], $conf['db_password'] ) or die ( "Could not connect to database server" );
|
||||
mysql_select_db( $conf['db_base'] ) or die ( "Could not connect to database" );
|
||||
if ( version_compare(mysql_get_server_info(), '4.1.0', '>=')
|
||||
and defined('DB_CHARSET') and DB_CHARSET!='' )
|
||||
{
|
||||
pwg_query('SET NAMES "'.DB_CHARSET.'"');
|
||||
}
|
||||
$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
|
||||
$conf['db_password'], $conf['db_base'])
|
||||
or my_error('pwg_db_connect', true);
|
||||
|
||||
pwg_db_check_charset();
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
|
@ -76,7 +75,7 @@ SHOW TABLES
|
|||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
while ($row = mysql_fetch_row($result))
|
||||
while ($row = pwg_db_fetch_row($result))
|
||||
{
|
||||
if (preg_match('/^'.PREFIX_TABLE.'/', $row[0]))
|
||||
{
|
||||
|
@ -105,7 +104,7 @@ DESC '.$table.'
|
|||
|
||||
$columns_of[$table] = array();
|
||||
|
||||
while ($row = mysql_fetch_row($result))
|
||||
while ($row = pwg_db_fetch_row($result))
|
||||
{
|
||||
array_push($columns_of[$table], $row[0]);
|
||||
}
|
||||
|
|
|
@ -35,6 +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');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Check Access and exit when it is not ok |
|
||||
|
@ -54,14 +55,11 @@ define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
|
|||
// | Database connection |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
mysql_connect($conf['db_host'], $conf['db_user'], $conf['db_password']) or die("Could not connect to database server");
|
||||
mysql_select_db($conf['db_base']) or die("Could not connect to database");
|
||||
if ( version_compare(mysql_get_server_info(), '4.1.0', '>=')
|
||||
and defined('DB_CHARSET') and DB_CHARSET!='' )
|
||||
{
|
||||
pwg_query('SET NAMES "'.DB_CHARSET.'"');
|
||||
}
|
||||
$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
|
||||
$conf['db_password'], $conf['db_base'])
|
||||
or my_error('pwg_db_connect', true);
|
||||
|
||||
pwg_db_check_charset();
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Upgrades |
|
||||
|
|
|
@ -248,7 +248,7 @@ if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) )
|
|||
$query.= ",'".$_POST['mail_address']."',".time().",'".$xml_infos."')";
|
||||
$query.= ';';
|
||||
pwg_query( $query );
|
||||
$page['waiting_id'] = mysql_insert_id();
|
||||
$page['waiting_id'] = pwg_db_insert_id();
|
||||
|
||||
if ($conf['email_admin_on_picture_uploaded'])
|
||||
{
|
||||
|
@ -288,7 +288,7 @@ if ( isset( $_POST['submit'] ) and isset( $_GET['waiting_id'] ) )
|
|||
$query.= ' where id = '.$_GET['waiting_id'];
|
||||
$query.= ';';
|
||||
$result= pwg_query( $query );
|
||||
$row = mysql_fetch_assoc( $result );
|
||||
$row = pwg_db_fetch_assoc( $result );
|
||||
$file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
|
||||
$extension = get_extension( $_FILES['picture']['name'] );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue