Advertisement
Jakolcz

fce.php

Feb 16th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. function check($wholeFile, $username, $password){
  3.   $strToCompare = $username.":".$password;
  4.   if(stristr($wholeFile, $strToCompare))
  5.     return true;
  6.   else return false;
  7. };
  8.  
  9. function logged_users($file){
  10.   $strFile = file_get_contents($file);
  11.   $arrFile = explode("\n", $strFile);
  12.   $pole = array(array());
  13.  
  14.   for($i = 0; $i < count($arrFile); $i++){
  15.     $pole[$i] = explode(":", $arrFile[$i]);
  16.   }
  17.  
  18.   $usernames = array();
  19.   $passwords = array();
  20.   $k = 0;
  21.   for($i = 0; $i < count($pole)-1; $i++){
  22.     $usernames[$k] = $pole[$i][0];
  23.     $passwords[$k] = $pole[$i][1];
  24.     $k++;
  25.   }
  26.  
  27.   echo "<form method='POST' action='log.php'><table>\n";
  28.   for($i = 0; $i < count($usernames); $i++){
  29.     echo "<tr><td><input type='checkbox' name='users[]' value='".$usernames[$i]."'/>".($i+1)."</td><td>".$usernames[$i]."</td><td>".$passwords[$i]."</td></tr>\n";
  30.   }
  31.   echo "</table>\n";
  32.   echo "<input type='submit' name='odeslat' value='smazat' />\n</form>\n";
  33. }
  34.  
  35. function log_user($username, $password){
  36.   file_put_contents("log.txt", $username.":".$password."\n", FILE_APPEND);
  37. }
  38.  
  39. function delete_users($users = array()){
  40.   $strFile = file_get_contents("log.txt");
  41.   $arrFile = explode("\n", $strFile);
  42.  
  43.   $patterns = array();
  44.  
  45.   for($i = 0; $i < count($users); $i++){
  46.     $patterns[$i] = "/^".$users[$i].":[\w\d]+\s/";
  47.   }
  48.  
  49.   $strFile = preg_replace($patterns, "", $strFile);
  50.  
  51.   $arrFile = explode("\n", $strFile);
  52.   file_put_contents("log.txt", $strFile);
  53.   logged_users("log.txt");
  54. }
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement