From ee7c624517f52450a5959457b633143bb2c6174b Mon Sep 17 00:00:00 2001 From: 8n-tech <8n-tech@users.noreply.github.com> Date: Thu, 9 Apr 2015 20:11:48 +1000 Subject: [PATCH] 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. --- inc/functions.php | 40 ++++++++++-------- .../Twig/Extensions/Extension/Tinyboard.php | 4 +- index.php | 2 + static/nsfw.png | Bin 0 -> 1229 bytes static/sfw.png | Bin 0 -> 1232 bytes 5 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 static/nsfw.png create mode 100644 static/sfw.png diff --git a/inc/functions.php b/inc/functions.php index 480df77f..4a4969ae 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -628,41 +628,47 @@ function purge($uri) { function file_write($path, $data, $simple = false, $skip_purge = false) { global $config, $debug; - + if (preg_match('/^remote:\/\/(.+)\:(.+)$/', $path, $m)) { if (isset($config['remote'][$m[1]])) { require_once 'inc/remote.php'; - + $remote = new Remote($config['remote'][$m[1]]); $remote->write($data, $m[2]); return; - } else { + } + else { error('Invalid remote server: ' . $m[1]); } } - - if (!$fp = dio_open($path, O_WRONLY | O_CREAT, 0644)) + else { + // 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); - + } + // 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); } - - // Truncate file - if (!dio_truncate($fp, 0)) - error('Unable to truncate file: ' . $path); - + // Write data - if (($bytes = dio_write($fp, $data)) === false) + if (($bytes = dio_write($fp, $data)) === false) { error('Unable to write to file: ' . $path); - + } + // 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 dio_close($fp); - + /** * Create gzipped file. * diff --git a/inc/lib/Twig/Extensions/Extension/Tinyboard.php b/inc/lib/Twig/Extensions/Extension/Tinyboard.php index 1c5b8981..f41e0768 100644 --- a/inc/lib/Twig/Extensions/Extension/Tinyboard.php +++ b/inc/lib/Twig/Extensions/Extension/Tinyboard.php @@ -76,7 +76,7 @@ function twig_remove_whitespace_filter($data) { } function twig_date_filter($date, $format) { - return gmstrftime($format, $date); + return gmstrftime($format, (int) $date); } 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) { $ext = mb_substr($value, mb_strrpos($value, '.') + 1); if($case_insensitive) - $ext = mb_strtolower($ext); + $ext = mb_strtolower($ext); return $ext; } diff --git a/index.php b/index.php index 12fec902..a44b56e5 100644 --- a/index.php +++ b/index.php @@ -9,3 +9,5 @@ if ($query) { $index = Element("8chan/index.html", array("config" => $config, "newsplus" => $newsplus)); file_write('index.html', $index); + +echo $index; \ No newline at end of file diff --git a/static/nsfw.png b/static/nsfw.png new file mode 100644 index 0000000000000000000000000000000000000000..475868b30edf938de0994384f0e3b72ebea07f78 GIT binary patch literal 1229 zcmV;;1Ty=HP)4Tx05}naRo`#hR1`jmZ&IWdKOk5~hl<6oRa0BJ8yc;~21%2p?MfD<>DVeH z9(p*dx19w`~g7O0}n_%Aq@s%d)fBDv`JHkDym6Hd+5XuAtvnwRpGmK zVkc9?T=n|PIo~X-eVh__(Z?q}P9Z-Dj?gOW6|D%o20XmjW-qs4UjrD(li^iv8@eK9k+ZFm zVRFymFOPAzG5-%Pn|1W;U4vNroTa&AxDScmEA~{ri9gr1^c?U@uwSpaNnw8l_>cP1 zd;)kMQS_;jeRSUEM_*s96y65j1$)tOrwdK{YIQMt92l|D^(E_=$Rjw{b!QT@q!)ni zR`|5oW9X5n$Wv+HVc@|^eX5yXnsHX8PF3UX~a6)MwxDE0HaPjyrlI!;jX{6Kvuh*8ej?;85ekN$?5uuCiS zBTvvVG+XTxAO{m@bvM#Jr)z6J><&E22D|vq?Y?Vkbo_DijopiF$2PET#mZ8eu=y$(ArYkv7@Ex`GL?QCc!_*KFrd&;n1r7 zqW-CFs9&fT)ZaU5gc&=gBz-DaCw(vdOp0__x+47~U6sC(E(JNe@4cTT*n6*E zVH4eoU1-&7pEV~_PRe`a7v+@vy!^5}8?Y3)UmlaER0001FNkl6a>K@I>x1Y`gIXREWCbS5&1%Q{d( z6%VtpNDp(*EHNUi!>m<&RwD;iQVtC?#jI8Q2#(?;{fVGEaXW#JQSCZ3{=sEHcL2|R rK&29A1n2rq!9ce1^a}KW+TGw65pEz5;MfpB00000NkvXXu0mjf2PH|^ literal 0 HcmV?d00001 diff --git a/static/sfw.png b/static/sfw.png new file mode 100644 index 0000000000000000000000000000000000000000..e031f3c3f7772113a2c19b3b2b14981d23086bf0 GIT binary patch literal 1232 zcmV;>1TXuEP)4Tx05}naRo`#hR1`jmZ&IWdKOk5~hl<6oRa0BJ8yc;~21%2p?MfD<>DVeH z9(p*dx19w`~g7O0}n_%Aq@s%d)fBDv`JHkDym6Hd+5XuAtvnwRpGmK zVkc9?T=n|PIo~X-eVh__(Z?q}P9Z-Dj?gOW6|D%o20XmjW-qs4UjrD(li^iv8@eK9k+ZFm zVRFymFOPAzG5-%Pn|1W;U4vNroTa&AxDScmEA~{ri9gr1^c?U@uwSpaNnw8l_>cP1 zd;)kMQS_;jeRSUEM_*s96y65j1$)tOrwdK{YIQMt92l|D^(E_=$Rjw{b!QT@q!)ni zR`|5oW9X5n$Wv+HVc@|^eX5yXnsHX8PF3UX~a6)MwxDE0HaPjyrlI!;jX{6Kvuh*8ej?;85ekN$?5uuCiS zBTvvVG+XTxAO{m@bvM#Jr)z6J><&E22D|vq?Y?Vkbo_DijopiF$2PET#mZ8eu=y$(ArYkv7@Ex`GL?QCc!_*KFrd&;n1r7 zqW-CFs9&fT)ZaU5gc&=gBz-DaCw(vdOp0__x+47~U6sC(E(JNe@4cTT*n6*E zVH4eoU1-&7pEV~_PRe`a7v+@vy!^5}8?Y3)UmlaER0001INkl6C*TMmFQ2otmWUs+dYNk^F3H1Z+k z(XJudQDduNW=L0{#hN(FST2pyzPFaQV(kL~yWm&wUjg3X$y(