function print_left_bar($type = "main", $selected = "stories") { global $auth_zid; global $auth_user; global $server_name; global $user_page; if ($type == "main") { if ($auth_zid == "") { $section_name = array("stories", "pipe", "poll", "search", "topics", "feed"); $section_link = array("", "pipe/", "poll/", "search", "topic", "feed/"); } else { $section_name = array("stories", "pipe", "poll", "search", "topics"); $section_link = array("", "pipe/", "poll/", "search", "topic"); } } else { if ($type == "user") { //$section_name = array("blog", "feed", "submissions", "comments", "achievements"); //$section_link = array("blog", "feed", "submissions", "comments", "achievements"); $section_name = array("comments"); $section_link = array("comments"); } elseif ($type == "account") { //$section_name = array("mail", "feed", "comments", "karma", "settings"); //$section_link = array("mail/", "feed/edit", "comments", "karma/", "settings"); $section_name = array("comments", "feed", "karma", "settings"); $section_link = array("comments", "feed/edit", "karma/", "settings"); } } writeln('<nav>'); for ($i = 0; $i < count($section_name); $i++) { $link = "/" . $section_link[$i]; //if ($user_page == "" && $section_name[$i] == "feed" && $auth_zid != "") { // $row = run_sql("select count(*) as feed_count from feed_user where zid = ?", array($auth_zid)); // if ($row[0]["feed_count"] > 0) { // $link = "http://" . $auth_user["username"] . ".$server_name/"; // } //} if ($selected == $section_name[$i]) { writeln(' <a href="' . $link . '"><div class="section_active">' . $section_name[$i] . '</div></a>'); } else { writeln(' <a href="' . $link . '"><div>' . $section_name[$i] . '</div></a>'); } } if ($type == "main") { writeln(' <hr/>'); $list = db_get_list("topic", "topic", array("promoted" => 1)); $keys = array_keys($list); for ($i = 0; $i < count($keys); $i++) { $topic = $list[$keys[$i]]["topic"]; if ($topic == $selected) { writeln(' <a href="/topic/' . $topic . '"><div class="section_active">' . $topic . '</div></a>'); } else { writeln(' <a href="/topic/' . $topic . '"><div>' . $topic . '</div></a>'); } } } writeln('</nav>'); }
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>'); }
function render_page($sid, $pid, $qid, $json) { //global $render; //global $parent; //global $keys; //global $total; global $can_moderate; global $hide_value; global $expand_value; $render = array(); $username = array(); $parent = array(); if ($sid != 0) { $comments = db_get_list("comment", "time", array("sid" => $sid)); } elseif ($pid != 0) { $comments = db_get_list("comment", "time", array("pid" => $pid)); } elseif ($qid != 0) { $comments = db_get_list("comment", "time", array("qid" => $qid)); } $total = count($comments); $k = array_keys($comments); if ($json) { writeln('{'); writeln(' "reply": ['); } else { if ($can_moderate) { writeln('<form action="/threshold" method="post">'); } writeln('<div class="comment_header">'); writeln(' <table class="fill">'); writeln(' <tr>'); if ($sid != 0) { writeln(' <td style="width: 30%"><a href="/post?sid=' . $sid . '" class="icon_16" style="background-image: url(\'/images/chat-16.png\')">Reply</a></td>'); } elseif ($pid != 0) { writeln(' <td style="width: 30%"><a href="/post?pid=' . $pid . '" class="icon_16" style="background-image: url(\'/images/chat-16.png\')">Reply</a></td>'); } elseif ($qid != 0) { writeln(' <td style="width: 30%"><a href="/post?qid=' . $qid . '" class="icon_16" style="background-image: url(\'/images/chat-16.png\')">Reply</a></td>'); } if ($can_moderate && false) { writeln(' <td style="width: 30%">'); writeln(' <table>'); writeln(' <tr>'); writeln(' <td>Hide</td>'); $s = "<select name=\"hide_value\">"; for ($i = -1; $i <= 5; $i++) { if ($i == $hide_value) { $s .= "<option selected=\"selected\">{$i}</option>"; } else { $s .= "<option>{$i}</option>"; } } $s .= "</select>"; writeln(' <td>' . $s . '</td>'); writeln(' <td><input type="submit" value="Change"/></td>'); writeln(' </tr>'); writeln(' </table>'); writeln(' </td>'); writeln(' <td style="width: 30%">'); writeln(' <table>'); writeln(' <tr>'); writeln(' <td>Expand</td>'); $s = "<select name=\"expand_value\">"; for ($i = -1; $i <= 5; $i++) { if ($i == $expand_value) { $s .= "<option selected=\"selected\">{$i}</option>"; } else { $s .= "<option>{$i}</option>"; } } $s .= "</select>"; writeln(' <td>' . $s . '</td>'); writeln(' <td><input type="submit" value="Change"/></td>'); writeln(' </tr>'); writeln(' </table>'); writeln(' </td>'); } writeln(' <td style="text-align: right; width: 30%">' . $total . ' comments</td>'); writeln(' </tr>'); writeln(' </table>'); writeln('</div>'); if ($can_moderate) { writeln('</form>'); } } for ($i = 0; $i < $total; $i++) { $comment = $comments[$k[$i]]; $zid = $comment["zid"]; if ($json) { $render[$comment["cid"]] = render_comment_json($comment["subject"], $zid, $comment["time"], $comment["cid"], $comment["comment"]); } else { $render[$comment["cid"]] = render_comment($comment["subject"], $zid, $comment["time"], $comment["cid"], $comment["comment"]); } $parent[$comment["cid"]] = $comment["parent"]; } $keys = array_keys($render); $s = ""; if (!$json && $can_moderate) { writeln('<form action="/moderate_noscript" method="post">'); if ($sid != 0) { writeln('<input type="hidden" name="sid" value="' . $sid . '"/>'); } elseif ($pid != 0) { writeln('<input type="hidden" name="pid" value="' . $pid . '"/>'); } elseif ($qid != 0) { writeln('<input type="hidden" name="qid" value="' . $qid . '"/>'); } } for ($i = 0; $i < $total; $i++) { $comment = $comments[$keys[$i]]; if ($comment["parent"] == 0) { if ($json) { $s .= recursive_render_json($render, $parent, $keys, $comment["cid"], 1) . "\n"; } else { writeln(recursive_render($render, $parent, $keys, $comment["cid"])); } } } if ($json) { if ($total > 0) { writeln(substr($s, 0, -2)); } writeln(' ]'); writeln('}'); } else { if ($can_moderate) { writeln('</form>'); } } }
include "story.php"; $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>');
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(); }
function print_mail_dir($location) { global $auth_zid; print_header($location, array("Compose"), array("mail-compose"), array("/mail/compose")); writeln('<table class="fill">'); writeln('<tr>'); writeln('<td style="vertical-align: top">'); beg_tab(); writeln(' <tr>'); writeln(' <td><a href="/mail/" class="icon_16" style="background-image: url(/images/inbox-16.png)">Inbox</a></td>'); writeln(' </tr>'); writeln(' <tr>'); writeln(' <td><a href="/mail/sent" class="icon_16" style="background-image: url(/images/sent-16.png)">Sent</a></td>'); writeln(' </tr>'); writeln(' <tr>'); writeln(' <td><a href="/mail/junk" class="icon_16" style="background-image: url(/images/junk-16.png)">Junk</a></td>'); writeln(' </tr>'); writeln(' <tr>'); writeln(' <td><a href="/mail/trash" class="icon_16" style="background-image: url(/images/trash-16.png)">Trash</a></td>'); writeln(' </tr>'); end_tab(); writeln('</td>'); writeln('<td class="fill" style="padding-left: 8px">'); beg_tab(); $list = db_get_list("mail", "received_time", array("zid" => $auth_zid, "location" => $location)); $keys = array_keys($list); if (count($list) == 0) { writeln('<tr><td>(no messages)</td></tr>'); } for ($i = 0; $i < count($list); $i++) { $message = $list[$keys[$i]]; if ($location == "Sent") { $address = parse_mail_address($message["rcpt_to"]); } else { $address = parse_mail_address($message["mail_from"]); } if ($message["subject"] == "") { $subject = "(no subject)"; } else { $subject = $message["subject"]; } writeln(' <tr>'); writeln(' <td><a href="view?mid=' . $message["mail_id"] . '" class="icon_16" style="background-image: url(/images/mail-16.png)">' . $message["subject"] . '</a></td>'); if (string_has($address["email"], "no-reply@")) { writeln(' <td class="center">' . $address["email"] . '</td>'); } else { writeln(' <td class="center"><a href="compose?to=' . $address["email"] . '">' . $address["email"] . '</a></td>'); } writeln(' <td class="right">' . date("Y-m-d H:i", $message["received_time"]) . '</td>'); writeln(' </tr>'); } end_tab(); writeln('</td>'); writeln('</tr>'); writeln('</table>'); if (count($list) > 0) { writeln('<form method="post">'); if ($location == "Junk" || $location == "Trash") { right_box("Empty"); } else { right_box("Delete All"); } writeln('</form>'); } print_footer(); }
// 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 "pipe.php"; print_header("Pipe"); writeln('<table class="fill">'); writeln('<tr>'); writeln('<td class="left_col">'); print_left_bar("main", "pipe"); writeln('</td>'); writeln('<td class="fill">'); writeln('<h1>Stories in the Pipe</h1>'); writeln('<p>These are stories waiting to be published to the main page. Remember, anyone can <a href="/submit">submit</a> a new story!</p>'); $pipes = db_get_list("pipe", "time desc", array("closed" => 0)); if (count($pipes) == 0) { writeln('<h1>No stories in the pipe!</h1>'); writeln('<p><a href="/submit">Submit</a> one now or <a href="/pipe/history">view the history</a>.</p>'); } $k = array_keys($pipes); for ($i = 0; $i < count($pipes); $i++) { $pipe = $pipes[$k[$i]]; print_pipe_small($pipe["pid"], false); } if (count($pipes) > 0) { writeln('<div style="margin-top: 8px; text-align: center"><a href="/pipe/history">History</a></div>'); } writeln('</td>'); writeln('</tr>'); writeln('</table>');
$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"]; $topic_keys[] = $k[$i]; } $icon_list = array(); $a = fs_dir("{$doc_root}/images"); for ($i = 0; $i < count($a); $i++) { if (substr($a[$i], -7) == "-64.png") { $icon_list[] = substr($a[$i], 0, -7); } } writeln('<h1>Preview</h1>'); $a = array(); $a["title"] = $title;
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>'); } }
function init_travel($domain) { LOG_MSG('INFO', "init_travel(): START"); $travel_row = db_get_list('ARRAY', 'travel_id,domain,name AS travel_name', 'tTravel', "domain='{$domain}'"); if ($travel_row[0]['STATUS'] != 'OK') { LOG_MSG('ERROR', "init_travel(): Error getting travel_id for domain=[{$domain}] "); add_msg('ERROR', 'There was an error loading. Please try later'); return; } define('TRAVEL_ID', $travel_row[0]['travel_id']); define('DOMAIN', $travel_row[0]['domain']); define('TRAVEL_NAME', $travel_row[0]['travel_name']); LOG_MSG('INFO', "init_travel(): END"); }