本文整理汇总了PHP中decoct函数的典型用法代码示例。如果您正苦于以下问题:PHP decoct函数的具体用法?PHP decoct怎么用?PHP decoct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decoct函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: __construct
/**
* @param string $filename
* @throws AException
*/
public function __construct($filename)
{
if (is_dir($filename)) {
$filename .= (substr($filename, -1) != '/' ? '/' : '') . 'error.txt';
}
$this->filename = $filename;
if (!is_writable(pathinfo($filename, PATHINFO_DIRNAME))) {
// if it happens see errors in httpd error log!
throw new AException(AC_ERR_LOAD, 'Error: Log directory ' . DIR_LOGS . ' is non-writable. Please change permissions.');
}
//check is log-file writable
//1.create file if it not exists
$handle = @fopen($filename, 'a+');
@fclose($handle);
//2. then change mode to 777
if (is_file($filename) && decoct(fileperms($filename) & 0777) != 777) {
chmod($filename, 0777);
//3.if log-file non-writable create new one
if (!is_writable($filename)) {
$this->filename = DIR_LOGS . 'error_0.txt';
$handle = @fopen($this->filename, 'a+');
@fclose($handle);
}
}
if (class_exists('Registry')) {
// for disabling via settings
$registry = Registry::getInstance();
if (is_object($registry->get('config'))) {
$this->mode = $registry->get('config')->get('config_error_log') ? true : false;
}
}
}
示例3: fixPermissions
/**
* Repair problems in a Typeframe installation.
* This command will configure BaseModel schemas and fix writeable directory
* permissions.
*/
function fixPermissions($dir)
{
static $ftp = null;
static $depth = 0;
$depth++;
if (is_null($ftp)) {
$ftp = new Typeframe_File();
}
if (!file_exists(TYPEF_DIR . '/files' . $dir)) {
$ftp->mkdir('/files' . $dir);
}
if (substr(sprintf('%o', fileperms(TYPEF_DIR . '/files/' . $dir)), -4) !== '0777') {
$ftp->chmod(0777, '/files' . $dir);
}
$dh = opendir(TYPEF_DIR . '/files' . $dir);
while (($file = readdir($dh)) !== false) {
if (substr($file, 0, 1) != '.') {
if (is_dir(TYPEF_DIR . '/files' . $dir . '/' . $file)) {
fixPermissions($dir . '/' . $file);
} else {
$perm = substr(decoct(fileperms(TYPEF_DIR . '/files/' . $dir . '/' . $file)), 1);
if ($perm !== '0666' && $perm !== '0777') {
$ftp->chmod(0666, '/files/' . $dir . '/' . $file);
}
}
}
}
$depth--;
if ($depth == 0) {
$ftp->close();
$ftp = null;
}
}
示例4: action_permissions
/**
* install an orbit module
*
* @param array $params
*/
public function action_permissions($params)
{
$folders = \CCEvent::fire('ccdoctor.permissions');
if (!is_array($folders)) {
$folders = array();
}
// add storage directories
foreach (\ClanCats::$config->get('storage.paths') as $folder) {
$folders[] = $folder;
}
foreach ($folders as $folder) {
$display_folder = \CCStr::replace($folder, array(CCROOT => ''));
// create directory if not existing
if (!is_dir($folder)) {
if (!mkdir($folder, 0755, true)) {
$this->error("doctor could not create folder at: {$display_folder}");
}
}
// check permissions
$perm = substr(decoct(fileperms($folder)), 2);
if ($perm < 755) {
CCCli::line(CCCli::color($perm, 'red') . ' - ' . $display_folder . ' fixing with ' . CCCli::color('755', 'green'));
if (!chmod($folder, 0755)) {
CCCli::line("doctor - is not able to change permissions for: {$display_folder}", 'red');
}
} elseif ($perm == 777) {
CCCli::line(CCCli::color($perm, 'yellow') . ' - ' . $display_folder . ' warning! this can be dangerous.');
} else {
$this->success('- ' . $display_folder, $perm);
}
}
}
示例5: mkdir
/**
*
* Safely create a folder and any folders in between
* Replaces icms_mkdir()
*
* @param string $target path to the folder to be created
* @param integer $mode permissions to set on the folder. This is affected by umask in effect
* @param string $base root location for the folder, ICMS_ROOT_PATH or ICMS_TRUST_PATH, for example
* @param array $metachars Characters to exclude from a valid path name
* @return boolean True if folder is created, False if it is not
*/
public static function mkdir($target, $mode = 0777, $base = ICMS_ROOT_PATH, $metachars = array())
{
if (is_dir($target)) {
return TRUE;
}
if (!isset($metachars)) {
$metachars = array('[', '?', '"', '.', '<', '>', '|', ' ', ':');
}
$base = preg_replace('/[\\|\\/]/', DIRECTORY_SEPARATOR, $base);
$target = preg_replace('/[\\|\\/]/', DIRECTORY_SEPARATOR, $target);
if ($base !== '') {
$target = str_ireplace($base . DIRECTORY_SEPARATOR, '', $target);
$target = $base . DIRECTORY_SEPARATOR . str_replace($metachars, '_', $target);
} else {
$target = str_replace($metachars, '_', $target);
}
if (mkdir($target, $mode, TRUE)) {
// create an index.html file in this directory
if ($fh = @fopen($target . '/index.html', 'w')) {
fwrite($fh, '<script>history.go(-1);</script>');
@fclose($fh);
}
if (substr(decoct(fileperms($target)), 2) != $mode) {
chmod($target, $mode);
}
}
return is_dir($target);
}
示例6: create
/**
* @param string $path The path of the Folder
* @param int $permission The permission to create the folder with.
*
* @return Folder The domain object for further usage
*
* @author Nicolas Pecher
* @version Version 0.1, 01.05.2012
* @version Version 0.2, 14.08.2012 (Bug-fix: default permissions are now set to ug+rwx; using PHP's built in recursive path creation)
*/
public function create($path, $permission = 0770)
{
if (!is_dir($path)) {
// due to a potential PHP bug with directly passing the permissions
// we have to initiate a workaround containing explicit formatting as
// well as umask setting to create the folders with correct permissions
// to provide a common API, octal numbers must be convert to the
// internal string representation. otherwise we will get wrong
// permissions with octal numbers!
if (is_int($permission)) {
$permission = decoct($permission);
}
// now the correct string representation must be created to ensure
// correct permissions (leading zero is important!)
$oct = sprintf('%04u', $permission);
// to be able to pass the argument as an octal number, the string must
// be correctly formatted
$permission = octdec($oct);
// on some boxes, the current umask prevents correct permission appliance.
// thus, the umask is set to 0000 to avoid permission shifts. this maybe
// a PHP bug but umasks unlike 0000 lead to wrong permissions, however.
$oldUmask = umask(0);
// the last parameter allows the creation of nested directories
mkdir($path, $permission, true);
umask($oldUmask);
}
$this->open($path);
return $this;
}
示例7: jb_fix_perms_recursive
function jb_fix_perms_recursive($dir)
{
//static $file_list;
if (is_dir($dir) && strpos($dir, '.svn') === false) {
if (chmod($dir . $file, JB_NEW_DIR_CHMOD)) {
echo "chmod " . decoct(JB_NEW_DIR_CHMOD) . " " . $dir . $file . "\n";
flush();
} else {
echo 'Seems like the system cannot set the permissions for this dir: ' . $dir . $file . '<br> Please try setting permissions from the command line or using FTP' . "\n";
flush();
}
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
//echo "$dir . $file<br>";
if (filetype($dir . $file) == 'file') {
//$file_list[] = $dir . $file;
if ($file !== 'index.html' && $file !== '.htaccess' && $file !== 'dl.php') {
if (chmod($dir . $file, JB_NEW_FILE_CHMOD)) {
echo "chmod " . decoct(JB_NEW_FILE_CHMOD) . " " . $dir . $file . "\n";
flush();
} else {
echo 'Seems like the system cannot set the permissions for this file: ' . $dir . $file . '<br> Please try setting permissions from the command line or using FTP' . "\n";
flush();
}
}
} elseif (filetype($dir . $file) == 'dir' && $file != '.' && $file != '..') {
jb_fix_perms_recursive($dir . $file . '/');
}
//echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
}
示例8: check_permissions
function check_permissions($folder)
{
// First check if the specified folder is actually a directory and check if the CHMOD permission is 4 characters in length (e.g 0777 is correct while 777 isn't)
if (is_dir($folder)) {
// Get the file permissions
$permission = substr(decoct(fileperms($folder)), 2);
// Check if the folder is writable
$dir_writeable = is_writable($folder);
// Set up a message based on the permissions
if ($dir_writeable == true) {
// Message when the directory is writable
$dir_message = "The output directory is writable, have fun using iScaffold";
$message_id = "succes-message";
} else {
$dir_message = "The output directory isn't writable, please change the CHMOD values. The current CHMOD value is {$permission}";
$message_id = "error-message";
}
// Create an array containing the results
$info = array('is_writeable' => $dir_writeable, 'dir_message' => $dir_message, 'message_id' => $message_id);
// Return it
return $info;
} else {
$dir_message = "The 'output' directory doesn't exists, please create in the root directory of iScaffold 2.0 it and make it writable.";
$message_id = "error-message";
$dir_writeable = false;
// Create an array containing the results
$info = array('is_writeable' => $dir_writeable, 'dir_message' => $dir_message, 'message_id' => 'error-message');
return $info;
}
}
示例9: typo3
/**
* Return t3lib helper class
* @return t3lib_cs
*/
protected static function typo3()
{
static $typo3cs = null;
if (isset($typo3cs)) {
return $typo3cs;
}
global $CFG;
// Required files
require_once $CFG->libdir . '/typo3/class.t3lib_cs.php';
require_once $CFG->libdir . '/typo3/class.t3lib_div.php';
// do not use mbstring or recode because it may return invalid results in some corner cases
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'iconv';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'iconv';
// Tell Typo3 we are curl enabled always (mandatory since 2.0)
$GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] = '1';
// And this directory must exist to allow Typo to cache conversion
// tables when using internal functions
make_temp_directory('typo3temp/cs');
// Make sure typo is using our dir permissions
$GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = decoct($CFG->directorypermissions);
// Default mask for Typo
$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = $CFG->directorypermissions;
// This full path constants must be defined too, transforming backslashes
// to forward slashed because Typo3 requires it.
define('PATH_t3lib', str_replace('\\', '/', $CFG->libdir . '/typo3/'));
define('PATH_typo3', str_replace('\\', '/', $CFG->libdir . '/typo3/'));
define('PATH_site', str_replace('\\', '/', $CFG->tempdir . '/'));
define('TYPO3_OS', stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin') ? 'WIN' : '');
$typo3cs = new t3lib_cs();
return $typo3cs;
}
示例10: setupAction
public function setupAction()
{
$config = $this->assetic->getConfiguration();
$mode = null !== ($mode = $config->getUmask()) ? $mode : 0775;
$displayMode = decoct($mode);
$cachePath = $config->getCachePath();
$pathExists = is_dir($cachePath);
if ($cachePath && !$pathExists) {
mkdir($cachePath, $mode, true);
echo "Cache path created '{$cachePath}' with mode '{$displayMode}' \n";
} else {
if ($pathExists) {
echo "Creation of cache path '{$cachePath}' skipped - path exists \n";
} else {
echo "Creation of cache path '{$cachePath}' skipped - no path provided \n";
}
}
$webPath = $config->getWebPath();
$pathExists = is_dir($webPath);
if ($webPath && !$pathExists) {
mkdir($webPath, $mode, true);
echo "Web path created '{$webPath}' with mode '{$displayMode}' \n";
} else {
if ($pathExists) {
echo "Creation of web path '{$webPath}' skipped - path exists \n";
} else {
echo "Creation of web path '{$webPath}' skipped - no path provided \n";
}
}
}
示例11: job_board_rewrite
/**
* job_board_rewrite function.
*
* @access public
* @return void
*/
public function job_board_rewrite()
{
if (!function_exists('get_home_path')) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
$root_path = get_home_path();
$file_existing_permission = '';
/* Getting Rules */
$rules = 'yes' === get_option('job_board_anti_hotlinking') ? $this->job_board_rewrite_rules() : '';
/* Rules Force Files to be Downloaded */
$forcedownload_rule = "AddType application/octet-stream .pdf .txt\n";
/* Changing File to Writable Mode */
if (file_exists($root_path . '.htaccess') && !is_writable($root_path . '.htaccess')) {
$file_existing_permission = substr(decoct(fileperms($root_path . '.htaccess')), -4);
chmod($root_path . '.htaccess', 0777);
}
/* Appending .htaccess */
if (file_exists($root_path . '.htaccess') && is_writable($root_path . '.htaccess')) {
$rules = explode("\n", $rules);
$forcedownload_rule = explode("\n", $forcedownload_rule);
// Anti-Hotlinking Rules Writing in .htaccess file
if (!function_exists('insert_with_markers')) {
require_once ABSPATH . 'wp-admin/includes/misc.php';
}
insert_with_markers($root_path . '.htaccess', 'Hotlinking', $rules);
// Force Download Rules Writing in .htaccess file
insert_with_markers($root_path . '.htaccess', 'Force Download', $forcedownload_rule);
/* Revert File Permission */
if (!empty($file_existing_permission)) {
chmod($root_path . '.htaccess', $file_existing_permission);
}
}
}
示例12: run
/**
* @inheritdoc
*/
public function run(&$cmdParams, &$params)
{
$res = true;
$taskRunner = $this->taskRunner;
$permList = !empty($cmdParams[0]) ? $cmdParams[0] : [];
foreach ($permList as $mode => $pathList) {
$mode = is_string($mode) ? octdec((int) $mode) : $mode;
foreach ($pathList as $path) {
$path = $taskRunner->parsePath($path);
if (file_exists($path)) {
$this->controller->stdout("Changing permissions of {$path} to ");
$this->controller->stdout('0' . decoct($mode), Console::FG_CYAN);
if (!$this->controller->dryRun) {
@chmod($path, $mode);
} else {
$this->controller->stdout(' [dry run]', Console::FG_YELLOW);
}
} else {
$this->controller->stderr("Not found: {$path}\n", Console::FG_RED);
}
$this->controller->stdout("\n");
}
}
return $res;
}
示例13: setMode
/**
* Sets the mode (octal)
*
* @param $mode
*
* @return $this
*/
public function setMode($mode)
{
if (decoct(octdec($mode)) == $mode) {
$this->mode = $mode;
}
return $this;
}
示例14: renderPermissions
function renderPermissions($perms)
{
if ($perms === false) {
return '—';
}
return decoct($perms & 0777);
}
示例15: onBrowse
protected function onBrowse($tpl = null)
{
// Default permissions
if (interface_exists('JModel')) {
$params = JModelLegacy::getInstance('Storage', 'AdmintoolsModel');
} else {
$params = JModel::getInstance('Storage', 'AdmintoolsModel');
}
$dirperms = '0' . ltrim(trim($params->getValue('dirperms', '0755')), '0');
$fileperms = '0' . ltrim(trim($params->getValue('fileperms', '0644')), '0');
$dirperms = octdec($dirperms);
if ($dirperms < 0600 || $dirperms > 0777) {
$dirperms = 0755;
}
$this->dirperms = '0' . decoct($dirperms);
$fileperms = octdec($fileperms);
if ($fileperms < 0600 || $fileperms > 0777) {
$fileperms = 0755;
}
$this->fileperms = '0' . decoct($fileperms);
// File lists
$model = $this->getModel();
$listing = $model->getListing();
$this->listing = $listing;
$relpath = $model->getState('filter_path', '');
$this->path = $relpath;
}