- * @author René Haentjens, UGent (RH)
- * @author Ivan Tcholakov, JUN-2009. Transliteration functionality has been added.
- * @param string $filename The filename string.
- * @param string $strict (optional) When it is 'strict', all non-ASCII charaters will be replaced. Additional ASCII replacemets will be done too.
- * @return string The cleaned filename.
+ * @param string $filename
+ * @param int $length
+ * @param bool $file_name
+ * @return string
*/
-
-function api_replace_dangerous_char($filename, $strict = 'loose')
+function api_replace_dangerous_char($filename)
{
- return URLify::filter($filename, 250);
+ return URLify::filter($filename, 250, '', true);
+
/*
// Safe replacements for some non-letter characters.
static $search = array(',', "\0", ' ', "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%');
diff --git a/main/inc/lib/diagnoser.lib.php b/main/inc/lib/diagnoser.lib.php
index a0794ef286..dca6e8d66c 100755
--- a/main/inc/lib/diagnoser.lib.php
+++ b/main/inc/lib/diagnoser.lib.php
@@ -72,7 +72,7 @@ class Diagnoser
$array = array();
$writable_folders = array(
api_get_path(SYS_APP_PATH) .'cache',
- api_get_path(SYS_APP_PATH) .'courses',
+ api_get_path(SYS_COURSE_PATH),
api_get_path(SYS_APP_PATH) .'home',
api_get_path(SYS_APP_PATH) .'upload/users/',
api_get_path(SYS_PATH) .'main/default_course_document/images/',
diff --git a/main/inc/lib/extra_field_value.lib.php b/main/inc/lib/extra_field_value.lib.php
index 1d174f2798..5748e21337 100755
--- a/main/inc/lib/extra_field_value.lib.php
+++ b/main/inc/lib/extra_field_value.lib.php
@@ -166,10 +166,10 @@ class ExtraFieldValue extends Model
switch ($this->type) {
case 'course':
- $fileDir = api_get_path(SYS_APP_PATH)."upload/courses/";
+ $fileDir = api_get_path(SYS_UPLOAD_PATH)."courses/";
break;
case 'session':
- $fileDir = api_get_path(SYS_APP_PATH)."upload/sessions/";
+ $fileDir = api_get_path(SYS_UPLOAD_PATH)."sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($this->handler_id, 'system');
@@ -204,10 +204,10 @@ class ExtraFieldValue extends Model
switch ($this->type) {
case 'course':
- $fileDir = api_get_path(SYS_APP_PATH)."upload/courses/";
+ $fileDir = api_get_path(SYS_UPLOAD_PATH)."courses/";
break;
case 'session':
- $fileDir = api_get_path(SYS_APP_PATH)."upload/sessions/";
+ $fileDir = api_get_path(SYS_UPLOAD_PATH)."sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($this->handler_id, 'system');
diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php
index 8dd70bc8d2..806283b96c 100755
--- a/main/inc/lib/group_portal_manager.lib.php
+++ b/main/inc/lib/group_portal_manager.lib.php
@@ -956,11 +956,11 @@ class GroupPortalManager
{
switch ($type) {
case 'system': // Base: absolute system path.
- $base = api_get_path(SYS_APP_PATH);
+ $base = api_get_path(SYS_UPLOAD_PATH);
break;
case 'web': // Base: absolute web path.
default:
- $base = api_get_path(WEB_PATH).'app/';
+ $base = api_get_path(WEB_PATH).'app/uploads/';
break;
}
@@ -985,14 +985,14 @@ class GroupPortalManager
if (api_get_setting('split_users_upload_directory') === 'true') {
if (!empty($picture_filename)) {
- $dir = $base.'upload/groups/'.substr($picture_filename, 0, 1).'/'.$id.'/';
+ $dir = $base.'groups/'.substr($picture_filename, 0, 1).'/'.$id.'/';
} elseif ($preview) {
- $dir = $base.'upload/groups/'.substr((string) $id, 0, 1).'/'.$id.'/';
+ $dir = $base.'groups/'.substr((string) $id, 0, 1).'/'.$id.'/';
} else {
- $dir = $base.'upload/groups/'.$id.'/';
+ $dir = $base.'groups/'.$id.'/';
}
} else {
- $dir = $base.'upload/groups/'.$id.'/';
+ $dir = $base.'groups/'.$id.'/';
}
if (empty($picture_filename) && $anonymous) {
diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php
index 1d04f3b21b..9ab234ab48 100755
--- a/main/inc/lib/usermanager.lib.php
+++ b/main/inc/lib/usermanager.lib.php
@@ -413,7 +413,8 @@ class UserManager
a user has 4 different sized photos to be deleted. */
$user_info = api_get_user_info($user_id);
if (strlen($user_info['picture_uri']) > 0) {
- $img_path = api_get_path(SYS_APP_PATH).'upload/users/'.$user_id.'/'.$user_info['picture_uri'];
+ $path = self::getUserPathById($user_id);
+ $img_path = $path.$user_info['picture_uri'];
if (file_exists($img_path))
unlink($img_path);
}
@@ -1242,7 +1243,7 @@ class UserManager
'email' => '',
);
- if ((empty($id) || empty($type))) {
+ if (empty($id) || empty($type)) {
return $anonymousPath;
}
@@ -1277,7 +1278,7 @@ class UserManager
* The return format is a complete path to a folder ending with "/"
* @param integer $id User ID
* @param string $type Type of path to return (can be 'system', 'web')
- * @return string User folder path (i.e. /var/www/chamilo/main/upload/users/1/1/)
+ * @return string User folder path (i.e. /var/www/chamilo/app/upload/users/1/1/)
*/
public static function getUserPathById($id, $type)
{
@@ -1286,17 +1287,16 @@ class UserManager
return null;
}
- $userPath = "upload/users/$id/";
+ $userPath = "users/$id/";
if (api_get_setting('split_users_upload_directory') === 'true') {
- $userPath = 'upload/users/'.substr((string) $id, 0, 1).'/'.$id.'/';
+ $userPath = 'users/'.substr((string) $id, 0, 1).'/'.$id.'/';
}
-
switch ($type) {
case 'system': // Base: absolute system path.
- $userPath = api_get_path(SYS_APP_PATH).$userPath;
+ $userPath = api_get_path(SYS_UPLOAD_PATH).$userPath;
break;
case 'web': // Base: absolute web path.
- $userPath = api_get_path(WEB_PATH).'app/'.$userPath;
+ $userPath = api_get_path(WEB_PATH).'app/upload/'.$userPath;
break;
}
@@ -1306,7 +1306,7 @@ class UserManager
/**
* Gets the current user image
* @param string $user_id
- * @param string $size it can be USER_IMAGE_SIZE_SMALL,
+ * @param int $size it can be USER_IMAGE_SIZE_SMALL,
* USER_IMAGE_SIZE_MEDIUM, USER_IMAGE_SIZE_BIG or USER_IMAGE_SIZE_ORIGINAL
* @param bool $addRandomId
* @param array $userInfo to avoid query the DB
@@ -1323,6 +1323,10 @@ class UserManager
$pictureWebFile = $imageWebPath['file'];
$pictureWebDir = $imageWebPath['dir'];
+ $pictureAnonymous = 'unknown.jpg';
+ $gravatarSize = 22;
+ $realSizeName = 'small_';
+
switch ($size) {
case USER_IMAGE_SIZE_SMALL:
$pictureAnonymous = 'unknown_22.jpg';
@@ -1360,9 +1364,10 @@ class UserManager
}
return $file;
}
+
$anonymousPath = api_get_path(WEB_CODE_PATH).'img/'.$pictureAnonymous;
- if ($pictureWebFile == 'unknown.jpg') {
+ if ($pictureWebFile == 'unknown.jpg' || empty($pictureWebFile)) {
return $anonymousPath;
}
diff --git a/main/install/install.lib.php b/main/install/install.lib.php
index 982ed93358..4ee895c7a1 100755
--- a/main/install/install.lib.php
+++ b/main/install/install.lib.php
@@ -899,16 +899,16 @@ function display_requirements(
'.check_writable(api_get_path(CONFIGURATION_PATH)).' |
- '.api_get_path(SYS_APP_PATH).'upload/users/ |
- '.check_writable(api_get_path(SYS_APP_PATH).'upload/users/').' |
+ '.api_get_path(SYS_UPLOAD_PATH).'users/ |
+ '.check_writable(api_get_path(SYS_UPLOAD_PATH).'users/').' |
- '.api_get_path(SYS_APP_PATH).'upload/sessions/ |
- '.check_writable(api_get_path(SYS_APP_PATH).'upload/sessions/').' |
+ '.api_get_path(SYS_UPLOAD_PATH).'sessions/ |
+ '.check_writable(api_get_path(SYS_UPLOAD_PATH).'sessions/').' |
- '.api_get_path(SYS_APP_PATH).'upload/courses/ |
- '.check_writable(api_get_path(SYS_APP_PATH).'upload/courses/').' |
+ '.api_get_path(SYS_UPLOAD_PATH).'courses/ |
+ '.check_writable(api_get_path(SYS_UPLOAD_PATH).'courses/').' |
'.api_get_path(SYS_CODE_PATH).'default_course_document/images/ |
@@ -1007,19 +1007,19 @@ function display_requirements(
@chmod($checked_writable, $perm);
}
- $checked_writable = api_get_path(SYS_APP_PATH).'upload/users/';
+ $checked_writable = api_get_path(SYS_UPLOAD_PATH).'users/';
if (!is_writable($checked_writable)) {
$notWritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
- $checkedWritable = api_get_path(SYS_APP_PATH).'upload/sessions/';
+ $checkedWritable = api_get_path(SYS_UPLOAD_PATH).'sessions/';
if (!is_writable($checkedWritable)) {
$notWritable[] = $checkedWritable;
@chmod($checkedWritable, $perm);
}
- $checkedWritable = api_get_path(SYS_APP_PATH).'upload/courses/';
+ $checkedWritable = api_get_path(SYS_UPLOAD_PATH).'courses/';
if (!is_writable($checkedWritable)) {
$notWritable[] = $checkedWritable;
@chmod($checkedWritable, $perm);
diff --git a/tests/wipe-out.php b/tests/wipe-out.php
index 8cc6e3b620..205e6bac24 100755
--- a/tests/wipe-out.php
+++ b/tests/wipe-out.php
@@ -52,7 +52,7 @@ $homepath = api_get_path(SYS_PATH).'home';
$clean_dirs = array(
api_get_path(SYS_COURSE_PATH), //courses
api_get_path(SYS_APP_PATH).'config/',
- api_get_path(SYS_APP_PATH).'upload/users/',
+ api_get_path(SYS_UPLOAD_PATH).'users/',
api_get_path(SYS_ARCHIVE_PATH)
);