function make_atom($topic) { global $server_name; global $server_title; global $server_slogan; global $cache_enabled; $row = run_sql("select sid, pipe.zid, story.time, story.title, story.ctitle, story.story from story inner join pipe on story.pid = pipe.pid order by sid desc limit 10"); if (count($row) > 0) { $updated = $row[0]["time"]; } else { $updated = time(); } $body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $body .= "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"; $body .= "\t<title type=\"text\">{$server_title}</title>\n"; $body .= "\t<subtitle type=\"text\">{$server_slogan}</subtitle>\n"; $body .= "\t<updated>" . gmdate(DATE_ATOM, $updated) . "</updated>\n"; $body .= "\t<id>http://{$server_name}/atom</id>\n"; $body .= "\t<link rel=\"alternate\" type=\"text/html\" hreflang=\"en\" href=\"http://{$server_name}/\"/>\n"; $body .= "\t<link rel=\"self\" type=\"application/atom+xml\" href=\"http://{$server_name}/atom\"/>\n"; $body .= "\t<icon>http://{$server_name}/favicon.ico</icon>\n"; $body .= "\t<logo>http://{$server_name}/images/logo-feed.png</logo>\n"; for ($i = 0; $i < count($row); $i++) { $body .= "\t<entry>\n"; $body .= "\t\t<id>http://{$server_name}/story/" . $row[$i]["sid"] . "</id>\n"; $body .= "\t\t<title>" . $row[$i]["title"] . "</title>\n"; $body .= "\t\t<updated>" . gmdate(DATE_ATOM, $row[$i]["time"]) . "</updated>\n"; $body .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"http://{$server_name}/story/" . gmdate("Y-m-d", $row[$i]["time"]) . "/" . $row[$i]["ctitle"] . "\"/>\n"; $body .= "\t\t<author>\n"; if ($row[$i]["zid"] == "") { $body .= "\t\t\t<name>Anonymous Coward</name>\n"; } else { $body .= "\t\t\t<name>" . $row[$i]["zid"] . "</name>\n"; $body .= "\t\t\t<uri>" . user_page_link($row[$i]["zid"]) . "</uri>\n"; } $body .= "\t\t</author>\n"; $body .= "\t\t<content type=\"html\">" . htmlspecialchars($row[$i]["story"]) . "</content>\n"; $body .= "\t</entry>\n"; } $body .= "</feed>\n"; //$date = gmdate("D, j M Y H:i:s") . " GMT"); $time = time(); $etag = md5($body); if ($cache_enabled) { //cache_set("atom.$topic.time", $time); //cache_set("atom.$topic.etag", $etag); //cache_set("atom.$topic.body", $body); cache_set(array("atom.{$topic}.time" => $time, "atom.{$topic}.etag" => $etag, "atom.{$topic}.body" => $body)); } return array($time, $etag, $body); }
function search_result($title, $link, $zid, $time, $body) { global $server_name; global $protocol; $date = date("Y-m-d H:i", $time); if ($zid == "") { $by = "Anonymous Coward"; } else { $by = "<a href=\"" . user_page_link($zid) . "\">{$zid}</a>"; } writeln("<article>"); writeln("\t<h1><a href=\"{$link}\">{$title}</a></h1>"); writeln("\t<h2>{$protocol}://{$server_name}{$link}</h2>"); writeln("\t<h3>by {$by} on {$date}</h3>"); writeln("\t<p>{$body}</p>"); writeln("</article>"); }
function render_comment($subject, $zid, $time, $cid, $body) { global $server_name; global $can_moderate; global $auth_zid; global $protocol; $score = get_comment_score($cid); $s = "<div class=\"comment_subject\">{$subject} (Score: {$score})</div>\n"; $s .= "<div class=\"comment_subtitle\">"; if ($zid == "") { $s .= "by Anonymous Coward "; } else { $s .= "by <a href=\"" . user_page_link($zid) . "\">{$zid}</a> "; } $s .= "on " . date("Y-m-d H:i", $time) . " (<a href=\"/comment/" . $cid . "\">#" . $cid . "</a>)</div>\n"; $s .= "<div class=\"comment_body\">\n"; $s .= "<div id=\"body_{$cid}\" class=\"comment_contents\">"; $s .= "{$body}\n"; $reason = array("Normal", "Offtopic", "Flamebait", "Troll", "Redundant", "Insightful", "Interesting", "Informative", "Funny", "Overrated", "Underrated"); if ($can_moderate && $zid != $auth_zid) { $row = run_sql("select rid from comment_vote where cid = ? and zid = ?", array($cid, $auth_zid)); if (count($row) == 0) { $selected = 0; } else { $selected = $row[0]["rid"]; } //$s = "selected [$selected]"; $s .= "<div class=\"comment_command\"><a href=\"/post?cid={$cid}\">Reply</a><select name=\"cid_{$cid}\">"; for ($i = 0; $i < count($reason); $i++) { if ($i == $selected) { $s .= "<option value=\"{$i}\" selected=\"selected\">" . $reason[$i] . "</option>"; } else { $s .= "<option value=\"{$i}\">" . $reason[$i] . "</option>"; } } $s .= "</select> <input type=\"submit\" value=\"Moderate\"/></div>\n"; } else { $s .= "<div class=\"comment_command\"><a href=\"/post?cid={$cid}\">Reply</a></div>\n"; } $s .= "</div>\n"; return $s; }
function print_noscript() { global $server_name; global $auth_zid; global $auth_user; global $protocol; writeln('<noscript>'); writeln('<div class="balloon">'); writeln('<h1>JavaScript Disabled</h1>'); writeln('<p>Which is fine! But you are currently browsing the JavaScript version of this page. Please do one of the following:</p>'); writeln('<ul>'); writeln(' <li>Enable scripts from <b>' . $server_name . '</b></li>'); if ($auth_zid == "") { writeln(' <li>Sign in and uncheck the "Use JavaScript" option on your account settings page.</li>'); writeln(' <li>Click <a href="">this link</a> to get a cookie that disables JavaScript. (not working yet)</li>'); } else { writeln(' <li>Uncheck the "Use JavaScript" option on your <a href="' . user_page_link($auth_zid) . 'settings">account settings page</a>.</li>'); } writeln('</ul>'); writeln('</div>'); writeln('</noscript>'); }
writeln(' <th>Date</th>'); writeln(' <th>Title</th>'); writeln(' <th>Submitter</th>'); writeln(' <th>Editor</th>'); writeln(' <th>Status</th>'); writeln(' </tr>'); for ($i = 0; $i < count($row); $i++) { if ($row[$i]["zid"] == "") { $author = 'Anonymous Coward'; } else { $author = '<a href="' . user_page_link($row[$i]["zid"]) . '">' . $row[$i]["zid"] . '</a>'; } if ($row[$i]["editor"] == "") { $editor = ''; } else { $editor = '<a href="' . user_page_link($row[$i]["editor"]) . '">' . $row[$i]["editor"] . '</a>'; } if ($row[$i]["sid"] > 0) { $status = '<a href="/story/' . $row[$i]["sid"] . '">Published</a>'; } else { if ($row[$i]["closed"] == 1) { $status = "Closed (" . ($row[$i]["reason"] == "" ? "no reason" : $row[$i]["reason"]) . ")"; } else { $status = "Voting"; } } writeln(' <tr>'); writeln(' <td style="white-space: nowrap">' . date("Y-m-d H:i", $row[$i]["time"]) . '</td>'); writeln(' <td><a href="/pipe/' . $row[$i]["pid"] . '">' . $row[$i]["title"] . '</a></td>'); writeln(' <td>' . $author . '</td>'); writeln(' <td>' . $editor . '</td>');
// (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 "feed.php"; print_header(); if ($user_page == "") { writeln('<table class="fill">'); writeln('<tr>'); writeln('<td class="left_col">'); print_left_bar("main", "feed"); writeln('</td>'); writeln('<td class="fill">'); } $zid = "bryan@{$server_name}"; print_feed_page($zid); if ($auth_zid == "") { writeln('<div style="text-align: center">This is a sample feed page. Login to create your own.</div>'); } else { writeln('<div style="text-align: center">This is a sample feed page. <a href="' . user_page_link($auth_zid) . 'feed/edit">Create</a> your own <a href="' . user_page_link($auth_zid) . '">homepage</a>.</div>'); } writeln(' </td>'); writeln(' </tr>'); writeln('</table>'); print_footer();
writeln('<div class="right_bar">'); writeln('<div class="dialog_title">Status</div>'); writeln('<div class="dialog_body">'); writeln(' <div class="pipe_status">' . $status . $reason . '</div>'); writeln('</div>'); if ($pipe["editor"] === "") { if ($auth_user["editor"]) { writeln('<div class="dialog_title">Editor</div>'); writeln('<div class="dialog_body">'); writeln(' <div class="pipe_editor"><a href="/pipe/' . $pid . '/publish">Publish</a> | <a href="/pipe/' . $pid . '/close">Close</a></div>'); writeln('</div>'); } } else { writeln('<div class="dialog_title">Editor</div>'); writeln('<div class="dialog_body">'); writeln(' <div class="pipe_editor"><a href="' . user_page_link($pipe["editor"]) . '"><b>' . $pipe["editor"] . '</b></a></div>'); writeln('</div>'); } writeln('</div>'); writeln('</td>'); writeln('</tr>'); writeln('<tr>'); writeln('<td style="vertical-align: top" colspan="2">'); if ($javascript_enabled) { render_sliders(0, $pid, 0); print_noscript(); } else { render_page(0, $pid, 0, false); } writeln('</td>'); writeln('</tr>');