Upload file error: open_basedir restriction quickfix
Page: 1
I had the same problem like many other members with open_basedir restriction and this fix worked for me like a charm on my fedora box...
- First locate activecollab\environment\functions folder and open the file "files.php".
- Find the function force_mkdir and change this line:
if(!is_dir($forced_path)) {
to:
if(!my_is_dir($forced_path)) {
* note that we added "my_" prefix on "is_dir" function.
- Add this new function just below force_mkdir to bypass open_basedir restrictions:
function my_is_dir($dir)
{
// bypasses open_basedir restrictions of is_dir and fileperms
$tmp_cmd = `ls -dl $dir`;
$dir_flag = $tmp_cmd[0];
if($dir_flag!="d")
{
// not d; use next char (first char might be 's' and is still directory)
$dir_flag = $tmp_cmd[1];
}
return ($dir_flag=="d");
}
- Save and upload.
*****
Great work, Ilija!!! Take care!
- First locate activecollab\environment\functions folder and open the file "files.php".
- Find the function force_mkdir and change this line:
if(!is_dir($forced_path)) {
to:
if(!my_is_dir($forced_path)) {
* note that we added "my_" prefix on "is_dir" function.
- Add this new function just below force_mkdir to bypass open_basedir restrictions:
function my_is_dir($dir)
{
// bypasses open_basedir restrictions of is_dir and fileperms
$tmp_cmd = `ls -dl $dir`;
$dir_flag = $tmp_cmd[0];
if($dir_flag!="d")
{
// not d; use next char (first char might be 's' and is still directory)
$dir_flag = $tmp_cmd[1];
}
return ($dir_flag=="d");
}
- Save and upload.
*****
Great work, Ilija!!! Take care!
Friends,
I don't understand well this issue. Example: My database prefix name, anathema_ so i have to use it like this : anathema_is_dir and change all my_ to anathema_ is it true?
And i don't understand well where i have to add these codes :
function my_is_dir($dir)
{
// bypasses open_basedir restrictions of is_dir and fileperms
$tmp_cmd = `ls -dl $dir`;
$dir_flag = $tmp_cmd[0];
if($dir_flag!="d")
{
// not d; use next char (first char might be 's' and is still directory)
$dir_flag = $tmp_cmd[1];
}
return ($dir_flag=="d");
}
Thanks for your reply from now. Take care
I don't understand well this issue. Example: My database prefix name, anathema_ so i have to use it like this : anathema_is_dir and change all my_ to anathema_ is it true?
And i don't understand well where i have to add these codes :
function my_is_dir($dir)
{
// bypasses open_basedir restrictions of is_dir and fileperms
$tmp_cmd = `ls -dl $dir`;
$dir_flag = $tmp_cmd[0];
if($dir_flag!="d")
{
// not d; use next char (first char might be 's' and is still directory)
$dir_flag = $tmp_cmd[1];
}
return ($dir_flag=="d");
}
Thanks for your reply from now. Take care
The fix worked well for me. For those of you who are confused, here is the replacement code:
function force_mkdir($path, $chmod = null) {
if(is_dir($path)) return true;
$real_path = str_replace('\\', '/', $path);
$parts = explode('/', $real_path);
$forced_path = '';
foreach($parts as $part) {
// Skip first on windows
if($forced_path == '') {
$start = substr(__FILE__, 0, 1) == '/' ? '/' : '';
$forced_path = $start . $part;
} else {
$forced_path .= '/' . $part;
} // if
if(!my_is_dir($forced_path)) {
if(!is_null($chmod)) {
if(!mkdir($forced_path)) return false;
} else {
if(!mkdir($forced_path, $chmod)) return false;
} // if
} // if
} // foreach
return true;
} // force_mkdir
function my_is_dir($dir)
{
// bypasses open_basedir restrictions of is_dir and fileperms
$tmp_cmd = `ls -dl $dir`;
$dir_flag = $tmp_cmd[0];
if($dir_flag!="d")
{
// not d; use next char (first char might be 's' and is still directory)
$dir_flag = $tmp_cmd[1];
}
return ($dir_flag=="d");
}
function force_mkdir($path, $chmod = null) {
if(is_dir($path)) return true;
$real_path = str_replace('\\', '/', $path);
$parts = explode('/', $real_path);
$forced_path = '';
foreach($parts as $part) {
// Skip first on windows
if($forced_path == '') {
$start = substr(__FILE__, 0, 1) == '/' ? '/' : '';
$forced_path = $start . $part;
} else {
$forced_path .= '/' . $part;
} // if
if(!my_is_dir($forced_path)) {
if(!is_null($chmod)) {
if(!mkdir($forced_path)) return false;
} else {
if(!mkdir($forced_path, $chmod)) return false;
} // if
} // if
} // foreach
return true;
} // force_mkdir
function my_is_dir($dir)
{
// bypasses open_basedir restrictions of is_dir and fileperms
$tmp_cmd = `ls -dl $dir`;
$dir_flag = $tmp_cmd[0];
if($dir_flag!="d")
{
// not d; use next char (first char might be 's' and is still directory)
$dir_flag = $tmp_cmd[1];
}
return ($dir_flag=="d");
}
Topic is locked. If you have something important to say about issues discussed on this page please write at hi@a51dev.com.



