Browse Source

a bit of optimization

pull/40/head
Savetheinternet 13 years ago
parent
commit
d21e28f6f6
  1. 8
      inc/config.php
  2. 6
      inc/display.php
  3. 14
      inc/functions.php

8
inc/config.php

@ -206,13 +206,13 @@
// Maximum number of cites per post (protects against abuse) // Maximum number of cites per post (protects against abuse)
$config['max_cites'] = 45; $config['max_cites'] = 45;
// Maximum number of cross-board links/cites per post // Maximum number of cross-board links/cites per post
$config['max_cross'] = $config['max_cites']; $config['max_cross'] = &$config['max_cites'];
// Maximum image upload size in bytes // Maximum image upload size in bytes
$config['max_filesize'] = 10*1024*1024; // 10MB $config['max_filesize'] = 10*1024*1024; // 10MB
// Maximum image dimensions // Maximum image dimensions
$config['max_width'] = 10000; $config['max_width'] = 10000;
$config['max_height'] = $config['max_width']; // 1:1 $config['max_height'] = &$config['max_width']; // 1:1
// Reject a post if its image is already in active content // Reject a post if its image is already in active content
$config['image_reject_repost'] = true; $config['image_reject_repost'] = true;
/** /**
@ -392,11 +392,11 @@
// Show expired bans in the ban list (they are kept in cache until the culprit returns) // Show expired bans in the ban list (they are kept in cache until the culprit returns)
$config['mod']['view_banexpired'] = true; $config['mod']['view_banexpired'] = true;
// View ban for IP address // View ban for IP address
$config['mod']['view_ban'] = $config['mod']['view_banlist']; $config['mod']['view_ban'] = &$config['mod']['view_banlist'];
// View IP address notes // View IP address notes
$config['mod']['view_notes'] = JANITOR; $config['mod']['view_notes'] = JANITOR;
// Create notes // Create notes
$config['mod']['create_notes'] = $config['mod']['view_notes']; $config['mod']['create_notes'] = &$config['mod']['view_notes'];
// Remote notes // Remote notes
$config['mod']['remove_notes'] = ADMIN; $config['mod']['remove_notes'] = ADMIN;
// Create a new board // Create a new board

6
inc/display.php

@ -102,7 +102,7 @@
global $config; global $config;
if(!isset($len)) if(!isset($len))
$len = $config['mod']['snippet_length']; $len = &$config['mod']['snippet_length'];
// Replace line breaks with some whitespace // Replace line breaks with some whitespace
$body = str_replace('<br/>', ' ', $body); $body = str_replace('<br/>', ' ', $body);
@ -188,7 +188,7 @@
class Post { class Post {
public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $embed, $root=null, $mod=false) { public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $embed, $root=null, $mod=false) {
global $config; global $config;
if(!isset($root)) $root = $config['root']; if(!isset($root)) $root = &$config['root'];
$this->id = $id; $this->id = $id;
$this->thread = $thread; $this->thread = $thread;
@ -368,7 +368,7 @@
class Thread { class Thread {
public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $embed, $root=null, $mod=false, $hr=true) { public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $embed, $root=null, $mod=false, $hr=true) {
global $config; global $config;
if(!isset($root)) $root = $config['root']; if(!isset($root)) $root = &$config['root'];
$this->id = $id; $this->id = $id;
$this->subject = utf8tohtml($subject); $this->subject = utf8tohtml($subject);

14
inc/functions.php

@ -55,7 +55,7 @@
')$/i'; ')$/i';
if(!isset($config['cookies']['path'])) if(!isset($config['cookies']['path']))
$config['cookies']['path'] = $config['root']; $config['cookies']['path'] = &$config['root'];
if(!isset($config['dir']['static'])) if(!isset($config['dir']['static']))
$config['dir']['static'] = $config['root'] . 'static/'; $config['dir']['static'] = $config['root'] . 'static/';
@ -80,7 +80,7 @@
$config['uri_img'] = sprintf($config['uri_img'], $board['dir']); $config['uri_img'] = sprintf($config['uri_img'], $board['dir']);
if(!isset($config['uri_stylesheets'])) if(!isset($config['uri_stylesheets']))
$config['uri_stylesheets'] = $config['root']; $config['uri_stylesheets'] = &$config['root'];
if($config['root_file']) { if($config['root_file']) {
chdir($config['root_file']); chdir($config['root_file']);
@ -94,7 +94,7 @@
if($config['ipv6_ipv4'] && isset($_SERVER['REMOTE_ADDR'])) { if($config['ipv6_ipv4'] && isset($_SERVER['REMOTE_ADDR'])) {
// Keep the original address to properly comply with other board configurations // Keep the original address to properly comply with other board configurations
if(!isset($__ip)) if(!isset($__ip))
$__ip = $_SERVER['REMOTE_ADDR']; $__ip = &$_SERVER['REMOTE_ADDR'];
// ::ffff:0.0.0.0 // ::ffff:0.0.0.0
if(preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) if(preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m))
@ -156,7 +156,7 @@
$query = query("SELECT `value` AS `theme` FROM `theme_settings` WHERE `name` = 'theme'") or error(db_error()); $query = query("SELECT `value` AS `theme` FROM `theme_settings` WHERE `name` = 'theme'") or error(db_error());
if($theme = $query->fetch()) { if($theme = $query->fetch()) {
// A theme is installed // A theme is installed
$_theme = $theme['theme']; $_theme = &$theme['theme'];
$theme = loadThemeConfig($_theme); $theme = loadThemeConfig($_theme);
@ -227,8 +227,8 @@
} }
foreach($config['purge'] as &$purge) { foreach($config['purge'] as &$purge) {
$host = $purge[0]; $host = &$purge[0];
$port = $purge[1]; $port = &$purge[1];
$http_host = isset($purge[2]) ? $purge[2] : $_SERVER['HTTP_HOST']; $http_host = isset($purge[2]) ? $purge[2] : $_SERVER['HTTP_HOST'];
$request = "PURGE {$uri} HTTP/1.0\r\nHost: {$http_host}\r\nUser-Agent: Tinyboard\r\nConnection: Close\r\n\r\n"; $request = "PURGE {$uri} HTTP/1.0\r\nHost: {$http_host}\r\nUser-Agent: Tinyboard\r\nConnection: Close\r\n\r\n";
if($fp = fsockopen($host, $port, $errno, $errstr, $config['purge_timeout'])) { if($fp = fsockopen($host, $port, $errno, $errstr, $config['purge_timeout'])) {
@ -647,7 +647,7 @@
file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id'])); file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id']));
} elseif($query->rowCount() == 1) { } elseif($query->rowCount() == 1) {
// Rebuild thread // Rebuild thread
$rebuild = $post['thread']; $rebuild = &$post['thread'];
} }
if($post['thumb']) { if($post['thumb']) {
// Delete thumbnail // Delete thumbnail

Loading…
Cancel
Save