{"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 id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">php<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"php\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000000;font-weight: bold\">&lt;?php<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\">\/\/ phpBB includes<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #990000\">define<\/span><span style=\"color: #009900\">&#040;<\/span><span style=\"color: #0000ff\">'IN_PHPBB'<\/span><span style=\"color: #339933\">,<\/span> <span style=\"color: #009900;font-weight: bold\">true<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\">\/\/ next one is the physical path to your forums root : CUSTOMIZE<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000088\">$phpbb_root_path<\/span> <span style=\"color: #339933\">=<\/span> <span style=\"color: #0000ff\">'\/home\/user\/you\/forums\/'<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">include<\/span><span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$phpbb_root_path<\/span> <span style=\"color: #339933\">.<\/span> <span style=\"color: #0000ff\">'extension.inc'<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">include<\/span><span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$phpbb_root_path<\/span> <span style=\"color: #339933\">.<\/span> <span style=\"color: #0000ff\">'common.'<\/span><span style=\"color: #339933\">.<\/span><span style=\"color: #000088\">$phpEx<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\">\/\/ Start session<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000088\">$userdata<\/span> <span style=\"color: #339933\">=<\/span> session_pagestart<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$user_ip<\/span><span style=\"color: #339933\">,<\/span> PAGE_INDEX<span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">init_userprefs<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$userdata<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #666666;font-style: italic\">\/\/ From now on, we have user infos<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #b1b100\">if<\/span> <span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$userdata<\/span><span style=\"color: #339933\">&amp;<\/span><span style=\"color: #666666;font-style: italic\">#91;'session_logged_in'&amp;#93;) {<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"> &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #b1b100\">echo<\/span> <span style=\"color: #0000ff\">&quot;You are : &quot;<\/span><span style=\"color: #339933\">.<\/span><span style=\"color: #000088\">$userdata<\/span><span style=\"color: #339933\">&amp;<\/span><span style=\"color: #666666;font-style: italic\">#91;'username'&amp;#93; .&quot; (&quot;.$userdata&amp;#91;'user_email'&amp;#93;.&quot;)&lt;br&gt;\\n&quot;;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"> &nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #b1b100\">echo<\/span> <span style=\"color: #0000ff\">&quot;Userid : &quot;<\/span><span style=\"color: #339933\">.<\/span><span style=\"color: #000088\">$userdata<\/span><span style=\"color: #009900\">&#091;<\/span><span style=\"color: #0000ff\">'user_id'<\/span><span style=\"color: #009900\">&#093;<\/span><span style=\"color: #339933\">.<\/span><span style=\"color: #0000ff\">&quot;&lt;br&gt;<span style=\"color: #000099;font-weight: bold\">\\n<\/span>&quot;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&#125;<\/span> <span style=\"color: #b1b100\">else<\/span> <span style=\"color: #009900\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #b1b100\">echo<\/span> <span style=\"color: #0000ff\">&quot;Not logged !&quot;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #000000;font-weight: bold\">?&gt;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\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}]}}