本文整理汇总了PHP中umask函数的典型用法代码示例。如果您正苦于以下问题:PHP umask函数的具体用法?PHP umask怎么用?PHP umask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了umask函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$remoteFilename = 'http://get.insight.sensiolabs.com/insight.phar';
$localFilename = $_SERVER['argv'][0];
$tempFilename = basename($localFilename, '.phar') . '-temp.phar';
try {
copy($remoteFilename, $tempFilename);
if (md5_file($localFilename) == md5_file($tempFilename)) {
$output->writeln('<info>insight is already up to date.</info>');
unlink($tempFilename);
return;
}
chmod($tempFilename, 0777 & ~umask());
// test the phar validity
$phar = new \Phar($tempFilename);
// free the variable to unlock the file
unset($phar);
rename($tempFilename, $localFilename);
$output->writeln('<info>insight updated.</info>');
} catch (\Exception $e) {
if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
throw $e;
}
unlink($tempFilename);
$output->writeln('<error>The download is corrupt (' . $e->getMessage() . ').</error>');
$output->writeln('<error>Please re-run the self-update command to try again.</error>');
}
}
开发者ID:ftdysa,项目名称:insight,代码行数:31,代码来源:SelfUpdateCommand.php
示例2: getDateCatalogTree
public static function getDateCatalogTree($sPath, $data = false, $czyWyswietlacBledy = false)
{
$data = $data ? substr($data, 0, 10) : date('Y-m-d');
$data = explode('-', $data);
$oldUmask = umask(0);
if (!file_exists($sPath . $data[0] . '/')) {
if ($czyWyswietlacBledy) {
mkdir($sPath . $data[0] . '/', 0770);
} else {
@mkdir($sPath . $data[0] . '/', 0770);
}
}
if (!file_exists($sPath . $data[0] . '/' . $data[1] . '/')) {
if ($czyWyswietlacBledy) {
mkdir($sPath . $data[0] . '/' . $data[1] . '/', 0770);
} else {
@mkdir($sPath . $data[0] . '/' . $data[1] . '/', 0770);
}
}
if (!file_exists($sPath . $data[0] . '/' . $data[1] . '/' . $data[2] . '/')) {
if ($czyWyswietlacBledy) {
mkdir($sPath . $data[0] . '/' . $data[1] . '/' . $data[2] . '/', 0770);
} else {
@mkdir($sPath . $data[0] . '/' . $data[1] . '/' . $data[2] . '/', 0770);
}
}
umask($oldUmask);
return $sPath . $data[0] . '/' . $data[1] . '/' . $data[2] . '/';
}
开发者ID:mariuszfilip,项目名称:umowatorium,代码行数:29,代码来源:CatalogTree.php
示例3: execute
/**
* @see Console\Command\Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$module = $input->getArgument('module');
$modules = $this->moduleManager->getModules();
$path = "{$this->modulesDir}/{$module}-module";
if (isset($modules[$module])) {
$output->writeln("<error>Module '{$module}' already exists.</error>");
return;
}
if (file_exists($path)) {
$output->writeln("<error>Path '" . $path . "' exists.</error>");
return;
}
if (!is_writable(dirname($path))) {
$output->writeln("<error>Path '" . dirname($path) . "' is not writable.</error>");
return;
}
umask(00);
mkdir($path, 0777, TRUE);
file_put_contents($path . '/Module.php', $this->getModuleFile($module));
file_put_contents($path . '/composer.json', $this->getComposerFile($module));
file_put_contents($path . '/readme.md', $this->getReadmeFile($module));
mkdir($path . '/Resources/config', 0777, TRUE);
mkdir($path . '/Resources/public', 0777, TRUE);
mkdir($path . '/Resources/translations', 0777, TRUE);
mkdir($path . '/Resources/layouts', 0777, TRUE);
mkdir($path . '/' . ucfirst($module) . 'Module', 0777, TRUE);
}
开发者ID:svobodni,项目名称:web,代码行数:31,代码来源:CreateCommand.php
示例4: up
public function up()
{
$old = umask(0);
mkdir(Config::get('upload_dir'), 0777);
umask($old);
symlink(Config::get('upload_dir'), Config::get('public_dir') . '/upload');
}
开发者ID:utumdol,项目名称:codeseed,代码行数:7,代码来源:create_upload_directory.class.php
示例5: writeFile
/**
* Writes file in a save way to disk
*
* @param string $_filepath complete filepath
* @param string $_contents file content
* @return boolean true
*/
public static function writeFile($_filepath, $_contents, $smarty)
{
$old_umask = umask(0);
$_dirpath = dirname($_filepath);
// if subdirs, create dir structure
if ($_dirpath !== '.' && !file_exists($_dirpath)) {
mkdir($_dirpath, $smarty->_dir_perms, true);
}
// write to tmp file, then move to overt file lock race condition
$_tmp_file = tempnam($_dirpath, 'wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
$_tmp_file = $_dirpath . DS . uniqid('wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
throw new SmartyException("unable to write file {$_tmp_file}");
return false;
}
}
fwrite($fd, $_contents);
fclose($fd);
// remove original file
if (file_exists($_filepath)) {
@unlink($_filepath);
}
// rename tmp file
rename($_tmp_file, $_filepath);
// set file permissions
chmod($_filepath, $smarty->_file_perms);
umask($old_umask);
return true;
}
开发者ID:kiang,项目名称:olc_baker,代码行数:37,代码来源:smarty_internal_write_file.php
示例6: log_msg
/**
* log a message to file
*
* @param string $level can be error, warn, info or debug
* @param string $msg message
* @return bool true if successful, false if not
*/
function log_msg($level, $msg)
{
global $logfile;
global $loglevels;
global $request_id;
// open logfile
if ($logfile === false) {
$m = umask(0111);
// having two processes appending to the same file should
// work fine (at least on Linux)
$logfile = @fopen(LOG_FILE, 'ab');
umask($m);
}
if ($logfile === false) {
return false;
}
foreach ($loglevels as $ll) {
if ($ll == $level) {
fwrite($logfile, date('Y-m-d H:i:s') . tab() . pad($_SERVER['REMOTE_ADDR'], 15) . tab() . sprintf('%05u', $request_id) . tab() . $level . tab() . $msg . nl());
fflush($logfile);
break;
}
if ($ll == LOG_LEVEL) {
break;
}
}
return true;
}
开发者ID:danielfogarty,项目名称:damp,代码行数:35,代码来源:log.inc.php
示例7: __construct
function __construct($name)
{
global $TMP_PATH;
global $SETUP;
$dir = $TMP_PATH . "/locks";
if (!is_dir($dir)) {
if (!@mkdir($dir, 0777, true)) {
throw new ADEIException(translate("It is not possible to create lock directory \"{$dir}\""));
}
# When creating from apache, the 0777 mode is ignored for unknown reason
@chmod($dir, 0777);
}
if ($SETUP) {
$fname = $dir . "/{$SETUP}__{$name}.lock";
} else {
$fname = $dir . "/ADEI__{$name}.lock";
}
$umask = @umask(0);
$this->lockf = @fopen($fname, "a+");
if (!$this->lockf) {
@umask($umask);
throw new ADEIException(translate("It is not possible to create lock file \"{$fname}\""));
}
$fname = $dir . "/{$name}.lock";
$this->rlock = @fopen($fname, "a+");
if (!$this->rlock) {
fclose($this->lockf);
@umask($umask);
throw new ADEIException(translate("It is not possible to create lock file \"{$fname}\""));
}
@umask($umask);
}
开发者ID:nicolaisi,项目名称:adei,代码行数:32,代码来源:lock.php
示例8: writeCacheFile
/**
* {@inheritdoc}
*/
protected function writeCacheFile($file, $content)
{
$dir = dirname($file);
$currentUmask = umask(00);
if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir));
}
} elseif (!is_writable($dir)) {
throw new RuntimeException(sprintf("Unable to write in the cache directory (%s).", $dir));
}
$success = false;
$tmpFile = tempnam(dirname($file), basename($file));
if (false !== @file_put_contents($tmpFile, $content)) {
if (false === ($success = @rename($tmpFile, $file))) {
$success = copy($tmpFile, $file);
$success = unlink($tmpFile) && $success;
}
}
if ($success) {
chmod($file, 0666);
}
umask($currentUmask);
if (!$success) {
throw new RuntimeException(sprintf('Failed to write cache file "%s".', $file));
}
}
开发者ID:krissym,项目名称:sfTwigPlugin,代码行数:30,代码来源:sfTwigEnvironment.class.php
示例9: _mkdir
/**
* Creates directory
*
* @param string $path Path to create
* @param integer $mode Optional permissions
* @return boolean Success
*/
function _mkdir($path, $mode = 0777)
{
$old = umask(0);
$res = @mkdir($path, $mode);
umask($old);
return $res;
}
开发者ID:RGBvision,项目名称:AVE.cms,代码行数:14,代码来源:thumb.php
示例10: buildXml
/**
* handle request and build XML
* @access protected
*
*/
protected function buildXml()
{
$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_CREATE)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
}
$_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
$sNewFolderName = isset($_GET["NewFolderName"]) ? $_GET["NewFolderName"] : "";
$sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($sNewFolderName);
if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sNewFolderName) || $_resourceTypeConfig->checkIsHiddenFolder($sNewFolderName)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
}
$sServerDir = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $sNewFolderName);
if (!is_writeable($this->_currentFolder->getServerPath())) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
}
$bCreated = false;
if (file_exists($sServerDir)) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
}
if ($perms = $_config->getChmodFolders()) {
$oldUmask = umask(0);
$bCreated = @mkdir($sServerDir, $perms);
umask($oldUmask);
} else {
$bCreated = @mkdir($sServerDir);
}
if (!$bCreated) {
$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
} else {
$oNewFolderNode = new Ckfinder_Connector_Utils_XmlNode("NewFolder");
$this->_connectorNode->addChild($oNewFolderNode);
$oNewFolderNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($sNewFolderName));
}
}
开发者ID:vcgato29,项目名称:poff,代码行数:40,代码来源:CreateFolder.php
示例11: createFromImagine
/**
* @param ImageInterface $image
* @param $namespace
* @param $image_hash
* @param $image_thumb
* @return File
*/
public function createFromImagine(ImageInterface $image, $namespace, $image_hash, $image_thumb)
{
umask(00);
$dest = $this->createDestinationPath($namespace, $image_hash, $image_thumb);
$image->save($dest);
return new File($dest);
}
开发者ID:vlatosev,项目名称:filebundle,代码行数:14,代码来源:ImageCacheManager.php
示例12: __construct
/**
* Initialize the Mage environment.
* @constructor
*/
public function __construct($config)
{
umask(0);
chdir($config['path']);
require_once $config['path'] . '/app/Mage.php';
\Mage::app($config['store']);
}
开发者ID:walexer,项目名称:Magento-on-Angular,代码行数:11,代码来源:MagentoProvider.php
示例13: make_child_dir
private function make_child_dir($path)
{
// No need to continue if the directory already exists
if (is_dir($path)) {
return true;
}
// Make sure parent exists
$parent = dirname($path);
if (!is_dir($parent)) {
$this->make_child_dir($parent);
}
$created = false;
$old = umask(0);
// Try to create new directory with parent directory's permissions
$permissions = substr(sprintf('%o', fileperms($parent)), -4);
if (is_dir($path) || mkdir($path, octdec($permissions), true)) {
$created = true;
} else {
if ($permissions == '0755' && chmod($parent, 0777) && mkdir($path, 0777, true)) {
$created = true;
}
}
umask($old);
return $created;
}
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:25,代码来源:plugin.php
示例14: loadMagento
protected function loadMagento($_languageCode = 'en')
{
if (file_exists($this->__config->get('pathToMagentoApp'))) {
include_once $this->__config->get('pathToMagentoApp');
} else {
if (file_exists(ROOT_DIR . $this->__config->get('pathToMagentoApp'))) {
include_once ROOT_DIR . $this->__config->get('pathToMagentoApp');
} else {
throw new \Exception('Mage NOT Found at ' . $this->__config->get('pathToMagentoApp'));
}
}
umask(0);
\Mage::app();
\Mage::app()->loadArea(\Mage_Core_Model_App_Area::AREA_FRONTEND);
$baseUrlMedia = \Mage::getBaseUrl(\Mage_Core_Model_Store::URL_TYPE_MEDIA);
$_stores = \Mage::app()->getStores(false, true);
if (isset($_stores[$_languageCode]) && $_stores[$_languageCode]->getIsActive()) {
$_storeID = $_stores[$_languageCode]->getId();
} else {
$_storeID = 0;
// default store for no language match
}
$this->set('languagecode', $_languageCode);
$this->set('storeid', $_storeID);
$this->set('baseurlmedia', $baseUrlMedia);
}
开发者ID:tboulogne,项目名称:magento-facebookstorefront,代码行数:26,代码来源:Loader.php
示例15: __construct
public function __construct()
{
$args = func_get_args();
$path = STORAGE_PATH;
// $path = isAke(get_defined_constants(), 'STORAGE_PATH', false);
if (0 == count($args)) {
return;
} elseif (2 == count($args)) {
list($db, $table) = $args;
} elseif (3 == count($args)) {
list($db, $table, $path) = $args;
}
if (false === $path) {
throw new Exception("You must provide a path in third argument of this method.");
}
if (!is_dir($path . DS . 'dbjson')) {
umask(00);
File::mkdir($path . DS . 'dbjson', 0777, true);
}
$this->dir = $path . DS . 'dbjson' . DS . Inflector::lower($db) . DS . Inflector::lower($table);
if (!is_dir($path . DS . 'dbjson' . DS . Inflector::lower($db))) {
umask(00);
File::mkdir($path . DS . 'dbjson' . DS . Inflector::lower($db), 0777, true);
}
if (!is_dir($path . DS . 'dbjson' . DS . Inflector::lower($db) . DS . Inflector::lower($table))) {
umask(00);
File::mkdir($path . DS . 'dbjson' . DS . Inflector::lower($db) . DS . Inflector::lower($table), 0777, true);
}
$changeFile = $this->dir . DS . 'change';
if (!File::exists($changeFile)) {
File::put($changeFile, '');
}
$this->db = $db;
$this->table = $table;
}
开发者ID:noikiy,项目名称:inovi,代码行数:35,代码来源:Dbjson.php
示例16: onSubmit
function onSubmit($vals)
{
$vals['name'] = strtolower($vals['name']);
//make sure that file doesnt exit
if (file_exists('inc/html/' . $vals['set_name'] . '/' . $vals['name'] . '.css')) {
echo '<p>' . intl_get('A file with that name already exists. Choose a different file name.') . '</p>';
echo '<p>' . intl_get('Go <a href=javascript:history.back()>back</a> to choose a different file name.') . '</p>';
}
if (preg_match('/\\.css$/i', $vals['name'])) {
$ext = '';
} else {
$ext = '.css';
}
if (!file_overwrite('inc/html/' . $vals['set_name'] . '/' . $vals['name'] . $ext, $vals['body'])) {
page_title(intl_get('An Error Occurred'));
echo '<p>' . intl_get('The file was unable to be saved. Please verify your server settings before trying again.') . '</p>';
return;
}
umask(00);
chmod('inc/html/' . $vals['set_name'] . '/' . $vals['name'] . $ext, 0777);
list($set, $tpl) = explode('/', $vals['path']);
echo $set . ' ' . $tpl;
page_title('File Saved');
echo '<p><a href="' . site_prefix() . '/index/sitetemplate-templateselect-action?set_name=' . $vals['set_name'] . '">' . intl_get('Return to template set') . '</a></p>';
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:25,代码来源:index.php
示例17: write
function write($log_file_data, $string)
{
$log_dir = $log_file_data[0];
$log_name = $log_file_data[1];
$file_name = $log_dir . $log_name;
if (!is_dir($log_dir)) {
fs::mkdir($log_dir, 0775, true);
}
$oldumask = @umask(0);
$file_existed = @file_exists($file_name);
$log_file = @fopen($file_name, 'a');
if ($log_file) {
$time = strftime("%b %d %Y %H:%M:%S", strtotime('now'));
$notice = '[ ' . $time . " ]\n";
$user =& user::instance();
if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
$notice .= '[ ' . $user_id . ' ] [ ' . $user->get_login() . ' ] [ ' . $user->get_email() . ' ] ';
}
$notice .= '[' . sys::client_ip() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n";
@fwrite($log_file, $notice);
@fclose($log_file);
if (!$file_existed) {
@chmod($file_name, 0664);
}
@umask($oldumask);
$result = true;
} else {
@umask($oldumask);
$result = false;
debug::write_error("Cannot open log file '{$file_name}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$file_name}' is disabled.", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, false);
}
return $result;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:33,代码来源:log.class.php
示例18: __construct
public function __construct(Silex\Application $app, $packageRepo = null)
{
// Needed (for now) to log errors to the bolt_log table.
$this->app = $app;
$this->basedir = $app['resources']->getPath('extensions');
$this->packageRepo = $packageRepo;
$this->packageFile = $app['resources']->getPath('root') . '/extensions/composer.json';
umask(00);
putenv("COMPOSER_HOME=" . $app['resources']->getPath('cache') . '/composer');
$this->wrapper = \evidev\composer\Wrapper::create();
if (!is_file($this->packageFile)) {
$this->execute('init');
}
if (is_file($this->packageFile) && !is_writable($this->packageFile)) {
$this->messages[] = sprintf("The file '%s' is not writable. You will not be able to use this feature without changing the permissions.", $this->packageFile);
}
$this->execute('config repositories.bolt composer ' . $app['extend.site'] . 'satis/');
$json = json_decode(file_get_contents($this->packageFile));
$json->repositories->packagist = false;
$basePackage = "bolt/bolt";
$json->provide = new \stdClass();
$json->provide->{$basePackage} = $app['bolt_version'];
$json->scripts = array('post-package-install' => "Bolt\\Composer\\ScriptHandler::extensions", 'post-package-update' => "Bolt\\Composer\\ScriptHandler::extensions");
$pathToWeb = $app['resources']->findRelativePath($this->app['resources']->getPath('extensions'), $this->app['resources']->getPath('web'));
$json->extra = array('bolt-web-path' => $pathToWeb);
file_put_contents($this->packageFile, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
try {
$json = json_decode(file_get_contents($this->packageRepo));
$this->available = $json->packages;
} catch (\Exception $e) {
$this->messages[] = sprintf($app['translator']->trans("The Bolt extensions Repo at %s is currently unavailable. Check your connection and try again shortly."), $this->packageRepo);
$this->available = array();
}
}
开发者ID:ArdKuijpers,项目名称:bolt,代码行数:34,代码来源:CommandRunner.php
示例19: minimalBootstrap
public static function minimalBootstrap()
{
if (!defined('VENDOR_PATH')) {
define('VENDOR_PATH', 'vendor');
}
if (VENDOR_PATH == '../vendor') {
$kwfPath = '..';
} else {
$kwfPath = VENDOR_PATH . '/koala-framework/koala-framework';
}
if (!defined('KWF_PATH')) {
define('KWF_PATH', $kwfPath);
}
//reset include path, don't use anything from php.ini
set_include_path('.' . PATH_SEPARATOR . $kwfPath . PATH_SEPARATOR . self::_getZendPath());
require_once $kwfPath . '/Kwf/Loader.php';
Kwf_Loader::registerAutoload();
Zend_Registry::setClassName('Kwf_Registry');
$configSection = call_user_func(array(Kwf_Setup::$configClass, 'getDefaultConfigSection'));
Kwf_Setup::$configSection = $configSection;
error_reporting(E_ALL ^ E_STRICT);
class_exists('Kwf_Trl');
//trigger autoload
umask(00);
//nicht 002 weil wwwrun und kwcms in unterschiedlichen gruppen
}
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:26,代码来源:Setup.php
示例20: createUsersFolder
private function createUsersFolder($uid)
{
$userFolder = md5($uid);
$oldUmask = umask(0);
mkdir('data/users/' . $userFolder, 0777, true);
umask($oldUmask);
$oldUmask = umask(0);
mkdir('data/users/' . $userFolder . '/avatar', 0777, true);
umask($oldUmask);
$oldUmask = umask(0);
mkdir('data/users/' . $userFolder . '/album', 0777, true);
umask($oldUmask);
$oldUmask = umask(0);
mkdir('data/users/' . $userFolder . '/event', 0777, true);
umask($oldUmask);
$oldUmask = umask(0);
mkdir('data/users/' . $userFolder . '/home', 0777, true);
umask($oldUmask);
copy('public/templates/default/images/avatar.jpg', 'data/users/' . $userFolder . '/avatar/avatar.jpg');
chmod('data/users/' . $this->user['md5'] . '/avatar.jpg', 0755);
copy('public/templates/default/images/friend.jpg', 'data/users/' . $userFolder . '/avatar/friend.jpg');
chmod('data/users/' . $this->user['md5'] . '/friend.jpg', 0755);
copy('public/templates/default/images/thumbnail.jpg', 'data/users/' . $userFolder . '/avatar/thumbnail.jpg');
chmod('data/users/' . $this->user['md5'] . '/thumbnail.jpg', 0755);
}
开发者ID:Tungse,项目名称:croncase,代码行数:25,代码来源:controller.php
注:本文中的umask函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论