示例#1
0
 /**
  * The action handler method. Creates an xml document and outputs it to the browser.
  */
 public function action_xml()
 {
     $recordset = $this->m_node->select($this->m_postvars['atkselector'])->mode('xml')->getAllRows();
     $output = Output::getInstance();
     $document = '<?xml version="1.0"?>' . "\n";
     for ($i = 0, $_i = count($recordset); $i < $_i; ++$i) {
         $document .= $this->invoke('xml', $recordset[$i]) . "\n";
     }
     $output->output($document);
 }
示例#2
0
文件: Tools.php 项目: sintattica/atk
 public static function redirect($location, $exit = true)
 {
     // The actual redirect.
     if (Config::getGlobal('debug') >= 2) {
         $debugger = Debugger::getInstance();
         $debugger->setRedirectUrl($location);
         self::atkdebug('Non-debug version would have redirected to <a href="' . $location . '">' . $location . '</a>');
         if ($exit) {
             $output = Output::getInstance();
             $output->outputFlush();
             exit;
         }
     } else {
         self::atkdebug('redirecting to: ' . $location);
         if (substr($location, -1) == '&') {
             $location = substr($location, 0, -1);
         }
         if (substr($location, -1) == '?') {
             $location = substr($location, 0, -1);
         }
         header('Location: ' . $location);
         if ($exit) {
             exit;
         }
     }
 }
示例#3
0
 /**
  * Display a login form.
  *
  * @param string $defaultname The username that might already be known
  * @param int $lastresponse The lastresponse when trying to login
  *                             possible values:
  *                             SecurityManager::AUTH_MISMATCH,
  *                             SecurityManager::AUTH_LOCKED,
  *                             SecurityManager::AUTH_MISSINGUSERNAME,
  *                             SecurityManager::AUTH_PASSWORDSENT
  */
 public function loginForm($defaultname, $lastresponse)
 {
     $page = Page::getInstance();
     $ui = Ui::getInstance();
     $page->register_script(Config::getGlobal('assets_url') . 'javascript/tools.js');
     $tplvars = [];
     $output = '<form action="' . Config::getGlobal('dispatcher') . '" method="post">';
     $output .= Tools::makeHiddenPostvars(array('atklogout'));
     $output .= '<br><br><table border="0" cellspacing="2" cellpadding="0" align="center">';
     $tplvars['atksessionformvars'] = Tools::makeHiddenPostvars(['atklogout', 'auth_rememberme']);
     $tplvars['formurl'] = Config::getGlobal('dispatcher');
     $tplvars['username'] = Tools::atktext('username');
     $tplvars['password'] = Tools::atktext('password');
     $tplvars['userfield'] = '<input class="form-control loginform" type="text" size="20" id="auth_user" name="auth_user" value="' . htmlentities($defaultname) . '" />';
     $tplvars['passwordfield'] = '<input class="loginform" type="password" size="20" name="auth_pw" value="" />';
     $tplvars['submitbutton'] = '<input name="login" class="button" type="submit" value="' . Tools::atktext('login') . '" />';
     $tplvars['title'] = Tools::atktext('login_form');
     if ($lastresponse == self::AUTH_LOCKED) {
         $output .= '<tr><td colspan=3 class=error>' . Tools::atktext('auth_account_locked') . '<br><br></td></tr>';
         $tplvars['auth_account_locked'] = Tools::atktext('auth_account_locked');
         $tplvars['error'] = Tools::atktext('auth_account_locked');
     } elseif ($lastresponse == self::AUTH_MISMATCH) {
         $output .= '<tr><td colspan=3 class=error>' . Tools::atktext('auth_mismatch') . '<br><br></td></tr>';
         $tplvars['auth_mismatch'] = Tools::atktext('auth_mismatch');
         $tplvars['error'] = Tools::atktext('auth_mismatch');
     } elseif ($lastresponse == self::AUTH_MISSINGUSERNAME) {
         $output .= '<tr><td colspan="3" class=error>' . Tools::atktext('auth_missingusername') . '<br /><br /></td></tr>';
         $tplvars['auth_mismatch'] = Tools::atktext('auth_missingusername');
         $tplvars['error'] = Tools::atktext('auth_missingusername');
     } elseif ($lastresponse == self::AUTH_PASSWORDSENT) {
         $output .= '<tr><td colspan="3">' . Tools::atktext('auth_passwordmail_sent') . '<br /><br /></td></tr>';
         $tplvars['auth_mismatch'] = Tools::atktext('auth_passwordmail_sent');
     }
     if (Config::getGlobal('auth_enable_rememberme')) {
         $tplvars['auth_enable_rememberme'] = true;
         if (isset($_POST['auth_rememberme']) && $_POST['auth_rememberme'] == '1') {
             $tplvars['auth_rememberme'] = true;
         }
     }
     // generate the form
     $output .= '<tr><td valign=top>' . Tools::atktext('username') . '</td><td>:</td><td>' . $tplvars['userfield'] . '</td></tr>';
     $output .= '<tr><td colspan=3 height=6></td></tr>';
     $output .= '<tr><td valign=top>' . Tools::atktext('password') . "</td><td>:</td><td><input type=password size=15 name=auth_pw value='' /></td></tr>";
     $output .= '<tr><td colspan="3" align="center" height="50" valign="middle">';
     $output .= '<input name="login" class="button" type="submit" value="' . Tools::atktext('login') . '">';
     $tplvars['auth_enablepasswordmailer'] = $this->get_enablepasswordmailer();
     if ($this->get_enablepasswordmailer()) {
         $output .= '&nbsp;&nbsp;<input name="login" class="button" type="submit" value="' . Tools::atktext('password_forgotten') . '">';
         $tplvars['forgotpasswordbutton'] = '<input name="login" class="button" type="submit" value="' . Tools::atktext('password_forgotten') . '">';
     }
     $output .= '</td></tr>';
     $output .= '</table></form>';
     $tplvars['content'] = $output;
     $page->addContent($ui->render('login.tpl', $tplvars));
     $o = Output::getInstance();
     $o->output($page->render(Tools::atktext('app_title'), Page::HTML_STRICT, '', $ui->render('login_meta.tpl')));
 }