本文整理汇总了PHP中posix_getgrgid函数的典型用法代码示例。如果您正苦于以下问题:PHP posix_getgrgid函数的具体用法?PHP posix_getgrgid怎么用?PHP posix_getgrgid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了posix_getgrgid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInfoByName
public function getInfoByName($filePath)
{
$this->MAX_FILE_SIZE_FOR_HASHING = 1024 * 1024;
$this->absoluteName = $filePath;
$this->name = str_replace($this->web_root_dir, '.', $filePath);
$this->ctime = 0;
$this->mtime = 0;
$this->owner = '-';
$this->group = '-';
$this->access = 0;
$this->size = -1;
$this->md5 = '-';
if (file_exists($filePath)) {
$this->ctime = filectime($filePath);
$this->mtime = filemtime($filePath);
$owner = fileowner($filePath);
$ownerInfo = function_exists('posix_getpwuid') ? posix_getpwuid($owner) : array('name' => $owner);
$this->owner = $ownerInfo['name'];
$group = filegroup($filePath);
$groupInfo = function_exists('posix_getgrgid') ? posix_getgrgid($group) : array('name' => $group);
$this->group = $groupInfo['name'];
$this->access = substr(sprintf('%o', fileperms($filePath)), -4);
if (is_file($filePath)) {
$this->size = filesize($filePath);
if ($this->size <= $this->MAX_FILE_SIZE_FOR_HASHING) {
$this->md5 = hash_file('md5', $filePath);
}
}
}
return true;
}
示例2: id2group
/**
* id2group
*
* @param int $id
* @return string
*/
public static function id2group($id = 0)
{
if (Registry::get('sysType') === 'WIN') {
return '';
} else {
if (function_exists('posix_getgrgid') && ($name = posix_getgrgid($id))) {
return $name['name'];
}
/*
exec('id -n -u ' . escapeshellarg($id), $outId, $resultId);
if ($resultId === 0) {
return trim($outId[0]);
}
*/
exec('getent group ' . escapeshellarg($id), $outGetent, $resultGetent);
if ($resultGetent === 0) {
$tmp = explode(':', $outGetent[0], 2);
return trim($tmp[0]);
}
exec(escapeshellcmd(Config::get('Perl', 'path')) . ' -e \'print getgrgid(' . escapeshellarg($id) . ');\'', $outPerl, $resultPerl);
if ($resultPerl === 0) {
$tmp = explode('*', $outPerl[0], 2);
return trim($tmp[0]);
}
}
return $id;
}
示例3: ls
function ls()
{
$list = array();
if ($handle = opendir($this->root . $this->cwd)) {
while (false !== ($file = readdir($handle))) {
if ($file == "." || $file == "..") {
continue;
}
$filename = $this->root . $this->cwd . $file;
$filetype = filetype($filename);
if ($filetype != "dir" && $filetype != "file") {
continue;
}
$filesize = $filetype == "file" ? filesize($filename) : 0;
/* owner, group, last modification and access info added by Phanatic */
$owner = posix_getpwuid(fileowner($filename));
$fileowner = $owner['name'];
$group = posix_getgrgid(filegroup($filename));
$filegroup = $group['name'];
$mtime = filemtime($filename);
$filemod = date("M d H:i", $mtime);
$fileperms = $this->perms(fileperms($filename));
clearstatcache();
$info = array("name" => $file, "size" => $filesize, "owner" => $fileowner, "group" => $filegroup, "time" => $filemod, "perms" => $fileperms);
$list[] = $info;
}
closedir($handle);
return $list;
} else {
return false;
}
}
示例4: alt_stat
function alt_stat($file)
{
$ss = @stat($file);
if (!$ss) {
return false;
}
//Couldnt stat file
$ts = array(0140000 => 'ssocket', 0120000 => 'llink', 0100000 => '-file', 060000 => 'bblock', 040000 => 'ddir', 020000 => 'cchar', 010000 => 'pfifo');
$tmpsize = $ss['size'];
$sizemod = 0;
$modnames = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
while ($tmpsize > 1024) {
$tmpsize /= 1024;
$sizemod++;
}
$hrsize = number_format($tmpsize, 2) . $modnames[$sizemod];
$p = $ss['mode'];
$t = decoct($ss['mode'] & 0170000);
// File Encoding Bit
$str = array_key_exists(octdec($t), $ts) ? $ts[octdec($t)][0] : 'u';
$str .= ($p & 0x100 ? 'r' : '-') . ($p & 0x80 ? 'w' : '-');
$str .= $p & 0x40 ? $p & 0x800 ? 's' : 'x' : ($p & 0x800 ? 'S' : '-');
$str .= ($p & 0x20 ? 'r' : '-') . ($p & 0x10 ? 'w' : '-');
$str .= $p & 0x8 ? $p & 0x400 ? 's' : 'x' : ($p & 0x400 ? 'S' : '-');
$str .= ($p & 0x4 ? 'r' : '-') . ($p & 0x2 ? 'w' : '-');
$str .= $p & 0x1 ? $p & 0x200 ? 't' : 'x' : ($p & 0x200 ? 'T' : '-');
$s = array('perms' => array('umask' => sprintf("%04o", @umask()), 'human' => $str, 'octal1' => sprintf("%o", $ss['mode'] & 0777), 'octal2' => sprintf("0%o", 0777 & $p), 'decimal' => sprintf("%04o", $p), 'fileperms' => @fileperms($file), 'mode1' => $p, 'mode2' => $ss['mode']), 'owner' => array('fileowner' => $ss['uid'], 'filegroup' => $ss['gid'], 'owner' => @posix_getpwuid($ss['uid']), 'group' => @posix_getgrgid($ss['gid'])), 'file' => array('filename' => $file, 'realpath' => @realpath($file), 'dirname' => @dirname($file), 'realdirname' => @dirname(@realpath($file)), 'basename' => @basename($file)), 'filetype' => array('type' => substr($ts[octdec($t)], 1), 'type_octal' => sprintf("%07o", octdec($t)), 'ext' => pathinfo($file, PATHINFO_EXTENSION), 'is_file' => @is_file($file), 'is_dir' => @is_dir($file), 'is_link' => @is_link($file), 'is_readable' => @is_readable($file), 'is_writable' => @is_writable($file)), 'device' => array('device' => $ss['dev'], 'device_number' => $ss['rdev'], 'inode' => $ss['ino'], 'link_count' => $ss['nlink'], 'link_to' => $s['type'] == 'link' ? @readlink($file) : ''), 'size' => array('size' => $ss['size'], 'hrsize' => $hrsize, 'blocks' => $ss['blocks'], 'block_size' => $ss['blksize']), 'time' => array('mtime' => $ss['mtime'], 'atime' => $ss['atime'], 'ctime' => $ss['ctime'], 'accessed' => @date('Y-m-d H:i:s', $ss['atime']), 'modified' => @date('Y-m-d H:i:s', $ss['mtime']), 'created' => @date('Y-m-d H:i:s', $ss['ctime'])));
return $s;
}
示例5: install_check
public static function install_check()
{
//Check the cache folder
if (!Backend::checkConfigFile()) {
if (function_exists('posix_getgrgid') && function_exists('posix_getegid')) {
if ($group = posix_getgrgid(posix_getegid())) {
$group = $group['name'];
}
}
$values = array('file' => Backend::getConfigFileLocation(), 'group' => isset($group) ? $group : false);
Backend::addContent(Render::file('config_value.fix_config.tpl.php', $values));
return false;
}
if (self::get('settings.ConfigValueSet')) {
return true;
}
if (is_post()) {
$result = true;
foreach ($_POST as $name => $value) {
$name = str_replace('_', '.', $name);
if (in_array($name, array('application.Title', 'application.Moto', 'application.HelpBoxContent', 'application.Description', 'author.Name', 'author.Email', 'author.Website'))) {
if (!self::set($name, $value)) {
Backend::addError('Could not set ' . $name);
$result = false;
}
} else {
var_dump('Rejected:', $name);
}
}
self::set('settings.ConfigValueSet', $result);
Controller::redirect();
}
Backend::addContent(Render::file('config_value.values.tpl.php'));
return false;
}
示例6: getProcessGroup
/**
* Get the system group of the user of the current process
*
* @return string
*/
protected function getProcessGroup()
{
// $groupInfo = posix_getgrgid(posix_getegid());
$groupInfo = posix_getgrgid(posix_getgid());
$groupName = $groupInfo['name'];
return $groupName;
}
示例7: show_about
/**
* @version $Id: footer.php 107 2008-07-22 17:27:12Z soeren $
* @package eXtplorer
* @copyright soeren 2007
* @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
* @author The The QuiX project (http://quixplorer.sourceforge.net)
*
* @license
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU General Public License Version 2 or later (the "GPL"), in
* which case the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision by
* deleting the provisions above and replace them with the notice and
* other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this file
* under either the MPL or the GPL."
*
* Shows the About Box!
*/
function show_about()
{
// footer for html-page
echo "\n<div id=\"ext_footer\" style=\"text-align:center;\">\r\n\t<img src=\"" . _EXT_URL . "/images/MangosWeb_small.png\" align=\"middle\" alt=\"Mangosweb Enhanced Logo\" />\r\n\t<br />\r\n\t" . ext_Lang::msg('your_version') . ": <a href=\"" . $GLOBALS['ext_home'] . "\" target=\"_blank\">eXtplorer {$GLOBALS['ext_version']}</a>\r\n\t<br />\r\n (<a href=\"http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "\" onclick=\"javascript:void window.open('http://virtuemart.net/index2.php?option=com_versions&catid=5&myVersion=" . $GLOBALS['ext_version'] . "', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=580,directories=no,location=no'); return false;\" title=\"" . $GLOBALS["messages"]["check_version"] . "\">" . $GLOBALS["messages"]["check_version"] . "</a>)\r\n\t\r\n\t";
if (function_exists("disk_free_space")) {
$size = disk_free_space($GLOBALS['home_dir'] . $GLOBALS['separator']);
$free = parse_file_size($size);
} elseif (function_exists("diskfreespace")) {
$size = diskfreespace($GLOBALS['home_dir'] . $GLOBALS['separator']);
$free = parse_file_size($size);
} else {
$free = "?";
}
echo '<br />' . $GLOBALS["messages"]["miscfree"] . ": " . $free . " \n";
if (extension_loaded("posix")) {
$owner_info = '<br /><br />' . ext_Lang::msg('current_user') . ' ';
if (ext_isFTPMode()) {
$my_user_info = posix_getpwnam($_SESSION['ftp_login']);
$my_group_info = posix_getgrgid($my_user_info['gid']);
} else {
$my_user_info = posix_getpwuid(posix_geteuid());
$my_group_info = posix_getgrgid(posix_getegid());
}
$owner_info .= $my_user_info['name'] . ' (' . $my_user_info['uid'] . '), ' . $my_group_info['name'] . ' (' . $my_group_info['gid'] . ')';
echo $owner_info;
}
echo "\r\n\t</div>";
}
示例8: get_stat
function get_stat($file_name, $path)
{
if (!empty($file_name && !empty($path))) {
$file_name_path = realpath($path) . "/" . $file_name;
if (file_exists($file_name_path)) {
if (is_readable($file_name_path)) {
$stat = stat($file_name_path);
$size = $stat["size"];
if ($size < 1024) {
$size = $stat["size"] . ' octets';
} elseif ($size > 1024 && $size < 1024000) {
$size = $stat["size"] / 1024 . ' Ko (' . $stat["size"] . ' octets)';
} elseif ($size > 1024000 && $size < 1048576000) {
$size = $stat["size"] / 1024 / 1024 . ' Mo (' . $stat["size"] . ' octets)';
} elseif ($size > 1048576000 && $size < 1073741824000) {
$size = $stat["size"] / 1024 / 1024 / 1024 . ' Go (' . $stat["size"] . ' octets)';
} elseif ($size > 1073741824000 && $size < 1099511627776000) {
$size = $stat["size"] / 1024 / 1024 / 1024 / 1024 . ' To (' . $stat["size"] . ' octets)';
} else {
$size = $stat["size"] / 1024 / 1024 / 1024 / 1024 / 1024 . ' Po (' . $stat["size"] . ' octets)';
}
send_json(null, array("device number" => $stat["dev"], "inode number" => $stat["ino"], "inode protection mode" => $stat["mode"], "links number" => $stat["nlinks"], "size of the file" => $size, "user owner" => posix_getpwuid($stat["uid"]), "group owner" => posix_getgrgid($stat["gid"]), "device type" => $stat["rdev"], "last access date" => date("F d Y H:i:s.", $stat["atime"]), "last modification date" => date("F d Y H:i:s.", $stat["mtime"]), "last changing right date" => date("F d Y H:i:s.", $stat["ctime"]), "block size" => $stat["blksize"], "512 bits block allowed" => $stat["blocks"]));
} else {
send_json("The file " . $file_name . " can't be readable !! Check this project right !!", null);
}
} else {
send_json("The file " . $file_name . " don't exists !!", null);
}
}
}
示例9: check_file
function check_file($f)
{
echo "\nFile {$f}\n";
echo '1.' . (file_exists($f) ? ' exists' : ' does NOT exist') . " \n";
if (!file_exists($f)) {
echo 'Remaining checks skipped' . " \n";
return;
}
echo '2. is' . (is_file($f) ? '' : ' NOT') . " a file\n";
echo '3. is' . (is_readable($f) ? '' : ' NOT') . " readable\n";
echo '4. is' . (is_writable($f) ? '' : ' NOT') . " writable\n";
echo '5. has permissions ' . substr(sprintf('%o', fileperms($f)), -4) . "\n";
echo '6. owner id ' . fileowner($f) . " (0 on Windows, blank if not permitted)\n";
if (function_exists('posix_geteuid')) {
$details = posix_getpwuid(posix_geteuid());
echo '6. owner name ' . $details['name'] . " \n";
echo '6. owner gid ' . $details['gid'] . " \n";
$details = posix_getgrgid($details['gid']);
echo '6. group name ' . $details['name'] . " \n";
}
echo '7. group id ' . filegroup($f) . " (0 on Windows, blank if not permitted)\n";
if (function_exists('posix_getegid')) {
$details = posix_getgrgid(posix_getegid());
echo '7. group name ' . $details['name'] . " \n";
}
}
示例10: renderUGID
function renderUGID($uid, $gid)
{
static $users = array();
static $groups = array();
if ($uid === false) {
$user = '—';
} else {
if (!array_key_exists($uid, $users)) {
if (function_exists('posix_getpwuid')) {
$uArray = posix_getpwuid($uid);
$users[$uid] = $uArray['name'];
//." ($uid)";
} else {
$users[$uid] = $uid;
}
}
$user = $users[$uid];
}
if ($gid === false) {
$group = '—';
} else {
if (!array_key_exists($gid, $groups)) {
if (function_exists('posix_getgrgid')) {
$gArray = posix_getgrgid($gid);
$groups[$gid] = $gArray['name'];
//." ($gid)";
} else {
$groups[$gid] = $gid;
}
}
$group = $groups[$gid];
}
return "{$user}:{$group}";
}
示例11: listDirectory
function listDirectory()
{
global $osC_Language, $toC_Json, $osC_MessageStack;
$directory = OSC_ADMIN_FILE_MANAGER_ROOT_PATH;
if (isset($_REQUEST['directory']) && !empty($_REQUEST['directory'])) {
$directory .= '/' . urldecode($_REQUEST['directory']);
} elseif (isset($_REQUEST['goto']) && !empty($_REQUEST['goto'])) {
$directory .= '/' . urldecode($_REQUEST['goto']);
}
$osC_DirectoryListing = new osC_DirectoryListing($directory);
$osC_DirectoryListing->setStats(true);
$records = array();
foreach ($osC_DirectoryListing->getFiles() as $file) {
$file_owner = function_exists('posix_getpwuid') ? posix_getpwuid($file['user_id']) : '-?-';
$group_owner = function_exists('posix_getgrgid') ? posix_getgrgid($file['group_id']) : '-?-';
if ($file['is_directory'] === true) {
$entry_icon = osc_icon('folder_red.png');
$action = array(array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
} else {
$entry_icon = osc_icon('file.png');
$action = array(array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit')), array('class' => 'icon-download-record', 'qtip' => $osC_Language->get('icon_download')), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
}
$records[] = array('icon' => $entry_icon, 'file_name' => $file['name'], 'is_directory' => $file['is_directory'], 'size' => number_format($file['size']), 'permission' => osc_get_file_permissions($file['permissions']), 'file_owner' => $file_owner, 'group_owner' => $group_owner, 'writeable' => osc_icon(is_writable($osC_DirectoryListing->getDirectory() . '/' . $file['name']) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif'), 'last_modified_date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($file['last_modified']), true), 'action' => $action);
}
$response = array(EXT_JSON_READER_ROOT => $records);
echo $toC_Json->encode($response);
}
示例12: check_writable_relative
function check_writable_relative($dir)
{
$uid = posix_getuid();
$gid = posix_getgid();
$user_info = posix_getpwuid($uid);
$user = $user_info['name'];
$group_info = posix_getgrgid($gid);
$group = $group_info['name'];
$fix_cmd = '. ' . _("To fix that, execute following commands as root") . ':<br><br>' . "cd " . getcwd() . "<br>" . "mkdir -p {$dir}<br>" . "chown {$user}:{$group} {$dir}<br>" . "chmod 0700 {$dir}";
if (!is_dir($dir)) {
$config_nt = array('content' => _("Required directory " . getcwd() . "{$dir} does not exist") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
$nt = new Notification('nt_1', $config_nt);
$nt->show();
exit;
}
if (!($stat = stat($dir))) {
$config_nt = array('content' => _("Could not stat configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
$nt = new Notification('nt_1', $config_nt);
$nt->show();
exit;
}
// 2 -> file perms (must be 0700)
// 4 -> uid (must be the apache uid)
// 5 -> gid (must be the apache gid)
if ($stat[2] != 16832 || $stat[4] !== $uid || $stat[5] !== $gid) {
$config_nt = array('content' => _("Invalid perms for configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
$nt = new Notification('nt_1', $config_nt);
$nt->show();
exit;
}
}
示例13: walkdir
function walkdir($path, $exclusions, &$array)
{
global $root_length;
$rs = @opendir($path);
if (!$rs) {
exit(3);
}
while ($file = readdir($rs)) {
if ($file == '.' || $file == '..') {
continue;
}
$current_path = "{$path}/{$file}";
if (is_excluded($current_path)) {
continue;
}
$stat = stat($current_path);
$group_entry = posix_getgrgid($stat['gid']);
$user_entry = posix_getpwuid($stat['uid']);
$group = $group_entry['name'];
$user = $user_entry['name'];
$relative_path = substr($current_path, $root_length + 1);
$array[] = $relative_path . ';' . $stat['mode'] . ';' . $stat['nlink'] . ';' . $stat['uid'] . ';' . $user . ';' . $stat['gid'] . ';' . $group . ';' . $stat['size'] . ';' . $stat['atime'] . ';' . $stat['mtime'] . ';' . $stat['ctime'];
if (is_dir($current_path)) {
walkdir($current_path, $exclusions, $array);
}
}
closedir($rs);
}
示例14: paloConfig
function paloConfig($directorio, $archivo, $separador = "", $separador_regexp = "", $usuario_proceso = NULL)
{
$this->directorio = $directorio;
$this->archivo = $archivo;
$this->separador = $separador;
$this->separador_regexp = $separador_regexp;
if (!is_null($usuario_proceso)) {
$this->usuario_proceso = $usuario_proceso;
} else {
$arr_user = posix_getpwuid(posix_getuid());
if (is_array($arr_user) && array_key_exists("name", $arr_user)) {
$this->usuario_proceso = $arr_user['name'];
}
}
//Debo setear el usuario de sistema y el grupo dependiendo del usuario y grupo propietario del archivo
$ruta_archivo = $directorio . "/" . $archivo;
if (file_exists($ruta_archivo)) {
$arr_usuario = posix_getpwuid(fileowner($ruta_archivo));
if (is_array($arr_usuario)) {
$this->usuario_sistema = $arr_usuario['name'];
}
$arr_grupo = posix_getgrgid(filegroup($ruta_archivo));
if (is_array($arr_grupo)) {
$this->grupo_sistema = $arr_grupo['name'];
}
}
/*
echo "ruta_archivo=".$ruta_archivo."<br>usuario_sistema=".$this->usuario_sistema."<br>grupo_sistema=".
$this->grupo_sistema."<br>usuario_proceso= ".$this->usuario_proceso."<br>";
echo "<script>alert('alto =)');</script>";
*/
}
示例15: getgroupname
protected function getgroupname($group)
{
if ($group && function_exists('posix_getgrgid')) {
$a = posix_getgrgid($group);
return $a['name'];
}
return $group;
}