index.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <?php // $Id: index.php 22269 2009-07-21 15:06:15Z juliomontoya $
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Index of the admin tools
  5. *
  6. * @package chamilo.admin
  7. */
  8. // name of the language file that needs to be included <br />
  9. $language_file=array('admin','tracking');
  10. // resetting the course id
  11. $cidReset=true;
  12. // including some necessary chamilo files
  13. require_once '../inc/global.inc.php';
  14. require_once api_get_path(LIBRARY_PATH).'security.lib.php';
  15. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  16. require_once api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php';
  17. require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
  18. // setting the section (for the tabs)
  19. $this_section=SECTION_PLATFORM_ADMIN;
  20. // Access restrictions
  21. api_protect_admin_script(true);
  22. $nameTools = get_lang('PlatformAdmin');
  23. // setting breadcrumbs
  24. //$interbreadcrumb[] = array('url' => 'index.php', 'name' => $nameTools);
  25. // setting the name of the tool
  26. $tool_name=get_lang('PlatformAdmin');
  27. // Displaying the header
  28. Display::display_header($nameTools);
  29. if(api_is_platform_admin()) {
  30. if(is_dir(api_get_path(SYS_CODE_PATH).'install/') && is_readable(api_get_path(SYS_CODE_PATH).'install/index.php'))
  31. {
  32. Display::display_normal_message(get_lang('InstallDirAccessibleSecurityThreat'));
  33. }
  34. /*
  35. ACTION HANDLING
  36. */
  37. if (!empty($_POST['Register']))
  38. {
  39. register_site();
  40. Display :: display_confirmation_message(get_lang('VersionCheckEnabled'));
  41. }
  42. /*
  43. MAIN SECTION
  44. */
  45. $keyword_url = Security::remove_XSS((empty($_GET['keyword'])?'':$_GET['keyword']));
  46. }
  47. if (api_is_platform_admin()) {
  48. ?>
  49. <div class="admin_section">
  50. <h4><?php Display::display_icon('members.gif', get_lang('Users')); ?> <?php echo api_ucfirst(get_lang('Users')); ?></h4>
  51. <div style="list-style-type:none"><form method="get" action="user_list.php">
  52. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  53. <button class="search" type="submit"> <?php echo get_lang('Search');?>
  54. </button>
  55. </form>
  56. </div>
  57. <ul>
  58. <!-- <li><a href="user_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a></li> -->
  59. <li><a href="user_list.php"> <?php echo get_lang('UserList') ?></a></li>
  60. <li><a href="user_add.php"> <?php echo get_lang('AddUsers') ?></a></li>
  61. <li><a href="user_export.php"> <?php echo get_lang('ExportUserListXMLCSV') ?></a></li>
  62. <li><a href="user_import.php"> <?php echo get_lang('ImportUserListXMLCSV') ?></a></li>
  63. <?php if (api_get_setting('allow_social_tool')=='true') { ?>
  64. <li><a href="group_add.php"> <?php echo get_lang('AddGroups') ?></a></li>
  65. <li><a href="group_list.php"> <?php echo get_lang('GroupList') ?></a></li>
  66. <?php
  67. }
  68. if(isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap'])>0){
  69. ?>
  70. <!-- dynamic ldap code -->
  71. <li><a href="ldap_users_list.php"><?php echo get_lang('ImportLDAPUsersIntoPlatform');?></a></li>
  72. <!-- dynamic ldap code -->
  73. <?php
  74. }
  75. ?>
  76. <li><a href="user_fields.php"> <?php echo get_lang('ManageUserFields'); ?></a></li>
  77. </ul>
  78. </div>
  79. <?php
  80. } else {
  81. ?>
  82. <div class="admin_section">
  83. <h4><?php Display::display_icon('members.gif', get_lang('Users')); ?> <?php echo api_ucfirst(get_lang('Users')); ?></h4>
  84. <ul>
  85. <li><a href="user_list.php"> <?php echo get_lang('UserList') ?></a></li>
  86. <li><a href="../mySpace/user_add.php"><?php echo get_lang('AddUsers') ?></a></li>
  87. <li><a href="user_import.php"> <?php echo get_lang('ImportUserListXMLCSV') ?></a></li>
  88. </ul>
  89. </div>
  90. <?php
  91. }
  92. //Advance search link moved
  93. /* <li><a href="course_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a></li> */
  94. if(api_is_platform_admin()) {
  95. ?>
  96. <div class="admin_section">
  97. <h4><?php Display::display_icon('course.gif', get_lang('Courses')); ?> <?php echo api_ucfirst(get_lang('Courses')); ?></h4>
  98. <div style="list-style-type:none">
  99. <form method="get" action="course_list.php">
  100. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  101. <button class="search" type="submit"> <?php echo get_lang('Search');?></button>
  102. </form>
  103. </div>
  104. <ul>
  105. <li><a href="course_list.php"><?php echo get_lang('CourseList') ?></a></li>
  106. <li><a href="course_add.php"><?php echo get_lang('AddCourse') ?></a></li>
  107. <li><a href="course_export.php"><?php echo get_lang('ExportCourses'); ?></a></li>
  108. <li><a href="course_import.php"><?php echo get_lang('ImportCourses'); ?></a></li>
  109. <!-- <li><a href="course_virtual.php"><?php //echo get_lang('AdminManageVirtualCourses') ?></a></li> -->
  110. <li><a href="course_category.php"><?php echo get_lang('AdminCategories'); ?></a></li>
  111. <li><a href="subscribe_user2course.php"><?php echo get_lang('AddUsersToACourse'); ?></a></li>
  112. <li><a href="course_user_import.php"><?php echo get_lang('ImportUsersToACourse'); ?></a></li>
  113. <?php if (api_get_setting('search_enabled')=='true') { ?>
  114. <li><a href="specific_fields.php"><?php echo get_lang('SpecificSearchFields'); ?></a></li>
  115. <?php } ?>
  116. <?php
  117. if(isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap'])>0){
  118. ?>
  119. <!-- dynamic ldap code -->
  120. <li><a href="ldap_import_students.php"><?php echo get_lang('ImportLDAPUsersIntoCourse');?></a></li>
  121. <!-- dynamic ldap code -->
  122. <?php
  123. }
  124. ?>
  125. </ul>
  126. </div>
  127. <div class="admin_section">
  128. <h4><?php Display::display_icon('settings.gif', get_lang('Platform')); ?> <?php echo api_ucfirst(get_lang('Platform')); ?></h4>
  129. <ul>
  130. <li><a href="settings.php"><?php echo get_lang('DokeosConfigSettings') ?></a></li>
  131. <li><a href="special_exports.php"><?php echo get_lang('SpecialExports') ?></a></li>
  132. <li><a href="system_announcements.php"><?php echo get_lang('SystemAnnouncements') ?></a></li>
  133. <li><a href="languages.php"><?php echo get_lang('Languages'); ?></a></li>
  134. <li><a href="configure_homepage.php"><?php echo get_lang('ConfigureHomePage'); ?></a></li>
  135. <li><a href="configure_inscription.php"><?php echo get_lang('ConfigureInscription'); ?></a></li>
  136. <li><a href="statistics/index.php"><?php echo get_lang('Statistics'); ?> </a></li>
  137. <li><a href="calendar.php"><?php echo get_lang('GlobalAgenda'); ?> </a></li>
  138. <?php if(!empty($phpMyAdminPath)) { ?>
  139. <li><a href="<?php echo $phpMyAdminPath; ?>" target="_blank"><?php echo get_lang("AdminDatabases"); ?></a><br />(<?php echo get_lang("DBManagementOnlyForServerAdmin"); ?>)</li>
  140. <?php } ?>
  141. <?php
  142. if(!empty($_configuration['multiple_access_urls'])) {
  143. if (api_is_global_platform_admin()) {
  144. echo '<li><a href="access_urls.php">'.get_lang('ConfigureMultipleAccessURLs').'</a></li>';
  145. }
  146. }
  147. if (api_get_setting('allow_reservation')=='true') {
  148. echo '<li><a href="../reservation/m_category.php">'.get_lang('BookingSystem').'</a></li>';
  149. }
  150. if (api_get_setting('allow_terms_conditions')=='true') {
  151. echo '<li><a href="legal_add.php">'.get_lang('TermsAndConditions').'</a></li>';
  152. }
  153. //@todo Translations needed in order to see a better explanation of issues
  154. echo '<li><a href="system_status.php">'.get_lang('SystemStatus').'</a></li>';
  155. if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
  156. //do not show on production portals, where the tests directory doesn't exist
  157. echo '<li><a href="filler.php">'.get_lang('DataFiller').'</a></li>';
  158. }
  159. ?>
  160. </ul>
  161. </div>
  162. <?php
  163. }
  164. if(api_get_setting('use_session_mode')=='true') {
  165. ?>
  166. <div class="admin_section">
  167. <h4><?php Display::display_icon('blackboard_blue.png', get_lang('Sessions'), array('width'=>'22px')); ?> <?php echo get_lang('Sessions') ?></h4>
  168. <div style="list-style-type:none"><form method="POST" action="session_list.php">
  169. <input type="text" name="keyword_name" value="<?php echo $keyword_url; ?>"/>
  170. <button class="search" type="submit"> <?php echo get_lang('Search');?>
  171. </button>
  172. </form>
  173. </div>
  174. <ul>
  175. <!-- <li><a href="session_list.php?search=advanced"><?php echo api_ucfirst(get_lang('AdvancedSearch')); ?></a></li> -->
  176. <li><a href="session_list.php"><?php echo get_lang('ListSession') ?></a></li>
  177. <li><a href="session_category_list.php"><?php echo get_lang('ListSessionCategory') ?></a></li>
  178. <li><a href="session_add.php"><?php echo get_lang('AddSession') ?></a></li>
  179. <li><a href="session_import.php"><?php echo get_lang('ImportSessionListXMLCSV') ?></a></li>
  180. <?php
  181. if(isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap'])>0){
  182. ?>
  183. <!-- dynamic ldap code -->
  184. <li><a href="ldap_import_students_to_session.php"><?php echo get_lang('ImportLDAPUsersIntoSession');?></a></li>
  185. <!-- dynamic ldap code -->
  186. <?php
  187. }
  188. ?>
  189. <li><a href="session_export.php"><?php echo get_lang('ExportSessionListXMLCSV') ?></a></li>
  190. <li><a href="../coursecopy/copy_course_session.php"><?php echo get_lang('CopyFromCourseInSessionToAnotherSession') ?></a></li>
  191. </ul>
  192. </div>
  193. <?php
  194. } else if(api_is_platform_admin()) {
  195. ?>
  196. <div class="admin_section">
  197. <h4><?php Display::display_icon('group.gif', get_lang('AdminClasses')); ?> <?php echo api_ucfirst(get_lang('AdminClasses')); ?></h4>
  198. <div style="list-style-type:none"><form method="get" action="class_list.php">
  199. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  200. <input class="search" type="submit" value="<?php echo get_lang('Search'); ?>"/>
  201. </form>
  202. </div>
  203. <ul>
  204. <li><a href="class_list.php"><?php echo get_lang('ClassList'); ?></a></li>
  205. <li><a href="class_add.php"><?php echo get_lang('AddClasses'); ?></a></li>
  206. <li><a href="class_import.php"><?php echo get_lang('ImportClassListCSV'); ?></a></li>
  207. <li><a href="class_user_import.php"><?php echo get_lang('AddUsersToAClass'); ?> CSV</a></li>
  208. <li><a href="subscribe_class2course.php"><?php echo get_lang('AddClassesToACourse'); ?></a></li>
  209. </ul>
  210. <br />
  211. <br />
  212. </div>
  213. <?php
  214. }
  215. if (api_is_platform_admin()) {
  216. ?>
  217. <div class="admin_section">
  218. <h4><?php Display::display_icon('visio_meeting.gif', get_lang('ConfigureExtensions')); ?> <?php echo api_ucfirst(get_lang('ConfigureExtensions')); ?></h4>
  219. <ul>
  220. <li><a href="configure_extensions.php?display=visio"><?php echo get_lang('Visioconf'); ?></a></li>
  221. <li><a href="configure_extensions.php?display=ppt2lp"><?php echo get_lang('Ppt2lp'); ?></a></li>
  222. <?php
  223. /* <li><a href="configure_extensions.php?display=ephorus"><?php echo get_lang('EphorusPlagiarismPrevention'); ?></a></li> */
  224. ?>
  225. <li><a href="configure_extensions.php?display=search"><?php echo get_lang('SearchEngine'); ?></a></li>
  226. <li><a href="configure_extensions.php?display=serverstats"><?php echo get_lang('ServerStatistics'); ?></a></li>
  227. <li><a href="configure_extensions.php?display=bandwidthstats"><?php echo get_lang('BandWidthStatistics'); ?></a></li>
  228. </ul>
  229. </div>
  230. <?php
  231. /*if(isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap'])>0){
  232. ?>
  233. <!-- dynamic ldap code -->
  234. <div class="admin_section">
  235. <h4><?php Display::display_icon('members.gif', 'LDAP'); ?> LDAP</h4>
  236. <ul>
  237. <li><a href="ldap_users_list.php"><?php echo get_lang('ImportLDAPUsersIntoPlatform');?></a></li>
  238. <li><a href="ldap_import_students.php"><?php echo get_lang('ImportLDAPUsersIntoCourse');?></a></li>
  239. <li><a href="ldap_import_students_to_session.php"><?php echo get_lang('ImportLDAPUsersIntoSession');?></a></li>
  240. <!--li><a href="ldap_users_synchro.php"><?php echo get_lang('LDAPSynchroImportUsersAndStepsInSessions');?></a></li-->
  241. </ul>
  242. </div>
  243. <!-- dynamic ldap code -->
  244. <?php
  245. }*/
  246. ?>
  247. <div class="admin_section">
  248. <h4><?php Display::display_icon('logo.gif', 'Chamilo'); ?> Chamilo.org</h4>
  249. <ul>
  250. <li><a href="http://www.chamilo.org/" target="_blank"><?php echo get_lang('ChamiloHomepage'); ?></a></li>
  251. <li><a href="http://www.chamilo.org/forum" target="_blank"><?php echo get_lang('ChamiloForum'); ?></a></li>
  252. <li><a href="http://www.chamilo.org/extensions" target="_blank"><?php echo get_lang('ChamiloExtensions'); ?></a></li>
  253. <?php
  254. //try to display a maximum before we check the chamilo version and all that
  255. //session_write_close(); //close session to avoid blocking concurrent access
  256. flush(); //send data to client as much as allowed by the web server
  257. //ob_flush();
  258. echo '<br />'.get_lang('VersionCheck').': '.version_check().'';
  259. ?>
  260. </ul>
  261. </div>
  262. <?php
  263. }
  264. /**
  265. * Displays either the text for the registration or the message that the installation is (not) up to date
  266. *
  267. * @return string html code
  268. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  269. * @version august 2006
  270. * @todo have a 6monthly re-registration
  271. */
  272. function version_check() {
  273. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  274. $sql = 'SELECT selected_value FROM '.$tbl_settings.' WHERE variable="registered" ';
  275. $result = Database::query($sql);
  276. $row=Database::fetch_array($result,'ASSOC');
  277. // The site has not been registered yet
  278. //if (api_get_setting('registered')=='false')
  279. $return = '';
  280. if ($row['selected_value']=='false')
  281. {
  282. $return .= '<form action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
  283. $return .= get_lang('VersionCheckExplanation');
  284. $return .= '<input type="checkbox" name="donotlistcampus" value="1" id="checkbox" />'.get_lang('HideCampusFromPublicDokeosPlatformsList');
  285. $return .= '<button type="submit" class="save" name="Register" value="'.get_lang('EnableVersionCheck').'" id="register" />'.get_lang('EnableVersionCheck').'</button>';
  286. $return .= '</form>';
  287. } else {
  288. // The site has been registered already but is seriously out of date (registration date + 15552000 seconds)
  289. /*
  290. if ((api_get_setting('registered') + 15552000) > mktime())
  291. {
  292. $return = 'It has been a long time since about your campus has been updated on chamilo.org';
  293. $return .= '<form action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
  294. $return .= '<input type="submit" name="Register" value="Enable Version Check" id="register" />';
  295. $return .= '</form>';
  296. }
  297. else
  298. {
  299. */
  300. $return = 'site registered. ';
  301. $return .= check_system_version2();
  302. //}
  303. }
  304. return $return;
  305. }
  306. /**
  307. * This setting changes the registration status for the campus
  308. *
  309. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  310. * @version August 2006
  311. *
  312. * @todo the $_settings should be reloaded here. => write api function for this and use this in global.inc.php also.
  313. */
  314. function register_site()
  315. {
  316. // Database Table Definitions
  317. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  318. // the SQL statment
  319. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'";
  320. $result = Database::query($sql);
  321. //
  322. if ($_POST['donotlistcampus'])
  323. {
  324. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='donotlistcampus'";
  325. $result = Database::query($sql);
  326. }
  327. // reload the settings
  328. }
  329. /**
  330. * Check if the current installation is up to date
  331. * The code is borrowed from phpBB and slighlty modified
  332. * @author The phpBB Group <support@phpbb.com> (the code)
  333. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  334. * @copyright (C) 2001 The phpBB Group
  335. * @return language string with some layout (color)
  336. */
  337. function check_system_version2()
  338. {
  339. global $_configuration;
  340. $system_version = trim($_configuration['system_version']); // the chamilo version of your installation
  341. if (ini_get('allow_url_fopen')==1)
  342. {
  343. // the number of courses
  344. $number_of_courses = statistics::count_courses();
  345. // the number of users
  346. $number_of_users = statistics::count_users();
  347. $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'));
  348. $handle=@fopen($version_url,'r');
  349. if ($handle !== false) {
  350. $version_info=trim(@fread($handle, 1024));
  351. if ($system_version <> $version_info) {
  352. $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>';
  353. } else {
  354. $output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>';
  355. }
  356. } else {
  357. $output = '<span style="color:red">' . get_lang('ImpossibleToContactVersionServerPleaseTryAgain') . '</span>';
  358. }
  359. }
  360. else
  361. {
  362. $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>';
  363. }
  364. return $output;
  365. }
  366. /**
  367. * Check if the current installation is up to date
  368. * The code is borrowed from phpBB and slighlty modified
  369. * @author The phpBB Group <support@phpbb.com> (the code)
  370. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  371. * @copyright (C) 2001 The phpBB Group
  372. * @return language string with some layout (color)
  373. * @deprecated For some reason this code adds a 9 in front and a 0 at the end of what normally gets displayed by
  374. the http://www.dokeos.com/version.php page (instead of version.txt) . That's why I chose to use fopen which requires however
  375. that allow_url_open is set to true
  376. */
  377. function check_system_version()
  378. {
  379. global $_configuration; // the chamilo version of your installation
  380. $system_version = $_configuration['system_version'];
  381. if ($fsock = @fsockopen('www.chamilo.org', 80, $errno, $errstr))
  382. {
  383. @fputs($fsock, "GET /version.php HTTP/1.1\r\n");
  384. @fputs($fsock, "HOST: www.chamilo.org\r\n");
  385. @fputs($fsock, "Connection: close\r\n\r\n");
  386. $get_info = false;
  387. while (!@feof($fsock))
  388. {
  389. if ($get_info)
  390. {
  391. $version_info .= @fread($fsock, 1024);
  392. }
  393. else
  394. {
  395. if (@fgets($fsock, 1024) == "\r\n")
  396. {
  397. $get_info = true;
  398. }
  399. }
  400. }
  401. @fclose($fsock);
  402. if (trim($system_version) <> trim($version_info)) {
  403. $output='<span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. '.get_lang('LatestVersionIs').' <b>Chamilo '.$version_info.'</b>. '.get_lang('YourVersionIs').' <b>Dokeos '.$system_version. '</b>. '.str_replace('http://www.chamilo.org','<a href="http://www.chamilo.org">http://www.chamilo.org</a>',get_lang('PleaseVisitDokeos')).'</span>';
  404. } else {
  405. $output = '<span style="color:green">'.get_lang('VersionUpToDate').': Chamilo '.$version_info.'</span>';
  406. }
  407. }
  408. else
  409. {
  410. if ($errstr)
  411. {
  412. $output = '<span style="color:red">' . get_lang('ConnectSocketError') . ': '. $errstr . '</span>';
  413. }
  414. else
  415. {
  416. $output = '<span>' . get_lang('SocketFunctionsDisabled') . '</span>';
  417. }
  418. }
  419. return $output;
  420. }
  421. /*
  422. FOOTER
  423. */
  424. Display::display_footer();
  425. ?>