コード例 #1
0
ファイル: Default.php プロジェクト: nsams/koala-framework
 public function sendContent($includeMaster)
 {
     $benchmarkEnabled = Kwf_Benchmark::isEnabled();
     if (Kwf_Util_Https::supportsHttps()) {
         $foundRequestHttps = Kwf_Util_Https::doesComponentRequestHttps($this->_data);
         if (isset($_SERVER['HTTPS'])) {
             //we are on https
             if (!$foundRequestHttps && isset($_COOKIE['kwcAutoHttps']) && !Zend_Session::sessionExists() && !Zend_Session::isStarted()) {
                 //we where auto-redirected to https but don't need https anymore
                 setcookie('kwcAutoHttps', '', 0, '/');
                 //delete cookie
                 Kwf_Util_Https::ensureHttp();
             }
         } else {
             //we are on http
             if ($foundRequestHttps) {
                 setcookie('kwcAutoHttps', '1', 0, '/');
                 Kwf_Util_Https::ensureHttps();
             }
         }
         if ($benchmarkEnabled) {
             Kwf_Benchmark::checkpoint('check requestHttps');
         }
     }
     if ($benchmarkEnabled) {
         $startTime = microtime(true);
     }
     $process = $this->_getProcessInputComponents($includeMaster);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::subCheckpoint('getProcessInputComponents', microtime(true) - $startTime);
     }
     self::_callProcessInput($process);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('processInput');
     }
     $hasDynamicParts = false;
     $out = $this->_render($includeMaster, $hasDynamicParts);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('render');
     }
     header('Content-Type: text/html; charset=utf-8');
     if (!$hasDynamicParts) {
         $lifetime = 60 * 60;
         header('Cache-Control: public, max-age=' . $lifetime);
         header('Expires: ' . gmdate("D, d M Y H:i:s \\G\\M\\T", time() + $lifetime));
         header('Pragma: public');
     }
     echo $out;
     self::_callPostProcessInput($process);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('postProcessInput');
     }
 }
コード例 #2
0
ファイル: View.php プロジェクト: nsams/koala-framework
 /**
  * Create a .txt.tpl or .html.tpl file and set $template to the path.
  * @param string|Kwc_Abstract|Kwf_Component_Data $template: If it's a
  *          string it should point to the template in /views/mails. It's
  *          also possible to use a 'Kwc_Abstract' or 'Kwf_Component_Data'
  *          (This is used when the template destination is in this component-folder).
  *          There are no absolute paths allowed.
  * @param string $masterTemplate
  */
 public function __construct($template, $masterTemplate = 'Master')
 {
     parent::__construct();
     if (is_object($template) || in_array($template, Kwc_Abstract::getComponentClasses())) {
         if (is_object($template)) {
             if ($template instanceof Kwc_Abstract) {
                 $template = $template->getData();
             }
             if (!$template instanceof Kwf_Component_Data) {
                 throw new Kwf_Exception("template must be instance of 'Kwc_Abstract' or 'Kwf_Component_Data'");
             }
             $template = $template->componentClass;
         }
         $this->_txtTemplate = Kwc_Admin::getComponentFile($template, 'Component', 'txt.tpl');
         if (!$this->_txtTemplate) {
             throw new Kwf_Exception("Component class '{$template}' needs at least a .txt.tpl mail template.");
         }
         $this->_htmlTemplate = Kwc_Admin::getComponentFile($template, 'Component', 'html.tpl');
     } else {
         if (substr($template, 0, 1) == '/') {
             throw new Kwf_Exception("Absolute mail template paths are not allowed. You called '{$template}'.");
         }
         if (false === $this->getScriptPath("{$template}.txt.tpl")) {
             $template = "mails/{$template}";
             if (false === $this->getScriptPath("{$template}.txt.tpl")) {
                 throw new Kwf_Exception("There has to exist at least a .txt.tpl mail template for '{$template}'.");
             }
         }
         $this->_txtTemplate = "{$template}.txt.tpl";
         if (false !== $this->getScriptPath("{$template}.html.tpl")) {
             $this->_htmlTemplate = "{$template}.html.tpl";
         }
     }
     $this->_mailTplViewMasterTemplate = $masterTemplate;
     if (isset($_SERVER['HTTP_HOST'])) {
         $host = $_SERVER['HTTP_HOST'];
     } else {
         $host = Kwf_Registry::get('config')->server->domain;
     }
     $this->webUrl = (Kwf_Util_Https::supportsHttps() ? 'https' : 'http') . '://' . $host;
     $this->host = $host;
     $this->applicationName = Kwf_Registry::get('config')->application->name;
 }
コード例 #3
0
ファイル: Autologin.php プロジェクト: nsams/koala-framework
 public static function setCookies($authedUser)
 {
     $cookieValue = $authedUser->id . '.' . $authedUser->generateAutoLoginToken();
     setcookie('feAutologin', $cookieValue, time() + 100 * 24 * 60 * 60, '/', null, Kwf_Util_Https::supportsHttps(), true);
     setcookie('hasFeAutologin', '1', time() + 100 * 24 * 60 * 60, '/', null, false, true);
 }