本文整理汇总了PHP中sugar_chmod函数的典型用法代码示例。如果您正苦于以下问题:PHP sugar_chmod函数的具体用法?PHP sugar_chmod怎么用?PHP sugar_chmod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sugar_chmod函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
//If somehow this package already exists copy it
if (file_exists('custom/modules/' . $this->package)) {
$this->packageExists = true;
mkdir_recursive('custom/modules/' . $this->package . '_bak');
copy_recursive('custom/modules/' . $this->package, 'custom/modules/' . $this->package . '_bak');
}
//Make the custom package directory and simulate copying the file in
mkdir_recursive('custom/modules/' . $this->package . '/Ext/WirelessLayoutdefs');
$theArray = array($this->package => array('subpanel_setup' => array($this->package . '_accounts' => array('order' => 100, 'module' => 'Contacts', 'subpanel_name' => 'default', 'title_key' => 'LBL_BUG48784TEST', 'get_subpanel_data' => 'Bug48748Test'))));
$theFile = 'custom/modules/' . $this->package . '/Ext/WirelessLayoutdefs/wireless.subpaneldefs.ext.php';
write_array_to_file('layout_defs', $theArray, $theFile);
sugar_chmod('custom/modules/' . $this->package . '/Ext/WirelessLayoutdefs/wireless.subpaneldefs.ext.php', 0655);
global $beanList, $beanFiles, $current_user;
//$beanList['Contacts'] = 'Contact';
//$beanFiles['Bug48784Mock'] = 'modules/Contacts/Contact.php';
//Create an anonymous user for login purposes/
$current_user = SugarTestUserUtilities::createAnonymousUser();
$current_user->status = 'Active';
$current_user->is_admin = 1;
$current_user->save();
$GLOBALS['db']->commit();
// Making sure we commit any changes before continuing
$_SESSION['avail_modules'][$this->package] = 'write';
}
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:27,代码来源:Bug48748Test.php
示例2: make_not_writable
function make_not_writable($file)
{
// Returns true if the given file/dir has been made not writable
$ret_val = false;
if (is_file($file) || is_dir($file)) {
if (!is_writable($file)) {
$ret_val = true;
} else {
$original_fileperms = fileperms($file);
// take away writable permissions
$new_fileperms = $original_fileperms & ~0x92;
@sugar_chmod($file, $new_fileperms);
if (!is_writable($file)) {
$ret_val = true;
}
}
}
return $ret_val;
}
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:19,代码来源:utils.php
示例3: make_writable
function make_writable($file)
{
$ret_val = false;
if (is_file($file) || is_dir($file)) {
if (is_writable($file)) {
$ret_val = true;
} else {
$original_fileperms = fileperms($file);
// add user writable permission
$new_fileperms = $original_fileperms | 0x80;
@sugar_chmod($file, $new_fileperms);
clearstatcache();
if (is_writable($file)) {
$ret_val = true;
} else {
// add group writable permission
$new_fileperms = $original_fileperms | 0x10;
@chmod($file, $new_fileperms);
clearstatcache();
if (is_writable($file)) {
$ret_val = true;
} else {
// add world writable permission
$new_fileperms = $original_fileperms | 0x2;
@chmod($file, $new_fileperms);
clearstatcache();
if (is_writable($file)) {
$ret_val = true;
}
}
}
}
}
return $ret_val;
}
开发者ID:stefano6310,项目名称:SuiteCRM,代码行数:35,代码来源:install_utils.php
示例4: sugar_touch
/**
* sugar_touch
* Attempts to set the access and modification times of the file named in the filename
* parameter to the value given in time . Note that the access time is always modified,
* regardless of the number of parameters. If the file does not exist it will be created.
* This method is basically a wrapper to the PHP touch method except that created files
* may be set with the permissions specified in the configuration file (if set).
*
* @param $filename - The name of the file being touched.
* @param $time - The touch time. If time is not supplied, the current system time is used.
* @param $atime - If present, the access time of the given filename is set to the value of atime
* @return boolean - Returns TRUE on success or FALSE on failure.
*
*/
function sugar_touch($filename, $time = null, $atime = null)
{
$result = false;
if (!empty($atime) && !empty($time)) {
$result = @touch($filename, $time, $atime);
} else {
if (!empty($time)) {
$result = @touch($filename, $time);
} else {
$result = @touch($filename);
}
}
if (!$result) {
$GLOBALS['log']->error("File {$filename} cannot be touched");
return $result;
}
if (!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])) {
sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
}
if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
sugar_chown($filename);
}
if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
sugar_chgrp($filename);
}
return true;
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:41,代码来源:sugar_file_utils.php
示例5: ConcatenateFiles
function ConcatenateFiles($from_path)
{
// Minifying the group files takes a long time sometimes.
@ini_set('max_execution_time', 300);
$js_groupings = array();
if (isset($_REQUEST['root_directory'])) {
require 'jssource/JSGroupings.php';
} else {
require 'JSGroupings.php';
}
//get array with file sources to concatenate
$file_groups = $js_groupings;
//from JSGroupings.php;
$files_opened = array();
$currPerm = '';
$excludedFiles = get_exclude_files($from_path);
//for each item in array, concatenate the source files
foreach ($file_groups as $fg) {
//process each group array
foreach ($fg as $loc => $trgt) {
$already_minified = FALSE;
$minified_loc = str_replace('.js', '-min.js', $loc);
if (is_file($minified_loc)) {
$loc = $minified_loc;
$already_minified = TRUE;
}
$relpath = $loc;
$loc = $from_path . '/' . $loc;
$trgt = sugar_cached($trgt);
//check to see that source file is a file, and is readable.
if (is_file($loc) && is_readable($loc)) {
$currPerm = fileperms($loc);
//check to see if target exists, if it does then open file
if (file_exists($trgt)) {
if (in_array($trgt, $files_opened)) {
//open target file
if (function_exists('sugar_fopen')) {
$trgt_handle = sugar_fopen($trgt, 'a');
} else {
$trgt_handle = fopen($trgt, 'a');
}
} else {
//open target file
if (function_exists('sugar_fopen')) {
$trgt_handle = sugar_fopen($trgt, 'w');
} else {
$trgt_handle = fopen($trgt, 'w');
}
}
} else {
if (!function_exists('mkdir_recursive')) {
require_once 'include/dir_inc.php';
}
mkdir_recursive(dirname($trgt));
//create and open target file
if (function_exists('sugar_fopen')) {
$trgt_handle = @sugar_fopen($trgt, 'w');
} else {
$trgt_handle = @fopen($trgt, 'w');
}
// todo: make this failure more friendly. Ideally, it will display a
// warning to admin users and revert back to displaying all of the
// Javascript files insted of displaying the minified versions.
if ($trgt_handle === false) {
$target_directory = dirname($trgt);
$base = dirname($target_directory);
while (!is_dir($base) && !empty($base) && $base != dirname($base)) {
$base = dirname($base);
}
sugar_die("Creating {$target_directory} failed: please make sure {$base} is writable\n");
}
}
$files_opened[] = $trgt;
//make sure we have handles to both source and target file
if ($trgt_handle) {
if ($already_minified || isset($excludedFiles[dirname($loc)])) {
$buffer = file_get_contents($loc);
} else {
$buffer = SugarMin::minify(file_get_contents($loc));
}
$buffer .= "/* End of File {$relpath} */\n\n";
$num = fwrite($trgt_handle, $buffer);
if ($num === false) {
//log error, file did not get appended
echo "Error while concatenating file {$loc} to target file {$trgt} \n";
}
//close file opened.
fclose($trgt_handle);
}
}
}
//set permissions on this file
if (!empty($currPerm) && $currPerm !== false) {
//if we can retrieve permissions from target files, use same
//permission on concatenated file
if (function_exists('sugar_chmod')) {
@sugar_chmod($trgt, $currPerm);
} else {
@chmod($trgt, $currPerm);
}
//.........这里部分代码省略.........
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:101,代码来源:minify_utils.php
示例6: testSugarChmodWithModeDefaultModeNotAnInteger
public function testSugarChmodWithModeDefaultModeNotAnInteger()
{
$GLOBALS['sugar_config']['default_permissions']['file_mode'] = '';
$mode = 0411;
$this->assertTrue(sugar_chmod($this->_filename, $mode));
$this->assertEquals($this->_getTestFilePermissions(), decoct($mode));
}
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:7,代码来源:SugarFileUtilsTest.php
示例7: ConcatenateFiles
function ConcatenateFiles($from_path)
{
$js_groupings = array();
if (isset($_REQUEST['root_directory'])) {
require 'jssource/JSGroupings.php';
} else {
require 'JSGroupings.php';
}
//get array with file sources to concatenate
$file_groups = $js_groupings;
//from JSGroupings.php;
$files_opened = array();
$currPerm = '';
//for each item in array, concatenate the source files
foreach ($file_groups as $fg) {
//process each group array
foreach ($fg as $loc => $trgt) {
$relpath = $loc;
$loc = $from_path . '/' . $loc;
$trgt = $from_path . '/' . $trgt;
//check to see that source file exists, that it is a file, and is readable
if (file_exists($loc) && is_file($loc) && is_readable($loc)) {
$currPerm = fileperms($loc);
//check to see if target exists, if it does then open file
if (file_exists($trgt)) {
if (in_array($trgt, $files_opened)) {
//open target file
if (function_exists('sugar_fopen')) {
$trgt_handle = sugar_fopen($trgt, 'a');
} else {
$trgt_handle = fopen($trgt, 'a');
}
} else {
//open target file
if (function_exists('sugar_fopen')) {
$trgt_handle = sugar_fopen($trgt, 'w');
} else {
$trgt_handle = fopen($trgt, 'w');
}
}
} else {
//create and open target file
if (function_exists('sugar_fopen')) {
$trgt_handle = @sugar_fopen($trgt, 'w');
} else {
$trgt_handle = @fopen($trgt, 'w');
}
// todo: make this failure more friendly. Ideally, it will display a
// warning to admin users and revert back to displaying all of the
// Javascript files insted of displaying the minified versions.
if ($trgt_handle === false) {
$target_directory = dirname($trgt);
$base_name = realpath(dirname(__FILE__) . '/..') . '/';
$target_directory = substr($target_directory, strlen($base_name));
sugar_die("please make sure {$target_directory} is writable\n");
}
}
$files_opened[] = $trgt;
//make sure we have handles to both source and target file
if ($trgt_handle) {
$buffer = file_get_contents($loc);
$buffer .= "// End of File {$relpath}\n \n";
$num = fwrite($trgt_handle, $buffer);
if ($num === false) {
//log error, file did not get appended
echo "Error while concatenating file {$loc} to target file {$trgt} \n";
}
//close file opened.
fclose($trgt_handle);
}
}
}
//set permissions on this file
if (!empty($currPerm) && $currPerm !== false) {
//if we can retrieve permissions from target files, use same
//permission on concatenated file
if (function_exists('sugar_chmod')) {
@sugar_chmod($trgt, $currPerm);
} else {
@chmod($trgt, $currPerm);
}
} else {
//no permissions could be retrieved, so set to 777
if (function_exists('sugar_chmod')) {
@sugar_chmod($trgt, 0777);
} else {
@chmod($trgt, 0777);
}
}
}
}
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:91,代码来源:minify_utils.php
示例8: sugar_touch
/**
* sugar_touch
* Attempts to set the access and modification times of the file named in the filename
* parameter to the value given in time . Note that the access time is always modified,
* regardless of the number of parameters. If the file does not exist it will be created.
* This method is basically a wrapper to the PHP touch method except that created files
* may be set with the permissions specified in the configuration file (if set).
*
* @param $filename - The name of the file being touched.
* @param $time - The touch time. If time is not supplied, the current system time is used.
* @param $atime - If present, the access time of the given filename is set to the value of atime
* @return boolean - Returns TRUE on success or FALSE on failure.
*
*/
function sugar_touch($filename, $time = null, $atime = null)
{
if (!empty($GLOBALS['sugar_config']['default_permissions']['dir_mode'])) {
$dirmode = $GLOBALS['sugar_config']['default_permissions']['dir_mode'];
} else {
$dirmode = null;
}
$result = sugar_mkdir(dirname($filename), $dirmode, true);
if (!$result) {
return $result;
}
if (!empty($atime) && !empty($time)) {
$result = @touch($filename, $time, $atime);
} else {
if (!empty($time)) {
$result = @touch($filename, $time);
} else {
$result = @touch($filename);
}
}
if (!$result) {
$GLOBALS['log']->error("File {$filename} cannot be touched");
return $result;
}
if (!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])) {
sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']);
}
if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) {
sugar_chown($filename);
}
if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) {
sugar_chgrp($filename);
}
// Add this to the file loader cache
if (!SugarAutoLoader::fileExists($filename)) {
SugarAutoLoader::addToMap($filename);
}
return true;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:53,代码来源:sugar_file_utils.php
注:本文中的sugar_chmod函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论