22
33/**
44 * Copyright (C) 2015 FeatherBB
5- * based on code by (C) 2008-2012 FluxBB
5+ * based on code by (C) 2008-2015 FluxBB
66 * and Rickard Andersson (C) 2002-2008 PunBB
77 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
88 */
5555
5656-----------------------------------------------------------------------------*/
5757
58+ namespace FeatherBB ;
59+ use DB ;
60+ use FeatherBB \Utils ;
61+ use FeatherBB \Url ;
62+
5863define ('FEATHER_QUIET_VISIT ' , 1 );
5964
60- // Load Slim Framework
61- require 'Slim/Slim.php ' ;
62- \Slim \Slim::registerAutoloader ();
65+ // Start a session for flash messages
66+ session_cache_limiter (false );
67+ session_start ();
68+ error_reporting (E_ALL ); // Let's report everything for development
69+ ini_set ('display_errors ' , 1 );
6370
64- // Load FeatherBB
65- require 'featherbb/Helpers/classes/autoload.class.php ' ;
66- \FeatherBB \Loader::registerAutoloader ();
71+ // Load Slim Framework
72+ require 'vendor/autoload.php ' ;
6773
6874// Instantiate Slim and add CSRF
6975$ feather = new \Slim \Slim ();
70- $ feather ->add (new \FeatherBB \Csrf ());
76+ $ feather ->add (new \FeatherBB \Middleware \ Csrf ());
7177
7278$ feather_settings = array ('config_file ' => 'featherbb/config.php ' ,
7379 'cache_dir ' => 'cache/ ' ,
7480 'debug ' => 'all ' ); // 3 levels : false, info (only execution time and number of queries), and all (display info + queries)
75- $ feather ->add (new \FeatherBB \Auth ());
76- $ feather ->add (new \FeatherBB \Core ($ feather_settings ));
77-
78- load_textdomain ('featherbb ' , FEATHER_ROOT .'featherbb/lang/ ' .$ feather ->user ->language .'/common.mo ' );
79- load_textdomain ('featherbb ' , FEATHER_ROOT .'featherbb/lang/ ' .$ feather ->user ->language .'/index.mo ' );
81+ $ feather ->add (new \FeatherBB \Middleware \Auth ());
82+ $ feather ->add (new \FeatherBB \Middleware \Core ($ feather_settings ));
8083
8184// The length at which topic subjects will be truncated (for HTML output)
8285if (!defined ('FORUM_EXTERN_MAX_SUBJECT_LENGTH ' )) {
@@ -87,7 +90,7 @@ function featherbb_write_cache_file($file, $content)
8790{
8891 $ fh = @fopen (FORUM_CACHE_DIR .$ file , 'wb ' );
8992 if (!$ fh ) {
90- die ('Unable to write cache file ' .Utils::escape ($ file ).' to cache directory. Please make sure PHP has write access to the directory \'' .Utils::escape (FORUM_CACHE_DIR ).'\'' , __FILE__ , __LINE__ );
93+ die ('Unable to write cache file ' .Utils::escape ($ file ).' to cache directory. Please make sure PHP has write access to the directory \'' .Utils::escape (FORUM_CACHE_DIR ).'\'' );
9194 }
9295
9396 flock ($ fh , LOCK_EX );
@@ -205,7 +208,7 @@ function authenticate_user($user, $password, $password_is_hash = false)
205208 // Check if there's a user matching $user and $password
206209 $ select_check_cookie = array ('u.* ' , 'g.* ' , 'o.logged ' , 'o.idle ' );
207210
208- $ result = ORM ::for_table ('users ' )
211+ $ result = DB ::for_table ('users ' )
209212 ->table_alias ('u ' )
210213 ->select_many ($ select_check_cookie )
211214 ->inner_join ('groups ' , array ('u.group_id ' , '= ' , 'g.g_id ' ), 'g ' )
@@ -229,6 +232,9 @@ function authenticate_user($user, $password, $password_is_hash = false)
229232 } else {
230233 $ feather ->user ->is_guest = false ;
231234 }
235+
236+ load_textdomain ('featherbb ' , FEATHER_ROOT .'featherbb/lang/ ' .$ feather ->user ->language .'/common.mo ' );
237+ load_textdomain ('featherbb ' , FEATHER_ROOT .'featherbb/lang/ ' .$ feather ->user ->language .'/index.mo ' );
232238}
233239
234240// If we're a guest and we've sent a username/pass, we can try to authenticate using those details
@@ -334,10 +340,12 @@ function output_atom($feed)
334340 echo "\t" .'<link href=" ' .Utils::escape ($ feed ['link ' ]).'"/> ' ."\n" ;
335341 echo "\t" .'<updated> ' .gmdate ('Y-m-d\TH:i:s\Z ' , count ($ feed ['items ' ]) ? $ feed ['items ' ][0 ]['pubdate ' ] : time ()).'</updated> ' ."\n" ;
336342
343+ $ feather = \Slim \Slim::getInstance ();
344+
337345 if ($ feather ->forum_settings ['o_show_version ' ] == '1 ' ) {
338- echo "\t" .'<generator version=" ' .$ feather ->forum_settings ['o_cur_version ' ].'">FluxBB </generator> ' ."\n" ;
346+ echo "\t" .'<generator version=" ' .$ feather ->forum_settings ['o_cur_version ' ].'">FeatherBB </generator> ' ."\n" ;
339347 } else {
340- echo "\t" .'<generator>FluxBB </generator> ' ."\n" ;
348+ echo "\t" .'<generator>FeatherBB </generator> ' ."\n" ;
341349 }
342350
343351 echo "\t" .'<id> ' .Utils::escape ($ feed ['link ' ]).'</id> ' ."\n" ;
@@ -439,8 +447,6 @@ function output_html($feed)
439447
440448// Show recent discussions
441449if ($ action == 'feed ' ) {
442- require FEATHER_ROOT .'featherbb/Helpers/parser.php ' ;
443-
444450 // Determine what type of feed to output
445451 $ type = isset ($ _GET ['type ' ]) ? strtolower ($ _GET ['type ' ]) : 'html ' ;
446452 if (!in_array ($ type , array ('html ' , 'rss ' , 'atom ' , 'xml ' ))) {
@@ -484,7 +490,7 @@ function output_html($feed)
484490 // Setup the feed
485491 $ feed = array (
486492 'title ' => $ feather ->forum_settings ['o_board_title ' ].__ ('Title separator ' ).$ cur_topic ['subject ' ],
487- 'link ' => get ('topic/ ' .$ tid .'/ ' .url_friendly ($ cur_topic ['subject ' ]).'/ ' ),
493+ 'link ' => Url:: get ('topic/ ' .$ tid .'/ ' .Url:: url_friendly ($ cur_topic ['subject ' ]).'/ ' ),
488494 'description ' => sprintf (__ ('RSS description topic ' ), $ cur_topic ['subject ' ]),
489495 'items ' => array (),
490496 'type ' => 'posts '
@@ -508,7 +514,7 @@ function output_html($feed)
508514 $ item = array (
509515 'id ' => $ cur_post ['id ' ],
510516 'title ' => $ cur_topic ['first_post_id ' ] == $ cur_post ['id ' ] ? $ cur_topic ['subject ' ] : __ ('RSS reply ' ).$ cur_topic ['subject ' ],
511- 'link ' => get ('post/ ' .$ cur_post ['id ' ].'/#p ' .$ cur_post ['id ' ]),
517+ 'link ' => Url:: get ('post/ ' .$ cur_post ['id ' ].'/#p ' .$ cur_post ['id ' ]),
512518 'description ' => $ cur_post ['message ' ],
513519 'author ' => array (
514520 'name ' => $ cur_post ['poster ' ],
@@ -521,7 +527,7 @@ function output_html($feed)
521527 $ item ['author ' ]['email ' ] = $ cur_post ['email ' ];
522528 }
523529
524- $ item ['author ' ]['uri ' ] = get ('user/ ' .$ cur_post ['poster_id ' ].'/ ' );
530+ $ item ['author ' ]['uri ' ] = Url:: get ('user/ ' .$ cur_post ['poster_id ' ].'/ ' );
525531 } elseif ($ cur_post ['poster_email ' ] != '' && !$ feather ->user ->is_guest ) {
526532 $ item ['author ' ]['email ' ] = $ cur_post ['poster_email ' ];
527533 }
@@ -626,7 +632,7 @@ function output_html($feed)
626632 $ item = array (
627633 'id ' => $ cur_topic ['id ' ],
628634 'title ' => $ cur_topic ['subject ' ],
629- 'link ' => get ('topic/ ' .$ cur_topic ['id ' ].'/ ' .url_friendly ($ cur_topic ['subject ' ]).'/ ' ).($ order_posted ? '' : '/action/new/ ' ),
635+ 'link ' => Url:: get ('topic/ ' .$ cur_topic ['id ' ].'/ ' .url_friendly ($ cur_topic ['subject ' ]).'/ ' ).($ order_posted ? '' : '/action/new/ ' ),
630636 'description ' => $ cur_topic ['message ' ],
631637 'author ' => array (
632638 'name ' => $ order_posted ? $ cur_topic ['poster ' ] : $ cur_topic ['last_poster ' ]
@@ -639,7 +645,7 @@ function output_html($feed)
639645 $ item ['author ' ]['email ' ] = $ cur_topic ['email ' ];
640646 }
641647
642- $ item ['author ' ]['uri ' ] = get ('user/ ' .$ cur_topic ['poster_id ' ].'/ ' );
648+ $ item ['author ' ]['uri ' ] = Url:: get ('user/ ' .$ cur_topic ['poster_id ' ].'/ ' );
643649 } elseif ($ cur_topic ['poster_email ' ] != '' && !$ feather ->user ->is_guest ) {
644650 $ item ['author ' ]['email ' ] = $ cur_topic ['poster_email ' ];
645651 }
@@ -700,7 +706,7 @@ function output_html($feed)
700706
701707 foreach ($ result as $ feather_user_online ) {
702708 if ($ feather_user_online ['user_id ' ] > 1 ) {
703- $ users [] = ($ feather ->user ->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%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 ' ]);
709+ $ users [] = ($ feather ->user ->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"x x-first x-last">Url:: get ('user/ ' .$ feather_user_online ['user_id ' ].'/ ' ).'"> ' .Utils::escape ($ feather_user_online ['ident ' ]).'</a> ' : Utils::escape ($ feather_user_online ['ident ' ]);
704710 ++$ num_users ;
705711 } else {
706712 ++$ num_guests ;
@@ -748,11 +754,11 @@ function output_html($feed)
748754 header ('Pragma: public ' );
749755
750756 echo sprintf (__ ('No of users ' ), Utils::forum_number_format ($ stats ['total_users ' ])).'<br /> ' ."\n" ;
751- echo sprintf (__ ('Newest user ' ), (($ feather ->user ->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%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" ;
757+ echo sprintf (__ ('Newest user ' ), (($ feather ->user ->g_view_users == '1 ' ) ? '<a href="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3C%2Fspan%3E%27%3C%2Fspan%3E.%3Cspan+class%3D"x x-first x-last">Url:: get ('user/ ' .$ stats ['last_user ' ]['id ' ].'/ ' ).'"> ' .Utils::escape ($ stats ['last_user ' ]['username ' ]).'</a> ' : Utils::escape ($ stats ['last_user ' ]['username ' ]))).'<br /> ' ."\n" ;
752758 echo sprintf (__ ('No of topics ' ), Utils::forum_number_format ($ stats ['total_topics ' ])).'<br /> ' ."\n" ;
753759 echo sprintf (__ ('No of posts ' ), Utils::forum_number_format ($ stats ['total_posts ' ])).'<br /> ' ."\n" ;
754760
755761 exit ;
756762}
757763// If we end up here, the script was called with some wacky parameters
758- exit (__ ('Bad request ' ));
764+ exit (__ ('Bad request ' ));
0 commit comments