/** * Handle plugin-specific actions * These actions are handled at the startup hook rather than registered as * custom actions because the user session does not necessarily exist when * these actions need to be handled. * * @param array $args arguments from rcmail * @return array modified arguments */ function startup($args) { // intercept PGT callback action if ($args['action'] == 'pgtcallback') { // initialize CAS client $this->cas_init(); // retrieve and store PGT if present phpCAS::forceAuthentication(); // end script exit; } // intercept CAS logout action else if ($args['action'] == 'caslogout') { // initialize CAS client $this->cas_init(); // logout from CAS server phpCAS::logout(); // end script exit; } $args['valid'] = true; return $args; }
public function logout() { $curruser = $this->session->userdata("curruser"); if ($curruser) { $this->session->sess_destroy(); } phpCAS::logout(); }
/** * Logs the user out / destroys the CAS session */ public function index() { if (\phpCAS::checkAuthentication()) { \phpCAS::logout(); } session_destroy(); header("Location: /landing"); return; }
/** * This method disconnects the user. * * Notice that the CAS server actually needs to be notified of the * disconnection, so we use phpCAS's relevant function. * * @returns Nothing ! This method should always redirect to the main * page. */ function disconnect() { // Load the CAS module include_once 'CAS/CAS.php'; // Start CAS, and use it to disconnect phpCAS::client(CAS_VERSION_2_0, $this->casServerHostname, $this->casServerPort, $this->casServerURI); phpCAS::logout("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"]); // Really ? Well, should not be ever executed, because phpCAS::logout() // redirects to another page, or exit()s the php script if failure. return true; }
public static function signOut($config, $return_url = null) { self::buildClient($config->get('cas-hostname'), $config->get('cas-port'), $config->get('cas-context')); unset($_SESSION[':cas']); if ($config->get('cas-single-sign-off')) { if (empty($return_url)) { phpCAS::logout(); } else { phpCAS::logoutWithRedirectService($return_url); } } }
function logoutCAS($config, $wwwroot) { require_once dirname(__FILE__) . '/CAS/CAS.php'; // get module configuration $cas_validate = true; $cas_version = CAS_VERSION_2_0; $cas_language = 'english'; phpCAS::client($cas_version, $config->cashostname, (int) $config->casport, $config->casbaseuri, false); error_log("CAS: Logout"); phpCAS::logout($wwwroot); error_log("CAS: Logout Exit"); return true; }
public function preLogUser($sessionId) { if ($_GET['get_action'] == "logout") { phpCAS::logout(); return; } phpCAS::forceAuthentication(); $cas_user = phpCAS::getUser(); if (!$this->userExists($cas_user) && $this->autoCreateUser()) { $this->createUser($cas_user, openssl_random_pseudo_bytes(20)); } if ($this->userExists($cas_user)) { AuthService::logUser($cas_user, "", true); } }
public static function logout($return_uri = "") { $options = ""; /* default value in phpCAS */ $host = (!empty($_SERVER['HTTPS']) ? "https://" : "http://" . $_SERVER['HTTP_HOST']) . '/'; if (strpos($return_uri, "http") === 0) { $host = ""; } if ($return_uri !== null) { $return_uri = trim($return_uri, '/'); $options = array('service' => "{$host}{$return_uri}"); } phpCAS::logout($options); NXAPI::clear_cache(); }
/** * Logout execution method. Initializes CAS client and force logout if required before returning to parent logout method. * * @param mixed $url Optional URL to redirect the user to after logout * @return string AuthComponent::$loginAction * @see AuthComponent::$loginAction * @access public */ function logout() { // Set debug mode phpCAS::setDebug(false); //Initialize phpCAS phpCAS::client(CAS_VERSION_2_0, Configure::read('CAS.hostname'), Configure::read('CAS.port'), Configure::read('CAS.uri'), true); // No SSL validation for the CAS server phpCAS::setNoCasServerValidation(); // Force CAS logout if required if (phpCAS::isAuthenticated()) { phpCAS::logout(array('url' => 'http://www.cakephp.org')); // Provide login url for your application } return parent::logout(); }
function logout() { if ($this->uso_login_basico() && $this->permite_login_toba()) { //Si es login toba no redirecciono al servidor CAS $this->eliminar_marca_login(self::$marca_login_basico); return; } if ($this->uso_login_centralizado()) { $this->eliminar_marca_login(self::$marca_login_central); } // Se conecta al CAS $this->instanciar_cliente_cas(); // Desloguea sin parametros porque igualmente CAS pide cerrar el browser por cuestiones de seguridad phpCAS::logout(); exit; }
public function index() { if ($this->customer->isLogged()) { $this->customer->logout(); $this->cart->clear(); unset($this->session->data['wishlist']); unset($this->session->data['shipping_address_id']); unset($this->session->data['shipping_country_id']); unset($this->session->data['shipping_zone_id']); unset($this->session->data['shipping_postcode']); unset($this->session->data['shipping_method']); unset($this->session->data['shipping_methods']); unset($this->session->data['payment_address_id']); unset($this->session->data['payment_country_id']); unset($this->session->data['payment_zone_id']); unset($this->session->data['payment_method']); unset($this->session->data['payment_methods']); unset($this->session->data['comment']); unset($this->session->data['order_id']); unset($this->session->data['coupon']); unset($this->session->data['reward']); unset($this->session->data['voucher']); unset($this->session->data['vouchers']); phpCAS::client(CAS_VERSION_2_0, CAS_HOST, CAS_PORT, CAS_CONTEXT); phpCAS::logout(); $this->redirect($this->url->link('account/logout', '', 'SSL')); } $this->language->load('account/logout'); $this->document->setTitle($this->language->get('heading_title')); $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', 'SSL'), 'separator' => $this->language->get('text_separator')); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_logout'), 'href' => $this->url->link('account/logout', '', 'SSL'), 'separator' => $this->language->get('text_separator')); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_message'] = $this->language->get('text_message'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['continue'] = $this->url->link('common/home'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) { $this->template = $this->config->get('config_template') . '/template/common/success.tpl'; } else { $this->template = 'default/template/common/success.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); $this->response->setOutput($this->render()); }
public function logout($user) { if (phpCAS::isAuthenticated()) { //Step 1. When the client clicks logout, this will run. // phpCAS::logout will redirect the client to the CAS server. // The CAS server will, in turn, redirect the client back to // this same logout URL. // // phpCAS will stop script execution after it sends the redirect // header, which is a problem because CakePHP still thinks the // user is logged in. See Step 2. $current_url = Router::url(null, true); phpCAS::logout(array('url' => $current_url)); } else { //Step 2. This will run when the CAS server has redirected the client // back to us. Do nothing in this method, then after this method // returns CakePHP will do whatever is necessary to log the user // out from its end (destroying the session or whatever). } }
/** * Actions to perform when logging out a user session * * @return void */ public function logout() { if (Config::get('debug')) { $debug_location = $this->params->get('debug_location', '/var/log/apache2/php/phpCAS.log'); phpCAS::setDebug($debug_location); } $this->initialize(); $service = rtrim(Request::base(), '/'); if (empty($service)) { $service = $_SERVER['HTTP_HOST']; } $return = ''; if ($return = Request::getVar('return', '', 'method', 'base64')) { $return = base64_decode($return); if (!JURI::isInternal($return)) { $return = ''; } $return = '/' . ltrim($return, '/'); } phpCAS::logout(array('service' => $service . $return, 'url' => $service . $return)); }
public static function sso($action = 'login') { include_once ROOT_PATH . 'lib/cas/CAS.php'; include_once ROOT_PATH . 'config/cas.php'; $client = ''; // error_reporting(E_ALL); // ini_set("display_errors", 1); $cas_host = CAS_HOST; $cas_port = intval(CAS_PORT); $cas_context = CAS_CONTEXT; $phpCAS = new \phpCAS(); // $phpCAS->setDebug(); $phpCAS->client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context); $phpCAS->setNoCasServerValidation(); $phpCAS->handleLogoutRequests(); $phpCAS->forceAuthentication(); if (isset($action) && $action == 'logout') { $phpCAS->logout(); } $client = $phpCAS->getAttributes(); return $client; }
$test = phpCAS::checkAuthentication(); // Récupération des données utilisateur $sql = 'SELECT * FROM user WHERE nbEtudiant = :nbEtu LIMIT 1'; $res = $db->prepare($sql); $res->execute(array('nbEtu' => phpCAS::getUser())); if ($res_f = $res->fetch()) { $_SESSION['id'] = $res_f['id']; $_SESSION['nom'] = $res_f['nom']; $_SESSION['prenom'] = $res_f['prenom']; $_SESSION['rang'] = $res_f['rang']; if (isset($res_f['promotion'])) { $_SESSION['promotion'] = $res_f['promotion']; } } else { $errorCode = serialize(array(32 => true)); phpCAS::logout(array('service' => ROOT . 'index.php?erreur=' . $errorCode)); } } // On revérifie l'état de la connexion if ($currentPageData['fullRight'][$_SESSION['rang']] == 0) { $errorCode = serialize(array(7 => true)); header('Location: ' . ROOT . 'index.php?erreur=' . $errorCode); } } } else { $errorCode = serialize(array(7 => true)); header('Location: ' . ROOT . 'index.php?erreur=' . $errorCode); } /** Connexion au nom d'un autre utilisateur **/
/** * @brief 封装使用UUAP SSO服务的退出过程 * * @return success-true failed-false * @retval boolean * @note 调用此接口成功后将跳转到http://uuap.baidu.com/logout * @author chenyijie * @date 2012/09/28 22:14:39 **/ public static function logout() { if (!self::init()) { return false; } setcookie('username', 'guest', time() + 3600 * 24 * 100, "/"); phpCAS::logout(); return true; }
public static function logout($parameters) { if (\OC::$server->getConfig()->getAppValue('user_cas', 'cas_disable_logout', false)) { return true; } $casBackend = OC_USER_CAS::getInstance(); if (phpCAS::isAuthenticated()) { phpCAS::logout(); } return true; }
public function beforeLogout() { // configure phpCAS $cas_host = $this->get('casAuthServer'); $cas_context = $this->get('casAuthUri'); $cas_port = (int) $this->get('casAuthPort'); // import phpCAS lib $basedir = dirname(__FILE__); Yii::setPathOfAlias('myplugin', $basedir); Yii::import('myplugin.third_party.CAS.*'); require_once 'third_party/CAS/CAS.php'; // Initialize phpCAS phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context, false); // disable SSL validation of the CAS server phpCAS::setNoCasServerValidation(); // logout from CAS phpCAS::logout(); }
public static function logout($parameters) { if (phpCAS::isAuthenticated()) { \OCP\Util::writeLog('user_cas', "Deconexion", \OCP\Util::DEBUG); //phpCAS::logoutWithUrl('www.univ-amu.fr'); phpCAS::logout(); } return true; }
function casLogout() { global $CASAuth; global $casIsSetUp; global $wgUser, $wgRequest, $wgLanguageCode; require_once $CASAuth["phpCAS"] . "/CAS.php"; // Logout from MediaWiki $wgUser->logout(); // Get returnto value $returnto = $wgRequest->getVal("returnto"); if ($returnto) { $lg = Language::factory($wgLanguageCode); $target = Title::newFromText($returnto); if ($target && $target->getPrefixedDBkey() != $lg->specialPage("Userlogout")) { $redirecturl = $target->getFullUrl(); } } if (!$casIsSetUp) { return false; } // Logout from CAS (will redirect user to CAS server) if (isset($redirecturl)) { phpCAS::logoutWithRedirectServiceAndUrl($redirecturl, $redirecturl); } else { phpCAS::logout(); } return true; // We won't get here }
function logout() { phpCAS::logout(); }
<?php /* lcs/logout_ent.php version du : 16/03/2012 */ include ("./includes/headerauth.inc.php"); //Logout ENT CAS service include_once('/usr/share/php/CAS/CAS.php'); #phpCAS::setDebug(); // initialise phpCAS phpCAS::client(CAS_VERSION_2_0,$ent_hostname,intval($ent_port),$ent_uri); // no SSL validation for the CAS server phpCAS::setNoCasServerValidation(); #phpCAS::handleLogoutRequests(true, array($hostname.".".$domain)); // logout if desired phpCAS::logout(array('url'=>$baseurl)); ?>
public function index() { phpCAS::client(CAS_VERSION_2_0, CAS_HOST, CAS_PORT, CAS_CONTEXT); phpCAS::setNoCasServerValidation(); phpCAS::forceAuthentication(); if (isset($_REQUEST['logout'])) { phpCAS::logout(); } $this->load->model('account/customer'); // Login override for admin users if (!empty($this->request->get['token'])) { $this->customer->logout(); $this->cart->clear(); unset($this->session->data['wishlist']); unset($this->session->data['shipping_address_id']); unset($this->session->data['shipping_country_id']); unset($this->session->data['shipping_zone_id']); unset($this->session->data['shipping_postcode']); unset($this->session->data['shipping_method']); unset($this->session->data['shipping_methods']); unset($this->session->data['payment_address_id']); unset($this->session->data['payment_country_id']); unset($this->session->data['payment_zone_id']); unset($this->session->data['payment_method']); unset($this->session->data['payment_methods']); unset($this->session->data['comment']); unset($this->session->data['order_id']); unset($this->session->data['coupon']); unset($this->session->data['reward']); unset($this->session->data['voucher']); unset($this->session->data['vouchers']); $customer_info = $this->model_account_customer->getCustomerByToken($this->request->get['token']); if ($customer_info && $this->customer->login($customer_info['email'], '', true)) { // Default Addresses $this->load->model('account/address'); $address_info = $this->model_account_address->getAddress($this->customer->getAddressId()); if ($address_info) { if ($this->config->get('config_tax_customer') == 'shipping') { $this->session->data['shipping_country_id'] = $address_info['country_id']; $this->session->data['shipping_zone_id'] = $address_info['zone_id']; $this->session->data['shipping_postcode'] = $address_info['postcode']; } if ($this->config->get('config_tax_customer') == 'payment') { $this->session->data['payment_country_id'] = $address_info['country_id']; $this->session->data['payment_zone_id'] = $address_info['zone_id']; } } else { unset($this->session->data['shipping_country_id']); unset($this->session->data['shipping_zone_id']); unset($this->session->data['shipping_postcode']); unset($this->session->data['payment_country_id']); unset($this->session->data['payment_zone_id']); } //$this->redirect($this->url->link('account/account', '', 'SSL')); } } if ($this->customer->isLogged()) { //$this->redirect($this->url->link('account/account', '', 'SSL')); } $this->language->load('account/login'); $this->document->setTitle($this->language->get('heading_title')); if (phpCAS::getUser() != null && $this->validate()) { unset($this->session->data['guest']); // Default Shipping Address $this->load->model('account/address'); $address_info = $this->model_account_address->getAddress($this->customer->getAddressId()); if ($address_info) { if ($this->config->get('config_tax_customer') == 'shipping') { $this->session->data['shipping_country_id'] = $address_info['country_id']; $this->session->data['shipping_zone_id'] = $address_info['zone_id']; $this->session->data['shipping_postcode'] = $address_info['postcode']; } if ($this->config->get('config_tax_customer') == 'payment') { $this->session->data['payment_country_id'] = $address_info['country_id']; $this->session->data['payment_zone_id'] = $address_info['zone_id']; } } else { unset($this->session->data['shipping_country_id']); unset($this->session->data['shipping_zone_id']); unset($this->session->data['shipping_postcode']); unset($this->session->data['payment_country_id']); unset($this->session->data['payment_zone_id']); } // Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295) if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) { $this->redirect(str_replace('&', '&', $this->request->post['redirect'])); } else { if (isset($this->session->data['redirect'])) { $this->redirect($this->session->data['redirect']); } else { $this->redirect($this->url->link('account/account', '', 'SSL')); } } } $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_account'), 'href' => $this->url->link('account/account', '', 'SSL'), 'separator' => $this->language->get('text_separator')); $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_login'), 'href' => $this->url->link('account/login', '', 'SSL'), 'separator' => $this->language->get('text_separator')); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_new_customer'] = $this->language->get('text_new_customer'); $this->data['text_register'] = $this->language->get('text_register'); $this->data['text_register_account'] = $this->language->get('text_register_account'); $this->data['text_returning_customer'] = $this->language->get('text_returning_customer'); $this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer'); $this->data['text_forgotten'] = $this->language->get('text_forgotten'); $this->data['entry_email'] = $this->language->get('entry_email'); $this->data['entry_password'] = $this->language->get('entry_password'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['button_login'] = $this->language->get('button_login'); if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } $this->data['action'] = $this->url->link('account/login', '', 'SSL'); $this->data['register'] = $this->url->link('account/register', '', 'SSL'); $this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL'); // Added strpos check to pass McAfee PCI compliance test (http://forum.opencart.com/viewtopic.php?f=10&t=12043&p=151494#p151295) if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('config_url')) !== false || strpos($this->request->post['redirect'], $this->config->get('config_ssl')) !== false)) { $this->data['redirect'] = $this->request->post['redirect']; } elseif (isset($this->session->data['redirect'])) { $this->data['redirect'] = $this->session->data['redirect']; unset($this->session->data['redirect']); } else { $this->data['redirect'] = ''; } if (isset($this->session->data['success'])) { $this->data['success'] = $this->session->data['success']; unset($this->session->data['success']); } else { $this->data['success'] = ''; } if (isset($this->request->post['email'])) { $this->data['email'] = $this->request->post['email']; } else { $this->data['email'] = ''; } if (isset($this->request->post['password'])) { $this->data['password'] = $this->request->post['password']; } else { $this->data['password'] = ''; } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/login.tpl')) { $this->template = $this->config->get('config_template') . '/template/account/login.tpl'; } else { $this->template = 'default/template/account/login.tpl'; } $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header'); $this->response->setOutput($this->render()); }
function logout() { global $conf_system_auth; if ($conf_system_auth == "cas") { require "lib/phpcas/CAS.php"; phpCAS::logout(); } else { $_SESSION = array(); if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 42000, '/'); } session_destroy(); } /* ?><center><h1>Bye-bye</h1></center> <script language="JavaScript"> window.location = "index.php"; </script> <? */ }
function buildsurveysession($surveyid, $preview = false) { global $hitid, $hitname; Yii::trace('start', 'survey.buildsurveysession'); global $secerror, $clienttoken; global $tokensexist; //global $surveyid; global $move, $rooturl; $sLangCode = App()->language; $languagechanger = makeLanguageChangerSurvey($sLangCode); if (!$preview) { $preview = Yii::app()->getConfig('previewmode'); } $thissurvey = getSurveyInfo($surveyid, $sLangCode); $_SESSION['survey_' . $surveyid]['templatename'] = $thissurvey['template']; // $thissurvey['template'] already fixed by model : but why put this in session ? $_SESSION['survey_' . $surveyid]['templatepath'] = getTemplatePath($thissurvey['template']) . DIRECTORY_SEPARATOR; $sTemplatePath = $_SESSION['survey_' . $surveyid]['templatepath']; $loadsecurity = returnGlobal('loadsecurity', true); // NO TOKEN REQUIRED BUT CAPTCHA ENABLED FOR SURVEY ACCESS if ($tokensexist == 0 && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha']) && !isset($_SESSION['survey_' . $surveyid]['captcha_surveyaccessscreen']) && !$preview) { //session_start(); require_once dirname(__FILE__) . "/CAS/CAS.php"; //指定log文件 phpCAS::setDebug('./log.log'); //指定cas地址,最后一个true表示是否cas服务器为https phpCAS::client(CAS_VERSION_2_0, 'ids.hit.edu.cn', 443, 'authserver', true); phpCAS::handleLogoutRequests(); //本地退出应该重定向到CAS进行退出,传递service参数可以使CAS退出后返回本应用 //demo表示退出请求为logout的请求 if (isset($_GET['logout'])) { $param = array('service' => 'http://demo.cas.wisedu.cn:3273/'); phpCAS::logout($param); exit; } //设置no ssl,即忽略证书检查.如果需要ssl,请用 phpCAS::setCasServerCACert()设置 //setCasServerCACert方法设置ssl证书, phpCAS::setNoCasServerValidation(); phpCAS::forceAuthentication(); $hitid = phpCAS::getUser(); $hitname = phpCAS::getAttributes()["cn"]; /*//默认的就是这种状况 // IF CAPTCHA ANSWER IS NOT CORRECT OR NOT SET //echo 2221; if (!isset($loadsecurity) || !isset($_SESSION['survey_'.$surveyid]['secanswer']) || $loadsecurity != $_SESSION['survey_'.$surveyid]['secanswer']) { //echo 111; sendCacheHeaders(); doHeader(); // No or bad answer to required security question $redata = compact(array_keys(get_defined_vars())); //下面一行测试注释掉,除样式没有发现其他影响 //echo templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"),array(),$redata,'frontend_helper[875]'); //echo makedropdownlist(); echo templatereplace(file_get_contents($sTemplatePath."survey.pstpl"),array(),$redata,'frontend_helper[877]'); echo "我们需要对你的身份进行确认,确保你是哈尔滨工业大学师生,请点击下面的按钮进行全校统一认证登录"; if (isset($loadsecurity)) { // was a bad answer echo "<font color='#FF0000'>".gT("The answer to the security question is incorrect.")."</font><br />"; } echo "<p class='captcha'>".gT("Please confirm access to survey by answering the security question below and click continue.")."</p>" .CHtml::form(array("/survey/index","sid"=>$surveyid), 'post', array('class'=>'captcha'))." <table align='center'> <tr> <td align='right' valign='middle'> <input type='hidden' name='sid' value='".$surveyid."' id='sid' /> <input type='hidden' name='lang' value='".$sLangCode."' id='lang' />"; // In case we this is a direct Reload previous answers URL, then add hidden fields if (isset($_GET['loadall']) && isset($_GET['scid']) && isset($_GET['loadname']) && isset($_GET['loadpass'])) { echo " <input type='hidden' name='loadall' value='".htmlspecialchars($_GET['loadall'],ENT_QUOTES, 'UTF-8')."' id='loadall' /> <input type='hidden' name='scid' value='".returnGlobal('scid',true)."' id='scid' /> <input type='hidden' name='loadname' value='".htmlspecialchars($_GET['loadname'],ENT_QUOTES, 'UTF-8')."' id='loadname' /> <input type='hidden' name='loadpass' value='".htmlspecialchars($_GET['loadpass'],ENT_QUOTES, 'UTF-8')."' id='loadpass' />"; } echo " </td> </tr>"; if (function_exists("ImageCreate") && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha'])) { echo "<tr> <td align='center' valign='middle'><label for='captcha'>".gT("Security question:")."</label></td><td align='left' valign='middle'><table><tr><td valign='middle'><img src='".Yii::app()->getController()->createUrl('/verification/image/sid/'.$surveyid)."' alt='captcha' /></td> <td valign='middle'><input id='captcha' type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table> </td> </tr>"; } echo "<tr><td colspan='2' align='center'><input class='submit' type='submit' value='".gT("Continue")."' /></td></tr> </table> </form>"; echo templatereplace(file_get_contents($sTemplatePath."endpage.pstpl"),array(),$redata,'frontend_helper[1567]'); doFooter(); exit; } else{ $_SESSION['survey_'.$surveyid]['captcha_surveyaccessscreen']=true; }*/ } //BEFORE BUILDING A NEW SESSION FOR THIS SURVEY, LET'S CHECK TO MAKE SURE THE SURVEY SHOULD PROCEED! // TOKEN REQUIRED BUT NO TOKEN PROVIDED if ($tokensexist == 1 && !$clienttoken && !$preview) { if ($thissurvey['nokeyboard'] == 'Y') { includeKeypad(); $kpclass = "text-keypad"; } else { $kpclass = ""; } // DISPLAY REGISTER-PAGE if needed // DISPLAY CAPTCHA if needed if (isset($thissurvey) && $thissurvey['allowregister'] == "Y") { // Add the event and test if done Yii::app()->runController("register/index/sid/{$surveyid}"); Yii::app()->end(); } else { sendCacheHeaders(); doHeader(); $redata = compact(array_keys(get_defined_vars())); echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata, 'frontend_helper[1594]'); //echo makedropdownlist(); echo templatereplace(file_get_contents($sTemplatePath . "survey.pstpl"), array(), $redata, 'frontend_helper[1596]'); // ->renderPartial('entertoken_view'); if (isset($secerror)) { echo "<span class='error'>" . $secerror . "</span><br />"; } echo '<div id="wrapper"><p id="tokenmessage">' . gT("This is a controlled survey. You need a valid token to participate.") . "<br />"; echo gT("If you have been issued a token, please enter it in the box below and click continue.") . "</p>\n <script type='text/javascript'>var focus_element='#token';</script>" . CHtml::form(array("/survey/index", "sid" => $surveyid), 'post', array('id' => 'tokenform', 'autocomplete' => 'off')) . "\n <ul>\n <li>"; ?> <label for='token'><?php eT("Token:"); ?> </label><input class='text <?php echo $kpclass; ?> ' id='token' type='password' name='token' value='' /> <?php echo "<input type='hidden' name='sid' value='" . $surveyid . "' id='sid' />\n <input type='hidden' name='lang' value='" . $sLangCode . "' id='lang' />"; if (isset($_GET['newtest']) && $_GET['newtest'] == "Y") { echo " <input type='hidden' name='newtest' value='Y' id='newtest' />"; } // If this is a direct Reload previous answers URL, then add hidden fields if (isset($_GET['loadall']) && isset($_GET['scid']) && isset($_GET['loadname']) && isset($_GET['loadpass'])) { echo "\n <input type='hidden' name='loadall' value='" . htmlspecialchars($_GET['loadall'], ENT_QUOTES, 'UTF-8') . "' id='loadall' />\n <input type='hidden' name='scid' value='" . returnGlobal('scid', true) . "' id='scid' />\n <input type='hidden' name='loadname' value='" . htmlspecialchars($_GET['loadname'], ENT_QUOTES, 'UTF-8') . "' id='loadname' />\n <input type='hidden' name='loadpass' value='" . htmlspecialchars($_GET['loadpass'], ENT_QUOTES, 'UTF-8') . "' id='loadpass' />"; } echo "</li>"; if (function_exists("ImageCreate") && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha'])) { echo "<li>\n <label for='captchaimage'>" . gT("Security Question") . "</label><img id='captchaimage' src='" . Yii::app()->getController()->createUrl('/verification/image/sid/' . $surveyid) . "' alt='captcha' /><input type='text' size='5' maxlength='3' name='loadsecurity' value='' />\n </li>"; } echo "<li>\n <input class='submit button' type='submit' value='" . gT("Continue") . "' />\n </li>\n </ul>\n </form></div>"; echo templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1645]'); doFooter(); exit; } } elseif ($tokensexist == 1 && $clienttoken && !isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha'])) { //check if token actually does exist // check also if it is allowed to change survey after completion if ($thissurvey['alloweditaftercompletion'] == 'Y') { $oTokenEntry = Token::model($surveyid)->findByAttributes(array('token' => $clienttoken)); } else { $oTokenEntry = Token::model($surveyid)->usable()->incomplete()->findByAttributes(array('token' => $clienttoken)); } if (!isset($oTokenEntry)) { //TOKEN DOESN'T EXIST OR HAS ALREADY BEEN USED. EXPLAIN PROBLEM AND EXIT killSurveySession($surveyid); sendCacheHeaders(); doHeader(); $redata = compact(array_keys(get_defined_vars())); echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata, 'frontend_helper[1676]'); echo templatereplace(file_get_contents($sTemplatePath . "survey.pstpl"), array(), $redata, 'frontend_helper[1677]'); echo '<div id="wrapper"><p id="tokenmessage">' . gT("This is a controlled survey. You need a valid token to participate.") . "<br /><br />\n" . "\t" . gT("The token you have provided is either not valid, or has already been used.") . "<br /><br />\n" . "\t" . sprintf(gT("For further information please contact %s"), $thissurvey['adminname']) . " (<a href='mailto:{$thissurvey['adminemail']}'>" . "{$thissurvey['adminemail']}</a>)</p></div>\n"; echo templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1684]'); doFooter(); exit; } } elseif ($tokensexist == 1 && $clienttoken && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha'])) { // IF CAPTCHA ANSWER IS CORRECT if (isset($loadsecurity) && isset($_SESSION['survey_' . $surveyid]['secanswer']) && $loadsecurity == $_SESSION['survey_' . $surveyid]['secanswer']) { if ($thissurvey['alloweditaftercompletion'] == 'Y') { $oTokenEntry = Token::model($surveyid)->findByAttributes(array('token' => $clienttoken)); } else { $oTokenEntry = Token::model($surveyid)->incomplete()->findByAttributes(array('token' => $clienttoken)); } if (!isset($oTokenEntry)) { sendCacheHeaders(); doHeader(); //TOKEN DOESN'T EXIST OR HAS ALREADY BEEN USED. EXPLAIN PROBLEM AND EXIT $redata = compact(array_keys(get_defined_vars())); echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata, 'frontend_helper[1719]'); echo templatereplace(file_get_contents($sTemplatePath . "survey.pstpl"), array(), $redata, 'frontend_helper[1720]'); echo "\t<div id='wrapper'>\n" . "\t<p id='tokenmessage'>\n" . "\t" . gT("This is a controlled survey. You need a valid token to participate.") . "<br /><br />\n" . "\t" . gT("The token you have provided is either not valid, or has already been used.") . "<br/><br />\n" . "\t" . sprintf(gT("For further information please contact %s"), $thissurvey['adminname']) . " (<a href='mailto:{$thissurvey['adminemail']}'>" . "{$thissurvey['adminemail']}</a>)\n" . "\t</p>\n" . "\t</div>\n"; echo templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1731]'); doFooter(); exit; } } else { if (!isset($move) || is_null($move)) { unset($_SESSION['survey_' . $surveyid]['srid']); $gettoken = $clienttoken; sendCacheHeaders(); doHeader(); // No or bad answer to required security question $redata = compact(array_keys(get_defined_vars())); echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata, 'frontend_helper[1745]'); echo templatereplace(file_get_contents($sTemplatePath . "survey.pstpl"), array(), $redata, 'frontend_helper[1746]'); // If token wasn't provided and public registration // is enabled then show registration form if (!isset($gettoken) && isset($thissurvey) && $thissurvey['allowregister'] == "Y") { echo templatereplace(file_get_contents($sTemplatePath . "register.pstpl"), array(), $redata, 'frontend_helper[1751]'); } else { // only show CAPTCHA echo '<div id="wrapper"><p id="tokenmessage">'; if (isset($loadsecurity)) { // was a bad answer echo "<span class='error'>" . gT("The answer to the security question is incorrect.") . "</span><br />"; } echo gT("This is a controlled survey. You need a valid token to participate.") . "<br /><br />"; // IF TOKEN HAS BEEN GIVEN THEN AUTOFILL IT // AND HIDE ENTRY FIELD if (!isset($gettoken)) { echo gT("If you have been issued a token, please enter it in the box below and click continue.") . "</p>\n <form id='tokenform' method='get' action='" . Yii::app()->getController()->createUrl("/survey/index") . "'>\n <ul>\n <li>\n <input type='hidden' name='sid' value='" . $surveyid . "' id='sid' />\n <input type='hidden' name='lang' value='" . $sLangCode . "' id='lang' />"; if (isset($_GET['loadall']) && isset($_GET['scid']) && isset($_GET['loadname']) && isset($_GET['loadpass'])) { echo "<input type='hidden' name='loadall' value='" . htmlspecialchars($_GET['loadall'], ENT_QUOTES, 'UTF-8') . "' id='loadall' />\n <input type='hidden' name='scid' value='" . returnGlobal('scid', true) . "' id='scid' />\n <input type='hidden' name='loadname' value='" . htmlspecialchars($_GET['loadname'], ENT_QUOTES, 'UTF-8') . "' id='loadname' />\n <input type='hidden' name='loadpass' value='" . htmlspecialchars($_GET['loadpass'], ENT_QUOTES, 'UTF-8') . "' id='loadpass' />"; } echo '<label for="token">' . gT("Token") . "</label><input class='text' type='password' id='token' name='token'></li>"; } else { echo gT("Please confirm the token by answering the security question below and click continue.") . "</p>\n <form id='tokenform' method='get' action='" . Yii::app()->getController()->createUrl("/survey/index") . "'>\n <ul>\n <li>\n <input type='hidden' name='sid' value='" . $surveyid . "' id='sid' />\n <input type='hidden' name='lang' value='" . $sLangCode . "' id='lang' />"; if (isset($_GET['loadall']) && isset($_GET['scid']) && isset($_GET['loadname']) && isset($_GET['loadpass'])) { echo "<input type='hidden' name='loadall' value='" . htmlspecialchars($_GET['loadall'], ENT_QUOTES, 'UTF-8') . "' id='loadall' />\n <input type='hidden' name='scid' value='" . returnGlobal('scid', true) . "' id='scid' />\n <input type='hidden' name='loadname' value='" . htmlspecialchars($_GET['loadname'], ENT_QUOTES, 'UTF-8') . "' id='loadname' />\n <input type='hidden' name='loadpass' value='" . htmlspecialchars($_GET['loadpass'], ENT_QUOTES, 'UTF-8') . "' id='loadpass' />"; } echo '<label for="token">' . gT("Token:") . "</label><span id='token'>{$gettoken}</span>" . "<input type='hidden' name='token' value='{$gettoken}'></li>"; } if (function_exists("ImageCreate") && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha'])) { echo "<li>\n <label for='captchaimage'>" . gT("Security Question") . "</label><img id='captchaimage' src='" . Yii::app()->getController()->createUrl('/verification/image/sid/' . $surveyid) . "' alt='captcha' /><input type='text' size='5' maxlength='3' name='loadsecurity' value='' />\n </li>"; } echo "<li><input class='submit' type='submit' value='" . gT("Continue") . "' /></li>\n </ul>\n </form>\n </id>"; } echo '</div>' . templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1817]'); doFooter(); exit; } } } //RESET ALL THE SESSION VARIABLES AND START AGAIN unset($_SESSION['survey_' . $surveyid]['grouplist']); unset($_SESSION['survey_' . $surveyid]['fieldarray']); unset($_SESSION['survey_' . $surveyid]['insertarray']); unset($_SESSION['survey_' . $surveyid]['fieldnamesInfo']); unset($_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . '-randMaster']); unset($_SESSION['survey_' . $surveyid]['groupReMap']); $_SESSION['survey_' . $surveyid]['fieldnamesInfo'] = array(); // Multi lingual support order : by REQUEST, if not by Token->language else by survey default language if (returnGlobal('lang', true)) { $language_to_set = returnGlobal('lang', true); } elseif (isset($oTokenEntry) && $oTokenEntry) { // If survey have token : we have a $oTokenEntry // Can use $oTokenEntry = Token::model($surveyid)->findByAttributes(array('token'=>$clienttoken)); if we move on another function : this par don't validate the token validity $language_to_set = $oTokenEntry->language; } else { $language_to_set = $thissurvey['language']; } // Always SetSurveyLanguage : surveys controller SetSurveyLanguage too, if different : broke survey (#09769) SetSurveyLanguage($surveyid, $language_to_set); UpdateGroupList($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']); $sQuery = "SELECT count(*)\n" . " FROM {{groups}} INNER JOIN {{questions}} ON {{groups}}.gid = {{questions}}.gid\n" . " WHERE {{questions}}.sid=" . $surveyid . "\n" . " AND {{groups}}.language='" . App()->getLanguage() . "'\n" . " AND {{questions}}.language='" . App()->getLanguage() . "'\n" . " AND {{questions}}.parent_qid=0\n"; $totalquestions = Yii::app()->db->createCommand($sQuery)->queryScalar(); $sQuery = "select count(*) from {{groups}}\n left join {{questions}} on {{groups}}.gid={{questions}}.gid\n where {{groups}}.sid={$surveyid} and qid is null"; $iTotalGroupsWithoutQuestions = Yii::app()->db->createCommand($sQuery)->queryScalar(); // Fix totalquestions by substracting Test Display questions $iNumberofQuestions = dbExecuteAssoc("SELECT count(*)\n" . " FROM {{questions}}" . " WHERE type in ('X','*')\n" . " AND sid={$surveyid}" . " AND language='" . $_SESSION['survey_' . $surveyid]['s_lang'] . "'" . " AND parent_qid=0")->read(); $_SESSION['survey_' . $surveyid]['totalquestions'] = $totalquestions - (int) reset($iNumberofQuestions); //2. SESSION VARIABLE: totalsteps //The number of "pages" that will be presented in this survey //The number of pages to be presented will differ depending on the survey format switch ($thissurvey['format']) { case "A": $_SESSION['survey_' . $surveyid]['totalsteps'] = 1; break; case "G": if (isset($_SESSION['survey_' . $surveyid]['grouplist'])) { $_SESSION['survey_' . $surveyid]['totalsteps'] = count($_SESSION['survey_' . $surveyid]['grouplist']); } break; case "S": $_SESSION['survey_' . $surveyid]['totalsteps'] = $totalquestions; } if ($totalquestions == 0 || $iTotalGroupsWithoutQuestions > 0) { sendCacheHeaders(); doHeader(); $redata = compact(array_keys(get_defined_vars())); echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata, 'frontend_helper[1914]'); echo templatereplace(file_get_contents($sTemplatePath . "survey.pstpl"), array(), $redata, 'frontend_helper[1915]'); echo "\t<div id='wrapper'>\n" . "\t<p id='tokenmessage'>\n" . "\t" . gT("This survey cannot be tested or completed for the following reason(s):") . "<br />\n"; echo "<ul>"; if ($totalquestions == 0) { echo '<li>' . gT("There are no questions in this survey.") . '</li>'; } if ($iTotalGroupsWithoutQuestions == 0) { echo '<li>' . gT("There are empty question groups in this survey - please create at least one question within a question group.") . '</li>'; } echo "</ul>" . "\t" . sprintf(gT("For further information please contact %s"), $thissurvey['adminname']) . " (<a href='mailto:{$thissurvey['adminemail']}'>" . "{$thissurvey['adminemail']}</a>)<br /><br />\n" . "\t</p>\n" . "\t</div>\n"; echo templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1925]'); doFooter(); exit; } //Perform a case insensitive natural sort on group name then question title of a multidimensional array // usort($arows, 'groupOrderThenQuestionOrder'); //3. SESSION VARIABLE - insertarray //An array containing information about used to insert the data into the db at the submit stage //4. SESSION VARIABLE - fieldarray //See rem at end.. if ($tokensexist == 1 && $clienttoken) { $_SESSION['survey_' . $surveyid]['token'] = $clienttoken; } if ($thissurvey['anonymized'] == "N") { $_SESSION['survey_' . $surveyid]['insertarray'][] = "token"; } $qtypes = getQuestionTypeList('', 'array'); $fieldmap = createFieldMap($surveyid, 'full', true, false, $_SESSION['survey_' . $surveyid]['s_lang']); // Randomization groups for groups $aRandomGroups = array(); $aGIDCompleteMap = array(); // first find all groups and their groups IDS $criteria = new CDbCriteria(); $criteria->addColumnCondition(array('sid' => $surveyid, 'language' => $_SESSION['survey_' . $surveyid]['s_lang'])); $criteria->addCondition("randomization_group != ''"); $oData = QuestionGroup::model()->findAll($criteria); foreach ($oData as $aGroup) { $aRandomGroups[$aGroup['randomization_group']][] = $aGroup['gid']; } // Shuffle each group and create a map for old GID => new GID foreach ($aRandomGroups as $sGroupName => $aGIDs) { $aShuffledIDs = $aGIDs; shuffle($aShuffledIDs); $aGIDCompleteMap = $aGIDCompleteMap + array_combine($aGIDs, $aShuffledIDs); } $_SESSION['survey_' . $surveyid]['groupReMap'] = $aGIDCompleteMap; $randomized = false; // So we can trigger reorder once for group and question randomization // Now adjust the grouplist if (count($aRandomGroups) > 0 && !$preview) { $randomized = true; // So we can trigger reorder once for group and question randomization // Now adjust the grouplist Yii::import('application.helpers.frontend_helper', true); // make sure frontend helper is loaded UpdateGroupList($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']); // ... and the fieldmap // First create a fieldmap with GID as key foreach ($fieldmap as $aField) { if (isset($aField['gid'])) { $GroupFieldMap[$aField['gid']][] = $aField; } else { $GroupFieldMap['other'][] = $aField; } } // swap it foreach ($GroupFieldMap as $iOldGid => $fields) { $iNewGid = $iOldGid; if (isset($aGIDCompleteMap[$iOldGid])) { $iNewGid = $aGIDCompleteMap[$iOldGid]; } $newGroupFieldMap[$iNewGid] = $GroupFieldMap[$iNewGid]; } $GroupFieldMap = $newGroupFieldMap; // and convert it back to a fieldmap unset($fieldmap); foreach ($GroupFieldMap as $aGroupFields) { foreach ($aGroupFields as $aField) { if (isset($aField['fieldname'])) { $fieldmap[$aField['fieldname']] = $aField; // isset() because of the shuffled flag above } } } unset($GroupFieldMap); } // Randomization groups for questions // Find all defined randomization groups through question attribute values $randomGroups = array(); if (in_array(Yii::app()->db->getDriverName(), array('mssql', 'sqlsrv', 'dblib'))) { $rgquery = "SELECT attr.qid, CAST(value as varchar(255)) as value FROM {{question_attributes}} as attr right join {{questions}} as quests on attr.qid=quests.qid WHERE attribute='random_group' and CAST(value as varchar(255)) <> '' and sid={$surveyid} GROUP BY attr.qid, CAST(value as varchar(255))"; } else { $rgquery = "SELECT attr.qid, value FROM {{question_attributes}} as attr right join {{questions}} as quests on attr.qid=quests.qid WHERE attribute='random_group' and value <> '' and sid={$surveyid} GROUP BY attr.qid, value"; } $rgresult = dbExecuteAssoc($rgquery); foreach ($rgresult->readAll() as $rgrow) { // Get the question IDs for each randomization group $randomGroups[$rgrow['value']][] = $rgrow['qid']; } // If we have randomization groups set, then lets cycle through each group and // replace questions in the group with a randomly chosen one from the same group if (count($randomGroups) > 0 && !$preview) { $randomized = true; // So we can trigger reorder once for group and question randomization $copyFieldMap = array(); $oldQuestOrder = array(); $newQuestOrder = array(); $randGroupNames = array(); foreach ($randomGroups as $key => $value) { $oldQuestOrder[$key] = $randomGroups[$key]; $newQuestOrder[$key] = $oldQuestOrder[$key]; // We shuffle the question list to get a random key->qid which will be used to swap from the old key shuffle($newQuestOrder[$key]); $randGroupNames[] = $key; } // Loop through the fieldmap and swap each question as they come up foreach ($fieldmap as $fieldkey => $fieldval) { $found = 0; foreach ($randomGroups as $gkey => $gval) { // We found a qid that is in the randomization group if (isset($fieldval['qid']) && in_array($fieldval['qid'], $oldQuestOrder[$gkey])) { // Get the swapped question $idx = array_search($fieldval['qid'], $oldQuestOrder[$gkey]); foreach ($fieldmap as $key => $field) { if (isset($field['qid']) && $field['qid'] == $newQuestOrder[$gkey][$idx]) { $field['random_gid'] = $fieldval['gid']; // It is possible to swap to another group $copyFieldMap[$key] = $field; } } $found = 1; break; } else { $found = 2; } } if ($found == 2) { $copyFieldMap[$fieldkey] = $fieldval; } reset($randomGroups); } $fieldmap = $copyFieldMap; } if ($randomized === true) { // reset the sequencing counts $gseq = -1; $_gid = -1; $qseq = -1; $_qid = -1; $copyFieldMap = array(); foreach ($fieldmap as $key => $val) { if ($val['gid'] != '') { if (isset($val['random_gid'])) { $gid = $val['random_gid']; } else { $gid = $val['gid']; } if ($gid != $_gid) { $_gid = $gid; ++$gseq; } } if ($val['qid'] != '' && $val['qid'] != $_qid) { $_qid = $val['qid']; ++$qseq; } if ($val['gid'] != '' && $val['qid'] != '') { $val['groupSeq'] = $gseq; $val['questionSeq'] = $qseq; } $copyFieldMap[$key] = $val; } $fieldmap = $copyFieldMap; unset($copyFieldMap); $_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . $_SESSION['survey_' . $surveyid]['s_lang']] = $fieldmap; $_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . '-randMaster'] = 'fieldmap-' . $surveyid . $_SESSION['survey_' . $surveyid]['s_lang']; } // TMSW Condition->Relevance: don't need hasconditions, or usedinconditions $_SESSION['survey_' . $surveyid]['fieldmap'] = $fieldmap; foreach ($fieldmap as $field) { if (isset($field['qid']) && $field['qid'] != '') { $_SESSION['survey_' . $surveyid]['fieldnamesInfo'][$field['fieldname']] = $field['sid'] . 'X' . $field['gid'] . 'X' . $field['qid']; $_SESSION['survey_' . $surveyid]['insertarray'][] = $field['fieldname']; //fieldarray ARRAY CONTENTS - // [0]=questions.qid, // [1]=fieldname, // [2]=questions.title, // [3]=questions.question // [4]=questions.type, // [5]=questions.gid, // [6]=questions.mandatory, // [7]=conditionsexist, // [8]=usedinconditions // [8]=usedinconditions // [9]=used in group.php for question count // [10]=new group id for question in randomization group (GroupbyGroup Mode) if (!isset($_SESSION['survey_' . $surveyid]['fieldarray'][$field['sid'] . 'X' . $field['gid'] . 'X' . $field['qid']])) { //JUST IN CASE : PRECAUTION! //following variables are set only if $style=="full" in createFieldMap() in common_helper. //so, if $style = "short", set some default values here! if (isset($field['title'])) { $title = $field['title']; } else { $title = ""; } if (isset($field['question'])) { $question = $field['question']; } else { $question = ""; } if (isset($field['mandatory'])) { $mandatory = $field['mandatory']; } else { $mandatory = 'N'; } if (isset($field['hasconditions'])) { $hasconditions = $field['hasconditions']; } else { $hasconditions = 'N'; } if (isset($field['usedinconditions'])) { $usedinconditions = $field['usedinconditions']; } else { $usedinconditions = 'N'; } $_SESSION['survey_' . $surveyid]['fieldarray'][$field['sid'] . 'X' . $field['gid'] . 'X' . $field['qid']] = array($field['qid'], $field['sid'] . 'X' . $field['gid'] . 'X' . $field['qid'], $title, $question, $field['type'], $field['gid'], $mandatory, $hasconditions, $usedinconditions); } if (isset($field['random_gid'])) { $_SESSION['survey_' . $surveyid]['fieldarray'][$field['sid'] . 'X' . $field['gid'] . 'X' . $field['qid']][10] = $field['random_gid']; } } } // Prefill questions/answers from command line params $reservedGetValues = array('token', 'sid', 'gid', 'qid', 'lang', 'newtest', 'action'); $startingValues = array(); if (isset($_GET)) { foreach ($_GET as $k => $v) { if (!in_array($k, $reservedGetValues) && isset($_SESSION['survey_' . $surveyid]['fieldmap'][$k])) { $startingValues[$k] = $v; } else { // Search question codes to use those for prefilling. foreach ($_SESSION['survey_' . $surveyid]['fieldmap'] as $sgqa => $details) { if ($details['title'] == $k) { $startingValues[$sgqa] = $v; } } } } } $_SESSION['survey_' . $surveyid]['startingValues'] = $startingValues; if (isset($_SESSION['survey_' . $surveyid]['fieldarray'])) { $_SESSION['survey_' . $surveyid]['fieldarray'] = array_values($_SESSION['survey_' . $surveyid]['fieldarray']); } //Check if a passthru label and value have been included in the query url $oResult = SurveyURLParameter::model()->getParametersForSurvey($surveyid); foreach ($oResult->readAll() as $aRow) { if (isset($_GET[$aRow['parameter']]) && !$preview) { $_SESSION['survey_' . $surveyid]['urlparams'][$aRow['parameter']] = $_GET[$aRow['parameter']]; if ($aRow['targetqid'] != '') { foreach ($fieldmap as $sFieldname => $aField) { if ($aRow['targetsqid'] != '') { if ($aField['qid'] == $aRow['targetqid'] && $aField['sqid'] == $aRow['targetsqid']) { $_SESSION['survey_' . $surveyid]['startingValues'][$sFieldname] = $_GET[$aRow['parameter']]; $_SESSION['survey_' . $surveyid]['startingValues'][$aRow['parameter']] = $_GET[$aRow['parameter']]; } } else { if ($aField['qid'] == $aRow['targetqid']) { $_SESSION['survey_' . $surveyid]['startingValues'][$sFieldname] = $_GET[$aRow['parameter']]; $_SESSION['survey_' . $surveyid]['startingValues'][$aRow['parameter']] = $_GET[$aRow['parameter']]; } } } } } } Yii::trace('end', 'survey.buildsurveysession'); }
/** * logout from the cas * * This function is called from admin/auth.php * */ function prelogout_hook() { global $CFG; if ($this->config->logoutcas) { $backurl = $CFG->wwwroot; $this->connectCAS(); phpCAS::logout($backurl); } }
public function logout_cas() { include_once('CAS.php'); // config_cas.inc.php est le fichier d'informations de connexions au serveur cas $path = dirname(__FILE__)."/../secure/config_cas.inc.php"; include($path); // Le premier argument est la version du protocole CAS phpCAS::client(CAS_VERSION_2_0,$cas_host,$cas_port,$cas_root,''); phpCAS::setLang(PHPCAS_LANG_FRENCH); if ($cas_use_logout) { phpCAS::logout(); }else{ if ($cas_logout_url != '') { header("Location:".$cas_logout_url); exit(); }else{ // Il faudra trouver mieux echo '<html><head><title>GEPI</title></head><body><h2>Vous êtes déconnecté.</h2></body></html>'; exit(); } } // redirige vers le serveur d'authentification si aucun utilisateur authentifié n'a // été trouvé par le client CAS. //phpCAS::setNoCasServerValidation(); //phpCAS::forceAuthentication(); //$this->login = phpCAS::getUser(); // On réinitialise la session //session_name("GEPI"); //session_start(); //$_SESSION['login'] = $this->login; //$this->current_auth_mode = "sso"; return true; }
} // Render $claroline->display->body->setContent($template->render()); if (!(isset($_REQUEST['logout']) && isset($_SESSION['isVirtualUser']))) { echo $claroline->display->render(); } } else { require_once get_path('clarolineRepositorySys') . '/desktop/index.php'; } // Logout request : delete session data if (isset($_REQUEST['logout'])) { if (isset($_SESSION['isVirtualUser'])) { unset($_SESSION['isVirtualUser']); claro_redirect(get_conf('rootWeb') . 'claroline/admin/admin_users.php'); exit; } // notify that a user has just loggued out if (isset($logout_uid)) { $eventNotifier->notifyEvent('user_logout', array('uid' => $logout_uid)); } /* needed to be able to : - log with claroline when 'magic login' has previously been clicked - notify logout event (logout from CAS has been commented in casProcess.inc.php)*/ if (get_conf('claro_CasEnabled', false) && (get_conf('claro_CasGlobalLogout') && !phpCAS::checkAuthentication())) { phpCAS::logout((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . get_conf('urlAppend') . '/index.php'); } session_destroy(); } // Hide breadcrumbs and view mode on platform home page // $claroline->display->banner->hideBreadcrumbLine();
// Exemple simple de login amb CAS // Llibreria CAS require_once 'CAS.php'; // Inicialitzem phpCAS phpCAS::client(CAS_VERSION_2_0, "cas.upc.edu", 443, ""); // En entorns de producció s'hauria d'especificar el path del certificat del servidor CAS //phpCAS::setCasServerCACert("path"); // Per aquesta prova simplement indiquem que no validi l'autenticitat del servidor de CAS phpCAS::setNoCasServerValidation(); // Forcem l'autenticacio... phpCAS::forceAuthentication(); // En aquest punt l'usuari ja ha seigut autenticat pel servidor de CAS // podem llegir el seu usuari amb phpCAS::getUser(). // Si s'ha clicat logout, fem logout amb phpCAS::logout(); if (isset($_REQUEST['logout'])) { phpCAS::logout(); } ?> <!--Indiquem a l'susuari que s'ha loguejat correctament i mostrem la versió del CAS--> <html> <head> <title>Exemple login CAS</title> </head> <body> <h1>Has entrat correctament!</h1> <p>El teu nom d'usuari es <b><?php echo phpCAS::getUser(); ?> </b>.</p> <p>La verisó de phpCAS es <b><?php echo phpCAS::getVersion();
public static function logout() { self::init(); phpCAS::logout(); return true; }