{"id":73,"date":"2004-08-14T23:38:23","date_gmt":"2004-08-14T21:38:23","guid":{"rendered":"http:\/\/frenchfragfactory.net\/ozh\/archives\/2004\/08\/14\/integration-of-phpbb2-into-a-site\/"},"modified":"2007-04-24T21:25:39","modified_gmt":"2007-04-24T19:25:39","slug":"integration-of-phpbb2-into-a-site","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2004\/08\/integration-of-phpbb2-into-a-site\/","title":{"rendered":"Integration of phpBB2 into a site"},"content":{"rendered":"<p>I run a community site that uses a phpBB2 forum, and I was wondering how to fetch informations from the forum into other pages (without messing with phpBB2 code, which is something I don&#39;t want to even hear about)<br \/>\nHere are some tips that may help you make your existing pages and phpBB2 communicate.<br \/>\n<!--more--><\/p>\n<h2>phpBB Fetch All<\/h2>\n<p><a href=\"http:\/\/phpbbfetchall.sourceforge.net\/\">phpBB Fetch All<\/a> : This project is a collection of functions you can easily use on any pages. Simple installation (5 or 6 pages in a forum sub-directory) and you have ready-to-use functions about posts (last posts, last topics, ongoing thread&#8230;), users (top posters, info about a random user&#8230;), polls and a lot of things. The <a href=\"http:\/\/phpbbfetchall.sourceforge.net\/docs\/\">doc pages<\/a> are clear and list every function available.<\/p>\n<p>This package contains almost everything I needed&#8230; Almost only, since there is no function to dectect informations from a login cookie, if any. It retrieves infos from the forum, but not from a user currently viewing a page.<\/p>\n<h2>Reading phpBB2&#39;s cookie<\/h2>\n<p>Hopefully, reading the login cookie is not difficult, I was real glad after a short googlage to realize how easy it was :) The following quick example just displays if the user has an ongoing session or cookie in your forums, you&#39;ll need to edit only line 5.<\/p>\n<div class=\"igsh-code-box\" id=\"ig-sh-1\"><pre class=\"language-php line-numbers\" data-no-optimize=\"1\" data-cfasync=\"false\"><code class=\"language-php\">&lt;?php\r\n\/\/ phpBB includes\r\ndefine(&#039;IN_PHPBB&#039;, true);\r\n\/\/ next one is the physical path to your forums root : CUSTOMIZE\r\n$phpbb_root_path = &#039;\/home\/user\/you\/forums\/&#039;;\r\ninclude($phpbb_root_path . &#039;extension.inc&#039;);\r\ninclude($phpbb_root_path . &#039;common.&#039;.$phpEx);\r\n\/\/ Start session\r\n$userdata = session_pagestart($user_ip, PAGE_INDEX);\r\ninit_userprefs($userdata);\r\n\/\/ From now on, we have user infos\r\nif ($userdata[&#039;session_logged_in&#039;]) {\r\n        echo &quot;You are : &quot;.$userdata[&#039;username&#039;] .&quot; (&quot;.$userdata[&#039;user_email&#039;].&quot;)&lt;br&gt;\\n&quot;;\r\n        echo &quot;Userid : &quot;.$userdata[&#039;user_id&#039;].&quot;&lt;br&gt;\\n&quot;;\r\n} else {\r\n        echo &quot;Not logged !&quot;;\r\n}\r\n?&gt;<\/code><\/pre><\/div>\n<p>The informations fetched can be any <em>$userdata[<strong>thing<\/strong>]<\/em> where <em>thing<\/em> is a field from  <em>phpbb2_users <\/em>table : user_id,  username,  user_regdate,  user_password,  user_email, etc &#8230;<\/p>\n<p>You can now use this informations into your existing site, for example auto-fill the comments form fields with username, user_url and user_email.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tips to fetch informations from a phpBB2 forum<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[2,10,70,245],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","tag-code","tag-php","tag-phpbb2","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}