当前位置: 首页>>代码示例>>PHP>>正文


PHP octdec函数代码示例

本文整理汇总了PHP中octdec函数的典型用法代码示例。如果您正苦于以下问题:PHP octdec函数的具体用法?PHP octdec怎么用?PHP octdec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了octdec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doChmod

 protected function doChmod($remote_file, $chmod_code)
 {
     // try to chmod
     $chmod_code = octdec(str_pad($chmod_code, 4, '0', STR_PAD_LEFT));
     $chmod_code = (int) $chmod_code;
     return ftp_chmod($this->getConnection(), $chmod_code, $remote_file);
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:7,代码来源:ftpMgr.class.php

示例2: parse

 /**
  * Parses a DNUMBER token like PHP would.
  *
  * @param string $str A string number
  *
  * @return float The parsed number
  */
 public static function parse($str)
 {
     // if string contains any of .eE just cast it to float
     if (false !== strpbrk($str, '.eE')) {
         return (double) $str;
     }
     // otherwise it's an integer notation that overflowed into a float
     // if it starts with 0 it's one of the special integer notations
     if ('0' === $str[0]) {
         // hex
         if ('x' === $str[1] || 'X' === $str[1]) {
             return hexdec($str);
         }
         // bin
         if ('b' === $str[1] || 'B' === $str[1]) {
             return bindec($str);
         }
         // oct
         // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9)
         // so that only the digits before that are used
         return octdec(substr($str, 0, strcspn($str, '89')));
     }
     // dec
     return (double) $str;
 }
开发者ID:ck-1,项目名称:PHP-Parser,代码行数:32,代码来源:DNumber.php

示例3: directoryAction

 /**
  * Create Icinga Web 2's configuration directory
  *
  * USAGE:
  *
  *  icingacli setup config directory [options]
  *
  * OPTIONS:
  *
  *  --config=<directory>    Path to Icinga Web 2's configuration files [/etc/icingaweb2]
  *
  *  --mode=<mode>           The access mode to use [2770]
  *
  *  --group=<group>         Owner group for the configuration directory [icingaweb2]
  *
  * EXAMPLES:
  *
  *  icingacli setup config directory
  *
  *  icingacli setup config directory --mode=2775 --config=/opt/icingaweb2/etc
  */
 public function directoryAction()
 {
     $configDir = trim($this->params->get('config', $this->app->getConfigDir()));
     if (strlen($configDir) === 0) {
         $this->fail($this->translate('The argument --config expects a path to Icinga Web 2\'s configuration files'));
     }
     $group = trim($this->params->get('group', 'icingaweb2'));
     if (strlen($group) === 0) {
         $this->fail($this->translate('The argument --group expects a owner group for the configuration directory'));
     }
     $mode = trim($this->params->get('mode', '2770'));
     if (strlen($mode) === 0) {
         $this->fail($this->translate('The argument --mode expects an access mode for the configuration directory'));
     }
     if (!file_exists($configDir) && !@mkdir($configDir)) {
         $e = error_get_last();
         $this->fail(sprintf($this->translate('Can\'t create configuration directory %s: %s'), $configDir, $e['message']));
     }
     if (!@chmod($configDir, octdec($mode))) {
         $e = error_get_last();
         $this->fail(sprintf($this->translate('Can\'t change the mode of the configuration directory to %s: %s'), $mode, $e['message']));
     }
     if (!@chgrp($configDir, $group)) {
         $e = error_get_last();
         $this->fail(sprintf($this->translate('Can\'t change the group of %s to %s: %s'), $configDir, $group, $e['message']));
     }
     printf($this->translate('Successfully created configuration directory %s') . PHP_EOL, $configDir);
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:49,代码来源:ConfigCommand.php

示例4: __construct

    /**
     * Constructor.
     *
     * $filePath File path. If specified, file metadata is fetched in the constructor.
     */
    function __construct( $filePath = false )
    {
        $filePath = eZDBFileHandler::cleanPath( $filePath );
        eZDebugSetting::writeDebug( 'kernel-clustering', "db::ctor( '$filePath' )" );

        if ( self::$dbbackend === null )
        {
            $optionArray = array( 'iniFile'     => 'file.ini',
                                  'iniSection'  => 'ClusteringSettings',
                                  'iniVariable' => 'DBBackend' );

            $options = new ezpExtensionOptions( $optionArray );

            self::$dbbackend = eZExtension::getHandlerClass( $options );
            self::$dbbackend->_connect( false );

            // connection failed
            if( self::$dbbackend->db === false )
                throw new eZClusterHandlerDBNoConnectionException( self::$dbbackend->dbparams['host'], self::$dbbackend->dbparams['user'], self::$dbbackend->dbparams['pass'] );
        }

        $this->filePath = $filePath;

        if ( !isset( $GLOBALS['eZDBFileHandler_Settings'] ) )
        {
            $fileINI = eZINI::instance( 'file.ini' );
            $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'] = $fileINI->variable( "ClusteringSettings", "NonExistantStaleCacheHandling" );
            unset( $fileINI );
        }
        $this->nonExistantStaleCacheHandling = $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'];
        $this->filePermissionMask = octdec( eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' ) );
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:37,代码来源:ezdbfilehandler.php

示例5: decompress

 /**
  * @return array  Tar file data:
  * <pre>
  * KEY: Position in the array
  * VALUES:
  *   attr - File attributes
  *   data - Raw file contents
  *   date - File modification time
  *   name - Filename
  *   size - Original file size
  *   type - File type
  * </pre>
  *
  * @throws Horde_Compress_Exception
  */
 public function decompress($data, array $params = array())
 {
     $data_len = strlen($data);
     $position = 0;
     $return_array = array();
     while ($position < $data_len) {
         if (version_compare(PHP_VERSION, '5.5', '>=')) {
             $info = @unpack('Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Ctypeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor', substr($data, $position));
         } else {
             $info = @unpack('a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor', substr($data, $position));
         }
         if (!$info) {
             throw new Horde_Compress_Exception(Horde_Compress_Translation::t("Unable to decompress data."));
         }
         $position += 512;
         $contents = substr($data, $position, octdec($info['size']));
         $position += ceil(octdec($info['size']) / 512) * 512;
         if ($info['filename']) {
             $file = array('attr' => null, 'data' => null, 'date' => octdec($info['mtime']), 'name' => trim($info['filename']), 'size' => octdec($info['size']), 'type' => isset($this->_types[$info['typeflag']]) ? $this->_types[$info['typeflag']] : null);
             if ($info['typeflag'] == 0 || $info['typeflag'] == 0x30 || $info['typeflag'] == 0x35) {
                 /* File or folder. */
                 $file['data'] = $contents;
                 $mode = hexdec(substr($info['mode'], 4, 3));
                 $file['attr'] = ($info['typeflag'] == 0x35 ? 'd' : '-') . ($mode & 0x400 ? 'r' : '-') . ($mode & 0x200 ? 'w' : '-') . ($mode & 0x100 ? 'x' : '-') . ($mode & 0x40 ? 'r' : '-') . ($mode & 0x20 ? 'w' : '-') . ($mode & 0x10 ? 'x' : '-') . ($mode & 0x4 ? 'r' : '-') . ($mode & 0x2 ? 'w' : '-') . ($mode & 0x1 ? 'x' : '-');
             }
             $return_array[] = $file;
         }
     }
     return $return_array;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:45,代码来源:Tar.php

示例6: put_gallery

 function put_gallery($gallery)
 {
     $csvpath = $this->config->base_path . $this->config->pathto_galleries . $gallery->id . "/metadata.csv";
     if (!is_writeable($csvpath) && file_exists($csvpath)) {
         // this is the fix for a fubared metadata file
         $perms = substr(sprintf('%o', fileperms($csvpath)), -4);
         if ($perms == '0000') {
             @chmod($csvpath, octdec($this->config->chmod_value));
         }
     }
     $fp = fopen($csvpath, "w");
     // throw an error if necessary
     if (!$fp) {
         if (file_exists($csvpath)) {
             echo 'Please fix permissions on ' . realpath($this->config->base_path . $this->config->pathto_galleries . $gallery->id);
         } else {
             echo "PhotoStack can't open your metadata file to write to it.";
         }
         return false;
     } else {
         // write csv header
         $success = (bool) fwrite($fp, "filename/thumbnail,image_name,description,long_description,date,sort");
         // write csv data
         $success &= (bool) fwrite($fp, "\n\"" . $gallery->filename . "\",\"" . $gallery->name . '","' . $gallery->desc . '","' . $gallery->long_desc . '","' . $gallery->date . '"');
         for ($i = 0; $i < count($gallery->images); $i++) {
             $success &= (bool) fwrite($fp, "\n\"" . $gallery->images[$i]->filename . "\",\"" . str_replace('"', '""', $gallery->images[$i]->name) . '","' . str_replace('"', '""', $gallery->images[$i]->desc) . '","' . str_replace('"', '""', $gallery->images[$i]->long_desc) . '",' . str_replace('"', '""', $gallery->images[$i]->date) . ',"' . str_replace('"', '""', $gallery->images[$i]->sort) . '"');
         }
         $success &= (bool) fclose($fp);
         @chmod($csvpath, octdec($this->config->chmod_value));
         return $success;
     }
 }
开发者ID:noeljackson,项目名称:PhotoStack,代码行数:32,代码来源:io_csv.class.php

示例7: CreateDatabase

 function CreateDatabase(&$db, $name)
 {
     if (!function_exists("sqlite_open")) {
         return $db->SetError("Connect", "SQLite support is not available in this PHP configuration");
     }
     $database_file = $db->GetDatabaseFile($name);
     if (@file_exists($database_file)) {
         return $db->SetError("Create database", "database already exists");
     }
     @touch($database_file);
     if (!@file_exists($database_file)) {
         return $db->SetError("Create database", "Unable to create new database. Permission denied");
     }
     $mode = isset($db->options["AccessMode"]) ? strcmp($db->options["AccessMode"][0], "0") ? intval($db->options["AccessMode"]) : octdec($db->options["AccessMode"]) : 0640;
     @chmod($database_file, $mode);
     if (!is_readable($database_file)) {
         @unlink($database_file);
         return $db->SetError("Create database", "Unable to open database for Reading. Permission denied");
     }
     if (!is_writable($database_file)) {
         @unlink($database_file);
         return $db->SetError("Create database", "Unable to open database for Writing. Permission denied");
     }
     $handle = @sqlite_open($database_file, $mode);
     if (!$handle) {
         @unlink($database_file);
         return $db->SetError("Create database", isset($php_errormsg) ? $php_errormsg : "could not create the database file");
     }
     sqlite_close($handle);
     return 1;
 }
开发者ID:wycus,项目名称:darmedic,代码行数:31,代码来源:manager_sqlite.php

示例8: chmod

 /**
  * Tries to change a folder/file's permissions using direct access or FTP
  *
  * @param   string  $path  The full path to the folder/file to chmod
  * @param   int     $mode  New permissions
  *
  * @return  bool  True on success
  */
 private function chmod($path, $mode)
 {
     if (is_string($mode)) {
         $mode = octdec($mode);
         $trustMeIKnowWhatImDoing = 500 + 10 + 1;
         // working around overzealous scanners written by bozos
         $ohSixHundred = 386 - 2;
         $ohSevenFiveFive = 500 - 7;
         if ($mode < $ohSixHundred || $mode > $trustMeIKnowWhatImDoing) {
             $mode = $ohSevenFiveFive;
         }
     }
     // Initialize variables
     JLoader::import('joomla.client.helper');
     $ftpOptions = JClientHelper::getCredentials('ftp');
     // Check to make sure the path valid and clean
     $path = JPath::clean($path);
     if (@chmod($path, $mode)) {
         $ret = true;
     } elseif ($ftpOptions['enabled'] == 1) {
         // Connect the FTP client
         JLoader::import('joomla.client.ftp');
         $ftp = JClientFtp::getInstance($ftpOptions['host'], $ftpOptions['port'], array(), $ftpOptions['user'], $ftpOptions['pass']);
         // Translate path and delete
         $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/');
         // FTP connector throws an error
         $ret = $ftp->chmod($path, $mode);
     } else {
         $ret = false;
     }
     return $ret;
 }
开发者ID:AlexanderKri,项目名称:joom-upd,代码行数:40,代码来源:Chmod.php

示例9: parseFile

    function parseFile( $fileName )
    {
        $binaryINI = eZINI::instance( 'binaryfile.ini' );

        $textExtractionTool = $binaryINI->variable( 'WordHandlerSettings', 'TextExtractionTool' );

        $tmpName = "var/cache/" . md5( time() ) . '.txt';
        $handle = fopen( $tmpName, "w" );
        fclose( $handle );

        $perm = octdec( eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' ) );
        chmod( $tmpName, $perm );

        exec( "$textExtractionTool $fileName > $tmpName", $ret );

        $metaData = "";
        if ( file_exists( $tmpName ) )
        {
            $fp = fopen( $tmpName, "r" );
            $metaData = fread( $fp, filesize( $tmpName ) );
            $metaData = strip_tags( $metaData );
            fclose( $fp );
            unlink( $tmpName );
        }

        return $metaData;
    }
开发者ID:nottavi,项目名称:ezpublish,代码行数:27,代码来源:ezwordparser.php

示例10: pathChmod

 public function pathChmod()
 {
     if ($_SERVER['HTTP_REFERER'] != $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) {
         if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
             $info_list = json_decode($this->in['list'], true);
             $mod = octdec('0' . $this->in['mod']);
             $success = 0;
             $error = 0;
             foreach ($info_list as $val) {
                 $path = _DIR($val['path']);
                 if (chmod_path($path, $mod)) {
                     $success++;
                 } else {
                     $error++;
                 }
             }
             $state = $error == 0 ? true : false;
             $info = $success . ' success,' . $error . ' error';
             if (count($info_list) == 1 && $error == 0) {
                 $info = $this->L['success'];
             }
             show_json($info, $state);
         }
     } else {
         header('Location: 403.php');
     }
 }
开发者ID:ajhalls,项目名称:KODExplorer,代码行数:27,代码来源:explorer.class.php

示例11: run

 /**
  * Initiates the sync by exchanging file lists
  * @param $url string URL to remote sync server script
  */
 public function run($url)
 {
     $this->curl = curl_init($url);
     //send client file list to server
     $localFiles = $this->getFileList($this->path);
     $request = array('action' => self::ACTION_FILELIST, 'data' => $localFiles);
     $response = $this->post($request);
     if (isset($response['error'])) {
         echo $response['error'];
         return;
     }
     //process modified files
     foreach ($response['data'] as $relativePath => $info) {
         //fetch file contents
         $response = $this->post(array('action' => self::ACTION_FETCH, 'file' => $relativePath));
         //save file
         $absolutePath = $this->path . $relativePath;
         if (!file_exists(dirname($absolutePath))) {
             mkdir(dirname($absolutePath), 0777, true);
         }
         file_put_contents($absolutePath, $response);
         //update modified time to match server
         touch($absolutePath, $info['timestamp']);
         //update permissions to match server
         chmod($absolutePath, octdec(intval($info['fileperm'])));
     }
 }
开发者ID:57-Wolve,项目名称:sync,代码行数:31,代码来源:Client.php

示例12: _getTarInfo

 protected function _getTarInfo(&$data)
 {
     $position = 0;
     $return_array = array();
     while ($position < strlen($data)) {
         $info = @unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", substr($data, $position));
         if (!$info) {
             $this->set('error.message', 'Unable to decompress data');
             return false;
         }
         $position += 512;
         $contents = substr($data, $position, octdec($info['size']));
         $position += ceil(octdec($info['size']) / 512) * 512;
         if ($info['filename']) {
             $file = array('attr' => null, 'data' => null, 'date' => octdec($info['mtime']), 'name' => trim($info['filename']), 'size' => octdec($info['size']), 'type' => isset($this->_types[$info['typeflag']]) ? $this->_types[$info['typeflag']] : null);
             if ($info['typeflag'] == 0 || $info['typeflag'] == 0x30 || $info['typeflag'] == 0x35) {
                 /* File or folder. */
                 $file['data'] = $contents;
                 $mode = hexdec(substr($info['mode'], 4, 3));
                 $file['attr'] = ($info['typeflag'] == 0x35 ? 'd' : '-') . ($mode & 0x400 ? 'r' : '-') . ($mode & 0x200 ? 'w' : '-') . ($mode & 0x100 ? 'x' : '-') . ($mode & 0x40 ? 'r' : '-') . ($mode & 0x20 ? 'w' : '-') . ($mode & 0x10 ? 'x' : '-') . ($mode & 0x4 ? 'r' : '-') . ($mode & 0x2 ? 'w' : '-') . ($mode & 0x1 ? 'x' : '-');
             } else {
                 /* Some other type. */
             }
             $return_array[] = $file;
         }
     }
     $this->_metadata = $return_array;
     return true;
 }
开发者ID:vanie3,项目名称:appland,代码行数:29,代码来源:tar.php

示例13: create

	/**
	 * Folder will be created and Permissions will be set to the specified permissions.
	 *
	 * If the folder exists just the permissions will be set.
	 * See FileSystemNode::setPermissions() on how to specify the permissions correctly.
	 * This function will also return false if the chmod are not set correctly.
	 * Folders are created recursively.
	 *
	 * This function implements the ftp fallback!
	 *
	 * @see Folder::setPermissions()
	 * @param int Permissions to set for the directory (default is 777)
	 * @return boolean Returns TRUE on success or FALSE on failure.
	 */
	public function create($permissions = 777) {
		$chmodResult = false;
		if ($this->exists() == false) {
			if (mkdir($this->path, octdec($permissions), true) == false && $this->ftp == true) {
				$ftp = FileSystem::initializeFTP();
				// Make sure the dir is created recursively as this is not natively supported by ftp
				$folders = preg_split('~[\\/]+~', $this->ftpPath(), -1, PREG_SPLIT_NO_EMPTY);
				$root = self::SEPARATOR;
				foreach ($folders as $folder) {
					$root .= $folder.self::SEPARATOR;
					if ($ftp->exists($root) == false) {
						$ftp->mkdir($root);
					}
				}
				$chmodResult = $this->setPermissions($permissions);
			}
		}
		else {
			$chmodResult = $this->setPermissions($permissions);
		}

		/*
		 * We should check the permissions like below, but windows does not support chmods properly
		 * and therefore this condition would fail always for chmods other than 666 and 777.
		 * return ($this->exists() && $this->getPermissions() == $permissions);
		 */
		return ($this->exists() && $chmodResult);
	}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:42,代码来源:class.Folder.php

示例14: createStructPersist

 /**
  * cria estrutura
  * @param string $path
  * @return string
  */
 private static function createStructPersist($path)
 {
     $year = date('Y');
     $month = date('m');
     $path .= Registry::get('bootstrap')->config()->get('app.file.repository');
     $system = Registry::get('bootstrap')->request()->getModule();
     $permission = octdec(self::$_permission);
     # obtenho a permissao do diretorio
     $repoSystem = $path . DIRECTORY_SEPARATOR . $system;
     # destino onde os arquivos serao salvos
     $repoCreate = $repoSystem . DIRECTORY_SEPARATOR . $year . DIRECTORY_SEPARATOR . $month;
     #@todo lancar exception se não poder efetuar a escrita is_writable
     $owner = self::whoIsOwner($path);
     $permDir = self::pathPermissions($path);
     //dump("SEM PERMISSAO PARA ESCRITA, PERMISSAO NA PASTA É {$permDir} E O DONO É {$owner}" ,1);
     # listo os diretorios e procuro na lista de diretorios pelo sistema informado
     if (!array_search($system, scandir($path))) {
         # cria repositorio e sub-diretorios referente ao Mes
         mkdir($repoCreate, $permission, TRUE);
     } else {
         # a pasta do sistema existe, agora faz a valizadacao da estrutura
         if (!array_search($year, scandir($repoSystem))) {
             mkdir($repoCreate, $permission, TRUE);
         } else {
             # Ultima verificacao caso o sub referente ao mes nao foi criado
             $listDir = scandir($repoSystem . DIRECTORY_SEPARATOR . $year);
             if (!array_search($month, $listDir)) {
                 mkdir($repoCreate, $permission, TRUE);
             }
         }
     }
     return base64_encode($repoCreate);
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:38,代码来源:Folder.php

示例15: processTemplatesData

 private function processTemplatesData(array $templates, $data)
 {
     $commands = array();
     foreach ($templates as $template) {
         $document = $this->extractFrontMatter($template);
         $meta = $document->getConfig();
         // validate meta data variables
         $this->validate($meta, $this->schemaMeta);
         // use a new dummy loader whose sole responsibilty is mapping template name to contents
         // this allows us to reference the template by name (and receive according error messages)
         $this->twig->setLoader(new Twig_Loader_Array(array($template => $document->getContent())));
         // create resulting configuration file by processing template
         $contents = $this->processTemplateContents($template, array('data' => $data, 'meta' => $meta));
         // chmod is either unset or convert decimal to octal notation
         $meta['chmod'] = isset($meta['chmod']) ? octdec($meta['chmod']) : null;
         // target file name can either be given or defaults to template name without ".twig" extension
         $target = isset($meta['target']) ? $meta['target'] : $this->fs->basename($template, '.twig');
         // write resulting configuration to target path and apply
         if (!$this->fs->fileContains($target, $contents)) {
             $this->fs->fileReplace($target, $contents, $meta['chmod']);
             // template has a command definition to reload this file
             if (isset($meta['reload'])) {
                 $commands[] = $meta['reload'];
             }
         }
     }
     // let's reload all the files after (successfully) writing all of them
     foreach ($commands as $command) {
         $this->execute($command);
     }
 }
开发者ID:clue,项目名称:confgen,代码行数:31,代码来源:Confgen.php


注:本文中的octdec函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。