Exemplo n.º 1
0
function print_comment($comment, $table)
{
    $output = "";
    if ($table == "ext") {
        $sect = "external-news";
    } elseif ($table == "sites") {
        $sect = "related-sites";
    } else {
        $sect = "press";
    }
    $c_name = utf8entities(stripslashes($comment->name));
    $c_date = utf8entities($comment->postdate);
    $c_body = nl2br(utf8entities(stripslashes($comment->body)), false);
    if ($comment->linecount == 1) {
        $output .= "\n\t\t<div>\n\t\t\t<div class=\"c-small\">\n\t\t\t\t<a name=\"c-{$comment->id}\"></a>\n\t\t\t\t<div class=\"c-small-actions\">\n\t\t\t\t\t<a class=\"c-actions-button\" alt=\"Respond to this comment\" href=\"/{$sect}/item/{$comment->itemid}/comments/post/{$comment->id}/\" onclick=\"return replyToComment(this);\">Reply</a>\n\t\t\t\t\t<a class=\"c-actions-button\" alt=\"Permalink to this comment\" href=\"/{$sect}/item/{$comment->itemid}/comments/#c-{$comment->id}\">Perma</a>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"c-small-inner\">\n\t\t\t\t\t<strong>{$c_name}</strong>&nbsp;&nbsp;\n\t\t\t\t\t{$c_body}\n\t\t\t\t</div>\n\t\t\t\t<div class=\"clear\"></div>\n\t\t\t</div>\n\t\t";
    } else {
        $output .= "\n\t\t<div>\n\t\t\t<div class=\"c-outer\">\n\t\t\t\t<a name=\"c-{$comment->id}\"></a>\n\t\t\t\t<div class=\"c-meta\">\n\t\t\t\t\t<span class=\"c-meta-name\">{$c_name}</span>\n\t\t\t\t\t<span class=\"c-meta-date\">{$c_date}</span>\n\t\t\t\t\t<div class=\"clear\"></div>\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t<div class=\"c-actions\">\n\t\t\t\t\t<a class=\"c-actions-button\" alt=\"Respond to this comment\" href=\"/{$sect}/item/{$comment->itemid}/comments/post/{$comment->id}/\" onclick=\"return replyToComment(this);\">Reply</a>\n\t\t\t\t\t<a class=\"c-actions-button\" alt=\"Permalink to this comment\" href=\"/{$sect}/item/{$comment->itemid}/comments/#c-{$comment->id}\">Perma</a>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"c-body\">\n\t\t\t\t\t{$c_body}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t";
    }
    $output .= "\n\t\t<div class=\"c-reply\">\n\t\t\t{$comment->id}\n\t\t</div>\n\t</div>\n\t<div class=\"c-children\">\n\t";
    foreach ($comment->children as $child) {
        $output .= print_comment($child, $table);
    }
    $output .= "</div>";
    return $output;
}
Exemplo n.º 2
0
/**
 * goback
 * outputs javascritp back link 
 * used for errors
**/
function goback($msg)
{
    $content = '<div id ="error">' . utf8entities($msg) . '<br>';
    $content .= '<a href="javascript:history.back()">Please return back and try again</a></div>';
    include 'static.php';
    exit;
}
Exemplo n.º 3
0
function userNav()
{
    global $_COOKIE;
    $n['View realtime logs'] = "/";
    $n['Settings'] = "/settings";
    $n['Feedbacks'] = "/feedbacks";
    if (isAdmin()) {
        $n['Admin'] = "/admin";
    }
    $c = 1;
    foreach ($n as $title => $link) {
        if ($_SERVER['REQUEST_URI'] == $link || strpos($_SERVER['REQUEST_URI'], $link . "?") === 0) {
            echo "<strong>" . htmlentities($title) . "</strong> ";
        } else {
            echo "<a href=\"{$link}\">" . htmlentities($title) . "</a> ";
        }
        if ($c++ != count($n)) {
            echo " | ";
        }
    }
    $allowed = getAllowed();
    if (count($allowed)) {
        $ru = isset($_COOKIE['requser']) ? $_COOKIE['requser'] : userName();
        echo " | <select id=\"seluser\" onchange=\"switchUser()\">";
        echo "<option value=\"\">" . utf8entities(userName()) . "</option>";
        foreach ($allowed as $id) {
            $name = getUsernameById($id);
            $selected = $ru == $name ? "selected" : "";
            echo "<option {$selected} value=\"" . urlencode($name) . "\">" . utf8entities($name) . "</option>";
        }
        echo "</select>";
    }
}
Exemplo n.º 4
0
function utf8_entities_if_needed($input)
{
    if (strpos($input, ">") !== false || strpos($input, "<") !== false) {
        return utf8entities($input);
    } else {
        return $input;
    }
}
Exemplo n.º 5
0
function template_post($post)
{
    $first = $post['ParentId'] == 0 ? " forum-post-first" : "";
    $user = utf8entities(stripslashes($post['Name']));
    $body = nl2br(utf8entities(stripslashes($post['Body'])));
    $date = date("F j, Y <b\\r>H:i:s", strtotime($post['Posted']));
    $output = "\n\t<a name=\"p-{$post['Id']}\"></a>\n\t<div class=\"forum-post{$first}\">\n\t\t<div class=\"forum-post-meta\">\n\t\t\t<div class=\"forum-post-user\">\n\t\t\t\t{$user}\n\t\t\t</div>\n\t\t\t<div class=\"forum-post-date\">\n\t\t\t\t{$date}\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"forum-post-body\">\n\t\t\t{$body}\n\t\t</div>\n\t\t<div class=\"clear\"></div>\n\t</div>\n\t";
    return $output;
}
Exemplo n.º 6
0
function uid2html($r, $uid)
{
    $keys = array("uid:{$uid}:username", "uid:{$uid}:email", "uid:{$uid}:regtime");
    $user = $r->mget($keys);
    if (!$user[0]) {
        return;
    }
    echo "<tr>";
    echo "<td>" . utf8entities($user[0]) . "</td><td>" . utf8entities($user[1]) . "</td>" . "<td>" . strelapsed($user[2]) . "</td>";
    echo "</tr>";
}
Exemplo n.º 7
0
            $age = flexFormatTime($age, false, false, false);
            $href = '/explorer.php?param=' . urlencode($networkPath . "\\" . $f->fname);
            $title = 'Diese Datei im Projekt-Ordner anzeigen - dazu klicken und "ausführen"!';
            $title = utf8entities(utf8_encode($title));
            $timeStatus = "+&nbsp;" . $age;
            $icon = '<img src="/img/icon-' . strtolower($f->extension) . '.gif" width="16" height="16" alt="" align="absbottom">';
            $filename = utf8entities(utf8_encode($f->fname));
            $filepath = utf8entities(utf8_encode($subPath));
            $lines[] = $lineTemplate->autoFill();
        }
        $networkPath = $project->path;
        foreach ($networkPathTranslations as $src => $dst) {
            $networkPath = str_replace($src, $dst, $networkPath);
        }
        $networkPath = str_replace("/", "\\", $networkPath);
        $explorerHref = '/explorer.php?param=' . urlencode($networkPath);
        $title = 'Projekt-Ordner anzeigen - dazu klicken und "ausführen"!';
        $title = utf8entities(utf8_encode($title));
        $projectName = utf8entities($project->name);
        $projectId = $project->uid;
        $fileCntMsg = "(" . count($projectFiles[$uid]) . " Dateien in den letzten " . $recentDays . " Tagen)";
        $output[] = $sectionTemplate->autoFill();
    }
}
$output = implode("\n", $output);
/*
$f = fopen("dump.txt", "w");
fputs($f, $output);
fclose($f);
*/
echo $output;
Exemplo n.º 8
0
function logGraph($id, $data, $conf = array())
{
    $logscale = isset($conf['logscale']) ? $conf['logscale'] : 0;
    $width = isset($conf['width']) ? $conf['width'] : 600;
    $height = isset($conf['height']) ? $conf['height'] : 140;
    # Compute some value
    $slots = max(count($data), 12);
    $w = floor(($slots > 15 ? 90 : 80) / $slots);
    $lstep = floor(90 / $slots);
    # Our graph lives inside a main div having the given id
    $html = '<div id="' . $id . '" class="graph" style="width: ' . $width . 'px; ';
    $html .= 'height: ' . $height . 'px;">';
    # Output the div for the title if any
    if (isset($conf['title'])) {
        $html .= '<div class="graphtitle">' . utf8entities($conf['title']) . "</div>\n";
    }
    $max = logGraphMaxValue($data);
    # Output the div for the max line
    if ($max > 0) {
        $h = logGraphBarHeight($logscale, $max, $max);
        $html .= '<div class="barmax" style="bottom: ' . $h . '">' . $max . "</div>\n";
    }
    # Output a div for every bar
    $pos = 0;
    for ($i = 0; $i < $slots - count($data); $i++) {
        $l = $pos * $lstep;
        $html .= '<div class="bar" style="width:' . $w . '%; bottom:0px; height:1px; left:' . $l . '%; background-color:#dddddd; border:none;"><!-- --></div>' . "\n";
        $pos++;
    }
    $tot = 0;
    for ($i = 0; $i < count($data); $i++) {
        $tot += $data[$i]['val'];
        $h = logGraphBarHeight($logscale, $max, $data[$i]['val']);
        $l = $pos * $lstep;
        if ($i == count($data) - 1) {
            $class = "bar lastbar";
        } else {
            if ($data[$i]['lab'] == 'S') {
                $class = "bar webar";
            } else {
                $class = "bar stdbar";
            }
        }
        $tip = isset($data[$i]['tip']) ? $data[$i]['tip'] : $data[$i]['val'];
        $html .= '<div class="' . $class . '" clicktip="' . $tip . '" style="bottom:0px; height:' . $h . '; left:' . $l . '%; width:' . $w . '%;">' . $data[$i]['lab'] . '</div>' . "\n";
        $pos++;
    }
    $avg = count($data) ? $tot / count($data) : 0;
    if ($avg > 10) {
        $avg = floor($avg);
    } else {
        $avg = round($avg, 2);
    }
    # Output the div for the average line
    if ($avg > 0 && count($data) > 1) {
        if ($logscale) {
            if ($max < 10) {
                $gridstep = 0.01;
            } else {
                if ($max < 100) {
                    $gridstep = 1;
                } else {
                    if ($max < 5000) {
                        $gridstep = 100;
                    } else {
                        if ($max < 10000) {
                            $gridstep = 1000;
                        } else {
                            if ($max < 100000) {
                                $gridstep = 10000;
                            }
                        }
                    }
                }
            }
            if ($gridstep) {
                $step = 0;
                $lasth = "0%";
                while (1) {
                    $step += $gridstep;
                    if ($step > $max) {
                        break;
                    }
                    $h = logGraphBarHeight($logscale, $max, $step);
                    $hmax = logGraphBarHeight($logscale, $max, $max);
                    if (trim($h, "%") - trim($lasth, "%") > 10) {
                        if (trim($h, "%") < 70) {
                            $html .= '<div class="baravg" style="bottom: ' . $h . '">' . round($step, 2) . "</div>\n";
                        }
                        $lasth = $h;
                    }
                }
            }
        } else {
            $h = logGraphBarHeight($logscale, $max, $avg);
            $hmax = logGraphBarHeight($logscale, $max, $max);
            if (trim($hmax, "%") / trim($h, "%") <= 1.15) {
                $avg = "";
            } else {
                $avg = "avg " . $avg;
            }
            $html .= '<div class="baravg" style="bottom: ' . $h . '">' . $avg . "</div>\n";
        }
    }
    # Done, almost.
    $html .= '</div>';
    return $html;
}
Exemplo n.º 9
0
        } elseif ($_GET['q'] == "ext_top_7days") {
            $query = "SELECT * FROM ext WHERE `Deleted`='0' AND `Visible`='1' AND `Posted` >= DATE_SUB(CURRENT_DATE(), INTERVAL {$recent_days} DAY) ORDER BY `Rank` DESC LIMIT 4";
            $section = "external-news";
        } elseif ($_GET['q'] == "ext_top_all") {
            $query = "SELECT * FROM ext WHERE `Deleted`='0' AND `Visible`='1' ORDER BY `Rank` DESC LIMIT 4";
            $section = "external-news";
        } elseif ($_GET['q'] == "ext_bottom_7days") {
            $query = "SELECT * FROM ext WHERE `Deleted`='0' AND `Visible`='1' AND `Posted` >= DATE_SUB(CURRENT_DATE(), INTERVAL {$recent_days} DAY) ORDER BY `Rank` ASC LIMIT 4";
            $section = "external-news";
        } elseif ($_GET['q'] == "ext_bottom_all") {
            $query = "SELECT * FROM ext WHERE `Deleted`='0' AND `Visible`='1' ORDER BY `Rank` ASC LIMIT 4";
            $section = "external-news";
        }
        if ($result = mysql_query_cached($query)) {
            foreach ($result->data as $item) {
                $name = utf8entities(stripslashes($item['Name']));
                $id = $item['Id'];
                $comments = $item['CommentCount'];
                $rank = $section == "external-news" ? $item['Rank'] : 0;
                $upvotes = $section == "press" ? $item['Upvotes'] : 0;
                echo template_item($name, $section, $id, $comments, false, $upvotes, $rank);
            }
        }
    }
} else {
    die("Error: No valid query was passed on.");
}
/*
if(!isset($_GET['s']) || !isset($_GET['f']) || !isset($_GET['o']) || !isset($_GET['p']))
{
	die("An internal error occurred. Not all variables were set.");
Exemplo n.º 10
0
<?
include("retwis.php");
if (!isLoggedIn()) {
    header("Location: index.php");
    exit;
}
include("header.php");
$r = redisLink();
?>
<div id="postform">
<form method="POST" action="post.php">
<?php 
echo utf8entities($User['username']);
?>
, what you are doing?
<br>
<table>
<tr><td><textarea cols="70" rows="3" name="status"></textarea></td></tr>
<tr><td align="right"><input type="submit" name="doit" value="Update"></td></tr>
</table>
</form>
<div id="homeinfobox">
<?php 
echo $r->scard("uid:" . $User['id'] . ":followers");
?>
 followers<br>
<?php 
echo $r->scard("uid:" . $User['id'] . ":following");
?>
 following<br>
</div>
Exemplo n.º 11
0
function showLastUsers() {
    $r = redisLink();
    $users = $r->sort("global:users","GET uid:*:username DESC LIMIT 0 10");
    echo("<div>");
    foreach($users as $u) {
        echo("<a class=\"username\" href=\"profile.php?u=".urlencode($u)."\">".utf8entities($u)."</a> ");
    }
    echo("</div><br>");
}
Exemplo n.º 12
0
    die;
}
/* Protect from direct requests */
/* This module shows a specific press release. */
if (is_numeric($var_id)) {
    $id = mysql_real_escape_string($var_id);
    $approved = " AND `Approved` = '1'";
    if (isset($_SESSION['loggedin'])) {
        $approved = "";
    }
    $query = "SELECT Name, Body, Attachment, ExternalAttachment, CommentCount FROM press WHERE `Id` = '{$id}'{$approved}";
    if ($result = mysql_query_cached($query)) {
        $title = utf8entities(stripslashes($result->data[0]['Name']));
        $body = youtubify(filter_extended(stripslashes($result->data[0]['Body'])));
        $externalattachment = $result->data[0]['ExternalAttachment'];
        $attachment = utf8entities(stripslashes($result->data[0]['Attachment']));
        $commentcount = $result->data[0]['CommentCount'];
        echo "<div class=\"pressrelease\">\n\t\t\t<a class=\"hl-comments\" href=\"/press/item/{$id}/comments/\"><strong>Join the conversation!</strong> {$commentcount} comment(s) already posted - click to post one yourself, anonymously of course.</a>\n\t\t\t<h5>{$title}</h5>";
        if (!empty($attachment)) {
            if ($externalattachment == 1) {
                $image = $tahoe_gateway . $attachment;
            } else {
                $image = "/" . $attachment;
            }
            echo "<div class=\"pressrelease-image\">\n\t\t\t\t<img src=\"{$image}\" alt=\"{$title} image\" width=\"900\">\n\t\t\t</div>";
        }
        echo "{$body}\n\t\t\t<a class=\"hl-comments\" href=\"/press/item/{$id}/comments/\"><strong>Join the conversation!</strong> {$commentcount} comment(s) already posted - click to post one yourself, anonymously of course.</a>\n\t\t\t</div>\n\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\$(function(){\n\t\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\t//resizeImage();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t</script>";
    } else {
        $var_code = ANONNEWS_ERROR_NOT_FOUND;
        require "module.error.php";
    }
Exemplo n.º 13
0
<input type="submit" name="saveoptions" value="Save options">
<br/><br/>
</form>
<h3>Give access</h3>
It is possible to give read-only access to your stats to other LLOOGG users. You can later remove the access if you want.<br/><br/>
Allow
<input id="allowusername" type="text" name="username">
to see my stats in read only
<input type="button" name="doit" value="Allow!" onclick="allowUser()">
<?php 
$allowed = getAllowing();
if (count($allowed)) {
    echo "<h4>Allowed users</h4>";
    echo "<ul>";
    foreach ($allowed as $id) {
        echo "<li>" . utf8entities(getUsernameById($id)) . " <a href=\"rmallowed.php?username="******"\">remove</a></li>";
    }
    echo "</ul>";
}
?>
</div>
<script type="text/javascript">
function allowUserHandler(res) {
    if (res.indexOf("ERR:") != -1) {
        alert(res);
    } else {
        window.location.reload();
    }
}

function allowUser() {
/* Protect from direct requests */
/* This module handles the category overview. */
?>

<h2>Forum</h2>

<div class="forum-header">
	Be sure to read the <a href="/static/forumrules">Forum Rules</a>! All posting is anonymous, no registration is necessary and no IPs are kept.
</div>

<table class="forum-table">
	<tr>
		<th class="forum-header-category-name">Category</th>
		<th class="forum-header-category-threads">Threads</th>
		<th class="forum-header-category-posts">Posts</th>
	</tr>
	<?php 
$result = mysql_query_cached("SELECT * FROM forum_categories ORDER BY `Name` ASC", 10);
foreach ($result->data as $category) {
    if ($category['Posts'] > 0) {
        $posttime = date("F j, Y H:i:s", strtotime($category['LastPostTime']));
        $lasttopic = utf8entities($category['LastPostTopic']);
        $lastpost = "Last post: <strong>{$lasttopic}</strong> @ {$posttime}";
    } else {
        $lastpost = "There are no posts in this category yet.";
    }
    echo "<tr>\n\t\t\t<td class=\"forum-item-category-name\">\n\t\t\t\t<a class=\"forum-table-link\" href=\"/forum/category/{$category['UrlName']}\">\n\t\t\t\t\t<div class=\"forum-table-name\">{$category['Name']}</div>\n\t\t\t\t\t<div class=\"forum-table-date\">{$lastpost}</div>\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t\t<td class=\"forum-item-category-threads\">{$category['Threads']}</td>\n\t\t\t<td class=\"forum-item-category-posts\">{$category['Posts']}</td>\n\t\t</tr>";
}
?>
</table>
function showLastUsers() {
    $r = redisLink();
    $users = $r->zrevrange("users_by_time",0,9);
    echo("<div>");
    foreach($users as $u) {
        echo("<a class=\"username\" href=\"profile.php?u=".urlencode($u)."\">".utf8entities($u)."</a> ");
    }
    echo("</div><br>");
}
Exemplo n.º 16
0
<?php

include "retwis.php";
include "header.php";
$r = redisLink();
if (!gt("u") || !($userid = $r->hget("users", gt("u")))) {
    header("Location: index.php");
    exit(1);
}
echo "<h2 class=\"username\">" . utf8entities(gt("u")) . "</h2>";
if (isLoggedIn() && $User['id'] != $userid) {
    $isfollowing = $r->zscore("following:" . $User['id'], $userid);
    if (!$isfollowing) {
        echo "<a href=\"follow.php?uid={$userid}&f=1\" class=\"button\">Follow this user</a>";
    } else {
        echo "<a href=\"follow.php?uid={$userid}&f=0\" class=\"button\">Stop following</a>";
    }
}
$start = gt("start") === false ? 0 : intval(gt("start"));
showUserPostsWithPagination(gt("u"), $userid, $start, 10);
include "footer.php";
Exemplo n.º 17
0
                        $tags_suggestion = utf8_entities_if_needed(implode(", ", $tag_list));
                    }
                    if ($detect_language) {
                        require_once "Text/LanguageDetect.php";
                        $detector = new Text_LanguageDetect();
                        $detected_language = $detector->detectSimple(strip_tags($request->result));
                    } else {
                        $detected_language = "English";
                    }
                    ?>
					<h2>Submit a related site</h2>
					
					<form method="POST" action="/related-sites/add/submit/" class="submission">
						
						<input type="hidden" name="url" value="<?php 
                    echo utf8entities($_POST['url']);
                    ?>
">
						
						<h4>Website Title</h4>
						<div class="form-notice">
							<?php 
                    echo $title_desc;
                    ?>
						</div>
						<input type="text" name="title" value="<?php 
                    echo $title_suggestion;
                    ?>
">
					
						<h4>Tags (optional)</h4>
Exemplo n.º 18
0
<?php

require "lib.php";
Config("title", "LLOOGG Administration");
include "header.php";
if (!isAdmin()) {
    exit;
}
$username = $_POST['username'];
$uid = getIdFromUsername($username);
if ($uid == -1) {
    echo "User " . utf8entities($username) . " not found.";
} else {
    setPro($uid, 1);
    echo "User " . utf8entities($username) . " is now PRO.";
}
include "footer.php";
Exemplo n.º 19
0
			</style>
			<script type="text/javascript" src="http://tahoe-gateway.cryto.net:3719/download/VVJJOkNISzpraHNjaHNuaGtwc3NhaHh2aHVvNnFjb2xleTp5M2N2Mm1rYXZ2eWVsZ3A1cGx3ejR0NG9rZnJpbjRiYWx1dG9paHc0ZGFsZnVjZmI0amlhOjM6Njo5MTU1Ng==/jquery-1.6.2.min.js"></script>
			<script type="text/javascript" src="/script2.js"></script>
			<script type="text/javascript">
				function clearButtons(text)
				{
					$('#voting').html("<div class='button'><strong>" + text + "</strong></div>");
				}
			</script>
		</head>
		<body>
			<h1><a href="/" target="_top">AnonNews</a></h1>
			<a href="/" target="_top" class="button home">back to homepage</a>
			<?php 
    echo "<a href=\"/{$var_section}/item/{$result->data[0]['Id']}/comments\" target=\"_blank\" class=\"button comments\">{$result->data[0]['CommentCount']} comments</a>";
    if ($table == "ext") {
        echo "<span id=\"voting\" class=\"votebuttons{$result->data[0]['Id']}\">\n\t\t\t\t\t<a href=\"process.vote.php?id={$result->data[0]['Id']}&vote=up&nojs=true&frame=true&token={$_SESSION['vote_token']}\" target=\"_blank\" onclick=\"return voteUp({$result->data[0]['Id']}, '{$_SESSION['vote_token']}');\" class=\"button up\"><span class=\"icon\">+</span> vote up</a>\n\t\t\t\t\t<a href=\"process.vote.php?id={$result->data[0]['Id']}&vote=down&nojs=true&frame=true&token={$_SESSION['vote_token']}\" target=\"_blank\" onclick=\"return voteDown({$result->data[0]['Id']}, '{$_SESSION['vote_token']}');\" class=\"button down\"><span class=\"icon\">-</span> vote down</a>\n\t\t\t\t</span>";
    }
    echo "<a href=\"" . utf8entities(stripslashes($result->data[0]['Url'])) . "\" target=\"_blank\" class=\"button comments\">Doesn't work?</a>";
    ?>
			<div class="border"></div>
		</body>
	</html>
	<?php 
}
?>




Exemplo n.º 20
0
function showLastUsers()
{
    $r = redisLink();
    $users = $r->sort("global:users", array('GET' => 'uid:*:username', 'DESC' => 0, 'LIMIT' => array(0 => '0', 1 => '10')));
    echo "<div>";
    foreach ($users as $u) {
        echo "<a class=\"username\" href=\"profile.php?u=" . urlencode($u) . "\">" . utf8entities($u) . "</a> ";
    }
    echo "</div><br>";
}
Exemplo n.º 21
0
if (!gt("username") || !gt("password") || !gt("password2")) {
    goback("Every field of the registration form is needed!");
}
if (gt("password") != gt("password2")) {
    goback("The two password fileds don't match!");
}
# The form is ok, check if the username is available
$username = gt("username");
$password = gt("password");
$r = redisLink();
if ($r->hget("users", $username)) {
    goback("Sorry the selected username is already in use.");
}
# Everything is ok, Register the user!
$userid = $r->incr("next_user_id");
$authsecret = getrand();
$r->hset("users", $username, $userid);
$r->hmset("user:{$userid}", "username", $username, "password", $password, "auth", $authsecret);
$r->hset("auths", $authsecret, $userid);
$r->zadd("users_by_time", time(), $username);
# User registered! Login her / him.
setcookie("auth", $authsecret, time() + 3600 * 24 * 365);
include "header.php";
?>
<h2>Welcome aboard!</h2>
Hey <?php 
echo utf8entities($username);
?>
, now you have an account, <a href="index.php">a good start is to write your first message!</a>.
<?php 
include "footer.php";
Exemplo n.º 22
0
<?php

if (!isset($_ANONNEWS)) {
    die;
}
/* Protect from direct requests */
/* This module handles the thread listing. */
$post_id = is_numeric($var_id) ? $var_id : 0;
if ($result = mysql_query_cached("SELECT * FROM forum_posts WHERE `Id`='{$var_id}' AND `ParentId`='0'", 5)) {
    $post = $result->data[0];
    $query = "SELECT * FROM forum_categories WHERE `Id`='{$post['CategoryId']}'";
    if ($category = mysql_query_cached($query)->data[0]) {
        $topic = utf8entities(stripslashes($post['Topic']));
        $caturlname = utf8entities(stripslashes($category['UrlName']));
        $catname = utf8entities(stripslashes($category['Name']));
        echo "<h2><a href=\"/forum\">Forum</a> &gt; <a href=\"/forum/category/{$caturlname}/\">{$catname}</a> &gt; {$topic}</h2>";
        echo template_post($post);
        $query = "SELECT * FROM forum_posts WHERE `ParentId`='{$post['Id']}'";
        if ($children = mysql_query_cached($query, 5)) {
            foreach ($children->data as $child) {
                echo template_post($child);
            }
        }
        echo "<div class=\"forum-reply\">\n\t\t\t<h3>Post a reply</h3>\n\t\t\t<form class=\"forum\" method=\"post\" action=\"/forum/post/{$var_id}/reply\">\n\t\t\t\t<input type=\"text\" name=\"name\" value=\"Anonymous\">\n\t\t\t\t<textarea name=\"body\"></textarea>\n\t\t\t\t<div class=\"forum-reply-button\">\n\t\t\t\t\t<button type=\"submit\" name=\"submit\">Post reply &gt;&gt;</button>\n\t\t\t\t\t" . template_captcha() . "\n\t\t\t\t</div>\n\t\t\t</form>\n\t\t</div>";
    } else {
        $var_code = ANONNEWS_ERROR_NOT_FOUND;
        require "module.error.php";
    }
} else {
    $var_code = ANONNEWS_ERROR_NOT_FOUND;
    require "module.error.php";
	<div class="forum-buttons">
		<a href="/forum/category/<?php 
    echo $var_id;
    ?>
/new">Create new thread</a>
		<div class="clear"></div>
	</div>
	
	<table class="forum-table">
		<tr>
			<th class="forum-header-threads-name">Thread Title</th>
			<th class="forum-header-threads-replies">Replies</th>
		</tr>
		<?php 
    if ($result = mysql_query_cached("SELECT * FROM forum_posts WHERE `CategoryId`='{$catid}' AND `ParentId`='0' ORDER BY `LastReplyTime` DESC", 10)) {
        foreach ($result->data as $post) {
            $teaser = cut_text(utf8entities(stripslashes($post['Body'])), 90);
            $topic = utf8entities(stripslashes($post['Topic']));
            echo "<tr>\n\t\t\t\t\t<td class=\"forum-item-threads-name\">\n\t\t\t\t\t\t<a class=\"forum-table-link\" href=\"/forum/post/{$post['Id']}\">\n\t\t\t\t\t\t\t<div class=\"forum-table-name\">{$topic}</div>\n\t\t\t\t\t\t\t<div class=\"forum-table-teaser\">{$teaser}</div>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class=\"forum-item-threads-replies\">{$post['Replies']}</td>\n\t\t\t\t</tr>";
        }
    } else {
        echo "<tr>\n\t\t\t\t<td colspan=\"2\">There are no threads in this category yet.</td>\n\t\t\t</tr>";
    }
    ?>
	</table>
	
	<?php 
} else {
    $var_code = ANONNEWS_ERROR_NOT_FOUND;
    require "module.error.php";
}