All pastes #402252 Raw Edit

yury

public php v1 · immutable
·published 2007-03-19 20:20 UTC
rendered paste body
<?php/* * * Determine what user that script runder as. * */// check if posix is enabledif (function_exists('posix_geteuid')) {		// Weeeee! got posix ;)		$winfo = posix_getpwuid(posix_geteuid());		print("Got info using posix!<br>\n<pre>");		print_r($winfo);		print("</pre>");	} 		else {			// no posix :( sux.						$filename = "user_test_" . time(); // i don't think such file will exist in cur dir ;P			if (!$handle = fopen($filename, 'w')) {			         echo "Cannot open file ($filename)";			         exit;			   }			// Write to file.			if (fwrite($handle, "This is a test file, you can safely remove it.") === FALSE) {			     echo "Cannot write to file ($filename)";			     exit;   			 }  			fclose($handle);			$file_stat = stat($filename);			print("Got info from creating a file!<br>\n UID: ${file_stat["uid"]} GID: ${file_stat["gid"]} <br>\n");			unlink($filename); //remove the test file		}?>