CBaZ Posted September 2, 2007 Share Posted September 2, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/67696-check-all-check-box-and-deleting-entry-from-txt/ Share on other sites More sharing options...
Timma Posted September 3, 2007 Share Posted September 3, 2007 With variables inside strings use . print("Deleted ".$value.""); Use dots. echo $PageTitle; No quotation marks. There could be more. Quote Link to comment https://forums.phpfreaks.com/topic/67696-check-all-check-box-and-deleting-entry-from-txt/#findComment-340140 Share on other sites More sharing options...
CBaZ Posted September 3, 2007 Author Share Posted September 3, 2007 have fixed those issues. There's just something else wrong with the check all checkboxes and of course the delete entry from banip.txt Quote Link to comment https://forums.phpfreaks.com/topic/67696-check-all-check-box-and-deleting-entry-from-txt/#findComment-340152 Share on other sites More sharing options...
Timma Posted September 3, 2007 Share Posted September 3, 2007 Hmm, I can't see the CheckAll function even being used, also most of that function has javascript in it, so ask about it in that forum. The code on the inside, not the php stuff. Quote Link to comment https://forums.phpfreaks.com/topic/67696-check-all-check-box-and-deleting-entry-from-txt/#findComment-340154 Share on other sites More sharing options...
CBaZ Posted September 3, 2007 Author Share Posted September 3, 2007 ok got ya one last thing do you see the fputs for the deleting of .txt that should be php related sorry about the javascript I thought the php end had the bug. Quote Link to comment https://forums.phpfreaks.com/topic/67696-check-all-check-box-and-deleting-entry-from-txt/#findComment-340156 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.