index.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <?php // $Id: index.php 9797 2006-10-26 06:47:10Z pcool $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  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, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Index of the admin tools
  22. *
  23. * @package dokeos.admin
  24. ==============================================================================
  25. */
  26. $langFile='admin';
  27. $cidReset=true;
  28. include('../inc/global.inc.php');
  29. include_once('../inc/installedVersion.inc.php');
  30. $this_section=SECTION_PLATFORM_ADMIN;
  31. api_protect_admin_script();
  32. $tool_name=get_lang("PlatformAdmin");
  33. Display::display_header();
  34. /*
  35. ==============================================================================
  36. ACTION HANDLING
  37. ==============================================================================
  38. */
  39. if ($_POST['Register'])
  40. {
  41. register_site();
  42. Display :: display_confirmation_message('Version Check Enabled');
  43. }
  44. /*
  45. ==============================================================================
  46. MAIN SECTION
  47. ==============================================================================
  48. */
  49. ?>
  50. <div class="admin_section">
  51. <h4><img src="../img/members.gif" border="0" style="vertical-align: middle;" alt="" /> <?php echo ucfirst(get_lang('Users')); ?></h4>
  52. <ul><li style="list-style-type:none"><form method="get" action="user_list.php">
  53. <input type="text" name="keyword" value="<?php echo $_GET['keyword']; ?>"/>
  54. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  55. </form></li>
  56. <li>
  57. <a href="user_list.php?search=advanced"><?php echo get_lang('AdvancedSearch'); ?></a>
  58. </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. </ul>
  64. </div>
  65. <div class="admin_section">
  66. <h4><img src="../img/course.gif" border="0" style="vertical-align: middle;" alt="" /> <?php echo ucfirst(get_lang('Courses')); ?></h4>
  67. <ul><li style="list-style-type:none"><form method="get" action="course_list.php">
  68. <input type="text" name="keyword" value="<?php echo $_GET['keyword']; ?>"/>
  69. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  70. </form></li>
  71. <li>
  72. <a href="course_list.php?search=advanced"><?php echo get_lang('AdvancedSearch'); ?></a>
  73. </li>
  74. <li><a href="course_list.php"><?php echo get_lang('CourseList') ?></a></li>
  75. <li><a href="course_add.php"><?php echo get_lang('AddCourse') ?></a></li>
  76. <li><a href="course_import.php"><?php echo get_lang('AddCourse').' CSV'; ?></a></li>
  77. <!--<li><a href="course_virtual.php"><?php //echo get_lang('AdminManageVirtualCourses') ?></a></li>-->
  78. <li><a href="course_category.php"><?php echo get_lang("AdminCategories"); ?></a></li>
  79. <li><a href="subscribe_class2course.php"><?php echo get_lang('AddClassesToACourse'); ?></a></li>
  80. <li><a href="subscribe_user2course.php"><?php echo get_lang('AddUsersToACourse'); ?></a></li>
  81. <li><a href="course_user_import.php"><?php echo get_lang('AddUsersToACourse').' CSV'; ?></a></li>
  82. </ul>
  83. </div>
  84. <div class="admin_section">
  85. <h4>
  86. <img src="../img/settings.gif" border="0" style="vertical-align: middle;" alt="" />
  87. <?php echo ucfirst(get_lang('Platform')); ?>
  88. </h4>
  89. <ul>
  90. <li><a href="settings.php"><?php echo get_lang('DokeosConfigSettings') ?></a></li>
  91. <li><a href="system_announcements.php"><?php echo get_lang('SystemAnnouncements') ?></a></li>
  92. <li><a href="languages.php"><?php echo get_lang('Languages'); ?></a></li>
  93. <li><a href="configure_homepage.php"><?php echo get_lang('ConfigureHomePage'); ?></a></li>
  94. <!-- <li><a href="configure_extensions.php"><?php echo get_lang('ConfigureExtensions'); ?></a></li> -->
  95. <li><a href="configure_extensions.php?display=visio"><?php echo get_lang('Visioconf'); ?></a></li>
  96. <li><a href="configure_extensions.php?display=ppt2lp"><?php echo get_lang('Ppt2lp'); ?></a></li>
  97. <li><a href="configure_extensions.php?display=search"><?php echo get_lang('SearchEngine'); ?></a></li>
  98. <li><a href="configure_extensions.php?display=serverstats"><?php echo get_lang('ServerStatistics'); ?></a></li>
  99. <li><a href="configure_extensions.php?display=bandwidthstats"><?php echo get_lang('BandWidthStatistics'); ?></a></li>
  100. <?php if(!empty($phpMyAdminPath)): ?>
  101. <li><a href="<?php echo $phpMyAdminPath; ?>" target="_blank"><?php echo get_lang("AdminDatabases"); ?></a><br />(<?php echo get_lang("DBManagementOnlyForServerAdmin"); ?>)</li>
  102. <?php endif; ?>
  103. </ul>
  104. </div>
  105. <?php
  106. if(api_get_setting('use_session_mode')=='true')
  107. {
  108. ?>
  109. <div class="admin_section">
  110. <h4>
  111. <img src="../img/agenda.gif" border="0" align="absmiddle" alt="" />
  112. <?php echo get_lang('Sessions') ?>
  113. </h4>
  114. <ul>
  115. <li style="list-style-type:none"><form method="POST" action="session_list.php">
  116. <input type="text" name="keyword" value="<?php echo $_GET['keyword']; ?>"/>
  117. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  118. </form>
  119. </li>
  120. <li><a href="session_list.php"><?php echo get_lang('ListSession') ?></a></li>
  121. <li><a href="session_add.php"><?php echo get_lang('AddSession') ?></a></li>
  122. <li><a href="session_import.php"><?php echo get_lang('ImportSessionListXMLCSV') ?></a></li>
  123. <li><a href="session_export.php"><?php echo get_lang('ExportSessionListXMLCSV') ?></a></li>
  124. </ul>
  125. </div>
  126. <?php
  127. }
  128. else
  129. {
  130. ?>
  131. <div class="admin_section">
  132. <h4><img src="../img/group.gif" border="0" style="vertical-align: middle;" alt="" /> <?php echo ucfirst(get_lang('AdminClasses')); ?></h4>
  133. <ul>
  134. <li style="list-style-type:none"><form method="get" action="class_list.php">
  135. <input type="text" name="keyword" value="<?php echo $_GET['keyword']; ?>"/>
  136. <input type="submit" value="<?php echo get_lang('Search'); ?>"/>
  137. </form>
  138. </li>
  139. <li><a href="class_list.php"><?php echo get_lang('ClassList'); ?></a></li>
  140. <li><a href="class_add.php"><?php echo get_lang('AddClasses'); ?></a></li>
  141. <li><a href="class_import.php"><?php echo get_lang('ImportClassListCSV'); ?></a></li>
  142. <li><a href="class_user_import.php"><?php echo get_lang('AddUsersToAClass'); ?> CSV</a></li>
  143. </ul>
  144. </div>
  145. <?php
  146. }
  147. ?>
  148. <div class="admin_section">
  149. <h4>
  150. <img src="../img/dokeos.gif" border="0" style="vertical-align: middle;" alt="" />
  151. <?php echo "dokeos.com"; ?>
  152. </h4>
  153. <ul>
  154. <li><a href="http://www.dokeos.com/"><?php echo get_lang('DokeosHomepage'); ?></a></li>
  155. <li><a href="http://www.dokeos.com/forum/"><?php echo get_lang('DokeosForum'); ?></a></li>
  156. <li><a href="http://www.dokeos.com/community_add_portal.php?url=<?php echo $rootWeb; ?>&amp;name=<?php echo urlencode(get_setting('siteName'));?>&amp;organisation=<?php echo urlencode(get_setting('InstitutionUrl'));?>&amp;manager=<?php echo urlencode(get_setting('administratorSurname')." ".get_setting('administratorName'));?>&amp;manageremail=<?php echo urlencode(get_setting('emailAdministrator'));?>"><?php echo get_lang('RegisterYourPortal'); ?></a></li>
  157. <li><a href="http://www.dokeos.com/extensions/"><?php echo get_lang('DokeosExtensions'); ?></a></li>
  158. <li>
  159. <?php
  160. //try to display a maximum before we check the dokeos version and all that
  161. flush(); //send data to client as much as allowed by the web server
  162. ob_flush();
  163. echo get_lang('VersionCheck').': '.version_check();
  164. ?>
  165. </li>
  166. </ul>
  167. </div>
  168. <?php
  169. /**
  170. * Displays either the text for the registration or the message that the installation is (not) up to date
  171. *
  172. * @return string html code
  173. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  174. * @version august 2006
  175. * @todo have a 6monthly re-registration
  176. */
  177. function version_check()
  178. {
  179. // The site has not been registered yet
  180. if (get_setting('registered')=='false' OR get_setting('registered') == false )
  181. {
  182. $return = '';
  183. $return .= '<form action="'.$_SERVER['PHP_SELF'].'" id="VersionCheck" name="VersionCheck" method="post">';
  184. $return .= get_lang('VersionCheckExplanation');
  185. $return .= '<input type="checkbox" name="donotlistcampus" value="1" id="checkbox" /> Do not display my campus in the list of Dokeos platforms';
  186. $return .= '<input type="submit" name="Register" value="Enable Version Check" id="register" />';
  187. $return .= '</form>';
  188. }
  189. else
  190. {
  191. // The site has been registered already but is seriously out of date (registration date + 15552000 seconds)
  192. if ((get_setting('registered') + 15552000) > mktime())
  193. {
  194. $return = 'It has been a long time since about your campus has been updated on Dokeos.com';
  195. $return .= '<form action="'.$_SERVER['PHP_SELF'].'" id="VersionCheck" name="VersionCheck" method="post">';
  196. $return .= '<input type="submit" name="Register" value="Enable Version Check" id="register" />';
  197. $return .= '</form>';
  198. }
  199. else
  200. {
  201. $return = 'site registered';
  202. $return .= check_dokeos_version2();
  203. }
  204. }
  205. return $return;
  206. }
  207. /**
  208. * This setting changes the registration status for the campus
  209. *
  210. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  211. * @version August 2006
  212. *
  213. * @todo the $_settings should be reloaded here. => write api function for this and use this in global.inc.php also.
  214. */
  215. function register_site()
  216. {
  217. // the settings table
  218. $tbl_settings = Database :: get_main_table(MAIN_SETTINGS_CURRENT_TABLE);
  219. // the SQL statment
  220. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'";
  221. $result = api_sql_query($sql);
  222. //
  223. if ($_POST['donotlistcampus'])
  224. {
  225. $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='donotlistcampus'";
  226. $result = api_sql_query($sql);
  227. }
  228. // reload the settings
  229. }
  230. /**
  231. * Check if the current installation is up to date
  232. * The code is borrowed from phpBB and slighlty modified
  233. * @author The phpBB Group <support@phpbb.com> (the code)
  234. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  235. * @copyright (C) 2001 The phpBB Group
  236. * @return language string with some layout (color)
  237. */
  238. function check_dokeos_version2()
  239. {
  240. global $dokeos_version; // the dokeos version of your installation
  241. if (ini_get('allow_url_fopen')==1)
  242. {
  243. // the number of courses
  244. $sql="SELECT code FROM ".Database::get_main_table(MAIN_COURSE_TABLE);
  245. $result=api_sql_query($sql);
  246. $number_of_courses = mysql_num_rows($result);
  247. // the number of users
  248. $sql="SELECT user_id FROM ".Database::get_main_table(MAIN_USER_TABLE);
  249. $result=api_sql_query($sql);
  250. $number_of_users = mysql_num_rows($result);
  251. $version_url= 'http://www.dokeos.com/version.php?url='.urlencode(api_get_path(WEB_PATH)).'&campus='.urlencode(api_get_setting('siteName')).'&contact='.urlencode(get_setting('emailAdministrator')).'&version='.urlencode($dokeos_version).'&numberofcourses='.urlencode($number_of_courses).'&numberofusers='.urlencode($number_of_users).'&donotlistcampus='.get_setting('donotlistcampus');
  252. $handle=@fopen($version_url,'r');
  253. $version_info=@fread($handle, 1024);
  254. if ($dokeos_version<>$version_info)
  255. {
  256. $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>';
  257. }
  258. else
  259. {
  260. $output = '<span style="color:green">'.get_lang('VersionUpToDate').': Dokeos '.$version_info.'</span>';
  261. }
  262. }
  263. else
  264. {
  265. $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>';
  266. }
  267. return $output;
  268. }
  269. /**
  270. * Check if the current installation is up to date
  271. * The code is borrowed from phpBB and slighlty modified
  272. * @author The phpBB Group <support@phpbb.com> (the code)
  273. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (the modifications)
  274. * @copyright (C) 2001 The phpBB Group
  275. * @return language string with some layout (color)
  276. * @deprecated For some reason this code adds a 9 in front and a 0 at the end of what normally gets displayed by
  277. the http://www.dokeos.com/version.php page (instead of version.txt) . That's why I chose to use fopen which requires however
  278. that allow_url_open is set to true
  279. */
  280. function check_dokeos_version()
  281. {
  282. global $dokeos_version; // the dokeos version of your installation
  283. if ($fsock = @fsockopen('www.dokeos.com', 80, $errno, $errstr))
  284. {
  285. @fputs($fsock, "GET /version.php HTTP/1.1\r\n");
  286. @fputs($fsock, "HOST: www.dokeos.com\r\n");
  287. @fputs($fsock, "Connection: close\r\n\r\n");
  288. $get_info = false;
  289. while (!@feof($fsock))
  290. {
  291. if ($get_info)
  292. {
  293. $version_info .= @fread($fsock, 1024);
  294. }
  295. else
  296. {
  297. if (@fgets($fsock, 1024) == "\r\n")
  298. {
  299. $get_info = true;
  300. }
  301. }
  302. }
  303. @fclose($fsock);
  304. if ($dokeos_version<>$version_info)
  305. {
  306. $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>';
  307. }
  308. else
  309. {
  310. $output = '<span style="color:green">'.get_lang('VersionUpToDate').': Dokeos '.$version_info.'</span>';
  311. }
  312. }
  313. else
  314. {
  315. if ($errstr)
  316. {
  317. $output = '<span style="color:red">' . get_lang('ConnectSocketError') . ': '. $errstr . '</span>';
  318. }
  319. else
  320. {
  321. $output = '<span>' . get_lang('SocketFunctionsDisabled') . '</span>';
  322. }
  323. }
  324. return $output;
  325. }
  326. /*
  327. ==============================================================================
  328. FOOTER
  329. ==============================================================================
  330. */
  331. Display::display_footer();
  332. ?>