1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304 |
- <?php
- use Chamilo\CoreBundle\Entity\ExtraField;
- use Chamilo\TicketBundle\Entity\Project as TicketProject;
- use Chamilo\TicketBundle\Entity\Category as TicketCategory;
- use Chamilo\TicketBundle\Entity\Priority as TicketPriority;
- use Doctrine\ORM\EntityManager;
- define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
- function isAlreadyInstalledSystem()
- {
- global $new_version, $_configuration;
- if (empty($new_version)) {
- return true;
- }
- $current_config_file = api_get_path(CONFIGURATION_PATH).'configuration.php';
- if (!file_exists($current_config_file)) {
- return false;
- }
- require $current_config_file;
- $current_version = null;
- if (isset($_configuration['system_version'])) {
- $current_version = trim($_configuration['system_version']);
- }
-
- return empty($current_version) ? false : version_compare($current_version, $new_version, '>=');
- }
- function checkExtension(
- $extensionName,
- $returnSuccess = 'Yes',
- $returnFailure = 'No',
- $optional = false,
- $enabledTerm = ''
- ) {
- if (extension_loaded($extensionName)) {
- if (!empty($enabledTerm)) {
- $isEnabled = ini_get($enabledTerm);
- if ($isEnabled == '1') {
- return Display::label($returnSuccess, 'success');
- } else {
- if ($optional) {
- return Display::label(get_lang('ExtensionInstalledButNotEnabled'), 'warning');
- } else {
- return Display::label(get_lang('ExtensionInstalledButNotEnabled'), 'important');
- }
- }
- } else {
- return Display::label($returnSuccess, 'success');
- }
- } else {
- if ($optional) {
- return Display::label($returnFailure, 'warning');
- } else {
- return Display::label($returnFailure, 'important');
- }
- }
- }
- function checkPhpSetting(
- $phpSetting,
- $recommendedValue,
- $returnSuccess = false,
- $returnFailure = false
- ) {
- $currentPhpValue = getPhpSetting($phpSetting);
- if ($currentPhpValue == $recommendedValue) {
- return Display::label($currentPhpValue.' '.$returnSuccess, 'success');
- } else {
- return Display::label($currentPhpValue.' '.$returnSuccess, 'important');
- }
- }
- function checkPhpSettingExists($phpSetting)
- {
- if (ini_get($phpSetting) != "") {
- return ini_get($phpSetting);
- }
- return false;
- }
- function checkAccessUrl()
- {
- if (api_get_configuration_value('multiple_access_urls') !== true) {
- return true;
- }
- $currentWebPath = api_get_path(WEB_PATH);
- $rootWeb = api_get_configuration_value('root_web');
- return $currentWebPath === $rootWeb;
- }
- function getPhpSetting($val)
- {
- return ini_get($val) == '1' ? 'ON' : 'OFF';
- }
- function trueFalse($var)
- {
- return $var ? 'true' : 'false';
- }
- function remove_memory_and_time_limits()
- {
- if (function_exists('ini_set')) {
- ini_set('memory_limit', -1);
- ini_set('max_execution_time', 0);
- error_log('Update-db script: memory_limit set to -1', 0);
- error_log('Update-db script: max_execution_time 0', 0);
- } else {
- error_log('Update-db script: could not change memory and time limits', 0);
- }
- }
- function detect_browser_language()
- {
- static $language_index = [
- 'ar' => 'arabic',
- 'ast' => 'asturian',
- 'bg' => 'bulgarian',
- 'bs' => 'bosnian',
- 'ca' => 'catalan',
- 'zh' => 'simpl_chinese',
- 'zh-tw' => 'trad_chinese',
- 'cs' => 'czech',
- 'da' => 'danish',
- 'prs' => 'dari',
- 'de' => 'german',
- 'el' => 'greek',
- 'en' => 'english',
- 'es' => 'spanish',
- 'eo' => 'esperanto',
- 'eu' => 'basque',
- 'fa' => 'persian',
- 'fr' => 'french',
- 'fur' => 'friulian',
- 'gl' => 'galician',
- 'ka' => 'georgian',
- 'hr' => 'croatian',
- 'he' => 'hebrew',
- 'hi' => 'hindi',
- 'id' => 'indonesian',
- 'it' => 'italian',
- 'ko' => 'korean',
- 'lv' => 'latvian',
- 'lt' => 'lithuanian',
- 'mk' => 'macedonian',
- 'hu' => 'hungarian',
- 'ms' => 'malay',
- 'nl' => 'dutch',
- 'ja' => 'japanese',
- 'no' => 'norwegian',
- 'oc' => 'occitan',
- 'ps' => 'pashto',
- 'pl' => 'polish',
- 'pt' => 'portuguese',
- 'pt-br' => 'brazilian',
- 'ro' => 'romanian',
- 'qu' => 'quechua_cusco',
- 'ru' => 'russian',
- 'sk' => 'slovak',
- 'sl' => 'slovenian',
- 'sr' => 'serbian',
- 'fi' => 'finnish',
- 'sv' => 'swedish',
- 'th' => 'thai',
- 'tr' => 'turkish',
- 'uk' => 'ukrainian',
- 'vi' => 'vietnamese',
- 'sw' => 'swahili',
- 'yo' => 'yoruba'
- ];
- $system_available_languages = & get_language_folder_list();
- $accept_languages = strtolower(str_replace('_', '-', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
- foreach ($language_index as $code => $language) {
- if (strpos($accept_languages, $code) === 0) {
- if (!empty($system_available_languages[$language])) {
- return $language;
- }
- }
- }
- $user_agent = strtolower(str_replace('_', '-', $_SERVER['HTTP_USER_AGENT']));
- foreach ($language_index as $code => $language) {
- if (@preg_match("/[\[\( ]{$code}[;,_\-\)]/", $user_agent)) {
- if (!empty($system_available_languages[$language])) {
- return $language;
- }
- }
- }
- return 'english';
- }
- function check_writable($folder, $suggestion = false)
- {
- if (is_writable($folder)) {
- return Display::label(get_lang('Writable'), 'success');
- } else {
- if ($suggestion) {
- return Display::label(get_lang('NotWritable'), 'info');
- } else {
- return Display::label(get_lang('NotWritable'), 'important');
- }
- }
- }
- function checkReadable($folder, $suggestion = false)
- {
- if (is_readable($folder)) {
- return Display::label(get_lang('Readable'), 'success');
- } else {
- if ($suggestion) {
- return Display::label(get_lang('NotReadable'), 'info');
- } else {
- return Display::label(get_lang('NotReadable'), 'important');
- }
- }
- }
- function file_to_array($filename)
- {
- if (!is_readable($filename) || is_dir($filename)) {
- return [];
- }
- $fp = fopen($filename, 'rb');
- $buffer = fread($fp, filesize($filename));
- fclose($fp);
- return explode('<br />', nl2br($buffer));
- }
- function set_file_folder_permissions()
- {
- @chmod('.', 0755);
- @chmod('..', 0755);
- }
- function write_system_config_file($path)
- {
- global $dbHostForm;
- global $dbPortForm;
- global $dbUsernameForm;
- global $dbPassForm;
- global $dbNameForm;
- global $urlForm;
- global $pathForm;
- global $urlAppendPath;
- global $languageForm;
- global $encryptPassForm;
- global $session_lifetime;
- global $new_version;
- global $new_version_stable;
- $root_sys = api_add_trailing_slash(str_replace('\\', '/', realpath($pathForm)));
- $content = file_get_contents(__DIR__.'/'.SYSTEM_CONFIG_FILENAME);
- $config['{DATE_GENERATED}'] = date('r');
- $config['{DATABASE_HOST}'] = $dbHostForm;
- $config['{DATABASE_PORT}'] = $dbPortForm;
- $config['{DATABASE_USER}'] = $dbUsernameForm;
- $config['{DATABASE_PASSWORD}'] = $dbPassForm;
- $config['{DATABASE_MAIN}'] = $dbNameForm;
- $config['{ROOT_WEB}'] = $urlForm;
- $config['{ROOT_SYS}'] = $root_sys;
- $config['{URL_APPEND_PATH}'] = $urlAppendPath;
- $config['{PLATFORM_LANGUAGE}'] = $languageForm;
- $config['{SECURITY_KEY}'] = md5(uniqid(rand().time()));
- $config['{ENCRYPT_PASSWORD}'] = $encryptPassForm;
- $config['SESSION_LIFETIME'] = $session_lifetime;
- $config['{NEW_VERSION}'] = $new_version;
- $config['NEW_VERSION_STABLE'] = trueFalse($new_version_stable);
- foreach ($config as $key => $value) {
- $content = str_replace($key, $value, $content);
- }
- $fp = @ fopen($path, 'w');
- if (!$fp) {
- echo '<strong><font color="red">Your script doesn\'t have write access to the config directory</font></strong><br />
- <em>('.str_replace('\\', '/', realpath($path)).')</em><br /><br />
- You probably do not have write access on Chamilo root directory,
- i.e. you should <em>CHMOD 777</em> or <em>755</em> or <em>775</em>.<br /><br />
- Your problems can be related on two possible causes:<br />
- <ul>
- <li>Permission problems.<br />Try initially with <em>chmod -R 777</em> and increase restrictions gradually.</li>
- <li>PHP is running in <a href="http://www.php.net/manual/en/features.safe-mode.php" target="_blank">Safe-Mode</a>. If possible, try to switch it off.</li>
- </ul>
- <a href="http://forum.chamilo.org/" target="_blank">Read about this problem in Support Forum</a><br /><br />
- Please go back to step 5.
- <p><input type="submit" name="step5" value="< Back" /></p>
- </td></tr></table></form></body></html>';
- exit;
- }
- fwrite($fp, $content);
- fclose($fp);
- }
- function & get_language_folder_list()
- {
- static $result;
- if (!is_array($result)) {
- $result = [];
- $exceptions = ['.', '..', 'CVS', '.svn'];
- $search = ['_latin', '_unicode', '_corporate', '_org', '_KM', '_'];
- $replace_with = [' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' '];
- $dirname = api_get_path(SYS_LANG_PATH);
- $handle = opendir($dirname);
- while ($entries = readdir($handle)) {
- if (in_array($entries, $exceptions)) {
- continue;
- }
- if (is_dir($dirname.$entries)) {
- if (is_file($dirname.$entries.'/install_disabled')) {
-
-
- continue;
- }
- $result[$entries] = ucwords(str_replace($search, $replace_with, $entries));
- }
- }
- closedir($handle);
- asort($result);
- }
- return $result;
- }
- function get_config_param($param, $updatePath = '')
- {
- global $configFile, $updateFromConfigFile;
-
- if (is_array($configFile) && isset($configFile[$param])) {
- return $configFile[$param];
- }
- if (empty($updatePath) && !empty($_POST['updatePath'])) {
- $updatePath = $_POST['updatePath'];
- }
- if (empty($updatePath)) {
- $updatePath = api_get_path(SYS_PATH);
- }
- $updatePath = api_add_trailing_slash(str_replace('\\', '/', realpath($updatePath)));
- $updateFromInstalledVersionFile = '';
- if (empty($updateFromConfigFile)) {
-
-
- if (file_exists($updatePath.'main/inc/conf/configuration.php')) {
- $updateFromConfigFile = 'main/inc/conf/configuration.php';
- } elseif (file_exists($updatePath.'app/config/configuration.php')) {
- $updateFromConfigFile = 'app/config/configuration.php';
- } else {
-
-
- return null;
- }
- }
- if (file_exists($updatePath.$updateFromConfigFile) &&
- !is_dir($updatePath.$updateFromConfigFile)
- ) {
- require $updatePath.$updateFromConfigFile;
- $config = new Zend\Config\Config($_configuration);
- return $config->get($param);
- }
- error_log('Config array could not be found in get_config_param()', 0);
- return null;
- }
- function get_config_param_from_db($param = '')
- {
- if (($res = Database::query("SELECT * FROM settings_current WHERE variable = '$param'")) !== false) {
- if (Database::num_rows($res) > 0) {
- $row = Database::fetch_array($res);
- return $row['selected_value'];
- }
- }
- return null;
- }
- function connectToDatabase(
- $dbHostForm,
- $dbUsernameForm,
- $dbPassForm,
- $dbNameForm,
- $dbPortForm = 3306
- ) {
- $dbParams = [
- 'driver' => 'pdo_mysql',
- 'host' => $dbHostForm,
- 'port' => $dbPortForm,
- 'user' => $dbUsernameForm,
- 'password' => $dbPassForm,
- 'dbname' => $dbNameForm
- ];
- $database = new \Database();
- $database->connect($dbParams);
- return $database;
- }
- function step_active($param)
- {
- global $current_step;
- if ($param == $current_step) {
- echo 'class="current-step" ';
- }
- }
- function display_step_sequence()
- {
- global $current_step;
- return get_lang('Step'.$current_step).' – ';
- }
- function display_language_selection_box(
- $name = 'language_list',
- $default_language = 'english'
- ) {
-
- $language_list = get_language_folder_list();
-
-
- if (!is_array($language_list) || empty($language_list)) {
- $language_list = ['english' => 'English'];
- }
-
-
-
- if (!array_key_exists($default_language, $language_list)) {
- if (array_key_exists('english', $language_list)) {
- $default_language = 'english';
- } else {
- $language_keys = array_keys($language_list);
- $default_language = $language_keys[0];
- }
- }
-
- $html = '';
- $html .= "\t\t<select class='selectpicker show-tick' name=\"$name\">\n";
- foreach ($language_list as $key => $value) {
- if ($key == $default_language) {
- $option_end = ' selected="selected">';
- } else {
- $option_end = '>';
- }
- $html .= "\t\t\t<option value=\"$key\"$option_end";
- $html .= $value;
- $html .= "</option>\n";
- }
- $html .= "\t\t</select>\n";
- return $html;
- }
- function display_language_selection()
- {
- ?>
- <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2>
- <div class="RequirementHeading">
- <h2><?php echo display_step_sequence(); ?>
- <?php echo get_lang('InstallationLanguage'); ?>
- </h2>
- <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p>
- <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
- <div class="form-group">
- <div class="col-sm-4">
- <?php echo display_language_selection_box('language_list', api_get_interface_language()); ?>
- </div>
- <div class="col-sm-6">
- <button type="submit" name="step1" class="btn btn-success" value="<?php echo get_lang('Next'); ?>">
- <em class="fa fa-forward"> </em>
- <?php echo get_lang('Next'); ?></button>
- </div>
- </div>
- <input type="hidden" name="is_executable" id="is_executable" value="-" />
- </form>
- </div>
- <div class="RequirementHeading">
- <?php echo get_lang('YourLanguageNotThereContactUs'); ?>
- </div>
- <?php
- }
- /**
- * This function displays the requirements for installing Chamilo.
- *
- * @param string $installType
- * @param boolean $badUpdatePath
- * @param boolean $badUpdatePath
- * @param string $updatePath The updatePath given (if given)
- * @param array $update_from_version_8 The different subversions from version 1.9
- *
- * @author unknow
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
- */
- function display_requirements(
- $installType,
- $badUpdatePath,
- $updatePath = '',
- $update_from_version_8 = []
- ) {
- global $_setting;
- echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('Requirements')."</h2></div>";
- echo '<div class="RequirementText">';
- echo '<strong>'.get_lang('ReadThoroughly').'</strong><br />';
- echo get_lang('MoreDetails').' <a href="../../documentation/installation_guide.html" target="_blank">'.get_lang('ReadTheInstallationGuide').'</a>.<br />'."\n";
- if ($installType == 'update') {
- echo get_lang('IfYouPlanToUpgradeFromOlderVersionYouMightWantToHaveAlookAtTheChangelog').'<br />';
- }
- echo '</div>';
- $properlyAccessUrl = checkAccessUrl();
- if (!$properlyAccessUrl) {
- echo '
- <div class="alert alert-danger">
- ' . Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_MEDIUM, true, false, true).
- ' '.
- sprintf(get_lang('InstallMultiURLDetectedNotMainURL'), api_get_configuration_value('root_web')).'
- </div>
- ';
- }
-
- echo '<div class="RequirementHeading"><h4>'.get_lang('ServerRequirements').'</h4>';
- $timezone = checkPhpSettingExists("date.timezone");
- if (!$timezone) {
- echo "<div class='alert alert-warning'>".
- Display::return_icon(
- 'warning.png',
- get_lang('Warning'),
- '',
- ICON_SIZE_MEDIUM,
- true,
- false,
- false
- ).
- get_lang("DateTimezoneSettingNotSet")."</div>";
- }
- echo '<div class="RequirementText">'.get_lang('ServerRequirementsInfo').'</div>';
- echo '<div class="RequirementContent">';
- echo '<table class="table">
- <tr>
- <td class="requirements-item">'.get_lang('PHPVersion').' >= '.REQUIRED_PHP_VERSION.'</td>
- <td class="requirements-value">';
- if (version_compare(phpversion(), REQUIRED_PHP_VERSION, '>=') > 1) {
- echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
- } else {
- echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>';
- }
- echo '</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.session.php" target="_blank">Session</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('session', get_lang('Yes'), get_lang('ExtensionSessionsNotAvailable')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.mysql.php" target="_blank">pdo_mysql</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('pdo_mysql', get_lang('Yes'), get_lang('ExtensionMySQLNotAvailable')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.zip.php" target="_blank">Zip</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('zip', get_lang('Yes'), get_lang('ExtensionNotAvailable')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.zlib.php" target="_blank">Zlib</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('zlib', get_lang('Yes'), get_lang('ExtensionZlibNotAvailable')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.pcre.php" target="_blank">Perl-compatible regular expressions</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('pcre', get_lang('Yes'), get_lang('ExtensionPCRENotAvailable')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.xml.php" target="_blank">XML</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('xml', get_lang('Yes'), get_lang('No')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.intl.php" target="_blank">Internationalization</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('intl', get_lang('Yes'), get_lang('No')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.json.php" target="_blank">JSON</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('json', get_lang('Yes'), get_lang('No')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.image.php" target="_blank">GD</a> '.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('gd', get_lang('Yes'), get_lang('ExtensionGDNotAvailable')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.curl.php" target="_blank">cURL</a>'.get_lang('Support').'</td>
- <td class="requirements-value">'.checkExtension('curl', get_lang('Yes'), get_lang('No')).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.mbstring.php" target="_blank">Multibyte string</a> '.get_lang('Support').' ('.get_lang('Optional').')</td>
- <td class="requirements-value">'.checkExtension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable'), true).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/opcache" target="_blank">Zend OpCache</a> '.get_lang('Support').' ('.get_lang('Optional').')</td>
- <td class="requirements-value">'.checkExtension('Zend OPcache', get_lang('Yes'), get_lang('No'), true, 'opcache.enable').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/apcu" target="_blank">APCu</a> '.get_lang('Support').' ('.get_lang('Optional').')</td>
- <td class="requirements-value">'.checkExtension('apcu', get_lang('Yes'), get_lang('No'), true, 'apc.enabled').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.iconv.php" target="_blank">Iconv</a> '.get_lang('Support').' ('.get_lang('Optional').')</td>
- <td class="requirements-value">'.checkExtension('iconv', get_lang('Yes'), get_lang('No'), true).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/en/book.ldap.php" target="_blank">LDAP</a> '.get_lang('Support').' ('.get_lang('Optional').')</td>
- <td class="requirements-value">'.checkExtension('ldap', get_lang('Yes'), get_lang('ExtensionLDAPNotAvailable'), true).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://xapian.org/" target="_blank">Xapian</a> '.get_lang('Support').' ('.get_lang('Optional').')</td>
- <td class="requirements-value">'.checkExtension('xapian', get_lang('Yes'), get_lang('No'), true).'</td>
- </tr>
- </table>';
- echo '</div>';
- echo '</div>';
-
-
-
- echo '<div class="RequirementHeading"><h4>'.get_lang('RecommendedSettings').'</h4>';
- echo '<div class="RequirementText">'.get_lang('RecommendedSettingsInfo').'</div>';
- echo '<div class="RequirementContent">';
- echo '<table class="table">
- <tr>
- <th>'.get_lang('Setting').'</th>
- <th>'.get_lang('Recommended').'</th>
- <th>'.get_lang('Actual').'</th>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/features.safe-mode.php">Safe Mode</a></td>
- <td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('safe_mode', 'OFF').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ref.errorfunc.php#ini.display-errors">Display Errors</a></td>
- <td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('display_errors', 'OFF').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.file-uploads">File Uploads</a></td>
- <td class="requirements-recommended">'.Display::label('ON', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('file_uploads', 'ON').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-gpc">Magic Quotes GPC</a></td>
- <td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('magic_quotes_gpc', 'OFF').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-runtime">Magic Quotes Runtime</a></td>
- <td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('magic_quotes_runtime', 'OFF').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/security.globals.php">Register Globals</a></td>
- <td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('register_globals', 'OFF').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ref.session.php#ini.session.auto-start">Session auto start</a></td>
- <td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('session.auto_start', 'OFF').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.short-open-tag">Short Open Tag</a></td>
- <td class="requirements-recommended">'.Display::label('OFF', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('short_open_tag', 'OFF').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-httponly">Cookie HTTP Only</a></td>
- <td class="requirements-recommended">'.Display::label('ON', 'success').'</td>
- <td class="requirements-value">'.checkPhpSetting('session.cookie_httponly', 'ON').'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.upload-max-filesize">Maximum upload file size</a></td>
- <td class="requirements-recommended">'.Display::label('>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M', 'success').'</td>
- <td class="requirements-value">'.compare_setting_values(ini_get('upload_max_filesize'), REQUIRED_MIN_UPLOAD_MAX_FILESIZE).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.post-max-size">Maximum post size</a></td>
- <td class="requirements-recommended">'.Display::label('>= '.REQUIRED_MIN_POST_MAX_SIZE.'M', 'success').'</td>
- <td class="requirements-value">'.compare_setting_values(ini_get('post_max_size'), REQUIRED_MIN_POST_MAX_SIZE).'</td>
- </tr>
- <tr>
- <td class="requirements-item"><a href="http://www.php.net/manual/en/ini.core.php#ini.memory-limit">Memory Limit</a></td>
- <td class="requirements-recommended">'.Display::label('>= '.REQUIRED_MIN_MEMORY_LIMIT.'M', 'success').'</td>
- <td class="requirements-value">'.compare_setting_values(ini_get('memory_limit'), REQUIRED_MIN_MEMORY_LIMIT).'</td>
- </tr>
- </table>';
- echo ' </div>';
- echo '</div>';
-
- echo '<div class="RequirementHeading"><h4>'.get_lang('DirectoryAndFilePermissions').'</h4>';
- echo '<div class="RequirementText">'.get_lang('DirectoryAndFilePermissionsInfo').'</div>';
- echo '<div class="RequirementContent">';
- $course_attempt_name = '__XxTestxX__';
- $course_dir = api_get_path(SYS_COURSE_PATH).$course_attempt_name;
-
- @unlink($course_dir.'/test.php');
- @rmdir($course_dir);
- $perms_dir = [0777, 0755, 0775, 0770, 0750, 0700];
- $perms_fil = [0666, 0644, 0664, 0660, 0640, 0600];
- $course_test_was_created = false;
- $dir_perm_verified = 0777;
- foreach ($perms_dir as $perm) {
- $r = @mkdir($course_dir, $perm);
- if ($r === true) {
- $dir_perm_verified = $perm;
- $course_test_was_created = true;
- break;
- }
- }
- $fil_perm_verified = 0666;
- $file_course_test_was_created = false;
- if (is_dir($course_dir)) {
- foreach ($perms_fil as $perm) {
- if ($file_course_test_was_created == true) {
- break;
- }
- $r = @touch($course_dir.'/test.php', $perm);
- if ($r === true) {
- $fil_perm_verified = $perm;
- if (check_course_script_interpretation($course_dir, $course_attempt_name, 'test.php')) {
- $file_course_test_was_created = true;
- }
- }
- }
- }
- @unlink($course_dir.'/test.php');
- @rmdir($course_dir);
- $_SESSION['permissions_for_new_directories'] = $_setting['permissions_for_new_directories'] = $dir_perm_verified;
- $_SESSION['permissions_for_new_files'] = $_setting['permissions_for_new_files'] = $fil_perm_verified;
- $dir_perm = Display::label('0'.decoct($dir_perm_verified), 'info');
- $file_perm = Display::label('0'.decoct($fil_perm_verified), 'info');
- $courseTestLabel = Display::label(get_lang('No'), 'important');
- if ($course_test_was_created && $file_course_test_was_created) {
- $courseTestLabel = Display::label(get_lang('Yes'), 'success');
- }
- if ($course_test_was_created && !$file_course_test_was_created) {
- $courseTestLabel = Display::label(get_lang('Warning'), 'warning');
- $courseTestLabel .= '<br />'.sprintf(
- get_lang('InstallWarningCouldNotInterpretPHP'),
- api_get_path(WEB_COURSE_PATH).$course_attempt_name.'/test.php'
- );
- }
- if (!$course_test_was_created && !$file_course_test_was_created) {
- $courseTestLabel = Display::label(get_lang('No'), 'important');
- }
- $oldConf = '';
- if (file_exists(api_get_path(SYS_CODE_PATH).'inc/conf/configuration.php')) {
- $oldConf = '<tr>
- <td class="requirements-item">'.api_get_path(SYS_CODE_PATH).'inc/conf</td>
- <td class="requirements-value">'.check_writable(api_get_path(SYS_CODE_PATH).'inc/conf').'</td>
- </tr>';
- }
- echo '<table class="table">
- '.$oldConf.'
- <tr>
- <td class="requirements-item">'.api_get_path(SYS_APP_PATH).'</td>
- <td class="requirements-value">'.check_writable(api_get_path(SYS_APP_PATH)).'</td>
- </tr>
- <tr>
- <td class="requirements-item">'.api_get_path(SYS_CODE_PATH).'default_course_document/images/</td>
- <td class="requirements-value">'.check_writable(api_get_path(SYS_CODE_PATH).'default_course_document/images/').'</td>
- </tr>
- <tr>
- <td class="requirements-item">'.api_get_path(SYS_CODE_PATH).'lang/</td>
- <td class="requirements-value">'.check_writable(api_get_path(SYS_CODE_PATH).'lang/', true).' <br />('.get_lang('SuggestionOnlyToEnableSubLanguageFeatureOrUpgradeProcess').')</td>
- </tr>
- <tr>
- <td class="requirements-item">'.api_get_path(SYS_PATH).'vendor/</td>
- <td class="requirements-value">'.checkReadable(api_get_path(SYS_PATH).'vendor').'</td>
- </tr>
- <tr>
- <td class="requirements-item">'.api_get_path(SYS_PUBLIC_PATH).'</td>
- <td class="requirements-value">'.check_writable(api_get_path(SYS_PUBLIC_PATH)).'</td>
- </tr>
- <tr>
- <td class="requirements-item">'.get_lang('CourseTestWasCreated').'</td>
- <td class="requirements-value">'.$courseTestLabel.' </td>
- </tr>
- <tr>
- <td class="requirements-item">'.get_lang('PermissionsForNewDirs').'</td>
- <td class="requirements-value">'.$dir_perm.' </td>
- </tr>
- <tr>
- <td class="requirements-item">'.get_lang('PermissionsForNewFiles').'</td>
- <td class="requirements-value">'.$file_perm.' </td>
- </tr>
- </table>';
- echo ' </div>';
- echo '</div>';
- if ($installType == 'update' && (empty($updatePath) || $badUpdatePath)) {
- if ($badUpdatePath) {
- ?>
- <div class="alert alert-warning">
- <?php echo get_lang('Error'); ?>!<br />
- Chamilo <?php echo implode('|', $update_from_version_8).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
- </div>
- <?php
- } else {
- echo '<br />';
- } ?>
- <div class="row">
- <div class="col-md-12">
- <p><?php echo get_lang('OldVersionRootPath'); ?>:
- <input type="text" name="updatePath" size="50" value="<?php echo ($badUpdatePath && !empty($updatePath)) ? htmlentities($updatePath) : ''; ?>" />
- </p>
- <p>
- <button type="submit" class="btn btn-default" name="step1" value="<?php echo get_lang('Back'); ?>" >
- <em class="fa fa-backward"> <?php echo get_lang('Back'); ?></em>
- </button>
- <input type="hidden" name="is_executable" id="is_executable" value="-" />
- <button type="submit" class="btn btn-success" name="<?php echo(isset($_POST['step2_update_6']) ? 'step2_update_6' : 'step2_update_8'); ?>" value="<?php echo get_lang('Next'); ?> >" >
- <em class="fa fa-forward"> </em> <?php echo get_lang('Next'); ?>
- </button>
- </p>
- </div>
- </div>
- <?php
- } else {
- $error = false;
-
- $perm = api_get_permissions_for_new_directories();
- $perm_file = api_get_permissions_for_new_files();
- $notWritable = [];
- $checked_writable = api_get_path(SYS_APP_PATH);
- if (!is_writable($checked_writable)) {
- $notWritable[] = $checked_writable;
- @chmod($checked_writable, $perm);
- }
- $checked_writable = api_get_path(SYS_PUBLIC_PATH);
- if (!is_writable($checked_writable)) {
- $notWritable[] = $checked_writable;
- @chmod($checked_writable, $perm);
- }
- $checked_writable = api_get_path(SYS_CODE_PATH).'default_course_document/images/';
- if (!is_writable($checked_writable)) {
- $notWritable[] = $checked_writable;
- @chmod($checked_writable, $perm);
- }
- if ($course_test_was_created == false) {
- $error = true;
- }
- $checked_writable = api_get_path(CONFIGURATION_PATH).'configuration.php';
- if (file_exists($checked_writable) && !is_writable($checked_writable)) {
- $notWritable[] = $checked_writable;
- @chmod($checked_writable, $perm_file);
- }
-
-
- if (count($notWritable) > 0) {
- $error = true; ?>
- <div class="text-danger">
- <h3 class="text-center"><?php echo get_lang('Warning') ?></h3>
- <p>
- <?php printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '<a href="../../documentation/installation_guide.html" target="blank">', '</a>'); ?>
- </p>
- </div>
- <?php
- echo '<ul>';
- foreach ($notWritable as $value) {
- echo '<li class="text-danger">'.$value.'</li>';
- }
- echo '</ul>';
- } elseif (file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php')) {
-
- echo '<div class="alert alert-warning"><h4><center>';
- echo get_lang('WarningExistingLMSInstallationDetected');
- echo '</center></h4></div>';
- }
- $deprecated = [
- api_get_path(SYS_CODE_PATH).'exercice/',
- api_get_path(SYS_CODE_PATH).'newscorm/',
- api_get_path(SYS_PLUGIN_PATH).'ticket/',
- api_get_path(SYS_PLUGIN_PATH).'skype/'
- ];
- $deprecatedToRemove = [];
- foreach ($deprecated as $deprecatedDirectory) {
- if (!is_dir($deprecatedDirectory)) {
- continue;
- }
- $deprecatedToRemove[] = $deprecatedDirectory;
- }
- if (count($deprecatedToRemove) > 0) {
- $error = true; ?>
- <p class="text-danger"><?php echo get_lang('WarningForDeprecatedDirectoriesForUpgrade') ?></p>
- <ul>
- <?php foreach ($deprecatedToRemove as $deprecatedDirectory) {
- ?>
- <li class="text-danger"><?php echo $deprecatedDirectory ?></li>
- <?php
- } ?>
- </ul>
- <?php
- }
- if (!$properlyAccessUrl) {
- $error = true;
- }
-
- <p align="center" style="padding-top:15px">
- <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php echo get_lang('Previous'); ?>" >
- <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?>
- </button>
- <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) {
- echo 'disabled="disabled"';
- } ?> >
- <em class="fa fa-forward"> </em> <?php echo get_lang('NewInstallation'); ?>
- </button>
- <input type="hidden" name="is_executable" id="is_executable" value="-" />
- <button type="submit" class="btn btn-default" <?php echo !$error ?: 'disabled="disabled"' ?> name="step2_update_8" value="Upgrade from Chamilo 1.9.x">
- <em class="fa fa-forward" aria-hidden="true"></em> <?php echo get_lang('UpgradeVersion') ?>
- </button>
- </p>
- <?php
- }
- }
- /**
- * 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 '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('Licence').'</h2>';
- echo '<p>'.get_lang('LMSLicenseInfo').'</p>';
- echo '<p><a href="../../documentation/license.html" target="_blank">'.get_lang('PrintVers').'</a></p>';
- echo '</div>'; ?>
- <div class="row">
- <div class="col-md-12">
- <pre style="overflow: auto; height: 200px; margin-top: 5px;">
- <?php echo api_htmlentities(@file_get_contents(api_get_path(SYS_PATH).'documentation/license.txt')); ?>
- </pre>
- <div class="checkbox">
- <label>
- <input type="checkbox" name="accept" id="accept_licence" value="1" />
- <?php echo get_lang('IAccept'); ?>
- </label>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12">
- <p class="alert alert-info"><?php echo get_lang('LMSMediaLicense'); ?></p>
- </div>
- </div>
- <!-- Contact information form -->
- <div class="section-parameters">
- <a href="javascript://" class = "advanced_parameters" >
- <span id="img_plus_and_minus"> <i class="fa fa-eye" aria-hidden="true"></i> <?php echo get_lang('ContactInformation') ?></span>
- </a>
- </div>
- <div id="id_contact_form" style="display:block">
- <div class="normal-message"><?php echo get_lang('ContactInformationDescription') ?></div>
- <div id="contact_registration">
- <p><?php echo get_contact_registration_form() ?></p><br />
- </div>
- </div>
- <div class="text-center">
- <button type="submit" class="btn btn-default" name="step1" value="< <?php echo get_lang('Previous'); ?>" >
- <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?>
- </button>
- <input type="hidden" name="is_executable" id="is_executable" value="-" />
- <button type="submit" id="license-next" class="btn btn-success" name="step3" onclick="javascript: if(!document.getElementById('accept_licence').checked) { alert('<?php echo get_lang('YouMustAcceptLicence')?>');return false;}" value="<?php echo get_lang('Next'); ?> >" >
- <em class="fa fa-forward"> </em> <?php echo get_lang('Next'); ?>
- </button>
- </div>
- <?php
- }
- /**
- * Get contact registration form
- */
- function get_contact_registration_form()
- {
- $html = '
- <div class="form-horizontal">
- <div class="panel panel-default">
- <div class="panel-body">
- <div id="div_sent_information"></div>
- <div class="form-group">
- <label class="col-sm-3"><span class="form_required">*</span>'.get_lang('Name').'</label>
- <div class="col-sm-9"><input id="person_name" class="form-control" type="text" name="person_name" size="30" /></div>
- </div>
- <div class="form-group">
- <label class="col-sm-3"><span class="form_required">*</span>'.get_lang('Email').'</label>
- <div class="col-sm-9"><input id="person_email" class="form-control" type="text" name="person_email" size="30" /></div>
- </div>
- <div class="form-group">
- <label class="col-sm-3"><span class="form_required">*</span>'.get_lang('CompanyName').'</label>
- <div class="col-sm-9"><input id="company_name" class="form-control" type="text" name="company_name" size="30" /></div>
- </div>
- <div class="form-group">
- <label class="col-sm-3"><span class="form_required">*</span>'.get_lang('CompanyActivity').'</label>
- <div class="col-sm-9">
- <select class="selectpicker show-tick" name="company_activity" id="company_activity" >
- <option value="">--- '.get_lang('SelectOne').' ---</option>
- <Option value="Advertising/Marketing/PR">Advertising/Marketing/PR</Option><Option value="Agriculture/Forestry">Agriculture/Forestry</Option>
- <Option value="Architecture">Architecture</Option><Option value="Banking/Finance">Banking/Finance</Option>
- <Option value="Biotech/Pharmaceuticals">Biotech/Pharmaceuticals</Option><Option value="Business Equipment">Business Equipment</Option>
- <Option value="Business Services">Business Services</Option><Option value="Construction">Construction</Option>
- <Option value="Consulting/Research">Consulting/Research</Option><Option value="Education">Education</Option>
- <Option value="Engineering">Engineering</Option><Option value="Environmental">Environmental</Option>
- <Option value="Government">Government</Option><Option value="Healthcare">Health Care</Option>
- <Option value="Hospitality/Lodging/Travel">Hospitality/Lodging/Travel</Option><Option value="Insurance">Insurance</Option>
- <Option value="Legal">Legal</Option><Option value="Manufacturing">Manufacturing</Option>
- <Option value="Media/Entertainment">Media/Entertainment</Option><Option value="Mortgage">Mortgage</Option>
- <Option value="Non-Profit">Non-Profit</Option><Option value="Real Estate">Real Estate</Option>
- <Option value="Restaurant">Restaurant</Option><Option value="Retail">Retail</Option>
- <Option value="Shipping/Transportation">Shipping/Transportation</Option>
- <Option value="Technology">Technology</Option><Option value="Telecommunications">Telecommunications</Option>
- <Option value="Other">Other</Option>
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3"><span class="form_required">*</span>'.get_lang('PersonRole').'</label>
- <div class="col-sm-9">
- <select class="selectpicker show-tick" name="person_role" id="person_role" >
- <option value="">--- '.get_lang('SelectOne').' ---</option>
- <Option value="Administration">Administration</Option><Option value="CEO/President/ Owner">CEO/President/ Owner</Option>
- <Option value="CFO">CFO</Option><Option value="CIO/CTO">CIO/CTO</Option>
- <Option value="Consultant">Consultant</Option><Option value="Customer Service">Customer Service</Option>
- <Option value="Engineer/Programmer">Engineer/Programmer</Option><Option value="Facilities/Operations">Facilities/Operations</Option>
- <Option value="Finance/ Accounting Manager">Finance/ Accounting Manager</Option><Option value="Finance/ Accounting Staff">Finance/ Accounting Staff</Option>
- <Option value="General Manager">General Manager</Option><Option value="Human Resources">Human Resources</Option>
- <Option value="IS/IT Management">IS/IT Management</Option><Option value="IS/ IT Staff">IS/ IT Staff</Option>
- <Option value="Marketing Manager">Marketing Manager</Option><Option value="Marketing Staff">Marketing Staff</Option>
- <Option value="Partner/Principal">Partner/Principal</Option><Option value="Purchasing Manager">Purchasing Manager</Option>
- <Option value="Sales/ Business Dev. Manager">Sales/ Business Dev. Manager</Option><Option value="Sales/ Business Dev.">Sales/ Business Dev.</Option>
- <Option value="Vice President/Senior Manager">Vice President/Senior Manager</Option><Option value="Other">Other</Option>
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3"><span class="form_required">*</span>'.get_lang('CompanyCountry').'</label>
- <div class="col-sm-9">'.get_countries_list_from_array(true).'</div>
- </div>
- <div class="form-group">
- <label class="col-sm-3">'.get_lang('CompanyCity').'</label>
- <div class="col-sm-9">
- <input type="text" class="form-control" id="company_city" name="company_city" size="30" />
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3">'.get_lang('WhichLanguageWouldYouLikeToUseWhenContactingYou').'</label>
- <div class="col-sm-9">
- <select class="selectpicker show-tick" id="language" name="language">
- <option value="bulgarian">Bulgarian</option>
- <option value="indonesian">Bahasa Indonesia</option>
- <option value="bosnian">Bosanski</option>
- <option value="german">Deutsch</option>
- <option selected="selected" value="english">English</option>
- <option value="spanish">Spanish</option>
- <option value="french">Français</option>
- <option value="italian">Italian</option>
- <option value="hungarian">Magyar</option>
- <option value="dutch">Nederlands</option>
- <option value="brazilian">Português do Brasil</option>
- <option value="portuguese">Português europeu</option>
- <option value="slovenian">Slovenčina</option>
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-3">'.get_lang('HaveYouThePowerToTakeFinancialDecisions').'</label>
- <div class="col-sm-9">
- <div class="radio">
- <label>
- <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').'
- </label>
- </div>
- <div class="radio">
- <label>
- <input type="radio" name="financial_decision" id="financial_decision2" value="0" /> '.get_lang('No').'
- </label>
- </div>
- </div>
- </div>
- <div class="clear"></div>
- <div class="form-group">
- <div class="col-sm-3"> </div>
- <div class="col-sm-9"><button type="button" class="btn btn-default" onclick="javascript:send_contact_information();" value="'.get_lang('SendInformation').'" ><em class="fa fa-floppy-o"></em> '.get_lang('SendInformation').'</button> <span id="loader-button"></span></div>
- </div>
- <div class="form-group">
- <div class="col-sm-3"> </div>
- <div class="col-sm-9"><span class="form_required">*</span><small>'.get_lang('FieldRequired').'</small></div>
- </div></div></div>
- </div>';
- return $html;
- }
- /**
- * Displays a parameter in a table row.
- * Used by the display_database_settings_form function.
- * @param string Type of install
- * @param string Name of parameter
- * @param string Field name (in the HTML form)
- * @param string Field value
- * @param string Extra notice (to show on the right side)
- * @param boolean Whether to display in update mode
- * @param string Additional attribute for the <tr> element
- * @return void Direct output
- */
- function displayDatabaseParameter(
- $installType,
- $parameterName,
- $formFieldName,
- $parameterValue,
- $extra_notice,
- $displayWhenUpdate = true,
- $tr_attribute = ''
- ) {
- //echo "<tr ".$tr_attribute.">";
- echo "<label class='col-sm-4'>$parameterName</label>";
- if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) {
- echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'.$parameterValue;
- } else {
- $inputType = $formFieldName == 'dbPassForm' ? 'password' : 'text';
-
- $maxLength = $formFieldName == 'dbPrefixForm' ? '15' : MAX_FORM_FIELD_LENGTH;
- if ($installType == INSTALL_TYPE_UPDATE) {
- echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />';
- echo api_htmlentities($parameterValue);
- } else {
- echo '<div class="col-sm-5"><input type="'.$inputType.'" class="form-control" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxLength.'" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'."</div>";
- echo '<div class="col-sm-3">'.$extra_notice.'</div>';
- }
- }
- }
- function display_database_settings_form(
- $installType,
- $dbHostForm,
- $dbUsernameForm,
- $dbPassForm,
- $dbNameForm,
- $dbPortForm = 3306,
- $installationProfile = ''
- ) {
- if ($installType == 'update') {
- global $_configuration;
- $dbHostForm = $_configuration['db_host'];
- $dbUsernameForm = $_configuration['db_user'];
- $dbPassForm = $_configuration['db_password'];
- $dbNameForm = $_configuration['main_database'];
- $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : '';
- echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
- echo '<div class="RequirementContent">';
- echo get_lang('DBSettingUpgradeIntro');
- echo '</div>';
- } else {
- echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
- echo '<div class="RequirementContent">';
- echo get_lang('DBSettingIntro');
- echo '</div>';
- } ?>
- <div class="panel panel-default">
- <div class="panel-body">
- <div class="form-group">
- <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label>
- <?php if ($installType == 'update') {
- ?>
- <div class="col-sm-5">
- <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
- </div>
- <div class="col-sm-3"></div>
- <?php
- } else {
- ?>
- <div class="col-sm-5">
- <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
- </div>
- <div class="col-sm-3"><?php echo get_lang('EG').' localhost'; ?></div>
- <?php
- } ?>
- </div>
- <div class="form-group">
- <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label>
- <?php if ($installType == 'update') {
- ?>
- <div class="col-sm-5">
- <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
- </div>
- <div class="col-sm-3"></div>
- <?php
- } else {
- ?>
- <div class="col-sm-5">
- <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
- </div>
- <div class="col-sm-3"><?php echo get_lang('EG').' 3306'; ?></div>
- <?php
- } ?>
- </div>
- <div class="form-group">
- <?php
- //database user username
- $example_login = get_lang('EG').' root';
- displayDatabaseParameter($installType, get_lang('DBLogin'), 'dbUsernameForm', $dbUsernameForm, $example_login); ?>
- </div>
- <div class="form-group">
- <?php
- //database user password
- $example_password = get_lang('EG').' '.api_generate_password();
- displayDatabaseParameter($installType, get_lang('DBPassword'), 'dbPassForm', $dbPassForm, $example_password); ?>
- </div>
- <div class="form-group">
- <?php
- //Database Name fix replace weird chars
- if ($installType != INSTALL_TYPE_UPDATE) {
- $dbNameForm = str_replace(['-', '*', '$', ' ', '.'], '', $dbNameForm);
- }
- displayDatabaseParameter(
- $installType,
- get_lang('MainDB'),
- 'dbNameForm',
- $dbNameForm,
- ' ',
- null,
- 'id="optional_param1"'
- ); ?>
- </div>
- <?php if ($installType != INSTALL_TYPE_UPDATE) {
- ?>
- <div class="form-group">
- <div class="col-sm-3"></div>
- <div class="col-sm-9">
- <button type="submit" class="btn btn-primary" name="step3" value="step3">
- <em class="fa fa-refresh"> </em>
- <?php echo get_lang('CheckDatabaseConnection'); ?>
- </button>
- </div>
- </div>
- <?php
- } ?>
- </div>
- </div>
- <?php
- $database_exists_text = '';
- $manager = null;
- try {
- $manager = connectToDatabase(
- $dbHostForm,
- $dbUsernameForm,
- $dbPassForm,
- null,
- $dbPortForm
- );
- $databases = $manager->getConnection()->getSchemaManager()->listDatabases();
- if (in_array($dbNameForm, $databases)) {
- $database_exists_text = '<div class="alert alert-warning">'.get_lang('ADatabaseWithTheSameNameAlreadyExists').'</div>';
- }
- } catch (Exception $e) {
- $database_exists_text = $e->getMessage();
- }
- if ($manager && $manager->getConnection()->isConnected()): ?>
- <?php echo $database_exists_text ?>
- <div id="db_status" class="alert alert-success">
- Database host: <strong><?php echo $manager->getConnection()->getHost(); ?></strong><br/>
- Database port: <strong><?php echo $manager->getConnection()->getPort(); ?></strong><br/>
- Database driver: <strong><?php echo $manager->getConnection()->getDriver()->getName(); ?></strong><br/>
- </div>
- <?php else: ?>
- <div id="db_status" class="alert alert-danger">
- <p><?php echo get_lang('FailedConectionDatabase'); ?></strong></p>
- <code><?php echo $database_exists_text ?></code>
- </div>
- <?php endif; ?>
- <div class="form-group">
- <div class="col-sm-6">
- <button type="submit" name="step2" class="btn btn-default pull-right" value="< <?php echo get_lang('Previous'); ?>" >
- <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?>
- </button>
- </div>
- <div class="col-sm-6">
- <input type="hidden" name="is_executable" id="is_executable" value="-" />
- <?php if ($manager) {
- ?>
- <button type="submit" class="btn btn-success" name="step4" value="<?php echo get_lang('Next'); ?> >" >
- <em class="fa fa-forward"> </em> <?php echo get_lang('Next'); ?>
- </button>
- <?php
- } else {
- ?>
- <button disabled="disabled" type="submit" class="btn btn-success disabled" name="step4" value="<?php echo get_lang('Next'); ?> >" >
- <em class="fa fa-forward"> </em> <?php echo get_lang('Next'); ?>
- </button>
- <?php
- } ?>
- </div>
- </div>
- <?php
- }
- function panel($content = null, $title = null, $id = null, $style = null)
- {
- $html = '';
- if (empty($style)) {
- $style = 'default';
- }
- if (!empty($title)) {
- $panelTitle = Display::div($title, ['class' => 'panel-heading']);
- $panelBody = Display::div($content, ['class' => 'panel-body']);
- $panelParent = Display::div($panelTitle.$panelBody, ['id' => $id, 'class' => 'panel panel-'.$style]);
- } else {
- $panelBody = Display::div($html, ['class' => 'panel-body']);
- $panelParent = Display::div($panelBody, ['id' => $id, 'class' => 'panel panel-'.$style]);
- }
- $html .= $panelParent;
- return $html;
- }
- function display_configuration_parameter(
- $installType,
- $parameterName,
- $formFieldName,
- $parameterValue,
- $displayWhenUpdate = 'true'
- ) {
- $html = '<div class="form-group">';
- $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>';
- if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) {
- $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue;
- } else {
- $html .= '<div class="col-sm-6"><input class="form-control" type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'."</div>";
- }
- $html .= "</div>";
- return $html;
- }
- function display_configuration_settings_form(
- $installType,
- $urlForm,
- $languageForm,
- $emailForm,
- $adminFirstName,
- $adminLastName,
- $adminPhoneForm,
- $campusForm,
- $institutionForm,
- $institutionUrlForm,
- $encryptPassForm,
- $allowSelfReg,
- $allowSelfRegProf,
- $loginForm,
- $passForm
- ) {
- if ($installType != 'update' && empty($languageForm)) {
- $languageForm = $_SESSION['install_language'];
- }
- echo '<div class="RequirementHeading">';
- echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>";
- echo '</div>';
- echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>';
-
- $html = '';
- $html .= display_configuration_parameter($installType, get_lang('AdminLogin'), 'loginForm', $loginForm, $installType == 'update');
-
- if ($installType != 'update') {
- $html .= display_configuration_parameter($installType, get_lang('AdminPass'), 'passForm', $passForm, false);
- }
-
- $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
- $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
-
- $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
-
- $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
- echo panel($html, get_lang('Administrator'), 'administrator');
-
- $html = '<div class="form-group">';
- $html .= '<label class="col-sm-6 control-label">'.get_lang('MainLang')."</label>";
- if ($installType == 'update') {
- $html .= '<input type="hidden" name="languageForm" value="'.api_htmlentities($languageForm, ENT_QUOTES).'" />'.$languageForm;
- } else {
- $html .= '<div class="col-sm-6">';
- $html .= display_language_selection_box('languageForm', $languageForm);
- $html .= '</div>';
- }
- $html .= "</div>";
-
- $html .= '<div class="form-group">';
- $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>';
- if ($installType == 'update') {
- $html .= api_htmlentities($urlForm, ENT_QUOTES)."\n";
- } else {
- $html .= '<div class="col-sm-6">';
- $html .= '<input class="form-control" type="text" size="40" maxlength="100" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES).'" />';
- $html .= '</div>';
- }
- $html .= '</div>';
-
- $html .= display_configuration_parameter(
- $installType,
- get_lang('CampusName'),
- 'campusForm',
- $campusForm
- );
-
- $html .= display_configuration_parameter(
- $installType,
- get_lang('InstituteShortName'),
- 'institutionForm',
- $institutionForm
- );
-
- $html .= display_configuration_parameter(
- $installType,
- get_lang('InstituteURL'),
- 'institutionUrlForm',
- $institutionUrlForm
- );
- $html .= '<div class="form-group">
- <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label>
- <div class="col-sm-6">';
- if ($installType == 'update') {
- $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm;
- } else {
- $html .= '<div class="checkbox">
- <label>
- <input type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt
- </label>';
- $html .= '<label>
- <input type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1
- </label>';
- $html .= '<label>
- <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5
- </label>';
- $html .= '<label>
- <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').'
- </label>';
- $html .= '</div>';
- }
- $html .= '</div></div>';
- $html .= '<div class="form-group">
- <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label>
- <div class="col-sm-6">';
- if ($installType == 'update') {
- if ($allowSelfReg == 'true') {
- $label = get_lang('Yes');
- } elseif ($allowSelfReg == 'false') {
- $label = get_lang('No');
- } else {
- $label = get_lang('AfterApproval');
- }
- $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label;
- } else {
- $html .= '<div class="control-group">';
- $html .= '<label class="checkbox-inline">
- <input type="radio" name="allowSelfReg" value="true" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').'
- </label>';
- $html .= '<label class="checkbox-inline">
- <input type="radio" name="allowSelfReg" value="false" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').'
- </label>';
- $html .= '<label class="checkbox-inline">
- <input type="radio" name="allowSelfReg" value="approval" id="allowSelfReg2" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').'
- </label>';
- $html .= '</div>';
- }
- $html .= '</div>';
- $html .= '</div>';
- $html .= '<div class="form-group">';
- $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label>
- <div class="col-sm-6">';
- if ($installType == 'update') {
- if ($allowSelfRegProf == 'true') {
- $label = get_lang('Yes');
- } else {
- $label = get_lang('No');
- }
- $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label;
- } else {
- $html .= '<div class="control-group">
- <label class="checkbox-inline">
- <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/>
- ' . get_lang('Yes').'
- </label>';
- $html .= '<label class="checkbox-inline">
- <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' />
- '. get_lang('No').'
- </label>';
- $html .= '</div>';
- }
- $html .= '</div>
- </div>';
- echo panel($html, get_lang('Platform'), 'platform'); ?>
- <div class='form-group'>
- <div class="col-sm-6">
- <button type="submit" class="btn btn-default pull-right" name="step3" value="< <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button>
- <input type="hidden" name="is_executable" id="is_executable" value="-" />
- </div>
- <div class="col-sm-6">
- <button class="btn btn-success" type="submit" name="step5" value="<?php echo get_lang('Next'); ?> >" ><em class="fa fa-forward"> </em> <?php echo get_lang('Next'); ?></button>
- </div>
- </div>
- <?php
- }
- /**
- * After installation is completed (step 6), this message is displayed.
- * @param string $installType
- */
- function display_after_install_message($installType)
- {
- echo '<div class="RequirementContent">'.get_lang('FirstUseTip').'</div>';
- echo '<div class="alert alert-warning">';
- echo '<strong>'.get_lang('SecurityAdvice').'</strong>';
- echo ': ';
- printf(get_lang('ToProtectYourSiteMakeXReadOnlyAndDeleteY'), 'app/config/', 'main/install/');
- echo '</div>'; ?></form>
- <br />
- <a class="btn btn-success btn-block" href="../../index.php">
- <?php echo get_lang('GoToYourNewlyCreatedPortal'); ?>
- </a>
- <?php
- }
- /**
- * This function return countries list from array (hardcoded)
- * @param bool $combo (Optional) True for returning countries list with select html
- * @return array|string countries list
- */
- function get_countries_list_from_array($combo = false)
- {
- $a_countries = [
- "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan",
- "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
- "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic",
- "Denmark", "Djibouti", "Dominica", "Dominican Republic",
- "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia",
- "Fiji", "Finland", "France",
- "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana",
- "Haiti", "Honduras", "Hungary",
- "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy",
- "Jamaica", "Japan", "Jordan",
- "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan",
- "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
- "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar",
- "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway",
- "Oman",
- "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal",
- "Qatar",
- "Romania", "Russia", "Rwanda",
- "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria",
- "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu",
- "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan",
- "Vanuatu", "Vatican City", "Venezuela", "Vietnam",
- "Yemen",
- "Zambia", "Zimbabwe"
- ];
- $country_select = '';
- if ($combo) {
- $country_select = '<select class="selectpicker show-tick" id="country" name="country">';
- $country_select .= '<option value="">--- '.get_lang('SelectOne').' ---</option>';
- foreach ($a_countries as $country) {
- $country_select .= '<option value="'.$country.'">'.$country.'</option>';
- }
- $country_select .= '</select>';
- return $country_select;
- }
- return $a_countries;
- }
- function lockSettings()
- {
- $access_url_locked_settings = api_get_locked_settings();
- $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
- foreach ($access_url_locked_settings as $setting) {
- $sql = "UPDATE $table SET access_url_locked = 1 WHERE variable = '$setting'";
- Database::query($sql);
- }
- }
- function updateDirAndFilesPermissions()
- {
- $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
- $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770;
- $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660;
-
- $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."'
- WHERE variable = 'permissions_for_new_directories'";
- Database::query($sql);
- $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable = 'permissions_for_new_files'";
- Database::query($sql);
- if (isset($_SESSION['permissions_for_new_directories'])) {
- unset($_SESSION['permissions_for_new_directories']);
- }
- if (isset($_SESSION['permissions_for_new_files'])) {
- unset($_SESSION['permissions_for_new_files']);
- }
- }
- function compare_setting_values($current_value, $wanted_value)
- {
- $current_value_string = $current_value;
- $current_value = (float) $current_value;
- $wanted_value = (float) $wanted_value;
- if ($current_value >= $wanted_value) {
- return Display::label($current_value_string, 'success');
- } else {
- return Display::label($current_value_string, 'important');
- }
- }
- function check_course_script_interpretation(
- $course_dir,
- $course_attempt_name,
- $file = 'test.php'
- ) {
- $output = false;
-
- $file_name = $course_dir.'/'.$file;
- $content = '<?php echo "123"; exit;';
- if (is_writable($file_name)) {
- if ($handler = @fopen($file_name, "w")) {
-
- if (fwrite($handler, $content)) {
- $sock_errno = '';
- $sock_errmsg = '';
- $url = api_get_path(WEB_PATH).'app/courses/'.$course_attempt_name.'/'.$file;
- $parsed_url = parse_url($url);
-
- $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
-
-
-
- if (empty($host) && !empty($_SERVER['HTTP_HOST'])) {
- $host = $_SERVER['HTTP_HOST'];
- $url = preg_replace('#:///#', '://'.$host.'/', $url);
- }
- $path = isset($parsed_url['path']) ? $parsed_url['path'] : '/';
- $port = '';
- $scheme = '';
- switch ($parsed_url['scheme']) {
- case 'https':
- $scheme = 'ssl://';
- $port = 443;
- break;
- case 'http':
- default:
- $scheme = '';
- $port = 80;
- }
-
-
- if ($fp = @fsockopen(str_replace('http://', $scheme, $url), $port, $sock_errno, $sock_errmsg, 60)) {
- $out = "GET $path HTTP/1.1\r\n";
- $out .= "Host: $host\r\n";
- $out .= "Connection: Close\r\n\r\n";
- fwrite($fp, $out);
- while (!feof($fp)) {
- $result = str_replace("\r\n", '', fgets($fp, 128));
- if (!empty($result) && $result == '123') {
- $output = true;
- }
- }
- fclose($fp);
- } elseif (ini_get('allow_url_fopen')) {
-
- if ($fp = @fopen($url, 'r')) {
- while ($result = fgets($fp, 1024)) {
- if (!empty($result) && $result == '123') {
- $output = true;
- }
- }
- fclose($fp);
- }
- } elseif (function_exists('curl_init')) {
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_URL, $url);
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $result = curl_exec($ch);
- if (!empty($result) && $result == '123') {
- $output = true;
- }
- curl_close($ch);
- }
- }
- @fclose($handler);
- }
- }
- return $output;
- }
- function installSettings(
- $organizationName,
- $organizationUrl,
- $siteName,
- $adminEmail,
- $adminLastName,
- $adminFirstName,
- $language,
- $allowRegistration,
- $allowTeacherSelfRegistration,
- $installationProfile = ''
- ) {
- $allowTeacherSelfRegistration = $allowTeacherSelfRegistration ? 'true' : 'false';
-
- $settings = [
- 'Institution' => $organizationName,
- 'InstitutionUrl' => $organizationUrl,
- 'siteName' => $siteName,
- 'emailAdministrator' => $adminEmail,
- 'administratorSurname' => $adminLastName,
- 'administratorName' => $adminFirstName,
- 'platformLanguage' => $language,
- 'allow_registration' => $allowRegistration,
- 'allow_registration_as_teacher' => $allowTeacherSelfRegistration,
- ];
- foreach ($settings as $variable => $value) {
- $sql = "UPDATE settings_current
- SET selected_value = '$value'
- WHERE variable = '$variable'";
- Database::query($sql);
- }
- installProfileSettings($installationProfile);
- }
- function migrate($chamiloVersion, EntityManager $manager)
- {
- $debug = true;
- $connection = $manager->getConnection();
- $config = new \Doctrine\DBAL\Migrations\Configuration\Configuration($connection);
-
-
- $config->setMigrationsTableName('version');
-
- $config->setMigrationsNamespace('Application\Migrations\Schema\V'.$chamiloVersion);
-
- $config->setMigrationsDirectory(api_get_path(SYS_PATH).'app/Migrations/Schema/V'.$chamiloVersion);
-
- $config->registerMigrationsFromDirectory($config->getMigrationsDirectory());
- $migration = new \Doctrine\DBAL\Migrations\Migration($config);
- $versions = $config->getMigrations();
-
- foreach ($versions as $version) {
- $version->getMigration()->setEntityManager($manager);
- }
- $to = null;
- echo "<pre>";
- try {
-
- $migratedSQL = $migration->migrate($to);
- if ($debug) {
- foreach ($migratedSQL as $version => $sqlList) {
- echo "VERSION: $version<br>";
- echo "----------------------------------------------<br>";
- $total = count($sqlList);
- error_log("VERSION: $version");
- error_log("# queries: ".$total);
- $counter = 1;
- foreach ($sqlList as $sql) {
- echo "<code>$sql</code><br>";
- error_log("$counter/$total : $sql");
- $counter++;
- }
- }
- echo "<br>DONE!<br>";
- }
- return true;
- } catch (Exception $ex) {
- if ($debug) {
- echo "ERROR: {$ex->getMessage()}<br>";
- return false;
- }
- }
- echo "</pre>";
- return false;
- }
- function fixIds(EntityManager $em)
- {
- $connection = $em->getConnection();
- $database = new Database();
- $database->setManager($em);
- $debug = true;
- if ($debug) {
- error_log('fixIds');
- }
-
-
-
-
- $sql = "ALTER TABLE c_document ADD INDEX tmpidx_doc(c_id, id)";
- $connection->executeQuery($sql);
- $sql = "ALTER TABLE c_student_publication ADD INDEX tmpidx_stud (c_id, id)";
- $connection->executeQuery($sql);
- $sql = "ALTER TABLE c_quiz ADD INDEX tmpidx_quiz (c_id, id)";
- $connection->executeQuery($sql);
- $sql = "ALTER TABLE c_item_property ADD INDEX tmpidx_ip (to_group_id)";
- $connection->executeQuery($sql);
- $sql = "SELECT * FROM c_lp_item";
- $result = $connection->fetchAll($sql);
- foreach ($result as $item) {
- $courseId = $item['c_id'];
- $iid = isset($item['iid']) ? intval($item['iid']) : 0;
- $ref = isset($item['ref']) ? intval($item['ref']) : 0;
- $sql = null;
- $newId = '';
- switch ($item['item_type']) {
- case TOOL_LINK:
- $sql = "SELECT * FROM c_link WHERE c_id = $courseId AND id = $ref";
- $data = $connection->fetchAssoc($sql);
- if ($data) {
- $newId = $data['iid'];
- }
- break;
- case TOOL_STUDENTPUBLICATION:
- $sql = "SELECT * FROM c_student_publication WHERE c_id = $courseId AND id = $ref";
- $data = $connection->fetchAssoc($sql);
- if ($data) {
- $newId = $data['iid'];
- }
- break;
- case TOOL_QUIZ:
- $sql = "SELECT * FROM c_quiz WHERE c_id = $courseId AND id = $ref";
- $data = $connection->fetchAssoc($sql);
- if ($data) {
- $newId = $data['iid'];
- }
- break;
- case TOOL_DOCUMENT:
- $sql = "SELECT * FROM c_document WHERE c_id = $courseId AND id = $ref";
- $data = $connection->fetchAssoc($sql);
- if ($data) {
- $newId = $data['iid'];
- }
- break;
- case TOOL_FORUM:
- $sql = "SELECT * FROM c_forum_forum WHERE c_id = $courseId AND forum_id = $ref";
- $data = $connection->fetchAssoc($sql);
- if ($data) {
- $newId = $data['iid'];
- }
- break;
- case 'thread':
- $sql = "SELECT * FROM c_forum_thread WHERE c_id = $courseId AND thread_id = $ref";
- $data = $connection->fetchAssoc($sql);
- if ($data) {
- $newId = $data['iid'];
- }
- break;
- }
- if (!empty($sql) && !empty($newId) && !empty($iid)) {
- $sql = "UPDATE c_lp_item SET ref = $newId WHERE iid = $iid";
- $connection->executeQuery($sql);
- }
- }
-
- $sql = "UPDATE c_item_property SET session_id = NULL WHERE session_id = 0";
- $connection->executeQuery($sql);
-
- $sql = "UPDATE c_item_property SET to_group_id = NULL WHERE to_group_id = 0";
- $connection->executeQuery($sql);
-
- $sql = "UPDATE c_item_property SET insert_user_id = NULL WHERE insert_user_id = 0";
- $connection->executeQuery($sql);
-
- $sql = "DELETE FROM c_item_property
- WHERE session_id IS NOT NULL AND session_id NOT IN (SELECT id FROM session)";
- $connection->executeQuery($sql);
-
- $sql = "DELETE FROM c_item_property
- WHERE to_group_id IS NOT NULL AND to_group_id NOT IN (SELECT DISTINCT id FROM c_group_info)";
- $connection->executeQuery($sql);
-
- if ($debug) {
- error_log('update iids');
- }
- $groupTableToFix = [
- 'c_group_rel_user',
- 'c_group_rel_tutor',
- 'c_permission_group',
- 'c_role_group',
- 'c_survey_invitation',
- 'c_attendance_calendar_rel_group'
- ];
- foreach ($groupTableToFix as $table) {
- $sql = "SELECT * FROM $table";
- $result = $connection->fetchAll($sql);
- foreach ($result as $item) {
- $iid = $item['iid'];
- $courseId = $item['c_id'];
- $groupId = intval($item['group_id']);
-
- if (!empty($groupId)) {
- $sql = "SELECT * FROM c_group_info
- WHERE c_id = $courseId AND id = $groupId
- LIMIT 1";
- $data = $connection->fetchAssoc($sql);
- if (!empty($data)) {
- $newGroupId = $data['iid'];
- $sql = "UPDATE $table SET group_id = $newGroupId
- WHERE iid = $iid";
- $connection->executeQuery($sql);
- } else {
-
- $sql = "DELETE FROM $table WHERE iid = $iid";
- $connection->executeQuery($sql);
- }
- }
- }
- }
-
- if ($debug) {
- error_log('update c_item_property');
- }
- $sql = "SELECT * FROM course";
- $courseList = $connection->fetchAll($sql);
- if ($debug) {
- error_log('Getting course list');
- }
- $totalCourse = count($courseList);
- $counter = 0;
- foreach ($courseList as $courseData) {
- $courseId = $courseData['id'];
- if ($debug) {
- error_log('Updating course: '.$courseData['code']);
- }
- $sql = "SELECT * FROM c_item_property WHERE c_id = $courseId";
- $result = $connection->fetchAll($sql);
- foreach ($result as $item) {
- $sessionId = intval($item['session_id']);
- $groupId = intval($item['to_group_id']);
- $iid = $item['iid'];
- $ref = $item['ref'];
-
- if (!empty($groupId)) {
- $sql = "SELECT * FROM c_group_info
- WHERE c_id = $courseId AND id = $groupId";
- $data = $connection->fetchAssoc($sql);
- if (!empty($data)) {
- $newGroupId = $data['iid'];
- $sql = "UPDATE c_item_property SET to_group_id = $newGroupId
- WHERE iid = $iid";
- $connection->executeQuery($sql);
- } else {
-
- $sql = "DELETE FROM c_item_property WHERE iid = $iid";
- $connection->executeQuery($sql);
- }
- }
- $sql = '';
- $newId = '';
- switch ($item['tool']) {
- case TOOL_LINK:
- $sql = "SELECT * FROM c_link WHERE c_id = $courseId AND id = $ref ";
- break;
- case TOOL_STUDENTPUBLICATION:
- $sql = "SELECT * FROM c_student_publication WHERE c_id = $courseId AND id = $ref";
- break;
- case TOOL_QUIZ:
- $sql = "SELECT * FROM c_quiz WHERE c_id = $courseId AND id = $ref";
- break;
- case TOOL_DOCUMENT:
- $sql = "SELECT * FROM c_document WHERE c_id = $courseId AND id = $ref";
- break;
- case TOOL_FORUM:
- $sql = "SELECT * FROM c_forum_forum WHERE c_id = $courseId AND id = $ref";
- break;
- case 'thread':
- $sql = "SELECT * FROM c_forum_thread WHERE c_id = $courseId AND id = $ref";
- break;
- }
- if (!empty($sql) && !empty($newId)) {
- $data = $connection->fetchAssoc($sql);
- if (isset($data['iid'])) {
- $newId = $data['iid'];
- }
- $sql = "UPDATE c_item_property SET ref = $newId WHERE iid = $iid";
- error_log($sql);
- $connection->executeQuery($sql);
- }
- }
- if ($debug) {
-
- error_log("Course process #$counter/$totalCourse");
- }
- $counter++;
- }
- if ($debug) {
- error_log('update gradebook_link');
- }
-
- $sql = "SELECT * FROM gradebook_link";
- $result = $connection->fetchAll($sql);
- foreach ($result as $item) {
- $courseCode = $item['course_code'];
- $sql = "SELECT * FROM course WHERE code = '$courseCode'";
- $courseInfo = $connection->fetchAssoc($sql);
- if (empty($courseInfo)) {
- continue;
- }
- $courseId = $courseInfo['id'];
- $ref = $item['ref_id'];
- $iid = $item['id'];
- $sql = '';
- switch ($item['type']) {
- case LINK_LEARNPATH:
- $sql = "SELECT * FROM c_link WHERE c_id = $courseId AND id = $ref ";
- break;
- case LINK_STUDENTPUBLICATION:
- $sql = "SELECT * FROM c_student_publication WHERE c_id = $courseId AND id = $ref";
- break;
- case LINK_EXERCISE:
- $sql = "SELECT * FROM c_quiz WHERE c_id = $courseId AND id = $ref";
- break;
- case LINK_ATTENDANCE:
-
- break;
- case LINK_FORUM_THREAD:
- $sql = "SELECT * FROM c_forum_thread WHERE c_id = $courseId AND thread_id = $ref";
- break;
- }
- if (!empty($sql)) {
- $data = $connection->fetchAssoc($sql);
- if (isset($data) && isset($data['iid'])) {
- $newId = $data['iid'];
- $sql = "UPDATE gradebook_link SET ref_id = $newId
- WHERE id = $iid";
- $connection->executeQuery($sql);
- }
- }
- }
- if ($debug) {
- error_log('update groups');
- }
- $sql = "SELECT * FROM groups";
- $result = $connection->executeQuery($sql);
- $groups = $result->fetchAll();
- $oldGroups = [];
- if (!empty($groups)) {
- foreach ($groups as $group) {
- if (empty($group['name'])) {
- continue;
- }
- $params = [
- 'name' => $group['name'],
- 'description' => $group['description'],
- 'group_type' => 1,
- 'picture' => $group['picture_uri'],
- 'url' => $group['url'],
- 'visibility' => $group['visibility'],
- 'updated_at' => $group['updated_on'],
- 'created_at' => $group['created_on']
- ];
- $connection->insert('usergroup', $params);
- $id = $connection->lastInsertId('id');
- $oldGroups[$group['id']] = $id;
- }
- }
- if (!empty($oldGroups)) {
- error_log('Moving group files');
- foreach ($oldGroups as $oldId => $newId) {
- $path = get_group_picture_path_by_id(
- $oldId,
- 'system'
- );
- if (!empty($path)) {
- $newPath = str_replace(
- "groups/$oldId/",
- "groups/$newId/",
- $path['dir']
- );
- $command = "mv {$path['dir']} $newPath ";
- error_log("Executing $command");
- system($command);
- }
- }
- $sql = "SELECT * FROM group_rel_user";
- $result = $connection->executeQuery($sql);
- $dataList = $result->fetchAll();
- if (!empty($dataList)) {
- foreach ($dataList as $data) {
- if (isset($oldGroups[$data['group_id']])) {
- $data['group_id'] = $oldGroups[$data['group_id']];
- $userId = $data['user_id'];
- $sql = "SELECT id FROM user WHERE user_id = $userId";
- $userResult = $connection->executeQuery($sql);
- $userInfo = $userResult->fetch();
- if (empty($userInfo)) {
- continue;
- }
- $sql = "INSERT INTO usergroup_rel_user (usergroup_id, user_id, relation_type)
- VALUES ('{$data['group_id']}', '{$userId}', '{$data['relation_type']}')";
- $connection->executeQuery($sql);
- }
- }
- }
- $sql = "SELECT * FROM group_rel_group";
- $result = $connection->executeQuery($sql);
- $dataList = $result->fetchAll();
- if (!empty($dataList)) {
- foreach ($dataList as $data) {
- if (isset($oldGroups[$data['group_id']]) && isset($oldGroups[$data['subgroup_id']])) {
- $data['group_id'] = $oldGroups[$data['group_id']];
- $data['subgroup_id'] = $oldGroups[$data['subgroup_id']];
- $sql = "INSERT INTO usergroup_rel_usergroup (group_id, subgroup_id, relation_type)
- VALUES ('{$data['group_id']}', '{$data['subgroup_id']}', '{$data['relation_type']}')";
- $connection->executeQuery($sql);
- }
- }
- }
- $sql = "SELECT * FROM announcement_rel_group";
- $result = $connection->executeQuery($sql);
- $dataList = $result->fetchAll();
- if (!empty($dataList)) {
- foreach ($dataList as $data) {
- if (isset($oldGroups[$data['group_id']])) {
-
- $sql = "DELETE FROM announcement_rel_group WHERE group_id = {$data['group_id']}";
- $connection->executeQuery($sql);
-
- $data['group_id'] = $oldGroups[$data['group_id']];
- $sql = "INSERT INTO announcement_rel_group(group_id, announcement_id)
- VALUES ('{$data['group_id']}', '{$data['announcement_id']}')";
- $connection->executeQuery($sql);
- }
- }
- }
- $sql = "SELECT * FROM group_rel_tag";
- $result = $connection->executeQuery($sql);
- $dataList = $result->fetchAll();
- if (!empty($dataList)) {
- foreach ($dataList as $data) {
- if (isset($oldGroups[$data['group_id']])) {
- $data['group_id'] = $oldGroups[$data['group_id']];
- $sql = "INSERT INTO usergroup_rel_tag (tag_id, usergroup_id)
- VALUES ('{$data['tag_id']}', '{$data['group_id']}')";
- $connection->executeQuery($sql);
- }
- }
- }
- }
- if ($debug) {
- error_log('update extra fields');
- }
-
- $extraFieldTables = [
- ExtraField::USER_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_USER_FIELD),
- ExtraField::COURSE_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_COURSE_FIELD),
-
- ExtraField::SESSION_FIELD_TYPE => Database::get_main_table(TABLE_MAIN_SESSION_FIELD),
-
-
-
- ];
- foreach ($extraFieldTables as $type => $table) {
- $sql = "SELECT * FROM $table ";
- if ($debug) {
- error_log($sql);
- }
- $result = $connection->query($sql);
- $fields = $result->fetchAll();
- foreach ($fields as $field) {
- if ($debug) {
- error_log("Loading field: ".$field['field_variable']);
- }
- $originalId = $field['id'];
- $params = [
- 'extra_field_type' => $type,
- 'variable' => $field['field_variable'],
- 'field_type' => $field['field_type'],
- 'display_text' => $field['field_display_text'],
- 'default_value' => $field['field_default_value'],
- 'field_order' => $field['field_order'],
- 'visible' => $field['field_visible'],
- 'changeable' => $field['field_changeable'],
- 'filter' => $field['field_filter']
- ];
- $connection->insert('extra_field', $params);
- $newExtraFieldId = $connection->lastInsertId();
- $values = [];
- $handlerId = null;
- switch ($type) {
- case ExtraField::USER_FIELD_TYPE:
- $optionTable = Database::get_main_table(
- TABLE_MAIN_USER_FIELD_OPTIONS
- );
- $valueTable = Database::get_main_table(
- TABLE_MAIN_USER_FIELD_VALUES
- );
- $handlerId = 'user_id';
- break;
- case ExtraField::COURSE_FIELD_TYPE:
- $optionTable = Database::get_main_table(
- TABLE_MAIN_COURSE_FIELD_OPTIONS
- );
- $valueTable = Database::get_main_table(
- TABLE_MAIN_COURSE_FIELD_VALUES
- );
- $handlerId = 'c_id';
- break;
- case ExtraField::SESSION_FIELD_TYPE:
- $optionTable = Database::get_main_table(
- TABLE_MAIN_SESSION_FIELD_OPTIONS
- );
- $valueTable = Database::get_main_table(
- TABLE_MAIN_SESSION_FIELD_VALUES
- );
- $handlerId = 'session_id';
- break;
- }
- if (!empty($optionTable)) {
- $sql = "SELECT * FROM $optionTable WHERE field_id = $originalId ";
- $result = $connection->query($sql);
- $options = $result->fetchAll();
- foreach ($options as $option) {
- $params = [
- 'display_text' => $option['option_display_text'],
- 'field_id' => $newExtraFieldId,
- 'option_order' => $option['option_order'],
- 'option_value' => $option['option_value']
- ];
- $connection->insert('extra_field_options', $params);
- }
- $sql = "SELECT * FROM $valueTable WHERE field_id = $originalId ";
- $result = $connection->query($sql);
- $values = $result->fetchAll();
- if ($debug) {
- error_log("Fetch all values for field");
- }
- }
- if (!empty($values)) {
- if ($debug) {
- error_log("Saving field value in new table");
- }
- $k = 0;
- foreach ($values as $value) {
- if (isset($value[$handlerId])) {
-
-
- $params = [
- 'field_id' => $newExtraFieldId,
- 'value' => $value['field_value'],
- 'item_id' => $value[$handlerId]
- ];
- $connection->insert('extra_field_values', $params);
- if ($debug && ($k % 10000 == 0)) {
- error_log("Saving field $k");
- }
- $k++;
- }
- }
- }
- }
- }
- if ($debug) {
- error_log('Remove index');
- }
-
- $sql = "ALTER TABLE c_document DROP INDEX tmpidx_doc";
- $connection->executeQuery($sql);
- $sql = "ALTER TABLE c_student_publication DROP INDEX tmpidx_stud";
- $connection->executeQuery($sql);
- $sql = "ALTER TABLE c_quiz DROP INDEX tmpidx_quiz";
- $connection->executeQuery($sql);
- $sql = "ALTER TABLE c_item_property DROP INDEX tmpidx_ip";
- $connection->executeQuery($sql);
- if ($debug) {
- error_log('Finish fixId function');
- }
- }
- function updateEnvFile($distFile, $envFile, $params)
- {
- $contents = file_get_contents($distFile);
- $contents = str_replace(array_keys($params), array_values($params), $contents);
- file_put_contents($envFile, $contents);
- }
- function finishInstallationWithContainer(
- Container $container,
- $manager,
- $sysPath,
- $encryptPassForm,
- $passForm,
- $adminLastName,
- $adminFirstName,
- $loginForm,
- $emailForm,
- $adminPhoneForm,
- $languageForm,
- $institutionForm,
- $institutionUrlForm,
- $siteName,
- $allowSelfReg,
- $allowSelfRegProf,
- $installationProfile = ''
- ) {
- $sysPath = !empty($sysPath) ? $sysPath : api_get_path(SYS_PATH);
- $connection = $manager->getConnection();
- Database::setConnection($connection);
- Database::setManager($manager);
- $sql = getVersionTable();
-
- $connection->executeQuery($sql);
-
- $ticketProject = new TicketProject();
- $ticketProject
- ->setId(1)
- ->setName('Ticket System')
- ->setInsertUserId(1);
- $manager->persist($ticketProject);
- $manager->flush();
- $categories = [
- get_lang('TicketEnrollment') => get_lang('TicketsAboutEnrollment'),
- get_lang('TicketGeneralInformation') => get_lang('TicketsAboutGeneralInformation'),
- get_lang('TicketRequestAndPapework') => get_lang('TicketsAboutRequestAndPapework'),
- get_lang('TicketAcademicIncidence') => get_lang('TicketsAboutAcademicIncidence'),
- get_lang('TicketVirtualCampus') => get_lang('TicketsAboutVirtualCampus'),
- get_lang('TicketOnlineEvaluation') => get_lang('TicketsAboutOnlineEvaluation')
- ];
- $i = 1;
- foreach ($categories as $category => $description) {
-
- $ticketCategory = new TicketCategory();
- $ticketCategory
- ->setId($i)
- ->setName($category)
- ->setDescription($description)
- ->setProject($ticketProject)
- ->setInsertUserId(1);
- $isRequired = $i == 6;
- $ticketCategory->setCourseRequired($isRequired);
- $manager->persist($ticketCategory);
- $manager->flush();
- $i++;
- }
-
- $defaultPriorities = [
- TicketManager::PRIORITY_NORMAL => get_lang('PriorityNormal'),
- TicketManager::PRIORITY_HIGH => get_lang('PriorityHigh'),
- TicketManager::PRIORITY_LOW => get_lang('PriorityLow')
- ];
- $i = 1;
- foreach ($defaultPriorities as $code => $priority) {
- $ticketPriority = new TicketPriority();
- $ticketPriority
- ->setId($i)
- ->setName($priority)
- ->setCode($code)
- ->setInsertUserId(1);
- $manager->persist($ticketPriority);
- $manager->flush();
- $i++;
- }
- $table = Database::get_main_table(TABLE_TICKET_STATUS);
-
- $defaultStatus = [
- TicketManager::STATUS_NEW => get_lang('StatusNew'),
- TicketManager::STATUS_PENDING => get_lang('StatusPending'),
- TicketManager::STATUS_UNCONFIRMED => get_lang('StatusUnconfirmed'),
- TicketManager::STATUS_CLOSE => get_lang('StatusClose'),
- TicketManager::STATUS_FORWARDED => get_lang('StatusForwarded')
- ];
- $i = 1;
- foreach ($defaultStatus as $code => $status) {
- $attributes = [
- 'id' => $i,
- 'code' => $code,
- 'name' => $status
- ];
- Database::insert($table, $attributes);
- $i++;
- }
- $accessUrl = new \Chamilo\CoreBundle\Entity\AccessUrl();
- $accessUrl
- ->setUrl('http://localhost/')
- ->setDescription('')
- ->setActive(1)
- ;
- $manager->persist($accessUrl);
- $manager->flush();
- $settingsManager = $container->get('chamilo.settings.manager');
- $settingsManager->installSchemas($accessUrl);
-
- UserManager::setPasswordEncryption($encryptPassForm);
-
- @UserManager::create_user(
- $adminFirstName,
- $adminLastName,
- 1,
- $emailForm,
- $loginForm,
- $passForm,
- 'ADMIN',
- $languageForm,
- $adminPhoneForm,
- '',
- PLATFORM_AUTH_SOURCE,
- '',
- 1,
- 0,
- null,
- '',
- false,
- true,
- '',
- false,
- '',
- 1
- );
-
- @UserManager::create_user(
- 'Joe',
- 'Anonymous',
- 6,
- 'anonymous@localhost',
- 'anon',
- 'anon',
- 'anonymous',
- $languageForm,
- '',
- '',
- PLATFORM_AUTH_SOURCE,
- '',
- 1,
- 0,
- null,
- '',
- false,
- false,
- '',
- false,
- '',
- 1
- );
-
- $sql = "UPDATE language SET available = 1 WHERE dokeos_folder = '$languageForm'";
- Database::query($sql);
-
- installSettings(
- $institutionForm,
- $institutionUrlForm,
- $siteName,
- $emailForm,
- $adminLastName,
- $adminFirstName,
- $languageForm,
- $allowSelfReg,
- $allowSelfRegProf,
- $installationProfile
- );
- lockSettings();
- updateDirAndFilesPermissions();
-
- $path = $sysPath.'app/Migrations/Schema/V111/';
- $finder = new \Symfony\Component\Finder\Finder();
- $files = $finder->files()->in($path);
-
- createVersionTable();
- foreach ($files as $version) {
- $version = str_replace(['Version', '.php'], '', $version->getFilename());
- $sql = "INSERT INTO version (version) VALUES ('$version')";
- Database::query($sql);
- }
- }
- function createVersionTable()
- {
- $sql = getVersionTable();
- Database::query($sql);
- }
- function getVersionTable()
- {
- return 'CREATE TABLE IF NOT EXISTS version (id int unsigned NOT NULL AUTO_INCREMENT, version varchar(20), PRIMARY KEY(id), UNIQUE(version));';
- }
- function installProfileSettings($installationProfile = '')
- {
- if (empty($installationProfile)) {
- return false;
- }
- $jsonPath = api_get_path(SYS_PATH).'main/install/profiles/'.$installationProfile.'.json';
-
- if (!Security::check_abs_path($jsonPath, api_get_path(SYS_PATH).'main/install/profiles/')) {
- return false;
- }
- if (!is_file($jsonPath)) {
- return false;
- }
- if (!is_readable($jsonPath)) {
- return false;
- }
- if (!function_exists('json_decode')) {
-
- return false;
- }
- $json = file_get_contents($jsonPath);
- $params = json_decode($json);
- if ($params === false or $params === null) {
- return false;
- }
- $settings = $params->params;
- if (!empty($params->parent)) {
- installProfileSettings($params->parent);
- }
- foreach ($settings as $id => $param) {
- $sql = "UPDATE settings_current
- SET selected_value = '".$param->selected_value."'
- WHERE variable = '".$param->variable."'";
- if (!empty($param->subkey)) {
- $sql .= " AND subkey='".$param->subkey."'";
- }
- Database::query($sql);
- }
- return true;
- }
- function rrmdir($dir)
- {
- if (is_dir($dir)) {
- $objects = scandir($dir);
- foreach ($objects as $object) {
- if ($object != "." && $object != "..") {
- if (filetype($dir."/".$object) == "dir") {
- @rrmdir($dir."/".$object);
- } else {
- @unlink($dir."/".$object);
- }
- }
- }
- reset($objects);
- rmdir($dir);
- }
- }
- function get_group_picture_path_by_id($id, $type = 'web', $preview = false, $anonymous = false)
- {
- switch ($type) {
- case 'system':
- $base = api_get_path(SYS_UPLOAD_PATH);
- break;
- case 'web':
- default:
- $base = api_get_path(WEB_UPLOAD_PATH);
- break;
- }
- $noPicturePath = ['dir' => $base.'img/', 'file' => 'unknown.jpg'];
- if (empty($id) || empty($type)) {
- return $anonymous ? $noPicturePath : ['dir' => '', 'file' => ''];
- }
- $id = intval($id);
-
- $group_table = 'groups';
- $sql = "SELECT picture_uri FROM $group_table WHERE id=".$id;
- $res = Database::query($sql);
- if (!Database::num_rows($res)) {
- return $anonymous ? $noPicturePath : ['dir' => '', 'file' => ''];
- }
- $user = Database::fetch_array($res);
- $picture_filename = trim($user['picture_uri']);
- if (api_get_setting('split_users_upload_directory') === 'true') {
- if (!empty($picture_filename)) {
- $dir = $base.'groups/'.substr($picture_filename, 0, 1).'/'.$id.'/';
- } elseif ($preview) {
- $dir = $base.'groups/'.substr((string) $id, 0, 1).'/'.$id.'/';
- } else {
- $dir = $base.'groups/'.$id.'/';
- }
- } else {
- $dir = $base.'groups/'.$id.'/';
- }
- if (empty($picture_filename) && $anonymous) {
- return $noPicturePath;
- }
- return ['dir' => $dir, 'file' => $picture_filename];
- }
- function migrateSwitch($fromVersion, $manager, $processFiles = true)
- {
- error_log('Starting migration process from '.$fromVersion.' ('.date('Y-m-d H:i:s').')');
- echo '<a class="btn btn-default" href="javascript:void(0)" id="details_button">'.get_lang('Details').'</a><br />';
- echo '<div id="details" style="display:none">';
- $connection = $manager->getConnection();
- $database = new Database();
- $database->setManager($manager);
- switch ($fromVersion) {
- case '1.9.0':
- case '1.9.2':
- case '1.9.4':
- case '1.9.6':
- case '1.9.6.1':
- case '1.9.8':
- case '1.9.8.1':
- case '1.9.8.2':
- case '1.9.10':
- case '1.9.10.2':
- case '1.9.10.4':
- case '1.9.10.6':
- $database = new Database();
- $database->setManager($manager);
-
- $connection->executeQuery("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'");
- $connection->executeQuery("ALTER TABLE course_category MODIFY COLUMN auth_cat_child VARCHAR(40) DEFAULT 'TRUE'");
- $connection->executeQuery("ALTER TABLE c_quiz_answer MODIFY COLUMN hotspot_type varchar(40) default NULL");
- $connection->executeQuery("ALTER TABLE c_tool MODIFY COLUMN target varchar(20) NOT NULL default '_self'");
- $connection->executeQuery("ALTER TABLE c_link MODIFY COLUMN on_homepage char(10) NOT NULL default '0'");
- $connection->executeQuery("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post'");
- $connection->executeQuery("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'");
- $connection->executeQuery("ALTER TABLE c_document MODIFY COLUMN filetype char(10) NOT NULL default 'file'");
- $connection->executeQuery("ALTER TABLE c_student_publication MODIFY COLUMN filetype char(10) NOT NULL default 'file'");
-
-
- $result = migrate(
- 110,
- $manager
- );
- if ($result) {
- error_log('Migrations files were executed ('.date('Y-m-d H:i:s').')');
- fixIds($manager);
- error_log('fixIds finished ('.date('Y-m-d H:i:s').')');
- $connection->executeQuery("UPDATE settings_current SET selected_value = '1.10.0' WHERE variable = 'chamilo_database_version'");
- if ($processFiles) {
- $fromVersionShort = '1.9';
- include __DIR__.'/update-files-1.9.0-1.10.0.inc.php';
-
- include __DIR__.'/update-configuration.inc.php';
- $configurationFiles = [
- 'mail.conf.php',
- 'profile.conf.php',
- 'course_info.conf.php',
- 'add_course.conf.php',
- 'events.conf.php',
- 'auth.conf.php'
- ];
- error_log('Copy conf files');
- foreach ($configurationFiles as $file) {
- if (file_exists(api_get_path(SYS_CODE_PATH).'inc/conf/'.$file)) {
- copy(
- api_get_path(SYS_CODE_PATH).'inc/conf/'.$file,
- api_get_path(CONFIGURATION_PATH).$file
- );
- }
- }
- }
- error_log('Upgrade 1.10.x process concluded! ('.date('Y-m-d H:i:s').')');
- } else {
- error_log('There was an error during running migrations. Check error.log');
- break;
- }
-
- case '1.10.0':
- case '1.10.2':
- case '1.10.4':
- case '1.10.6':
- case '1.10.8':
- $database = new Database();
- $database->setManager($manager);
-
-
- $result = migrate(
- 111,
- $manager
- );
- if ($result) {
- error_log('Migrations files were executed ('.date('Y-m-d H:i:s').')');
- fixPostGroupIds($connection);
- $sql = "UPDATE settings_current SET selected_value = '1.11.0' WHERE variable = 'chamilo_database_version'";
- $connection->executeQuery($sql);
- if ($processFiles) {
- error_log('Update config files');
- $fromVersionShort = '1.10';
- include __DIR__.'/update-files-1.10.0-1.11.0.inc.php';
-
- include __DIR__.'/update-configuration.inc.php';
- }
- error_log('Upgrade 1.11.x process concluded! ('.date('Y-m-d H:i:s').')');
- } else {
- error_log('There was an error during running migrations. Check error.log');
- }
- break;
- default:
- break;
- }
- echo '</div>';
- return true;
- }
- function fixPostGroupIds($connection)
- {
- $connection->executeQuery("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'");
- error_log('Fix c_student_publication.post_group_id');
-
- $sql = "SELECT * FROM c_student_publication
- WHERE (post_group_id <> 0 AND post_group_id is not null)";
- $statement = $connection->executeQuery($sql);
- $result = $statement->fetchAll();
- foreach ($result as $row) {
- $groupId = $row['post_group_id'];
- $courseId = $row['c_id'];
- $workIid = $row['iid'];
- $sql = "SELECT iid from c_group_info
- WHERE c_id = $courseId AND id = $groupId";
- $statement = $connection->executeQuery($sql);
- $count = $statement->rowCount();
- if ($count > 0) {
- $rowGroup = $statement->fetch();
- $newGroupId = $rowGroup['iid'];
- if ($newGroupId == $groupId) {
- continue;
- }
- if ($newGroupId) {
- $sql = "UPDATE c_student_publication
- SET post_group_id = $newGroupId
- WHERE
- c_id = $courseId AND
- iid = $workIid
- ";
- $connection->executeQuery($sql);
- }
- }
- }
- error_log('End - Fix c_student_publication.post_group_id');
-
- $sql = "DELETE FROM c_student_publication
- WHERE session_id NOT IN (SELECT id FROM session) AND (session_id <> 0 AND session_id is not null)";
- $connection->executeQuery($sql);
- error_log('Fix work documents');
-
- $sql = "SELECT * FROM c_student_publication WHERE parent_id IS NOT NULL";
- $statement = $connection->executeQuery($sql);
- $result = $statement->fetchAll();
- foreach ($result as $row) {
- $groupId = $row['post_group_id'];
- $courseId = $row['c_id'];
- $sessionId = $row['session_id'];
- $workId = $row['id'];
- $itemInfo = api_get_item_property_info(
- $courseId,
- 'work',
- $workId,
- $sessionId
- );
- $courseInfo = api_get_course_info_by_id($courseId);
- if (empty($itemInfo)) {
- api_item_property_update(
- $courseInfo,
- 'work',
- $workId,
- 'visible',
- 1,
- $groupId,
- null,
- null,
- null,
- $sessionId
- );
- }
- }
- error_log('End - Fix work documents');
- }
|