Kill one more NULL bug.
Kill one more NULL bug.

File last commit:

e8561709c1cb
e18a8b6ee362
Show More
index.php
109 lines | 3.6 KiB | text/x-php | XmlPhpLexer
/ index.php
Add most necessary files for admin interface.
r1 <?php
require_once('include/admin.inc.php');
auth_redirect(); // Require logged in user to access this page.
function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
if ($diff <= 3600) {
$mins = round($diff / 60);
if ($mins <= 1) {
$mins = 1;
}
$since = sprintf( $mins == 1 ? '%s minute' : '%s minutes', $mins);
} elseif ($diff <= 86400) {
$hours = round($diff / 3600);
if ($hours <= 1) {
$hour = 1;
}
$since = sprintf( $hours == 1 ? '%s hour' : '%s hours', $hours);
} elseif($diff <= 604800 ) {
$days = round($diff / 86400);
if ($days <= 1) {
$days = 1;
}
$since = sprintf( $days == 1 ? '%s day' : '%s days', $days);
Clean up extraneous spaces at the ends of lines.
r8 } else {
Add most necessary files for admin interface.
r1 $weeks = round($diff / 604800);
if( $weeks <= 1) {
$weeks = 1;
}
$since = sprintf( $weeks == 1 ? '%s week' : '%s weeks', $weeks);
}
return $since;
}
adminhead();
adminmenu();
?>
<h2>Scratchpad</h2>
<form method="post" action="post-scratchpad.php">
<?php nonce_field('new-scratchpad'); ?>
<ul class="historic">
<?php
Finish (I think) refactoring to use DBAL.
r36 $strips = array_reverse( $dbConnection->fetchAll('SELECT UNIX_TIMESTAMP(s.published) AS pubdate, c.name, s.message FROM scratchpad s JOIN contributor c ON s.contributor = c.id ORDER BY published DESC LIMIT 5') );
Add most necessary files for admin interface.
r1
foreach($strips as $k=>$v)
{
$message = preg_replace('/(https?\:\/\/[^"\s\<\>]*[^.,;\'">\:\s\<\>\)\]\!])/i',
'<a href="$1">$1</a>', htmlentities($v->message));
printf( '<li>%s wrote %s ago: %s</li>', htmlspecialchars($v->name), human_time_diff($v->pubdate), $message);
}
?>
</ul>
<p style="padding-bottom:1em;"><input type="text" name="message" /><input type="submit" value="Send" /></p>
Clean up extraneous spaces at the ends of lines.
r8
Add most necessary files for admin interface.
r1 </form><br>
<h2>Recent Strips</h2>
<ul class="historic">
<?php
Fix up style images and a couple of typos.
r37 $strips = $dbConnection->fetchAll('SELECT id, title, UNIX_TIMESTAMP(published) as date FROM strip WHERE published <= NOW() order by id DESC LIMIT 5');
Add most necessary files for admin interface.
r1
foreach($strips as $k=>$v) {
printf( '<li>%d: <a href="%s/index.php?strip_id=%d">%s</a>, %s ago</li>', $v->id, SITE_HOST . SITE_PATH, $v->id, htmlspecialchars($v->title), human_time_diff($v->date) );
}
?>
</ul><br>
<h2>Upcoming Strips</h2>
<ul class="historic">
<?php
Fix up style images and a couple of typos.
r37 $strips = $dbConnection->fetchAll('SELECT id, title, UNIX_TIMESTAMP(published) as date FROM strip WHERE published > NOW() order by id ASC LIMIT 5');
Add most necessary files for admin interface.
r1
foreach($strips as $k=>$v) {
printf( '<li>%d: <a href="%s/edit-comic.php?strip_id=%d">%s</a>, in %s</li>', $v->id, SITE_HOST . SITE_PATH . '/' . SITE_ADMIN, $v->id, htmlspecialchars($v->title), human_time_diff($v->date) );
}
?>
</ul><br>
<h2>Recent Published Rants</h2>
<ul class="historic">
<?php
Fix up style images and a couple of typos.
r37 $rants = $dbConnection->fetchAll('SELECT rant.id,UNIX_TIMESTAMP(rant.published) as date,rant.title,contributor.name from rant,contributor where rant.author=contributor.id AND rant.status=\'published\' ORDER BY rant.published DESC limit 5');
Add most necessary files for admin interface.
r1
foreach($rants as $k=>$v) {
printf( '<li>%d: <a href="%s/index.php?rant_id=%d">%s</a> by %s, %s ago</li>', $v->id, SITE_HOST . SITE_PATH, $v->id, htmlspecialchars($v->title), htmlspecialchars($v->name), human_time_diff($v->date) );
}
?>
</ul><br>
<h2>Recent Draft Rants</h2>
<ul class="historic">
<?php
Fix up style images and a couple of typos.
r37 $rants = $dbConnection->fetchAll('SELECT rant.id,UNIX_TIMESTAMP(rant.published) as date,rant.title,contributor.name from rant,contributor where rant.author=contributor.id AND rant.status=\'draft\' ORDER BY rant.published DESC limit 5');
Add most necessary files for admin interface.
r1
foreach($rants as $k=>$v) {
printf( '<li>%d: <a href="%s/edit-rant.php?rant_id=%d">%s</a> by %s, %s ago</li>', $v->id, SITE_HOST . ADMIN_PATH, $v->id, htmlspecialchars($v->title), htmlspecialchars($v->name), human_time_diff($v->date) );
}
?>
</ul>
<?php
adminfooter();
?>