These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* For licensing terms, see /license.txt */ |
||
3 | |||
4 | header('Location: web/app_dev.php'); |
||
5 | exit; |
||
6 | |||
7 | /** |
||
8 | * @package chamilo.main |
||
9 | */ |
||
10 | |||
11 | use \ChamiloSession as Session; |
||
12 | |||
13 | define('CHAMILO_HOMEPAGE', true); |
||
14 | |||
15 | /* Flag forcing the 'current course' reset, as we're not inside a course anymore. */ |
||
16 | // Maybe we should change this into an api function? an example: CourseManager::unset(); |
||
17 | $cidReset = true; |
||
18 | |||
19 | require_once 'main/inc/global.inc.php'; |
||
20 | require_once 'main/chat/chat_functions.lib.php'; |
||
21 | //require_once 'main/auth/external_login/facebook.inc.php'; |
||
22 | |||
23 | // The section (for the tabs). |
||
24 | $this_section = SECTION_CAMPUS; |
||
25 | |||
26 | $header_title = null; |
||
27 | if (!api_is_anonymous()) { |
||
28 | $header_title = " "; |
||
29 | } |
||
30 | |||
31 | // Facebook connexion, if activated |
||
32 | /*if (api_is_facebook_auth_activated() && !api_get_user_id()) { |
||
33 | facebookConnect(); |
||
34 | } |
||
35 | */ |
||
36 | $controller = new IndexManager($header_title); |
||
37 | |||
38 | //Actions |
||
39 | $loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed); |
||
40 | |||
41 | if (!empty($_GET['logout'])) { |
||
42 | $redirect = !empty($_GET['no_redirect']) ? false : true; |
||
43 | $controller->logout($redirect); |
||
44 | } |
||
45 | |||
46 | |||
47 | /* Table definitions */ |
||
48 | |||
49 | /* Constants and CONFIGURATION parameters */ |
||
50 | /** @todo these configuration settings should move to the Chamilo config settings. */ |
||
51 | |||
52 | /** Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world. */ |
||
53 | $_setting['display_courses_to_anonymous_users'] = 'true'; |
||
54 | |||
55 | /* LOGIN */ |
||
56 | |||
57 | /** |
||
58 | * Registers in the track_e_default table (view in important activities in admin |
||
59 | * interface) a possible attempted break in, sending auth data through get. |
||
60 | * @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled. The real use of this code block should be seriously considered as well. This form should just use a security token and get done with it. |
||
61 | */ |
||
62 | if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) { |
||
63 | $i = api_get_anonymous_id(); |
||
64 | Event::addEvent( |
||
65 | LOG_ATTEMPTED_FORCED_LOGIN, |
||
66 | 'tried_hacking_get', |
||
67 | $_SERVER['REMOTE_ADDR'].(empty($_POST['login'])?'':'/'.$_POST['login']), |
||
68 | null, |
||
69 | $i |
||
70 | ); |
||
71 | echo 'Attempted breakin - sysadmins notified.'; |
||
72 | session_destroy(); |
||
73 | die(); |
||
74 | } |
||
75 | |||
76 | // Delete session item necessary to check for legal terms |
||
77 | if (api_get_setting('registration.allow_terms_conditions') == 'true') { |
||
78 | Session::erase('term_and_condition'); |
||
79 | } |
||
80 | //If we are not logged in and customapages activated |
||
81 | if (!api_get_user_id() && CustomPages::enabled()) { |
||
82 | if (Request::get('loggedout')) { |
||
83 | CustomPages::display(CustomPages::LOGGED_OUT); |
||
84 | } else { |
||
85 | CustomPages::display(CustomPages::INDEX_UNLOGGED); |
||
86 | } |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled. |
||
91 | * @todo Check if this code is used. I think this code is never executed because after clicking the submit button |
||
92 | * the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending |
||
93 | * on api_get_setting('page_after_login'). |
||
94 | */ |
||
95 | |||
96 | if (!empty($_POST['submitAuth'])) { |
||
97 | // The user has been already authenticated, we are now to find the last login of the user. |
||
98 | if (isset ($_user['user_id'])) { |
||
99 | $track_login_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
||
100 | $sql_last_login = "SELECT UNIX_TIMESTAMP(login_date) |
||
101 | FROM $track_login_table |
||
102 | WHERE login_user_id = '".$_user['user_id']."' |
||
103 | ORDER BY login_date DESC LIMIT 1"; |
||
104 | $result_last_login = Database::query($sql_last_login); |
||
105 | if (!$result_last_login) { |
||
106 | if (Database::num_rows($result_last_login) > 0) { |
||
107 | $user_last_login_datetime = Database::fetch_array($result_last_login); |
||
108 | $user_last_login_datetime = $user_last_login_datetime[0]; |
||
109 | Session::write('user_last_login_datetime',$user_last_login_datetime); |
||
110 | } |
||
111 | } |
||
112 | //Event::event_login(); |
||
113 | } |
||
114 | // End login -- if ($_POST['submitAuth']) |
||
115 | } else { |
||
116 | // Only if login form was not sent because if the form is sent the user was already on the page. |
||
117 | Event::event_open(); |
||
118 | } |
||
119 | |||
120 | if (api_get_setting('display_categories_on_homepage') == 'true') { |
||
121 | $controller->tpl->assign('course_category_block', $controller->return_courses_in_categories()); |
||
0 ignored issues
–
show
|
|||
122 | } |
||
123 | |||
124 | $controller->set_login_form(); |
||
125 | |||
126 | //@todo move this inside the IndexManager |
||
127 | if (!api_is_anonymous()) { |
||
128 | $controller->tpl->assign('profile_block', $controller->return_profile_block()); |
||
0 ignored issues
–
show
|
|||
129 | $controller->tpl->assign('user_image_block', $controller->return_user_image_block()); |
||
0 ignored issues
–
show
|
|||
130 | |||
131 | if (api_is_platform_admin()) { |
||
132 | $controller->tpl->assign('course_block', $controller->return_course_block()); |
||
0 ignored issues
–
show
|
|||
133 | } else { |
||
134 | $controller->tpl->assign('teacher_block', $controller->return_teacher_link()); |
||
0 ignored issues
–
show
|
|||
135 | } |
||
136 | } |
||
137 | |||
138 | $hot_courses = null; |
||
139 | $announcements_block = null; |
||
140 | |||
141 | |||
142 | // Display the Site Use Cookie Warning Validation |
||
143 | $useCookieValidation = api_get_setting('platform.cookie_warning'); |
||
144 | View Code Duplication | if ($useCookieValidation === 'true') { |
|
145 | if (isset($_POST['acceptCookies'])) { |
||
146 | api_set_site_use_cookie_warning_cookie(); |
||
147 | } else if (!api_site_use_cookie_warning_cookie_exist()) { |
||
148 | if (Template::isToolBarDisplayedForUser()) { |
||
149 | $controller->tpl->assign('toolBarDisplayed', true); |
||
0 ignored issues
–
show
|
|||
150 | } else { |
||
151 | $controller->tpl->assign('toolBarDisplayed', false); |
||
0 ignored issues
–
show
|
|||
152 | } |
||
153 | $controller->tpl->assign('displayCookieUsageWarning', true); |
||
0 ignored issues
–
show
|
|||
154 | } |
||
155 | } |
||
156 | |||
157 | // When loading a chamilo page do not include the hot courses and news |
||
158 | |||
159 | if (!isset($_REQUEST['include'])) { |
||
160 | if (api_get_setting('display.show_hot_courses') == 'true') { |
||
161 | $hot_courses = $controller->return_hot_courses(); |
||
162 | } |
||
163 | $announcements_block = $controller->return_announcements(); |
||
164 | } |
||
165 | |||
166 | $controller->tpl->assign('hot_courses', $hot_courses); |
||
0 ignored issues
–
show
|
|||
167 | $controller->tpl->assign('announcements_block', $announcements_block); |
||
0 ignored issues
–
show
|
|||
168 | $controller->tpl->assign('home_page_block', $controller->return_home_page()); |
||
0 ignored issues
–
show
|
|||
169 | $controller->tpl->assign('navigation_course_links', $controller->return_navigation_links()); |
||
0 ignored issues
–
show
|
|||
170 | $controller->tpl->assign('notice_block', $controller->return_notice()); |
||
0 ignored issues
–
show
|
|||
171 | $controller->tpl->assign('main_navigation_block', $controller->return_navigation_links()); |
||
0 ignored issues
–
show
|
|||
172 | $controller->tpl->assign('help_block', $controller->return_help()); |
||
0 ignored issues
–
show
|
|||
173 | |||
174 | if (api_is_platform_admin() || api_is_drh()) { |
||
175 | $controller->tpl->assign('skills_block', $controller->return_skills_links()); |
||
0 ignored issues
–
show
|
|||
176 | } |
||
177 | |||
178 | if (api_is_anonymous()) { |
||
179 | $controller->tpl->setLoginBodyClass(); |
||
0 ignored issues
–
show
|
|||
180 | } |
||
181 | |||
182 | // direct login to course |
||
183 | if (isset($_GET['firstpage'])) { |
||
184 | api_set_firstpage_parameter($_GET['firstpage']); |
||
185 | // if we are already logged, go directly to course |
||
186 | if (api_user_is_login()) { |
||
187 | echo "<script type='text/javascript'>self.location.href='index.php?firstpage=".Security::remove_XSS($_GET['firstpage'])."'</script>"; |
||
188 | } |
||
189 | } else { |
||
190 | api_delete_firstpage_parameter(); |
||
191 | } |
||
192 | |||
193 | $controller->tpl->display_two_col_template(); |
||
0 ignored issues
–
show
|
|||
194 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.