index.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <?php // $Id: index.php 15605 2008-06-19 22:18:32Z yannoo $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 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. if(is_dir(api_get_path(SYS_CODE_PATH).'install/') && is_readable(api_get_path(SYS_CODE_PATH).'install/index.php'))
  46. {
  47. Display::display_normal_message(get_lang('InstallDirAccessibleSecurityThreat'));
  48. }
  49. /*
  50. ==============================================================================
  51. ACTION HANDLING
  52. ==============================================================================
  53. */
  54. if (!empty($_POST['Register']))
  55. {
  56. register_site();
  57. Display :: display_confirmation_message(get_lang('VersionCheckEnabled'));
  58. }
  59. /*
  60. ==============================================================================
  61. MAIN SECTION
  62. ==============================================================================
  63. */
  64. $keyword_url = Security::remove_XSS((empty($_GET['keyword'])?'':$_GET['keyword']));
  65. ?>
  66. <div class="admin_section">
  67. <h4><img src="../img/members.gif" border="0" style="vertical-align: middle;" alt="" /> <?php echo ucfirst(get_lang('Users')); ?></h4>
  68. <ul><li style="list-style-type:none"><form method="get" action="user_list.php">
  69. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  70. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  71. </form></li>
  72. <li>
  73. <a href="user_list.php?search=advanced"><?php echo ucfirst(get_lang('AdvancedSearch')); ?></a>
  74. </li>
  75. <li><a href="user_list.php"><?php echo get_lang('UserList') ?></a></li>
  76. <li><a href="user_add.php"><?php echo get_lang('AddUsers') ?></a></li>
  77. <li><a href="user_export.php"><?php echo get_lang('ExportUserListXMLCSV') ?></a></li>
  78. <li><a href="user_import.php"><?php echo get_lang('ImportUserListXMLCSV') ?></a></li>
  79. <li><a href="user_fields.php"><?php echo get_lang('ManageUserFields'); ?></a></li>
  80. </ul>
  81. </div>
  82. <div class="admin_section">
  83. <h4><img src="../img/course.gif" border="0" style="vertical-align: middle;" alt="" /> <?php echo ucfirst(get_lang('Courses')); ?></h4>
  84. <ul><li style="list-style-type:none"><form method="get" action="course_list.php">
  85. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  86. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  87. </form></li>
  88. <li>
  89. <a href="course_list.php?search=advanced"><?php echo ucfirst(get_lang('AdvancedSearch')); ?></a>
  90. </li>
  91. <li><a href="course_list.php"><?php echo get_lang('CourseList') ?></a></li>
  92. <li><a href="course_add.php"><?php echo get_lang('AddCourse') ?></a></li>
  93. <li><a href="course_import.php"><?php echo get_lang('AddCourse').' CSV'; ?></a></li>
  94. <!--<li><a href="course_virtual.php"><?php //echo get_lang('AdminManageVirtualCourses') ?></a></li>-->
  95. <li><a href="course_category.php"><?php echo get_lang("AdminCategories"); ?></a></li>
  96. <li><a href="subscribe_class2course.php"><?php echo get_lang('AddClassesToACourse'); ?></a></li>
  97. <li><a href="subscribe_user2course.php"><?php echo get_lang('AddUsersToACourse'); ?></a></li>
  98. <li><a href="course_user_import.php"><?php echo get_lang('AddUsersToACourse').' CSV'; ?></a></li>
  99. </ul>
  100. </div>
  101. <div class="admin_section">
  102. <h4>
  103. <img src="../img/settings.gif" border="0" style="vertical-align: middle;" alt="" />
  104. <?php echo ucfirst(get_lang('Platform')); ?>
  105. </h4>
  106. <ul>
  107. <li><a href="settings.php"><?php echo get_lang('DokeosConfigSettings') ?></a></li>
  108. <li><a href="system_announcements.php"><?php echo get_lang('SystemAnnouncements') ?></a></li>
  109. <li><a href="languages.php"><?php echo get_lang('Languages'); ?></a></li>
  110. <li><a href="configure_homepage.php"><?php echo get_lang('ConfigureHomePage'); ?></a></li>
  111. <li><a href="statistics/index.php"><?php echo get_lang('ToolName'); ?> </a></li>
  112. <?php if(!empty($phpMyAdminPath)): ?>
  113. <li><a href="<?php echo $phpMyAdminPath; ?>" target="_blank"><?php echo get_lang("AdminDatabases"); ?></a><br />(<?php echo get_lang("DBManagementOnlyForServerAdmin"); ?>)</li>
  114. <?php endif; ?>
  115. <?php
  116. if(!empty($_configuration['multiple_access_urls']))
  117. {
  118. echo ' <li><a href="access_urls.php">'.get_lang('ConfigureMultipleAccessURLs').'</a></li>';
  119. }
  120. ?>
  121. </ul>
  122. </div>
  123. <?php
  124. endif;
  125. if(api_get_setting('use_session_mode')=='true')
  126. {
  127. ?>
  128. <div class="admin_section">
  129. <h4>
  130. <img src="../img/agenda.gif" border="0" align="absmiddle" alt="" />
  131. <?php echo get_lang('Sessions') ?>
  132. </h4>
  133. <ul>
  134. <li style="list-style-type:none"><form method="POST" action="session_list.php">
  135. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  136. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  137. </form>
  138. </li>
  139. <li><a href="session_list.php"><?php echo get_lang('ListSession') ?></a></li>
  140. <li><a href="session_add.php"><?php echo get_lang('AddSession') ?></a></li>
  141. <li><a href="session_import.php"><?php echo get_lang('ImportSessionListXMLCSV') ?></a></li>
  142. <li><a href="session_export.php"><?php echo get_lang('ExportSessionListXMLCSV') ?></a></li>
  143. </ul>
  144. <br /><br />
  145. </div>
  146. <?php
  147. }
  148. else if(api_is_platform_admin())
  149. {
  150. ?>
  151. <div class="admin_section">
  152. <h4><img src="../img/group.gif" border="0" style="vertical-align: middle;" alt="" /> <?php echo ucfirst(get_lang('AdminClasses')); ?></h4>
  153. <ul>
  154. <li style="list-style-type:none"><form method="get" action="class_list.php">
  155. <input type="text" name="keyword" value="<?php echo $keyword_url; ?>"/>
  156. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  157. </form>
  158. </li>
  159. <li><a href="class_list.php"><?php echo get_lang('ClassList'); ?></a></li>
  160. <li><a href="class_add.php"><?php echo get_lang('AddClasses'); ?></a></li>
  161. <li><a href="class_import.php"><?php echo get_lang('ImportClassListCSV'); ?></a></li>
  162. <li><a href="class_user_import.php"><?php echo get_lang('AddUsersToAClass'); ?> CSV</a></li>
  163. </ul>
  164. <br />
  165. <br />
  166. </div>
  167. <?php
  168. }
  169. ?>
  170. <?php
  171. if(api_is_platform_admin()){
  172. ?>
  173. <div class="admin_section">
  174. <h4>
  175. <img src="../img/visio_meeting.gif" border="0" style="vertical-align: middle;" alt="" />
  176. <?php echo ucfirst(get_lang('ConfigureExtensions')); ?>
  177. </h4>
  178. <ul>
  179. <li><a href="configure_extensions.php?display=visio"><?php echo get_lang('Visioconf'); ?></a></li>
  180. <li><a href="configure_extensions.php?display=ppt2lp"><?php echo get_lang('Ppt2lp'); ?></a></li>
  181. <li><a href="configure_extensions.php?display=ephorus"><?php echo get_lang('EphorusPlagiarismPrevention'); ?></a></li>
  182. <li><a href="configure_extensions.php?display=search"><?php echo get_lang('SearchEngine'); ?></a></li>
  183. <li><a href="configure_extensions.php?display=serverstats"><?php echo get_lang('ServerStatistics'); ?></a></li>
  184. <li><a href="configure_extensions.php?display=bandwidthstats"><?php echo get_lang('BandWidthStatistics'); ?></a></li>
  185. </ul>
  186. </div>
  187. <?php
  188. if(isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap'])>0){
  189. ?>
  190. <!-- dynamic ldap code -->
  191. <div class="admin_section">
  192. <h4><img src="../img/members.gif" border="0" style="vertical-align: middle;" alt="LDAP" />LDAP</h4>
  193. <ul>
  194. <li><a href="ldap_users_list.php"><?php echo get_lang('ImportLDAPUsersIntoPlatform');?></a></li>
  195. <li><a href="ldap_import_students.php"><?php echo get_lang('ImportLDAPUsersIntoCourse');?></a></li>
  196. <li><a href="ldap_import_students_to_session.php"><?php echo get_lang('ImportLDAPUsersIntoSession');?></a></li>
  197. <!--li><a href="ldap_users_synchro.php"><?php echo get_lang('LDAPSynchroImportUsersAndStepsInSessions');?></a></li-->
  198. </ul>
  199. </div>
  200. <!-- dynamic ldap code -->
  201. <?php
  202. }
  203. ?>
  204. <div class="admin_section">
  205. <h4>
  206. <img src="../img/dokeos.gif" border="0" style="vertical-align: middle;" alt="" />
  207. <?php echo "dokeos.com"; ?>
  208. </h4>
  209. <ul>
  210. <li><a href="http://www.dokeos.com/"><?php echo get_lang('DokeosHomepage'); ?></a></li>
  211. <li><a href="http://www.dokeos.com/forum/"><?php echo get_lang('DokeosForum'); ?></a></li>
  212. <li><a href="http://www.dokeos.com/extensions/"><?php echo get_lang('DokeosExtensions'); ?></a></li>
  213. <li>
  214. <?php
  215. //try to display a maximum before we check the dokeos version and all that
  216. //session_write_close(); //close session to avoid blocking concurrent access
  217. flush(); //send data to client as much as allowed by the web server
  218. //ob_flush();
  219. echo get_lang('VersionCheck').': '.version_check();
  220. ?>
  221. </li>
  222. </ul>
  223. </div>
  224. <?php
  225. }
  226. /**
  227. * Displays either the text for the registration or the message that the installation is (not) up to date
  228. *
  229. * @return string html code
  230. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  231. * @version august 2006
  232. * @todo have a 6monthly re-registration
  233. */
  234. function version_check()
  235. {
  236. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  237. $sql = 'SELECT selected_value FROM '.$tbl_settings.' WHERE variable="registered" ';
  238. $result = api_sql_query($sql,__FILE__,__LINE__);
  239. $row=Database::fetch_array($result,'ASSOC');
  240. // The site has not been registered yet
  241. //if (api_get_setting('registered')=='false')
  242. $return = '';
  243. if ($row['selected_value']=='false')
  244. {
  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" /> Do not display my campus in the list of Dokeos platforms';
  248. $return .= '<input type="submit" name="Register" value="Enable Version Check" id="register" />';
  249. $return .= '</form>';
  250. }
  251. else
  252. {
  253. // The site has been registered already but is seriously out of date (registration date + 15552000 seconds)
  254. /*
  255. if ((api_get_setting('registered') + 15552000) > mktime())
  256. {
  257. $return = 'It has been a long time since about your campus has been updated on Dokeos.com';
  258. $return .= '<form action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
  259. $return .= '<input type="submit" name="Register" value="Enable Version Check" id="register" />';
  260. $return .= '</form>';
  261. }
  262. else
  263. {
  264. */
  265. $return = 'site registered. ';
  266. $return .= check_dokeos_version2();
  267. //}
  268. }
  269. return $return;
  270. }
  271. /**
  272. * This setting changes the registration status for the campus
  273. *
  274. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  275. * @version August 2006
  276. *
  277. * @todo the $_settings should be reloaded here. => write api function for this and use this in global.inc.php also.
  278. */
  279. function register_site()
  280. {
  281. // Database Table Definitions
  282. $tbl_settings = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  283. // the SQL statment
  284. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'";
  285. $result = api_sql_query($sql,__FILE__,__LINE__);
  286. //
  287. if ($_POST['donotlistcampus'])
  288. {
  289. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='donotlistcampus'";
  290. $result = api_sql_query($sql,__FILE__,__LINE__);
  291. }
  292. // reload the settings
  293. }
  294. /**
  295. * Check if the current installation is up to date
  296. * The code is borrowed from phpBB and slighlty modified
  297. * @author The phpBB Group <support@phpbb.com> (the code)
  298. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  299. * @copyright (C) 2001 The phpBB Group
  300. * @return language string with some layout (color)
  301. */
  302. function check_dokeos_version2()
  303. {
  304. global $_configuration;
  305. $dokeos_version = trim($_configuration['dokeos_version']); // the dokeos version of your installation
  306. if (ini_get('allow_url_fopen')==1)
  307. {
  308. // the number of courses
  309. $sql="SELECT count(code) FROM ".Database::get_main_table(TABLE_MAIN_COURSE);
  310. $result=api_sql_query($sql,__FILE__,__LINE__);
  311. $row = Database::fetch_array($result);
  312. $number_of_courses = $row[0];
  313. // the number of users
  314. $sql="SELECT count(user_id) FROM ".Database::get_main_table(TABLE_MAIN_USER);
  315. $result=api_sql_query($sql,__FILE__,__LINE__);
  316. $row = Database::fetch_array($result);
  317. $number_of_users = $row[0];
  318. $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'));
  319. $handle=@fopen($version_url,'r');
  320. $version_info=trim(@fread($handle, 1024));
  321. if ($dokeos_version<>$version_info)
  322. {
  323. $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>';
  324. }
  325. else
  326. {
  327. $output = '<br /><span style="color:green">'.get_lang('VersionUpToDate').': Dokeos '.$version_info.'</span>';
  328. }
  329. }
  330. else
  331. {
  332. $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>';
  333. }
  334. return $output;
  335. }
  336. /**
  337. * Check if the current installation is up to date
  338. * The code is borrowed from phpBB and slighlty modified
  339. * @author The phpBB Group <support@phpbb.com> (the code)
  340. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  341. * @copyright (C) 2001 The phpBB Group
  342. * @return language string with some layout (color)
  343. * @deprecated For some reason this code adds a 9 in front and a 0 at the end of what normally gets displayed by
  344. the http://www.dokeos.com/version.php page (instead of version.txt) . That's why I chose to use fopen which requires however
  345. that allow_url_open is set to true
  346. */
  347. function check_dokeos_version()
  348. {
  349. global $_configuration; // the dokeos version of your installation
  350. $dokeos_version = $_configuration['dokeos_version'];
  351. if ($fsock = @fsockopen('www.dokeos.com', 80, $errno, $errstr))
  352. {
  353. @fputs($fsock, "GET /version.php HTTP/1.1\r\n");
  354. @fputs($fsock, "HOST: www.dokeos.com\r\n");
  355. @fputs($fsock, "Connection: close\r\n\r\n");
  356. $get_info = false;
  357. while (!@feof($fsock))
  358. {
  359. if ($get_info)
  360. {
  361. $version_info .= @fread($fsock, 1024);
  362. }
  363. else
  364. {
  365. if (@fgets($fsock, 1024) == "\r\n")
  366. {
  367. $get_info = true;
  368. }
  369. }
  370. }
  371. @fclose($fsock);
  372. if (trim($dokeos_version)<>trim($version_info))
  373. {
  374. $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>';
  375. }
  376. else
  377. {
  378. $output = '<span style="color:green">'.get_lang('VersionUpToDate').': Dokeos '.$version_info.'</span>';
  379. }
  380. }
  381. else
  382. {
  383. if ($errstr)
  384. {
  385. $output = '<span style="color:red">' . get_lang('ConnectSocketError') . ': '. $errstr . '</span>';
  386. }
  387. else
  388. {
  389. $output = '<span>' . get_lang('SocketFunctionsDisabled') . '</span>';
  390. }
  391. }
  392. return $output;
  393. }
  394. /*
  395. ==============================================================================
  396. FOOTER
  397. ==============================================================================
  398. */
  399. Display::display_footer();
  400. ?>