setvar('cookie_set', 1); $creds = explode($cookieDelim, $_COOKIE["autologin"]); $tmpl->setvar('cookieuser', $creds[0]); $tmpl->setvar('cookiepass', $creds[1]); } } } break; case 4: /* Form-Auth + Image-Validation */ // Image class require_once('inc/classes/Image.php'); $user = strtolower(tfb_getRequestVar('username')); $iamhim = addslashes(tfb_getRequestVar('iamhim')); $md5password = ""; $isImageSupported = Image::isSupported(); if (!empty($user)) { $isLoginRequest = true; // image-validation if ($isImageSupported) { $secCode = tfb_getRequestVar('security'); $rndChk = tfb_getRequestVar('rnd_chk'); if ($secCode !== loginImageCode($cfg["db_user"], $rndChk)) { // log this AuditAction($cfg["constants"]["access_denied"], "FAILED IMAGE-VALIDATION: ".$user); // flush credentials if sec-code-validation fails (-> login-failure) $user = ""; $iamhim = ""; } } } if ($isImageSupported) { $tmpl->setvar('imageSupported', 1); // rand mt_srand((double)microtime() * 1000000); $rnd = mt_rand(0, 1000000); $tmpl->setvar('rnd', $rnd); } else { $tmpl->setvar('imageSupported', 0); } break; case 0: /* Form-Based Auth Standard */ default: $user = strtolower(tfb_getRequestVar('username')); $iamhim = addslashes(tfb_getRequestVar('iamhim')); $md5password = ""; if (!empty($user)) $isLoginRequest = true; break; } // process login if this is a login-request if ($isLoginRequest) { // First User check $next_loc = "index.php?iid=index"; $sql = "SELECT count(*) FROM tf_users"; $user_count = $db->GetOne($sql); if ($user_count == 0) { firstLogin($user, $iamhim); $next_loc = "admin.php?op=serverSettings"; } // perform auth if (performAuthentication($user, $iamhim, $md5password) == 1) { @header("location: ".$next_loc); exit(); } else { $tmpl->setvar('login_failed', 1); } } // defines $tmpl->setvar('auth_type', $cfg["auth_type"]); tmplSetTitleBar($cfg["pagetitle"], false); tmplSetFoot(false); tmplSetIidVars(); $tmpl->setvar('iid', 'login'); // parse template $tmpl->pparse(); ?>