diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 0570fa2030..74aa339e48 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -5,7 +5,7 @@ build: override: - php-scrutinizer-run resources: - cpus: 2 + cpus: 1 environment: php: ini: diff --git a/main/inc/ajax/agenda.ajax.php b/main/inc/ajax/agenda.ajax.php index fc2a274c7c..390623f605 100755 --- a/main/inc/ajax/agenda.ajax.php +++ b/main/inc/ajax/agenda.ajax.php @@ -120,7 +120,7 @@ switch ($action) { $DaysShort = api_get_week_days_short(); $MonthsLong = api_get_months_long(); - $user_id = intval($_REQUEST['user_id']); + $user_id = (int) $_REQUEST['user_id']; $my_course_list = CourseManager::get_courses_list_by_user_id($user_id, true); if (!is_array($my_course_list)) { // this is for the special case if the user has no courses (otherwise you get an error) diff --git a/main/inc/ajax/chat.ajax.php b/main/inc/ajax/chat.ajax.php index 56a003ea51..028348446f 100755 --- a/main/inc/ajax/chat.ajax.php +++ b/main/inc/ajax/chat.ajax.php @@ -71,7 +71,7 @@ switch ($action) { exit; break; case 'set_status': - $status = isset($_REQUEST['status']) ? intval($_REQUEST['status']) : 0; + $status = isset($_REQUEST['status']) ? (int) $_REQUEST['status'] : 0; $chat->setUserStatus($status); break; case 'create_room': diff --git a/main/inc/ajax/course.ajax.php b/main/inc/ajax/course.ajax.php index faf57e87a4..b753de48c6 100755 --- a/main/inc/ajax/course.ajax.php +++ b/main/inc/ajax/course.ajax.php @@ -276,7 +276,7 @@ switch ($action) { case 'search_exercise_by_course': if (api_is_platform_admin()) { $course = api_get_course_info_by_id($_GET['course_id']); - $session_id = (!empty($_GET['session_id'])) ? intval($_GET['session_id']) : 0; + $session_id = (!empty($_GET['session_id'])) ? (int) $_GET['session_id'] : 0; $exercises = ExerciseLib::get_all_exercises( $course, $session_id, @@ -310,8 +310,8 @@ switch ($action) { $sql_query = sprintf( $sql, - intval($_GET['course_id']), - intval($_GET['session_id']), + (int) $_GET['course_id'], + (int) $_GET['session_id'], '%'.Database::escape_string($_GET['q']).'%' ); $result = Database::query($sql_query); @@ -330,7 +330,7 @@ switch ($action) { } break; case 'display_sessions_courses': - $sessionId = intval($_GET['session']); + $sessionId = (int) $_GET['session']; $userTable = Database::get_main_table(TABLE_MAIN_USER); $coursesData = SessionManager::get_course_list_by_session_id($sessionId); diff --git a/main/inc/ajax/course_chat.ajax.php b/main/inc/ajax/course_chat.ajax.php index ba05cacbe3..4dbf193f89 100644 --- a/main/inc/ajax/course_chat.ajax.php +++ b/main/inc/ajax/course_chat.ajax.php @@ -22,12 +22,12 @@ switch ($_REQUEST['action']) { $courseChatUtils->keepUserAsConnected(); $courseChatUtils->disconnectInactiveUsers(); - $friend = isset($_REQUEST['friend']) ? intval($_REQUEST['friend']) : 0; + $friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0; $filePath = $courseChatUtils->getFileName(true, $friend); $newFileSize = file_exists($filePath) ? filesize($filePath) : 0; - $oldFileSize = isset($_GET['size']) ? intval($_GET['size']) : -1; + $oldFileSize = isset($_GET['size']) ? (int) $_GET['size'] : -1; $newUsersOnline = $courseChatUtils->countUsersOnline(); - $oldUsersOnline = isset($_GET['users_online']) ? intval($_GET['users_online']) : 0; + $oldUsersOnline = isset($_GET['users_online']) ? (int) $_GET['users_online'] : 0; $json = [ 'status' => true, @@ -50,7 +50,7 @@ switch ($_REQUEST['action']) { ]; break; case 'reset': - $friend = isset($_REQUEST['friend']) ? intval($_REQUEST['friend']) : 0; + $friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0; $json = [ 'status' => true, @@ -58,7 +58,7 @@ switch ($_REQUEST['action']) { ]; break; case 'write': - $friend = isset($_REQUEST['friend']) ? intval($_REQUEST['friend']) : 0; + $friend = isset($_REQUEST['friend']) ? (int) $_REQUEST['friend'] : 0; $writed = $courseChatUtils->saveMessage($_POST['message'], $friend); $json = [ diff --git a/main/inc/ajax/course_home.ajax.php b/main/inc/ajax/course_home.ajax.php index 863b597f2a..8cf18d82b4 100755 --- a/main/inc/ajax/course_home.ajax.php +++ b/main/inc/ajax/course_home.ajax.php @@ -174,16 +174,16 @@ switch ($action) { */ require_once __DIR__.'/../global.inc.php'; $now = time(); - $page = intval($_REQUEST['page']); //page - $limit = intval($_REQUEST['rows']); // quantity of rows + $page = (int) $_REQUEST['page']; //page + $limit = (int) $_REQUEST['rows']; // quantity of rows //index to filter $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id'; $sord = $_REQUEST['sord']; //asc or desc if (!in_array($sord, ['asc', 'desc'])) { $sord = 'desc'; } - $session_id = intval($_REQUEST['session_id']); - $course_id = intval($_REQUEST['course_id']); + $session_id = (int) $_REQUEST['session_id']; + $course_id = (int) $_REQUEST['course_id']; //Filter users that does not belong to the session if (!api_is_platform_admin()) { @@ -302,8 +302,8 @@ switch ($action) { case 'session_courses_lp_by_week': require_once __DIR__.'/../global.inc.php'; $now = time(); - $page = intval($_REQUEST['page']); //page - $limit = intval($_REQUEST['rows']); // quantity of rows + $page = (int) $_REQUEST['page']; //page + $limit = (int) $_REQUEST['rows']; // quantity of rows $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'course'; $sidx = str_replace(['week desc,', ' '], '', $sidx); $sord = $_REQUEST['sord']; //asc or desc @@ -311,8 +311,8 @@ switch ($action) { $sord = 'desc'; } - $session_id = intval($_REQUEST['session_id']); - $course_id = intval($_REQUEST['course_id']); + $session_id = (int) $_REQUEST['session_id']; + $course_id = (int) $_REQUEST['course_id']; //Filter users that does not belong to the session if (!api_is_platform_admin()) { @@ -445,8 +445,8 @@ switch ($action) { case 'session_courses_lp_by_course': require_once __DIR__.'/../global.inc.php'; $now = time(); - $page = intval($_REQUEST['page']); //page - $limit = intval($_REQUEST['rows']); // quantity of rows + $page = (int) $_REQUEST['page']; //page + $limit = (int) $_REQUEST['rows']; // quantity of rows $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id'; $sidx = str_replace(['course asc,', ' '], '', $sidx); @@ -454,8 +454,8 @@ switch ($action) { if (!in_array($sord, ['asc', 'desc'])) { $sord = 'desc'; } - $session_id = intval($_REQUEST['session_id']); - $course_id = intval($_REQUEST['course_id']); + $session_id = (int) $_REQUEST['session_id']; + $course_id = (int) $_REQUEST['course_id']; //Filter users that does not belong to the session if (!api_is_platform_admin()) { diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index a3b8ce2533..c255dcf23a 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -281,7 +281,7 @@ switch ($action) { exit; } $userId = api_get_user_id(); - $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0; + $sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0; $courseCodeList = []; $userIdList = []; $sessionIdList = []; @@ -1576,9 +1576,9 @@ switch ($action) { */ break; case 'get_exercise_progress': - $sessionId = intval($_GET['session_id']); - $courseId = intval($_GET['course_id']); - $exerciseId = intval($_GET['exercise_id']); + $sessionId = (int) $_GET['session_id']; + $courseId = (int) $_GET['course_id']; + $exerciseId = (int) $_GET['exercise_id']; $date_from = $_GET['date_from']; $date_to = $_GET['date_to']; @@ -1613,8 +1613,8 @@ switch ($action) { case 'get_session_lp_progress': $sessionId = 0; if (!empty($_GET['session_id']) && !empty($_GET['course_id'])) { - $sessionId = intval($_GET['session_id']); - $courseId = intval($_GET['course_id']); + $sessionId = (int) $_GET['session_id']; + $courseId = (int) $_GET['course_id']; $course = api_get_course_info_by_id($courseId); } diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index c55741e4b0..b3c73b6764 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -331,7 +331,7 @@ class UserManager // value of 0000... if (api_get_setting('account_valid_duration') != '') { $expirationDate = new DateTime($currentDate); - $days = intval(api_get_setting('account_valid_duration')); + $days = (int) api_get_setting('account_valid_duration'); $expirationDate->modify('+'.$days.' day'); } } else { @@ -1639,8 +1639,8 @@ class UserManager } if (is_numeric($limit_from) && is_numeric($limit_from)) { - $limit_from = intval($limit_from); - $limit_to = intval($limit_to); + $limit_from = (int) $limit_from; + $limit_to = (int) $limit_to; $sql .= " LIMIT $limit_from, $limit_to"; } $sql_result = Database::query($sql); @@ -2379,7 +2379,7 @@ class UserManager $sqlf .= " AND visible_to_self = 1 "; } if (!is_null($field_filter)) { - $field_filter = intval($field_filter); + $field_filter = (int) $field_filter; $sqlf .= " AND filter = $field_filter "; } $sqlf .= " ORDER BY ".$columns[$column]." $sort_direction "; @@ -3928,8 +3928,8 @@ class UserManager // database table definition $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); $table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG); - $field_id = intval($field_id); - $limit = intval($limit); + $field_id = (int) $field_id; + $limit = (int) $limit; // all the information of the field $sql = "SELECT count(*) count, tag FROM $table_user_tag_values uv INNER JOIN $table_user_tag ut @@ -3962,8 +3962,8 @@ class UserManager // database table definition $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); $table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG); - $field_id = intval($field_id); - $user_id = intval($user_id); + $field_id = (int) $field_id; + $user_id = (int) $user_id; // all the information of the field $sql = "SELECT ut.id, tag, count @@ -3997,8 +3997,8 @@ class UserManager // database table definition $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); $table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG); - $field_id = intval($field_id); - $user_id = intval($user_id); + $field_id = (int) $field_id; + $user_id = (int) $user_id; // all the information of the field $sql = "SELECT ut.id, tag,count FROM $table_user_tag ut @@ -4045,7 +4045,7 @@ class UserManager { $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); $tag = Database::escape_string($tag); - $field_id = intval($field_id); + $field_id = (int) $field_id; //with COLLATE latin1_bin to select query in a case sensitive mode $sql = "SELECT id FROM $table_user_tag WHERE tag LIKE '$tag' AND field_id = $field_id"; @@ -4070,8 +4070,8 @@ class UserManager public static function get_tag_id_from_id($tag_id, $field_id) { $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); - $tag_id = intval($tag_id); - $field_id = intval($field_id); + $tag_id = (int) $tag_id; + $field_id = (int) $field_id; $sql = "SELECT id FROM $table_user_tag WHERE id = '$tag_id' AND field_id = $field_id"; $result = Database::query($sql); @@ -4101,8 +4101,8 @@ class UserManager $table_user_tag = Database::get_main_table(TABLE_MAIN_TAG); $table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG); $tag = trim(Database::escape_string($tag)); - $user_id = intval($user_id); - $field_id = intval($field_id); + $user_id = (int) $user_id; + $field_id = (int) $field_id; $tag_id = self::get_tag_id($tag, $field_id); @@ -4525,9 +4525,9 @@ class UserManager { $tbl_my_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER); - $friend_id = intval($friend_id); - $my_user_id = intval($my_user_id); - $relation_type = intval($relation_type); + $friend_id = (int) $friend_id; + $my_user_id = (int) $my_user_id; + $relation_type = (int) $relation_type; $sql = 'SELECT COUNT(*) as count FROM '.$tbl_my_friend.' WHERE @@ -4590,7 +4590,7 @@ class UserManager ) { $tbl_my_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER); $tbl_my_message = Database::get_main_table(TABLE_MESSAGE); - $friend_id = intval($friend_id); + $friend_id = (int) $friend_id; if ($real_removed) { $extra_condition = ''; @@ -4651,13 +4651,13 @@ class UserManager $tblUser = Database::get_main_table(TABLE_MAIN_USER); $tblUserRelUser = Database::get_main_table(TABLE_MAIN_USER_REL_USER); $tblUserRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $userId = intval($userId); + $userId = (int) $userId; $orderBy = null; if (api_is_western_name_order()) { - $orderBy .= " ORDER BY firstname, lastname "; + $orderBy .= ' ORDER BY firstname, lastname '; } else { - $orderBy .= " ORDER BY lastname, firstname "; + $orderBy .= ' ORDER BY lastname, firstname '; } $sql = "SELECT u.id, username, u.firstname, u.lastname @@ -4765,12 +4765,12 @@ class UserManager $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); - $userId = intval($userId); + $userId = (int) $userId; $limitCondition = ''; if (isset($from) && isset($numberItems)) { - $from = intval($from); - $numberItems = intval($numberItems); + $from = (int) $from; + $numberItems = (int) $numberItems; $limitCondition = "LIMIT $from, $numberItems"; }