@@ -51,70 +51,70 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode) |
| 53 | 53 | { |
| 54 | - global $conf,$langs; |
|
| 54 | + global $conf,$langs; |
|
| 55 | 55 | //global $dolauthmode; // To return authentication finally used |
| 56 | 56 | |
| 57 | - // Check parameters |
|
| 58 | - if ($entitytotest == '') $entitytotest=1; |
|
| 57 | + // Check parameters |
|
| 58 | + if ($entitytotest == '') $entitytotest=1; |
|
| 59 | 59 | |
| 60 | 60 | dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".join(',',$authmode)); |
| 61 | - $login = ''; |
|
| 62 | - |
|
| 63 | - // Validation of login/pass/entity with standard modules |
|
| 64 | - if (empty($login)) |
|
| 65 | - { |
|
| 66 | - $test=true; |
|
| 67 | - foreach($authmode as $mode) |
|
| 68 | - { |
|
| 69 | - if ($test && $mode && ! $login) |
|
| 70 | - { |
|
| 71 | - // Validation of login/pass/entity for mode $mode |
|
| 72 | - $mode=trim($mode); |
|
| 73 | - $authfile='functions_'.$mode.'.php'; |
|
| 74 | - $fullauthfile=''; |
|
| 75 | - |
|
| 76 | - $dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']); |
|
| 77 | - foreach($dirlogin as $reldir) |
|
| 78 | - { |
|
| 79 | - $dir=dol_buildpath($reldir,0); |
|
| 80 | - $newdir=dol_osencode($dir); |
|
| 81 | - |
|
| 82 | - // Check if file found (do not use dol_is_file to avoid loading files.lib.php) |
|
| 83 | - $tmpnewauthfile = $newdir.(preg_match('/\/$/',$newdir)?'':'/').$authfile; |
|
| 84 | - if (is_file($tmpnewauthfile)) $fullauthfile=$tmpnewauthfile; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $result=false; |
|
| 88 | - if ($fullauthfile) $result=include_once $fullauthfile; |
|
| 89 | - if ($fullauthfile && $result) |
|
| 90 | - { |
|
| 91 | - // Call function to check user/password |
|
| 92 | - $function='check_user_password_'.$mode; |
|
| 93 | - $login=call_user_func($function, $usertotest, $passwordtotest, $entitytotest); |
|
| 94 | - if ($login) // Login is successfull |
|
| 95 | - { |
|
| 96 | - $test=false; // To stop once at first login success |
|
| 97 | - $conf->authmode=$mode; // This properties is defined only when logged to say what mode was successfully used |
|
| 98 | - $dol_tz=GETPOST('tz'); |
|
| 99 | - $dol_dst=GETPOST('dst'); |
|
| 100 | - $dol_screenwidth=GETPOST('screenwidth'); |
|
| 101 | - $dol_screenheight=GETPOST('screenheight'); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - else |
|
| 105 | - { |
|
| 106 | - dol_syslog("Authentification ko - failed to load file '".$authfile."'", LOG_ERR); |
|
| 107 | - sleep(1); |
|
| 108 | - // Load translation files required by the page |
|
| 61 | + $login = ''; |
|
| 62 | + |
|
| 63 | + // Validation of login/pass/entity with standard modules |
|
| 64 | + if (empty($login)) |
|
| 65 | + { |
|
| 66 | + $test=true; |
|
| 67 | + foreach($authmode as $mode) |
|
| 68 | + { |
|
| 69 | + if ($test && $mode && ! $login) |
|
| 70 | + { |
|
| 71 | + // Validation of login/pass/entity for mode $mode |
|
| 72 | + $mode=trim($mode); |
|
| 73 | + $authfile='functions_'.$mode.'.php'; |
|
| 74 | + $fullauthfile=''; |
|
| 75 | + |
|
| 76 | + $dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']); |
|
| 77 | + foreach($dirlogin as $reldir) |
|
| 78 | + { |
|
| 79 | + $dir=dol_buildpath($reldir,0); |
|
| 80 | + $newdir=dol_osencode($dir); |
|
| 81 | + |
|
| 82 | + // Check if file found (do not use dol_is_file to avoid loading files.lib.php) |
|
| 83 | + $tmpnewauthfile = $newdir.(preg_match('/\/$/',$newdir)?'':'/').$authfile; |
|
| 84 | + if (is_file($tmpnewauthfile)) $fullauthfile=$tmpnewauthfile; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $result=false; |
|
| 88 | + if ($fullauthfile) $result=include_once $fullauthfile; |
|
| 89 | + if ($fullauthfile && $result) |
|
| 90 | + { |
|
| 91 | + // Call function to check user/password |
|
| 92 | + $function='check_user_password_'.$mode; |
|
| 93 | + $login=call_user_func($function, $usertotest, $passwordtotest, $entitytotest); |
|
| 94 | + if ($login) // Login is successfull |
|
| 95 | + { |
|
| 96 | + $test=false; // To stop once at first login success |
|
| 97 | + $conf->authmode=$mode; // This properties is defined only when logged to say what mode was successfully used |
|
| 98 | + $dol_tz=GETPOST('tz'); |
|
| 99 | + $dol_dst=GETPOST('dst'); |
|
| 100 | + $dol_screenwidth=GETPOST('screenwidth'); |
|
| 101 | + $dol_screenheight=GETPOST('screenheight'); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + else |
|
| 105 | + { |
|
| 106 | + dol_syslog("Authentification ko - failed to load file '".$authfile."'", LOG_ERR); |
|
| 107 | + sleep(1); |
|
| 108 | + // Load translation files required by the page |
|
| 109 | 109 | $langs->loadLangs(array('other', 'main', 'errors')); |
| 110 | 110 | |
| 111 | - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorFailedToLoadLoginFileForMode", $mode); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 111 | + $_SESSION["dol_loginmesg"]=$langs->trans("ErrorFailedToLoadLoginFileForMode", $mode); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - return $login; |
|
| 117 | + return $login; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -130,29 +130,29 @@ discard block |
||
| 130 | 130 | * @return void |
| 131 | 131 | */ |
| 132 | 132 | function dol_loginfunction($langs,$conf,$mysoc) |
| 133 | - { |
|
| 134 | - global $dolibarr_main_demo,$db; |
|
| 135 | - global $smartphone,$hookmanager; |
|
| 133 | + { |
|
| 134 | + global $dolibarr_main_demo,$db; |
|
| 135 | + global $smartphone,$hookmanager; |
|
| 136 | 136 | |
| 137 | - $langs->loadLangs(array("main","other","help","admin")); |
|
| 137 | + $langs->loadLangs(array("main","other","help","admin")); |
|
| 138 | 138 | |
| 139 | - // Instantiate hooks of thirdparty module only if not already define |
|
| 139 | + // Instantiate hooks of thirdparty module only if not already define |
|
| 140 | 140 | $hookmanager->initHooks(array('mainloginpage')); |
| 141 | 141 | |
| 142 | 142 | $main_authentication = $conf->file->main_authentication; |
| 143 | 143 | |
| 144 | 144 | $session_name=session_name(); // Get current session name |
| 145 | 145 | |
| 146 | - $dol_url_root = DOL_URL_ROOT; |
|
| 146 | + $dol_url_root = DOL_URL_ROOT; |
|
| 147 | 147 | |
| 148 | - // Title |
|
| 149 | - $appli=constant('DOL_APPLICATION_TITLE'); |
|
| 150 | - $title=$appli.' '.constant('DOL_VERSION'); |
|
| 151 | - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; |
|
| 152 | - $titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version |
|
| 148 | + // Title |
|
| 149 | + $appli=constant('DOL_APPLICATION_TITLE'); |
|
| 150 | + $title=$appli.' '.constant('DOL_VERSION'); |
|
| 151 | + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; |
|
| 152 | + $titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version |
|
| 153 | 153 | |
| 154 | - // Note: $conf->css looks like '/theme/eldy/style.css.php' |
|
| 155 | - /* |
|
| 154 | + // Note: $conf->css looks like '/theme/eldy/style.css.php' |
|
| 155 | + /* |
|
| 156 | 156 | $conf->css = "/theme/".(GETPOST('theme','alpha')?GETPOST('theme','alpha'):$conf->theme)."/style.css.php"; |
| 157 | 157 | $themepath=dol_buildpath($conf->css,1); |
| 158 | 158 | if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application |
@@ -169,138 +169,138 @@ discard block |
||
| 169 | 169 | $conf_css = $themepath."?lang=".$langs->defaultlang; |
| 170 | 170 | */ |
| 171 | 171 | |
| 172 | - // Select templates dir |
|
| 173 | - if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application |
|
| 174 | - { |
|
| 175 | - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl/')); |
|
| 176 | - foreach($dirtpls as $reldir) |
|
| 177 | - { |
|
| 178 | - $tmp=dol_buildpath($reldir.'login.tpl.php'); |
|
| 179 | - if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/','',$tmp); break; } |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - else |
|
| 183 | - { |
|
| 184 | - $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; |
|
| 185 | - } |
|
| 172 | + // Select templates dir |
|
| 173 | + if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application |
|
| 174 | + { |
|
| 175 | + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl/')); |
|
| 176 | + foreach($dirtpls as $reldir) |
|
| 177 | + { |
|
| 178 | + $tmp=dol_buildpath($reldir.'login.tpl.php'); |
|
| 179 | + if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/','',$tmp); break; } |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + else |
|
| 183 | + { |
|
| 184 | + $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - // Set cookie for timeout management |
|
| 188 | - $prefix=dol_getprefix(''); |
|
| 189 | - $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; |
|
| 190 | - if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true); |
|
| 187 | + // Set cookie for timeout management |
|
| 188 | + $prefix=dol_getprefix(''); |
|
| 189 | + $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; |
|
| 190 | + if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true); |
|
| 191 | 191 | |
| 192 | - if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha'); |
|
| 193 | - else unset($_SESSION["urlfrom"]); |
|
| 192 | + if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha'); |
|
| 193 | + else unset($_SESSION["urlfrom"]); |
|
| 194 | 194 | |
| 195 | - if (! GETPOST("username",'alpha')) $focus_element='username'; |
|
| 196 | - else $focus_element='password'; |
|
| 195 | + if (! GETPOST("username",'alpha')) $focus_element='username'; |
|
| 196 | + else $focus_element='password'; |
|
| 197 | 197 | |
| 198 | - $demologin=''; |
|
| 199 | - $demopassword=''; |
|
| 200 | - if (! empty($dolibarr_main_demo)) |
|
| 201 | - { |
|
| 202 | - $tab=explode(',',$dolibarr_main_demo); |
|
| 203 | - $demologin=$tab[0]; |
|
| 204 | - $demopassword=$tab[1]; |
|
| 205 | - } |
|
| 198 | + $demologin=''; |
|
| 199 | + $demopassword=''; |
|
| 200 | + if (! empty($dolibarr_main_demo)) |
|
| 201 | + { |
|
| 202 | + $tab=explode(',',$dolibarr_main_demo); |
|
| 203 | + $demologin=$tab[0]; |
|
| 204 | + $demopassword=$tab[1]; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - // Execute hook getLoginPageOptions (for table) |
|
| 208 | - $parameters=array('entity' => GETPOST('entity','int')); |
|
| 209 | - $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. |
|
| 210 | - if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { |
|
| 211 | - $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility |
|
| 212 | - } else { |
|
| 213 | - $morelogincontent = $hookmanager->resPrint; |
|
| 214 | - } |
|
| 207 | + // Execute hook getLoginPageOptions (for table) |
|
| 208 | + $parameters=array('entity' => GETPOST('entity','int')); |
|
| 209 | + $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. |
|
| 210 | + if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { |
|
| 211 | + $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility |
|
| 212 | + } else { |
|
| 213 | + $morelogincontent = $hookmanager->resPrint; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - // Execute hook getLoginPageExtraOptions (eg for js) |
|
| 217 | - $parameters=array('entity' => GETPOST('entity','int')); |
|
| 218 | - $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions',$parameters); // Note that $action and $object may have been modified by some hooks. |
|
| 219 | - $moreloginextracontent = $hookmanager->resPrint; |
|
| 216 | + // Execute hook getLoginPageExtraOptions (eg for js) |
|
| 217 | + $parameters=array('entity' => GETPOST('entity','int')); |
|
| 218 | + $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions',$parameters); // Note that $action and $object may have been modified by some hooks. |
|
| 219 | + $moreloginextracontent = $hookmanager->resPrint; |
|
| 220 | 220 | |
| 221 | - // Login |
|
| 222 | - $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin)); |
|
| 223 | - $password = $demopassword; |
|
| 221 | + // Login |
|
| 222 | + $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin)); |
|
| 223 | + $password = $demopassword; |
|
| 224 | 224 | |
| 225 | - // Show logo (search in order: small company logo, large company logo, theme logo, common logo) |
|
| 226 | - $width=0; |
|
| 227 | - $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
| 225 | + // Show logo (search in order: small company logo, large company logo, theme logo, common logo) |
|
| 226 | + $width=0; |
|
| 227 | + $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
| 228 | 228 | |
| 229 | 229 | if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) |
| 230 | - { |
|
| 231 | - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
| 232 | - } |
|
| 233 | - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
| 234 | - { |
|
| 235 | - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); |
|
| 236 | - $width=128; |
|
| 237 | - } |
|
| 238 | - elseif (is_readable(DOL_BASE_URI . '/theme/' . $conf->theme . '/img/dolibarr_logo.png')) { |
|
| 239 | - $urllogo = DOL_BASE_URI . '/theme/' . $conf->theme . '/img/dolibarr_logo.png'; |
|
| 230 | + { |
|
| 231 | + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
| 240 | 232 | } |
| 241 | - elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
| 242 | - $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png'; |
|
| 233 | + elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) |
|
| 234 | + { |
|
| 235 | + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); |
|
| 236 | + $width=128; |
|
| 237 | + } |
|
| 238 | + elseif (is_readable(DOL_BASE_URI . '/theme/' . $conf->theme . '/img/dolibarr_logo.png')) { |
|
| 239 | + $urllogo = DOL_BASE_URI . '/theme/' . $conf->theme . '/img/dolibarr_logo.png'; |
|
| 240 | + } |
|
| 241 | + elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
| 242 | + $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png'; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - // Security graphical code |
|
| 246 | - $captcha=0; |
|
| 247 | - $captcha_refresh=''; |
|
| 248 | - if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) |
|
| 249 | - { |
|
| 250 | - $captcha=1; |
|
| 251 | - $captcha_refresh=img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"'); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - // Extra link |
|
| 255 | - $forgetpasslink=0; |
|
| 256 | - $helpcenterlink=0; |
|
| 257 | - if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) |
|
| 258 | - { |
|
| 259 | - if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) |
|
| 260 | - { |
|
| 261 | - $forgetpasslink=1; |
|
| 262 | - } |
|
| 245 | + // Security graphical code |
|
| 246 | + $captcha=0; |
|
| 247 | + $captcha_refresh=''; |
|
| 248 | + if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) |
|
| 249 | + { |
|
| 250 | + $captcha=1; |
|
| 251 | + $captcha_refresh=img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"'); |
|
| 252 | + } |
|
| 263 | 253 | |
| 264 | - if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) |
|
| 265 | - { |
|
| 266 | - $helpcenterlink=1; |
|
| 267 | - } |
|
| 268 | - } |
|
| 254 | + // Extra link |
|
| 255 | + $forgetpasslink=0; |
|
| 256 | + $helpcenterlink=0; |
|
| 257 | + if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) |
|
| 258 | + { |
|
| 259 | + if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) |
|
| 260 | + { |
|
| 261 | + $forgetpasslink=1; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) |
|
| 265 | + { |
|
| 266 | + $helpcenterlink=1; |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - // Home message |
|
| 271 | - $main_home=''; |
|
| 272 | - if (! empty($conf->global->MAIN_HOME)) |
|
| 273 | - { |
|
| 274 | - $substitutionarray=getCommonSubstitutionArray($langs); |
|
| 275 | - complete_substitutions_array($substitutionarray, $langs); |
|
| 276 | - $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs); |
|
| 270 | + // Home message |
|
| 271 | + $main_home=''; |
|
| 272 | + if (! empty($conf->global->MAIN_HOME)) |
|
| 273 | + { |
|
| 274 | + $substitutionarray=getCommonSubstitutionArray($langs); |
|
| 275 | + complete_substitutions_array($substitutionarray, $langs); |
|
| 276 | + $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs); |
|
| 277 | 277 | |
| 278 | - $main_home=dol_htmlcleanlastbr($texttoshow); |
|
| 279 | - } |
|
| 278 | + $main_home=dol_htmlcleanlastbr($texttoshow); |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - // Google AD |
|
| 282 | - $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0); |
|
| 281 | + // Google AD |
|
| 282 | + $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0); |
|
| 283 | 283 | |
| 284 | - // Set jquery theme |
|
| 285 | - $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:''); |
|
| 286 | - $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); |
|
| 287 | - if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; |
|
| 288 | - $jquerytheme = 'base'; |
|
| 289 | - if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; |
|
| 284 | + // Set jquery theme |
|
| 285 | + $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:''); |
|
| 286 | + $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); |
|
| 287 | + if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; |
|
| 288 | + $jquerytheme = 'base'; |
|
| 289 | + if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; |
|
| 290 | 290 | |
| 291 | - // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover |
|
| 292 | - $dol_hide_topmenu=GETPOST('dol_hide_topmenu','int'); |
|
| 293 | - $dol_hide_leftmenu=GETPOST('dol_hide_leftmenu','int'); |
|
| 294 | - $dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen','int'); |
|
| 295 | - $dol_no_mouse_hover=GETPOST('dol_no_mouse_hover','int'); |
|
| 296 | - $dol_use_jmobile=GETPOST('dol_use_jmobile','int'); |
|
| 291 | + // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover |
|
| 292 | + $dol_hide_topmenu=GETPOST('dol_hide_topmenu','int'); |
|
| 293 | + $dol_hide_leftmenu=GETPOST('dol_hide_leftmenu','int'); |
|
| 294 | + $dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen','int'); |
|
| 295 | + $dol_no_mouse_hover=GETPOST('dol_no_mouse_hover','int'); |
|
| 296 | + $dol_use_jmobile=GETPOST('dol_use_jmobile','int'); |
|
| 297 | 297 | |
| 298 | - // Include login page template |
|
| 299 | - include $template_dir.'login.tpl.php'; |
|
| 298 | + // Include login page template |
|
| 299 | + include $template_dir.'login.tpl.php'; |
|
| 300 | 300 | |
| 301 | 301 | |
| 302 | - $_SESSION["dol_loginmesg"] = ''; |
|
| 303 | - } |
|
| 302 | + $_SESSION["dol_loginmesg"] = ''; |
|
| 303 | + } |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -313,23 +313,23 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | function makesalt($type=CRYPT_SALT_LENGTH) |
| 315 | 315 | { |
| 316 | - dol_syslog("makesalt type=".$type); |
|
| 317 | - switch($type) |
|
| 318 | - { |
|
| 319 | - case 12: // 8 + 4 |
|
| 320 | - $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; |
|
| 321 | - case 8: // 8 (Pour compatibilite, ne devrait pas etre utilise) |
|
| 322 | - $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; |
|
| 323 | - case 2: // 2 |
|
| 324 | - default: // by default, fall back on Standard DES (should work everywhere) |
|
| 325 | - $saltlen=2; $saltprefix=''; $saltsuffix=''; break; |
|
| 326 | - } |
|
| 327 | - $salt=''; |
|
| 328 | - while(dol_strlen($salt) < $saltlen) $salt.=chr(mt_rand(64,126)); |
|
| 329 | - |
|
| 330 | - $result=$saltprefix.$salt.$saltsuffix; |
|
| 331 | - dol_syslog("makesalt return=".$result); |
|
| 332 | - return $result; |
|
| 316 | + dol_syslog("makesalt type=".$type); |
|
| 317 | + switch($type) |
|
| 318 | + { |
|
| 319 | + case 12: // 8 + 4 |
|
| 320 | + $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; |
|
| 321 | + case 8: // 8 (Pour compatibilite, ne devrait pas etre utilise) |
|
| 322 | + $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; |
|
| 323 | + case 2: // 2 |
|
| 324 | + default: // by default, fall back on Standard DES (should work everywhere) |
|
| 325 | + $saltlen=2; $saltprefix=''; $saltsuffix=''; break; |
|
| 326 | + } |
|
| 327 | + $salt=''; |
|
| 328 | + while(dol_strlen($salt) < $saltlen) $salt.=chr(mt_rand(64,126)); |
|
| 329 | + |
|
| 330 | + $result=$saltprefix.$salt.$saltsuffix; |
|
| 331 | + dol_syslog("makesalt return=".$result); |
|
| 332 | + return $result; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -340,102 +340,102 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | function encodedecode_dbpassconf($level=0) |
| 342 | 342 | { |
| 343 | - dol_syslog("encodedecode_dbpassconf level=".$level, LOG_DEBUG); |
|
| 344 | - $config = ''; |
|
| 345 | - $passwd=''; |
|
| 346 | - $passwd_crypted=''; |
|
| 347 | - |
|
| 348 | - if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','r')) |
|
| 349 | - { |
|
| 350 | - while(!feof($fp)) |
|
| 351 | - { |
|
| 352 | - $buffer = fgets($fp,4096); |
|
| 353 | - |
|
| 354 | - $lineofpass=0; |
|
| 355 | - |
|
| 356 | - if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i',$buffer,$reg)) // Old way to save crypted value |
|
| 357 | - { |
|
| 358 | - $val = trim($reg[1]); // This also remove CR/LF |
|
| 359 | - $val=preg_replace('/^["\']/','',$val); |
|
| 360 | - $val=preg_replace('/["\'][\s;]*$/','',$val); |
|
| 361 | - if (! empty($val)) |
|
| 362 | - { |
|
| 363 | - $passwd_crypted = $val; |
|
| 364 | - $val = dol_decode($val); |
|
| 365 | - $passwd = $val; |
|
| 366 | - $lineofpass=1; |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i',$buffer,$reg)) |
|
| 370 | - { |
|
| 371 | - $val = trim($reg[1]); // This also remove CR/LF |
|
| 372 | - $val=preg_replace('/^["\']/','',$val); |
|
| 373 | - $val=preg_replace('/["\'][\s;]*$/','',$val); |
|
| 374 | - if (preg_match('/crypted:/i',$buffer)) |
|
| 375 | - { |
|
| 376 | - $val = preg_replace('/crypted:/i','',$val); |
|
| 377 | - $passwd_crypted = $val; |
|
| 378 | - $val = dol_decode($val); |
|
| 379 | - $passwd = $val; |
|
| 380 | - } |
|
| 381 | - else |
|
| 382 | - { |
|
| 383 | - $passwd = $val; |
|
| 384 | - $val = dol_encode($val); |
|
| 385 | - $passwd_crypted = $val; |
|
| 386 | - } |
|
| 387 | - $lineofpass=1; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - // Output line |
|
| 391 | - if ($lineofpass) |
|
| 392 | - { |
|
| 393 | - // Add value at end of file |
|
| 394 | - if ($level == 0) |
|
| 395 | - { |
|
| 396 | - $config .= '$dolibarr_main_db_pass=\''.$passwd.'\';'."\n"; |
|
| 397 | - } |
|
| 398 | - if ($level == 1) |
|
| 399 | - { |
|
| 400 | - $config .= '$dolibarr_main_db_pass=\'crypted:'.$passwd_crypted.'\';'."\n"; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - //print 'passwd = '.$passwd.' - passwd_crypted = '.$passwd_crypted; |
|
| 404 | - //exit; |
|
| 405 | - } |
|
| 406 | - else |
|
| 407 | - { |
|
| 408 | - $config .= $buffer; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - fclose($fp); |
|
| 412 | - |
|
| 413 | - // Write new conf file |
|
| 414 | - $file=DOL_DOCUMENT_ROOT.'/conf/conf.php'; |
|
| 415 | - if ($fp = @fopen($file,'w')) |
|
| 416 | - { |
|
| 417 | - fputs($fp, $config); |
|
| 418 | - fflush($fp); |
|
| 419 | - fclose($fp); |
|
| 420 | - clearstatcache(); |
|
| 421 | - |
|
| 422 | - // It's config file, so we set read permission for creator only. |
|
| 423 | - // Should set permission to web user and groups for users used by batch |
|
| 424 | - //@chmod($file, octdec('0600')); |
|
| 425 | - |
|
| 426 | - return 1; |
|
| 427 | - } |
|
| 428 | - else |
|
| 429 | - { |
|
| 430 | - dol_syslog("encodedecode_dbpassconf Failed to open conf.php file for writing", LOG_WARNING); |
|
| 431 | - return -1; |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - else |
|
| 435 | - { |
|
| 436 | - dol_syslog("encodedecode_dbpassconf Failed to read conf.php", LOG_ERR); |
|
| 437 | - return -2; |
|
| 438 | - } |
|
| 343 | + dol_syslog("encodedecode_dbpassconf level=".$level, LOG_DEBUG); |
|
| 344 | + $config = ''; |
|
| 345 | + $passwd=''; |
|
| 346 | + $passwd_crypted=''; |
|
| 347 | + |
|
| 348 | + if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','r')) |
|
| 349 | + { |
|
| 350 | + while(!feof($fp)) |
|
| 351 | + { |
|
| 352 | + $buffer = fgets($fp,4096); |
|
| 353 | + |
|
| 354 | + $lineofpass=0; |
|
| 355 | + |
|
| 356 | + if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i',$buffer,$reg)) // Old way to save crypted value |
|
| 357 | + { |
|
| 358 | + $val = trim($reg[1]); // This also remove CR/LF |
|
| 359 | + $val=preg_replace('/^["\']/','',$val); |
|
| 360 | + $val=preg_replace('/["\'][\s;]*$/','',$val); |
|
| 361 | + if (! empty($val)) |
|
| 362 | + { |
|
| 363 | + $passwd_crypted = $val; |
|
| 364 | + $val = dol_decode($val); |
|
| 365 | + $passwd = $val; |
|
| 366 | + $lineofpass=1; |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i',$buffer,$reg)) |
|
| 370 | + { |
|
| 371 | + $val = trim($reg[1]); // This also remove CR/LF |
|
| 372 | + $val=preg_replace('/^["\']/','',$val); |
|
| 373 | + $val=preg_replace('/["\'][\s;]*$/','',$val); |
|
| 374 | + if (preg_match('/crypted:/i',$buffer)) |
|
| 375 | + { |
|
| 376 | + $val = preg_replace('/crypted:/i','',$val); |
|
| 377 | + $passwd_crypted = $val; |
|
| 378 | + $val = dol_decode($val); |
|
| 379 | + $passwd = $val; |
|
| 380 | + } |
|
| 381 | + else |
|
| 382 | + { |
|
| 383 | + $passwd = $val; |
|
| 384 | + $val = dol_encode($val); |
|
| 385 | + $passwd_crypted = $val; |
|
| 386 | + } |
|
| 387 | + $lineofpass=1; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + // Output line |
|
| 391 | + if ($lineofpass) |
|
| 392 | + { |
|
| 393 | + // Add value at end of file |
|
| 394 | + if ($level == 0) |
|
| 395 | + { |
|
| 396 | + $config .= '$dolibarr_main_db_pass=\''.$passwd.'\';'."\n"; |
|
| 397 | + } |
|
| 398 | + if ($level == 1) |
|
| 399 | + { |
|
| 400 | + $config .= '$dolibarr_main_db_pass=\'crypted:'.$passwd_crypted.'\';'."\n"; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + //print 'passwd = '.$passwd.' - passwd_crypted = '.$passwd_crypted; |
|
| 404 | + //exit; |
|
| 405 | + } |
|
| 406 | + else |
|
| 407 | + { |
|
| 408 | + $config .= $buffer; |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + fclose($fp); |
|
| 412 | + |
|
| 413 | + // Write new conf file |
|
| 414 | + $file=DOL_DOCUMENT_ROOT.'/conf/conf.php'; |
|
| 415 | + if ($fp = @fopen($file,'w')) |
|
| 416 | + { |
|
| 417 | + fputs($fp, $config); |
|
| 418 | + fflush($fp); |
|
| 419 | + fclose($fp); |
|
| 420 | + clearstatcache(); |
|
| 421 | + |
|
| 422 | + // It's config file, so we set read permission for creator only. |
|
| 423 | + // Should set permission to web user and groups for users used by batch |
|
| 424 | + //@chmod($file, octdec('0600')); |
|
| 425 | + |
|
| 426 | + return 1; |
|
| 427 | + } |
|
| 428 | + else |
|
| 429 | + { |
|
| 430 | + dol_syslog("encodedecode_dbpassconf Failed to open conf.php file for writing", LOG_WARNING); |
|
| 431 | + return -1; |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + else |
|
| 435 | + { |
|
| 436 | + dol_syslog("encodedecode_dbpassconf Failed to read conf.php", LOG_ERR); |
|
| 437 | + return -2; |
|
| 438 | + } |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -448,72 +448,72 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | function getRandomPassword($generic=false, $replaceambiguouschars=null) |
| 450 | 450 | { |
| 451 | - global $db,$conf,$langs,$user; |
|
| 452 | - |
|
| 453 | - $generated_password=''; |
|
| 454 | - if ($generic) |
|
| 455 | - { |
|
| 456 | - $length = 32; |
|
| 457 | - $lowercase = "qwertyuiopasdfghjklzxcvbnm"; |
|
| 458 | - $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP"; |
|
| 459 | - $numbers = "1234567890"; |
|
| 460 | - $randomCode = ""; |
|
| 461 | - $nbofchar = round($length/3); |
|
| 462 | - $nbofcharlast = ($length - 2*$nbofchar); |
|
| 463 | - //var_dump($nbofchar.'-'.$nbofcharlast); |
|
| 464 | - if (function_exists('random_int')) // Cryptographic random |
|
| 465 | - { |
|
| 466 | - $max = strlen($lowercase) - 1; |
|
| 467 | - for ($x = 0; $x < $nbofchar; $x++) { |
|
| 468 | - $randomCode .= $lowercase{random_int(0, $max)}; |
|
| 469 | - } |
|
| 470 | - $max = strlen($uppercase) - 1; |
|
| 471 | - for ($x = 0; $x < $nbofchar; $x++) { |
|
| 472 | - $randomCode .= $uppercase{random_int(0, $max)}; |
|
| 473 | - } |
|
| 474 | - $max = strlen($numbers) - 1; |
|
| 475 | - for ($x = 0; $x < $nbofcharlast; $x++) { |
|
| 476 | - $randomCode .= $numbers{random_int(0, $max)}; |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - $generated_password=str_shuffle($randomCode); |
|
| 480 | - } |
|
| 481 | - else // Old platform, non cryptographic random |
|
| 482 | - { |
|
| 483 | - $max = strlen($lowercase) - 1; |
|
| 484 | - for ($x = 0; $x < $nbofchar; $x++) { |
|
| 485 | - $randomCode .= $lowercase{mt_rand(0, $max)}; |
|
| 486 | - } |
|
| 487 | - $max = strlen($uppercase) - 1; |
|
| 488 | - for ($x = 0; $x < $nbofchar; $x++) { |
|
| 489 | - $randomCode .= $uppercase{mt_rand(0, $max)}; |
|
| 490 | - } |
|
| 491 | - $max = strlen($numbers) - 1; |
|
| 492 | - for ($x = 0; $x < $nbofcharlast; $x++) { |
|
| 493 | - $randomCode .= $numbers{mt_rand(0, $max)}; |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - $generated_password=str_shuffle($randomCode); |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - else if (! empty($conf->global->USER_PASSWORD_GENERATED)) |
|
| 500 | - { |
|
| 501 | - $nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); |
|
| 502 | - $nomfichier=$nomclass.".class.php"; |
|
| 503 | - //print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass; |
|
| 504 | - require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier; |
|
| 505 | - $genhandler=new $nomclass($db,$conf,$langs,$user); |
|
| 506 | - $generated_password=$genhandler->getNewGeneratedPassword(); |
|
| 507 | - unset($genhandler); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - // Do we have to discard some alphabetic characters ? |
|
| 511 | - if (is_array($replaceambiguouschars) && count($replaceambiguouschars) > 0) |
|
| 512 | - { |
|
| 513 | - $numbers = "ABCDEF"; |
|
| 514 | - $max = strlen($numbers) - 1; |
|
| 515 | - $generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password); |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - return $generated_password; |
|
| 451 | + global $db,$conf,$langs,$user; |
|
| 452 | + |
|
| 453 | + $generated_password=''; |
|
| 454 | + if ($generic) |
|
| 455 | + { |
|
| 456 | + $length = 32; |
|
| 457 | + $lowercase = "qwertyuiopasdfghjklzxcvbnm"; |
|
| 458 | + $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP"; |
|
| 459 | + $numbers = "1234567890"; |
|
| 460 | + $randomCode = ""; |
|
| 461 | + $nbofchar = round($length/3); |
|
| 462 | + $nbofcharlast = ($length - 2*$nbofchar); |
|
| 463 | + //var_dump($nbofchar.'-'.$nbofcharlast); |
|
| 464 | + if (function_exists('random_int')) // Cryptographic random |
|
| 465 | + { |
|
| 466 | + $max = strlen($lowercase) - 1; |
|
| 467 | + for ($x = 0; $x < $nbofchar; $x++) { |
|
| 468 | + $randomCode .= $lowercase{random_int(0, $max)}; |
|
| 469 | + } |
|
| 470 | + $max = strlen($uppercase) - 1; |
|
| 471 | + for ($x = 0; $x < $nbofchar; $x++) { |
|
| 472 | + $randomCode .= $uppercase{random_int(0, $max)}; |
|
| 473 | + } |
|
| 474 | + $max = strlen($numbers) - 1; |
|
| 475 | + for ($x = 0; $x < $nbofcharlast; $x++) { |
|
| 476 | + $randomCode .= $numbers{random_int(0, $max)}; |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + $generated_password=str_shuffle($randomCode); |
|
| 480 | + } |
|
| 481 | + else // Old platform, non cryptographic random |
|
| 482 | + { |
|
| 483 | + $max = strlen($lowercase) - 1; |
|
| 484 | + for ($x = 0; $x < $nbofchar; $x++) { |
|
| 485 | + $randomCode .= $lowercase{mt_rand(0, $max)}; |
|
| 486 | + } |
|
| 487 | + $max = strlen($uppercase) - 1; |
|
| 488 | + for ($x = 0; $x < $nbofchar; $x++) { |
|
| 489 | + $randomCode .= $uppercase{mt_rand(0, $max)}; |
|
| 490 | + } |
|
| 491 | + $max = strlen($numbers) - 1; |
|
| 492 | + for ($x = 0; $x < $nbofcharlast; $x++) { |
|
| 493 | + $randomCode .= $numbers{mt_rand(0, $max)}; |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + $generated_password=str_shuffle($randomCode); |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + else if (! empty($conf->global->USER_PASSWORD_GENERATED)) |
|
| 500 | + { |
|
| 501 | + $nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); |
|
| 502 | + $nomfichier=$nomclass.".class.php"; |
|
| 503 | + //print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass; |
|
| 504 | + require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier; |
|
| 505 | + $genhandler=new $nomclass($db,$conf,$langs,$user); |
|
| 506 | + $generated_password=$genhandler->getNewGeneratedPassword(); |
|
| 507 | + unset($genhandler); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + // Do we have to discard some alphabetic characters ? |
|
| 511 | + if (is_array($replaceambiguouschars) && count($replaceambiguouschars) > 0) |
|
| 512 | + { |
|
| 513 | + $numbers = "ABCDEF"; |
|
| 514 | + $max = strlen($numbers) - 1; |
|
| 515 | + $generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password); |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + return $generated_password; |
|
| 519 | 519 | } |