15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
# This is an IVLE application.
23
# A SMF forum application for IVLE.
18
# Author: David Coles, Will Grant
30
from ivle import interpret
34
Handler for the Forum application.
36
This application implements a general purpose PHP CGI loader
41
forum_base = "php/phpBB3"
43
# Set request attributes
45
req.styles = ["media/forum/forum.css"]
47
# Process URL for special directives
48
url = urlparse.urlparse(req.path)
49
hierarchical_part = url[2]
51
forum_page = "" # use the default forum page
54
board = re.match('board/(.*?)(/|$)',hierarchical_part)
56
framequery += 'f=' + board.group(1) + "&"
57
forum_page = "viewforum.php"
59
topic = re.search('topic/(.*?)(/|$)',hierarchical_part)
61
framequery += 't=' + topic.group(1)
62
forum_page = "viewtopic.php"
64
# If the tail of the forum url is empty or a known special request
65
# then wrap the page in the headers and footer and load the default or
66
# special page in the ivlebody frame
69
location = forum_page + framequery
71
frameurl = util.make_path(os.path.join(forum_base,location))
72
req.content_type = "text/html"
73
req.write_html_head_foot = True
74
req.write('<object class="fullscreen" type="text/html" data="%s">'%
75
(frameurl + framequery))
25
from urllib import quote
27
from ivle.webapp.base.xhtml import XHTMLView
28
from ivle.webapp.base.plugins import ViewPlugin, CookiePlugin, MediaPlugin
32
class ForumView(XHTMLView):
35
def __init__(self, req, path):
38
def populate(self, req, ctx):
39
self.plugin_styles[Plugin] = ['forum.css']
41
forum_base = "php/phpBB3"
43
ctx['url'] = ivle.util.make_path(os.path.join(forum_base, self.path))
45
class ForumBoardView(ForumView):
46
def __init__(self, req, board):
47
self.path = 'viewforum.php?f=' + board
49
class ForumTopicView(ForumView):
50
def __init__(self, req, topic):
51
self.path = 'viewtopic.php?t=' + topic
53
def make_forum_cookie(user):
54
secret = ivle.conf.forum_secret
56
login = quote(user.login)
57
nick = quote(user.nick)
59
if user.email != None:
60
email = quote(user.email)
62
role = quote(str(user.role))
64
hashtext = login + nick + email + role + secret
65
hash = hashlib.md5(hashtext).hexdigest()
66
data = quote(login + ':' + nick + ':' + email + ':' + role + ':' + hash)
70
class Plugin(ViewPlugin, CookiePlugin, MediaPlugin):
72
('forum', ForumView, {'path': ''}),
73
('forum/+board/:board', ForumBoardView),
74
('forum/+topic/:topic', ForumTopicView),
75
('forum/*path', ForumView),
78
cookies = {'ivleforumcookie': make_forum_cookie}