index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Index page of the admin tools
  5. * @package chamilo.admin
  6. */
  7. // Language files that need to be included.
  8. $language_file = array('admin', 'tracking');
  9. // Resetting the course id.
  10. $cidReset = true;
  11. // Including some necessary chamilo files.
  12. require_once '../inc/global.inc.php';
  13. require_once api_get_path(LIBRARY_PATH).'security.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  15. require_once api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php';
  16. require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
  17. // Setting the section (for the tabs).
  18. $this_section = SECTION_PLATFORM_ADMIN;
  19. // Access restrictions.
  20. api_protect_admin_script(true);
  21. $nameTools = get_lang('PlatformAdmin');
  22. // Setting breadcrumbs.
  23. //$interbreadcrumb[] = array('url' => 'index.php', 'name' => $nameTools);
  24. // Setting the name of the tool.
  25. $tool_name = get_lang('PlatformAdmin');
  26. // Displaying the header
  27. Display::display_header($nameTools);
  28. if (api_is_platform_admin()) {
  29. if (is_dir(api_get_path(SYS_CODE_PATH).'install/') && is_readable(api_get_path(SYS_CODE_PATH).'install/index.php')) {
  30. Display::display_warning_message(get_lang('InstallDirAccessibleSecurityThreat'));
  31. }
  32. /* ACTION HANDLING */
  33. if (!empty($_POST['Register'])) {
  34. register_site();
  35. Display :: display_confirmation_message(get_lang('VersionCheckEnabled'));
  36. }
  37. /* MAIN SECTION */
  38. $keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
  39. }
  40. if (api_is_platform_admin()) {
  41. ?>
  42. <div class="admin_section">
  43. <h4><?php Display::display_icon('members.gif', get_lang('Users')); ?> <?php echo api_ucfirst(get_lang('Users')); ?></h4>
  44. <div style="list-style-type:none">
  45. <form method="get" action="user_list.php">
  46. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  47. <button class="search" type="submit"> <?php echo get_lang('Search'); ?></button>
  48. </form>
  49. </div>
  50. <ul>
  51. <li><a href="user_list.php"><?php echo get_lang('UserList'); ?></a></li>
  52. <li><a href="user_add.php"><?php echo get_lang('AddUsers'); ?></a></li>
  53. <li><a href="user_export.php"><?php echo get_lang('ExportUserListXMLCSV'); ?></a></li>
  54. <li><a href="user_import.php"><?php echo get_lang('ImportUserListXMLCSV'); ?></a></li>
  55. <?php if (api_get_setting('allow_social_tool') == 'true') { ?>
  56. <li><a href="group_add.php"><?php echo get_lang('AddGroups'); ?></a></li>
  57. <li><a href="group_list.php"><?php echo get_lang('GroupList'); ?></a></li>
  58. <?php }
  59. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { ?>
  60. <li><a href="ldap_users_list.php"><?php echo get_lang('ImportLDAPUsersIntoPlatform');?></a></li>
  61. <?php } ?>
  62. <li><a href="user_fields.php"><?php echo get_lang('ManageUserFields'); ?></a></li>
  63. </ul>
  64. </div>
  65. <?php } else { ?>
  66. <div class="admin_section">
  67. <h4><?php Display::display_icon('members.gif', get_lang('Users')); ?> <?php echo api_ucfirst(get_lang('Users')); ?></h4>
  68. <ul>
  69. <li><a href="user_list.php"><?php echo get_lang('UserList'); ?></a></li>
  70. <li><a href="../mySpace/user_add.php"><?php echo get_lang('AddUsers'); ?></a></li>
  71. <li><a href="user_import.php"><?php echo get_lang('ImportUserListXMLCSV'); ?></a></li>
  72. </ul>
  73. </div>
  74. <?php
  75. }
  76. if (api_is_platform_admin()) { ?>
  77. <div class="admin_section">
  78. <h4><?php Display::display_icon('course.gif', get_lang('Courses')); ?> <?php echo api_ucfirst(get_lang('Courses')); ?></h4>
  79. <div style="list-style-type:none">
  80. <form method="get" action="course_list.php">
  81. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  82. <button class="search" type="submit"><?php echo get_lang('Search'); ?></button>
  83. </form>
  84. </div>
  85. <ul>
  86. <li><a href="course_list.php"><?php echo get_lang('CourseList'); ?></a></li>
  87. <?php if (api_get_setting('course_validation') != 'true') { ?>
  88. <li><a href="course_add.php"><?php echo get_lang('AddCourse'); ?></a></li>
  89. <?php } else { ?>
  90. <li><a href="course_request_review.php"><?php echo get_lang('ReviewCourseRequests'); ?></a></li>
  91. <li><a href="course_request_accepted.php"><?php echo get_lang('AcceptedCourseRequests'); ?></a></li>
  92. <li><a href="course_request_rejected.php"><?php echo get_lang('RejectedCourseRequests'); ?></a></li>
  93. <?php } ?>
  94. <li><a href="course_export.php"><?php echo get_lang('ExportCourses'); ?></a></li>
  95. <li><a href="course_import.php"><?php echo get_lang('ImportCourses'); ?></a></li>
  96. <!-- <li><a href="course_virtual.php"><?php //echo get_lang('AdminManageVirtualCourses'); ?></a></li> -->
  97. <li><a href="course_category.php"><?php echo get_lang('AdminCategories'); ?></a></li>
  98. <li><a href="subscribe_user2course.php"><?php echo get_lang('AddUsersToACourse'); ?></a></li>
  99. <li><a href="course_user_import.php"><?php echo get_lang('ImportUsersToACourse'); ?></a></li>
  100. <?php
  101. if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { ?>
  102. <li><a href="ldap_import_students.php"><?php echo get_lang('ImportLDAPUsersIntoCourse'); ?></a></li>
  103. <?php } ?>
  104. </ul>
  105. </div>
  106. <div class="admin_section">
  107. <h4><?php Display::display_icon('settings.png', get_lang('Platform')); ?> <?php echo api_ucfirst(get_lang('Platform')); ?></h4>
  108. <ul>
  109. <li><a href="settings.php"><?php echo get_lang('DokeosConfigSettings') ?></a></li>
  110. <li><a href="special_exports.php"><?php echo get_lang('SpecialExports') ?></a></li>
  111. <li><a href="system_announcements.php"><?php echo get_lang('SystemAnnouncements') ?></a></li>
  112. <li><a href="languages.php"><?php echo get_lang('Languages'); ?></a></li>
  113. <li><a href="configure_homepage.php"><?php echo get_lang('ConfigureHomePage'); ?></a></li>
  114. <li><a href="configure_inscription.php"><?php echo get_lang('ConfigureInscription'); ?></a></li>
  115. <li><a href="statistics/index.php"><?php echo get_lang('Statistics'); ?> </a></li>
  116. <li><a href="calendar.php"><?php echo get_lang('GlobalAgenda'); ?> </a></li>
  117. <?php if (!empty($phpMyAdminPath)) { ?>
  118. <li><a href="<?php echo $phpMyAdminPath; ?>" target="_blank"><?php echo get_lang('AdminDatabases'); ?></a><br />(<?php echo get_lang('DBManagementOnlyForServerAdmin'); ?>)</li>
  119. <?php
  120. }
  121. if (!empty($_configuration['multiple_access_urls'])) {
  122. if (api_is_global_platform_admin()) {
  123. echo '<li><a href="access_urls.php">'.get_lang('ConfigureMultipleAccessURLs').'</a></li>';
  124. }
  125. }
  126. if (api_get_setting('allow_reservation') == 'true') {
  127. echo '<li><a href="../reservation/m_category.php">'.get_lang('BookingSystem').'</a></li>';
  128. }
  129. if (api_get_setting('allow_terms_conditions') == 'true') {
  130. echo '<li><a href="legal_add.php">'.get_lang('TermsAndConditions').'</a></li>';
  131. }
  132. //@todo Translations needed in order to see a better explanation of issues
  133. echo '<li><a href="system_status.php">'.get_lang('SystemStatus').'</a></li>';
  134. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  135. // Do not show on production portals, where the tests directory doesn't exist.
  136. echo '<li><a href="filler.php">'.get_lang('DataFiller').'</a></li>';
  137. }
  138. ?>
  139. </ul>
  140. </div>
  141. <?php
  142. }
  143. if (api_get_setting('use_session_mode') == 'true') { ?>
  144. <div class="admin_section">
  145. <h4><?php Display::display_icon('blackboard_blue.png', get_lang('Sessions'), array('width' => '22px')); ?> <?php echo get_lang('Sessions'); ?></h4>
  146. <div style="list-style-type:none">
  147. <form method="POST" action="session_list.php">
  148. <input type="text" name="keyword_name" value="<?php echo $keyword_url; ?>"/>
  149. <button class="search" type="submit"><?php echo get_lang('Search'); ?></button>
  150. </form>
  151. </div>
  152. <ul>
  153. <li><a href="session_list.php"><?php echo get_lang('ListSession'); ?></a></li>
  154. <li><a href="session_add.php"><?php echo get_lang('AddSession'); ?></a></li>
  155. <li><a href="session_category_list.php"><?php echo get_lang('ListSessionCategory'); ?></a></li>
  156. <li><a href="session_import.php"><?php echo get_lang('ImportSessionListXMLCSV'); ?></a></li>
  157. <?php if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) { ?>
  158. <li><a href="ldap_import_students_to_session.php"><?php echo get_lang('ImportLDAPUsersIntoSession'); ?></a></li>
  159. <?php } ?>
  160. <li><a href="session_export.php"><?php echo get_lang('ExportSessionListXMLCSV'); ?></a></li>
  161. <li><a href="../coursecopy/copy_course_session.php"><?php echo get_lang('CopyFromCourseInSessionToAnotherSession'); ?></a></li>
  162. <?php if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required ?>
  163. <li><a href="user_move_stats.php"><?php echo get_lang('MoveUserStats'); ?></a></li>
  164. <?php }
  165. echo Display::tag('li',Display::url(get_lang('CareersAndPromotions'), 'career_dashboard.php'));
  166. echo Display::tag('li',Display::url(get_lang('Classes'), 'usergroups.php'));
  167. ?>
  168. </ul>
  169. </div>
  170. <?php
  171. } elseif (api_is_platform_admin()) { ?>
  172. <div class="admin_section">
  173. <h4><?php Display::display_icon('group.gif', get_lang('AdminClasses')); ?> <?php echo api_ucfirst(get_lang('AdminClasses')); ?></h4>
  174. <div style="list-style-type:none">
  175. <form method="get" action="class_list.php">
  176. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  177. <input class="search" type="submit" value="<?php echo get_lang('Search'); ?>"/>
  178. </form>
  179. </div>
  180. <ul>
  181. <li><a href="class_list.php"><?php echo get_lang('ClassList'); ?></a></li>
  182. <li><a href="class_add.php"><?php echo get_lang('AddClasses'); ?></a></li>
  183. <li><a href="class_import.php"><?php echo get_lang('ImportClassListCSV'); ?></a></li>
  184. <li><a href="class_user_import.php"><?php echo get_lang('AddUsersToAClass'); ?> CSV</a></li>
  185. <li><a href="subscribe_class2course.php"><?php echo get_lang('AddClassesToACourse'); ?></a></li>
  186. </ul>
  187. <br /><br />
  188. </div>
  189. <?php
  190. }
  191. if (api_is_platform_admin()) {
  192. ?>
  193. <div class="admin_section">
  194. <h4><?php Display::display_icon('visio_meeting.gif', get_lang('ConfigureExtensions')); ?> <?php echo api_ucfirst(get_lang('ConfigureExtensions')); ?></h4>
  195. <ul>
  196. <li><a href="configure_extensions.php?display=visio"><?php echo get_lang('Visioconf'); ?></a></li>
  197. <li><a href="configure_extensions.php?display=ppt2lp"><?php echo get_lang('Ppt2lp'); ?></a></li>
  198. <?php
  199. /* <li><a href="configure_extensions.php?display=ephorus"><?php echo get_lang('EphorusPlagiarismPrevention'); ?></a></li> */
  200. ?>
  201. <li><a href="configure_extensions.php?display=search"><?php echo get_lang('SearchEngine'); ?></a></li>
  202. <li><a href="configure_extensions.php?display=serverstats"><?php echo get_lang('ServerStatistics'); ?></a></li>
  203. <li><a href="configure_extensions.php?display=bandwidthstats"><?php echo get_lang('BandWidthStatistics'); ?></a></li>
  204. </ul>
  205. </div>
  206. <div class="admin_section">
  207. <h4><?php Display::display_icon('logo.gif', 'Chamilo'); ?> Chamilo.org</h4>
  208. <ul>
  209. <li><a href="http://www.chamilo.org/" target="_blank"><?php echo get_lang('ChamiloHomepage'); ?></a></li>
  210. <li><a href="http://www.chamilo.org/forum" target="_blank"><?php echo get_lang('ChamiloForum'); ?></a></li>
  211. <li><a href="../../documentation/installation_guide.html" target="_blank"><?php echo get_lang('InstallationGuide'); ?></a></li>
  212. <li><a href="../../documentation/changelog.html" target="_blank"><?php echo get_lang('ChangesInLastVersion'); ?></a></li>
  213. <li><a href="../../documentation/credits.html" target="_blank"><?php echo get_lang('ContributorsList'); ?></a></li>
  214. <li><a href="../../documentation/security.html" target="_blank"><?php echo get_lang('SecurityGuide'); ?></a></li>
  215. <li><a href="../../documentation/optimization.html" target="_blank"><?php echo get_lang('OptimizationGuide'); ?></a></li>
  216. <li><a href="http://www.chamilo.org/extensions" target="_blank"><?php echo get_lang('ChamiloExtensions'); ?></a></li>
  217. <?php
  218. // Try to display a maximum before we check the chamilo version and all that.
  219. //session_write_close(); //close session to avoid blocking concurrent access
  220. flush(); //send data to client as much as allowed by the web server
  221. //ob_flush();
  222. echo '<br />'.get_lang('VersionCheck').': '.version_check().'';
  223. ?>
  224. </ul>
  225. </div>
  226. <?php
  227. }
  228. /**
  229. * Displays either the text for the registration or the message that the installation is (not) up to date
  230. *
  231. * @return string html code
  232. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  233. * @version august 2006
  234. * @todo have a 6monthly re-registration
  235. */
  236. function version_check() {
  237. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  238. $sql = 'SELECT selected_value FROM '.$tbl_settings.' WHERE variable="registered" ';
  239. $result = Database::query($sql);
  240. $row = Database::fetch_array($result, 'ASSOC');
  241. // The site has not been registered yet.
  242. //if (api_get_setting('registered') == 'false')
  243. $return = '';
  244. if ($row['selected_value'] == 'false') {
  245. $return .= '<form action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
  246. $return .= get_lang('VersionCheckExplanation');
  247. $return .= '<input type="checkbox" name="donotlistcampus" value="1" id="checkbox" />'.get_lang('HideCampusFromPublicDokeosPlatformsList');
  248. $return .= '<button type="submit" class="save" name="Register" value="'.get_lang('EnableVersionCheck').'" id="register" />'.get_lang('EnableVersionCheck').'</button>';
  249. $return .= '</form>';
  250. } else {
  251. // The site has been registered already but is seriously out of date (registration date + 15552000 seconds).
  252. /*
  253. if ((api_get_setting('registered') + 15552000) > mktime()) {
  254. $return = 'It has been a long time since about your campus has been updated on chamilo.org';
  255. $return .= '<form action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
  256. $return .= '<input type="submit" name="Register" value="Enable Version Check" id="register" />';
  257. $return .= '</form>';
  258. } else {
  259. */
  260. $return = 'site registered. ';
  261. $return .= check_system_version();
  262. //}
  263. }
  264. return $return;
  265. }
  266. /**
  267. * This setting changes the registration status for the campus
  268. *
  269. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  270. * @version August 2006
  271. *
  272. * @todo the $_settings should be reloaded here. => write api function for this and use this in global.inc.php also.
  273. */
  274. function register_site() {
  275. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  276. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'";
  277. $result = Database::query($sql);
  278. if ($_POST['donotlistcampus']) {
  279. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='donotlistcampus'";
  280. $result = Database::query($sql);
  281. }
  282. // Reload the settings.
  283. }
  284. /**
  285. * Check if the current installation is up to date
  286. * The code is borrowed from phpBB and slighlty modified
  287. * @author The phpBB Group <support@phpbb.com> (the code)
  288. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  289. * @copyright (C) 2001 The phpBB Group
  290. * @return language string with some layout (color)
  291. */
  292. function check_system_version() {
  293. global $_configuration;
  294. $system_version = trim($_configuration['system_version']); // the chamilo version of your installation
  295. if (ini_get('allow_url_fopen') == 1) {
  296. // The number of courses
  297. $number_of_courses = statistics::count_courses();
  298. // The number of users
  299. $number_of_users = statistics::count_users();
  300. $version_url = 'http://version.chamilo.org/version.php?url='.urlencode(api_get_path(WEB_PATH)).'&campus='.urlencode(api_get_setting('siteName')).'&contact='.urlencode(api_get_setting('emailAdministrator')).'&version='.urlencode($system_version).'&numberofcourses='.urlencode($number_of_courses).'&numberofusers='.urlencode($number_of_users).'&donotlistcampus='.api_get_setting('donotlistcampus').'&organisation='.urlencode(api_get_setting('Institution')).'&adminname='.urlencode(api_get_setting('administratorName').' '.api_get_setting('administratorSurname'));
  301. $handle = @fopen($version_url, 'r');
  302. if ($handle !== false) {
  303. $version_info = trim(@fread($handle, 1024));
  304. if ($system_version != $version_info) {
  305. $output = '<br /><span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Chamilo '.$system_version. '</b>. '.str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('PleaseVisitDokeos')).'</span>';
  306. } else {
  307. $output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>';
  308. }
  309. } else {
  310. $output = '<span style="color:red">' . get_lang('ImpossibleToContactVersionServerPleaseTryAgain') . '</span>';
  311. }
  312. } else {
  313. $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>';
  314. }
  315. return $output;
  316. }
  317. /* FOOTER */
  318. Display::display_footer();