Popular Vulnerable Code

Errors

Errors using inadequate data are much less than those using no data at all.
-Charles Babbage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
if (isset($_GET['action']) || isset($_POST['prune']) || isset($_POST['prune_comply']))
{
if (isset($_POST['prune_comply']))
{
confirm_referrer('admin_prune.php');

$prune_from = $_POST['prune_from'];
$prune_days = intval($_POST['prune_days']);
$prune_date = ($prune_days) ? time() - ($prune_days*86400) : -1;

@set_time_limit(0);

if ($prune_from == 'all')
{
$result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
$num_forums = $db->num_rows($result);

for ($i = 0; $i < $num_forums; ++$i)
{
$fid = $db->result($result, $i);

prune($fid, $_POST['prune_sticky'], $prune_date);
update_forum($fid);
}
}
else
{
$prune_from = intval($prune_from);
prune($prune_from, $_POST['prune_sticky'], $prune_date);
update_forum($prune_from);
}

// Locate any "orphaned redirect topics"and delete them
$result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
$num_orphans = $db->num_rows($result);

if ($num_orphans)
{
for ($i = 0; $i < $num_orphans; ++$i)
$orphans[] = $db->result($result, $i);

$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
}

redirect('admin_prune.php', 'Posts pruned. Redirecting &hellip;');
}
?>
...<snip>...

<div>
<h2><span>Prune</span></h2>
<div>
<form method="post"action="admin_prune.php?action=foo">
<div>
<input type="hidden"name="prune_days"value="<?php echo $prune_days ?>"/>
<input type="hidden"name="prune_sticky"value="<?php echo $_POST['prune_sticky'] ?>"/>
<input type="hidden"name="prune_from"value="<?php echo $prune_from ?>"/>
<fieldset>
<legend>Confirm prune posts</legend>
<div>
<p>Are you sure that you want to prune all topics older than <?php echo $prune_days ?> days from <?php echo $forum ?>? (<?php echo $num_topics ?> topics)</p>
<p>WARNING! Pruning posts deletes them permanently.</p>
</div>
</fieldset>
</div>
<p><input type="submit"name="prune_comply"value="Prune"/><a href="javascript:history.go(-1)">Go back</a></p>
If you enjoyed this post,make sure you subscribe to my RSS feed!

1 comment to Errors

Leave a Reply

  

  

  

You can use these HTML tags

<a href=""title=""><abbr title=""><acronym title=""><b><blockquote cite=""><cite><code><del datetime=""><em><i><q cite=""><strike><strong><pre lang=""line=""escaped=""highlight="">