Jump to content

check all check box and deleting entry from .txt


CBaZ

Recommended Posts

the check all check is not working

also the fputs removing a line from banip.txt is not working

 

<script>

function CheckAll(){

if(document.frmls.chkAll.checked == true){

for(var j = 0; j < document.frmls.length; j++){

if(document.frmls.elements[j].name == "ids[]"){

document.frmls.elements[j].checked = true;

}

}

}

else if(document.frmls.chkAll.checked == false){

for(var j = 0; j < document.frmls.length; j++){

if(document.frmls.elements[j].name == "todelete[$key]"){

document.frmls.elements[j].checked = false;

}

}

}

}

</script>

<?php

session_start();

if ($_SESSION[permission] == "1") {

}

include ("header.php");

$PageTitle = "Banned IP Log";

?>

 

<h1><?php echo "$PageTitle" ?></h1>

<p class="breadcrumb"><a href="admin.php">Administrative Control</a> > <?php echo "$PageTitle" ?></p>

 

<p>This page is designed to report all Banned IPs. From My Site</p>

 

 

<table>

<tr>

<td>

<?php

$file_contents = file("../banip/banip.txt"); // the file

$file_contents_deleted = file("../banip/issues_deleted.txt"); // the file

// [ DELETE ROUTINE ]

if($_POST['action'] == "delete"){ // delete triggered

$arrToDelete = $_POST['todelete']; // assign checked items array to var

if($arrToDelete != "") { // if the array isnt open proceed

foreach($arrToDelete as $key => $value) { // assign a key and value to

//each checked item

#$file_contents_deleted[count($file_contents_deleted)] = $file_contents[$key];

$file_contents_deleted[] = $file_contents[$key];

array_splice($file_contents, $key, 1, "");// assign null value to each 

$file_contents = file("../banip/banip.txt"); // the file

print("Deleted <b>$value</b><br>");

$file_contents = file("../banip/banip.txt"); // the file

foreach($file_contents as $key=>$value){ // assign a key to each line in the file

list($entry[0],$entry[1],$entry[2],$entry[3]) = split('[,|]',$value);

$entries[]=array('key'=>$key, 'ip'=>$entry[0], 'date'=>$entry[1],

'hostname'=>$entry[2], 'browser'=>$entry[3]);

$fp = fopen("../banip/issues_deleted.txt", "r+");

fwrite($fp, "\n$entry[0], $entry[1], $entry[2], $entry[3]"); // write

fclose($fp); // close the file

$fb = fopen("../banip/banip.txt", "r+");

// open the file for writing

fputs($fb, $file_contents[$y]); // write the new file_contents

fclose($fb); // close the file

}

}

}

}

?>

<?php    // [ READ & OUTPUT FILE CONTENTS ]    ?>

<!-- The Form & Table -->

<form name="cbox" method="POST" action="<?php $PHP_SELF ?>" style="margin:0;">

<input type="hidden" name="action" value="delete">

<table width="780" height="0" border="0" cellpadding="1" cellspacing="1" class="tablehead">

<tr> 

<td class="rowA"><input name="chkAll" type="checkbox" id="chkAll" value="1" onClick="CheckAll();" title="Select All"></td>

<td class="rowA"><center><strong>IP</strong></td></center>

<td class="rowA"><center><strong>Time</strong></center></td>

<td class="rowA"><center><strong>Browser</strong></td></center>

<td class="rowA"><center><strong>Hostname</strong></center></td>

</tr> 

<?php

$file_contents = file("../banip/banip.txt"); // the file

foreach($file_contents as $key=>$value){ // assign a key to each line in the file

list($entry[0],$entry[1],$entry[2],$entry[3]) = split('[,|]',$value);

$entries[]=array('key'=>$key, 'ip'=>$entry[0], 'date'=>$entry[1],

'hostname'=>$entry[2], 'browser'=>$entry[3]);

print "<table width=\"780\" height=\"0\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"tablehead\">

<tr>

<td class=\"rowB\"><center><input name=\"todelete[$key]\" type=\"checkbox\" id=\"ids[]\" onClick=\"this.form.chkAll.checked=false; \"></td>

<td class=\"rowB\"><center><strong>".$entry[0]."</strong></center></td>

<td class=\"rowB\"><center><strong>".$entry[1]."</strong></center></td>

<td class=\"rowB\"><center><strong>".$entry[2]."</strong></center></td>

<td class=\"rowB\"><center><strong>".$entry[3]."</strong></center></td>

</tr>\n";

 

}

?>

<tr>

<td colspan="8" align="center" class="\rowB\"><input type="submit"

onClick="CheckIfChecked();" value="Remove Resolved Issue"></td>

</tr>

</table>

</form>

</td>

</table>

<br><br><br>

<?php include "footer.php" ?>

<script language="Javascript1.2">

 

// © 2000 www.CodeLifter.com

// http://www.codelifter.com

// Free for all users, but leave in this header

 

// Set the message for the alert box

am = "© COPYRIGHT 2007 MaloriaN Entertainment, ALL RIGHTS RESERVED.";

 

// do not edit below this line

// ===========================

bV = parseInt(navigator.appVersion)

bNS = navigator.appName=="Netscape"

bIE = navigator.appName=="Microsoft Internet Explorer"

 

function nrc(e) {

if (bNS && e.which > 1){

alert(am)

return false

} else if (bIE && (event.button >1)) {

alert(am)

return false;

}

}

 

document.onmousedown = nrc;

if (document.layers) window.captureEvents(Event.MOUSEDOWN);

if (bNS && bV<5) window.onmousedown = nrc;

 

 

</script>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.