public function render()
 {
     // TODO Do not use global
     global $microblogTemplates, $pageTitle, $pageAuthor, $post;
     $postView = new PostView();
     $activitiesView = new ActivitiesView();
     $profileView = new ProfileView();
     $followView = new FollowView();
     $tpl = new \rubisco\text\SimpleTemplate($microblogTemplates);
     $tpl->pageAuthor = $pageAuthor;
     $tpl->pageTitle = $pageTitle;
     $tpl->showLog = '';
     $tpl->login = "******";
     $tpl->infoMessage = $this->m->getLastInfoMessagesAsHTML();
     $tpl->postView = '';
     $tpl->activities = $activitiesView->html();
     $tpl->profile = $profileView->html();
     $tpl->follow = $followView->html();
     if ($this->m->isLogin()) {
         $tpl->showLog = '<li><a href="?showLog=1">Show Log</a></li>';
         $tpl->login = "******";
         $tpl->postView = $postView->html($post['message'], $post['to']);
     }
     $this->m->clearLastInfoMessages();
     $content = $tpl->render('head') . $tpl->render('main') . $tpl->render('foot');
     header('Content-Type: text/html; charset=utf-8');
     header('Content-Length: ' . strlen($content));
     echo $content;
 }
    public function testTextToLinks()
    {
        $text = <<<TEXT
http://www.example.org/
http://www.example.org/index.html
http://www.example.org/foo-bar_bazz.html
http://www.example.org/index.html?foo=1
TEXT;
        $expected = <<<HTML
<a href='http://www.example.org/'>http://www.example.org/</a>
<a href='http://www.example.org/index.html'>http://www.example.org/index.html</a>
<a href='http://www.example.org/foo-bar_bazz.html'>http://www.example.org/foo-bar_bazz.html</a>
<a href='http://www.example.org/index.html?foo=1'>http://www.example.org/index.html?foo=1</a>
HTML;
        $this->assertEquals($expected, $this->m->textToLinks($text));
    }
    public function render()
    {
        // TODO Do not use global
        global $microblogTemplates, $pageTitle, $pageAuthor, $post;
        $content = '';
        $tpl = new \rubisco\text\SimpleTemplate($microblogTemplates);
        $tpl->pageAuthor = $pageAuthor;
        $tpl->pageTitle = $pageTitle;
        $tpl->showLog = '';
        $tpl->login = '';
        $content = $tpl->render('head');
        $content .= $this->m->getLastInfoMessagesAsHTML();
        // TODO Dont print if already in lastInfoMessage
        if (!isset($_COOKIE['PHPSESSID'])) {
            $content .= "<p class='note'>Note: For login cookies must be enabled.</p>\n";
        }
        $content .= <<<HTML
<form action="" method="post">
  <p>
    <label for="name">Username</label>
    <input type="text" id="username" name="username" size="20" maxlength="20" value="" />
    <br />

    <label for="name">Password</label>
    <input type="password" id="password" name="password" size="20" maxlength="256" value="" />
    <br />

    <input type="submit" name="loginCancel" value="Cancel" />
    <input type="submit" name="login" value="Login" />
  </p>
</form>
HTML;
        $content .= $tpl->render('foot');
        $this->m->clearLastInfoMessages();
        header('Content-Type: text/html; charset=utf-8');
        header('Content-Length: ' . strlen($content));
        echo $content;
    }
 public function __construct()
 {
     $this->logger = \Logger::getLogger(__CLASS__);
     $this->m = Microblog::getInstance();
 }
 public function __construct()
 {
     $this->m = Microblog::getInstance();
 }
Example #6
0
require_once 'MainView.php';
require_once 'LoginView.php';
require_once 'SimpleTemplate.php';
require_once 'themes/blue/Templates.php';
// Init
set_magic_quotes_runtime(false);
$pageTitle = 'Microblog';
$pageAuthor = '';
// Improve security of session cookie
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_secure', 1);
ini_set('session.cookie_httponly', 1);
try {
    \Logger::configure('log4php.properties');
    $logger = \Logger::getLogger('index');
    $m = Microblog::getInstance();
    // Only start session and so set cookie after login
    if (isset($_COOKIE['PHPSESSID'])) {
        session_start();
    }
    // Input
    if (get_magic_quotes_gpc()) {
        $logger->debug('magic_quotes_gpc = On');
        $get = array_map('stripslashes', $_GET);
        // TODO Check
        $post = array_map('stripslashes', $_POST);
        // TODO Check
    } else {
        $logger->debug('magic_quotes_gpc = On');
        $get = $_GET;
        $post = $_POST;