| 1 |
<?php /* $Id */ |
|---|
| 2 |
//Copyright (C) 2006 Magnus Ullberg (magnus@ullberg.us) |
|---|
| 3 |
// |
|---|
| 4 |
//This program is free software; you can redistribute it and/or |
|---|
| 5 |
//modify it under the terms of the GNU General Public License |
|---|
| 6 |
//as published by the Free Software Foundation; either version 2 |
|---|
| 7 |
//of the License, or (at your option) any later version. |
|---|
| 8 |
// |
|---|
| 9 |
//This program is distributed in the hope that it will be useful, |
|---|
| 10 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
//GNU General Public License for more details. |
|---|
| 13 |
|
|---|
| 14 |
isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action=''; |
|---|
| 15 |
|
|---|
| 16 |
isset($_REQUEST['number'])?$number = $_REQUEST['number']:$number=''; |
|---|
| 17 |
|
|---|
| 18 |
isset($_REQUEST['editnumber'])?$editnumber = $_REQUEST['editnumber']:$editnumber=''; |
|---|
| 19 |
|
|---|
| 20 |
$dispnum = "blacklist"; //used for switch on config.php |
|---|
| 21 |
|
|---|
| 22 |
//if submitting form, update database |
|---|
| 23 |
|
|---|
| 24 |
if(isset($_REQUEST['action'])) { |
|---|
| 25 |
switch ($action) { |
|---|
| 26 |
case "add": |
|---|
| 27 |
blacklist_add($_POST); |
|---|
| 28 |
redirect_standard(); |
|---|
| 29 |
break; |
|---|
| 30 |
case "delete": |
|---|
| 31 |
blacklist_del($number); |
|---|
| 32 |
redirect_standard(); |
|---|
| 33 |
break; |
|---|
| 34 |
case "edit": |
|---|
| 35 |
blacklist_del($editnumber); |
|---|
| 36 |
blacklist_add($_POST); |
|---|
| 37 |
redirect_standard('editnumber'); |
|---|
| 38 |
break; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
} |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
$numbers = blacklist_list(); |
|---|
| 45 |
?> |
|---|
| 46 |
</div> |
|---|
| 47 |
|
|---|
| 48 |
<!-- NO rnav in this module --> |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
<div class="content"> |
|---|
| 52 |
<?php |
|---|
| 53 |
if ($action == 'delete') |
|---|
| 54 |
echo '<h3>'._("Blacklist entry").' '.$itemid.' '._("deleted").'!</h3>'; |
|---|
| 55 |
|
|---|
| 56 |
if (is_array($numbers)) { |
|---|
| 57 |
|
|---|
| 58 |
?> |
|---|
| 59 |
|
|---|
| 60 |
<table cellpadding="5"> |
|---|
| 61 |
<tr> |
|---|
| 62 |
<td colspan="4"><h5><?php echo _("Blacklist entries") ?><hr></h5></td> |
|---|
| 63 |
</tr> |
|---|
| 64 |
|
|---|
| 65 |
<tr> |
|---|
| 66 |
<td><b><?php _("Number") ?></b></td> |
|---|
| 67 |
<td> </td> |
|---|
| 68 |
<td> </td> |
|---|
| 69 |
</tr> |
|---|
| 70 |
|
|---|
| 71 |
<?php |
|---|
| 72 |
// Why should I specify type=setup ??? |
|---|
| 73 |
|
|---|
| 74 |
foreach ($numbers as $num) { |
|---|
| 75 |
print('<tr>'); |
|---|
| 76 |
printf('<td>%s</td>', $num); |
|---|
| 77 |
printf('<td><a href="%s?type=setup&display=%s&number=%s&action=delete">%s</a></td>', |
|---|
| 78 |
$_SERVER['PHP_SELF'], urlencode($dispnum), urlencode($num), _("Delete")); |
|---|
| 79 |
printf('<td><a href="#" onClick="theForm.number.value = \'%s\'; theForm.editnumber.value = \'%s\' ; theForm.action.value = \'edit\' ; ">%s</a></td>', |
|---|
| 80 |
$num, $num, _("Edit")); |
|---|
| 81 |
print('</tr>'); |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
print('</table>'); |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
?> |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
<form autocomplete="off" name="edit" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return edit_onsubmit();"> |
|---|
| 91 |
<input type="hidden" name="display" value="<?php echo $dispnum?>"> |
|---|
| 92 |
<input type="hidden" name="action" value="add"> |
|---|
| 93 |
<input type="hidden" name="editnumber" value=""> |
|---|
| 94 |
|
|---|
| 95 |
<table> |
|---|
| 96 |
<tr><td colspan="2"><h5><?php echo _("Add or replace entry") ?><hr></h5></td></tr> |
|---|
| 97 |
|
|---|
| 98 |
<tr> |
|---|
| 99 |
<td><a href="#" class="info"><?php echo _("Number:")?> |
|---|
| 100 |
<span><?php echo _("Enter the number you want to block")?></span></a></td> |
|---|
| 101 |
<td><input type="text" name="number"></td> |
|---|
| 102 |
</tr> |
|---|
| 103 |
|
|---|
| 104 |
<tr> |
|---|
| 105 |
<td colspan="2"><br><h6><input name="submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6></td> |
|---|
| 106 |
</tr> |
|---|
| 107 |
</table> |
|---|
| 108 |
|
|---|
| 109 |
<script language="javascript"> |
|---|
| 110 |
<!-- |
|---|
| 111 |
|
|---|
| 112 |
var theForm = document.edit; |
|---|
| 113 |
theForm.number.focus(); |
|---|
| 114 |
|
|---|
| 115 |
function edit_onsubmit() { |
|---|
| 116 |
defaultEmptyOK = false; |
|---|
| 117 |
if (!isInteger(theForm.number.value)) |
|---|
| 118 |
return warnInvalid(theForm.number, "Please enter a valid Number"); |
|---|
| 119 |
return true; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
--> |
|---|
| 124 |
</script> |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
</form> |
|---|