Exemple #1
0
	<title>Composing Message</title>
</head>
<?php 
require "php/topbar.php";
?>
<body>
	<div class="maindiv">
<?php 
require_once "php/database.php";
require_once "php/storedprocedures.php";
require_once "php/error.php";
require_once "php/posting.php";
if (isset($_GET['touserid'])) {
    $db = connectToDatabase();
    if ($db) {
        $userInfo = getPublicUserDetails($db, $_GET['touserid']);
        $displayName = "???";
        if ($userInfo[SP::ERROR] == ERR::OK) {
            $displayName = $userInfo[USER::DISP_NAME];
        }
        echo <<<EOT
\t<h2 class='title'>Creating a new message to: <a href=profile.php?profileid={$_GET['touserid']}>{$displayName}</a></h2>
\t<form id="postform" method="POST" action="messagesubmission.php">
\t\t<input type="text" name="messagetitle" id="messagetitle" />
\t\t<input type='hidden' id='touserid' name='touserid' value='{$_GET['touserid']}'>
EOT;
        echo createContentArea();
        echo "</form>";
    }
} else {
    echo "<p>No recipient specified.</p>";
Exemple #2
0
                header("Location: logout.php?error=" . $sentError);
                break;
            default:
                echo "<p>Error: " . $ERRORS[$sentError] . "</p>";
                break;
        }
        switch ($receivedError) {
            case ERR::OK:
                echo <<<EOT
\t<div class='messagesbox'>
\t\t<h2 class='title'>All messages received</h2>
\t\t<ol>
EOT;
                foreach ($receivedMessages as $msg => $details) {
                    if (!isset($userInfo[$details[MESSAGE::SENDER]])) {
                        $userInfo[$details[MESSAGE::SENDER]] = getPublicUserDetails($db, $details[MESSAGE::SENDER]);
                    }
                    echo <<<EOT
\t\t\t<li>
\t\t\t\t<div class='message'>
\t\t\t\t\t<p><a href='viewmessage.php?messageid={$details[MESSAGE::ID]}'>{$details[MESSAGE::TITLE]}</a> at {$details[MESSAGE::MADE_AT]}, sent to <a href='profile.php?profileid={$details[MESSAGE::SENDER]}'>{$userInfo[$details[MESSAGE::SENDER]][USER::DISP_NAME]}</a></p>
\t\t\t\t</div>
\t\t\t</li>
EOT;
                }
                echo "</ol></div>";
                break;
            case ERR::TOKEN_EXPIRED:
            case ERR::TOKEN_FAIL:
            case ERR::USER_NO_TOKEN:
                header("Location: logout.php?error=" . $receivedError);
Exemple #3
0
</li>
EOT;
        }
    }
    echo "</ol></div>";
}
//ThreadID, StarterUserID, ThreadTitle, CreatedAt, isSticky, Open, Views, Count(aggregate posts)
$userInfo = array();
if (isset($threads)) {
    echo "<div class='forumbox'><h2 class='title'>Threads</h2><ol>";
    foreach ($threads as $thread) {
        if (!isset($userInfo[$thread[THREAD::STARTER_USER_ID]])) {
            $userInfo[$thread[THREAD::STARTER_USER_ID]] = getPublicUserDetails($db, $thread[THREAD::STARTER_USER_ID]);
        }
        if (!isset($userInfo[$thread[POST::USER_ID]])) {
            $userInfo[$thread[POST::USER_ID]] = getPublicUserDetails($db, $thread[POST::USER_ID]);
        }
        $threadStarter = $userInfo[$thread[THREAD::STARTER_USER_ID]];
        $latestPoster = $userInfo[$thread[POST::USER_ID]];
        echo <<<EOT
<li>
\t<div class='subitem'>
\t\t<div class='threadmeta'>
EOT;
        echo "<img class='threadicon' ";
        if ($thread[THREAD::OPEN]) {
            echo "src='img/open.jpg' alt='Thread Open' />";
        } else {
            echo "src='img/closed.jpg' alt='Thread Closed' />";
        }
        echo <<<EOT
Exemple #4
0
         case ERR::USER_NO_TOKEN:
             header("Location: logout.php?error=" . $errorCode);
             break;
         case ERR::PERMIS_FAIL:
             echo "<p>You do not have permissions to edit this profile.</p>";
             break;
         case ERR::USER_NOT_EXIST:
             break;
         default:
             header("Location: logout.php?error=" . $errorCode);
             break;
     }
     // Update because it can change (though rarely)
     $_SESSION['permission'] = $permisLevel;
 } else {
     $results = getPublicUserDetails($db, $userID);
     $errorCode = $results[SP::ERROR];
     switch ($errorCode) {
         case ERR::OK:
             $displayName = $results[USER::DISP_NAME];
             $location = $results[USER::LOC];
             $gender = $results[USER::SEX];
             $permisLevel = $results[PERMISSION::LEVEL];
             break;
         case ERR::USER_NOT_EXIST:
             echo "<p>That user does not exist.</p>";
             break;
     }
 }
 if ($errorCode == ERR::OK) {
     // If you want to customize that upload thing, wrap it in a label, make input's display: none. Then, place a <span> after it, inside the label, and style that how you like.
Exemple #5
0
             break;
         default:
             echo "<p>Could not remove friend. Error: " . $ERRORS[$results[SP::ERROR]] . "</p>";
             break;
     }
 } else {
     $results = getFriends($db, $_SESSION['id'], $_SESSION['token']);
     $errorCode = $results[SP::ERROR];
     unset($results[SP::ERROR]);
     switch ($errorCode) {
         case ERR::OK:
             if (count($results) == 0) {
                 echo "<p>You have no friends ;_;</p>";
             }
             foreach ($results as $num => $friend) {
                 $friendInfo = getPublicUserDetails($db, $friend[FRIEND::FRIEND_ID]);
                 echo <<<EOT
t\t<div class="friendbox">
t\t\t<a href="profile.php?profileid={$friend[FRIEND::FRIEND_ID]}">
t\t\t\t<img class="avatar" src="avatar/{$friend[FRIEND::FRIEND_ID]}.jpg" />
t\t\t{$friendInfo[USER::DISP_NAME]}</a>
t\t\t<form method="GET" action="makemessage.php">
t\t\t\t<input type="hidden" name="touserid" value="{$friend[FRIEND::FRIEND_ID]}"/>
t\t\t\t<input type="submit" value="Send Message" />
t\t\t</form>
t\t\t<form method="GET" action="messages.php">
t\t\t\t<input type="hidden" name="userid" value="{$friend[FRIEND::FRIEND_ID]}"/>
t\t\t\t<input type="submit" value="View Messages" />
t\t\t</form>
t\t\t<form method="POST" action="friendslist.php">
t\t\t\t<input type="hidden" name="deletefriendid" value="{$friend[FRIEND::FRIEND_ID]}"/>
Exemple #6
0
\t\t\t\t<img class='avatar' src='avatar/{$details[POST::USER_ID]}.jpg' alt="{$userDetails[$userID][USER::DISP_NAME]}'s avatar" />
\t\t\t\t<p>Location: {$userDetails[$userID][USER::LOC]}</p>
\t\t\t\t<p>{$P_LEVELS[$userDetails[$userID][PERMISSION::LEVEL]]}</p>
\t\t\t</div>
\t\t\t<div class='content'>
\t\t\t\t<p>{$details[POST::CONTENT]}</p>
\t\t\t</div>
\t\t</div>
\t\t<div class='replyfooter'>
EOT;
                $editor = $details[POST::EDITING_USER_ID];
                if ($editor) {
                    echo "<p>Last edited ";
                    if ($editor != $details[POST::USER_ID]) {
                        if (!isset($userDetails[$editor])) {
                            $userDetails[$editor] = getPublicUserDetails($db, $editor);
                        }
                        echo "by <a href='profile.php?profileid={$editor}'>" . $userDetails[$editor][USER::DISP_NAME] . "</a> ";
                    }
                    echo "at " . $details[POST::EDITED_AT] . "</p>";
                }
                echo "</div></div></li>";
                break;
            case ERR::POST_NOT_EXIST:
                echo "Post does not exist, or has been deleted.";
                break;
            case ERR::UNKNOWN:
            default:
                echo "Unknown error obtaining post.";
                break;
        }