Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
JAVA
/
system
/
authentication
:
htaccess_editor.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php require($GC_other_Path . "/Passwd.php"); class htaccessEditor{ var $users = Array(); var $passwords = Array(); var $filename = ""; var $filePasswd; function htaccessEditor($filename){ if($filename == "") die("Filename is empty!"); if(!file_exists($filename)) die("File '$filename' not found!"); $this->filename = $filename; $this->filePasswd = new File_Passwd(); $lines = file($filename); foreach($lines as $line){ $values = explode(":", $line); array_push($this->users, trim($values[0])); array_push($this->passwords, trim($values[1])); } } function addUser($username, $password){ for($u = 0; $u < sizeof($this->users); $u++) if($this->users[$u] == $username){ $this->passwords[$u] = $this->_getPassword($password); return true; } array_push($this->users, $username); array_push($this->passwords, $this->_getPassword($password)); return true; } function deleteUser($username){ $selIndex = -1; for($u = 0; $u < sizeof($this->users); $u++) if($this->users[$u] == $username) $selIndex = $u; if($selIndex > -1){ unset($this->users[$selIndex]); unset($this->passwords[$selIndex]); }else{ return false; } } function _getPassword($password){ if(strpos(strToUpper(PHP_OS), "WIN") === false){ # return crypt($password, substr($password, 0, 2)); return $this->filePasswd->crypt_des($password); }else{ return $this->filePasswd->crypt_apr_md5($password); } } function writeFile(){ $content = ""; for($u = 0; $u < sizeof($this->users); $u++) $content .= $this->users[$u] . ":" . $this->passwords[$u] . "\n"; $handle = fopen($this->filename, "w"); fwrite($handle, $content); fclose($handle); } } ?>