Skip to content

Commit

Permalink
feature 2601: Allow searching by ip in admin history
Browse files Browse the repository at this point in the history
also remove php warnings when tags zere deleted after visits

git-svn-id: http://piwigo.org/svn/trunk@14688 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed May 2, 2012
1 parent db0d423 commit 1307d07
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
43 changes: 19 additions & 24 deletions admin/history.php
Expand Up @@ -118,6 +118,15 @@
);
}

if (!empty($_POST['ip']))
{
$search['fields']['ip'] = str_replace(
'*',
'%',
pwg_db_real_escape_string($_POST['ip'])
);
}

$search['fields']['display_thumbnail'] = $_POST['display_thumbnail'];
// Display choise are also save to one cookie
if (!empty($_POST['display_thumbnail'])
Expand All @@ -129,7 +138,7 @@
{
$cookie_val = null;
}

pwg_set_cookie_var('display_thumbnail', $cookie_val, strtotime('+1 month') );

// TODO manage inconsistency of having $_POST['image_id'] and
Expand Down Expand Up @@ -226,7 +235,7 @@
$username_of = array();
$category_ids = array();
$image_ids = array();
$tag_ids = array();
$has_tags = false;

foreach ($data as $row)
{
Expand All @@ -244,16 +253,10 @@

if (isset($row['tag_ids']))
{
foreach (explode(',', $row['tag_ids']) as $tag_id)
{
array_push($tag_ids, $tag_id);
}
$has_tags = true;
}

array_push(
$history_lines,
$row
);
$history_lines[] = $row;
}

// prepare reference data (users, tags, categories...)
Expand Down Expand Up @@ -338,24 +341,14 @@
// echo '<pre>'; print_r($high_filesize_of_image); echo '</pre>';
}

if (count($tag_ids) > 0)
if ($has_tags > 0)
{
$tag_ids = array_unique($tag_ids);

$query = '
SELECT
id,
name
FROM '.TAGS_TABLE.'
WHERE id IN ('.implode(', ', $tag_ids).')
;';
$name_of_tag = array();

$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
$name_of_tag[ $row['id'] ] = $row['name'];
}
FROM '.TAGS_TABLE;
$name_of_tag = simple_hash_from_query($query, 'id', 'name');
}

$i = 0;
Expand Down Expand Up @@ -430,7 +423,7 @@
{
$tags_string = preg_replace(
'/(\d+)/e',
'$name_of_tag["$1"]',
'isset($name_of_tag["$1"]) ? $name_of_tag["$1"] : "$1"',
str_replace(
',',
', ',
Expand Down Expand Up @@ -630,6 +623,7 @@

$form['image_id'] = @$page['search']['fields']['image_id'];
$form['filename'] = @$page['search']['fields']['filename'];
$form['ip'] = @$page['search']['fields']['ip'];

$form['display_thumbnail'] = @$page['search']['fields']['display_thumbnail'];
}
Expand All @@ -655,6 +649,7 @@
array(
'IMAGE_ID' => @$form['image_id'],
'FILENAME' => @$form['filename'],
'IP' => @$form['ip'],

'month_list' => $month_list,

Expand Down
5 changes: 5 additions & 0 deletions admin/include/functions_history.inc.php
Expand Up @@ -137,6 +137,11 @@ function get_history($data, $search, $types)
);
}
}

if (isset($search['fields']['ip']))
{
$clauses[] = 'IP LIKE "'.$search['fields']['ip'].'"';
}

$clauses = prepend_append_array_items($clauses, '(', ')');

Expand Down
7 changes: 6 additions & 1 deletion admin/themes/default/template/history.tpl
Expand Up @@ -68,9 +68,14 @@

<label>
{'File name'|@translate}
<input name="filename" value="{$FILENAME}" type="text">
<input name="filename" value="{$FILENAME}" type="text" size="12">
</label>

<label>
{'IP'|@translate}
<input name="ip" value="{$IP}" type="text" size="12">
</label>

<label>
{'Thumbnails'|@translate}
<select name="display_thumbnail">
Expand Down

0 comments on commit 1307d07

Please sign in to comment.