index.php 18 KB

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