%PDF- %PDF-
Direktori : /home2/vacivi36/www2]/old/wp-content/plugins/loco-translate/src/compat/ |
Current File : //home2/vacivi36/www2]/old/wp-content/plugins/loco-translate/src/compat/PosixExtension.php |
<?php /** * */ abstract class Loco_compat_PosixExtension { private static $uid = null; private static $gid = null; public static function getuid(){ if( is_null(self::$uid) ){ // use posix function if extension available if( function_exists('posix_geteuid') ){ self::$uid = posix_geteuid(); } // else use temp file system to establish owner else { self::$uid = self::getuidViaTempDir(); } } return self::$uid; } public static function getgid(){ if( is_null(self::$gid) ){ // use posix function if extension available if( function_exists('posix_getegid') ){ self::$gid = posix_getegid(); } // else use temp file system to establish group owner else { self::$gid = self::getgidViaTempDir(); } } return self::$gid; } /** * @return int */ public static function getuidViaTempDir(){ $dir = get_temp_dir(); if( 04000 & fileperms($dir) ){ trigger_error( sprintf('%s directory has setuid bit, getuid may not be accurate'), E_USER_NOTICE ); } $path = wp_tempnam( 'loco-sniff-'.time(), $dir ); $uid = fileowner($path); unlink( $path ); return $uid; } /** * @return int */ public static function getgidViaTempDir(){ $dir = get_temp_dir(); if( 02000 & fileperms($dir) ){ trigger_error( sprintf('%s directory has setgid bit, getgid may not be accurate'), E_USER_NOTICE ); } $path = wp_tempnam( 'loco-sniff-'.time(), $dir ); $gid = filegroup($path); unlink( $path ); return $gid; } /** * Get the name of the user that the web server runs under * This is only for visual/info purposes. * @return string */ public static function getHttpdUser(){ if( function_exists('posix_geteuid') ){ $info = posix_getpwuid( posix_geteuid() ); return $info['name']; } // @codeCoverageIgnoreStart if( false !== stripos(PHP_SAPI,'apache') ){ return 'Apache'; } return __('the web server','loco'); // @codeCoverageIgnoreEnd } }