public function auth_sspi() { global $ATK_VARS; if (isset($ATK_VARS['atklogout'])) { if ($this->validateUser() == SecurityManager::AUTH_SUCCESS) { // On se reconnecte par defaut $session =& SessionManager::getSession(); $session['relogin'] = 1; } } }
/** * Handle the error. * * @param string $errorMessage * @param string $debugMessage */ public function handle($errorMessage, $debugMessage) { $sessionManager = SessionManager::getInstance(); $sessionData =& SessionManager::getSession(); $txt_app_title = Tools::atktext('app_title'); if ($this->params['mailto'] != '') { // only if enabled.. $atk = Atk::getInstance(); $subject = '[' . $_SERVER['SERVER_NAME'] . "] {$txt_app_title} error"; $defaultfrom = sprintf('%s <%s@%s>', $txt_app_title, Config::getGlobal('identifier', 'atk'), $_SERVER['SERVER_NAME']); $from = Config::getGlobal('mail_sender', $defaultfrom); $body = "Hello,\n\nAn error seems to have occurred in the atk application named '{$txt_app_title}'.\n"; $body .= "\nThe errormessage was:\n\n" . implode("\n", is_array($errorMessage) ? $errorMessage : array()) . "\n"; $body .= "\nA detailed report follows:\n"; $body .= "\nPHP Version: " . phpversion() . "\n\n"; $body .= "\nDEBUGMESSAGES\n" . str_repeat('-', 70) . "\n"; $lines = []; for ($i = 0, $_ = count($debugMessage); $i < $_; ++$i) { $lines[] = $this->_wordwrap(Tools::atk_html_entity_decode(preg_replace('(\\[<a.*</a>\\])', '', $debugMessage[$i]))); } $body .= implode("\n", $lines); if (is_array($_GET)) { $body .= "\n\n_GET\n" . str_repeat('-', 70) . "\n"; foreach ($_GET as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } if (function_exists('getallheaders')) { $request = getallheaders(); if (count($request) > 0) { $body .= "\n\nREQUEST INFORMATION\n" . str_repeat('-', 70) . "\n"; foreach ($request as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } if (is_array($_POST)) { $body .= "\n\n_POST\n" . str_repeat('-', 70) . "\n"; foreach ($_POST as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } if (is_array($_COOKIE)) { $body .= "\n\n_COOKIE\n" . str_repeat('-', 70) . "\n"; foreach ($_COOKIE as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } $body .= "\n\nATK CONFIGURATION\n" . str_repeat('-', 70) . "\n"; foreach ($GLOBALS as $key => $value) { if (substr($key, 0, 7) == 'config_') { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } $body .= "\n\nMODULE CONFIGURATION\n" . str_repeat('-', 70) . "\n"; foreach ($atk->g_modules as $modname => $modpath) { $modexists = file_exists($modpath) ? ' (path exists)' : ' (PATH DOES NOT EXIST!)'; $body .= $this->_wordwrap($modname . ':' . str_repeat(' ', max(1, 20 - strlen($modname))) . var_export($modpath, 1) . $modexists) . "\n"; } $body .= "\n\nCurrent User:\n" . str_repeat('-', 70) . "\n"; $user = SecurityManager::atkGetUser(); if (is_array($user) && count($user)) { foreach ($user as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } else { $body .= "Not known\n"; } if (is_object($sessionManager)) { $body .= "\n\nATK SESSION\n" . str_repeat('-', 70); $body .= "\nNamespace: " . $sessionManager->getNameSpace() . "\n"; if (isset($sessionData[$sessionManager->getNameSpace()]['stack'])) { $stack = $sessionData[$sessionManager->getNameSpace()]['stack']; for ($i = 0; $i < count($stack); ++$i) { $body .= "\nStack level {$i}:\n"; $item = isset($stack[$i]) ? $stack[$i] : null; if (is_array($item)) { foreach ($item as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } } if (isset($sessionData[$sessionManager->getNameSpace()]['globals'])) { $ns_globals = $sessionData[$sessionManager->getNameSpace()]['globals']; if (count($ns_globals) > 0) { $body .= "\nNamespace globals:\n"; foreach ($ns_globals as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } if (isset($sessionData['globals'])) { $globals = $sessionData['globals']; if (count($globals) > 0) { $body .= "\nGlobals:\n"; foreach ($globals as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 30 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } } } } $body .= "\n\nSERVER INFORMATION\n" . str_repeat('-', 70) . "\n"; foreach ($_SERVER as $key => $value) { $body .= $this->_wordwrap($key . str_repeat(' ', max(1, 20 - strlen($key))) . ' = ' . var_export($value, 1)) . "\n"; } //TODO: replace with some mailer object mail($this->params['mailto'], $subject, $body, "From: {$from}"); } }
/** * the real import function * import the uploaded csv file for real. */ public function doExport() { $enclosure = $this->m_postvars['enclosure']; $delimiter = $this->m_postvars['delimiter']; $source = $this->m_postvars; $list_includes = []; foreach ($source as $name => $value) { $pos = strpos($name, 'export_'); if (is_integer($pos) and $pos == 0) { $list_includes[] = substr($name, strlen('export_')); } } $sm = SessionManager::getInstance(); $sessionData =& SessionManager::getSession(); $session_back = $sessionData['default']['stack'][$sm->atkStackID()][$sm->atkLevel() - 1]; $atkorderby = $session_back['atkorderby']; $node = $this->m_node; $node_bk = $node; $num_atts = count($node_bk->m_attribList); $atts =& $node_bk->m_attribList; foreach ($atts as $name => $object) { $att = $node_bk->getAttribute($name); if (in_array($name, $list_includes) && $att->hasFlag(Attribute::AF_HIDE_LIST)) { $att->removeFlag(Attribute::AF_HIDE_LIST); } elseif (!in_array($name, $list_includes)) { $att->addFlag(Attribute::AF_HIDE_LIST); } } $rl = new CustomRecordList(); $flags = ($node_bk->hasFlag(Node::NF_MRA) ? RecordList::RL_MRA : 0) | ($node_bk->hasFlag(Node::NF_MRPA) ? RecordList::RL_MRPA : 0); $node_bk->m_postvars = $session_back; if (isset($session_back['atkdg']['admin']['atksearch'])) { $node_bk->m_postvars['atksearch'] = $session_back['atkdg']['admin']['atksearch']; } if (isset($session_back['atkdg']['admin']['atksearchmode'])) { $node_bk->m_postvars['atksearchmode'] = $session_back['atkdg']['admin']['atksearchmode']; } $atkfilter = Tools::atkArrayNvl($source, 'atkfilter', ''); $condition = $session_back['atkselector'] . ($session_back['atkselector'] != '' && $atkfilter != '' ? ' AND ' : '') . $atkfilter; $recordset = $node_bk->select($condition)->orderBy($atkorderby)->includes($list_includes)->mode('export')->getAllRows(); if (method_exists($this->m_node, 'assignExportData')) { $this->m_node->assignExportData($list_includes, $recordset); } $recordset_new = []; foreach ($recordset as $row) { foreach ($row as $name => $value) { if (in_array($name, $list_includes)) { $value = str_replace("\r\n", '\\n', $value); $value = str_replace("\n", '\\n', $value); $value = str_replace("\t", '\\t', $value); $row[$name] = $value; } } $recordset_new[] = $row; } $filename = 'export_' . strtolower(str_replace(' ', '_', $this->getUi()->nodeTitle($node))); $rl->render($node_bk, $recordset_new, '', $enclosure, $enclosure, "\r\n", 1, '', '', array('filename' => $filename), 'csv', $source['generatetitlerow'], true, $delimiter); return true; }
/** * Retrieve all known information about the currently logged-in user. * * @param $key string * * @return array Array with userinfo, or "" if no user is logged in. */ public static function atkGetUser($key = '') { $sm = SessionManager::getInstance(); $session = SessionManager::getSession(); $user = ''; $session_auth = is_object($sm) ? $sm->getValue('authentication', 'globals') : []; if (Config::getGlobal('authentication_session') && Tools::atkArrayNvl($session, 'login', 0) == 1 && $session_auth['authenticated'] == 1 && !empty($session_auth['user'])) { $user = $session_auth['user']; if (!isset($user['access_level']) || empty($user['access_level'])) { $user['access_level'] = 0; } } if ($key) { return $user[$key]; } return $user; }
/** * Generate the dispatcher. */ public function atkGenerateDispatcher() { global $ATK_VARS; $session =& SessionManager::getSession(); if ($session['login'] != 1) { // no nodetype passed, or session expired $destination = ''; if (isset($ATK_VARS['atknodeuri']) && isset($ATK_VARS['atkaction'])) { $destination = '&atknodeuri=' . $ATK_VARS['atknodeuri'] . '&atkaction=' . $ATK_VARS['atkaction']; if (isset($ATK_VARS['atkselector'])) { $destination .= '&atkselector=' . $ATK_VARS['atkselector']; } } $box = $this->m_ui->renderBox(array('title' => Tools::atktext('title_session_expired'), 'content' => '<br><br>' . Tools::atktext('explain_session_expired') . '<br><br><br><br> <a href="' . Config::getGlobal('dispatcher') . '?atklogout=true' . $destination . '" target="_top">' . Tools::atktext('relogin') . '</a><br><br>')); $this->m_page->addContent($box); $this->m_output->output($this->m_page->render(Tools::atktext('title_session_expired'), true)); } else { // Create node if (isset($ATK_VARS['atknodeuri'])) { $node = $this->atk->atkGetNode($ATK_VARS['atknodeuri']); $this->loadDispatchPage($ATK_VARS, $node); } else { if (is_array($this->m_defaultDestination)) { // using dispatch_url to redirect to the node $isIndexed = array_values($this->m_defaultDestination) === $this->m_defaultDestination; if ($isIndexed) { $destination = Tools::dispatch_url($this->m_defaultDestination[0], $this->m_defaultDestination[1], $this->m_defaultDestination[2] ? $this->m_defaultDestination[2] : array()); } else { $destination = Tools::dispatch_url($this->m_defaultDestination['atknodeuri'], $this->m_defaultDestination['atkaction'], $this->m_defaultDestination[0] ? $this->m_defaultDestination[0] : array()); } header('Location: ' . $destination); exit; } else { $this->renderContent(); } } } }