More small changes to help save a few microseconds.

This commit is contained in:
green-ponies (jgen) 2012-01-12 15:46:34 -05:00
parent d7ff1b96ab
commit fc12bbbfe5
4 changed files with 71 additions and 71 deletions

View File

@ -225,8 +225,8 @@ class Page {
print $this->data;
break;
case "redirect":
header("Location: {$this->redirect}");
print "You should be redirected to <a href='{$this->redirect}'>{$this->redirect}</a>";
header('Location: '.$this->redirect);
print 'You should be redirected to <a href="'.$this->redirect'">'.$this->redirect.'</a>';
break;
default:
print "Invalid page mode";

View File

@ -384,7 +384,7 @@ function _count_execs($db, $sql, $inputarray) {
if(DEBUG) {
$fp = @fopen("data/sql.log", "a");
if($fp) {
if(is_array($inputarray)) {
if(isset($inputarray) && is_array($inputarray)) {
fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)." -- ".join(", ", $inputarray)."\n");
}
else {

View File

@ -21,12 +21,12 @@ class CommentListTheme extends Themelet {
$next = $page_number + 1;
$h_prev = ($page_number <= 1) ? "Prev" :
"<a href='".make_link("comment/list/$prev")."'>Prev</a>";
'<a href="'.make_link('comment/list/'.$prev).'">Prev</a>';
$h_index = "<a href='".make_link()."'>Index</a>";
$h_next = ($page_number >= $total_pages) ? "Next" :
"<a href='".make_link("comment/list/$next")."'>Next</a>";
'<a href="'.make_link('comment/list/'.$next).'">Next</a>';
$nav = "$h_prev | $h_index | $h_next";
$nav = $h_prev.' | '.$h_index.' | '.$h_next;
$page->set_title("Comments");
$page->set_heading("Comments");
@ -46,7 +46,7 @@ class CommentListTheme extends Themelet {
$comment_count = count($comments);
if($comment_limit > 0 && $comment_count > $comment_limit) {
$hidden = $comment_count - $comment_limit;
$comment_html .= "<p>showing $comment_limit of $comment_count comments</p>";
$comment_html .= '<p>showing '.$comment_limit.' of '.$comment_count.' comments</p>';
$comments = array_slice($comments, -$comment_limit);
}
$this->anon_id = 1;
@ -68,14 +68,14 @@ class CommentListTheme extends Themelet {
}
}
$html = "
<table class='comment_list_table'><tr>
<td>$thumb_html</td>
<td>$comment_html</td>
$html = '
<table class="comment_list_table"><tr>
<td>'.$thumb_html.'</td>
<td>'.$comment_html.'</td>
</tr></table>
";
';
$page->add_block(new Block("{$image->id}: ".($image->get_tag_list()), $html, "main", $position++));
$page->add_block(new Block( $image->id.': '.$image->get_tag_list(), $html, "main", $position++));
}
}
@ -154,23 +154,23 @@ class CommentListTheme extends Themelet {
$anoncode = "";
if($h_name == "Anonymous" && $this->anon_id >= 0) {
$anoncode = "<sup>{$this->anon_id}</sup>";
$anoncode = '<sup>'.$this->anon_id.'</sup>';
$this->anon_id++;
}
$h_userlink = "<a href='".make_link("user/$h_name")."'>$h_name</a>$anoncode";
$h_userlink = '<a href="'.make_link('user/'.$h_name).'">'.$h_name.'</a>'.$anoncode;
$stripped_nonl = str_replace("\n", "\\n", substr($tfe->stripped, 0, 50));
$stripped_nonl = str_replace("\r", "\\r", $stripped_nonl);
$h_dellink = $user->is_admin() ?
"<br>($h_poster_ip, $h_timestamp, <a ".
"onclick=\"return confirm('Delete comment by $h_name:\\n$stripped_nonl');\" ".
"href='".make_link("comment/delete/$i_comment_id/$i_image_id")."'>Del</a>)" : "";
'<br>('.$h_poster_ip.', '.$h_timestamp.', <a '.
'onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '.
'href="'.make_link('comment/delete/'.$i_comment_id.'/'.$i_image_id).'">Del</a>)' : '';
if($trim) {
return "
$h_userlink: $h_comment
<a href='".make_link("post/view/$i_image_id")."'>&gt;&gt;&gt;</a>
$h_dellink
";
return '
'.$h_userlink.': '.$h_comment.'
<a href="'.make_link('post/view/'.$i_image_id).'">&gt;&gt;&gt;</a>
'.$h_dellink.'
';
}
else {
//$avatar = "";
@ -179,14 +179,14 @@ class CommentListTheme extends Themelet {
// $avatar = "<img src=\"http://www.gravatar.com/avatar/$hash.jpg\"><br>";
//}
$oe = ($this->comments_shown++ % 2 == 0) ? "even" : "odd";
return "
<a name='$i_comment_id'></a>
<div class='$oe comment'>
<!--<span class='timeago' style='float: right;'>$h_timestamp</span>-->
$h_userlink: $h_comment
$h_dellink
return '
<a name="'.$i_comment_id.'"></a>
<div class="'.$oe.' comment">
<!--<span class="timeago" style="float: right;">'.$h_timestamp.'</span>-->
'.$h_userlink.': '.$h_comment.'
'.$h_dellink.'
</div>
";
';
}
}
@ -197,15 +197,15 @@ class CommentListTheme extends Themelet {
$hash = CommentList::get_hash();
$captcha = $config->get_bool("comment_captcha") ? captcha_get_html() : "";
return "
".make_form(make_link("comment/add"))."
<input type='hidden' name='image_id' value='$i_image_id' />
<input type='hidden' name='hash' value='$hash' />
<textarea name='comment' rows='5' cols='50'></textarea>
$captcha
<br><input type='submit' value='Post Comment' />
return '
'.make_form(make_link("comment/add")).'
<input type="hidden" name="image_id" value="'.$i_image_id.'" />
<input type="hidden" name="hash" value="'.$hash.'" />
<textarea name="comment" rows="5" cols="50"></textarea>
'.$captcha.'
<br><input type="submit" value="Post Comment" />
</form>
";
';
}
}
?>

View File

@ -30,9 +30,9 @@ class UserPageTheme extends Themelet {
public function display_user_block(Page $page, User $user, $parts) {
$h_name = html_escape($user->name);
$html = "Logged in as $h_name";
$html = 'Logged in as '.$h_name;
foreach($parts as $part) {
$html .= "<br><a href='{$part["link"]}'>{$part["name"]}</a>";
$html .= '<br><a href="'.$part["link"].'">'.$part["name"].'</a>';
}
$page->add_block(new Block("User Links", $html, "left", 90));
}
@ -48,12 +48,12 @@ class UserPageTheme extends Themelet {
}
if(empty($tac)) {$html = "";}
else {$html = "<p>$tac</p>";}
else {$html = '<p>'.$tac.'</p>';}
$reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>";
$html .= "
".make_form(make_link("user_admin/create"))."
$html .= '
'.make_form(make_link("user_admin/create"))."
<table style='width: 300px;'>
<tr><td>Name</td><td><input type='text' name='name'></td></tr>
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
@ -81,8 +81,8 @@ class UserPageTheme extends Themelet {
public function display_login_block(Page $page) {
global $config;
$html = "
".make_form(make_link("user_admin/login"))."
$html = '
'.make_form(make_link("user_admin/login"))."
<table summary='Login Form'>
<tr>
<td width='70'><label for='user'>Name</label></td>
@ -107,7 +107,7 @@ class UserPageTheme extends Themelet {
$html .= "<tr><td>Uploaded from: ";
$n = 0;
foreach($uploads as $ip => $count) {
$html .= "<br>$ip ($count)";
$html .= '<br>'.$ip.' ('.$count.')';
if(++$n >= 20) {
$html .= "<br>...";
break;
@ -117,7 +117,7 @@ class UserPageTheme extends Themelet {
$html .= "</td><td>Commented from:";
$n = 0;
foreach($comments as $ip => $count) {
$html .= "<br>$ip ($count)";
$html .= '<br>'.$ip.' ('.$count.')';
if(++$n >= 20) {
$html .= "<br>...";
break;
@ -133,10 +133,10 @@ class UserPageTheme extends Themelet {
public function display_user_page(User $duser, $stats) {
global $page, $user;
assert(is_array($stats));
$stats[] = "User ID: {$duser->id}";
$stats[] = 'User ID: '.$duser->id;
$page->set_title("{$duser->name}'s Page");
$page->set_heading("{$duser->name}'s Page");
$page->set_title($duser->name."'s Page");
$page->set_heading($duser->name."'s Page");
$page->add_block(new NavBlock());
$page->add_block(new Block("Stats", join("<br>", $stats), "main", 0));
@ -150,37 +150,37 @@ class UserPageTheme extends Themelet {
protected function build_options(User $duser) {
global $config, $database, $user;
$html = "
".make_form(make_link("user_admin/change_pass"))."
<input type='hidden' name='id' value='{$duser->id}'>
<table style='width: 300px;'>
<tr><th colspan='2'>Change Password</th></tr>
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
$html = '
'.make_form(make_link("user_admin/change_pass")).'
<input type="hidden" name="id" value="'.$duser->id.'">
<table style="width: 300px;">
<tr><th colspan="2">Change Password</th></tr>
<tr><td>Password</td><td><input type="password" name="pass1"></td></tr>
<tr><td>Repeat Password</td><td><input type="password" name="pass2"></td></tr>
<tr><td colspan="2"><input type="Submit" value="Change Password"></td></tr>
</table>
</form>
<p>".make_form(make_link("user_admin/change_email"))."
<input type='hidden' name='id' value='{$duser->id}'>
<table style='width: 300px;'>
<tr><th colspan='2'>Change Email</th></tr>
<tr><td>Address</td><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr>
<tr><td colspan='2'><input type='Submit' value='Set'></td></tr>
<p>'.make_form(make_link("user_admin/change_email")).'
<input type="hidden" name="id" value="'.$duser->id.'">
<table style="width: 300px;">
<tr><th colspan="2">Change Email</th></tr>
<tr><td>Address</td><td><input type="text" name="address" value="'.html_escape($duser->email).'"></td></tr>
<tr><td colspan="2"><input type="Submit" value="Set"></td></tr>
</table>
</form>
";
';
if($user->is_admin()) {
$i_user_id = int_escape($duser->id);
$h_is_admin = $duser->is_admin() ? " checked" : "";
$html .= "
<p>".make_form(make_link("user_admin/set_more"))."
<input type='hidden' name='id' value='$i_user_id'>
Admin: <input name='admin' type='checkbox'$h_is_admin>
<input type='submit' value='Set'>
$html .= '
<p>'.make_form(make_link("user_admin/set_more")).'
<input type="hidden" name="id" value="'.$i_user_id.'">
Admin: <input name="admin" type="checkbox'.$h_is_admin.'">
<input type="submit" value="Set">
</form>
";
';
}
return $html;
}