summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-05-18 17:05:48 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-05-18 17:05:48 +1000
commit797fd8ad131e909d4dcc436e6bfa73921d8ea1dd (patch)
tree4df0b8444831715bf650e632e67c8a2e8cabf938 /inc
parent88a48c10d5ac16412ee046837f54a71c6e519a81 (diff)
Embedding field
Diffstat (limited to 'inc')
-rw-r--r--inc/config.php16
-rw-r--r--inc/display.php93
-rw-r--r--inc/functions.php35
3 files changed, 80 insertions, 64 deletions
diff --git a/inc/config.php b/inc/config.php
index 721d0974..78941116 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -491,7 +491,8 @@
'password',
'sticky',
'lock',
- 'raw'
+ 'raw',
+ 'embed'
);
// Custom flood filters. Detect flood attacks and reject new posts if there's a positive match.
@@ -583,16 +584,21 @@
// Characters used to generate a random password (with Javascript)
$config['genpassword_chars'] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+';
+ // Enable embedding (see below)
+ $config['enable_enbedding'] = false;
+
// Custom embedding (YouTube, vimeo, etc.)
+ // It's very important that you match the full string (with ^ and $) or things will not work correctly.
$config['embedding'] = Array(
Array(
- '/^https?:\/\/(\w+\.)?youtube\.com\/watch\?v=([a-zA-Z0-9-]{10,11})(&|$)/i',
- '<iframe width="%%tb_width%%" height="%%tb_height%%" src="http://www.youtube.com/embed/$2" frameborder="0" allowfullscreen></iframe>'
+ '/^https?:\/\/(\w+\.)?youtube\.com\/watch\?v=([a-zA-Z0-9-]{10,11})(&.+)?$/i',
+ // '<iframe width="%%tb_width%%" height="%%tb_height%%" src="http://www.youtube.com/embed/$2" frameborder="0" allowfullscreen></iframe>',
+ '<object style="float: left;margin: 10px 20px;" width="%%tb_width%%" height="%%tb_height%%"><param name="movie" value="http://www.youtube.com/v/$2?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-EBs2Os9ZXw?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" width="%%tb_width%%" height="%%tb_height%%" allowscriptaccess="always" allowfullscreen="true"></embed></object>'
)
);
// Embedding width and height
- $config['embed_width'] = 200;
- $config['embed_height'] = 164;
+ $config['embed_width'] = 300;
+ $config['embed_height'] = 246;
// Enable IP range bans (eg. "127.*.0.1", "127.0.0.*", and "12*.0.0.1" all match "127.0.0.1").
diff --git a/inc/display.php b/inc/display.php
index 2f0c15a2..7ec95ef3 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -186,7 +186,7 @@
}
class Post {
- public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $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;
if(!isset($root)) $root = $config['root'];
@@ -208,6 +208,7 @@
$this->filesize = $filesize;
$this->filename = $filename;
$this->ip = $ip;
+ $this->embed = $embed;
$this->root = $root;
$this->mod = $mod;
@@ -312,28 +313,33 @@
// JavaScript cite
'<a class="post_no"' . ($index?'':' onclick="citeReply(' . $this->id . ');"') . ' href="' . ($index ? $this->link('q') : 'javascript:void(0);') . '">'.$this->id.'</a>' .
'</p>';
-
- // File info
- if(!empty($this->file) && $this->file != 'deleted') {
+
+ if($this->embed) {
+ // Embedded video (or something else; doesn't have to be a video really)
+ $built .=
+ // Actual embedding
+ $this->embed;
+ } elseif(!empty($this->file) && $this->file != 'deleted') {
+ // File info
$built .= '<p class="fileinfo">File: <a href="' . $config['uri_img'] . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
- // Filesize
- format_bytes($this->filesize) .
- // File dimensions
- ($this->filex && $this->filey ?
- ', ' . $this->filex . 'x' . $this->filey
- : '' );
- // Aspect Ratio
- if($config['show_ratio'] && $this->filex && $this->filey) {
- $fraction = fraction($this->filex, $this->filey, ':');
- $built .= ', ' . $fraction;
- }
- // Filename
- $built .= ', ' . $this->filename . ')</span></p>' .
-
- // Thumbnail
- '<a href="' . $config['uri_img'] . $this->file.'"><img src="' . $config['uri_thumb'] . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
- } elseif($this->file == 'deleted') {
- $built .= '<img src="' . $config['image_deleted'] . '" />';
+ // Filesize
+ format_bytes($this->filesize) .
+ // File dimensions
+ ($this->filex && $this->filey ?
+ ', ' . $this->filex . 'x' . $this->filey
+ : '' );
+ // Aspect Ratio
+ if($config['show_ratio'] && $this->filex && $this->filey) {
+ $fraction = fraction($this->filex, $this->filey, ':');
+ $built .= ', ' . $fraction;
+ }
+ // Filename
+ $built .= ', ' . $this->filename . ')</span></p>' .
+
+ // Thumbnail
+ '<a href="' . $config['uri_img'] . $this->file.'"><img src="' . $config['uri_thumb'] . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
+ } elseif($this->file == 'deleted') {
+ $built .= '<img src="' . $config['image_deleted'] . '" />';
}
$built .= $this->postControls();
@@ -346,7 +352,7 @@
};
class Thread {
- public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $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;
if(!isset($root)) $root = $config['root'];
@@ -372,6 +378,7 @@
$this->ip = $ip;
$this->sticky = $sticky;
$this->locked = $locked;
+ $this->embed = $embed;
$this->root = $root;
$this->mod = $mod;
$this->hr = $hr;
@@ -440,22 +447,32 @@
public function build($index=false) {
global $board, $config;
- $built = '<p class="fileinfo">File: <a href="' . $config['uri_img'] . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
- // Filesize
- format_bytes($this->filesize) .
- // File dimensions
- ($this->filex && $this->filey ?
- ', ' . $this->filex . 'x' . $this->filey
- : '' );
- // Aspect Ratio
- if($config['show_ratio'] && $this->filex && $this->filey) {
- $fraction = fraction($this->filex, $this->filey, ':');
- $built .= ', ' . $fraction;
+ if($this->embed) {
+ // Embedded video (or something else; doesn't have to be a video really)
+ $built =
+ // Actual embedding
+ $this->embed;
+ } else {
+ // Image, not embedded shit
+ $built =
+ // File link
+ '<p class="fileinfo">File: <a href="' . $config['uri_img'] . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
+ // Filesize
+ format_bytes($this->filesize) .
+ // File dimensions
+ ($this->filex && $this->filey ?
+ ', ' . $this->filex . 'x' . $this->filey
+ : '' );
+ // Aspect Ratio
+ if($config['show_ratio'] && $this->filex && $this->filey) {
+ $fraction = fraction($this->filex, $this->filey, ':');
+ $built .= ', ' . $fraction;
+ }
+ // Filename
+ $built .= ', ' . $this->filename . ')</span></p>' .
+ // Thumbnail
+ '<a href="' . $config['uri_img'] . $this->file.'"><img src="' . $config['uri_thumb'] . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
}
- // Filename
- $built .= ', ' . $this->filename . ')</span></p>' .
- // Thumbnail
- '<a href="' . $config['uri_img'] . $this->file.'"><img src="' . $config['uri_thumb'] . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
$built .= '<div class="post op"><p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>';
diff --git a/inc/functions.php b/inc/functions.php
index c23168d9..a2ea8168 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -94,18 +94,6 @@
if($config['memcached']['enabled'])
memcached_open();
-
- // Test custom fields and stuff
- if(isset($config['fields'])) {
- $error_func = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet';
-
- foreach($config['fields'] as $index => $field) {
- if(!is_array($field))
- $error_func(sprintf("Error parsing custom fields. Field at index %d is not an array!", $index));
- if(!isset($field['name']))
- $error_func(sprintf("Error parsing custom fields. Field at index %d doesn't have a name!", $index));
- }
- }
}
function basic_error_function_because_the_other_isnt_loaded_yet($message) {
@@ -428,8 +416,7 @@
function post($post, $OP) {
global $pdo, $board;
-
- $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :time, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked)", $board['uri']));
+ $query = prepare(sprintf("INSERT INTO `posts_%s` VALUES ( NULL, :thread, :subject, :email, :name, :trip, :capcode, :body, :time, :time, :thumb, :thumbwidth, :thumbheight, :file, :width, :height, :filesize, :filename, :filehash, :password, :ip, :sticky, :locked, :embed)", $board['uri']));
// Basic stuff
$query->bindValue(':subject', $post['subject']);
@@ -459,6 +446,12 @@
$query->bindValue(':capcode', NULL, PDO::PARAM_NULL);
}
+ if(!empty($post['embed'])) {
+ $query->bindValue(':embed', $post['embed']);
+ } else {
+ $query->bindValue(':embed', NULL, PDO::PARAM_NULL);
+ }
+
if($OP) {
// No parent thread, image
$query->bindValue(':thread', null, PDO::PARAM_NULL);
@@ -611,9 +604,9 @@
if($query->rowcount() < 1 && $page > 1) return false;
while($th = $query->fetch()) {
- $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['capcode'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $th['locked'], $mod ? '?/' : $config['root'], $mod);
+ $thread = new Thread($th['id'], $th['subject'], $th['email'], $th['name'], $th['trip'], $th['capcode'], $th['body'], $th['time'], $th['thumb'], $th['thumbwidth'], $th['thumbheight'], $th['file'], $th['filewidth'], $th['fileheight'], $th['filesize'], $th['filename'], $th['ip'], $th['sticky'], $th['locked'], $th['embed'], $mod ? '?/' : $config['root'], $mod);
- $posts = prepare(sprintf("SELECT `id`, `subject`, `email`, `name`, `trip`, `capcode`, `body`, `time`, `thumb`, `thumbwidth`, `thumbheight`, `file`, `filewidth`, `fileheight`, `filesize`, `filename`,`ip` FROM `posts_%s` WHERE `thread` = ? ORDER BY `id` DESC LIMIT ?", $board['uri']));
+ $posts = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `thread` = ? ORDER BY `id` DESC LIMIT ?", $board['uri']));
$posts->bindValue(1, $th['id']);
$posts->bindValue(2, ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']), PDO::PARAM_INT);
$posts->execute() or error(db_error($posts));
@@ -623,7 +616,7 @@
if($po['file'])
$num_images++;
- $thread->add(new Post($po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['capcode'], $po['body'], $po['time'], $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], $po['filename'], $po['ip'], $mod ? '?/' : $config['root'], $mod));
+ $thread->add(new Post($po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['capcode'], $po['body'], $po['time'], $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], $po['filename'], $po['ip'], $po['embed'], $mod ? '?/' : $config['root'], $mod));
}
if($posts->rowCount() == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
@@ -962,7 +955,7 @@
while($page <= $config['max_pages'] && $content = index($page)) {
$filename = $board['dir'] . ($page==1 ? $config['file_index'] : sprintf($config['file_page'], $page));
if(file_exists($filename)) $md5 = md5_file($filename);
-
+
$content['pages'] = $pages;
$content['pages'][$page-1]['selected'] = true;
$content['btn'] = getPageButtons($content['pages']);
@@ -1231,15 +1224,15 @@
global $board, $config;
$id = round($id);
- $query = prepare(sprintf("SELECT `id`,`thread`,`subject`,`name`,`email`,`trip`,`capcode`,`body`,`time`,`thumb`,`thumbwidth`,`thumbheight`,`file`,`filewidth`,`fileheight`,`filesize`,`filename`,`ip`,`sticky`,`locked` FROM `posts_%s` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`time`", $board['uri']));
+ $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`time`", $board['uri']));
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
while($post = $query->fetch()) {
if(!isset($thread)) {
- $thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $mod ? '?/' : $config['root'], $mod);
+ $thread = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], $mod ? '?/' : $config['root'], $mod);
} else {
- $thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $mod ? '?/' : $config['root'], $mod));
+ $thread->add(new Post($post['id'], $thread->id, $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], $mod ? '?/' : $config['root'], $mod));
}
}