Merge branch 'sti' of github.com:savetheinternet/Tinyboard into jamer
This commit is contained in:
commit
93c6012aee
|
@ -51,6 +51,7 @@
|
|||
define('ERR_INVALIDIMG','Invalid image.', true);
|
||||
define('ERR_FILESIZE', 'Maximum file size: %maxsz% bytes<br>Your file\'s size: %filesz% bytes', true);
|
||||
define('ERR_MAXSIZE', 'The file was too big.', true);
|
||||
define('ERR_INVALIDZIP', 'Invalid archive!', true);
|
||||
|
||||
// For resizing, max values
|
||||
define('THUMB_WIDTH', 200, true);
|
||||
|
@ -62,7 +63,11 @@
|
|||
define('MAX_WIDTH', 10000, true);
|
||||
define('MAX_HEIGHT', MAX_WIDTH, true);
|
||||
|
||||
define('ALLOW_ZIP', true, true);
|
||||
/* When you upload a ZIP as a file, all the images inside the archive
|
||||
* get dumped into the thread as replies.
|
||||
* Extremely beta and not recommended yet.
|
||||
*/
|
||||
define('ALLOW_ZIP', false, true);
|
||||
define('ZIP_IMAGE', 'src/zip.png', true);
|
||||
|
||||
|
||||
|
@ -85,6 +90,11 @@
|
|||
// The root directory, including the trailing slash, for Tinyboard.
|
||||
// examples: '/', '/board/', '/chan/'
|
||||
define('ROOT', '/', true);
|
||||
|
||||
// If for some reason the folders and static HTML index files aren't in the current working direcotry,
|
||||
// enter the directory path here. Otherwise, keep it false.
|
||||
define('ROOT_FILE', false);
|
||||
|
||||
define('POST_URL', ROOT . 'post.php', true);
|
||||
define('FILE_INDEX', 'index.html', true);
|
||||
define('FILE_PAGE', '%d.html', true);
|
||||
|
@ -100,11 +110,14 @@
|
|||
|
||||
define('BUTTON_NEWTOPIC', 'New Topic', true);
|
||||
define('BUTTON_REPLY', 'New Reply', true);
|
||||
|
||||
|
||||
define('ALWAYS_NOKO', false, true);
|
||||
|
||||
|
||||
define('URL_MATCH', '/^' . (@$_SERVER['HTTPS']?'https':'http').':\/\/'.$_SERVER['HTTP_HOST'] . '(' . preg_quote(ROOT, '/') . '|' . preg_quote(ROOT, '/') . '' . preg_quote(FILE_INDEX, '/') . '|' . preg_quote(ROOT, '/') . '' . str_replace('%d', '\d+', preg_quote(FILE_PAGE, '/')) . ')$/', true);
|
||||
|
||||
|
||||
if(ROOT_FILE) {
|
||||
chdir(ROOT_FILE);
|
||||
}
|
||||
if(!defined('IS_INSTALLATION')) {
|
||||
if(!file_exists(DIR_IMG)) @mkdir(DIR_IMG) or error("Couldn't create " . DIR_IMG . ". Install manually.", true);
|
||||
if(!file_exists(DIR_THUMB)) @mkdir(DIR_THUMB) or error("Couldn't create " . DIR_IMG . ". Install manually.", true);
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
|
||||
// File info
|
||||
if(!empty($this->file)) {
|
||||
$built .= '<p class="fileinfo">File: <a href="' . ROOT . $this->file .'">' . basename($this->file) . '</a> <span class="unimportant">(' .
|
||||
$built .= '<p class="fileinfo">File: <a href="' . ROOT . DIR_IMG . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
|
||||
// Filesize
|
||||
format_bytes($this->filesize) . ', ' .
|
||||
// File dimensions
|
||||
|
@ -94,7 +94,7 @@
|
|||
// Filename
|
||||
$built .= ', ' . $this->filename . ')</span></p>' .
|
||||
// Thumbnail
|
||||
'<a href="' . ROOT . $this->file.'"><img src="' . ROOT . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
|
||||
'<a href="' . ROOT . DIR_IMG . $this->file.'"><img src="' . ROOT . DIR_THUMB . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
|
||||
}
|
||||
|
||||
// Body
|
||||
|
@ -131,7 +131,7 @@
|
|||
|
||||
|
||||
public function build($index=false) {
|
||||
$built = '<p class="fileinfo">File: <a href="' . ROOT . $this->file .'">' . basename($this->file) . '</a> <span class="unimportant">(' .
|
||||
$built = '<p class="fileinfo">File: <a href="' . ROOT . DIR_IMG . $this->file .'">' . $this->file . '</a> <span class="unimportant">(' .
|
||||
// Filesize
|
||||
format_bytes($this->filesize) . ', ' .
|
||||
// File dimensions
|
||||
|
@ -144,7 +144,7 @@
|
|||
// Filename
|
||||
$built .= ', ' . $this->filename . ')</span></p>' .
|
||||
// Thumbnail
|
||||
'<a href="' . ROOT . $this->file.'"><img src="' . ROOT . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
|
||||
'<a href="' . ROOT . DIR_IMG . $this->file.'"><img src="' . ROOT . DIR_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 . '"':'') . '>';
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Instance Configuration
|
||||
* ----------------------
|
||||
|
@ -9,10 +10,13 @@
|
|||
|
||||
/*
|
||||
|
||||
define('MY_SERVER', 'localhost', true);
|
||||
define('MY_USER', '', true);
|
||||
define('MY_PASSWORD', '', true);
|
||||
define('MY_DATABASE', '', true);
|
||||
// Database stuff
|
||||
define('MY_SERVER', 'localhost');
|
||||
define('MY_USER', '');
|
||||
define('MY_PASSWORD', '');
|
||||
define('MY_DATABASE', '');
|
||||
|
||||
define('ROOT', '/');
|
||||
|
||||
// define('FOO', 'bar');
|
||||
*/
|
||||
|
|
17
post.php
17
post.php
|
@ -121,6 +121,13 @@
|
|||
if(!@move_uploaded_file($_FILES['file']['tmp_name'], $post['file'])) error(ERROR_NOMOVE);
|
||||
|
||||
if($post['zip']) {
|
||||
// Validate ZIP file
|
||||
if(is_resource($zip = zip_open($post['zip'])))
|
||||
// TODO: Check if it's not empty and has at least one (valid) image
|
||||
zip_close($zip);
|
||||
else
|
||||
error(ERR_INVALIDZIP);
|
||||
|
||||
$post['file'] = ZIP_IMAGE;
|
||||
$post['extension'] = strtolower(substr($post['file'], strrpos($post['file'], '.') + 1));
|
||||
}
|
||||
|
@ -173,6 +180,10 @@
|
|||
$post['thumbheight'] = $thumb['height'];
|
||||
}
|
||||
|
||||
// Remove DIR_* before inserting them into the database.
|
||||
$post['file'] = substr_replace($post['file'], '', 0, strlen(DIR_IMG));
|
||||
$post['thumb'] = substr_replace($post['thumb'], '', 0, strlen(DIR_THUMB));
|
||||
|
||||
// Todo: Validate some more, remove messy code, allow more specific configuration
|
||||
|
||||
// MySQLify
|
||||
|
@ -191,7 +202,6 @@
|
|||
|
||||
if(in_array($extension, $allowed_ext)) {
|
||||
if (zip_entry_open($zip, $entry, 'r')) {
|
||||
|
||||
// Fake post
|
||||
$dump_post = Array(
|
||||
'subject' => $post['subject'],
|
||||
|
@ -260,6 +270,10 @@
|
|||
$dump_post['thumbwidth'] = $thumb['width'];
|
||||
$dump_post['thumbheight'] = $thumb['height'];
|
||||
|
||||
// Remove DIR_* before inserting them into the database.
|
||||
$dump_post['file'] = substr_replace($dump_post['file'], '', 0, strlen(DIR_IMG));
|
||||
$dump_post['thumb'] = substr_replace($dump_post['thumb'], '', 0, strlen(DIR_THUMB));
|
||||
|
||||
// Create the post
|
||||
post($dump_post, false);
|
||||
}
|
||||
|
@ -297,7 +311,6 @@
|
|||
} else {
|
||||
if(!file_exists(FILE_INDEX)) {
|
||||
buildIndex();
|
||||
sql_close();
|
||||
}
|
||||
|
||||
header('Location: ' . ROOT . FILE_INDEX, true, 302);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<link rel="stylesheet" media="screen" href="{index}style.css"/>
|
||||
<title>{board[url]} - {board[name]}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
<script type="text/javascript" src="{index}main.js"></script>
|
||||
</head>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
<head>
|
||||
<link rel="stylesheet" media="screen" href="{index}style.css"/>
|
||||
<title>{title}</title>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>{title}</h1>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<link rel="stylesheet" media="screen" href="{index}style.css"/>
|
||||
<title>{board[url]} - {board[name]}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
<script type="text/javascript" src="{index}main.js"></script>
|
||||
</head>
|
||||
|
|
Loading…
Reference in New Issue