1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-24 15:40:12 +01:00

Signed-off-by: 8n-tech <8n-tech@users.noreply.github.com>

inc/functions.php
- Fixed issues with dio on windows machines.

inc/lib/Twig/Extensions/Extension/Tinyboard.php
- Added strict (int) typecasting to avoid critical errors in timestamp formatting.

index.php
- Fixed issue where opening index.php would whitepage.

static/nsfw.png
static/swf.png
- Added missing static files.
This commit is contained in:
8n-tech 2015-04-09 20:11:48 +10:00
parent 46cd77e813
commit ee7c624517
5 changed files with 27 additions and 19 deletions

View File

@ -628,41 +628,47 @@ function purge($uri) {
function file_write($path, $data, $simple = false, $skip_purge = false) { function file_write($path, $data, $simple = false, $skip_purge = false) {
global $config, $debug; global $config, $debug;
if (preg_match('/^remote:\/\/(.+)\:(.+)$/', $path, $m)) { if (preg_match('/^remote:\/\/(.+)\:(.+)$/', $path, $m)) {
if (isset($config['remote'][$m[1]])) { if (isset($config['remote'][$m[1]])) {
require_once 'inc/remote.php'; require_once 'inc/remote.php';
$remote = new Remote($config['remote'][$m[1]]); $remote = new Remote($config['remote'][$m[1]]);
$remote->write($data, $m[2]); $remote->write($data, $m[2]);
return; return;
} else { }
else {
error('Invalid remote server: ' . $m[1]); error('Invalid remote server: ' . $m[1]);
} }
} }
else {
if (!$fp = dio_open($path, O_WRONLY | O_CREAT, 0644)) // This will convert a local, relative path like "b/index.html" to a full path.
// dio_open does not work with relative paths on Windows machines.
$path = realpath(dirname($path)) . DIRECTORY_SEPARATOR . basename($path);
}
if (!$fp = dio_open( $path, O_WRONLY | O_CREAT | O_TRUNC, 0644)) {
error('Unable to open file for writing: ' . $path); error('Unable to open file for writing: ' . $path);
}
// File locking // File locking
if (dio_fcntl($fp, F_SETLKW, array('type' => F_WRLCK)) === -1) { if (function_exists("dio_fcntl") && dio_fcntl($fp, F_SETLKW, array('type' => F_WRLCK)) === -1) {
error('Unable to lock file: ' . $path); error('Unable to lock file: ' . $path);
} }
// Truncate file
if (!dio_truncate($fp, 0))
error('Unable to truncate file: ' . $path);
// Write data // Write data
if (($bytes = dio_write($fp, $data)) === false) if (($bytes = dio_write($fp, $data)) === false) {
error('Unable to write to file: ' . $path); error('Unable to write to file: ' . $path);
}
// Unlock // Unlock
dio_fcntl($fp, F_SETLK, array('type' => F_UNLCK)); if (function_exists("dio_fcntl")) {
dio_fcntl($fp, F_SETLK, array('type' => F_UNLCK));
}
// Close // Close
dio_close($fp); dio_close($fp);
/** /**
* Create gzipped file. * Create gzipped file.
* *

View File

@ -76,7 +76,7 @@ function twig_remove_whitespace_filter($data) {
} }
function twig_date_filter($date, $format) { function twig_date_filter($date, $format) {
return gmstrftime($format, $date); return gmstrftime($format, (int) $date);
} }
function twig_hasPermission_filter($mod, $permission, $board = null) { function twig_hasPermission_filter($mod, $permission, $board = null) {
@ -86,7 +86,7 @@ function twig_hasPermission_filter($mod, $permission, $board = null) {
function twig_extension_filter($value, $case_insensitive = true) { function twig_extension_filter($value, $case_insensitive = true) {
$ext = mb_substr($value, mb_strrpos($value, '.') + 1); $ext = mb_substr($value, mb_strrpos($value, '.') + 1);
if($case_insensitive) if($case_insensitive)
$ext = mb_strtolower($ext); $ext = mb_strtolower($ext);
return $ext; return $ext;
} }

View File

@ -9,3 +9,5 @@ if ($query) {
$index = Element("8chan/index.html", array("config" => $config, "newsplus" => $newsplus)); $index = Element("8chan/index.html", array("config" => $config, "newsplus" => $newsplus));
file_write('index.html', $index); file_write('index.html', $index);
echo $index;

BIN
static/nsfw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/sfw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB