@@ -136,7 +136,7 @@ function get_current_url($max_length = 0)
136136}
137137
138138//
139- // Fill Container ::get('user' ) with default values (for guests)
139+ // Fill User ::get() with default values (for guests)
140140//
141141function set_default_user ()
142142{
@@ -158,11 +158,11 @@ function set_default_user()
158158 exit ('Unable to fetch guest information. Your database must contain both a guest user and a guest user group. ' );
159159 }
160160
161- foreach ($ result as Container ::get (' user ' ));
161+ foreach ($ result as User ::get ());
162162
163163 // Update online list
164- if (!Container ::get (' user ' )->logged ) {
165- Container ::get (' user ' )->logged = time ();
164+ if (!User ::get ()->logged ) {
165+ User ::get ()->logged = time ();
166166
167167 // With MySQL/MySQLi/SQLite, REPLACE INTO avoids a user having two rows in the online table
168168 switch (ForumSettings::get ('db_type ' )) {
@@ -172,26 +172,26 @@ function set_default_user()
172172 case 'mysqli_innodb ' :
173173 case 'sqlite ' :
174174 case 'sqlite3 ' :
175- \DB ::for_table ('online ' )->raw_execute ('REPLACE INTO ' .ForumSettings::get ('db_prefix ' ).'online (user_id, ident, logged) VALUES(1, :ident, :logged) ' , array (':ident ' => $ remote_addr , ':logged ' => Container ::get (' user ' )->logged ));
175+ \DB ::for_table ('online ' )->raw_execute ('REPLACE INTO ' .ForumSettings::get ('db_prefix ' ).'online (user_id, ident, logged) VALUES(1, :ident, :logged) ' , array (':ident ' => $ remote_addr , ':logged ' => User ::get ()->logged ));
176176 break ;
177177
178178 default :
179- \DB ::for_table ('online ' )->raw_execute ('INSERT INTO ' .ForumSettings::get ('db_prefix ' ).'online (user_id, ident, logged) SELECT 1, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM ' .ForumSettings::get ('db_prefix ' ).'online WHERE ident=:ident) ' , array (':ident ' => $ remote_addr , ':logged ' => Container ::get (' user ' )->logged ));
179+ \DB ::for_table ('online ' )->raw_execute ('INSERT INTO ' .ForumSettings::get ('db_prefix ' ).'online (user_id, ident, logged) SELECT 1, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM ' .ForumSettings::get ('db_prefix ' ).'online WHERE ident=:ident) ' , array (':ident ' => $ remote_addr , ':logged ' => User ::get ()->logged ));
180180 break ;
181181 }
182182 } else {
183183 \DB ::for_table ('online ' )->where ('ident ' , $ remote_addr )
184184 ->update_many ('logged ' , time ());
185185 }
186186
187- Container ::get (' user ' )->disp_topics = ForumSettings::get ('o_disp_topics_default ' );
188- Container ::get (' user ' )->disp_posts = ForumSettings::get ('o_disp_posts_default ' );
189- Container ::get (' user ' )->timezone = ForumSettings::get ('o_default_timezone ' );
190- Container ::get (' user ' )->dst = ForumSettings::get ('o_default_dst ' );
191- Container ::get (' user ' )->language = ForumSettings::get ('o_default_lang ' );
192- Container ::get (' user ' )->style = ForumSettings::get ('o_default_style ' );
193- Container ::get (' user ' )->is_guest = true ;
194- Container ::get (' user ' )->is_admmod = false ;
187+ User ::get ()->disp_topics = ForumSettings::get ('o_disp_topics_default ' );
188+ User ::get ()->disp_posts = ForumSettings::get ('o_disp_posts_default ' );
189+ User ::get ()->timezone = ForumSettings::get ('o_default_timezone ' );
190+ User ::get ()->dst = ForumSettings::get ('o_default_dst ' );
191+ User ::get ()->language = ForumSettings::get ('o_default_lang ' );
192+ User ::get ()->style = ForumSettings::get ('o_default_style ' );
193+ User ::get ()->is_guest = true ;
194+ User ::get ()->is_admmod = false ;
195195}
196196
197197//
@@ -201,8 +201,6 @@ function set_default_user()
201201//
202202function authenticate_user ($ user , $ password , $ password_is_hash = false )
203203{
204- global $ feather ;
205-
206204 // Check if there's a user matching $user and $password
207205 $ select_check_cookie = array ('u.* ' , 'g.* ' , 'o.logged ' , 'o.idle ' );
208206
@@ -221,26 +219,26 @@ function authenticate_user($user, $password, $password_is_hash = false)
221219
222220 $ result = $ result ->find_result_set ();
223221
224- foreach ($ result as Container ::get (' user ' ));
222+ foreach ($ result as User ::get ());
225223
226- if (!isset (Container ::get (' user ' )->id ) ||
227- ($ password_is_hash && $ password != Container ::get (' user ' )->password ) ||
228- (!$ password_is_hash && \FeatherBB \Core \Random::hash ($ password ) != Container ::get (' user ' )->password )) {
224+ if (!isset (User ::get ()->id ) ||
225+ ($ password_is_hash && $ password != User ::get ()->password ) ||
226+ (!$ password_is_hash && \FeatherBB \Core \Random::hash ($ password ) != User ::get ()->password )) {
229227 set_default_user ();
230228 } else {
231- Container ::get (' user ' )->is_guest = false ;
229+ User ::get ()->is_guest = false ;
232230 }
233231
234- load_textdomain ( ' featherbb ' , FEATHER_ROOT . ' featherbb/lang/ ' .Container:: get ( ' user ' )-> language . ' / common.mo ' );
235- load_textdomain ( ' featherbb ' , FEATHER_ROOT . ' featherbb/lang/ ' .Container:: get ( ' user ' )-> language . ' / index.mo ' );
232+ translate ( ' common ' );
233+ translate ( ' index ' );
236234}
237235
238236// If we're a guest and we've sent a username/pass, we can try to authenticate using those details
239- if (Container ::get (' user ' )->is_guest && isset ($ _SERVER ['PHP_AUTH_USER ' ])) {
237+ if (User ::get ()->is_guest && isset ($ _SERVER ['PHP_AUTH_USER ' ])) {
240238 authenticate_user ($ _SERVER ['PHP_AUTH_USER ' ], $ _SERVER ['PHP_AUTH_PW ' ]);
241239}
242240
243- if (Container ::get (' user ' )->g_read_board == '0 ' ) {
241+ if (User ::get ()->g_read_board == '0 ' ) {
244242 http_authenticate_user ();
245243 exit (__ ('No view ' ));
246244}
@@ -267,7 +265,7 @@ function http_authenticate_user()
267265{
268266 global $ feather ;
269267
270- if (!Container ::get (' user ' )->is_guest ) {
268+ if (!User ::get ()->is_guest ) {
271269 return ;
272270 }
273271
@@ -468,7 +466,7 @@ function output_html($feed)
468466 $ cur_topic = \DB ::for_table ('topics ' )->table_alias ('t ' )
469467 ->select_many ($ select_show_recent_topics )
470468 ->left_outer_join ('forum_perms ' , array ('fp.forum_id ' , '= ' , 't.forum_id ' ), 'fp ' )
471- ->left_outer_join ('forum_perms ' , array ('fp.group_id ' , '= ' , Container ::get (' user ' )->g_id ), null , true )
469+ ->left_outer_join ('forum_perms ' , array ('fp.group_id ' , '= ' , User ::get ()->g_id ), null , true )
472470 ->where_any_is ($ where_show_recent_topics )
473471 ->where_null ('t.moved_to ' )
474472 ->where ('t.id ' , $ tid )
@@ -519,12 +517,12 @@ function output_html($feed)
519517 );
520518
521519 if ($ cur_post ['poster_id ' ] > 1 ) {
522- if ($ cur_post ['email_setting ' ] == '0 ' && !Container ::get (' user ' )->is_guest ) {
520+ if ($ cur_post ['email_setting ' ] == '0 ' && !User ::get ()->is_guest ) {
523521 $ item ['author ' ]['email ' ] = $ cur_post ['email ' ];
524522 }
525523
526524 $ item ['author ' ]['uri ' ] = Url::get ('user/ ' .$ cur_post ['poster_id ' ].'/ ' );
527- } elseif ($ cur_post ['poster_email ' ] != '' && !Container ::get (' user ' )->is_guest ) {
525+ } elseif ($ cur_post ['poster_email ' ] != '' && !User ::get ()->is_guest ) {
528526 $ item ['author ' ]['email ' ] = $ cur_post ['poster_email ' ];
529527 }
530528
@@ -558,7 +556,7 @@ function output_html($feed)
558556
559557 $ cur_topic = \DB ::for_table ('forums ' )->table_alias ('f ' )
560558 ->left_outer_join ('forum_perms ' , array ('fp.forum_id ' , '= ' , 'f.id ' ), 'fp ' )
561- ->left_outer_join ('forum_perms ' , array ('fp.group_id ' , '= ' , Container ::get (' user ' )->g_id ), null , true )
559+ ->left_outer_join ('forum_perms ' , array ('fp.group_id ' , '= ' , User ::get ()->g_id ), null , true )
562560 ->where_any_is ($ where_show_forum_name )
563561 ->where ('f.id ' , $ fids [0 ])
564562 ->find_one_col ('f.forum_name ' );
@@ -581,7 +579,7 @@ function output_html($feed)
581579
582580 // Only attempt to cache if caching is enabled and we have all or a single forum
583581 if (ForumSettings::get ('o_feed_ttl ' ) > 0 && ($ forum_sql == '' || ($ forum_name != '' && !isset ($ _GET ['nfid ' ])))) {
584- $ cache_id = 'feed ' .sha1 (Container ::get (' user ' )->g_id .'| ' .__ ('lang_identifier ' ).'| ' .($ order_posted ? '1 ' : '0 ' ).($ forum_name == '' ? '' : '| ' .$ fids [0 ]));
582+ $ cache_id = 'feed ' .sha1 (User ::get ()->g_id .'| ' .__ ('lang_identifier ' ).'| ' .($ order_posted ? '1 ' : '0 ' ).($ forum_name == '' ? '' : '| ' .$ fids [0 ]));
585583 }
586584
587585 // Load cached feed
@@ -611,7 +609,7 @@ function output_html($feed)
611609 ->inner_join ('posts ' , array ('p.id ' , '= ' , ($ order_posted ? 't.first_post_id ' : 't.last_post_id ' )), 'p ' )
612610 ->inner_join ('users ' , array ('u.id ' , '= ' , 'p.poster_id ' ), 'u ' )
613611 ->left_outer_join ('forum_perms ' , array ('fp.forum_id ' , '= ' , 't.forum_id ' ), 'fp ' )
614- ->left_outer_join ('forum_perms ' , array ('fp.group_id ' , '= ' , Container ::get (' user ' )->g_id ), null , true )
612+ ->left_outer_join ('forum_perms ' , array ('fp.group_id ' , '= ' , User ::get ()->g_id ), null , true )
615613 ->where_any_is ($ where_print_posts )
616614 ->where_null ('t.moved_to ' )
617615 ->order_by (($ order_posted ? 't.posted ' : 't.last_post ' ))
@@ -637,12 +635,12 @@ function output_html($feed)
637635 );
638636
639637 if ($ cur_topic ['poster_id ' ] > 1 ) {
640- if ($ cur_topic ['email_setting ' ] == '0 ' && !Container ::get (' user ' )->is_guest ) {
638+ if ($ cur_topic ['email_setting ' ] == '0 ' && !User ::get ()->is_guest ) {
641639 $ item ['author ' ]['email ' ] = $ cur_topic ['email ' ];
642640 }
643641
644642 $ item ['author ' ]['uri ' ] = Url::get ('user/ ' .$ cur_topic ['poster_id ' ].'/ ' );
645- } elseif ($ cur_topic ['poster_email ' ] != '' && !Container ::get (' user ' )->is_guest ) {
643+ } elseif ($ cur_topic ['poster_email ' ] != '' && !User ::get ()->is_guest ) {
646644 $ item ['author ' ]['email ' ] = $ cur_topic ['poster_email ' ];
647645 }
648646
@@ -702,7 +700,7 @@ function output_html($feed)
702700
703701 foreach ($ result as $ feather_user_online ) {
704702 if ($ feather_user_online ['user_id ' ] > 1 ) {
705- $ users [] = (Container ::get (' user ' )->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.Url%3A%3A%3Cspan+class%3D"pl-en">get ('user/ ' .$ feather_user_online ['user_id ' ].'/ ' ).'"> ' .Utils::escape ($ feather_user_online ['ident ' ]).'</a> ' : Utils::escape ($ feather_user_online ['ident ' ]);
703+ $ users [] = (User ::get ()->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.Url%3A%3A%3Cspan+class%3D"pl-en">get ('user/ ' .$ feather_user_online ['user_id ' ].'/ ' ).'"> ' .Utils::escape ($ feather_user_online ['ident ' ]).'</a> ' : Utils::escape ($ feather_user_online ['ident ' ]);
706704 ++$ num_users ;
707705 } else {
708706 ++$ num_guests ;
@@ -750,7 +748,7 @@ function output_html($feed)
750748 header ('Pragma: public ' );
751749
752750 echo sprintf (__ ('No of users ' ), Utils::forum_number_format ($ stats ['total_users ' ])).'<br /> ' ."\n" ;
753- echo sprintf (__ ('Newest user ' ), ((Container ::get (' user ' )->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.Url%3A%3A%3Cspan+class%3D"pl-en">get ('user/ ' .$ stats ['last_user ' ]['id ' ].'/ ' ).'"> ' .Utils::escape ($ stats ['last_user ' ]['username ' ]).'</a> ' : Utils::escape ($ stats ['last_user ' ]['username ' ]))).'<br /> ' ."\n" ;
751+ echo sprintf (__ ('Newest user ' ), ((User ::get ()->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.Url%3A%3A%3Cspan+class%3D"pl-en">get ('user/ ' .$ stats ['last_user ' ]['id ' ].'/ ' ).'"> ' .Utils::escape ($ stats ['last_user ' ]['username ' ]).'</a> ' : Utils::escape ($ stats ['last_user ' ]['username ' ]))).'<br /> ' ."\n" ;
754752 echo sprintf (__ ('No of topics ' ), Utils::forum_number_format ($ stats ['total_topics ' ])).'<br /> ' ."\n" ;
755753 echo sprintf (__ ('No of posts ' ), Utils::forum_number_format ($ stats ['total_posts ' ])).'<br /> ' ."\n" ;
756754
0 commit comments