Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function check($wholeFile, $username, $password){
- $strToCompare = $username.":".$password;
- if(stristr($wholeFile, $strToCompare))
- return true;
- else return false;
- };
- function logged_users($file){
- $strFile = file_get_contents($file);
- $arrFile = explode("\n", $strFile);
- $pole = array(array());
- for($i = 0; $i < count($arrFile); $i++){
- $pole[$i] = explode(":", $arrFile[$i]);
- }
- $usernames = array();
- $passwords = array();
- $k = 0;
- for($i = 0; $i < count($pole)-1; $i++){
- $usernames[$k] = $pole[$i][0];
- $passwords[$k] = $pole[$i][1];
- $k++;
- }
- echo "<form method='POST' action='log.php'><table>\n";
- for($i = 0; $i < count($usernames); $i++){
- echo "<tr><td><input type='checkbox' name='users[]' value='".$usernames[$i]."'/>".($i+1)."</td><td>".$usernames[$i]."</td><td>".$passwords[$i]."</td></tr>\n";
- }
- echo "</table>\n";
- echo "<input type='submit' name='odeslat' value='smazat' />\n</form>\n";
- }
- function log_user($username, $password){
- file_put_contents("log.txt", $username.":".$password."\n", FILE_APPEND);
- }
- function delete_users($users = array()){
- $strFile = file_get_contents("log.txt");
- $arrFile = explode("\n", $strFile);
- $patterns = array();
- for($i = 0; $i < count($users); $i++){
- $patterns[$i] = "/^".$users[$i].":[\w\d]+\s/";
- }
- $strFile = preg_replace($patterns, "", $strFile);
- $arrFile = explode("\n", $strFile);
- file_put_contents("log.txt", $strFile);
- logged_users("log.txt");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement