<?php
class QS{
	function getUsernameList(){
		$databasePath = "";
		if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
				$rootPath = "C:/AOB/";
			}else{
				$rootPath = "/etc/AOB/";
		}
		if (filesize("root.inf") > 0){
			//Use the special path instead.
			$rootPath = trim(file_get_contents("root.inf"));
		}
		$databasePath = $rootPath . "whitelist.config";
		$authdata =  file_get_contents($databasePath);
		$usernameList = [];
		foreach(explode("\n",$authdata) as $value){
			 array_push($usernameList,explode(",",$value)[0]);
		}
		array_pop($usernameList);
		return $usernameList;
	}
	
	function filepath($str){
		return '"'.explode("<and>",explode("file_request=../../",$str)[1])[0].'"';
	}
	
	function checkfileexist($str){
		$path = $this->filepath($str);
		$path = str_replace('"',"",$path);
		return file_exists($path) ? "true" : "false";
	}

	function arr2jsarr($arr){
		$str = "[";
		foreach($arr as $value){
			 $str = $str.'"'.$value.'",';
		}
		$str = substr($str, 0, -1);
		$str = $str."]";
		return $str;
	}
}