Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

v3. Added "page=last" support for threads

  • Loading branch information...
commit ca9d10bb68637fcfae69ed19b24c8ab37f041fbb 1 parent 87eb91f
Kroc Camen authored
4 HISTORY.txt
View
@@ -1,3 +1,7 @@
+v3 30.JUL.11
+ Links to threads now use "page=last"
+ "Users" folder now included in the download for simpler setup
+
v2 18.JUN.11
Ignore invalid XML files when generating index page / RSS
Prevent null filenames for threads with only non-ASCII titles
2  LICENCE.txt
View
@@ -1,4 +1,4 @@
-NoNonsense Forum v2 © Copyright CC-BY 3.0 Kroc Camen of Camen Design
+NoNonsense Forum v3 © Copyright CC-BY 3.0 Kroc Camen of Camen Design
====================================================================
The PHP / HTML / CSS and other resources of this project are licensed under a Creative Commons 3.0 Attribution Unported licence (unless otherwise stated), viewable here: http://creativecommons.org/licenses/by/3.0/deed.en_GB
2  README.txt
View
@@ -1,4 +1,4 @@
-NoNonsense Forum v2 © Copyright CC-BY 3.0 Kroc Camen of Camen Design
+NoNonsense Forum v3 © Copyright CC-BY 3.0 Kroc Camen of Camen Design
====================================================================
A simple forum that focuses on discussion and simplicity.
2  action.php
View
@@ -1,6 +1,6 @@
<?php //commit actions on posts, like delete, edit &c.
/* ====================================================================================================================== */
-/* NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+/* NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
2  config.example.php
View
@@ -1,6 +1,6 @@
<?php //configuration defaults
/* ====================================================================================================================== */
-/* NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+/* NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
9 index.php
View
@@ -1,12 +1,15 @@
<?php //display the index of threads in a folder
/* ====================================================================================================================== */
-/* NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+/* NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
require_once './shared.php';
+//get page number
+define ('PAGE', preg_match ('/^[1-9][0-9]*$/', @$_GET['page']) ? (int) $_GET['page'] : 1);
+
//submitted info for making a new thread
//(name / password already handled in 'shared.php')
define ('TITLE', mb_substr (trim (@$_POST['title']), 0, SIZE_TITLE, 'UTF-8'));
@@ -139,9 +142,7 @@
$THREADS[] = array (
'STICKY' => in_array ($file, $stickies),
//link to the thread--go to the last page of replies
- 'URL' => pathinfo ($file, PATHINFO_FILENAME).(count ($xml->channel->item) > FORUM_POSTS+1
- ? '?page='.ceil ((count ($xml->channel->item) - 1) / FORUM_POSTS) : ''
- ),
+ 'URL' => pathinfo ($file, PATHINFO_FILENAME).'?page=last',
'TITLE' => safeHTML ($xml->channel->title),
'COUNT' => count ($xml->channel->item) - 1,
'DATETIME' => date ('c', strtotime ($last->pubDate)), //HTML5 datetime attr
6 shared.php
View
@@ -1,6 +1,6 @@
<?php //reduce some duplication
/* ====================================================================================================================== */
-/* NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+/* NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
@@ -76,10 +76,6 @@
define ('AUTH', false);
}
-//whilst page number is not used everywhere (like 'action.php'), it does no harm to get it here because it can simply be
-//ignored on 'action.php' &c. whilst avoiding duplicated code on the scripts that do use it
-define ('PAGE', preg_match ('/^[1-9][0-9]*$/', @$_GET['page']) ? (int) $_GET['page'] : 1);
-
//all our pages use path (often optional) so this is done here
define ('PATH', preg_match ('/[^.\/&]+/', @$_GET['path']) ? $_GET['path'] : '');
//these two get used an awful lot
2  themes/greyscale/append.inc.php
View
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8" />
-<!-- NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+<!-- NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licensed under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com> -->
<title>Append to <?php echo $HEADER['TITLE']?></title>
2  themes/greyscale/delete.inc.php
View
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8" />
-<!-- NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+<!-- NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licensed under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com> -->
<title><?php echo $ID ? 'Delete Post?' : 'Delete Thread?'?> <?php echo $HEADER['TITLE']?></title>
2  themes/greyscale/index.inc.php
View
@@ -11,7 +11,7 @@
}
?><!DOCTYPE html>
<meta charset="utf-8" />
-<!-- NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+<!-- NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licensed under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com> -->
<title><?php echo (PATH ? PATH : safeHTML(FORUM_NAME)).(PAGE>1 ? ' # '.PAGE : '')?></title>
2  themes/greyscale/theme.css
View
@@ -1,4 +1,4 @@
-/* NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+/* NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com> */
/* ====================================================================================================================== */
4 themes/greyscale/thread.inc.php
View
@@ -11,7 +11,7 @@
}
?><!DOCTYPE html>
<meta charset="utf-8" />
-<!-- NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+<!-- NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licensed under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com> -->
<title><?php echo $HEADER['TITLE'].(PAGE>1 ? ' # '.PAGE : '')?></title>
@@ -77,7 +77,7 @@
<?php if (!$POST['DELETED']): ?><a class="ui append" rel="noindex nofollow" href="<?php echo $POST['APPEND_URL']?>">append</a>
<a class="ui delete" rel="noindex nofollow" href="<?php echo $POST['DELETE_URL']?>">delete</a><?php endif;?>
<time datetime="<?php echo $POST['DATETIME']?>" pubdate><?php echo $POST['TIME']?></time>
- <a href="#<?php echo $POST['ID']?>">#<?php echo $POST['NO']?>.</a>
+ <a href="?page=<?php echo PAGE?>#<?php echo $POST['ID']?>">#<?php echo $POST['NO']?>.</a>
<b<?php echo $POST['MOD']?' class="mod"':''?>><?php echo $POST['AUTHOR']?></b>
</header>
10 thread.php
View
@@ -1,6 +1,6 @@
<?php //display a particular thread’s contents
/* ====================================================================================================================== */
-/* NoNonsense Forum v2 © Copyright (CC-BY) Kroc Camen 2011
+/* NoNonsense Forum v3 © Copyright (CC-BY) Kroc Camen 2011
licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
*/
@@ -29,6 +29,7 @@
formatText (TEXT) == $xml->channel->item[0]->description
)) {
//where to?
+ //(we won’t use `page=last` here as we are effecitvely handing the user a permalink here)
$page = ceil (count ($xml->channel->item) / FORUM_POSTS);
$url = FORUM_URL.PATH_URL.$FILE.($page > 1 ? "?page=$page" : '').'#'.base_convert (microtime (), 10, 36);
@@ -97,6 +98,13 @@
/* replies
---------------------------------------------------------------------------------------------------------------------- */
+//determine the page number (for threads the page number can be given as "last")
+define ('PAGE',
+ @$_GET['page'] == 'last'
+ ? ceil (count ($thread) / FORUM_POSTS)
+ : (preg_match ('/^[1-9][0-9]*$/', @$_GET['page']) ? (int) $_GET['page'] : 1)
+);
+
if (count ($thread)) {
//sort the other way around
//<stackoverflow.com/questions/2119686/sorting-an-array-of-simplexml-objects/2120569#2120569>
Please sign in to comment.
Something went wrong with that request. Please try again.