示例#1
0
 private function TraverseComment(&$box, $comments)
 {
     if (sizeof($comments) > 0) {
         foreach ($comments as $comment) {
             if (is_a($comment, 'Comment')) {
                 $args = null;
                 if (Login::IsLoggedIn()) {
                     $args = array('onclick' => 'SelectComment(' . $comment->GetId() . ')');
                 }
                 $childbox = new RTK_Box($comment->GetId(), 'comment');
                 $infobox = new RTK_Box($comment->GetId(), 'commentinfo', $args);
                 $infobox->AddChild(new RTK_Textview($comment->GetUser()->getUserName() . ':', true, null, 'commentposter'));
                 $infobox->AddChild(new RTK_Textview($comment->GetContents(), true, null, 'commentmessage'));
                 $infobox->AddChild(new RTK_Textview('Posted ' . $comment->GetTime(), true, null, 'commenttime'));
                 $childbox->AddChild($infobox);
                 if (!empty($comment->GetComments())) {
                     $this->TraverseComment($childbox, $comment->GetComments());
                 }
                 $box->AddChild($childbox);
             }
         }
     }
 }
示例#2
0
 public static function Insert($message, $recipe, $id = EMPTYSTRING)
 {
     $result = false;
     if (Site::HasHttps() && Login::IsLoggedIn()) {
         if (Value::SetAndNotEmpty($message) && Value::SetAndNotNull($recipe)) {
             $path = 'R=' . $recipe;
             if ($id != EMPTYSTRING) {
                 if ($stmt = Database::GetLink()->prepare('SELECT `comment_path` FROM `Comment` WHERE `comment_path` LIKE ?;')) {
                     $stmt->bindParam(1, $path, PDO::PARAM_STR, 255);
                     $stmt->execute();
                     $stmt->bindColumn(1, $result);
                     $stmt->fetch();
                     $stmt->closeCursor();
                     if ($result != null && _string::StartsWith($result, $path)) {
                         $path = $result . '>' . $id;
                     } else {
                         $path = null;
                     }
                 }
             }
             if ($path != null) {
                 $userid = Login::GetId();
                 $timestamp = time();
                 if ($stmt = Database::GetLink()->prepare('INSERT INTO `Comment` (`user_id`, `comment_path`, `comment_contents`, `sent_at`) VALUES (?, ?, ?, ?);')) {
                     $stmt->bindParam(1, $userid, PDO::PARAM_INT);
                     $stmt->bindParam(2, $path, PDO::PARAM_STR, 255);
                     $stmt->bindParam(3, $message, PDO::PARAM_STR, 255);
                     $stmt->bindParam(4, $timestamp, PDO::PARAM_INT);
                     $stmt->execute();
                     $stmt->closeCursor();
                 }
             }
         }
     }
     return $result;
 }
示例#3
0
}
// Handle the login
if (!Login::IsLoggedIn() && Site::CheckSecurityToken()) {
    if (Login::TryToLogin()) {
        Site::BackToHome();
    }
}
// Page Output
include_once 'Pages/OnAllPages.php';
$RTK->AddJavascript('/jquery-2.1.4.min.js');
$RTK->AddJavascript('/login.js');
if (Login::GetError() != EMPTYSTRING) {
    $RTK->AddElement(new RTK_Textview(Login::GetError()));
}
$loginbox = new RTK_Box('loginbox');
if (Login::IsLoggedIn()) {
    // If a user is logged in
    $loginbox->AddChild(new RTK_Textview('You are logged in as: ' . Login::GetUsername()));
    $loginbox->AddChild(new RTK_Link('Logout' . URLPAGEEXT, 'click here for log out', true));
} elseif (Site::HasHttps()) {
    // If a user is not logged in, but the site is running secure
    $loginform = new RTK_Form('loginform', EMPTYSTRING, 'POST');
    $loginform->AddTextField('loginname', 'Username:'******'loginpass', 'Password:'******'submit', 'log in');
    $loginbox->AddChild($loginform);
} else {
    // If a user is not logged in, and the site is not running secure
    $loginbox->AddChild(new RTK_Textview('You are not running secure and therefore cannot be allowed to log in.'));
    $loginbox->AddChild(new RTK_Link('Login' . URLPAGEEXT, 'click here for encrypted login', true));
}
示例#4
0
<?php

// Page Logic
if (!Login::IsLoggedIn()) {
    Site::BackToHome();
}
/*
$id = Site::GetArgumentSafely('id');
$recipe = null;
if ($id == 'new') { $recipe = new Recipe(); }
elseif (is_numeric($id)) { $recipe = Recipe::Load($id); }

if (!is_a($recipe, 'Recipe')) { Site::BackToHome(); }

$types = Recipe::GetTypes();
$title = null;
$description = null;
$typeid = null;
$image = null;

if (Value::SetAndNotNull($_POST, 'submit') && Site::CheckSecurityToken()) {
	$typeid = Site::GetPostValueSafely("type");
	if ($typeid != null) {
		foreach ($types as $type) { if ($type[0] == $typeid) { $recipe->SetType($type); } }
		if ($recipe->GetType() == null) { Site::BackToHome(); }
	}
	
	$image = Site::GetUploadedImage('pffile');
	if ($typeid != null) {
		$image->Save();
	}
示例#5
0
 /**
  * Adds a comment directly to the view (only use for demonstration purposes)
  * @param string $comment the comment to add to the view
  **/
 public function AddComment($comment)
 {
     if (is_string($comment)) {
         $args = null;
         if (Login::IsLoggedIn()) {
             $args = array('onclick' => 'SelectComment(' . $comment->GetId() . ')');
         }
         $childbox = new RTK_Box($comment->GetId(), 'comment');
         $infobox = new RTK_Box($comment->GetId(), 'commentinfo', $args);
         $infobox->AddChild(new RTK_Textview($comment->GetUser()->GetUserName() . ':', true, null, 'commentposter'));
         $infobox->AddChild(new RTK_Textview($comment->GetContents(), true, null, 'commentmessage'));
         $infobox->AddChild(new RTK_Textview('Posted ' . $comment->GetTime(), true, null, 'commenttime'));
         $childbox->AddChild($infobox);
         if (!empty($comment->GetComments())) {
             $this->TraverseComment($childbox, $comment->GetComments());
         }
         $this->_commentbox::GetLastChild()->AddChild($childbox);
     }
 }
示例#6
0
                $id = Login::FetchUserId($username);
                if ($id > 0) {
                    $name = Login::FetchUsername($id);
                    if ($name != false) {
                        $username = $name;
                    }
                }
            }
            if ($stmt = Database::GetLink()->prepare('INSERT INTO LoginAttempt (occurred_at, username_input, successful) VALUES (?, ?, ?);')) {
                $stmt->bindParam(1, $now, PDO::PARAM_INT);
                $stmt->bindParam(2, $username, PDO::PARAM_STR, 255);
                $stmt->bindParam(3, $success, PDO::PARAM_BOOL);
                $stmt->execute();
                $stmt->closeCursor();
            }
            if (!$success) {
                Login::IncrementAttempts();
                $tryleft = 3 - Login::GetAttempts();
                if ($tryleft <= 0) {
                    Login::SetError('You have been banned.');
                    Login::BanClient();
                } else {
                    Login::SetError('Login failed, only ' . $tryleft . ' attempts left.');
                }
            }
        }
    }
    if (!Site::HasHttps() && Login::IsLoggedIn()) {
        Site::BackToHome(true);
    }
}