diff --git a/main/inc/lib/security.lib.php b/main/inc/lib/security.lib.php index c8a019a706..5e9004fd69 100755 --- a/main/inc/lib/security.lib.php +++ b/main/inc/lib/security.lib.php @@ -1,6 +1,8 @@ */ -use Chamilo\CoreBundle\Component\HTMLPurifier\Filter\AllowIframes; - /** * Security class * @@ -186,7 +186,7 @@ class Security */ public static function get_HTML_token() { - $token = md5(uniqid(rand(), TRUE)); + $token = md5(uniqid(rand(), true)); $string = ''; $_SESSION['sec_token'] = $token; @@ -235,51 +235,6 @@ class Security $_SESSION['sec_ua'] = $_SERVER['HTTP_USER_AGENT'].$_SESSION['sec_ua_seed']; } - /** - * This function filters a variable to the type given, with the options given - * @param mixed The variable to be filtered - * @param string The type of variable we expect (bool,int,float,string) - * @param array Additional options - * @return bool True if variable was filtered and added to the current object, false otherwise - */ - public static function filter($var, $type = 'string', $options = array()) - { - // This function has not been finished! Do not use! - $result = false; - // Get variable name and value. - $args = func_get_args(); - $names = array_keys($args); - $name = $names[0]; - $value = $args[$name]; - switch ($type) { - case 'bool': - $result = (bool) $var; - break; - case 'int': - $result = (int) $var; - break; - case 'float': - $result = (float) $var; - break; - case 'string/html': - $result = self::remove_XSS($var); - break; - case 'string/db': - $result = Database::escape_string($var); - break; - case 'array': - // An array variable shouldn't be given to the filter. - return false; - default: - return false; - } - if (!empty($option['save'])) { - self::$clean[$name] = $result; - } - - return $result; - } - /** * This function returns a variable from the clean array. If the variable doesn't exist, * it returns null @@ -434,7 +389,6 @@ class Security return $text; } - /** * This method provides specific protection (against XSS and other kinds of attacks) for static images (icons) used by the system. * Image paths are supposed to be given by programmers - people who know what they do, anyway, this method encourages diff --git a/main/inc/lib/sub_language.class.php b/main/inc/lib/sub_language.class.php index 9d99612dee..5c57fb0d5c 100644 --- a/main/inc/lib/sub_language.class.php +++ b/main/inc/lib/sub_language.class.php @@ -17,7 +17,8 @@ class SubLanguageManager /** * Get all the languages * @param bool $onlyActive Whether to return only active languages (default false) - * @return Array All information about sub-language + * + * @return array All information about sub-language */ public static function getAllLanguages($onlyActive = false) { @@ -38,10 +39,10 @@ class SubLanguageManager /** * Get all files of lang folder (forum.inc.php,gradebook.inc.php,notebook.inc.php) - * @param String The lang path folder (/var/www/my_lms/main/lang/spanish) + * @param string The lang path folder (/var/www/my_lms/main/lang/spanish) * @param bool true if we only want the "subname" trad4all instead of trad4all.inc.php * - * @return Array All file of lang folder + * @return array All file of lang folder */ public static function get_lang_folder_files_list($path, $only_main_name = false) { @@ -69,7 +70,7 @@ class SubLanguageManager * Get all information of sub-language * @param Integer The parent id(Language father id) * @param Integer The sub language id - * @return Array All information about sub-language + * @return array All information about sub-language */ public static function get_all_information_of_sub_language($parent_id, $sub_language_id) { @@ -90,7 +91,7 @@ class SubLanguageManager /** * Get all information of language * @param Integer The parent id(Language father id) - * @return Array All information about language + * @return array All information about language */ public static function get_all_information_of_language($parent_id) { @@ -107,9 +108,9 @@ class SubLanguageManager /** * Get all information of chamilo file - * @param String The chamilo path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php) + * @param string The chamilo path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php) * @patam Bool Whether we want to remove the '$' prefix in the results or not - * @return Array Contains all information of chamilo file + * @return array Contains all information of chamilo file */ public static function get_all_language_variable_in_file($system_path_file, $get_as_string_index = false) { @@ -136,7 +137,8 @@ class SubLanguageManager /** * Add file in sub-language directory and add header(tag php) - * @param String The chamilo path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php) + * @param string The chamilo path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php) + * * @return bool */ public static function add_file_in_language_directory($system_path_file) @@ -148,9 +150,9 @@ class SubLanguageManager /** * Write in file of sub-language - * @param String The path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php) - * @param String The new sub-language - * @param String The language variable + * @param string The path file (/var/www/chamilo/main/lang/spanish/gradebook.inc.php) + * @param string The new sub-language + * @param string The language variable * @return Boolean True on success, False on error */ public static function write_data_in_file($path_file, $new_term, $new_variable) @@ -225,7 +227,7 @@ class SubLanguageManager /** * Remove directory for sub-language - * @param String The sub-language path directory ( e.g. 'spanish_corporate'' ) + * @param string The sub-language path directory ( e.g. 'spanish_corporate'' ) * @return boolean True on success, false on failure */ public static function remove_language_directory($sub_language_dir) @@ -275,8 +277,8 @@ class SubLanguageManager /** * Get name of language by id - * @param Integer The language id - * @return String The original name of language + * @param int The language id + * @return string The original name of language */ public static function get_name_of_language_by_id($language_id) { @@ -332,7 +334,7 @@ class SubLanguageManager /** * Verified if language is father of an sub-language - * @param Integer The language id + * @param int The language id * @return Boolean */ public static function check_if_language_is_father($language_id) @@ -351,7 +353,7 @@ class SubLanguageManager /** * Make unavailable the language - * @param Integer The language id + * @param int The language id * @return void() */ public static function make_unavailable_language($language_id) @@ -366,7 +368,7 @@ class SubLanguageManager /** * Make available the language - * @param Integer The language id + * @param int The language id * @return void */ public static function make_available_language($language_id) @@ -381,7 +383,7 @@ class SubLanguageManager /** * Set platform language - * @param Integer The language id + * @param int The language id * @return bool */ public static function set_platform_language($language_id) diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php index 003eb911f3..2daf2b6c25 100755 --- a/main/inc/lib/system_announcements.lib.php +++ b/main/inc/lib/system_announcements.lib.php @@ -6,9 +6,9 @@ */ class SystemAnnouncementManager { - CONST VISIBLE_GUEST = 1; - CONST VISIBLE_STUDENT = 2; - CONST VISIBLE_TEACHER = 3; + const VISIBLE_GUEST = 1; + const VISIBLE_STUDENT = 2; + const VISIBLE_TEACHER = 3; /** * Displays all announcements @@ -38,13 +38,13 @@ class SystemAnnouncementManager (('$now' BETWEEN date_start AND date_end) OR date_end='0000-00-00') "; switch ($visible) { - case self::VISIBLE_GUEST : + case self::VISIBLE_GUEST: $sql .= " AND visible_guest = 1 "; break; - case self::VISIBLE_STUDENT : + case self::VISIBLE_STUDENT: $sql .= " AND visible_student = 1 "; break; - case self::VISIBLE_TEACHER : + case self::VISIBLE_TEACHER: $sql .= " AND visible_teacher = 1 "; break; } @@ -160,9 +160,6 @@ class SystemAnnouncementManager $announcements = Database::query($sql); $content = ''; if (Database::num_rows($announcements) > 0) { - $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); - $query_string = ereg_replace('&$', '', $query_string); - $url = api_get_self(); $content .= '