Ignore:
Timestamp:
May 2, 2012, 10:24:28 PM (12 years ago)
Author:
rvelices
Message:

feature 2601: Allow searching by ip in admin history
also remove php warnings when tags zere deleted after visits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r12922 r14688  
    119119  }
    120120
     121  if (!empty($_POST['ip']))
     122  {
     123    $search['fields']['ip'] = str_replace(
     124      '*',
     125      '%',
     126      pwg_db_real_escape_string($_POST['ip'])
     127      );
     128  }
     129
    121130  $search['fields']['display_thumbnail'] = $_POST['display_thumbnail'];
    122131  // Display choise are also save to one cookie
     
    130139    $cookie_val = null;
    131140  }
    132  
     141
    133142  pwg_set_cookie_var('display_thumbnail', $cookie_val, strtotime('+1 month') );
    134143
     
    227236  $category_ids = array();
    228237  $image_ids = array();
    229   $tag_ids = array();
     238  $has_tags = false;
    230239
    231240  foreach ($data as $row)
     
    245254    if (isset($row['tag_ids']))
    246255    {
    247       foreach (explode(',', $row['tag_ids']) as $tag_id)
    248       {
    249         array_push($tag_ids, $tag_id);
    250       }
    251     }
    252 
    253     array_push(
    254       $history_lines,
    255       $row
    256       );
     256      $has_tags = true;
     257    }
     258
     259    $history_lines[] = $row;
    257260  }
    258261
     
    339342  }
    340343
    341   if (count($tag_ids) > 0)
    342   {
    343     $tag_ids = array_unique($tag_ids);
    344 
     344  if ($has_tags > 0)
     345  {
    345346    $query = '
    346347SELECT
    347348    id,
    348349    name
    349   FROM '.TAGS_TABLE.'
    350   WHERE id IN ('.implode(', ', $tag_ids).')
    351 ;';
    352     $name_of_tag = array();
    353 
    354     $result = pwg_query($query);
    355     while ($row = pwg_db_fetch_assoc($result))
    356     {
    357       $name_of_tag[ $row['id'] ] = $row['name'];
    358     }
     350  FROM '.TAGS_TABLE;
     351    $name_of_tag = simple_hash_from_query($query, 'id', 'name');
    359352  }
    360353
     
    431424      $tags_string = preg_replace(
    432425        '/(\d+)/e',
    433         '$name_of_tag["$1"]',
     426        'isset($name_of_tag["$1"]) ? $name_of_tag["$1"] : "$1"',
    434427        str_replace(
    435428          ',',
     
    631624  $form['image_id'] = @$page['search']['fields']['image_id'];
    632625  $form['filename'] = @$page['search']['fields']['filename'];
     626  $form['ip'] = @$page['search']['fields']['ip'];
    633627
    634628  $form['display_thumbnail'] = @$page['search']['fields']['display_thumbnail'];
     
    656650    'IMAGE_ID' => @$form['image_id'],
    657651    'FILENAME' => @$form['filename'],
     652    'IP' => @$form['ip'],
    658653
    659654    'month_list' => $month_list,
Note: See TracChangeset for help on using the changeset viewer.