Changeset 21652


Ignore:
Timestamp:
Mar 17, 2013, 3:55:39 PM (11 years ago)
Author:
mistic100
Message:

replace mysql_* by pwg_db_* and correct errors inherited by mysql return values

Location:
extensions/event_cats
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/autolog_entries.inc.php

    r8956 r21652  
    104104          elseif ($a == 3) { // Image
    105105            $url_end.= ($url_end == '') ? '' : '&img='.$arg2;
    106             $t = mysql_fetch_row(pwg_query("
     106            $t = pwg_db_fetch_row(pwg_query("
    107107             SELECT `name`, `file`
    108108             FROM `".IMAGES_TABLE."`
  • extensions/event_cats/admin/autolog_new.inc.php

    r8956 r21652  
    111111  (count($ec_lists['user_ids']) == 0) ? 'style = "display:none;"' : ''
    112112);
    113 $template->assign('ec_no_assoc', ((mysql_num_rows(pwg_query("
     113$template->assign('ec_no_assoc', ((pwg_db_num_rows(pwg_query("
    114114  SELECT *
    115115  FROM `".IMAGE_CATEGORY_TABLE."`
  • extensions/event_cats/admin/evntcats_admin.php

    r10030 r21652  
    101101  );
    102102 
    103   $ec_exist_entries = (mysql_num_rows(pwg_query("
     103  $ec_exist_entries = (pwg_db_num_rows(pwg_query("
    104104    SELECT * FROM `".EVNTCATS_TABLE."`
    105105    WHERE `code` IS NOT NULL ;
  • extensions/event_cats/include/ec_conf.inc.php

    r8956 r21652  
    3737// following instructions :
    3838/*
    39 $t = mysql_fetch_row(pwg_query("
     39$t = pwg_db_fetch_row(pwg_query("
    4040  SELECT `value`
    4141  FROM `".CONFIG_TABLE."`
     
    123123
    124124$t = array(); $u = '0'; $v = false;
    125 if ($v = (
    126   ($t = mysql_fetch_row(pwg_query("
    127     SELECT `value`
    128     FROM `".CONFIG_TABLE."`
    129     WHERE `param` = 'event_cats';
    130   "))) !== false)
    131 ) {
     125$r = pwg_query("
     126  SELECT `value`
     127  FROM `".CONFIG_TABLE."`
     128  WHERE `param` = 'event_cats';
     129");
     130if (pwg_db_num_rows($r)) {
     131  $t = pwg_db_fetch_row($r);
    132132  $v = (count($ec_conf = explode(',', $t[0])) == count($ec_conf_index));
    133133  $u = $ec_conf[0];
  • extensions/event_cats/include/evntcats_admin_funcs.inc.php

    r10457 r21652  
    7979  $page['errors'][] =
    8080   sprintf(l10n('ec_DB_problem'), $n).
    81    'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     81   'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    8282  return false;
    8383}
     
    137137    $t2 = 0; $t3 = false; $t4 = false;
    138138    while ( // The check is executed once at minimum
    139       !($t3 = mysql_fetch_row(pwg_query("
     139      !($t3 = pwg_db_fetch_row(pwg_query("
    140140        SELECT `id`
    141141        FROM `".GROUPS_TABLE."`
     
    154154     $page['errors'][] =
    155155      sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (1) : '.
    156       'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     156      'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    157157    if (
    158158      pwg_query("
     
    162162    ) $page['errors'][] =
    163163      sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (2) : '.
    164       'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     164      'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    165165    else $page['infos'][] = sprintf(
    166166      l10n('ec_group_create_OK2'),
     
    176176      array_key_exists($_POST['ec_in_up_cat'], $ec_lists['categories'])
    177177    ) {
    178       if (mysql_num_rows(pwg_query("
     178      if (pwg_db_num_rows(pwg_query("
    179179        SELECT `id`
    180180        FROM `".CATEGORIES_TABLE."`
     
    197197         );
    198198        mass_inserts(GROUP_ACCESS_TABLE,array('group_id','cat_id'), $inserts);
    199         if (mysql_errno() == 0)
     199        if (pwg_db_errno() == 0)
    200200         $page['infos'][] = sprintf(
    201201           l10n('ec_group_create_OK2'),
     
    206206          l10n('ec_assoc_pb'),
    207207          $_POST['groupname'],$ec_lists['categories'][$_POST['ec_in_up_cat']]
    208          ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
     208         ).' : MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    209209      }
    210210    }
     
    241241          l10n('ec_assoc_pb'),
    242242          $_POST['groupname'],$ec_lists['add_pages'][$_POST['ec_in_up_aps']]
    243          ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
     243         ).' : MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    244244        else $page['infos'][] = sprintf(
    245245         l10n('ec_group_create_OK2'),
     
    274274          AND `user_id` = '$ec_user_id';
    275275      ");
    276       while ($row = mysql_fetch_array($result))
     276      while ($row = pwg_db_fetch_assoc($result))
    277277       $granteds[$row['cat_id']][] = $row['user_id'];
    278278      $inserts = array();
     
    285285      if (count($inserts) != 0) {
    286286        mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts);
    287         if (mysql_errno() == 0)
     287        if (pwg_db_errno() == 0)
    288288         $page['infos'][] = sprintf(
    289289           l10n('ec_group_create_OK2'),
     
    294294          l10n('ec_assoc_pb'),
    295295          $_POST['login'], $ec_lists['categories'][$_POST['ec_in_up_cat']]
    296          ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
     296         ).' : MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    297297      }
    298298    }
     
    553553  $arg2p = ($arg2 == 'NULL') ? 'IS NULL' : ' = '.$arg2;
    554554  $ec_user_idp = ($ec_user_id == 'NULL') ? 'IS NULL' : ' = '.$ec_user_id;
    555   if (($t1 = mysql_fetch_row(pwg_query("
     555  $r = pwg_query("
    556556    SELECT `id`
    557557    FROM `".EVNTCATS_TABLE."`
     
    563563      AND `forced`  = '".$forced."'
    564564      AND `comment` = '".$comment."'
    565   "))) !== false) { // print("<pre>$arg1 $arg2<br>$q</pre>");
     565  ");
     566  if (pwg_db_num_rows($r)) { // print("<pre>$arg1 $arg2<br>$q</pre>");
     567    $t1 = pwg_db_fetch_row();
    566568    $page['errors'][] = sprintf(l10n('ec_entry_already_exists'), $t1[0]);
    567569    return false;
     
    570572  // Delete other entries using the same code, if needed
    571573  if ($del_other) {
    572     if ((
    573       $t1 = mysql_fetch_row(pwg_query("
    574         SELECT `code`
    575         FROM `".EVNTCATS_TABLE."`
    576         WHERE `id` = ".$_POST['ec_entry_sel']
    577       ))) === false
    578     ) die('Entry not found in DB ?!');
     574    $r = pwg_query("
     575      SELECT `code`
     576      FROM `".EVNTCATS_TABLE."`
     577      WHERE `id` = ".$_POST['ec_entry_sel']
     578    );
     579    if (!pwg_db_num_rows($r)) die('Entry not found in DB ?!');
     580    $t1 = pwg_db_fetch_row($r);
    579581    $r = pwg_query("
    580582      SELECT `id`
     
    583585       AND `id` <> ".$_POST['ec_entry_sel']
    584586    );
    585     while ($t2 = mysql_fetch_row($r)) if (!ec_delete_entry_OK($t2[0]))
     587    while ($t2 = pwg_db_fetch_row($r)) if (!ec_delete_entry_OK($t2[0]))
    586588     return false;
    587589  }
     
    608610      $page['errors'][] =
    609611       l10n('ec_entry_create_pb').' : '.
    610        'MySQL error '.mysql_errno().', "'.mysql_error().'"'
     612       'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"'
    611613      ;
    612614      $ret = false;
     
    616618      $forced = ($forced == 'false') ? '' : l10n('ec_cnfrm_forced');
    617619      $page['infos'][] =
    618        sprintf(l10n('ec_entry_create_OK'), mysql_insert_id()).
     620       sprintf(l10n('ec_entry_create_OK'), pwg_db_insert_id()).
    619621       $ec_code.' => '.
    620622       $ec_lists['user_ids'][$ec_user_id].$forced
     
    639641      $page['errors'][] =
    640642       l10n('ec_entry_create_pb').' : '.
    641        'MySQL error '.mysql_errno().', "'.mysql_error().'"'
     643       'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"'
    642644      ;
    643645      $ret = false;
     
    662664function ec_delete_entry_OK($ec_id) {
    663665  global $page;
    664   if (count($t = mysql_fetch_row(pwg_query("
     666  $r = pwg_query("
    665667    SELECT `code`
    666668    FROM `".EVNTCATS_TABLE."`
    667669    WHERE `id` = $ec_id;
    668   "))) == 0) {
     670  ");
     671  if (!pwg_db_num_rows($r)) {
    669672    $page['errors'][] = sprintf(l10n('ec_entry_dont_exist'), $ec_id);
    670673    return false;
    671674  }
     675  $t = pwg_db_fetch_row($r);
    672676  if (pwg_query("
    673677    DELETE FROM `".EVNTCATS_TABLE."`
     
    677681     sprintf(l10n('ec_entry_del_nok'),
    678682     $ec_id).
    679      'MySQL error '.mysql_errno().', "'.mysql_error().'"';
     683     'MySQL error '.pwg_db_errno().', "'.pwg_db_error().'"';
    680684    return false;
    681685  }
  • extensions/event_cats/include/evntcats_main_funcs.inc.php

    r10052 r21652  
    7777 */
    7878function ec_image_exists($cat, $img) {
    79   return (mysql_fetch_row(pwg_query("
     79  $r = pwg_query("
    8080    SELECT *
    8181    FROM `".IMAGE_CATEGORY_TABLE."`
    8282    WHERE `category_id` = ".$cat."
    8383     AND `image_id` = ".$img
    84   )) !== false);
     84  );
     85  return (bool)pwg_num_rows($r);
    8586}
    8687
     
    207208  if (defined('ADD_PAGES_TABLE')) {
    208209    $res = pwg_query("SELECT `id`, `title` FROM `".ADD_PAGES_TABLE."`;");
    209     while ($r = mysql_fetch_array($res)) {
     210    while ($r = pwg_db_fetch_assoc($res)) {
    210211      $a = (is_in($r['title'], '/user_id=')) ?
    211212       explode('/user_id=' , $r['title']) : array($r['title']);
     
    281282    ORDER BY `id`
    282283  ");
    283   while ($r = mysql_fetch_assoc($q))
     284  while ($r = pwg_db_fetch_assoc($q))
    284285   $ec_lists['ec_table'][intval($r['id'])] = $r;
    285286 
     
    395396  // certain group (in groups, level (friends, family, contacts),
    396397  // or user status (generic))
    397   $types_entry_exists = (($t = mysql_fetch_row(pwg_query("
     398  $r = pwg_query("
    398399    SELECT `arg2`
    399400    FROM `".EVNTCATS_TABLE."`
     
    402403      AND `arg2` IS NOT NULL
    403404    LIMIT 1;
    404   "))) !== false);
    405   $ec_lists['types_granted'] = ($types_entry_exists) ? $t[0] : 0;
     405  ");
     406  if (pwg_db_num_rows($r)) {
     407    $types_entry_exists = true;
     408    list($ec_lists['types_granted']) = pwg_db_fetch_row($r);
     409  }
     410  else {
     411    $types_entry_exists = false;
     412    $ec_lists['types_granted'] = 0;
     413  }
    406414 
    407415  return $types_entry_exists;
     
    495503          AND `user_id` > 2;
    496504      ");
    497       while ($row = mysql_fetch_array($result)) {
     505      while ($row = pwg_db_fetch_assoc($result)) {
    498506        if (!isset($user_granted_from_type[$row['level']])) {
    499507          $user_granted_from_type[$row['level']] = array();
     
    534542        AND `user_id` > 2;
    535543    ");
    536     while ($row = mysql_fetch_array($result)) {
     544    while ($row = pwg_db_fetch_assoc($result)) {
    537545      if (!isset($granted_groups[$row['group_id']])) {
    538546        $granted_groups[$row['group_id']] = array();
  • extensions/event_cats/main.inc.php

    r10458 r21652  
    249249    ");
    250250    $insert = array();
    251     while ($row = mysql_fetch_assoc($result))
     251    while ($row = pwg_db_fetch_assoc($result))
    252252     $insert[] = "(".$new_user['id'].",".$row['cat_id'].")";
    253253    if (!empty($insert)) pwg_query("
     
    263263    ");
    264264    $insert = array();
    265     while ($row = mysql_fetch_assoc($result))
     265    while ($row = pwg_db_fetch_assoc($result))
    266266     $insert[] = "(".$new_user['id'].",".$row['group_id'].")";
    267267    if (!empty($insert)) pwg_query("
     
    277277    ");
    278278    $insert = array();
    279     while ($row = mysql_fetch_assoc($result))
     279    while ($row = pwg_db_fetch_assoc($result))
    280280     $insert[] = "(".$new_user['id'].",".$row['level'].")";
    281281    if (!empty($insert)) pwg_query("
Note: See TracChangeset for help on using the changeset viewer.