<commit_before><?php
class Pull {

	public static function pull_status($sServer){
		
		echo "Setting up prerequisites...\n";
		$sTimestamp = time();
		global $database;
		// Insert History
		$sHistory = new History(0);
		$sHistory->uServerId = $sServer;
		$sHistory->uTimestamp = $sTimestamp;
		$sHistory->uStatus = false;
		$sHistory->InsertIntoDatabase();
		
		// Insert Statistics
		$sStatistics = new Statistics(0);
		$sStatistics->uServerId = $sServer;
		$sStatistics->uStatus = false;
		$sStatistics->uTimestamp = $sTimestamp;
		$sStatistics->InsertIntoDatabase();
		
		// Connect to Server
		$sServer = new Server($sServer);
		$sSSH = Server::server_connect($sServer, "1");
		if(is_array($sSSH)){
			die();
		}
		
		// Setup and start anti-abuse script on node.
		if($sServer->sType == 'openvz'){
			$sAbuse = escapeshellarg(file_get_contents('/var/feathur/Scripts/abuse.sh'));
			$sDumpCode = $sSSH->exec("mkdir -p /var/feathur/data;cd /var/feathur/data/;echo {$sAbuse} > abuse.sh;screen -dmS abuse bash -c \"cd /var/feathur/data/;bash abuse.sh;\";");
			
			// Pull list of suspended users:
			$sSuspended = explode("\n", $sSSH->exec("cat /var/feathur/data/suspended.txt"));
			foreach($sSuspended as $sValue){
				$sValue = preg_replace('/[^0-9]/', '', $sValue);
				if((!empty($sValue)) && ($sValue >> 10)){
					try {
						$sVPS = new VPS($sValue);
						$sVPS->uSuspended = 2;
						$sVPS->InsertIntoDatabase();
					} catch (Exception $e) {
						echo "Odd data in suspend tracker. Skipping";
					}
				}
			}
			
		}
		
		
		// Pull system stats.
		echo "Connected to server...\n";
		$sUptime = explode(' ', $sSSH->exec("cat /proc/uptime"));
		$sCPU = explode(' ', $sSSH->exec("cat /proc/loadavg"));	
		$sUsedRAM = preg_replace('/[^0-9]/', '', $sSSH->exec("free | head -n 3 | tail -n 1 | awk '{print $3}'"));
		$sTotalRAM = preg_replace('/[^0-9]/', '', $sSSH->exec("free | head -n 2 | tail -n 1 | awk '{print $2}'"));

		$sDisk = $sSSH->exec("df");
		$sDisk = explode("\n", trim($sDisk));
		array_shift($sDisk);
		foreach($sDisk as $sValue){
			$sValue = explode(" ", preg_replace("/\s+/", " ", $sValue));
			if(is_numeric($sValue[2])){
				$sDiskUsed = $sDiskUsed + $sValue[2];
				$sDiskTotal = $sDiskTotal + $sValue[1];
			}
		}
		$sDiskUsed = $sDiskUsed / 1048576;
		$sDiskTotal = $sDiskTotal / 1048576;<commit_msg>Patches to prevent continual suspending of VPS.<commit_after><?php
class Pull {

	public static function pull_status($sServer){
		
		echo "Setting up prerequisites...\n";
		$sTimestamp = time();
		global $database;
		// Insert History
		$sHistory = new History(0);
		$sHistory->uServerId = $sServer;
		$sHistory->uTimestamp = $sTimestamp;
		$sHistory->uStatus = false;
		$sHistory->InsertIntoDatabase();
		
		// Insert Statistics
		$sStatistics = new Statistics(0);
		$sStatistics->uServerId = $sServer;
		$sStatistics->uStatus = false;
		$sStatistics->uTimestamp = $sTimestamp;
		$sStatistics->InsertIntoDatabase();
		
		// Connect to Server
		$sServer = new Server($sServer);
		$sSSH = Server::server_connect($sServer, "1");
		if(is_array($sSSH)){
			die();
		}
		
		// Setup and start anti-abuse script on node.
		if($sServer->sType == 'openvz'){
			$sAbuse = escapeshellarg(file_get_contents('/var/feathur/Scripts/abuse.sh'));
			$sDumpCode = $sSSH->exec("mkdir -p /var/feathur/data;cd /var/feathur/data/;echo {$sAbuse} > abuse.sh;screen -dmS abuse bash -c \"cd /var/feathur/data/;bash abuse.sh;\";");
			
			// Pull list of suspended users:
			$sSuspended = explode("\n", $sSSH->exec("cat /var/feathur/data/suspended.txt"));
			foreach($sSuspended as $sValue){
				$sValue = preg_replace('/[^0-9]/', '', $sValue);
				if((!empty($sValue)) && ($sValue >> 10)){
					try {
						$sVPS = new VPS($sValue);
						$sVPS->uSuspended = 2;
						$sVPS->InsertIntoDatabase();
					} catch (Exception $e) {
						echo "Odd data in suspend tracker. Skipping";
					}
				}
			}
			$sClean = $sSSH->exec("rm -rf /var/feathur/data/suspended.txt");
		}
		
		
		// Pull system stats.
		echo "Connected to server...\n";
		$sUptime = explode(' ', $sSSH->exec("cat /proc/uptime"));
		$sCPU = explode(' ', $sSSH->exec("cat /proc/loadavg"));	
		$sUsedRAM = preg_replace('/[^0-9]/', '', $sSSH->exec("free | head -n 3 | tail -n 1 | awk '{print $3}'"));
		$sTotalRAM = preg_replace('/[^0-9]/', '', $sSSH->exec("free | head -n 2 | tail -n 1 | awk '{print $2}'"));

		$sDisk = $sSSH->exec("df");
		$sDisk = explode("\n", trim($sDisk));
		array_shift($sDisk);
		foreach($sDisk as $sValue){
			$sValue = explode(" ", preg_replace("/\s+/", " ", $sValue));
			if(is_numeric($sValue[2])){
				$sDiskUsed = $sDiskUsed + $sValue[2];
				$sDiskTotal = $sDiskTotal + $sValue[1];
			}
		}
		$sDiskUsed = $sDiskUsed / 1048576;
		$sDiskTotal = $sDiskTotal / 1048576;
{'fraction_non_alphanumeric': 0.20272536687631026, 'fraction_numerical': 0.014675052410901468, 'mean_word_length': 3.454715219421102, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4926799', 'n_tokens_mistral': 2085, 'n_tokens_neox': 1759, 'n_words': 359}