Example #1
0
function send_notifications($parent, $comment)
{
    global $server_name;
    $new_subject = $comment["subject"];
    $new_cid = $comment["cid"];
    $parent = $comment["parent"];
    while ($parent > 0) {
        $comment = db_get_rec("comment", $parent);
        $zid = $comment["zid"];
        if ($zid != "") {
            $a = article_info($comment);
            $subject = "Comment Reply";
            $body = "Your comment has a new reply.\n";
            $body .= "\n";
            $body .= "In the " . $a["type"] . ":\n";
            $body .= $a["title"] . "\n";
            $body .= $a["link"] . "\n";
            $body .= "\n";
            $body .= "Your original comment:\n";
            $body .= $comment["subject"] . "\n";
            $body .= "http://{$server_name}/comment/{$parent}\n";
            $body .= "\n";
            $body .= "The new reply:\n";
            $body .= "{$new_subject}\n";
            $body .= "http://{$server_name}/comment/{$new_cid}\n";
            $body .= "\n";
            send_web_mail($zid, $subject, $body, "", false);
        }
        $parent = $comment["parent"];
    }
}
Example #2
0
function moderate($cid, $zid, $rid)
{
    if (!db_has_rec("comment", $cid)) {
        return;
    }
    if (db_has_rec("comment_vote", array("cid" => $cid, "zid" => $zid))) {
        $comment_vote = db_get_rec("comment_vote", array("cid" => $cid, "zid" => $zid));
        $old = $comment_vote["rid"];
        if ($rid == $old) {
            return;
        } else {
            if ($rid == 0) {
                db_del_rec("comment_vote", array("cid" => $cid, "zid" => $zid));
            } else {
                $comment_vote["rid"] = $rid;
                db_set_rec("comment_vote", $comment_vote);
                return;
            }
        }
    }
    $comment_vote = array();
    $comment_vote["cid"] = $cid;
    $comment_vote["zid"] = $zid;
    $comment_vote["rid"] = $rid;
    $comment_vote["time"] = time();
    db_set_rec("comment_vote", $comment_vote);
}
Example #3
0
function print_story($sid, $ipos = "right")
{
    global $server_name;
    global $auth_user;
    $story = db_get_rec("story", $sid);
    $pipe = db_get_rec("pipe", $story["pid"]);
    $topic = db_get_rec("topic", $story["tid"]);
    $a["story"] = $story["story"];
    $a["time"] = $story["time"];
    $a["sid"] = $sid;
    $a["ipos"] = $ipos;
    $a["topic"] = $topic["topic"];
    $a["icon"] = $story["icon"];
    $a["title"] = $story["title"];
    $a["pid"] = $story["pid"];
    $a["ipos"] = $ipos;
    $a["zid"] = $pipe["zid"];
    if ($sid > 0) {
        $row = run_sql("select count(cid) as comments from comment where sid = ?", array($sid));
        $a["comments"] = $row[0]["comments"];
    } else {
        $a["comments"] = 0;
    }
    print_article($a);
}
Example #4
0
function captcha_verify($answer)
{
    global $remote_ip;
    $answer = crypt_md5(strtolower(trim($answer)));
    $captcha_challenge = db_get_rec("captcha_challenge", $remote_ip);
    $captcha = db_get_rec("captcha", $captcha_challenge["captcha_id"]);
    $a = explode(" ", $captcha["answer"]);
    return in_array($answer, $a);
}
Example #5
0
function get_comment_score($cid)
{
    global $cache_enabled;
    //	if ($cache_enabled) {
    //		$cache_key = "comment_score.$cid";
    //		$s = cache_get($cache_key);
    //		if ($s !== false) {
    //			return $s;
    //		}
    //	}
    $row = run_sql("select sum(value) as score from comment_vote inner join reason on comment_vote.rid = reason.rid where cid = ?", array($cid));
    $score = (int) $row[0]["score"];
    if (db_has_rec("comment", $cid)) {
        $comment = db_get_rec("comment", $cid);
        if ($comment["zid"] != "") {
            $score++;
        }
    }
    if ($score < -1) {
        $score = -1;
    } else {
        if ($score > 5) {
            $score = 5;
        }
    }
    //$up = array("Insightful", "Interesting", "Informative", "Funny", "Underrated");
    //$down = array("Offtopic", "Flamebait", "Troll", "Redundant", "Overrated");
    $reason = "";
    $row = run_sql("select reason, count(reason) as reason_count, value from comment_vote inner join reason on comment_vote.rid = reason.rid where cid = ? group by reason order by value desc, reason_count desc", array($cid));
    for ($i = 0; $i < count($row); $i++) {
        if ($score < 0 && $row[$i]["value"] < 0 && $row[$i]["reason_count"] > 1 && $row[$i]["reason"] != "Overrated") {
            $reason = ", " . $row[$i]["reason"];
            break;
        }
        if ($score > 1 && $row[$i]["value"] > 0 && $row[$i]["reason_count"] > 1 && $row[$i]["reason"] != "Underrated") {
            $reason = ", " . $row[$i]["reason"];
            break;
        }
    }
    //	if ($cache_enabled) {
    //		cache_set($cache_key, "$score$reason");
    //	}
    return "{$score}{$reason}";
}
Example #6
0
function article_info($comment)
{
    global $server_name;
    $a = array();
    if ($comment["sid"] > 0) {
        $story = db_get_rec("story", $comment["sid"]);
        $a["type"] = "story";
        $a["title"] = $story["title"];
        $date = gmdate("Y-m-d", $story["time"]);
        $a["link"] = "http://{$server_name}/story/{$date}/" . $story["ctitle"];
    } else {
        if ($comment["pid"] > 0) {
            $pipe = db_get_rec("pipe", $comment["pid"]);
            $a["type"] = "pipe";
            $a["title"] = $pipe["title"];
            $a["link"] = "http://{$server_name}/pipe/" . $comment["pid"];
        } else {
            if ($comment["qid"] > 0) {
                $question = db_get_rec("poll_question", $comment["qid"]);
                $a["type"] = "poll";
                $a["title"] = $question["question"];
                $a["link"] = "http://{$server_name}/poll/" . $comment["qid"];
            }
        }
    }
    return $a;
}
Example #7
0
function print_submit_box($title, $body, $story, $tid, $preview)
{
    global $auth_zid;
    global $auth_user;
    print_header("Submit Story");
    writeln('<table class="fill">');
    writeln('<tr>');
    writeln('<td class="left_col">');
    print_left_bar("main", "pipe");
    writeln('</td>');
    writeln('<td class="fill">');
    if ($preview) {
        $a["zid"] = $auth_zid;
        $topic = db_get_rec("topic", $tid);
        $a["title"] = $title;
        $a["topic"] = $topic["topic"];
        $a["icon"] = $topic["icon"];
        $a["story"] = $story;
        writeln('<h1>Preview</h1>');
        writeln('<p>Check your links before you post!</p>');
        print_article($a);
    }
    writeln('<form method="post">');
    writeln('<div class="dialog_title">Submit Story</div>');
    writeln('<div class="dialog_body">');
    writeln('<table class="fill" style="padding: 0px">');
    writeln('	<tr>');
    writeln('		<td style="width: 80px">Title</td>');
    writeln('		<td colspan="2"><input name="title" type="text" value="' . $title . '" required="required"/></td>');
    writeln('	</tr>');
    writeln('	<tr>');
    writeln('		<td style="width: 80px">Topic</td>');
    writeln('		<td colspan="2">');
    writeln('			<select name="tid">');
    $topics = db_get_list("topic", "topic", array("promoted" => 1));
    $k = array_keys($topics);
    for ($i = 0; $i < count($topics); $i++) {
        $topic = $topics[$k[$i]];
        if ($topic["tid"] == $tid) {
            writeln('				<option value="' . $topic["tid"] . '" selected="selected">' . $topic["topic"] . '</option>');
        } else {
            writeln('				<option value="' . $topic["tid"] . '">' . $topic["topic"] . '</option>');
        }
    }
    writeln('			</select>');
    writeln('		</td>');
    writeln('	</tr>');
    writeln('	<tr>');
    writeln('		<td style="width: 80px; vertical-align: top; padding-top: 12px">Story</td>');
    writeln('		<td colspan="2"><textarea name="story" style="height: 200px" required="required">' . $body . '</textarea></td>');
    writeln('	</tr>');
    writeln('	<tr>');
    $question = captcha_challenge();
    writeln('		<td>Captcha</td>');
    writeln('		<td><table><tr><td>' . $question . '</td><td><input name="answer" type="text" style="margin-left: 8px; width: 100px"/></td></tr></table></td>');
    writeln('		<td class="right"><input type="submit" value="Submit"/> <input name="preview" type="submit" value="Preview"/></td>');
    writeln('	</tr>');
    writeln('</table>');
    writeln('</div>');
    writeln('</form>');
    writeln('</td>');
    writeln('</tr>');
    writeln('</table>');
    print_footer();
}
Example #8
0
function print_feed_page($zid)
{
    writeln('<table style="width: 100%">');
    writeln('	<tr>');
    for ($c = 0; $c < 3; $c++) {
        writeln('		<td class="feed_box">');
        $row = run_sql("select fid from feed_user where zid = ? and col = ? order by pos", array($zid, $c));
        for ($f = 0; $f < count($row); $f++) {
            $feed = db_get_rec("feed", $row[$f]["fid"]);
            writeln('			<div class="feed_title"><a href="' . $feed["link"] . '">' . $feed["title"] . '</a></div>');
            writeln('			<div class="feed_body">');
            $items = db_get_list("feed_item", "time desc", array("fid" => $feed["fid"]));
            $item_keys = array_keys($items);
            for ($j = 0; $j < count($items); $j++) {
                $item = $items[$item_keys[$j]];
                writeln('				<div><a href="' . $item["link"] . '">' . clean_feed_title($item["title"]) . '</a></div>');
            }
            writeln('			</div>');
        }
        writeln('		</td>');
    }
    writeln('	</tr>');
    writeln('</table>');
}
Example #9
0
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
include "render.php";
include "poll.php";
$qid = (int) $s2;
if ($qid == "") {
    $row = run_sql("select max(qid) as qid from poll_question");
    $qid = $row[0]["qid"];
    $vote = true;
}
$poll_question = db_get_rec("poll_question", $qid);
$clean = clean_url($poll_question["question"]);
$type_id = $poll_question["type_id"];
if ($auth_zid == "") {
    $can_moderate = true;
    $hide_value = $auth_user["hide_threshold"];
    $expand_value = $auth_user["expand_threshold"];
} else {
    $can_moderate = false;
    $hide_value = -1;
    $expand_value = 0;
}
print_header("Poll");
writeln('<table class="fill">');
writeln('<tr>');
writeln('<td class="left_col">');
Example #10
0
$topic = $s2;
print_header("Topics");
writeln('<table class="fill">');
writeln('<tr>');
writeln('<td class="left_col">');
if ($topic == "") {
    print_left_bar("main", "topics");
} else {
    print_left_bar("main", $topic);
}
writeln('</td>');
writeln('<td class="fill">');
if ($topic == "") {
    writeln('<h1>Topics</h1>');
    $list = db_get_list("topic", "topic");
    $k = array_keys($list);
    for ($i = 0; $i < count($list); $i++) {
        $topic = $list[$k[$i]];
        writeln('<a href="/topic/' . $topic["topic"] . '"><div class="topic_box"><img alt="' . $topic["icon"] . '" src="/images/' . $topic["icon"] . '-64.png"/>' . $topic["topic"] . '</div></a>');
    }
} else {
    $topic = db_get_rec("topic", array("topic" => $topic));
    $row = run_sql("select sid from story where tid = ? order by sid desc", array($topic["tid"]));
    for ($i = 0; $i < count($row); $i++) {
        print_story($row[$i]["sid"]);
    }
}
writeln('</td>');
writeln('</tr>');
writeln('</table>');
print_footer();
Example #11
0
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pipecode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
if ($zid != $auth_zid) {
    die("not your page");
}
$fid = http_get_int("fid");
$feed = db_get_rec("feed", $fid);
if (http_post()) {
    db_del_rec("feed_user", array("zid" => $auth_zid, "fid" => $fid));
    $row = run_sql("select count(zid) as user_count from feed_user where fid = ?", array($fid));
    $count = $row[0]["user_count"];
    if ($count == 0) {
        run_sql("delete from feed_item where fid = ?", array($fid));
        run_sql("delete from feed where fid = ?", array($fid));
    }
    header("Location: edit");
    die;
}
print_header();
writeln('<form method="post">');
writeln('<h1>Remove Feed</h1>');
writeln('<p>Are you sure you want to remove <b>' . $feed["title"] . '</b> from your page?</p>');
Example #12
0
// (at your option) any later version.
//
// Pipecode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
include "render.php";
$cid = (int) $s2;
if (!string_uses($cid, "[0-9]")) {
    die("invalid cid [{$cid}]");
}
$comment = db_get_rec("comment", $cid);
$can_moderate = false;
$a = article_info($comment);
print_header($comment["subject"]);
writeln('<table class="fill">');
writeln('<tr>');
writeln('<td class="left_col">');
print_left_bar("main", "stories");
writeln('</td>');
writeln('<td class="fill">');
writeln('<h1>' . ucwords($a["type"]) . '</h1>');
writeln('<a href="' . $a["link"] . '">' . $a["title"] . '</a>');
writeln('<h2>Preview</h2>');
writeln(render_comment($comment["subject"], $comment["zid"], $comment["time"], $comment["cid"], $comment["comment"]));
writeln('</div>');
writeln('</td>');
Example #13
0
 if (count($row) == 0) {
     writeln('(no results)');
 }
 //var_dump($row);
 for ($i = 0; $i < count($row); $i++) {
     if ($haystack == "comments") {
         $title = $row[$i]["subject"];
         $link = "/comment/" . $row[$i]["cid"];
         $body = $row[$i]["comment"];
         $zid = $row[$i]["zid"];
     } else {
         if ($haystack == "stories") {
             $title = $row[$i]["title"];
             $link = "/story/" . $row[$i]["sid"];
             $body = $row[$i]["story"];
             $pipe = db_get_rec("pipe", $row[$i]["pid"]);
             $zid = $pipe["zid"];
         } else {
             if ($haystack == "pipe") {
                 $title = $row[$i]["title"];
                 $link = "/pipe/" . $row[$i]["pid"];
                 $body = $row[$i]["story"];
                 $zid = $row[$i]["zid"];
             } else {
                 if ($haystack == "polls") {
                     $title = $row[$i]["question"];
                     $link = "/poll/" . $row[$i]["qid"];
                     $body = "";
                     $zid = $row[$i]["zid"];
                 }
             }
Example #14
0
         if ($qid != $poll_answer["qid"]) {
             die("answer [" . $aids[$i] . "] not on question [{$qid}]");
         }
     }
 } else {
     if ($type_id == 3) {
         $row = run_sql("select count(*) as answer_count from poll_answer where qid = ?", array($qid));
         $max = $row[0]["answer_count"];
         $aids = @$_POST["aid"];
         $keys = array_keys($aids);
         $scores = array();
         for ($i = 0; $i < count($keys); $i++) {
             if (!string_uses($keys[$i], "[0-9]")) {
                 die("invalid aid [" . $keys[$i] . "]");
             }
             $poll_answer = db_get_rec("poll_answer", $keys[$i]);
             if ($qid != $poll_answer["qid"]) {
                 die("answer [" . $keys[$i] . "] not on question [{$qid}]");
             }
             $aid = $keys[$i];
             $score = (int) $aids[$aid];
             if ($aids[$aid] === "0" || $score > $max) {
                 die("score out of bounds [{$score}]");
             }
             if ($score > 0) {
                 $scores[] = $score;
             }
         }
         if (count($scores) !== count(array_unique($scores))) {
             die("duplicate score detected");
         }
Example #15
0
        $story["ctitle"] = clean_url($title);
        $story["icon"] = $icon;
        $story["story"] = $new_body;
        db_set_rec("story", $story);
        header("Location: /story/{$sid}");
        die;
    }
} else {
    $title = $story["title"];
    $tid = $story["tid"];
    $icon = $story["icon"];
    $body = $story["story"];
    $new_body = $story["story"];
    $body = dirty_html($new_body);
}
$topic = db_get_rec("topic", $tid);
$topic = $topic["topic"];
print_header();
writeln('<form method="post">');
writeln('<table class="fill">');
writeln('<tr>');
writeln('<td class="left_col">');
print_left_bar("main", "pipe");
writeln('</td>');
writeln('<td class="fill">');
$topic_list = array();
$topic_keys = array();
$topics = db_get_list("topic", "topic");
$k = array_keys($topics);
for ($i = 0; $i < count($topics); $i++) {
    $topic_list[] = $topics[$k[$i]]["topic"];
Example #16
0
//
// Pipecode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
include "mail.php";
$verify = http_get_string("verify", array("required" => false, "len" => 64, "valid" => "[0-9]abcdef"));
if (strlen($verify) != 0 && strlen($verify) != 64) {
    die("invalid verify hash");
}
if ($verify != "") {
    $email_challenge = db_get_rec("email_challenge", array("challenge" => $verify));
    $zid = strtolower($email_challenge["username"]) . "@{$site_name}";
    if (!is_local_user($zid)) {
        die("no such user [{$zid}]");
    }
    $user_conf = db_get_conf("user_conf", $zid);
}
if (http_post()) {
    if ($verify != "") {
        $password_1 = http_post_string("password_1", array("len" => 64, "valid" => "[KEYBOARD]"));
        $password_2 = http_post_string("password_2", array("len" => 64, "valid" => "[KEYBOARD]"));
        if (strlen($password_1) < 6) {
            die("password too short");
        }
        if ($password_1 != $password_2) {
            die("passwords do not match");
Example #17
0
// Pipecode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
include "render.php";
include "pipe.php";
include "story.php";
$pid = $s2;
if (!string_uses($pid, "[0-9]")) {
    die("invalid pid [{$pid}]");
}
$pipe = db_get_rec("pipe", $pid);
$status = "Voting";
if ($pipe["closed"]) {
    $status = "Closed";
    $row = run_sql("select sid from story where pid = ?", array($pid));
    if (count($row) > 0) {
        $status = '<a href="/story/' . $row[0]["sid"] . '">Published</a>';
    }
}
if ($pipe["reason"] == "") {
    $reason = "";
} else {
    $reason = " (" . $pipe["reason"] . ")";
}
if ($auth_zid != "") {
    $can_moderate = true;
Example #18
0
function vote_box($qid, $full, $vote)
{
    global $poll_question;
    if (empty($poll_question)) {
        $poll_question = db_get_rec("poll_question", $qid);
    }
    $clean = clean_url($poll_question["question"]);
    $type_id = $poll_question["type_id"];
    if (!$full) {
        writeln('<div class="right_bar">');
    }
    writeln('<div class="dialog_title">Poll</div>');
    writeln('<div class="dialog_body">');
    $poll_answer = db_get_list("poll_answer", "position", array("qid" => $poll_question["qid"]));
    $k = array_keys($poll_answer);
    if ($vote) {
        writeln('	<form action="/poll/' . $qid . '/vote" method="post">');
        writeln('	<div class="poll_question">' . $poll_question["question"] . '</div>');
        writeln('	<table class="poll_table">');
        for ($i = 0; $i < count($poll_answer); $i++) {
            $answer = $poll_answer[$k[$i]];
            writeln('		<tr>');
            if ($type_id == 1) {
                $units = "votes";
                writeln('			<td><input id="a_' . $answer["aid"] . '" name="aid" value="' . $answer["aid"] . '" type="radio"/></td>');
            } else {
                if ($type_id == 2) {
                    $units = "votes";
                    writeln('			<td><input id="a_' . $answer["aid"] . '" name="aid[]" value="' . $answer["aid"] . '" type="checkbox"/></td>');
                } else {
                    if ($type_id == 3) {
                        $units = "points";
                        writeln('			<td><input id="a_' . $answer["aid"] . '" name="aid[' . $answer["aid"] . ']" type="text"/></td>');
                    } else {
                        die("unknown poll type [{$type_id}]");
                    }
                }
            }
            writeln('			<td><label for="a_' . $answer["aid"] . '">' . $answer["answer"] . '</label></td>');
            writeln('		</tr>');
        }
        writeln('	</table>');
        if ($type_id == 1 || $type_id == 2) {
            $row = run_sql("select count(zid) as votes from poll_vote where qid = ?", array($qid));
            $votes = $row[0]["votes"];
        } else {
            $row = run_sql("select sum(points) as votes from poll_vote where qid = ?", array($qid));
            $votes = (int) $row[0]["votes"];
        }
        $row = run_sql("select count(cid) as comments from comment where qid = ?", array($qid));
        $comments = $row[0]["comments"];
        writeln('	<table class="fill">');
        writeln('		<tr>');
        writeln('			<td style="width: 40px"><input type="submit" value="Vote"/></td>');
        writeln('			<td><a href="/poll/' . $qid . '/' . $clean . '"><b>' . $comments . '</b> comments</a></td>');
        writeln('			<td class="right"><b>' . $votes . '</b> ' . $units . '</td>');
        writeln('		</tr>');
        writeln('	</table>');
        writeln('	</form>');
    } else {
        $total = 0;
        $votes = array();
        writeln('	<table style="width: 100%">');
        writeln('		<tr>');
        writeln('			<td class="poll_question">' . $poll_question["question"] . '</td>');
        writeln('		</tr>');
        if ($type_id == 1 || $type_id == 2) {
            $units = "votes";
            for ($i = 0; $i < count($poll_answer); $i++) {
                $answer = $poll_answer[$k[$i]];
                $row = run_sql("select count(*) as votes from poll_vote where qid = ? and aid = ?", array($qid, $answer["aid"]));
                $votes[] = $row[0]["votes"];
                $total += $row[0]["votes"];
            }
        } else {
            if ($type_id == 3) {
                $units = "points";
                for ($i = 0; $i < count($poll_answer); $i++) {
                    $answer = $poll_answer[$k[$i]];
                    $row = run_sql("select sum(points) as votes from poll_vote where qid = ? and aid = ?", array($qid, $answer["aid"]));
                    $votes[] = $row[0]["votes"];
                    $total += $row[0]["votes"];
                }
            }
        }
        for ($i = 0; $i < count($poll_answer); $i++) {
            $answer = $poll_answer[$k[$i]];
            if ($total == 0) {
                $percent = 0;
            } else {
                $percent = round($votes[$i] / $total * 100);
            }
            writeln('		<tr>');
            writeln('			<td class="poll_answer">' . $answer["answer"] . '</td>');
            writeln('		</tr>');
            writeln('		<tr>');
            writeln('			<td><table class="poll_result"><tr><th style="width: ' . $percent . '%"></th><td style="width: ' . (100 - $percent) . '%">' . $votes[$i] . " {$units} ({$percent}%)" . '</td></tr></table></td>');
            writeln('		</tr>');
        }
        writeln('	</table>');
        writeln('	<table class="fill">');
        writeln('		<tr>');
        writeln('			<td><a href="/poll/' . $qid . '/vote"><b>Vote</b></a></td>');
        writeln('			<td class="right"><b>' . $total . '</b> ' . $units . '</td>');
        writeln('		</tr>');
        writeln('	</table>');
    }
    writeln('</div>');
    if (!$full) {
        writeln('</div>');
    }
}
Example #19
0
    $row = run_sql("select sid from story where time > ? and time < ? and ctitle = ?", array($time_beg, $time_end, $ctitle));
    if (count($row) == 0) {
        die("story not found - date [{$date}] title [{$ctitle}]");
    }
    $sid = $row[0]["sid"];
}
if ($auth_zid != "") {
    $can_moderate = true;
    $hide_value = $auth_user["hide_threshold"];
    $expand_value = $auth_user["expand_threshold"];
} else {
    $can_moderate = false;
    $hide_value = -1;
    $expand_value = 0;
}
$story = db_get_rec("story", $sid);
print_header($story["title"]);
writeln('<table class="fill">');
writeln('<tr>');
writeln('<td class="left_col">');
print_left_bar("main", "stories");
writeln('</td>');
writeln('<td class="fill">');
print_story($sid);
//print_story($sid, true, false);
if ($javascript_enabled) {
    render_sliders($sid, 0, 0);
    print_noscript();
} else {
    render_page($sid, 0, 0, false);
}
Example #20
0
// along with Pipecode.  If not, see <http://www.gnu.org/licenses/>.
//
include "mail.php";
if (http_post()) {
    $to = http_post_string("to", array("len" => 250, "valid" => "[a-z][A-Z][0-9]-_.<>@+ "));
    $subject = http_post_string("subject", array("len" => 250, "valid" => "[ALL]"));
    $body = http_post_string("body", array("len" => 64000, "valid" => "[ALL]"));
    $in_reply_to = http_post_string("in_reply_to", array("required" => false, "len" => 250, "valid" => "[a-z][A-Z][0-9]-_.@+-"));
    send_web_mail($to, $subject, $body, $in_reply_to);
    header("Location: /mail/");
    die;
}
$to = http_get_string("to", array("required" => false, "len" => 250, "valid" => "[a-z][A-Z][0-9]-_.<>@+ "));
$mid = http_get_int("mid", array("required" => false));
if ($mid > 0) {
    $message = db_get_rec("mail", $mid);
    $in_reply_to = $message["message_id"];
    $to = $message["mail_from"];
    $subject = $message["subject"];
    if (substr($subject, 0, 4) != "Re: ") {
        $subject = "Re: {$subject}";
    }
} else {
    $in_reply_to = "";
    $subject = "";
}
print_header("Mail", array("Inbox"), array("inbox"), array("/mail/"));
writeln('<form method="post">');
writeln('<input name="in_reply_to" type="hidden" value="' . $in_reply_to . '"/>');
beg_tab();
print_row(array("caption" => "To", "text_key" => "to", "text_value" => $to));
Example #21
0
function print_pipe_small($pid, $full)
{
    global $server_name;
    global $auth_zid;
    global $auth_user;
    global $javascript_enabled;
    $pipe = db_get_rec("pipe", $pid);
    $date = date("Y-m-d H:i", $pipe["time"]);
    $score = 0;
    $topic = db_get_rec("topic", $pipe["tid"]);
    $zid = $pipe["zid"];
    if ($zid == "") {
        $by = "<b>Anonymous Coward</b>";
    } else {
        $by = "<b>{$zid}</b>";
    }
    $row = run_sql("select count(cid) as total from comment where pid = ?", array($pid));
    $total = $row[0]["total"];
    $row = run_sql("select value from pipe_vote where pid = ? and zid = ?", array($pid, $auth_zid));
    if (count($row) == 0) {
        $value = 0;
    } else {
        $value = $row[0]["value"];
    }
    $row = run_sql("select sum(value) as score from pipe_vote where pid = ?", array($pid));
    $score = (int) $row[0]["score"];
    if ($score > 0) {
        $score = "+{$score}";
    }
    if ($javascript_enabled) {
        writeln('<div id="title_' . $pid . '" class="pipe_title_collapse">');
    } else {
        writeln('<form method="post" action="/pipe/' . $pid . '/vote">');
        writeln('<div id="title_' . $pid . '" class="pipe_title_expand">');
    }
    writeln('<table class="fill">');
    writeln('	<tr>');
    if ($auth_zid != "") {
        if ($javascript_enabled) {
            if ($value < 0) {
                writeln('		<td style="width: 32px"><img id="icon_' . $pid . '_a" alt="You Voted Down" title="You Voted Down" style="cursor: pointer;" src="/images/down-32.png" onclick="vote(' . $pid . ', 1)"/></td>');
                writeln('		<td style="width: 32px"><img id="icon_' . $pid . '_b" alt="Undo Vote" title="Undo Vote" style="cursor: pointer;" src="/images/undo-32.png" onclick="vote(' . $pid . ', 0)"/></td>');
            } else {
                if ($value == 0) {
                    writeln('		<td style="width: 32px"><img id="icon_' . $pid . '_a" alt="Vote Up" title="Vote Up" style="cursor: pointer;" src="/images/add-32.png" onclick="vote(' . $pid . ', 1)"/></td>');
                    writeln('		<td style="width: 32px"><img id="icon_' . $pid . '_b" alt="Vote Down" title="Vote Down" style="cursor: pointer;" src="/images/remove-32.png" onclick="vote(' . $pid . ', 0)"/></td>');
                } else {
                    if ($value > 0) {
                        writeln('		<td style="width: 32px"><img id="icon_' . $pid . '_a" alt="You Voted Up" title="You Voted Up" style="cursor: pointer;" src="/images/up-32.png" onclick="vote(' . $pid . ', 1)"/></td>');
                        writeln('		<td style="width: 32px"><img id="icon_' . $pid . '_b" alt="Undo Vote" title="Undo Vote" style="cursor: pointer;" src="/images/undo-32.png" onclick="vote(' . $pid . ', 0)"/></td>');
                    }
                }
            }
        } else {
            if ($value < 0) {
                writeln('		<td style="width: 32px"><img alt="You Voted Down" title="You Voted Down" src="/images/down-32.png"/></td>');
                writeln('		<td style="width: 32px"><input type="image" name="undo" alt="Undo Vote" title="Undo Vote" src="/images/undo-32.png"/></td>');
            } else {
                if ($value == 0) {
                    writeln('		<td style="width: 32px"><input type="image" name="up" alt="Vote Up" title="Vote Up" src="/images/add-32.png"/></td>');
                    writeln('		<td style="width: 32px"><input type="image" name="down" alt="Vote Down" title="Vote Down" src="/images/remove-32.png"/></td>');
                } else {
                    if ($value > 0) {
                        writeln('		<td style="width: 32px"><img alt="You Voted Up" title="You Voted Up" src="/images/up-32.png"/></td>');
                        writeln('		<td style="width: 32px"><input type="image" name="undo" alt="Undo Vote" title="Undo Vote" src="/images/undo-32.png"/></td>');
                    }
                }
            }
        }
    }
    writeln('		<td style="width: 100%">');
    if ($javascript_enabled) {
        writeln('			<table class="fill" style="cursor: pointer;" onclick="toggle_body(' . $pid . ')">');
    } else {
        writeln('			<table class="fill">');
    }
    writeln('				<tr>');
    writeln('					<td id="score_' . $pid . '" style="width: 48px; text-align: center">' . $score . '</td>');
    writeln('					<td>');
    writeln('						<table class="fill">');
    writeln('							<tr>');
    writeln('								<td>' . $pipe["title"] . '</td>');
    writeln('							</tr>');
    writeln('							<tr>');
    writeln('								<td class="pipe_subtitle">by ' . $by . ' on ' . $date . ' (#' . $pipe["pid"] . ')</td>');
    writeln('							</tr>');
    writeln('						</table>');
    writeln('					</td>');
    writeln('				</tr>');
    writeln('			</table>');
    writeln('		</td>');
    writeln('		<td style="text-align: right; white-space: nowrap;"><a href="/pipe/' . $pid . '" class="icon_16" style="background-image: url(\'/images/chat-16.png\')"><b>' . $total . '</b> comments</a></td>');
    writeln('	</tr>');
    writeln('</table>');
    writeln('</div>');
    if ($javascript_enabled) {
        writeln('<div id="body_' . $pid . '" class="pipe_body" style="display: none">');
    } else {
        writeln('</form>');
        writeln('<div class="pipe_body">');
    }
    writeln($pipe["story"]);
    writeln('</div>');
}