, Ghent University */ function step_active($param) { global $current_step; if ($param==$current_step) { echo 'class="current_step" '; } } /** * This function displays the Step X of Y - * @return string String that says 'Step X of Y' with the right values */ function display_step_sequence() { global $current_step; global $total_steps; return get_lang('Step'.$current_step).' – '; } /** * This function checks if a php extension exists or not and returns an HTML * status string. * * @param string Name of the PHP extension to be checked * @param string Text to show when extension is available (defaults to 'OK') * @param string Text to show when extension is available (defaults to 'KO') * @param boolean Whether this extension is optional (in this case show unavailable text in orange rather than red) * @return string HTML string reporting the status of this extension. Language-aware. * @author Christophe Gesche * @author Patrick Cool , Ghent University * @author Yannick Warnier * @version Dokeos 1.8.1, May 2007 */ function check_extension($extension_name,$return_success='OK',$return_failure='KO',$optional=false) { if(extension_loaded($extension_name)) { return ''.$return_success.''; } else { if($optional===true) { return ''.$return_failure.''; } else { return ''.$return_failure.''; } } } /** * This function checks whether a php setting matches the recommended value * * @author Patrick Cool , Ghent University * @version Dokeos 1.8, august 2006 */ function check_php_setting($php_setting, $recommended_value, $return_success=false, $return_failure=false) { $current_php_value = get_php_setting($php_setting); if ( $current_php_value== $recommended_value) { return ''.$current_php_value.' '.$return_success.''; } else { return ''.$current_php_value.' '.$return_failure.''; } } /** * Enter description here... * * @param string $val a php ini value * @return boolean: ON or OFF * @author Joomla */ function get_php_setting($val) { $r = (ini_get($val) == '1' ? 1 : 0); return $r ? 'ON' : 'OFF'; } /** * This function checks if the given folder is writable */ function check_writable($folder) { if (is_writable('../'.$folder)) { return ''.get_lang('Writable').''; } else { return ''.get_lang('NotWritable').''; } } /** * this function returns a string "FALSE" or "TRUE" according to the variable in parameter * * @param integer $var the variable to convert * @return string the string "FALSE" or "TRUE" * @author Christophe Gesche */ function trueFalse($var) { return $var?'true':'false'; } /** * This function is similar to the core file() function, except that it * works with line endings in Windows (which is not the case of file()) * @param string File path * @return array The lines of the file returned as an array */ function file_to_array($filename) { $fp = fopen($filename, "rb"); $buffer = fread($fp, filesize($filename)); fclose($fp); $result = explode('
',nl2br($buffer)); return $result; } /** * This function returns the value of a parameter from the configuration file * * WARNING - this function relies heavily on global variables $updateFromConfigFile * and $configFile, and also changes these globals. This can be rewritten. * * @param string $param the parameter of which the value is returned * @return string the value of the parameter * @author Olivier Brouckaert */ function get_config_param($param) { global $configFile, $updateFromConfigFile; $updatePath = realpath($_POST['updatePath']).'/'; $updateFromInstalledVersionFile = ''; if(empty($updateFromConfigFile)) //if update from previous install was requested { //try to recover old config file from dokeos 1.8.x if(file_exists($updatePath.'main/inc/conf/configuration.php')) { $updateFromConfigFile='main/inc/conf/configuration.php'; } //give up recovering else { error_log('Could not find config file in '.$updatePath.' in get_config_param()',0); return null; } } if(file_exists($updatePath.'main/inc/installedVersion.inc.php')) { $updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php'; } //look if we already have the queried param if(is_array($configFile) && isset($configFile[$param])) { return $configFile[$param]; } //the param was not found in global vars, so look into the old config file elseif(file_exists($updatePath.$updateFromConfigFile)) { $configFile=array(); $temp=file_to_array($updatePath.$updateFromConfigFile); $val=''; if(file_exists($updatePath.$updateFromInstalledVersionFile)) { $temp2 = file_to_array($updatePath.$updateFromInstalledVersionFile); $temp = array_merge($temp,$temp2); } //parse the config file (TODO clarify why it has to be so complicated) foreach($temp as $enreg) { if(strstr($enreg,'=')) { $enreg=explode('=',$enreg); $enreg[0] = trim($enreg[0]); if($enreg[0][0] == '$') { list($enreg[1])=explode(' //',$enreg[1]); $enreg[0]=trim(str_replace('$','',$enreg[0])); $enreg[1]=str_replace('\"','"',ereg_replace('(^"|"$)','',substr(trim($enreg[1]),0,-1))); $enreg[1]=str_replace('\'','"',ereg_replace('(^\'|\'$)','',$enreg[1])); if(strtolower($enreg[1]) == 'true') { $enreg[1]=1; } if(strtolower($enreg[1]) == 'false') { $enreg[1]=0; } else { $implode_string=' '; if(!strstr($enreg[1],'." ".') && strstr($enreg[1],'.$')) { $enreg[1]=str_replace('.$','." ".$',$enreg[1]); $implode_string=''; } $tmp=explode('." ".',$enreg[1]); foreach($tmp as $tmp_key=>$tmp_val) { if(eregi('^\$[a-z_][a-z0-9_]*$',$tmp_val)) { $tmp[$tmp_key]=get_config_param(str_replace('$','',$tmp_val)); } } $enreg[1]=implode($implode_string,$tmp); } $configFile[$enreg[0]]=$enreg[1]; if($enreg[0] == $param) { $val=$enreg[1]; } } } } return $val; } else { error_log('Config array could not be found in get_config_param()',0); return null; } } /** * Get the config param from the database. If not found, return null * @param string DB Host * @param string DB login * @param string DB pass * @param string DB name * @param string Name of param we want * @return mixed The parameter value or null if not found */ function get_config_param_from_db($host,$login,$pass,$db_name,$param='') { $mydb = mysql_connect($host,$login,$pass); $myconnect = mysql_select_db($db_name); $sql = "SELECT * FROM settings_current WHERE variable = '$param'"; $res = mysql_query($sql); if($res===false){return null;} if(mysql_num_rows($res)>0) { $row = mysql_fetch_array($res); $value = $row['selected_value']; return $value; } return null; } /** * Return a list of language directories. * @todo function does not belong here, move to code library, * also see infocours.php which contains similar function */ function get_language_folder_list($dirname) { if ($dirname[strlen($dirname)-1] != '/') $dirname .= '/'; $handle = opendir($dirname); $language_list = array(); while ($entries = readdir($handle)) { if ($entries=='.' || $entries=='..' || $entries=='CVS' || $entries == '.svn') continue; if (is_dir($dirname.$entries)) { $language_list[] = $entries; } } closedir($handle); return $language_list; } /* ============================================================================== DISPLAY FUNCTIONS ============================================================================== */ /** * Displays a form (drop down menu) so the user can select * his/her preferred language. */ function display_language_selection_box() { //get language list $dirname = '../lang/'; $language_list = get_language_folder_list($dirname); sort($language_list); //Reduce the number of languages shown to only show those with higher than 90% translation in DLTT //This option can be easily removed later on. The aim is to test people response to less choice //$language_to_display = $language_list; $language_to_display = array('brazilian','dutch','english','french','german','hungarian','italian','portuguese','slovenian','spanish'); //display echo "\t\t\n"; } /** * This function displays a language dropdown box so that the installatioin * can be done in the language of the user */ function display_language_selection() { ?>

:

, Ghent University */ function display_requirements($installType, $badUpdatePath, $update_from_version) { echo '

'.display_step_sequence().get_lang('Requirements')."

\n"; echo ''.get_lang('ReadThoroughly').'
'; echo get_lang('MoreDetails').' '.get_lang('ReadTheInstallGuide').'.
'."\n"; // SERVER REQUIREMENTS echo '

'.get_lang('ServerRequirements').'

'; echo '
'.get_lang('ServerRequirementsInfo').'
'; echo '
'; echo '
'.get_lang('PHPVersion').'>= 5.0 '; if (phpversion() < '5.0') { echo ''.get_lang('PHPVersionError').''; } else { echo ''.get_lang('PHPVersionOK'). ' '.phpversion().''; } echo '
session '.get_lang('support').' '.check_extension('session',get_lang('OK'), get_lang('ExtensionSessionsNotAvailable')).'
MySQL '.get_lang('support').' '.check_extension('mysql',get_lang('OK'), get_lang('ExtensionMySQLNotAvailable')).'
zlib '.get_lang('support').' '.check_extension('zlib',get_lang('OK'), get_lang('ExtensionZlibNotAvailable')).'
Regular Expressions '.get_lang('support').' '.check_extension('pcre',get_lang('OK'), get_lang('ExtensionPCRENotAvailable')).'
XML '.get_lang('support').' '.check_extension('xml',get_lang('OK'), get_lang('ExtensionZlibNotAvailable')).'
MultiByteString '.get_lang('support').' '.check_extension('mbstring',get_lang('OK'), get_lang('ExtensionMBStringNotAvailable')).'
GD '.get_lang('support').' '.check_extension('gd',get_lang('OK'), get_lang('ExtensionGDNotAvailable')).'
LDAP '.get_lang('support').' ('.get_lang('Optional').') '.check_extension('ldap',get_lang('OK'), get_lang('ExtensionLDAPNotAvailable'),true).'
'; echo '
'; echo '
'; // RECOMMENDED SETTINGS // Note: these are the settings for Joomla, does this also apply for Dokeos? // Note: also add upload_max_filesize here so that large uploads are possible echo '

'.get_lang('RecommendedSettings').'

'; echo '
'.get_lang('RecommendedSettingsInfo').'
'; echo '
'; echo '
'.get_lang('Setting').' '.get_lang('Recommended').' '.get_lang('Actual').'
Safe Mode '.check_php_setting('safe_mode','OFF').'
Display Errors '.check_php_setting('display_errors','OFF').'
File Uploads '.check_php_setting('file_uploads','ON').'
Magic Quotes GPC '.check_php_setting('magic_quotes_gpc','ON').'
Magic Quotes Runtime '.check_php_setting('magic_quotes_runtime','OFF').'
Register Globals '.check_php_setting('register_globals','OFF').'
Session auto start '.check_php_setting('session.auto_start','OFF').'
Short Open Tag '.check_php_setting('short_open_tag','ON').'
Maximum upload file size '.ini_get('upload_max_filesize').'
Maximum post size '.ini_get('post_max_size').'
'; echo '
'; echo '
'; // DIRECTORY AND FILE PERMISSIONS echo '

'.get_lang('DirectoryAndFilePermissions').'

'; echo '
'.get_lang('DirectoryAndFilePermissionsInfo').'
'; echo '
'; echo ' '; echo '
dokeos/main/inc/conf/ '.check_writable('inc/conf/').'
dokeos/main/garbage/ '.check_writable('garbage/').'
dokeos/main/upload/ '.check_writable('upload/').'
dokeos/main/default_course_document/images/ '.check_writable('default_course_document/images/').'
dokeos/archive/ '.check_writable('../archive/').'
dokeos/courses/ '.check_writable('../courses/').'
dokeos/home/ '.check_writable('../home/').'
'; echo '
'; echo '
'; if($installType == 'update' && (empty($_POST['updatePath']) || $badUpdatePath)) { if($badUpdatePath) { ?>
!
Dokeos .
'; } ?>
:
the user will have to adjust the permissions manually if(count($notwritable)>0) { $error=true; echo '
'; echo get_lang('Warning').':
'; printf(get_lang('NoWritePermissionPleaseReadInstallGuide'),'',' '); echo '
    '; foreach ($notwritable as $value) { echo '
  • '.$value.'
  • '; } echo '
'; echo '
'; } // check wether a Dokeos configuration file already exists. elseif(file_exists('../inc/conf/configuration.php')) { echo '
'; echo get_lang('WarningExistingDokeosInstallationDetected'); echo '
'; } //and now display the choice buttons (go back or install) ?>

" /> '; echo '

'; } } /** * Displays the license (GNU GPL) as step 2, with * - an "I accept" button named step3 to proceed to step 3; * - a "Back" button named step1 to go back to the first step. */ function display_license_agreement() { echo '

'.display_step_sequence().get_lang('Licence').'

'; echo '

'.get_lang('DokeosLicenseInfo').'

'; echo '

'.get_lang('PrintVers').'

'; ?>

\n"; echo "$parameter_name  \n"; if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) { echo ''.$parameter_value."\n"; } else { echo ''."\n"; echo "$extra_notice\n"; } echo "\n"; } /** * Displays step 3 - a form where the user can enter the installation settings * regarding the databases - login and password, names, prefixes, single * or multiple databases, tracking or not... */ function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm) { if($installType == 'update') { global $_configuration; $dbHostForm=$_configuration['db_host']; $dbUsernameForm=$_configuration['db_user']; $dbPassForm=$_configuration['db_password']; $dbPrefixForm=$_configuration['db_prefix']; $enableTrackingForm=$_configuration['tracking_enabled']; $singleDbForm=$_configuration['single_database']; $dbNameForm=$_configuration['main_database']; $dbStatsForm=$_configuration['statistics_database']; $dbScormForm=$_configuration['scorm_database']; $dbUserForm=$_configuration['user_personal_database']; $dbScormExists=true; if(empty($dbScormForm)) { if($singleDbForm) { $dbScormForm=$dbNameForm; } else { $dbScormForm=$dbPrefixForm.'scorm'; $dbScormExists=false; } } if(empty($dbUserForm)) { if($singleDbForm) { $dbUserForm=$dbNameForm; } else { $dbUserForm=$dbPrefixForm.'dokeos_user'; } } echo "

" . display_step_sequence() .get_lang("DBSetting") . "

"; echo get_lang("DBSettingUpgradeIntro"); }else{ echo "

" . display_step_sequence() .get_lang("DBSetting") . "

"; echo get_lang("DBSettingIntro"); } ?>

 
/> />  
/> />  
Confirmation
MySQL host info:
MySQL server version:
MySQL protocol version:
Error
MySQL error:
 
\n"; echo "$parameter_name  \n"; if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) { echo ''.$parameter_value."\n"; } else { echo ''."\n"; } echo "\n"; } /** * Displays step 4 of the installation - configuration settings about Dokeos itself. */ function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm) { if($installType != 'update') { $languageForm = $_SESSION['install_language']; } echo "

" . display_step_sequence() . get_lang("CfgSetting") . "

"; echo '

'.get_lang('ConfigSettingsInfo').' main/inc/conf/configuration.php

'; echo "\n"; echo ""; //First parameter: language echo "\n"; echo '\n"; if($installType == 'update') { echo '\n"; } else // new installation { echo '\n"; } echo "\n"; //Second parameter: Dokeos URL echo "\n"; echo '\n"; if($installType == 'update') echo '\n"; else echo '\n"; echo "\n"; //Parameter 3: administrator's email display_configuration_parameter($installType, get_lang("AdminEmail"), "emailForm", $emailForm); //Parameter 4: administrator's last name display_configuration_parameter($installType, get_lang("AdminLastName"), "adminLastName", $adminLastName); //Parameter 5: administrator's first name display_configuration_parameter($installType, get_lang("AdminFirstName"), "adminFirstName", $adminFirstName); //Parameter 6: administrator's telephone display_configuration_parameter($installType, get_lang("AdminPhone"), "adminPhoneForm", $adminPhoneForm); //Parameter 7: administrator's login display_configuration_parameter($installType, get_lang("AdminLogin"), "loginForm", $loginForm, ($installType == 'update' ? true : false)); //Parameter 8: administrator's password if($installType != 'update') display_configuration_parameter($installType, get_lang("AdminPass"), "passForm", $passForm, false); //Parameter 9: campus name display_configuration_parameter($installType, get_lang("CampusName"), "campusForm", $campusForm); //Parameter 10: institute (short) name display_configuration_parameter($installType, get_lang("InstituteShortName"), "institutionForm", $institutionForm); //Parameter 11: institute (short) name display_configuration_parameter($installType, get_lang("InstituteURL"), "institutionUrlForm", $institutionUrlForm); ?>
'.get_lang('MainLang')."  '.$languageForm."'; echo "'; echo "
'.get_lang('DokeosURL').' ('.get_lang('ThisFieldIsRequired').")  '.htmlentities($urlForm)."'."
: /> />
: /> />
: /> />

MAX_COURSE_TRANSFER): ?>

: ','');?>

'; echo ''.get_lang('Warning').''; echo ''.get_lang('SecurityAdvice').''; echo ': '; printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'),'main/inc/conf/configuration.php','main/install/index.php'); echo ''; ?>