Changeset 14688


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

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

Location:
trunk/admin
Files:
3 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,
  • trunk/admin/include/functions_history.inc.php

    r12922 r14688  
    138138    }
    139139  }
     140
     141  if (isset($search['fields']['ip']))
     142  {
     143    $clauses[] = 'IP LIKE "'.$search['fields']['ip'].'"';
     144  }
    140145 
    141146  $clauses = prepend_append_array_items($clauses, '(', ')');
  • trunk/admin/themes/default/template/history.tpl

    r7995 r14688  
    6969  <label>
    7070    {'File name'|@translate}
    71     <input name="filename" value="{$FILENAME}" type="text">
     71                <input name="filename" value="{$FILENAME}" type="text" size="12">
    7272  </label>
     73
     74        <label>
     75                {'IP'|@translate}
     76                <input name="ip" value="{$IP}" type="text" size="12">
     77        </label>
    7378
    7479  <label>
Note: See TracChangeset for help on using the changeset viewer.