* @param $filemode unix style file permissions as integer
* @param int $filemode unix style file permissions
*
* @return bool
*/
*/
static function chmodr($path, $filemode) {
static function chmodr($path, $filemode) {
if (!is_dir($path))
if (!is_dir($path))
@ -277,7 +276,7 @@ class OC_Helper {
}
}
/**
/**
* @brief Recusive copying of folders
* @brief Recursive copying of folders
* @param string $src source folder
* @param string $src source folder
* @param string $dest target folder
* @param string $dest target folder
*
*
@ -299,9 +298,9 @@ class OC_Helper {
}
}
/**
/**
* @brief Recusive deletion of folders
* @brief Recursive deletion of folders
* @param string $dir path to the folder
* @param string $dir path to the folder
*
* @return bool
*/
*/
static function rmdirr($dir) {
static function rmdirr($dir) {
if(is_dir($dir)) {
if(is_dir($dir)) {
@ -317,12 +316,14 @@ class OC_Helper {
}
}
if(file_exists($dir)) {
if(file_exists($dir)) {
return false;
return false;
}else{
return true;
}
}
}
}
/**
/**
* get the mimetype form a local file
* get the mimetype form a local file
* @param string path
* @param string $path
* @return string
* @return string
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
*/
*/
@ -379,7 +380,7 @@ class OC_Helper {
/**
/**
* get the mimetype form a data string
* get the mimetype form a data string
* @param string data
* @param string $data
* @return string
* @return string
*/
*/
static function getStringMimeType($data) {
static function getStringMimeType($data) {
@ -399,9 +400,9 @@ class OC_Helper {
/**
/**
* @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d.
* @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d.
* @param $s name of the var to escape, if set.
* @param string $s name of the var to escape, if set.
* @param $d default value.
* @param string $d default value.
* @returns the print-safe value.
* @returnstring the print-safe value.
*
*
*/
*/
@ -415,7 +416,7 @@ class OC_Helper {
}
}
/**
/**
* returns "checked"-attribut if request contains selected radio element OR if radio element is the default one -- maybe?
* returns "checked"-attribute if request contains selected radio element OR if radio element is the default one -- maybe?
* @param string $s Name of radio-button element name
* @param string $s Name of radio-button element name
* @param string $v Value of current radio-button element
* @param string $v Value of current radio-button element
* @param string $d Value of default radio-button element
* @param string $d Value of default radio-button element
@ -428,8 +429,8 @@ class OC_Helper {
/**
/**
* detect if a given program is found in the search PATH
* detect if a given program is found in the search PATH
*
*
* @param string program name
* @param string $program name
* @param string optional search path, defaults to $PATH
* @param string $optional search path, defaults to $PATH
* @return bool true if executable program found in path
* @return bool true if executable program found in path
*/
*/
public static function canExecute($name, $path = false) {
public static function canExecute($name, $path = false) {
@ -451,18 +452,16 @@ class OC_Helper {
$dirs = explode(PATH_SEPARATOR, $path);
$dirs = explode(PATH_SEPARATOR, $path);
// WARNING : We have to check if open_basedir is enabled :
// WARNING : We have to check if open_basedir is enabled :
$obd = ini_get('open_basedir');
$obd = ini_get('open_basedir');
if($obd != "none")
if($obd != "none"){
$obd_values = explode(PATH_SEPARATOR, $obd);
$obd_values = explode(PATH_SEPARATOR, $obd);
if(count($obd_values) > 0 and $obd_values[0])
if(count($obd_values) > 0 and $obd_values[0]){
{
// open_basedir is in effect !
// open_basedir is in effect !
// We need to check if the program is in one of these dirs :
// We need to check if the program is in one of these dirs :
$dirs = $obd_values;
$dirs = $obd_values;
}
}
}
foreach($dirs as $dir)
foreach($dirs as $dir){
{
foreach($exts as $ext){
foreach($exts as $ext)
{
if($check_fn("$dir/$name".$ext))
if($check_fn("$dir/$name".$ext))
return true;
return true;
}
}
@ -472,8 +471,8 @@ class OC_Helper {
/**
/**
* copy the contents of one stream to another
* copy the contents of one stream to another
* @param resource source
* @param resource $source
* @param resource target
* @param resource $target
* @return int the number of bytes copied
* @return int the number of bytes copied
*/
*/
public static function streamCopy($source,$target) {
public static function streamCopy($source,$target) {
@ -489,7 +488,7 @@ class OC_Helper {
/**
/**
* create a temporary file with an unique filename
* create a temporary file with an unique filename
* @param string postfix
* @param string $postfix
* @return string
* @return string
*
*
* temporary files are automatically cleaned up after the script is finished
* temporary files are automatically cleaned up after the script is finished
@ -553,10 +552,10 @@ class OC_Helper {
$ext = substr($filename, $pos);
$ext = substr($filename, $pos);
} else {
} else {
$name = $filename;
$name = $filename;
$ext = '';
}
}
$newpath = $path . '/' . $filename;
$newpath = $path . '/' . $filename;
$newname = $filename;
$counter = 2;
$counter = 2;
while (OC_Filesystem::file_exists($newpath)) {
while (OC_Filesystem::file_exists($newpath)) {
$newname = $name . ' (' . $counter . ')' . $ext;
$newname = $name . ' (' . $counter . ')' . $ext;
@ -570,8 +569,8 @@ class OC_Helper {
/*
/*
* checks if $sub is a subdirectory of $parent
* checks if $sub is a subdirectory of $parent
*
*
* @param $sub
* @param string $sub
* @param $parent
* @param string $parent
* @return bool
* @return bool
*/
*/
public static function issubdirectory($sub, $parent) {
public static function issubdirectory($sub, $parent) {
@ -604,9 +603,9 @@ class OC_Helper {
/**
/**
* @brief Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
* @brief Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
*
*
* @param $input The array to work on
* @param array $input The array to work on
* @param $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
* @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
* @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return array
* @return array
*
*
* Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
* Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
@ -625,11 +624,11 @@ class OC_Helper {
/**
/**
* @brief replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement.
* @brief replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement.
*
*
* @param $input The input string. .Opposite to the PHP build-in function does not accept an array.
* @param string $input The input string. .Opposite to the PHP build-in function does not accept an array.
* @param $replacement The replacement string.
* @param string $replacement The replacement string.
* @param $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.
* @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.
* @param $length Length of the part to be replaced
* @param int $length Length of the part to be replaced
* @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return string
* @return string
*
*
*/
*/
@ -646,11 +645,11 @@ class OC_Helper {
/**
/**
* @brief Replace all occurrences of the search string with the replacement string
* @brief Replace all occurrences of the search string with the replacement string
*
*
* @param $search The value being searched for, otherwise known as the needle. String.
* @param string $search The value being searched for, otherwise known as the needle.
* @param $replace The replacement string.
* @param string $replace The replacement
* @param $subject The string or array being searched and replaced on, otherwise known as the haystack.
* @param string $subject The string or array being searched and replaced on, otherwise known as the haystack.
* @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @param $count If passed, this will be set to the number of replacements performed.
* @param int $count If passed, this will be set to the number of replacements performed.
* @return string
* @return string
*
*
*/
*/
@ -667,10 +666,10 @@ class OC_Helper {
/**
/**
* @brief performs a search in a nested array
* @brief performs a search in a nested array
* @param haystack the array to be searched
* @param array $haystack the array to be searched
* @param needle the search string
* @param string $needle the search string
* @param $index optional, only search this key name
* @param string $index optional, only search this key name
* @return the key of the matching field, otherwise false
* @return mixed the key of the matching field, otherwise false