| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/forevervamp.com/cgi-bin/ |
Upload File : |
<?php
class htpasswd {
var $fp;
var $filename;
var $logname;
function __construct($filename, $logname) {
$this->filename = $filename;
$this->logname = $logname;
}
function open_file( ) {
//$this->logToFile ('Open Password file :' . $this->filename );
@$this->fp = fopen($this->filename,'r+') ;
if ( $this->fp )
return 'File Open';
else {
$this->logToFile ('Unable to open password file ');
return ' Unable to open file ' . $filename;
}
}
function logToFile($msg)
{
// open file
$fd = fopen($this->logname, "a+");
// append date/time to message
$str = "[" . date("Y-m-d h:i:s", time()) . "] " . $msg;
// write string
fwrite($fd, $str . "\n");
// close file
fclose($fd);
}
function user_exists($username)
{
$this->logToFile ('Start Exists User :' . $username );
rewind($this->fp);
while(!feof($this->fp)) {
$line = rtrim(fgets($this->fp));
if(!$line)
continue;
$tmp = explode(":",$line);
$lusername = $tmp[0];
if($lusername == $username) {
$this->logToFile ('User Exists :' . $username );
return 1;
}
}
$this->logToFile ('User Does not Exists :' . $username );
return 0;
}
function user_add($username,$password)
{
$this->logToFile ('Start Add User :' . $username );
if($this->user_exists($username)) {
$this->logToFile ('User Not Added :' . $username );
return false;
}
fseek($this->fp,0,SEEK_END);
$encryptPasswd = $this->getPassword( $password );
fwrite ( $this->fp, $username.':'. $encryptPasswd. "\n");
$this->logToFile ('User Added :' . $username );
return true;
}
function user_delete($username)
{
$this->logToFile ('Start Delete User :' . $username );
$data = '';
$found = false;
rewind($this->fp);
while(!feof($this->fp)) {
$line = rtrim(fgets($this->fp));
if(!$line)
continue;
$tmp = explode(":",$line);
$lusername = $tmp[0];
// $lusername = explode(":",$line)[0];
if($lusername != $username) {
$data .= $line."\n";
}
else {
$found = true;
}
}
if ( $found == true )
{
$this->fp = fopen($this->filename,'w');
fwrite($this->fp,rtrim($data).(trim($data) ? "\n" : ''));
fclose($this->fp);
$this->fp = fopen($this->filename,'r+');
return true;
} else {
// name not found don't remove
return false;
}
}
function user_list()
{
$this->logToFile ( 'List Users' );
$data = '';
rewind($this->fp);
while(!feof($this->fp)) {
$line = rtrim(fgets($this->fp));
$data .= $line."<br>";
}
return $data;
}
function user_query($username) {
$data = '';
$found = false;
$this->logToFile ('Find User :' . $username );
rewind($this->fp);
while(!feof($this->fp)) {
$line = rtrim(fgets($this->fp));
if(!$line)
continue;
$tmp = explode(":",$line);
$lusername = $tmp[0];
if($lusername != $username) {
$data .= $line."\n";
}
else {
$this->logToFile ( 'Found User :' . $username );
$found = true;
}
}
return $found;
}
function user_update($username,$password)
{
$this->logToFile ('Start Update User : ' . $username );
rewind($this->fp);
while(!feof($this->fp)) {
$line = rtrim(fgets($this->fp));
if(!$line)
continue;
$tmpLine = explode(":",$line);
$lusername = $tmpLine[0];
$lpasswd = $tmpLine[1];
if($lusername == $username) {
$this->logToFile ('Found User : ' . $username );
fseek($this->fp,(-15 - strlen($username)),SEEK_CUR);
$encryptPasswd = $this->getPassword( $password );
fwrite( $this->fp, $username . ':' . $encryptPasswd );
return true;
}
}
return false;
}
function getPassword($passwd)
{
$seed = time();
$salter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./';
srand($seed);
$salt = substr($salter,rand(1,strlen($salter)),1);
$salt .= substr($salter,rand(1,strlen($salter)),1);
// $this->logToFile (' ' . $salt );
$encpass = crypt($passwd,$salt);
return($encpass);
}
function return_log($count)
{
$this->logToFile ('Start return Log : ' . $count );
$file = file ( $this->logname );
for ( $ind = max(0, count($file) - $count); $ind < count($file); $ind++)
{
$retString .= $file[$ind] . '<br>';
}
return $retString;
}
}