AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 3.15.15.91


Current Path : /var/www/lhjmq-records.qc.ca/public_html/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/sysinfo.php

<?php

//App settings
include("includes/applogger.php");
include("includes/appsettings.php");

function thatDuration($sec){
	$time=$sec;
	$weeks=$time/604800;
	$days=($time%604800)/86400;
	$hours=(($time%604800)%86400)/3600;
	$minutes=((($time%604800)%86400)%3600)/60;
	$seconds=(((($time%604800)%86400)%3600)%60);
	$timestring='';
	if(round($days)) $timestring.=round($days)."d ";
	if(round($hours)) $timestring.=round($hours)."h ";
	if(round($minutes)) $timestring.=round($minutes)."mn";
	if(!round($minutes)&&!round($hours)&&!round($days)) $timestring.=" ".round($seconds)."s";
	return $timestring;
}

/*
$allowed_adresses = array(
	'207.96.185.210',	// Sajy's office routers
	'207.96.185.222', 
	'69.70.6.130',
	'10.0.0.150',		// ES Work
	'10.0.1.2',			// ES Home
	'10.0.1.10',		// ES Home
	'67.71.26.113',		// ES Home	(ext. IP)	
);
if(in_array($_SERVER['REMOTE_ADDR'], $allowed_adresses) == true) { // Sajy's office routers
*/
if ($appSettings->accessing_from_development_workstation) {

	$useCustomVersion = TRUE; 
	if ($useCustomVersion)
	{

	/*
		INFO_GENERAL		1	The configuration line, php.ini location, build date, Web Server, System and more.  
		INFO_CREDITS		2	PHP Credits. See also phpcredits().  
		INFO_CONFIGURATION	4	Current Local and Master values for PHP directives. See also ini_get().  
		INFO_MODULES		8	Loaded modules and their respective settings. See also get_loaded_extensions().  
		INFO_ENVIRONMENT	16	Environment Variable information that's also available in $_ENV.  
		INFO_VARIABLES		32	Shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server).  
		INFO_LICENSE		64	PHP License information. See also the license FAQ.  
		INFO_ALL			-1	Shows all of the above. This is the default value.  
	*/

		ob_start();
		phpinfo(INFO_GENERAL | INFO_ENVIRONMENT);
		$phpinfo = ob_get_contents();
		ob_end_clean();

		echo "<p><b>SYSTEM INFORMATION</b></p>";

		if (FALSE === ($uname = posix_uname())) {
			echo "Could not get system information.<br>";
		} else {			
			//print_r($uname);
			echo "System Name: " . $uname["nodename"]."<br>";
		}

		echo ('Development server: '. (($appSettings->running_on_development_server) ? "yes" : "no") . "<br>");

		//echo $phpinfo;

		//Connection data
		$mysql_host = "localhost";
		$mysql_user = "lhjmq_readonly";
		$mysql_pass = "45GhiLk19cQ";
		$mysql_db = "lhjmq_pii";
		$stat_db = "lhjmqstats_pii";

		$mysql_link = @mysql_connect($mysql_host, $mysql_user, $mysql_pass);
		if(!is_resource($mysql_link)){
			exit('MySQL is not responding'."<br>");
		} else {
			echo ('MySQL is responding'."<br>");
		}

		if(!@mysql_select_db($mysql_db, $mysql_link)){
			exit('MySQL [' . $mysql_db . '] db is not avalaible'."<br>");
		} else {
			echo ('MySQL [' . $mysql_db . '] db is avalaible'."<br>");
		}

		if(!@mysql_select_db($stat_db, $mysql_link)){
			exit('MySQL [' . $stat_db . '] db is not avalaible'."<br>");
		} else {
			echo ('MySQL [' . $stat_db . '] db is avalaible'."<br>");
		}

		$result = mysql_query($sql='SHOW MASTER STATUS', $mysql_link);
		if (!$result) { 
		   echo "Could not successfully run query ($sql) from DB: " . mysql_error() ."<br>"; 
		   exit; 
		} 
    
		if (mysql_num_rows($result) == 0) { 
		   echo "MySQL Master replication is NOT ACTIVATED"."<br>"; 
		} else {
			$replication_status = "UP";

			while ($row = mysql_fetch_assoc($result)) { 
				echo 'File = [' .$row["File"] . "]<br>";  
				echo 'Position = ' .$row["Position"] . "<br>"; 
			} 

			if ($replication_status != "UP") {
				echo "MySQL Master replication is DOWN"."<br>"; 
			   //exit; 
			} else {
				echo ('MySQL Master replication is UP'."<br>");
			}

			mysql_free_result($result); 
		}

		$result = mysql_query($sql='SHOW SLAVE STATUS', $mysql_link);
		if (!$result) { 
		   echo "Could not successfully run query ($sql) from DB: " . mysql_error() ."<br>"; 
		   exit; 
		} 

		$seconds_behind_master = 0;
    
		if (mysql_num_rows($result) == 0) { 
		   echo "MySQL Slave replication is NOT ACTIVATED"."<br>"; 
		} else {
			$replication_status = "UP";

			while ($row = mysql_fetch_assoc($result)) { 
				echo 'Master_Host = [' .$row["Master_Host"] . "]<br>";  
				echo 'Master_User = [' .$row["Master_User"] . "]<br>"; 
				echo 'Slave_IO_Running = [' .$row["Slave_IO_Running"] . "]<br>"; 
				echo 'Slave_SQL_Running = [' .$row["Slave_SQL_Running"] . "]<br>"; 				
				$seconds_behind_master = $row["Seconds_Behind_Master"];
				echo 'Seconds_Behind_Master = [' .$row["Seconds_Behind_Master"] . "]<br>"; 
			} 

			if ($replication_status != "UP") {
				echo "MySQL Slave replication is DOWN"."<br>"; 
			   //exit; 
			} else {
				echo ('MySQL Slave replication is UP'."<br>");
			}

			if ($seconds_behind_master + 0 > 30) {
				echo ('<font style="color:red">Warning: MySQL Slave server is "late"! (' . thatDuration($seconds_behind_master) . ' behind Master)</font>'."<br>");
			}

			mysql_free_result($result); 
		}
		
		mysql_close($mysql_link);

		exit('<br><b>System appears to be working properly</b>'."<br>");
	} else {
		phpinfo();
	}
}else{
	header('HTTP/1.1 403 Forbiden');
};
?>