Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 8
- Log:
Updated to HEAD revision from SVN repository for 22-Jul-2006 at
about 6:30pm.
- Author:
- adh
- Date:
- Sat Jul 22 19:30:50 +0100 2006
- Size:
- 3791 Bytes
1 | require 'navbar' |
2 | require 'post_menu' |
3 | require 'url_generator' |
4 | |
5 | # The filters added to this controller will be run for all controllers in the application. |
6 | # Likewise will all the methods added be available for all controllers. |
7 | class ApplicationController < ActionController::Base |
8 | model :forum, :post, :topic, :user |
9 | helper :application |
10 | |
11 | session :session_expires => Time.now + 1.years |
12 | |
13 | include RForum::Localization |
14 | |
15 | layout 'default' |
16 | before_filter :check_block, :setup_user, :setup_url_generator, :setup_local, \ |
17 | :setup_skin |
18 | |
19 | before_filter :detect_site if RForum::CONFIG[:use_sites] |
20 | |
21 | before_filter :get_forums |
22 | |
23 | after_filter :finish_user, :remember_location |
24 | |
25 | # Default index action: redirect to start page |
26 | def index |
27 | redirect_to :controller => 'forum', :action => 'list' |
28 | end |
29 | |
30 | protected |
31 | |
32 | def rescue_action(e) |
33 | if e.is_a?(RForum::SecurityError) |
34 | redirect_to :controller => 'security', :action => 'access_denied' |
35 | else |
36 | super |
37 | end |
38 | end |
39 | |
40 | # Check if the client IP is blocked |
41 | def check_block |
42 | if BlockedIp.blocked?(@request.remote_ip) |
43 | # don't waste any time on template rendering |
44 | render_text 'blocked', 403 |
45 | return false |
46 | end |
47 | end |
48 | |
49 | def setup_user |
50 | if @params['user_id'] and @params['key'] |
51 | @user = User.find_by_token(@params['user_id'], @params['key']) |
52 | @authenticated_by_token = true |
53 | # set the token to expire in no more than next 10 minutes |
54 | if @user |
55 | @user.token_expiry = [@user.token_expiry, Time.at(Time.now.to_i + 600 * 1000)].min |
56 | @user.save |
57 | end |
58 | elsif @session[:user_id] |
59 | @user = User.find(@session[:user_id]) |
60 | else |
61 | @user = Guest.new(@session[:guest_name], @session[:guest_email]) if @user.nil? |
62 | end |
63 | |
64 | raise RForum::SecurityError if @user.nil? |
65 | |
66 | rescue => e |
67 | reset_session |
68 | if retried? |
69 | raise e |
70 | else |
71 | retried = true |
72 | retry |
73 | end |
74 | end |
75 | |
76 | def setup_url_generator |
77 | UrlGenerator.controller = self |
78 | end |
79 | |
80 | def finish_user |
81 | @session[:user_id] = @user.id |
82 | @session[:guest_name] = @user.guest_name |
83 | @session[:guest_email] = @user.guest_email |
84 | end |
85 | |
86 | @@REMEMBER_NOT = ['user', 'security', 'feed'] |
87 | def remember_location |
88 | if @response.headers['Status'] == '200 OK' |
89 | @session[:return_to] = url_for unless @@REMEMBER_NOT.include? controller_name |
90 | end |
91 | end |
92 | |
93 | def return_to_last_remembered |
94 | begin |
95 | redirect_to_url(@session[:return_to] || '/') |
96 | rescue RForum::SecurityError |
97 | redirect_to_url('/') |
98 | end |
99 | end |
100 | |
101 | def setup_local |
102 | @headers["Content-Type"] = "text/html; charset=#{RForum::CONFIG[:web_charset]}" |
103 | end |
104 | |
105 | def setup_skin |
106 | if @params['set_skin'] |
107 | @session[:skin] = @params['set_skin'] |
108 | end |
109 | |
110 | @skin = @session[:skin] || RForum::CONFIG[:skin] |
111 | end |
112 | |
113 | def detect_site |
114 | @site = Site.find(:first, :conditions => ["host = ?", request.host]) |
115 | if @site |
116 | self.class.layout @site.layout || 'default' |
117 | @skin = @session[:skin] || @site.skin || 'default' |
118 | end |
119 | end |
120 | |
121 | def get_forums |
122 | if @site |
123 | @forums = @site.forums.find(:all, :order => 'position') |
124 | else |
125 | @forums = Forum.find(:all, :order => 'site_id, position') |
126 | end |
127 | end |
128 | |
129 | def redirect_if_site_doesnt_match |
130 | if @site && @forum && @forum.site && (@site != @forum.site) |
131 | headers["Status"] = "301 Moved Permanently" |
132 | redirect_to_url 'http://' + @forum.site.host + request.path |
133 | return true |
134 | end |
135 | return false |
136 | end |
137 | end |
138 | |
139 | module RForum |
140 | |
141 | # Security error. Controllers throw these in situations where a user is trying to access a |
142 | # function that he is not authorized to access. |
143 | # Normally, RForum does not show URLs that would allow the user to access such features. |
144 | class SecurityError < StandardError |
145 | end |
146 | |
147 | end |