PluginProbe
wpForo Forum / beta-1
wpForo Forum vbeta-1
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / wpforo.php

wpforo.php in wpForo Forum beta-1, at wpforo.php

305 lines 12.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: Forum - wpForo
4 * Plugin URI: http://wpforo.com
5 * Description: Next Generation of WordPress Forum Softwares. Everything you need to run an efficient and professional community. Powerful and beautiful bulletin board with unique features.
6 * Author: gVectors Team (A. Chakhoyan, R. Hovhannisyan)
7 * Author URI: http://gvectors.com/
8 * Version: beta-1
9 */
10
11 // Exit if accessed directly
12 if( !defined( 'ABSPATH' ) ) exit;
13
14 if( !class_exists( 'wpForo' ) ) {
15
16 define('WPFORO_DIR', rtrim( plugin_dir_path( __FILE__ ), '/'));
17 define('WPFORO_URL', rtrim( plugins_url( plugin_basename(dirname(__FILE__))), '/'));
18 define('WPFORO_FOLDER', rtrim( plugin_basename(dirname(__FILE__)), '/'));
19 define('WPFORO_BASENAME', plugin_basename(__FILE__)); //wpforo/wpforo.php
20
21 define('WPFORO_THEME_DIR', WPFORO_DIR . '/wpf-themes' );
22 define('WPFORO_THEME_URL', WPFORO_URL . '/wpf-themes' );
23 define('WPFORO_PLUGIN_DIR', WPFORO_DIR . '/wpf-plugins' );
24 define('WPFORO_PLUGIN_URL', WPFORO_URL . '/wpf-plugins' );
25
26 include( WPFORO_DIR . '/wpf-includes/wpf-hooks.php' );
27 include( WPFORO_DIR . '/wpf-includes/wpf-actions.php');
28 include( WPFORO_DIR . '/wpf-includes/functions.php' );
29 include( WPFORO_DIR . '/wpf-includes/functions-installation.php' );
30 include( WPFORO_DIR . '/wpf-includes/functions-integration.php' );
31 include( WPFORO_DIR . '/wpf-includes/functions-template.php' );
32 include( WPFORO_DIR . '/wpf-includes/class-forums.php' );
33 include( WPFORO_DIR . '/wpf-includes/class-topics.php' );
34 include( WPFORO_DIR . '/wpf-includes/class-posts.php' );
35 include( WPFORO_DIR . '/wpf-includes/class-usergroups.php' );
36 include( WPFORO_DIR . '/wpf-includes/class-members.php' );
37 include( WPFORO_DIR . '/wpf-includes/class-permissions.php' );
38 include( WPFORO_DIR . '/wpf-includes/class-phrases.php');
39 include( WPFORO_DIR . '/wpf-includes/class-subscribes.php' );
40 include( WPFORO_DIR . '/wpf-includes/class-template.php' );
41 include( WPFORO_DIR . '/wpf-includes/class-notices.php' );
42 include( WPFORO_DIR . '/wpf-includes/class-feed.php' );
43
44 class wpForo{
45
46 public $version = 'Beta-1';
47 public $options = array();
48 public $db;
49 public $phrases;
50 public $theme;
51 public $current_object;
52 public $menu = array();
53
54 public function __construct(){
55 $this->options();
56 $this->setup();
57 }
58
59 public function init(){
60 $this->member->init_current_user();
61 $this->init_current_object();
62 $this->tpl->init_member_templates();
63 $this->tpl->init_nav_menu();
64 wpforo_actions();
65 }
66
67 private function options(){
68 global $wpdb;
69 $this->db = $wpdb;
70 $this->file = __FILE__;
71 $this->error = NULL;
72 $this->basename = plugin_basename( $this->file );
73
74 //OPTIONS
75 $this->url = trim( get_option('wpforo_url'), '/' ) . "/";
76 $this->general_options = get_option( 'wpforo_general_options');
77 $this->notices = get_option( 'wpforo_notices');
78 $this->pageid = get_option( 'wpforo_pageid');
79 $this->default_groupid = get_option('wpforo_default_groupid') ? get_option('wpforo_default_groupid') : 3;
80 $this->usergroup_cans = get_option('wpforo_usergroup_cans');
81 $this->forum_options = get_option('wpforo_forum_options');
82 $this->forum_cans = get_option('wpforo_forum_cans');
83 $this->post_options = get_option('wpforo_post_options');
84 $this->member_options = get_option('wpforo_member_options');
85 $this->subscribe_options = get_option('wpforo_subscribe_options');
86 $this->countries = get_option('wpforo_countries');
87 $this->features = get_option('wpforo_features');
88 $this->theme_options = get_option('wpforo_theme_options');
89 $this->theme = $this->theme_options['folder'];
90 //CONSTANTS
91 define('WPFORO_BASE_URL', $this->url );
92 define('WPFORO_THEME', $this->theme );
93 define('WPFORO_TEMPLATE_DIR', WPFORO_THEME_DIR . '/' . $this->theme );
94 define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme );
95 }
96
97 private function setup(){
98 add_action( 'activate_' . $this->basename, 'wpforo_activation' );
99 add_action( 'deactivate_' . $this->basename, 'wpforo_deactivation' );
100 }
101
102 public function phrases(){
103 if($this->general_options){
104 $phrases = $this->phrase->get_phrases( array( 'langid' => $this->general_options['lang'] ) );
105 foreach($phrases as $phrase){
106 $this->phrases[addslashes(strtolower($phrase['phrase_key']))] = $phrase['phrase_value'];
107 }
108 }
109 }
110
111 public function get_statistic(){
112 $stats = array();
113 $stats['forums'] = $this->forum->get_count();
114 $stats['topics'] = $this->topic->get_count();
115 $stats['posts'] = $this->post->get_count();
116 $stats['members'] = $this->member->get_count();
117 $stats['online_members_count'] = $this->member->online_members_count();
118
119 $stats['last_post_title'] = '';
120 $stats['last_post_url'] = '';
121
122 $posts = $this->topic->get_topics( array( 'orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1 ) );
123 if(isset($posts[0]) && !empty($posts[0])){
124 $stats['last_post_title'] = $posts[0]['title'];
125 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
126 }
127
128 $stats['newest_member_dname'] = '';
129 $stats['newest_member_profile_url'] = '';
130
131 $members = $this->member->get_members( array( 'orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1 ) );
132 if(isset($members[0]) && !empty($members[0])){
133 $stats['newest_member_dname'] = $members[0]['display_name'] ? $members[0]['display_name'] : $members[0]['user_nicename'];
134 $stats['newest_member_profile_url'] = $this->member->get_profile_url($members[0]['ID']);
135 }
136
137 return apply_filters('wpforo_get_statistic_array_filter', $stats);
138 }
139
140 private function init_current_object($url = ''){
141 $this->current_object = array('template' => '', 'paged' => 1);
142 if(!$url) $url = wpforo_full_url();
143 if( strpos($url, WPFORO_BASE_URL) === FALSE ) return;
144
145 $current_object = array();
146 $current_object['template'] = '';
147
148 $wpf_url = str_replace( WPFORO_BASE_URL, '' , $url );
149 $wpf_url = preg_replace('#\/?\?.*$#is', '', $wpf_url);
150 $wpf_url_parse = explode('/', trim($wpf_url, '/'));
151 $wpf_url_parse = array_reverse($wpf_url_parse);
152
153 if(in_array('paged', $wpf_url_parse)){
154 foreach($wpf_url_parse as $key => $value){
155 if( $value == 'paged'){
156 unset($wpf_url_parse[$key]);
157 break;
158 }
159 if(is_numeric($value)) $paged = $value;
160
161 unset($wpf_url_parse[$key]);
162 }
163 }
164 $current_object['paged'] = isset($paged) ? $paged : 1;
165
166 $wpf_url_parse = array_values($wpf_url_parse);
167
168 if(in_array('members', $wpf_url_parse) && $wpf_url_parse[0] == 'members'){
169 $current_object['template'] = 'members';
170 }elseif(in_array('profile', $wpf_url_parse)){
171 $current_object['template'] = 'profile';
172 foreach($wpf_url_parse as $value){
173 if( $value == 'profile') break;
174 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
175 }
176 }elseif(in_array('messages', $wpf_url_parse)){
177 $current_object['template'] = 'messages';
178 foreach($wpf_url_parse as $value){
179 if( $value == 'messages') break;
180 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
181 }
182 }elseif(in_array('account', $wpf_url_parse)){
183 $current_object['template'] = 'account';
184 foreach($wpf_url_parse as $value){
185 if( $value == 'account') break;
186 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
187 }
188 }elseif(in_array('activity', $wpf_url_parse)){
189 $current_object['template'] = 'activity';
190 foreach($wpf_url_parse as $value){
191 if( $value == 'activity') break;
192 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
193 }
194 }elseif(in_array('subscriptions', $wpf_url_parse)){
195 $current_object['template'] = 'subscriptions';
196 foreach($wpf_url_parse as $value){
197 if( $value == 'subscriptions') break;
198 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
199 }
200 }else{
201 $current_object['template'] = 'forum';
202 if($wpf_url_parse[0] && $wpf_url_parse[0] != 'wpforo'){
203
204 if(isset($wpf_url_parse[1])){
205 $current_object['topic_slug'] = $wpf_url_parse[0];
206 $current_object['forum_slug'] = $wpf_url_parse[1];
207 $current_object['template'] = 'post';
208 }else{
209 $current_object['forum_slug'] = $wpf_url_parse[0];
210 $current_object['template'] = 'topic';
211 }
212 }
213 }
214
215 if( isset($current_object['userid']) || isset($current_object['username']) ){
216 $args = array();
217 if(isset($current_object['userid'])) $args['userid'] = $current_object['userid'];
218 if(isset($current_object['username'])) $args['username'] = $current_object['username'];
219 $selected_user = $this->member->get_member($args);
220 if(isset($current_object['userid']) && empty($selected_user)) $selected_user = $this->member->get_member(array('username' => $current_object['userid']));
221 if(!empty($selected_user)){
222 $current_object['user'] = $selected_user;
223 $current_object['userid'] = $selected_user['ID'];
224 $current_object['username'] = $selected_user['user_nicename'];
225
226 switch($current_object['template']){
227 case 'activity':
228 $args = array(
229 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
230 'row_count' => $this->post_options['posts_per_page'],
231 'userid' => $current_object['userid'],
232 'order' => 'DESC'
233 );
234 $current_object['items_count'] = 0;
235 $current_object['activities'] = $this->post->get_posts( $args, $current_object['items_count']);
236 break;
237 case 'subscriptions':
238 $args = array(
239 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
240 'row_count' => $this->post_options['posts_per_page'],
241 'userid' => $current_object['userid'],
242 'order' => 'DESC'
243 );
244 $current_object['items_count'] = 0;
245 $current_object['subscribes'] = $this->sbscrb->get_subscribes( $args, $current_object['items_count']);
246 break;
247 }
248
249 }else{
250 $current_object['user'] = array();
251 $current_object['userid'] = 0;
252 $current_object['username'] = '';
253 }
254 }
255
256 if(isset($current_object['forum_slug']) && $current_object['forum_slug']){
257 $forum = $this->forum->get_forum(array('slug' => $current_object['forum_slug']));
258 if(!empty($forum)){
259 $current_object['forum'] = $forum;
260 $current_object['forumid'] = $forum['forumid'];
261 $current_object['forum_desc'] = $forum['description'];
262 $current_object['forum_meta_key'] = $forum['meta_key'];
263 $current_object['forum_meta_desc'] = $forum['meta_desc'];
264 }else{
265 $current_object['forum'] = array();
266 $current_object['forumid'] = 0;
267 $current_object['forum_desc'] = '';
268 $current_object['forum_meta_key'] = '';
269 $current_object['forum_meta_desc'] = '';
270 }
271 }
272
273 if(isset($current_object['topic_slug']) && $current_object['topic_slug']){
274 $topic = $this->topic->get_topic(array('slug' => $current_object['topic_slug']));
275 if(!empty($topic)){
276 $current_object['topic'] = $topic;
277 $current_object['topicid'] = $topic['topicid'];
278 }else{
279 $current_object['topic'] = array();
280 $current_object['topicid'] = 0;
281 }
282 }
283
284 $this->current_object = apply_filters('wpforo_current_object_filter', $current_object);
285 }
286 }
287
288 $wpforo = new wpForo();
289 $wpforo->phrase = new wpForoPhrase( $wpforo );
290 $wpforo->phrases();
291 $wpforo->forum = new wpForoForum( $wpforo );
292 $wpforo->topic = new wpForoTopic( $wpforo );
293 $wpforo->post = new wpForoPost( $wpforo );
294 $wpforo->usergroup = new wpForoUsergroup( $wpforo );
295 $wpforo->member = new wpForoMember( $wpforo );
296 $wpforo->perm = new wpForoPermissions( $wpforo );
297 $wpforo->sbscrb = new wpForoSubscribe( $wpforo );
298 $wpforo->tpl = new wpForoTemplate( $wpforo );
299 $wpforo->notice = new wpForoNotices( $wpforo );
300 $wpforo->feed = new wpForoFeed( $wpforo );
301 if(is_admin()) include( WPFORO_DIR .'/wpf-admin/admin.php' );
302 $GLOBALS['wpforo'] = $wpforo;
303 add_action('init', array($wpforo, 'init'));
304 }
305 ?>