{"action":"created","comment":{"url":"https://api.github.com/repos/featherbb/featherbb/pulls/comments/36909784","id":36909784,"diff_hunk":"@@ -1,36 +1,132 @@\n <?php\n /**\n- * FeatherBB\n  *\n- *\n- * USAGE\n+ * Copyright (C) 2015 FeatherBB\n+ * based on code by (C) 2008-2012 FluxBB\n+ * and Rickard Andersson (C) 2002-2008 PunBB\n+ * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher\n  *\n  * $app = new \\Slim\\Slim();\n- * $app->add(new \\Slim\\Extras\\Middleware\\FeatherBB());\n+ * $app->add(new \\Slim\\Extras\\Middleware\\FeatherBB($params));\n  *\n  */\n+\n namespace Slim\\Extras\\Middleware;\n+use DB;\n \n class FeatherBB extends \\Slim\\Middleware\n {\n-\tprotected $settings = array();\n+    protected $data = array();\n \n-\tpublic function __construct()\n+\tpublic function __construct(array $user_forum_settings = array())\n \t{\n+        // Define forum env constants\n+        $this->data['forum_env'] = array(\n+                                    'FEATHER' => true,\n+                                    'FEATHER_ROOT' => dirname(__FILE__).'/../../../',\n+                                    'FORUM_VERSION' => '1.0.0',\n+                                    'FORUM_NAME' => 'FeatherBB',\n+                                    'FORUM_DB_REVISION' => 21,\n+                                    'FORUM_SI_REVISION' => 2,\n+                                    'FORUM_PARSER_REVISION' => 2,\n+                                    'FORUM_CACHE_DIR' => dirname(__FILE__).'/../../../cache/', // TODO : Move in user settings\n+                                    'FEATHER_UNVERIFIED' => 0,\n+                                    'FEATHER_ADMIN' => 1,\n+                                    'FEATHER_MOD' => 2,\n+                                    'FEATHER_GUEST' => 3,\n+                                    'FEATHER_MEMBER' => 4,\n+                                    'FEATHER_MAX_POSTSIZE' => 32768,\n+                                    'FEATHER_SEARCH_MIN_WORD' => 3,\n+                                    'FEATHER_SEARCH_MAX_WORD' => 20,\n+                                    'FORUM_MAX_COOKIE_SIZE' => 4048,\n+                                    'FEATHER_SHOW_QUERIES' => 1\n+                                    );\n+\n+        // Define forum settings / TODO : handle settings with a class / User input overrides all previous settings\n+        $this->data['forum_settings'] = array_merge(self::load_default_settings(), $user_forum_settings);\n \n+        // Load DB settings\n+        require_once $this->data['forum_env']['FEATHER_ROOT'].'include/idiorm.php';\n+        DB::configure('mysql:host='.$this->data['forum_settings']['db_host'].';dbname='.$this->data['forum_settings']['db_name']);\n+        DB::configure('username', $this->data['forum_settings']['db_user']);\n+        DB::configure('password', $this->data['forum_settings']['db_pass']);\n+        DB::configure('logging', true);\n+        DB::configure('driver_options', array(\\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));\n+        DB::configure('id_column_overrides', array(\n+            'groups' => 'g_id',\n+        ));\n \t}\n \n-    public function call() \n+    public function load_forum_config()\n+    {\n+        global $feather_config; // Legacy\n+\n+        if (file_exists($this->data['forum_env']['FORUM_CACHE_DIR'].'cache_config.php')) {\n+            include $this->data['forum_env']['FORUM_CACHE_DIR'].'cache_config.php';\n+        } else {\n+            require_once $this->data['forum_env']['FEATHER_ROOT'].'include/cache.php';\n+            generate_config_cache();\n+            require $this->data['forum_env']['FORUM_CACHE_DIR'].'cache_config.php';\n+        }\n+        return $feather_config;\n+    }\n+\n+    public static function load_default_settings()","path":"Slim/Extras/Middleware/FeatherBB.php","position":81,"original_position":81,"commit_id":"86906209fa766cfb84e05ccd53b568f27e6cd7c9","original_commit_id":"86906209fa766cfb84e05ccd53b568f27e6cd7c9","user":{"login":"capkokoon","id":12816250,"avatar_url":"https://avatars.githubusercontent.com/u/12816250?v=3","gravatar_id":"","url":"https://api.github.com/users/capkokoon","html_url":"https://github.com/capkokoon","followers_url":"https://api.github.com/users/capkokoon/followers","following_url":"https://api.github.com/users/capkokoon/following{/other_user}","gists_url":"https://api.github.com/users/capkokoon/gists{/gist_id}","starred_url":"https://api.github.com/users/capkokoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capkokoon/subscriptions","organizations_url":"https://api.github.com/users/capkokoon/orgs","repos_url":"https://api.github.com/users/capkokoon/repos","events_url":"https://api.github.com/users/capkokoon/events{/privacy}","received_events_url":"https://api.github.com/users/capkokoon/received_events","type":"User","site_admin":false},"body":"This function is called when the middleware merges the current settings with the forum config stored in the DB, and returns the config array : pointless, but it's a wrapper for the cache loading procedure in order for the call function to be cleaner :)","created_at":"2015-08-12T20:30:09Z","updated_at":"2015-08-12T20:30:09Z","html_url":"https://github.com/featherbb/featherbb/pull/46#discussion_r36909784","pull_request_url":"https://api.github.com/repos/featherbb/featherbb/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/featherbb/featherbb/pulls/comments/36909784"},"html":{"href":"https://github.com/featherbb/featherbb/pull/46#discussion_r36909784"},"pull_request":{"href":"https://api.github.com/repos/featherbb/featherbb/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/featherbb/featherbb/pulls/46","id":42141234,"html_url":"https://github.com/featherbb/featherbb/pull/46","diff_url":"https://github.com/featherbb/featherbb/pull/46.diff","patch_url":"https://github.com/featherbb/featherbb/pull/46.patch","issue_url":"https://api.github.com/repos/featherbb/featherbb/issues/46","number":46,"state":"open","locked":false,"title":"Auth/config in FeatherBB middleware","user":{"login":"capkokoon","id":12816250,"avatar_url":"https://avatars.githubusercontent.com/u/12816250?v=3","gravatar_id":"","url":"https://api.github.com/users/capkokoon","html_url":"https://github.com/capkokoon","followers_url":"https://api.github.com/users/capkokoon/followers","following_url":"https://api.github.com/users/capkokoon/following{/other_user}","gists_url":"https://api.github.com/users/capkokoon/gists{/gist_id}","starred_url":"https://api.github.com/users/capkokoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capkokoon/subscriptions","organizations_url":"https://api.github.com/users/capkokoon/orgs","repos_url":"https://api.github.com/users/capkokoon/repos","events_url":"https://api.github.com/users/capkokoon/events{/privacy}","received_events_url":"https://api.github.com/users/capkokoon/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-11T15:19:32Z","updated_at":"2015-08-12T20:30:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7215173cc4156a70c73076bb13f38b9dc62d7a70","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/featherbb/featherbb/pulls/46/commits","review_comments_url":"https://api.github.com/repos/featherbb/featherbb/pulls/46/comments","review_comment_url":"https://api.github.com/repos/featherbb/featherbb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/featherbb/featherbb/issues/46/comments","statuses_url":"https://api.github.com/repos/featherbb/featherbb/statuses/86906209fa766cfb84e05ccd53b568f27e6cd7c9","head":{"label":"capkokoon:new-feather-middleware","ref":"new-feather-middleware","sha":"86906209fa766cfb84e05ccd53b568f27e6cd7c9","user":{"login":"capkokoon","id":12816250,"avatar_url":"https://avatars.githubusercontent.com/u/12816250?v=3","gravatar_id":"","url":"https://api.github.com/users/capkokoon","html_url":"https://github.com/capkokoon","followers_url":"https://api.github.com/users/capkokoon/followers","following_url":"https://api.github.com/users/capkokoon/following{/other_user}","gists_url":"https://api.github.com/users/capkokoon/gists{/gist_id}","starred_url":"https://api.github.com/users/capkokoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capkokoon/subscriptions","organizations_url":"https://api.github.com/users/capkokoon/orgs","repos_url":"https://api.github.com/users/capkokoon/repos","events_url":"https://api.github.com/users/capkokoon/events{/privacy}","received_events_url":"https://api.github.com/users/capkokoon/received_events","type":"User","site_admin":false},"repo":{"id":39826927,"name":"featherbb","full_name":"capkokoon/featherbb","owner":{"login":"capkokoon","id":12816250,"avatar_url":"https://avatars.githubusercontent.com/u/12816250?v=3","gravatar_id":"","url":"https://api.github.com/users/capkokoon","html_url":"https://github.com/capkokoon","followers_url":"https://api.github.com/users/capkokoon/followers","following_url":"https://api.github.com/users/capkokoon/following{/other_user}","gists_url":"https://api.github.com/users/capkokoon/gists{/gist_id}","starred_url":"https://api.github.com/users/capkokoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capkokoon/subscriptions","organizations_url":"https://api.github.com/users/capkokoon/orgs","repos_url":"https://api.github.com/users/capkokoon/repos","events_url":"https://api.github.com/users/capkokoon/events{/privacy}","received_events_url":"https://api.github.com/users/capkokoon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/capkokoon/featherbb","description":"FeatherBB is a simple and lightweight new generation forum system","fork":true,"url":"https://api.github.com/repos/capkokoon/featherbb","forks_url":"https://api.github.com/repos/capkokoon/featherbb/forks","keys_url":"https://api.github.com/repos/capkokoon/featherbb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/capkokoon/featherbb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/capkokoon/featherbb/teams","hooks_url":"https://api.github.com/repos/capkokoon/featherbb/hooks","issue_events_url":"https://api.github.com/repos/capkokoon/featherbb/issues/events{/number}","events_url":"https://api.github.com/repos/capkokoon/featherbb/events","assignees_url":"https://api.github.com/repos/capkokoon/featherbb/assignees{/user}","branches_url":"https://api.github.com/repos/capkokoon/featherbb/branches{/branch}","tags_url":"https://api.github.com/repos/capkokoon/featherbb/tags","blobs_url":"https://api.github.com/repos/capkokoon/featherbb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/capkokoon/featherbb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/capkokoon/featherbb/git/refs{/sha}","trees_url":"https://api.github.com/repos/capkokoon/featherbb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/capkokoon/featherbb/statuses/{sha}","languages_url":"https://api.github.com/repos/capkokoon/featherbb/languages","stargazers_url":"https://api.github.com/repos/capkokoon/featherbb/stargazers","contributors_url":"https://api.github.com/repos/capkokoon/featherbb/contributors","subscribers_url":"https://api.github.com/repos/capkokoon/featherbb/subscribers","subscription_url":"https://api.github.com/repos/capkokoon/featherbb/subscription","commits_url":"https://api.github.com/repos/capkokoon/featherbb/commits{/sha}","git_commits_url":"https://api.github.com/repos/capkokoon/featherbb/git/commits{/sha}","comments_url":"https://api.github.com/repos/capkokoon/featherbb/comments{/number}","issue_comment_url":"https://api.github.com/repos/capkokoon/featherbb/issues/comments{/number}","contents_url":"https://api.github.com/repos/capkokoon/featherbb/contents/{+path}","compare_url":"https://api.github.com/repos/capkokoon/featherbb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/capkokoon/featherbb/merges","archive_url":"https://api.github.com/repos/capkokoon/featherbb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/capkokoon/featherbb/downloads","issues_url":"https://api.github.com/repos/capkokoon/featherbb/issues{/number}","pulls_url":"https://api.github.com/repos/capkokoon/featherbb/pulls{/number}","milestones_url":"https://api.github.com/repos/capkokoon/featherbb/milestones{/number}","notifications_url":"https://api.github.com/repos/capkokoon/featherbb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/capkokoon/featherbb/labels{/name}","releases_url":"https://api.github.com/repos/capkokoon/featherbb/releases{/id}","created_at":"2015-07-28T10:11:33Z","updated_at":"2015-08-01T15:52:06Z","pushed_at":"2015-08-11T16:06:27Z","git_url":"git://github.com/capkokoon/featherbb.git","ssh_url":"git@github.com:capkokoon/featherbb.git","clone_url":"https://github.com/capkokoon/featherbb.git","svn_url":"https://github.com/capkokoon/featherbb","homepage":"http://featherbb.org","size":2581,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"featherbb:development","ref":"development","sha":"6e645eeba5b75aa062a4ae0af1ecc976f5611bcc","user":{"login":"featherbb","id":12696022,"avatar_url":"https://avatars.githubusercontent.com/u/12696022?v=3","gravatar_id":"","url":"https://api.github.com/users/featherbb","html_url":"https://github.com/featherbb","followers_url":"https://api.github.com/users/featherbb/followers","following_url":"https://api.github.com/users/featherbb/following{/other_user}","gists_url":"https://api.github.com/users/featherbb/gists{/gist_id}","starred_url":"https://api.github.com/users/featherbb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/featherbb/subscriptions","organizations_url":"https://api.github.com/users/featherbb/orgs","repos_url":"https://api.github.com/users/featherbb/repos","events_url":"https://api.github.com/users/featherbb/events{/privacy}","received_events_url":"https://api.github.com/users/featherbb/received_events","type":"Organization","site_admin":false},"repo":{"id":36659400,"name":"featherbb","full_name":"featherbb/featherbb","owner":{"login":"featherbb","id":12696022,"avatar_url":"https://avatars.githubusercontent.com/u/12696022?v=3","gravatar_id":"","url":"https://api.github.com/users/featherbb","html_url":"https://github.com/featherbb","followers_url":"https://api.github.com/users/featherbb/followers","following_url":"https://api.github.com/users/featherbb/following{/other_user}","gists_url":"https://api.github.com/users/featherbb/gists{/gist_id}","starred_url":"https://api.github.com/users/featherbb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/featherbb/subscriptions","organizations_url":"https://api.github.com/users/featherbb/orgs","repos_url":"https://api.github.com/users/featherbb/repos","events_url":"https://api.github.com/users/featherbb/events{/privacy}","received_events_url":"https://api.github.com/users/featherbb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/featherbb/featherbb","description":"FeatherBB is a simple and lightweight new generation forum system","fork":false,"url":"https://api.github.com/repos/featherbb/featherbb","forks_url":"https://api.github.com/repos/featherbb/featherbb/forks","keys_url":"https://api.github.com/repos/featherbb/featherbb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/featherbb/featherbb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/featherbb/featherbb/teams","hooks_url":"https://api.github.com/repos/featherbb/featherbb/hooks","issue_events_url":"https://api.github.com/repos/featherbb/featherbb/issues/events{/number}","events_url":"https://api.github.com/repos/featherbb/featherbb/events","assignees_url":"https://api.github.com/repos/featherbb/featherbb/assignees{/user}","branches_url":"https://api.github.com/repos/featherbb/featherbb/branches{/branch}","tags_url":"https://api.github.com/repos/featherbb/featherbb/tags","blobs_url":"https://api.github.com/repos/featherbb/featherbb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/featherbb/featherbb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/featherbb/featherbb/git/refs{/sha}","trees_url":"https://api.github.com/repos/featherbb/featherbb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/featherbb/featherbb/statuses/{sha}","languages_url":"https://api.github.com/repos/featherbb/featherbb/languages","stargazers_url":"https://api.github.com/repos/featherbb/featherbb/stargazers","contributors_url":"https://api.github.com/repos/featherbb/featherbb/contributors","subscribers_url":"https://api.github.com/repos/featherbb/featherbb/subscribers","subscription_url":"https://api.github.com/repos/featherbb/featherbb/subscription","commits_url":"https://api.github.com/repos/featherbb/featherbb/commits{/sha}","git_commits_url":"https://api.github.com/repos/featherbb/featherbb/git/commits{/sha}","comments_url":"https://api.github.com/repos/featherbb/featherbb/comments{/number}","issue_comment_url":"https://api.github.com/repos/featherbb/featherbb/issues/comments{/number}","contents_url":"https://api.github.com/repos/featherbb/featherbb/contents/{+path}","compare_url":"https://api.github.com/repos/featherbb/featherbb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/featherbb/featherbb/merges","archive_url":"https://api.github.com/repos/featherbb/featherbb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/featherbb/featherbb/downloads","issues_url":"https://api.github.com/repos/featherbb/featherbb/issues{/number}","pulls_url":"https://api.github.com/repos/featherbb/featherbb/pulls{/number}","milestones_url":"https://api.github.com/repos/featherbb/featherbb/milestones{/number}","notifications_url":"https://api.github.com/repos/featherbb/featherbb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/featherbb/featherbb/labels{/name}","releases_url":"https://api.github.com/repos/featherbb/featherbb/releases{/id}","created_at":"2015-06-01T12:31:15Z","updated_at":"2015-08-07T12:59:16Z","pushed_at":"2015-08-12T16:39:56Z","git_url":"git://github.com/featherbb/featherbb.git","ssh_url":"git@github.com:featherbb/featherbb.git","clone_url":"https://github.com/featherbb/featherbb.git","svn_url":"https://github.com/featherbb/featherbb","homepage":"http://featherbb.org","size":3057,"stargazers_count":13,"watchers_count":13,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":5,"forks":4,"open_issues":5,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/featherbb/featherbb/pulls/46"},"html":{"href":"https://github.com/featherbb/featherbb/pull/46"},"issue":{"href":"https://api.github.com/repos/featherbb/featherbb/issues/46"},"comments":{"href":"https://api.github.com/repos/featherbb/featherbb/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/featherbb/featherbb/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/featherbb/featherbb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/featherbb/featherbb/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/featherbb/featherbb/statuses/86906209fa766cfb84e05ccd53b568f27e6cd7c9"}}}}