Changeset 4325


Ignore:
Timestamp:
Nov 20, 2009, 3:17:04 PM (14 years ago)
Author:
nikrou
Message:

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 { }.

Location:
trunk
Files:
2 added
77 edited

Legend:

Unmodified
Added
Removed
  • trunk/action.php

    r3282 r4325  
    7272
    7373$result = pwg_query($query);
    74 $element_info = mysql_fetch_assoc($result);
     74$element_info = pwg_db_fetch_assoc($result);
    7575if ( empty($element_info) )
    7676{
     
    9494  LIMIT 1
    9595;';
    96 if ( mysql_num_rows(pwg_query($query))<1 )
     96if ( pwg_db_num_rows(pwg_query($query))<1 )
    9797{
    9898  do_error(401, 'Access denied');
  • trunk/admin/cat_list.php

    r3282 r4325  
    120120;';
    121121  $result = pwg_query($query);
    122   while ($row = mysql_fetch_assoc($result))
     122  while ($row = pwg_db_fetch_assoc($result))
    123123  {
    124124    $categories[ $row['id'] ] = strtolower($row['name']);
  • trunk/admin/cat_modify.php

    r4265 r4325  
    194194  WHERE id = '.$_GET['cat_id'].'
    195195;';
    196 $category = mysql_fetch_assoc( pwg_query( $query ) );
     196$category = pwg_db_fetch_assoc( pwg_query( $query ) );
    197197// nullable fields
    198198foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
     
    211211  LIMIT 1';
    212212$result = pwg_query($query);
    213 $category['has_images'] = mysql_num_rows($result)>0 ? true : false;
     213$category['has_images'] = pwg_db_num_rows($result)>0 ? true : false;
    214214
    215215// Navigation path
     
    374374  WHERE id = '.$category['representative_picture_id'].'
    375375;';
    376     $row = mysql_fetch_assoc(pwg_query($query));
     376    $row = pwg_db_fetch_assoc(pwg_query($query));
    377377    $src = get_thumbnail_url($row);
    378378    $url = get_root_url().'admin.php?page=picture_modify';
     
    462462
    463463    $result = pwg_query($query);
    464     if (mysql_num_rows($result) > 0)
     464    if (pwg_db_num_rows($result) > 0)
    465465    {
    466       $element = mysql_fetch_assoc($result);
     466      $element = pwg_db_fetch_assoc($result);
    467467
    468468      $img_url  = '<a href="'.
     
    512512  WHERE id = '.$_POST['group'].'
    513513;';
    514   list($group_name) = mysql_fetch_row(pwg_query($query));
     514  list($group_name) = pwg_db_fetch_row(pwg_query($query));
    515515 
    516516  array_push(
  • trunk/admin/cat_perm.php

    r4265 r4325  
    4646  WHERE id = '.$_GET['cat'].'
    4747;';
    48   list($status) = mysql_fetch_row(pwg_query($query));
     48  list($status) = pwg_db_fetch_row(pwg_query($query));
    4949 
    5050  if ('private' == $status)
     
    6363;';
    6464
    65   list($page['cat']) = mysql_fetch_row(pwg_query($query));
     65  list($page['cat']) = pwg_db_fetch_row(pwg_query($query));
    6666}
    6767
     
    111111;';
    112112  $result = pwg_query($query);
    113   while ($row = mysql_fetch_assoc($result))
     113  while ($row = pwg_db_fetch_assoc($result))
    114114  {
    115115    array_push($granteds[$row['cat_id']], $row['group_id']);
     
    170170;';
    171171  $result = pwg_query($query);
    172   while ($row = mysql_fetch_assoc($result))
     172  while ($row = pwg_db_fetch_assoc($result))
    173173  {
    174174    array_push($granteds[$row['cat_id']], $row['user_id']);
     
    275275';
    276276  $result = pwg_query($query);
    277   while ($row = mysql_fetch_assoc($result))
     277  while ($row = pwg_db_fetch_assoc($result))
    278278  {
    279279    if (!isset($granted_groups[$row['group_id']]))
  • trunk/admin/comments.php

    r4304 r4325  
    146146;';
    147147$result = pwg_query($query);
    148 while ($row = mysql_fetch_assoc($result))
     148while ($row = pwg_db_fetch_assoc($result))
    149149{
    150150  $thumb = get_thumbnail_url(
  • trunk/admin/configuration.php

    r4265 r4325  
    139139    //echo '<pre>'; print_r($_POST); echo '</pre>';
    140140    $result = pwg_query('SELECT param FROM '.CONFIG_TABLE);
    141     while ($row = mysql_fetch_assoc($result))
     141    while ($row = pwg_db_fetch_assoc($result))
    142142    {
    143143      if (isset($_POST[$row['param']]))
  • trunk/admin/element_set.php

    r4265 r4325  
    193193  $query = 'SELECT MAX(date_available) AS date
    194194  FROM '.IMAGES_TABLE;
    195   if ($row = mysql_fetch_assoc( pwg_query($query) ) )
     195  if ($row = pwg_db_fetch_assoc( pwg_query($query) ) )
    196196  {
    197197    $query = 'SELECT id
  • trunk/admin/element_set_global.php

    r4265 r4325  
    246246    $result = pwg_query($query);
    247247
    248     while ($row = mysql_fetch_assoc($result))
     248    while ($row = pwg_db_fetch_assoc($result))
    249249    {
    250250      $data = array();
     
    338338    AND storage_category_id IS NULL
    339339;';
    340   list($counter) = mysql_fetch_row(pwg_query($query));
     340  list($counter) = pwg_db_fetch_row(pwg_query($query));
    341341
    342342  if ($counter > 0)
     
    482482  // template thumbnail initialization
    483483
    484   while ($row = mysql_fetch_assoc($result))
     484  while ($row = pwg_db_fetch_assoc($result))
    485485  {
    486486    $src = get_thumbnail_url($row);
  • trunk/admin/element_set_ranks.php

    r4265 r4325  
    116116  WHERE id = '.$page['category_id'].'
    117117;';
    118 $category = mysql_fetch_assoc(pwg_query($query));
     118$category = pwg_db_fetch_assoc(pwg_query($query));
    119119
    120120// Navigation path
     
    151151$current_rank = 1;
    152152
    153 while ($row = mysql_fetch_assoc($result))
     153while ($row = pwg_db_fetch_assoc($result))
    154154{
    155155  $src = get_thumbnail_url($row);
  • trunk/admin/element_set_unit.php

    r4265 r4325  
    5757  $result = pwg_query($query);
    5858
    59   while ($row = mysql_fetch_assoc($result))
     59  while ($row = pwg_db_fetch_assoc($result))
    6060  {
    6161    $data = array();
     
    201201  $result = pwg_query($query);
    202202
    203   while ($row = mysql_fetch_assoc($result))
     203  while ($row = pwg_db_fetch_assoc($result))
    204204  {
    205205    // echo '<pre>'; print_r($row); echo '</pre>';
  • trunk/admin/group_list.php

    r4265 r4325  
    6161  WHERE id = '.$_GET['delete'].'
    6262;';
    63   list($groupname) = mysql_fetch_row(pwg_query($query));
     63  list($groupname) = pwg_db_fetch_row(pwg_query($query));
    6464 
    6565  // destruction of the group
     
    9595  WHERE name = \''.$_POST['groupname'].'\'
    9696;';
    97     list($count) = mysql_fetch_row(pwg_query($query));
     97    list($count) = pwg_db_fetch_row(pwg_query($query));
    9898    if ($count != 0)
    9999    {
     
    108108  (name)
    109109  VALUES
    110   (\''.mysql_real_escape_string($_POST['groupname']).'\')
     110  (\''.pwg_db_real_escape_string($_POST['groupname']).'\')
    111111;';
    112112    pwg_query($query);
     
    130130  WHERE id = '.$_GET['toggle_is_default'].'
    131131;';
    132   list($groupname, $is_default) = mysql_fetch_row(pwg_query($query));
     132  list($groupname, $is_default) = pwg_db_fetch_row(pwg_query($query));
    133133 
    134134  // update of the group
     
    176176$toggle_is_default_url     = $admin_url.'group_list&amp;toggle_is_default=';
    177177
    178 while ($row = mysql_fetch_assoc($result))
     178while ($row = pwg_db_fetch_assoc($result))
    179179{
    180180  $query = '
     
    183183  WHERE group_id = '.$row['id'].'
    184184;';
    185   list($counter) = mysql_fetch_row(pwg_query($query));
     185  list($counter) = pwg_db_fetch_row(pwg_query($query));
    186186 
    187187  $template->append(
  • trunk/admin/group_perm.php

    r4265 r4325  
    8080;';
    8181  $result = pwg_query($query);
    82   while ($row = mysql_fetch_assoc($result))
     82  while ($row = pwg_db_fetch_assoc($result))
    8383  {
    8484    array_push($private_uppercats, $row['id']);
     
    9797  $result = pwg_query($query);
    9898
    99   while ($row = mysql_fetch_assoc($result))
     99  while ($row = pwg_db_fetch_assoc($result))
    100100  {
    101101    array_push($authorized_ids, $row['cat_id']);
     
    158158$result = pwg_query($query_true);
    159159$authorized_ids = array();
    160 while ($row = mysql_fetch_assoc($result))
     160while ($row = pwg_db_fetch_assoc($result))
    161161{
    162162  array_push($authorized_ids, $row['id']);
  • trunk/admin/history.php

    r4304 r4325  
    111111      '*',
    112112      '%',
    113       mysql_real_escape_string($_POST['filename'])
     113      pwg_db_real_escape_string($_POST['filename'])
    114114      );
    115115  }
     
    137137    pwg_query($query);
    138138
    139     $search_id = mysql_insert_id();
     139    $search_id = pwg_db_insert_id();
    140140
    141141    redirect(
     
    178178  WHERE id = '.$page['search_id'].'
    179179;';
    180   list($serialized_rules) = mysql_fetch_row(pwg_query($query));
     180  list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
    181181
    182182  $page['search'] = unserialize($serialized_rules);
     
    199199    pwg_query($query);
    200200
    201     $search_id = mysql_insert_id();
     201    $search_id = pwg_db_insert_id();
    202202
    203203    redirect(
     
    258258
    259259    $username_of = array();
    260     while ($row = mysql_fetch_assoc($result))
     260    while ($row = pwg_db_fetch_assoc($result))
    261261    {
    262262      $username_of[$row['id']] = stripslashes($row['username']);
     
    306306
    307307    $result = pwg_query($query);
    308     while ($row = mysql_fetch_assoc($result))
     308    while ($row = pwg_db_fetch_assoc($result))
    309309    {
    310310      $label_of_image[ $row['id'] ] = $row['label'];
     
    342342
    343343    $result = pwg_query($query);
    344     while ($row = mysql_fetch_assoc($result))
     344    while ($row = pwg_db_fetch_assoc($result))
    345345    {
    346346      $name_of_tag[ $row['id'] ] = $row['name'];
  • trunk/admin/include/c13y_internal.class.php

    r4304 r4325  
    4343    $check_list[] = array('type' => 'PHP', 'current' => phpversion(), 'required' => REQUIRED_PHP_VERSION);
    4444
    45     list($mysql_version) = mysql_fetch_row(pwg_query('SELECT VERSION();'));
    46     $check_list[] = array('type' => 'MySQL', 'current' => $mysql_version, 'required' => REQUIRED_MYSQL_VERSION);
     45    $db_version = pwg_get_db_version();
     46    $check_list[] = array('type' => 'MySQL', 'current' => $db_version, 'required' => REQUIRED_MYSQL_VERSION);
    4747
    4848    foreach ($check_list as $elem)
     
    127127
    128128    $result = pwg_query($query);
    129     while ($row = mysql_fetch_assoc($result))
     129    while ($row = pwg_db_fetch_assoc($result))
    130130    {
    131131      $status[$row['id']] = $row['status'];
  • trunk/admin/include/functions.php

    r4304 r4325  
    3737  $result = pwg_query($query);
    3838  $category_ids = array();
    39   while ($row = mysql_fetch_assoc($result))
     39  while ($row = pwg_db_fetch_assoc($result))
    4040  {
    4141    array_push($category_ids, $row['id']);
     
    7878  $result = pwg_query($query);
    7979  $element_ids = array();
    80   while ($row = mysql_fetch_assoc($result))
     80  while ($row = pwg_db_fetch_assoc($result))
    8181  {
    8282    array_push($element_ids, $row['id']);
     
    160160;';
    161161    $result = pwg_query($query);
    162     while ($row = mysql_fetch_assoc($result))
     162    while ($row = pwg_db_fetch_assoc($result))
    163163    {
    164164      $file_path = $row['path'];
     
    410410
    411411/**
    412  * inserts multiple lines in a table
    413  *
    414  * @param string table_name
    415  * @param array dbfields
    416  * @param array inserts
    417  * @return void
    418  */
    419 function mass_inserts($table_name, $dbfields, $datas)
    420 {
    421   if (count($datas) != 0)
    422   {
    423     $first = true;
    424 
    425     $query = 'SHOW VARIABLES LIKE \'max_allowed_packet\'';
    426     list(, $packet_size) = mysql_fetch_row(pwg_query($query));
    427     $packet_size = $packet_size - 2000; // The last list of values MUST not exceed 2000 character*/
    428     $query = '';
    429 
    430     foreach ($datas as $insert)
    431     {
    432       if (strlen($query) >= $packet_size)
    433       {
    434         pwg_query($query);
    435         $first = true;
    436       }
    437 
    438       if ($first)
    439       {
    440         $query = '
    441 INSERT INTO '.$table_name.'
    442   ('.implode(',', $dbfields).')
    443   VALUES';
    444         $first = false;
    445       }
    446       else
    447       {
    448         $query .= '
    449   , ';
    450       }
    451 
    452       $query .= '(';
    453       foreach ($dbfields as $field_id => $dbfield)
    454       {
    455         if ($field_id > 0)
    456         {
    457           $query .= ',';
    458         }
    459 
    460         if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
    461         {
    462           $query .= 'NULL';
    463         }
    464         else
    465         {
    466           $query .= "'".$insert[$dbfield]."'";
    467         }
    468       }
    469       $query .= ')';
    470     }
    471     pwg_query($query);
    472   }
    473 }
    474 
    475 define('MASS_UPDATES_SKIP_EMPTY', 1);
    476 /**
    477  * updates multiple lines in a table
    478  *
    479  * @param string table_name
    480  * @param array dbfields
    481  * @param array datas
    482  * @param int flags - if MASS_UPDATES_SKIP_EMPTY - empty values do not overwrite existing ones
    483  * @return void
    484  */
    485 function mass_updates($tablename, $dbfields, $datas, $flags=0)
    486 {
    487   if (count($datas) == 0)
    488     return;
    489   // depending on the MySQL version, we use the multi table update or N update queries
    490   if (count($datas) < 10 or version_compare(mysql_get_server_info(), '4.0.4') < 0)
    491   { // MySQL is prior to version 4.0.4, multi table update feature is not available
    492     foreach ($datas as $data)
    493     {
    494       $query = '
    495 UPDATE '.$tablename.'
    496   SET ';
    497       $is_first = true;
    498       foreach ($dbfields['update'] as $key)
    499       {
    500         $separator = $is_first ? '' : ",\n    ";
    501 
    502         if (isset($data[$key]) and $data[$key] != '')
    503         {
    504           $query.= $separator.$key.' = \''.$data[$key].'\'';
    505         }
    506         else
    507         {
    508           if ($flags & MASS_UPDATES_SKIP_EMPTY )
    509             continue; // next field
    510           $query.= "$separator$key = NULL";
    511         }
    512         $is_first = false;
    513       }
    514       if (!$is_first)
    515       {// only if one field at least updated
    516         $query.= '
    517   WHERE ';
    518         $is_first = true;
    519         foreach ($dbfields['primary'] as $key)
    520         {
    521           if (!$is_first)
    522           {
    523             $query.= ' AND ';
    524           }
    525           if ( isset($data[$key]) )
    526           {
    527             $query.= $key.' = \''.$data[$key].'\'';
    528           }
    529           else
    530           {
    531             $query.= $key.' IS NULL';
    532           }
    533           $is_first = false;
    534         }
    535         pwg_query($query);
    536       }
    537     } // foreach update
    538   } // if mysql_ver or count<X
    539   else
    540   {
    541     // creation of the temporary table
    542     $query = '
    543 SHOW FULL COLUMNS FROM '.$tablename;
    544     $result = pwg_query($query);
    545     $columns = array();
    546     $all_fields = array_merge($dbfields['primary'], $dbfields['update']);
    547     while ($row = mysql_fetch_assoc($result))
    548     {
    549       if (in_array($row['Field'], $all_fields))
    550       {
    551         $column = $row['Field'];
    552         $column.= ' '.$row['Type'];
    553 
    554         $nullable = true;
    555         if (!isset($row['Null']) or $row['Null'] == '' or $row['Null']=='NO')
    556         {
    557           $column.= ' NOT NULL';
    558           $nullable = false;
    559         }
    560         if (isset($row['Default']))
    561         {
    562           $column.= " default '".$row['Default']."'";
    563         }
    564         elseif ($nullable)
    565         {
    566           $column.= " default NULL";
    567         }
    568         if (isset($row['Collation']) and $row['Collation'] != 'NULL')
    569         {
    570           $column.= " collate '".$row['Collation']."'";
    571         }
    572         array_push($columns, $column);
    573       }
    574     }
    575 
    576     $temporary_tablename = $tablename.'_'.micro_seconds();
    577 
    578     $query = '
    579 CREATE TABLE '.$temporary_tablename.'
    580 (
    581   '.implode(",\n  ", $columns).',
    582   UNIQUE KEY the_key ('.implode(',', $dbfields['primary']).')
    583 )';
    584 
    585     pwg_query($query);
    586     mass_inserts($temporary_tablename, $all_fields, $datas);
    587     if ( $flags & MASS_UPDATES_SKIP_EMPTY )
    588       $func_set = create_function('$s', 'return "t1.$s = IFNULL(t2.$s, t1.$s)";');
    589     else
    590       $func_set = create_function('$s', 'return "t1.$s = t2.$s";');
    591 
    592     // update of images table by joining with temporary table
    593     $query = '
    594 UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
    595   SET '.
    596       implode(
    597         "\n    , ",
    598         array_map($func_set,$dbfields['update'])
    599         ).'
    600   WHERE '.
    601       implode(
    602         "\n    AND ",
    603         array_map(
    604           create_function('$s', 'return "t1.$s = t2.$s";'),
    605           $dbfields['primary']
    606           )
    607         );
    608     pwg_query($query);
    609     $query = '
    610 DROP TABLE '.$temporary_tablename;
    611     pwg_query($query);
    612   }
    613 }
    614 
    615 /**
    616412 * order categories (update categories.rank and global_rank database fields)
    617413 * so that rank field are consecutive integers starting at 1 for each child
     
    631427
    632428  $result = pwg_query($query);
    633   while ($row = mysql_fetch_assoc($result))
     429  while ($row = pwg_db_fetch_assoc($result))
    634430  {
    635431    if ($row['id_uppercat'] != $current_uppercat)
     
    777573;';
    778574  $result = pwg_query($query);
    779   while ($row = mysql_fetch_assoc($result))
     575  while ($row = pwg_db_fetch_assoc($result))
    780576  {
    781577    $uppercats = array_merge($uppercats,
     
    804600  LIMIT 0,1
    805601;';
    806     list($representative) = mysql_fetch_row(pwg_query($query));
     602    list($representative) = pwg_db_fetch_row(pwg_query($query));
    807603
    808604    array_push(
     
    864660;';
    865661  $result = pwg_query($query);
    866   while ($row = mysql_fetch_assoc($result))
     662  while ($row = pwg_db_fetch_assoc($result))
    867663  {
    868664    array_push($categories, $row);
     
    1140936  $datas = array();
    1141937
    1142   while ($row = mysql_fetch_assoc($result))
     938  while ($row = pwg_db_fetch_assoc($result))
    1143939  {
    1144940    array_push(
     
    12071003;';
    12081004  $result = pwg_query($query);
    1209   while ($row = mysql_fetch_assoc($result))
     1005  while ($row = pwg_db_fetch_assoc($result))
    12101006  {
    12111007    $categories[$row['id']] =
     
    12261022  WHERE id = '.$new_parent.'
    12271023;';
    1228     list($new_parent_uppercats) = mysql_fetch_row(pwg_query($query));
     1024    list($new_parent_uppercats) = pwg_db_fetch_row(pwg_query($query));
    12291025
    12301026    foreach ($categories as $category)
     
    12711067  WHERE id = '.$new_parent.'
    12721068;';
    1273     list($parent_status) = mysql_fetch_row(pwg_query($query));
     1069    list($parent_status) = pwg_db_fetch_row(pwg_query($query));
    12741070  }
    12751071
     
    13561152  WHERE id_uppercat '.(is_numeric($parent_id) ? '= '.$parent_id : 'IS NULL').'
    13571153;';
    1358   list($current_rank) = mysql_fetch_row(pwg_query($query));
     1154  list($current_rank) = pwg_db_fetch_row(pwg_query($query));
    13591155
    13601156  $insert = array(
     
    13721168  WHERE id = '.$parent_id.'
    13731169;';
    1374     $parent = mysql_fetch_assoc(pwg_query($query));
     1170    $parent = pwg_db_fetch_assoc(pwg_query($query));
    13751171
    13761172    $insert['id_uppercat'] = $parent['id'];
     
    14181214    );
    14191215
    1420   $inserted_id = mysql_insert_id();
     1216  $inserted_id = pwg_db_insert_id();
    14211217
    14221218  $query = '
     
    15511347      );
    15521348
    1553     $page['tag_id_from_tag_name_cache'][$tag_name] = mysql_insert_id();
     1349    $page['tag_id_from_tag_name_cache'][$tag_name] = pwg_db_insert_id();
    15541350  }
    15551351  else
     
    15931389      $inserts
    15941390      );
    1595   }
    1596 }
    1597 
    1598 /**
    1599  * Do maintenance on all PWG tables
    1600  *
    1601  * @return none
    1602  */
    1603 function do_maintenance_all_tables()
    1604 {
    1605   global $prefixeTable, $page;
    1606 
    1607   $all_tables = array();
    1608 
    1609   // List all tables
    1610   $query = 'SHOW TABLES LIKE \''.$prefixeTable.'%\'';
    1611   $result = pwg_query($query);
    1612   while ($row = mysql_fetch_assoc($result))
    1613   {
    1614     array_push($all_tables, $row[0]);
    1615   }
    1616 
    1617   // Repair all tables
    1618   $query = 'REPAIR TABLE '.implode(', ', $all_tables);
    1619   $mysql_rc = pwg_query($query);
    1620 
    1621   // Re-Order all tables
    1622   foreach ($all_tables as $table_name)
    1623   {
    1624     $all_primary_key = array();
    1625 
    1626     $query = 'DESC '.$table_name.';';
    1627     $result = pwg_query($query);
    1628     while ($row = mysql_fetch_assoc($result))
    1629     {
    1630       if ($row['Key'] == 'PRI')
    1631       {
    1632         array_push($all_primary_key, $row['Field']);
    1633       }
    1634     }
    1635 
    1636     if (count($all_primary_key) != 0)
    1637     {
    1638       $query = 'ALTER TABLE '.$table_name.' ORDER BY '.implode(', ', $all_primary_key).';';
    1639       $mysql_rc = $mysql_rc && pwg_query($query);
    1640     }
    1641   }
    1642 
    1643   // Optimize all tables
    1644   $query = 'OPTIMIZE TABLE '.implode(', ', $all_tables);
    1645   $mysql_rc = $mysql_rc && pwg_query($query);
    1646   if ($mysql_rc)
    1647   {
    1648     array_push(
    1649           $page['infos'],
    1650           l10n('Optimizations completed')
    1651           );
    1652   }
    1653   else
    1654   {
    1655     array_push(
    1656           $page['errors'],
    1657           l10n('Optimizations errors')
    1658           );
    16591391  }
    16601392}
     
    18901622      );
    18911623
    1892     $inserted_id = mysql_insert_id();
     1624    $inserted_id = pwg_db_insert_id();
    18931625
    18941626    return array(
     
    20761808;';
    20771809  $result = pwg_query($query);
    2078   if (mysql_num_rows($result) > 0)
    2079   {
    2080     list($groupname) = mysql_fetch_row($result);
     1810  if (pwg_db_num_rows($result) > 0)
     1811  {
     1812    list($groupname) = pwg_db_fetch_row($result);
    20811813  }
    20821814  else
     
    21041836;';
    21051837  $result = pwg_query($query);
    2106   if (mysql_num_rows($result) > 0)
    2107   {
    2108     list($username) = mysql_fetch_row($result);
     1838  if (pwg_db_num_rows($result) > 0)
     1839  {
     1840    list($username) = pwg_db_fetch_row($result);
    21091841  }
    21101842  else
  • trunk/admin/include/functions_history.inc.php

    r3282 r4325  
    166166  $result = pwg_query($query);
    167167
    168   while ($row = mysql_fetch_assoc($result))
     168  while ($row = pwg_db_fetch_assoc($result))
    169169  {
    170170    array_push($data, $row);
  • trunk/admin/include/functions_metadata.php

    r4265 r4325  
    260260;';
    261261  $result = pwg_query($query);
    262   while ($row = mysql_fetch_assoc($result))
     262  while ($row = pwg_db_fetch_assoc($result))
    263263  {
    264264    array_push($cat_ids, $row['id']);
     
    285285;';
    286286  $result = pwg_query($query);
    287   while ($row = mysql_fetch_assoc($result))
     287  while ($row = pwg_db_fetch_assoc($result))
    288288  {
    289289    $files[$row['id']] = $row['path'];
  • trunk/admin/include/functions_notification_by_mail.inc.php

    r4304 r4325  
    6060  check_key = \''.$key.'\';';
    6161
    62     list($count) = mysql_fetch_row(pwg_query($query));
     62    list($count) = pwg_db_fetch_row(pwg_query($query));
    6363    if ($count == 0)
    6464    {
     
    168168    if (!empty($result))
    169169    {
    170       while ($nbm_user = mysql_fetch_assoc($result))
     170      while ($nbm_user = pwg_db_fetch_assoc($result))
    171171      {
    172172        array_push($data_users, $nbm_user);
  • trunk/admin/include/functions_permalinks.php

    r4265 r4325  
    5252  $result = pwg_query($query);
    5353  $cat_id = null;
    54   if ( mysql_num_rows($result) )
    55     list( $cat_id ) = mysql_fetch_row($result);
     54  if ( pwg_db_num_rows($result) )
     55    list( $cat_id ) = pwg_db_fetch_row($result);
    5656  return $cat_id;
    5757}
     
    7373;';
    7474  $result = pwg_query($query);
    75   if ( mysql_num_rows($result) )
    76   {
    77     list($permalink) = mysql_fetch_row($result);
     75  if ( pwg_db_num_rows($result) )
     76  {
     77    list($permalink) = pwg_db_fetch_row($result);
    7878  }
    7979  if ( !isset($permalink) )
  • trunk/admin/include/functions_upgrade.php

    r4280 r4325  
    113113  $result = pwg_query($query);
    114114  $plugins = array();
    115   while ($row = mysql_fetch_assoc($result))
     115  while ($row = pwg_db_fetch_assoc($result))
    116116  {
    117117    array_push($plugins, $row['id']);
     
    139139  if(!@get_magic_quotes_gpc())
    140140  {
    141     $username = mysql_real_escape_string($username);
     141    $username = pwg_db_real_escape_string($username);
    142142  }
    143143
     
    166166;';
    167167  }
    168   $row = mysql_fetch_assoc(pwg_query($query));
     168  $row = pwg_db_fetch_assoc(pwg_query($query));
    169169
    170170  if (!isset($conf['pass_convert']))
  • trunk/admin/intro.php

    r3382 r4325  
    5454    // if the current version is a BSF (development branch) build, we check
    5555    // the first line, for stable versions, we check the second line
    56     if (preg_match('/^BSF/', $versions{'current'}))
    57     {
    58       $versions{'latest'} = trim($lines[0]);
     56    if (preg_match('/^BSF/', $versions['current']))
     57    {
     58      $versions['latest'] = trim($lines[0]);
    5959
    6060      // because integer are limited to 4,294,967,296 we need to split BSF
     
    6262      foreach ($versions as $key => $value)
    6363      {
    64         $versions{$key} =
     64        $versions[$key] =
    6565          preg_replace('/BSF_(\d{8})(\d{4})/', '$1.$2', $value);
    6666      }
     
    6868    else
    6969    {
    70       $versions{'latest'} = trim($lines[1]);
    71     }
    72 
    73     if ('' == $versions{'latest'})
     70      $versions['latest'] = trim($lines[1]);
     71    }
     72
     73    if ('' == $versions['latest'])
    7474    {
    7575      array_push(
     
    8080    // concatenation needed to avoid automatic transformation by release
    8181    // script generator
    82     else if ('%'.'PWGVERSION'.'%' == $versions{'current'})
     82    else if ('%'.'PWGVERSION'.'%' == $versions['current'])
    8383    {
    8484      array_push(
     
    8787        );
    8888    }
    89     else if (version_compare($versions{'current'}, $versions{'latest'}) < 0)
     89    else if (version_compare($versions['current'], $versions['latest']) < 0)
    9090    {
    9191      array_push(
     
    126126
    127127$php_current_timestamp = date("Y-m-d H:i:s");
    128 list($mysql_version, $db_current_timestamp) = mysql_fetch_row(pwg_query('SELECT VERSION(), CURRENT_TIMESTAMP;'));
     128$db_version = pwg_get_db_version();
     129list($db_current_timestamp) = pwg_db_fetch_row(pwg_query('SELECT CURRENT_TIMESTAMP;'));
    129130
    130131$query = '
     
    132133  FROM '.IMAGES_TABLE.'
    133134;';
    134 list($nb_elements) = mysql_fetch_row(pwg_query($query));
     135list($nb_elements) = pwg_db_fetch_row(pwg_query($query));
    135136
    136137$query = '
     
    138139  FROM '.CATEGORIES_TABLE.'
    139140;';
    140 list($nb_categories) = mysql_fetch_row(pwg_query($query));
     141list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
    141142
    142143$query = '
     
    145146  WHERE dir IS NULL
    146147;';
    147 list($nb_virtual) = mysql_fetch_row(pwg_query($query));
     148list($nb_virtual) = pwg_db_fetch_row(pwg_query($query));
    148149
    149150$query = '
     
    152153  WHERE dir IS NOT NULL
    153154;';
    154 list($nb_physical) = mysql_fetch_row(pwg_query($query));
     155list($nb_physical) = pwg_db_fetch_row(pwg_query($query));
    155156
    156157$query = '
     
    158159  FROM '.IMAGE_CATEGORY_TABLE.'
    159160;';
    160 list($nb_image_category) = mysql_fetch_row(pwg_query($query));
     161list($nb_image_category) = pwg_db_fetch_row(pwg_query($query));
    161162
    162163$query = '
     
    164165  FROM '.TAGS_TABLE.'
    165166;';
    166 list($nb_tags) = mysql_fetch_row(pwg_query($query));
     167list($nb_tags) = pwg_db_fetch_row(pwg_query($query));
    167168
    168169$query = '
     
    170171  FROM '.IMAGE_TAG_TABLE.'
    171172;';
    172 list($nb_image_tag) = mysql_fetch_row(pwg_query($query));
     173list($nb_image_tag) = pwg_db_fetch_row(pwg_query($query));
    173174
    174175$query = '
     
    176177  FROM '.USERS_TABLE.'
    177178;';
    178 list($nb_users) = mysql_fetch_row(pwg_query($query));
     179list($nb_users) = pwg_db_fetch_row(pwg_query($query));
    179180
    180181$query = '
     
    182183  FROM '.GROUPS_TABLE.'
    183184;';
    184 list($nb_groups) = mysql_fetch_row(pwg_query($query));
     185list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
    185186
    186187$query = '
     
    188189  FROM '.COMMENTS_TABLE.'
    189190;';
    190 list($nb_comments) = mysql_fetch_row(pwg_query($query));
     191list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
    191192
    192193$template->assign(
     
    196197    'OS' => PHP_OS,
    197198    'PHP_VERSION' => phpversion(),
    198     'MYSQL_VERSION' => $mysql_version,
     199    'DB_ENGINE' => 'MySQL',
     200    'DB_VERSION' => $db_version,
    199201    'DB_ELEMENTS' => l10n_dec('%d element', '%d elements', $nb_elements),
    200202    'DB_CATEGORIES' =>
     
    224226  FROM '.IMAGES_TABLE.'
    225227;';
    226   list($first_date) = mysql_fetch_row(pwg_query($query));
     228  list($first_date) = pwg_db_fetch_row(pwg_query($query));
    227229
    228230  $template->assign(
     
    244246  WHERE validated=\'false\'
    245247;';
    246 list($nb_waiting) = mysql_fetch_row(pwg_query($query));
     248list($nb_waiting) = pwg_db_fetch_row(pwg_query($query));
    247249
    248250if ($nb_waiting > 0)
     
    263265  WHERE validated=\'false\'
    264266;';
    265 list($nb_comments) = mysql_fetch_row(pwg_query($query));
     267list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
    266268
    267269if ($nb_comments > 0)
  • trunk/admin/notification_by_mail.php

    r4304 r4325  
    146146  $result = pwg_query($query);
    147147
    148   if (mysql_num_rows($result) > 0)
     148  if (pwg_db_num_rows($result) > 0)
    149149  {
    150150    $inserts = array();
    151151    $check_key_list = array();
    152152
    153     while ($nbm_user = mysql_fetch_assoc($result))
     153    while ($nbm_user = pwg_db_fetch_assoc($result))
    154154    {
    155155      // Calculate key
     
    239239  if (in_array($action, array('list_to_send', 'send')))
    240240  {
    241     list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     241    list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    242242
    243243    $is_action_send = ($action == 'send');
     
    513513      // Update param
    514514      $result = pwg_query('select param, value from '.CONFIG_TABLE.' where param like \'nbm\\_%\'');
    515       while ($nbm_user = mysql_fetch_assoc($result))
     515      while ($nbm_user = pwg_db_fetch_assoc($result))
    516516      {
    517517        if (isset($_POST[$nbm_user['param']]))
  • trunk/admin/permalinks.php

    r3282 r4325  
    100100  LIMIT 1';
    101101  pwg_query($query);
    102   if (mysql_affected_rows()==0)
     102  if (pwg_db_affected_rows()==0)
    103103    array_push($page['errors'], 'Cannot delete the old permalink !');
    104104}
     
    135135$categories=array();
    136136$result=pwg_query($query);
    137 while ( $row=mysql_fetch_assoc($result) )
     137while ( $row = pwg_db_fetch_assoc($result) )
    138138{
    139139  $row['name'] = get_cat_display_name_cache( $row['uppercats'] );
     
    163163$result = pwg_query($query);
    164164$deleted_permalinks=array();
    165 while ( $row=mysql_fetch_assoc($result) )
     165while ( $row = pwg_db_fetch_assoc($result) )
    166166{
    167167  $row['name'] = get_cat_display_name_cache($row['cat_id']);
  • trunk/admin/picture_modify.php

    r4265 r4325  
    4545  WHERE id = '.$_GET['image_id'].'
    4646;';
    47   list($path) = mysql_fetch_row(pwg_query($query));
     47  list($path) = pwg_db_fetch_row(pwg_query($query));
    4848  update_metadata(array($_GET['image_id'] => $path));
    4949
     
    176176  WHERE id = '.$_GET['image_id'].'
    177177;';
    178 $row = mysql_fetch_assoc(pwg_query($query));
     178$row = pwg_db_fetch_assoc(pwg_query($query));
    179179
    180180$storage_category_id = null;
     
    325325$result = pwg_query($query);
    326326
    327 while ($row = mysql_fetch_assoc($result))
     327while ($row = pwg_db_fetch_assoc($result))
    328328{
    329329  $name =
     
    418418  array_push($associateds, $storage_category_id);
    419419}
    420 while ($row = mysql_fetch_assoc($result))
     420while ($row = pwg_db_fetch_assoc($result))
    421421{
    422422  array_push($associateds, $row['id']);
  • trunk/admin/rating.php

    r4304 r4325  
    9595;';
    9696$result = pwg_query($query);
    97 while ($row = mysql_fetch_assoc($result))
     97while ($row = pwg_db_fetch_assoc($result))
    9898{
    9999  $users[$row['id']]=stripslashes($row['username']);
     
    105105WHERE r.element_id=i.id'. $page['user_filter'] .
    106106';';
    107 list($nb_images) = mysql_fetch_row(pwg_query($query));
     107list($nb_images) = pwg_db_fetch_row(pwg_query($query));
    108108
    109109
     
    182182$images = array();
    183183$result = pwg_query($query);
    184 while ($row = mysql_fetch_assoc($result))
     184while ($row = pwg_db_fetch_assoc($result))
    185185{
    186186  array_push($images, $row);
     
    200200ORDER BY date DESC;';
    201201  $result = pwg_query($query);
    202   $nb_rates = mysql_num_rows($result);
     202  $nb_rates = pwg_db_num_rows($result);
    203203
    204204  $tpl_image =
     
    215215   );
    216216
    217   while ($row = mysql_fetch_assoc($result))
     217  while ($row = pwg_db_fetch_assoc($result))
    218218  {
    219219
  • trunk/admin/site_manager.php

    r4265 r4325  
    9999  WHERE galleries_url = \''.$url.'\'
    100100;';
    101   $row = mysql_fetch_assoc(pwg_query($query));
     101  $row = pwg_db_fetch_assoc(pwg_query($query));
    102102  if ($row['count'] > 0)
    103103  {
     
    168168  WHERE id = '.$page['site'].'
    169169;';
    170   list($galleries_url) = mysql_fetch_row(pwg_query($query));
     170  list($galleries_url) = pwg_db_fetch_row(pwg_query($query));
    171171  switch($_GET['action'])
    172172  {
     
    237237$result = pwg_query($query);
    238238
    239 while ($row = mysql_fetch_assoc($result))
     239while ($row = pwg_db_fetch_assoc($result))
    240240{
    241241  $is_remote = url_is_remote($row['galleries_url']);
  • trunk/admin/site_update.php

    r4265 r4325  
    4444  FROM '.SITES_TABLE.'
    4545  WHERE id = '.$site_id;
    46 list($site_url) = mysql_fetch_row(pwg_query($query));
     46list($site_url) = pwg_db_fetch_row(pwg_query($query));
    4747if (!isset($site_url))
    4848{
     
    5151$site_is_remote = url_is_remote($site_url);
    5252
    53 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     53list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    5454define('CURRENT_DATE', $dbnow);
    5555
     
    186186  FROM '.CATEGORIES_TABLE;
    187187  $result = pwg_query($query);
    188   while ($row = mysql_fetch_assoc($result))
     188  while ($row = pwg_db_fetch_assoc($result))
    189189  {
    190190    $next_rank[$row['id']] = 1;
     
    197197  GROUP BY id_uppercat';
    198198  $result = pwg_query($query);
    199   while ($row = mysql_fetch_assoc($result))
     199  while ($row = pwg_db_fetch_assoc($result))
    200200  {
    201201    // for the id_uppercat NULL, we write 'NULL' and not the empty string
     
    211211SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_id
    212212  FROM '.CATEGORIES_TABLE;
    213   list($next_id) = mysql_fetch_row(pwg_query($query));
     213  list($next_id) = pwg_db_fetch_row(pwg_query($query));
    214214
    215215  // retrieve sub-directories fulldirs from the site reader
     
    247247          ? 'false'
    248248          : boolean_to_string($conf['newcat_default_uploadable']),
    249         'status'      => $conf{'newcat_default_status'},
    250         'visible'     => boolean_to_string($conf{'newcat_default_visible'}),
     249        'status'      => $conf['newcat_default_status'],
     250        'visible'     => boolean_to_string($conf['newcat_default_visible']),
    251251        );
    252252
     
    255255        $parent = $db_fulldirs[dirname($fulldir)];
    256256
    257         $insert{'id_uppercat'} = $parent;
    258         $insert{'uppercats'} =
    259           $db_categories[$parent]['uppercats'].','.$insert{'id'};
    260         $insert{'rank'} = $next_rank[$parent]++;
    261         $insert{'global_rank'} =
    262           $db_categories[$parent]['global_rank'].'.'.$insert{'rank'};
     257        $insert['id_uppercat'] = $parent;
     258        $insert['uppercats'] =
     259          $db_categories[$parent]['uppercats'].','.$insert['id'];
     260        $insert['rank'] = $next_rank[$parent]++;
     261        $insert['global_rank'] =
     262          $db_categories[$parent]['global_rank'].'.'.$insert['rank'];
    263263        if ('private' == $db_categories[$parent]['status'])
    264264        {
    265           $insert{'status'} = 'private';
     265          $insert['status'] = 'private';
    266266        }
    267267        if ('false' == $db_categories[$parent]['visible'])
    268268        {
    269           $insert{'visible'} = 'false';
     269          $insert['visible'] = 'false';
    270270        }
    271271      }
    272272      else
    273273      {
    274         $insert{'uppercats'} = $insert{'id'};
     274        $insert['uppercats'] = $insert['id'];
    275275        $insert{'rank'} = $next_rank['NULL']++;
    276         $insert{'global_rank'} = $insert{'rank'};
     276        $insert['global_rank'] = $insert['rank'];
    277277      }
    278278
     
    289289      $db_categories[$insert{'id'}] =
    290290        array(
    291           'id' => $insert{'id'},
    292           'status' => $insert{'status'},
    293           'visible' => $insert{'visible'},
    294           'uppercats' => $insert{'uppercats'},
    295           'global_rank' => $insert{'global_rank'}
     291          'id' => $insert['id'],
     292          'status' => $insert['status'],
     293          'visible' => $insert['visible'],
     294          'uppercats' => $insert['uppercats'],
     295          'global_rank' => $insert['global_rank']
    296296          );
    297       $db_fulldirs[$fulldir] = $insert{'id'};
     297      $db_fulldirs[$fulldir] = $insert['id'];
    298298      $next_rank[$insert{'id'}] = 1;
    299299    }
     
    387387    AND validated = \'false\'';
    388388    $result = pwg_query($query);
    389     while ($row = mysql_fetch_assoc($result))
     389    while ($row = pwg_db_fetch_assoc($result))
    390390    {
    391391      array_push(
     
    403403SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
    404404  FROM '.IMAGES_TABLE;
    405   list($next_element_id) = mysql_fetch_row(pwg_query($query));
     405  list($next_element_id) = pwg_db_fetch_row(pwg_query($query));
    406406
    407407  $start = get_moment();
     
    471471        $insert_links,
    472472        array(
    473           'image_id'    => $insert{'id'},
     473          'image_id'    => $insert['id'],
    474474          'category_id' => $insert['storage_category_id'],
    475475          )
     
    479479        $infos,
    480480        array(
    481           'path' => $insert{'path'},
     481          'path' => $insert['path'],
    482482          'info' => l10n('update_research_added')
    483483          )
     
    556556    $waiting_to_delete = array();
    557557
    558     while ($row = mysql_fetch_assoc($result))
     558    while ($row = pwg_db_fetch_assoc($result))
    559559    {
    560560      $data = array();
     
    565565  WHERE storage_category_id = '.$row['storage_category_id'].'
    566566    AND file = \''.$row['file'].'\'';
    567       list($data['id']) = mysql_fetch_row(pwg_query($query));
     567      list($data['id']) = pwg_db_fetch_row(pwg_query($query));
    568568
    569569      foreach ($fields['update'] as $field)
  • trunk/admin/stats.php

    r4265 r4325  
    9696
    9797  $output = array();
    98   while ($row = mysql_fetch_assoc($result))
     98  while ($row = pwg_db_fetch_assoc($result))
    9999  {
    100100    array_push($output, $row);
     
    134134$first_time_key = null;
    135135
    136 while ($row = mysql_fetch_assoc($result))
     136while ($row = pwg_db_fetch_assoc($result))
    137137{
    138138  $time_keys = array(
     
    205205;';
    206206  $result = pwg_query($query);
    207   while ($row = mysql_fetch_assoc($result))
     207  while ($row = pwg_db_fetch_assoc($result))
    208208  {
    209209    $key = sprintf('%4u', $row['year']);
  • trunk/admin/tags.php

    r4265 r4325  
    5050;';
    5151  $result = pwg_query($query);
    52   while ($row = mysql_fetch_assoc($result))
     52  while ($row = pwg_db_fetch_assoc($result))
    5353  {
    5454    $current_name_of[ $row['id'] ] = $row['name'];
     
    221221;';
    222222  $result = pwg_query($query);
    223   while ($row = mysql_fetch_assoc($result))
     223  while ($row = pwg_db_fetch_assoc($result))
    224224  {
    225225    $name_of[ $row['id'] ] = $row['name'];
  • trunk/admin/template/goto/intro.tpl

    r3722 r4325  
    3131      <li>PHP: {$PHP_VERSION} (<a href="{$U_PHPINFO}" onclick="window.open(this.href, '');
    3232          return false;">{'Show info'|@translate}</a>)  [{$PHP_DATATIME}]</li>
    33       <li>MySQL: {$MYSQL_VERSION} [{$DB_DATATIME}]</li>
     33      <li>{$DB_ENGINE}: {$DB_VERSION} [{$DB_DATATIME}]</li>
    3434    </ul>
    3535  </dd>
  • trunk/admin/thumbnail.php

    r3747 r4325  
    179179;';
    180180$result = pwg_query($query);
    181 while ( $row=mysql_fetch_assoc($result) )
     181while ( $row=pwg_db_fetch_assoc($result) )
    182182{
    183183  $basedir = preg_replace('#/*$#', '', $row['galleries_url']);
  • trunk/admin/upload.php

    r4304 r4325  
    101101;';
    102102    $result = pwg_query($query);
    103     while($row = mysql_fetch_assoc($result))
     103    while($row = pwg_db_fetch_assoc($result))
    104104    {
    105105      $dir = get_complete_dir($row['storage_category_id']);
     
    154154$query.= ';';
    155155$result = pwg_query( $query );
    156 while ( $row = mysql_fetch_assoc( $result ) )
     156while ( $row = pwg_db_fetch_assoc( $result ) )
    157157{
    158158  if ( !isset( $cat_names[$row['storage_category_id']] ) )
  • trunk/admin/user_list.php

    r4304 r4325  
    5050  {
    5151    $username = str_replace('*', '%', $_GET['username']);
    52     $filter['username'] = mysql_real_escape_string($username);
     52    $filter['username'] = pwg_db_real_escape_string($username);
    5353  }
    5454
     
    116116
    117117  $result = pwg_query($query);
    118   while ($row = mysql_fetch_assoc($result))
     118  while ($row = pwg_db_fetch_assoc($result))
    119119  {
    120120    $user = $row;
     
    140140;';
    141141    $result = pwg_query($query);
    142     while ($row = mysql_fetch_assoc($result))
     142    while ($row = pwg_db_fetch_assoc($result))
    143143    {
    144144      array_push(
     
    493493$result = pwg_query($query);
    494494
    495 while ($row = mysql_fetch_assoc($result))
     495while ($row = pwg_db_fetch_assoc($result))
    496496{
    497497  $groups[$row['id']] = $row['name'];
  • trunk/admin/user_perm.php

    r4265 r4325  
    7979;';
    8080  $result = pwg_query($query);
    81   while ($row = mysql_fetch_assoc($result))
     81  while ($row = pwg_db_fetch_assoc($result))
    8282  {
    8383    array_push($private_uppercats, $row['id']);
     
    9696  $result = pwg_query($query);
    9797
    98   while ($row = mysql_fetch_assoc($result))
     98  while ($row = pwg_db_fetch_assoc($result))
    9999  {
    100100    array_push($authorized_ids, $row['cat_id']);
     
    156156$result = pwg_query($query);
    157157
    158 if (mysql_num_rows($result) > 0)
     158if (pwg_db_num_rows($result) > 0)
    159159{
    160160  $cats = array();
    161   while ($row = mysql_fetch_assoc($result))
     161  while ($row = pwg_db_fetch_assoc($result))
    162162  {
    163163    array_push($cats, $row);
     
    192192$result = pwg_query($query_true);
    193193$authorized_ids = array();
    194 while ($row = mysql_fetch_assoc($result))
     194while ($row = pwg_db_fetch_assoc($result))
    195195{
    196196  array_push($authorized_ids, $row['id']);
  • trunk/comments.php

    r4182 r4325  
    284284    AND ', $page['where_clauses']).'
    285285;';
    286 list($counter) = mysql_fetch_row(pwg_query($query));
     286list($counter) = pwg_db_fetch_row(pwg_query($query));
    287287
    288288$url = PHPWG_ROOT_PATH
     
    332332;';
    333333$result = pwg_query($query);
    334 while ($row = mysql_fetch_assoc($result))
     334while ($row = pwg_db_fetch_assoc($result))
    335335{
    336336  array_push($comments, $row);
     
    349349;';
    350350  $result = pwg_query($query);
    351   while ($row = mysql_fetch_assoc($result))
     351  while ($row = pwg_db_fetch_assoc($result))
    352352  {
    353353    $elements[$row['id']] = $row;
  • trunk/feed.php

    r4304 r4325  
    7676  WHERE id = \''.$feed_id.'\'
    7777;';
    78   $feed_row = mysql_fetch_assoc(pwg_query($query));
     78  $feed_row = pwg_db_fetch_assoc(pwg_query($query));
    7979  if ( empty($feed_row) )
    8080  {
     
    9898check_status(ACCESS_GUEST);
    9999
    100 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     100list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    101101
    102102include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
  • trunk/include/calendar_monthly.class.php

    r4265 r4325  
    232232  $result = pwg_query($query);
    233233  $items=array();
    234   while ($row = mysql_fetch_assoc($result))
     234  while ($row = pwg_db_fetch_assoc($result))
    235235  {
    236236    $y = substr($row['period'], 0, 4);
     
    284284  $result = pwg_query($query);
    285285  $items=array();
    286   while ($row = mysql_fetch_assoc($result))
     286  while ($row = pwg_db_fetch_assoc($result))
    287287  {
    288288    $m = (int)substr($row['period'], 0, 2);
     
    334334  $items=array();
    335335  $result = pwg_query($query);
    336   while ($row = mysql_fetch_assoc($result))
     336  while ($row = pwg_db_fetch_assoc($result))
    337337  {
    338338    $d = (int)$row['period'];
     
    352352    unset ( $page['chronology_date'][CDAY] );
    353353
    354     $row = mysql_fetch_assoc(pwg_query($query));
     354    $row = pwg_db_fetch_assoc(pwg_query($query));
    355355    $items[$day]['tn_url'] = get_thumbnail_url($row);
    356356    $items[$day]['file'] = $row['file'];
  • trunk/include/category_cats.inc.php

    r4265 r4325  
    7676$image_ids = array();
    7777
    78 while ($row = mysql_fetch_assoc($result))
     78while ($row = pwg_db_fetch_assoc($result))
    7979{
    8080  $row['is_child_date_last'] = @$row['max_date_last']>@$row['date_last'];
     
    109109;';
    110110      $subresult = pwg_query($query);
    111       if (mysql_num_rows($subresult) > 0)
     111      if (pwg_db_num_rows($subresult) > 0)
    112112      {
    113         list($image_id) = mysql_fetch_row($subresult);
     113        list($image_id) = pwg_db_fetch_row($subresult);
    114114      }
    115115    }
     
    137137  ;';
    138138      $subresult = pwg_query($query);
    139       if (mysql_num_rows($subresult) > 0)
     139      if (pwg_db_num_rows($subresult) > 0)
    140140      {
    141         list($image_id) = mysql_fetch_row($subresult);
     141        list($image_id) = pwg_db_fetch_row($subresult);
    142142      }
    143143    }
     
    179179;';
    180180    $result = pwg_query($query);
    181     while ($row = mysql_fetch_assoc($result))
     181    while ($row = pwg_db_fetch_assoc($result))
    182182    {
    183183      $dates_of_category[ $row['category_id'] ] = array(
     
    203203;';
    204204  $result = pwg_query($query);
    205   while ($row = mysql_fetch_assoc($result))
     205  while ($row = pwg_db_fetch_assoc($result))
    206206  {
    207207    $thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
  • trunk/include/category_default.inc.php

    r3491 r4325  
    4646;';
    4747  $result = pwg_query($query);
    48   while ($row = mysql_fetch_assoc($result))
     48  while ($row = pwg_db_fetch_assoc($result))
    4949  {
    5050    $row['rank'] = $rank_of[ $row['id'] ];
  • trunk/include/common.inc.php

    r4280 r4325  
    9393include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
    9494@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
     95include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
    9596
    9697if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
     
    105106
    106107// Database connection
    107 @mysql_connect( $conf['db_host'], $conf['db_user'], $conf['db_password'] ) or my_error( 'mysql_connect', true );
    108 @mysql_select_db( $conf['db_base'] ) or my_error( 'mysql_select_db', true );
    109 
    110 defined('PWG_CHARSET') and defined('DB_CHARSET')
    111   or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined');
    112 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
    113 {
    114   if (DB_CHARSET!='')
    115   {
    116     pwg_query('SET NAMES "'.DB_CHARSET.'"');
    117   }
    118 }
    119 elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
    120 {
    121   fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
    122 }
     108$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
     109                              $conf['db_password'], $conf['db_base'])
     110  or my_error('pwg_db_connect', true);
     111
     112pwg_db_check_charset();
    123113
    124114load_conf_from_db();
  • trunk/include/functions.inc.php

    r4265 r4325  
    4545  // columns are 'Field', 'Type'
    4646  $result = pwg_query('desc '.$table);
    47   while ($row = mysql_fetch_assoc($result))
     47  while ($row = pwg_db_fetch_assoc($result))
    4848  {
    4949    // we are only interested in the the field given in parameter for the
     
    6060    }
    6161  }
    62   mysql_free_result($result);
     62  pwg_db_free_result($result);
    6363  return $options;
    6464}
     
    597597}
    598598
    599 function pwg_query($query)
    600 {
    601   global $conf,$page,$debug,$t2;
    602 
    603   $start = get_moment();
    604   ($result = mysql_query($query)) or my_error($query, $conf['die_on_sql_error']);
    605 
    606   $time = get_moment() - $start;
    607 
    608   if (!isset($page['count_queries']))
    609   {
    610     $page['count_queries'] = 0;
    611     $page['queries_time'] = 0;
    612   }
    613 
    614   $page['count_queries']++;
    615   $page['queries_time']+= $time;
    616 
    617   if ($conf['show_queries'])
    618   {
    619     $output = '';
    620     $output.= '<pre>['.$page['count_queries'].'] ';
    621     $output.= "\n".$query;
    622     $output.= "\n".'(this query time : ';
    623     $output.= '<b>'.number_format($time, 3, '.', ' ').' s)</b>';
    624     $output.= "\n".'(total SQL time  : ';
    625     $output.= number_format($page['queries_time'], 3, '.', ' ').' s)';
    626     $output.= "\n".'(total time      : ';
    627     $output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
    628     if ( $result!=null and preg_match('/\s*SELECT\s+/i',$query) )
    629     {
    630       $output.= "\n".'(num rows        : ';
    631       $output.= mysql_num_rows($result).' )';
    632     }
    633     elseif ( $result!=null
    634       and preg_match('/\s*INSERT|UPDATE|REPLACE|DELETE\s+/i',$query) )
    635     {
    636       $output.= "\n".'(affected rows   : ';
    637       $output.= mysql_affected_rows().' )';
    638     }
    639     $output.= "</pre>\n";
    640 
    641     $debug .= $output;
    642   }
    643 
    644   return $result;
    645 }
    646 
    647599function pwg_debug( $string )
    648600{
     
    904856
    905857  return $thumbnail_title;
    906 }
    907 
    908 // my_error returns (or send to standard output) the message concerning the
    909 // error occured for the last mysql query.
    910 function my_error($header, $die)
    911 {
    912   $error = "[mysql error ".mysql_errno().'] '.mysql_error()."\n";
    913   $error .= $header;
    914 
    915   if ($die)
    916   {
    917     fatal_error($error);
    918   }
    919   echo("<pre>");
    920   trigger_error($error, E_USER_WARNING);
    921   echo("</pre>");
    922 }
    923 
    924 
    925 /**
    926  * creates an array based on a query, this function is a very common pattern
    927  * used here
    928  *
    929  * @param string $query
    930  * @param string $fieldname
    931  * @return array
    932  */
    933 function array_from_query($query, $fieldname)
    934 {
    935   $array = array();
    936 
    937   $result = pwg_query($query);
    938   while ($row = mysql_fetch_assoc($result))
    939   {
    940     array_push($array, $row[$fieldname]);
    941   }
    942 
    943   return $array;
    944858}
    945859
     
    11221036  WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
    11231037;';
    1124   list($email) = mysql_fetch_row(pwg_query($query));
     1038  list($email) = pwg_db_fetch_row(pwg_query($query));
    11251039
    11261040  return $email;
     
    11431057  $result = pwg_query($query);
    11441058
    1145   if ((mysql_num_rows($result) == 0) and !empty($condition))
     1059  if ((pwg_db_num_rows($result) == 0) and !empty($condition))
    11461060  {
    11471061    fatal_error('No configuration data');
    11481062  }
    11491063
    1150   while ($row = mysql_fetch_assoc($result))
     1064  while ($row = pwg_db_fetch_assoc($result))
    11511065  {
    11521066    $conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
     
    11931107
    11941108  $result = pwg_query($query);
    1195   while ($row = mysql_fetch_assoc($result))
     1109  while ($row = pwg_db_fetch_assoc($result))
    11961110  {
    11971111    $array[ $row[$keyname] ] = $row[$valuename];
     
    12141128  $array = array();
    12151129  $result = pwg_query($query);
    1216   while ($row = mysql_fetch_assoc($result))
     1130  while ($row = pwg_db_fetch_assoc($result))
    12171131  {
    12181132    $array[ $row[$keyname] ] = $row;
     
    15851499    // Use MySql date in order to standardize all recent "actions/queries"
    15861500    list($cache['get_icon']['sql_recent_date']) =
    1587       mysql_fetch_row(pwg_query('select SUBDATE(
     1501      pwg_db_fetch_row(pwg_query('select SUBDATE(
    15881502      CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
    15891503  }
  • trunk/include/functions_category.inc.php

    r4265 r4325  
    102102  $cats = array();
    103103  $selected_category = isset($page['category']) ? $page['category'] : null;
    104   while ($row = mysql_fetch_assoc($result))
     104  while ($row = pwg_db_fetch_assoc($result))
    105105  {
    106106    $child_date_last = @$row['max_date_last']> @$row['date_last'];
     
    166166  WHERE id = '.$id.'
    167167;';
    168   $cat = mysql_fetch_assoc(pwg_query($query));
     168  $cat = pwg_db_fetch_assoc(pwg_query($query));
    169169  if (empty($cat))
    170170    return null;
     
    241241    $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id;
    242242    $query.= ';';
    243     $row = mysql_fetch_assoc( pwg_query( $query ) );
     243    $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    244244    $uppercats = $row['uppercats'];
    245245  }
     
    252252  $query.= ';';
    253253  $result = pwg_query( $query );
    254   while( $row = mysql_fetch_assoc( $result ) )
     254  while( $row = pwg_db_fetch_assoc( $result ) )
    255255  {
    256256    $database_dirs[$row['id']] = $row['dir'];
     
    276276    AND c.id = '.$category_id.'
    277277;';
    278   $row = mysql_fetch_assoc(pwg_query($query));
     278  $row = pwg_db_fetch_assoc(pwg_query($query));
    279279  return $row['galleries_url'];
    280280}
     
    345345  if (!empty($result))
    346346  {
    347     while ($row = mysql_fetch_assoc($result))
     347    while ($row = pwg_db_fetch_assoc($result))
    348348    {
    349349      array_push($categories, $row);
     
    385385
    386386  $subcats = array();
    387   while ($row = mysql_fetch_assoc($result))
     387  while ($row = pwg_db_fetch_assoc($result))
    388388  {
    389389    array_push($subcats, $row['id']);
     
    534534LIMIT 1';
    535535
    536       $show_link = mysql_num_rows(pwg_query($query)) <> 0;
     536      $show_link = pwg_db_num_rows(pwg_query($query)) <> 0;
    537537    }
    538538  }
  • trunk/include/functions_comment.inc.php

    r4306 r4325  
    101101  FROM '.USERS_TABLE.'
    102102  WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."'";
    103       $row = mysql_fetch_assoc( pwg_query( $query ) );
     103      $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    104104      if ( $row['user_exists'] == 1 )
    105105      {
     
    139139  WHERE date > FROM_UNIXTIME('.$reference_date.')
    140140    AND author_id = '.$comm['author_id'];
    141     if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
     141    if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
    142142    {
    143143      array_push( $infos, l10n('comment_anti-flood') );
     
    169169    pwg_query($query);
    170170
    171     $comm['id'] = mysql_insert_id();
     171    $comm['id'] = pwg_db_insert_id();
    172172
    173173    if (($comment_action=='validate' and $conf['email_admin_on_comment']) or
     
    267267  WHERE date > FROM_UNIXTIME('.$reference_date.')
    268268    AND author_id = '.$comm['author_id'];
    269     if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
     269    if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
    270270    {
    271271      //?? array_push( $infos, l10n('comment_anti-flood') );
  • trunk/include/functions_mail.inc.php

    r4304 r4325  
    352352  if (!empty($datas))
    353353  {
    354     while ($admin = mysql_fetch_assoc($datas))
     354    while ($admin = pwg_db_fetch_assoc($datas))
    355355    {
    356356      if (!empty($admin['mail_address']))
     
    448448  $result = pwg_query($query);
    449449
    450   if (mysql_num_rows($result) > 0)
     450  if (pwg_db_num_rows($result) > 0)
    451451  {
    452452    $list = array();
    453     while ($row = mysql_fetch_assoc($result))
     453    while ($row = pwg_db_fetch_assoc($result))
    454454    {
    455455      $row['template_theme'] = $row['template'];
     
    477477      $result = pwg_query($query);
    478478
    479       if (mysql_num_rows($result) > 0)
     479      if (pwg_db_num_rows($result) > 0)
    480480      {
    481481        $Bcc = array();
    482         while ($row = mysql_fetch_assoc($result))
     482        while ($row = pwg_db_fetch_assoc($result))
    483483        {
    484484          if (!empty($row['mail_address']))
  • trunk/include/functions_notification.inc.php

    r4265 r4325  
    146146    $query = 'SELECT count(distinct '.$field_id.') as CountId
    147147'.$query;
    148     list($count) = mysql_fetch_row(pwg_query($query));
     148    list($count) = pwg_db_fetch_row(pwg_query($query));
    149149    return $count;
    150150
     
    179179    $infos = array();
    180180
    181     while ($row = mysql_fetch_assoc($result))
     181    while ($row = pwg_db_fetch_assoc($result))
    182182    {
    183183      array_push($infos, $row);
     
    449449  $result = pwg_query($query);
    450450  $dates = array();
    451   while ($row = mysql_fetch_assoc($result))
     451  while ($row = pwg_db_fetch_assoc($result))
    452452  {
    453453    array_push($dates, $row);
     
    469469      $dates[$i]['elements'] = array();
    470470      $result = pwg_query($query);
    471       while ($row = mysql_fetch_assoc($result))
     471      while ($row = pwg_db_fetch_assoc($result))
    472472      {
    473473        array_push($dates[$i]['elements'], $row);
     
    489489      $dates[$i]['categories'] = array();
    490490      $result = pwg_query($query);
    491       while ($row = mysql_fetch_assoc($result))
     491      while ($row = pwg_db_fetch_assoc($result))
    492492      {
    493493        array_push($dates[$i]['categories'], $row);
  • trunk/include/functions_plugins.inc.php

    r4265 r4325  
    239239  $result = pwg_query($query);
    240240  $plugins = array();
    241   while ($row = mysql_fetch_assoc($result))
     241  while ($row = pwg_db_fetch_assoc($result))
    242242  {
    243243    array_push($plugins, $row);
  • trunk/include/functions_rate.inc.php

    r3282 r4325  
    125125  WHERE element_id = '.$image_id.'
    126126;';
    127   $row = mysql_fetch_assoc(pwg_query($query));
     127  $row = pwg_db_fetch_assoc(pwg_query($query));
    128128  $query = '
    129129UPDATE '.IMAGES_TABLE.'
  • trunk/include/functions_search.inc.php

    r4265 r4325  
    4242  WHERE id = '.$search_id.'
    4343;';
    44   list($serialized_rules) = mysql_fetch_row(pwg_query($query));
     44  list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
    4545
    4646  return unserialize($serialized_rules);
     
    459459  $by_weights=array();
    460460  $result = pwg_query($query);
    461   while ($row = mysql_fetch_assoc($result))
     461  while ($row = pwg_db_fetch_assoc($result))
    462462  { // weight is important when sorting images by relevance
    463463    if ($row['weight'])
     
    490490  GROUP BY image_id';
    491491      $result = pwg_query($query);
    492       while ($row = mysql_fetch_assoc($result))
     492      while ($row = pwg_db_fetch_assoc($result))
    493493      { // weight is important when sorting images by relevance
    494494        $image_id=(int)$row['image_id'];
     
    511511    );
    512512  $result = pwg_query($query);
    513   while ($row = mysql_fetch_assoc($result))
     513  while ($row = pwg_db_fetch_assoc($result))
    514514  { // weight is important when sorting images by relevance
    515515    if ($row['nb_images']==0)
  • trunk/include/functions_session.inc.php

    r3282 r4325  
    122122  if ($result)
    123123  {
    124     $row = mysql_fetch_assoc($result);
     124    $row = pwg_db_fetch_assoc($result);
    125125    return $row['data'];
    126126  }
  • trunk/include/functions_tag.inc.php

    r3282 r4325  
    6464  $result = pwg_query($query);
    6565  $tags = array();
    66   while ($row = mysql_fetch_assoc($result))
     66  while ($row = pwg_db_fetch_assoc($result))
    6767  {
    6868    $counter = @$tag_counters[ $row['id'] ];
     
    8989  $result = pwg_query($query);
    9090  $tags = array();
    91   while ($row = mysql_fetch_assoc($result))
     91  while ($row = pwg_db_fetch_assoc($result))
    9292  {
    9393    array_push($tags, $row);
     
    250250  $result = pwg_query($query);
    251251  $tags = array();
    252   while($row = mysql_fetch_assoc($result))
     252  while($row = pwg_db_fetch_assoc($result))
    253253  {
    254254    array_push($tags, $row);
     
    312312  $result = pwg_query($query);
    313313  $tags = array();
    314   while ($row = mysql_fetch_assoc($result))
     314  while ($row = pwg_db_fetch_assoc($result))
    315315  {
    316316    array_push($tags, $row);
  • trunk/include/functions_user.inc.php

    r4304 r4325  
    5959'.(is_numeric($user_id) ? 'and '.$conf['user_fields']['id'].' != \''.$user_id.'\'' : '').'
    6060;';
    61     list($count) = mysql_fetch_row(pwg_query($query));
     61    list($count) = pwg_db_fetch_row(pwg_query($query));
    6262    if ($count != 0)
    6363    {
     
    111111  FROM '.USERS_TABLE.'
    112112;';
    113     list($next_id) = mysql_fetch_row(pwg_query($query));
     113    list($next_id) = pwg_db_fetch_row(pwg_query($query));
    114114
    115115    $insert =
    116116      array(
    117117        $conf['user_fields']['id'] => $next_id,
    118         $conf['user_fields']['username'] => mysql_real_escape_string($login),
     118        $conf['user_fields']['username'] => pwg_db_real_escape_string($login),
    119119        $conf['user_fields']['password'] => $conf['pass_convert']($password),
    120120        $conf['user_fields']['email'] => $mail_address
     
    135135
    136136      $inserts = array();
    137       while ($row = mysql_fetch_assoc($result))
     137      while ($row = pwg_db_fetch_assoc($result))
    138138      {
    139139        array_push
     
    250250  WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\'';
    251251
    252   $row = mysql_fetch_assoc(pwg_query($query));
     252  $row = pwg_db_fetch_assoc(pwg_query($query));
    253253
    254254  while (true)
     
    260260  WHERE ui.user_id = \''.$user_id.'\'';
    261261    $result = pwg_query($query);
    262     if (mysql_num_rows($result) > 0)
     262    if (pwg_db_num_rows($result) > 0)
    263263    {
    264264      break;
     
    270270  }
    271271
    272   $row = array_merge($row, mysql_fetch_assoc($result));
     272  $row = array_merge($row, pwg_db_fetch_assoc($result));
    273273
    274274  foreach ($row as $key => $value)
     
    325325  WHERE category_id NOT IN ('.$userdata['forbidden_categories'].')
    326326    AND image_id '.$userdata['image_access_type'].' ('.$userdata['image_access_list'].')';
    327       list($userdata['nb_total_images']) = mysql_fetch_row(pwg_query($query));
     327      list($userdata['nb_total_images']) = pwg_db_fetch_row(pwg_query($query));
    328328
    329329
     
    429429  $result = pwg_query($query);
    430430  $authorizeds = array();
    431   while ($row = mysql_fetch_assoc($result))
     431  while ($row = pwg_db_fetch_assoc($result))
    432432  {
    433433    array_push($authorizeds, $row['image_id']);
     
    441441  $result = pwg_query($query);
    442442  $favorites = array();
    443   while ($row = mysql_fetch_assoc($result))
     443  while ($row = pwg_db_fetch_assoc($result))
    444444  {
    445445    array_push($favorites, $row['image_id']);
     
    482482;';
    483483  $result = pwg_query($query);
    484   while ($row = mysql_fetch_assoc($result))
     484  while ($row = pwg_db_fetch_assoc($result))
    485485  {
    486486    array_push($private_array, $row['id']);
     
    524524;';
    525525    $result = pwg_query($query);
    526     while ($row = mysql_fetch_assoc($result))
     526    while ($row = pwg_db_fetch_assoc($result))
    527527    {
    528528      array_push($forbidden_array, $row['id']);
     
    648648
    649649  $cats = array();
    650   while ($row = mysql_fetch_assoc($result))
     650  while ($row = pwg_db_fetch_assoc($result))
    651651  {
    652652    $row['user_id'] = $userdata['id'];
     
    693693  global $conf;
    694694
    695   $username = mysql_real_escape_string($username);
     695  $username = pwg_db_real_escape_string($username);
    696696
    697697  $query = '
     
    702702  $result = pwg_query($query);
    703703
    704   if (mysql_num_rows($result) == 0)
     704  if (pwg_db_num_rows($result) == 0)
    705705  {
    706706    return false;
     
    708708  else
    709709  {
    710     list($user_id) = mysql_fetch_row($result);
     710    list($user_id) = pwg_db_fetch_row($result);
    711711    return $user_id;
    712712  }
     
    728728  WHERE id = \''.$key.'\'
    729729;';
    730     list($count) = mysql_fetch_row(pwg_query($query));
     730    list($count) = pwg_db_fetch_row(pwg_query($query));
    731731    if (0 == $count)
    732732    {
     
    751751
    752752    $result = pwg_query($query);
    753     $cache['default_user'] = mysql_fetch_assoc($result);
     753    $cache['default_user'] = pwg_db_fetch_assoc($result);
    754754
    755755    if ($cache['default_user'] !== false)
     
    866866  {
    867867    $inserts = array();
    868     list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     868    list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    869869
    870870    $default_user = get_default_user_info(false);
     
    931931WHERE '.$conf['user_fields']['id'].' = '.$user_id;
    932932  $result = pwg_query($query);
    933   if (mysql_num_rows($result) > 0)
    934   {
    935     $row = mysql_fetch_assoc($result);
     933  if (pwg_db_num_rows($result) > 0)
     934  {
     935    $row = pwg_db_fetch_assoc($result);
    936936    $username = stripslashes($row['username']);
    937937    $data = $time.stripslashes($row['username']).$row['password'];
     
    10421042  WHERE '.$conf['user_fields']['username'].' = \''.mysql_real_escape_string($username).'\'
    10431043;';
    1044   $row = mysql_fetch_assoc(pwg_query($query));
     1044  $row = pwg_db_fetch_assoc(pwg_query($query));
    10451045  if ($row['password'] == $conf['pass_convert']($password))
    10461046  {
  • trunk/include/picture_comment.inc.php

    r4304 r4325  
    9494  FROM '.COMMENTS_TABLE.'
    9595  WHERE image_id='.$page['image_id']." AND validated = 'true'";
    96   $row = mysql_fetch_assoc( pwg_query( $query ) );
     96  $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    9797
    9898  // navigation bar creation
     
    141141    $result = pwg_query( $query );
    142142
    143     while ($row = mysql_fetch_assoc($result))
     143    while ($row = pwg_db_fetch_assoc($result))
    144144    {
    145145      if (!empty($row['author']))
  • trunk/include/picture_rate.inc.php

    r4265 r4325  
    3838  WHERE element_id = '.$picture['current']['id'].'
    3939;';
    40     $row = mysql_fetch_assoc(pwg_query($query));
     40    $row = pwg_db_fetch_assoc(pwg_query($query));
    4141  }
    4242  else
     
    6868
    6969      $result = pwg_query($query);
    70       if (mysql_num_rows($result) > 0)
     70      if (pwg_db_num_rows($result) > 0)
    7171      {
    72         $row = mysql_fetch_assoc($result);
     72        $row = pwg_db_fetch_assoc($result);
    7373        $user_rate = $row['rate'];
    7474      }
  • trunk/include/ws_functions.inc.php

    r4304 r4325  
    257257  $result = pwg_query($query);
    258258  $cats = array();
    259   while ($row = mysql_fetch_assoc($result))
     259  while ($row = pwg_db_fetch_assoc($result))
    260260  {
    261261    $row['id'] = (int)$row['id'];
     
    296296
    297297    $result = pwg_query($query);
    298     while ($row = mysql_fetch_assoc($result))
     298    while ($row = pwg_db_fetch_assoc($result))
    299299    {
    300300      $image = array();
     
    406406
    407407  $cats = array();
    408   while ($row = mysql_fetch_assoc($result))
     408  while ($row = pwg_db_fetch_assoc($result))
    409409  {
    410410    $row['url'] = make_index_url(
     
    472472  $cats = array();
    473473
    474   while ($row = mysql_fetch_assoc($result))
     474  while ($row = pwg_db_fetch_assoc($result))
    475475  {
    476476    $id = $row['id'];
     
    518518      ' AND'
    519519    );
    520   if ( !mysql_num_rows( pwg_query( $query ) ) )
     520  if ( !pwg_db_num_rows( pwg_query( $query ) ) )
    521521  {
    522522    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
     
    578578LIMIT 1';
    579579
    580   $image_row = mysql_fetch_assoc(pwg_query($query));
     580  $image_row = pwg_db_fetch_assoc(pwg_query($query));
    581581  if ($image_row==null)
    582582  {
     
    599599  $is_commentable = false;
    600600  $related_categories = array();
    601   while ($row = mysql_fetch_assoc($result))
     601  while ($row = pwg_db_fetch_assoc($result))
    602602  {
    603603    if ($row['commentable']=='true')
     
    656656  WHERE element_id = '.$image_row['id'].'
    657657;';
    658   $rating = mysql_fetch_assoc(pwg_query($query));
     658  $rating = pwg_db_fetch_assoc(pwg_query($query));
    659659  $rating['count'] = (int)$rating['count'];
    660660
     
    687687
    688688    $result = pwg_query($query);
    689     while ($row = mysql_fetch_assoc($result))
     689    while ($row = pwg_db_fetch_assoc($result))
    690690    {
    691691      $row['id']=(int)$row['id'];
     
    758758    ).'
    759759    LIMIT 1';
    760   if ( mysql_num_rows( pwg_query($query) )==0 )
     760  if ( pwg_db_num_rows( pwg_query($query) )==0 )
    761761  {
    762762    return new PwgError(404, "Invalid image_id or access denied" );
     
    814814    $image_ids = array_flip($image_ids);
    815815    $result = pwg_query($query);
    816     while ($row = mysql_fetch_assoc($result))
     816    while ($row = pwg_db_fetch_assoc($result))
    817817    {
    818818      $image = array();
     
    871871  WHERE id IN ('.implode(',',$params['image_id']).')';
    872872  $result = pwg_query($query);
    873   $affected_rows = mysql_affected_rows();
     873  $affected_rows = pwg_db_affected_rows();
    874874  if ($affected_rows)
    875875  {
     
    10081008  WHERE md5sum = \''.$params['original_sum'].'\'
    10091009;';
    1010   list($counter) = mysql_fetch_row(pwg_query($query));
     1010  list($counter) = pwg_db_fetch_row(pwg_query($query));
    10111011  if ($counter != 0) {
    10121012    return new PwgError(500, 'file already exists');
     
    10141014
    10151015  // current date
    1016   list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     1016  list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    10171017  list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
    10181018
     
    12001200    );
    12011201
    1202   $image_id = mysql_insert_id();
     1202  $image_id = pwg_db_insert_id();
    12031203
    12041204  // let's add links between the image and the categories
     
    13591359  GROUP BY image_id';
    13601360      $result = pwg_query($query);
    1361       while ( $row=mysql_fetch_assoc($result) )
     1361      while ( $row=pwg_db_fetch_assoc($result) )
    13621362      {
    13631363        $row['image_id'] = (int)$row['image_id'];
     
    14021402
    14031403    $result = pwg_query($query);
    1404     while ($row = mysql_fetch_assoc($result))
     1404    while ($row = pwg_db_fetch_assoc($result))
    14051405    {
    14061406      $image = array();
     
    15731573;';
    15741574
    1575   $image_row = mysql_fetch_assoc(pwg_query($query));
     1575  $image_row = pwg_db_fetch_assoc(pwg_query($query));
    15761576  if ($image_row == null)
    15771577  {
  • trunk/install.php

    r4280 r4325  
    365365    // make PWG avoid upgrading, we must tell it upgrades have already been
    366366    // made.
    367     list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     367    list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    368368    define('CURRENT_DATE', $dbnow);
    369369    $datas = array();
  • trunk/install/db/1-database.php

    r3282 r4325  
    3333// +-----------------------------------------------------------------------+
    3434
    35 list($now) = mysql_fetch_row(pwg_query('SELECT NOW()'));
     35list($now) = pwg_db_fetch_row(pwg_query('SELECT NOW()'));
    3636echo
    3737$now
  • trunk/install/db/12-database.php

    r4265 r4325  
    6767$datas = array();
    6868
    69 while ($row = mysql_fetch_assoc($result))
     69while ($row = pwg_db_fetch_assoc($result))
    7070{
    7171  array_push(
  • trunk/install/db/18-database.php

    r4265 r4325  
    4848$datas = array();
    4949
    50 while ($row = mysql_fetch_assoc($result))
     50while ($row = pwg_db_fetch_assoc($result))
    5151{
    5252  array_push(
  • trunk/install/db/19-database.php

    r4265 r4325  
    6969;';
    7070$result = pwg_query($query);
    71 while ($row = mysql_fetch_assoc($result))
     71while ($row = pwg_db_fetch_assoc($result))
    7272{
    7373  foreach(preg_split('/[,]+/', $row['keywords']) as $keyword)
  • trunk/install/db/20-database.php

    r4265 r4325  
    4848
    4949$datas = array();
    50 while ($row = mysql_fetch_assoc($result))
     50while ($row = pwg_db_fetch_assoc($result))
    5151{
    5252  array_push(
  • trunk/install/db/65-database.php

    r4280 r4325  
    109109  GROUP BY language';
    110110  $result = pwg_query($query);
    111   while ( $row=mysql_fetch_assoc($result) )
     111  while ( $row=pwg_db_fetch_assoc($result) )
    112112  {
    113113    $language = $row["language"];
     
    142142  WHERE user_id='.$conf['webmaster_id'];
    143143  $result = pwg_query($query);
    144   if (mysql_num_rows($result)==0)
     144  if (pwg_db_num_rows($result)==0)
    145145  {
    146146    $query='
     
    151151  }
    152152
    153   if ( $row=mysql_fetch_assoc($result) )
     153  if ( $row=pwg_db_fetch_assoc($result) )
    154154  {
    155155    $admin_charset = $all_langs[$row['language']]['charset'];
     
    166166  $query = 'SHOW TABLES LIKE "'.$prefixeTable.'%"';
    167167  $result = pwg_query($query);
    168   while ( $row=mysql_fetch_assoc($result) )
     168  while ( $row=pwg_db_fetch_assoc($result) )
    169169  {
    170170    array_push($all_tables, $row[0]);
     
    177177    $result = pwg_query($query);
    178178    $field_definitions=array();
    179     while ( $row=mysql_fetch_assoc($result) )
     179    while ( $row=pwg_db_fetch_assoc($result) )
    180180    {
    181181      if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
  • trunk/install/db/8-database.php

    r4265 r4325  
    6161$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
    6262$result = pwg_query($query);
    63 while ($row = mysql_fetch_assoc($result))
     63while ($row = pwg_db_fetch_assoc($result))
    6464{
    6565  unset( $params[ $row['param'] ] );
  • trunk/install/db/9-database.php

    r4265 r4325  
    4848$datas = array();
    4949
    50 while ($row = mysql_fetch_assoc($result))
     50while ($row = pwg_db_fetch_assoc($result))
    5151{
    5252  array_push(
  • trunk/install/upgrade_1.3.0.php

    r4265 r4325  
    8585;';
    8686$result = pwg_query($query);
    87 while ($row = mysql_fetch_assoc($result))
     87while ($row = pwg_db_fetch_assoc($result))
    8888{
    8989  if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
  • trunk/install/upgrade_1.3.1.php

    r4280 r4325  
    4343  FROM '.PREFIX_TABLE.'config
    4444;';
    45 $save = mysql_fetch_assoc(pwg_query($query));
     45$save = pwg_db_fetch_assoc(pwg_query($query));
    4646
    4747$queries = array(
     
    345345;';
    346346  $result = pwg_query($query);
    347   while ($row = mysql_fetch_assoc($result))
     347  while ($row = pwg_db_fetch_assoc($result))
    348348  {
    349349    if ($row['Key_name'] != 'PRIMARY')
     
    537537;';
    538538$result = pwg_query($query);
    539 while ($row = mysql_fetch_assoc($result))
     539while ($row = pwg_db_fetch_assoc($result))
    540540{
    541541  array_push($cat_ids, $row['unique_storage_category_id']);
     
    562562;';
    563563$result = pwg_query($query);
    564 while ($row = mysql_fetch_assoc($result))
     564while ($row = pwg_db_fetch_assoc($result))
    565565{
    566566  array_push($cat_ids, $row['id']);
  • trunk/install/upgrade_1.4.0.php

    r4265 r4325  
    4343  WHERE param = \'prefix_thumbnail\'
    4444;';
    45 list($prefix_thumbnail) = mysql_fetch_row(pwg_query($query));
     45list($prefix_thumbnail) = pwg_db_fetch_row(pwg_query($query));
    4646
    4747// delete obsolete configuration
     
    192192
    193193$datas = array();
    194 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     194list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    195195
    196196$result = pwg_query($query);
    197 while ($row = mysql_fetch_assoc($result))
     197while ($row = pwg_db_fetch_assoc($result))
    198198{
    199199  $row['user_id'] = $row['id'];
  • trunk/install/upgrade_1.5.0.php

    r4265 r4325  
    8080;';
    8181  $result = pwg_query($query);
    82   while ($row = mysql_fetch_assoc($result))
     82  while ($row = pwg_db_fetch_assoc($result))
    8383  {
    8484    foreach(preg_split('/[,]+/', $row['keywords']) as $keyword)
     
    352352$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
    353353$result = pwg_query($query);
    354 while ($row = mysql_fetch_assoc($result))
     354while ($row = pwg_db_fetch_assoc($result))
    355355{
    356356  unset( $params[ $row['param'] ] );
     
    453453$result = pwg_query($query);
    454454
    455 while ($row = mysql_fetch_assoc($result))
     455while ($row = pwg_db_fetch_assoc($result))
    456456{
    457457  if (!in_array($row['Field'], $to_keep))
  • trunk/install/upgrade_1.7.0.php

    r3282 r4325  
    3636define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
    3737
    38 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     38list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    3939define('CURRENT_DATE', $dbnow);
    4040
  • trunk/password.php

    r4304 r4325  
    5757  else if (isset($_POST['mail_address']) and !empty($_POST['mail_address']))
    5858  {
    59     $mail_address = mysql_real_escape_string($_POST['mail_address']);
     59    $mail_address = pwg_db_real_escape_string($_POST['mail_address']);
    6060   
    6161    $query = '
     
    7575    $result = pwg_query($query);
    7676
    77     if (mysql_num_rows($result) > 0)
     77    if (pwg_db_num_rows($result) > 0)
    7878    {
    7979      $error_on_mail = false;
    8080      $datas = array();
    8181     
    82       while ($row = mysql_fetch_assoc($result))
     82      while ($row = pwg_db_fetch_assoc($result))
    8383      {
    8484        $new_password = generate_key(6);
  • trunk/picture.php

    r4265 r4325  
    5858      '.%" ESCAPE "/" LIMIT 1';
    5959  }
    60   if ( ! ( $row = mysql_fetch_assoc(pwg_query($query)) ) )
     60  if ( ! ( $row = pwg_db_fetch_assoc(pwg_query($query)) ) )
    6161  {// element does not exist
    6262    page_not_found( 'The requested image does not exist',
     
    9494          ).'
    9595  LIMIT 1';
    96       if ( mysql_num_rows( pwg_query($query) ) == 0 )
     96      if ( pwg_db_num_rows( pwg_query($query) ) == 0 )
    9797      {
    9898        access_denied();
     
    388388$result = pwg_query($query);
    389389$related_categories = array();
    390 while ($row = mysql_fetch_assoc($result))
     390while ($row = pwg_db_fetch_assoc($result))
    391391{
    392392  array_push($related_categories, $row);
     
    416416$result = pwg_query($query);
    417417
    418 while ($row = mysql_fetch_assoc($result))
     418while ($row = pwg_db_fetch_assoc($result))
    419419{
    420420  if (isset($page['previous_item']) and $row['id'] == $page['previous_item'])
     
    768768;';
    769769  $result = pwg_query($query);
    770   $row = mysql_fetch_assoc($result);
     770  $row = pwg_db_fetch_assoc($result);
    771771
    772772  if ($row['nb_fav'] == 0)
  • trunk/profile.php

    r4304 r4325  
    5656;';
    5757    $result = pwg_query($query);
    58     $default_user = mysql_fetch_assoc($result);
     58    $default_user = pwg_db_fetch_assoc($result);
    5959    $userdata = array_merge($userdata, $default_user);
    6060  }
     
    163163    WHERE '.$conf['user_fields']['id'].' = \''.$userdata['id'].'\'
    164164  ;';
    165       list($current_password) = mysql_fetch_row(pwg_query($query));
     165      list($current_password) = pwg_db_fetch_row(pwg_query($query));
    166166 
    167167      if ($conf['pass_convert']($_POST['password']) != $current_password)
  • trunk/qsearch.php

    r3282 r4325  
    6161;';
    6262  pwg_query($query);
    63   $search_id = mysql_insert_id();
     63  $search_id = pwg_db_insert_id();
    6464}
    6565
  • trunk/search.php

    r3282 r4325  
    137137    pwg_query($query);
    138138
    139     $search_id = mysql_insert_id();
     139    $search_id = pwg_db_insert_id();
    140140  }
    141141  else
  • trunk/search_rules.php

    r4265 r4325  
    136136  if (!empty($result))
    137137  {
    138     while ($row = mysql_fetch_assoc($result))
     138    while ($row = pwg_db_fetch_assoc($result))
    139139    {
    140140      array_push($categories, $row);
  • trunk/upgrade.php

    r4280 r4325  
    4444include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
    4545@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
     46include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
    4647
    4748prepare_conf_upgrade();
     
    5152
    5253// Database connection
    53 mysql_connect( $conf['db_host'], $conf['db_user'], $conf['db_password'] ) or die ( "Could not connect to database server" );
    54 mysql_select_db( $conf['db_base'] ) or die ( "Could not connect to database" );
    55 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=')
    56     and defined('DB_CHARSET') and DB_CHARSET!='' )
    57 {
    58   pwg_query('SET NAMES "'.DB_CHARSET.'"');
    59 }
     54$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
     55                              $conf['db_password'], $conf['db_base'])
     56  or my_error('pwg_db_connect', true);
     57
     58pwg_db_check_charset();
    6059
    6160// +-----------------------------------------------------------------------+
     
    7776  $result = pwg_query($query);
    7877
    79   while ($row = mysql_fetch_row($result))
     78  while ($row = pwg_db_fetch_row($result))
    8079  {
    8180    if (preg_match('/^'.PREFIX_TABLE.'/', $row[0]))
     
    106105    $columns_of[$table] = array();
    107106
    108     while ($row = mysql_fetch_row($result))
     107    while ($row = pwg_db_fetch_row($result))
    109108    {
    110109      array_push($columns_of[$table], $row[0]);
  • trunk/upgrade_feed.php

    r4280 r4325  
    3636include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
    3737@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
     38include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
    3839
    3940// +-----------------------------------------------------------------------+
     
    5556// +-----------------------------------------------------------------------+
    5657
    57 mysql_connect($conf['db_host'], $conf['db_user'], $conf['db_password']) or die("Could not connect to database server");
    58 mysql_select_db($conf['db_base']) or die("Could not connect to database");
    59 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=')
    60     and defined('DB_CHARSET') and DB_CHARSET!='' )
    61 {
    62   pwg_query('SET NAMES "'.DB_CHARSET.'"');
    63 }
     58$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
     59                              $conf['db_password'], $conf['db_base'])
     60  or my_error('pwg_db_connect', true);
    6461
     62pwg_db_check_charset();
    6563
    6664// +-----------------------------------------------------------------------+
  • trunk/upload.php

    r4304 r4325  
    249249    $query.= ';';
    250250    pwg_query( $query );
    251     $page['waiting_id'] = mysql_insert_id();
     251    $page['waiting_id'] = pwg_db_insert_id();
    252252
    253253    if ($conf['email_admin_on_picture_uploaded'])
     
    289289  $query.= ';';
    290290  $result= pwg_query( $query );
    291   $row = mysql_fetch_assoc( $result );
     291  $row = pwg_db_fetch_assoc( $result );
    292292  $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
    293293  $extension = get_extension( $_FILES['picture']['name'] );
Note: See TracChangeset for help on using the changeset viewer.