<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>thedeadone.net &#187; Pligg</title>
	<atom:link href="http://thedeadone.net/tag/pligg/feed/" rel="self" type="application/rss+xml" />
	<link>http://thedeadone.net</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 13:04:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Add a &#8220;pligg it&#8221; button to your webpage!</title>
		<link>http://thedeadone.net/how-to/add-a-pligg-it-button-to-your-webpage/</link>
		<comments>http://thedeadone.net/how-to/add-a-pligg-it-button-to-your-webpage/#comments</comments>
		<pubDate>Tue, 07 Nov 2006 10:00:18 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Game-Crafters-Guild]]></category>
		<category><![CDATA[Pligg]]></category>
		<category><![CDATA[Redbrick]]></category>

		<guid isPermaLink="false">http://thedeadone.net/news/add-a-pligg-it-button-to-your-webpage/</guid>
		<description><![CDATA[Found this neat little feature in Pligg that allows you to easily add a link to Pligg. The simple code can be expanded so you can add a button to your webpage that allows it to be easily submitted to Pligg. It&#8217;s not world-shattering, nor is it an unusual feature to find. However, if your [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>Found this neat little feature in <a HREF="http://www.pligg.com">Pligg</a> that allows you to easily add a link to Pligg. The simple code can be expanded so you can add a button to your webpage that allows it to be easily submitted to Pligg. It&#8217;s not world-shattering, nor is it an unusual feature to find.</p>
<p>However, if your a <a HREF="http://www.redbrick.dcu.ie">Redbrick Member</a> you could add this piece of code to any of your webpages that would all you or another Redbrick user to submit it to Pligg.</p>
<p><a HREF="javascript:q=(document.location.href);void(open('http://www.redbrick.dcu.ie/~cammy/pig/submit.php?url='+escape(q),'','resizable,location,menubar,toolbar,scrollbars,status'));">Submit this to Redbrick Pligg!</a></p>
<p>If you want, you can replace &#8220;document.location.href&#8221; with an explicit URL. I guess what we really need is a icon for Redbrick Pligg!</p>
<p>I&#8217;m considering adding it to <a HREF="http://planet.redbrick.dcu.ie">Planet Redbrick</a> and <a HREF="http://wiki.redbrick.dcu.ie">Redbrick Wiki</a>. Is it a good idea? I could package it up in a <a HREF="http://wordpress.org">WordPress</a> plugin but I don&#8217;t know how many Redbrick Bloggers use WordPress.</p>
<p>The same also applies for <a HREF="http://www.gamecraftersguild.com/p/">Game Crafter&#8217;s Guild&#8217;s Pligg</a>, however this Pligg is specifically for Gaming and Roleplaying related content, and we don&#8217;t have an icon either!</p>
<p><a HREF="javascript:q=(document.location.href);void(open('http://www.gamecraftersguild.com/p/submit.php?url='+escape(q),'','resizable,location,menubar,toolbar,scrollbars,status'));">Submit to Game Crafter&#8217;s Guild&#8217;s Pligg!</a><br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/blog/a-thought-exercise-redbrick-web-20/' title='A thought-exercise: Redbrick &#8220;Web 2.0&#8243;'>A thought-exercise: Redbrick &#8220;Web 2.0&#8243;</a></li>
<li><a href='http://thedeadone.net/blog/frustrating/' title='Frustrating!'>Frustrating!</a></li>
<li><a href='http://thedeadone.net/how-to/integrating-pligg-beta-810-with-wordpress-204/' title='Integrating Pligg beta 8.1.0 with WordPress 2.0.4 (v1.1)'>Integrating Pligg beta 8.1.0 with WordPress 2.0.4 (v1.1)</a></li>
<li><a href='http://thedeadone.net/how-to/integrating-pligg-beta-810-with-pubcookie/' title='Integrating Pligg beta 8.1.0 with PubCookie'>Integrating Pligg beta 8.1.0 with PubCookie</a></li>
<li><a href='http://thedeadone.net/blog/a-new-look-for-thedeadonenet/' title='A new look for thedeadone.net'>A new look for thedeadone.net</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/how-to/add-a-pligg-it-button-to-your-webpage/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A thought-exercise: Redbrick &#8220;Web 2.0&#8243;</title>
		<link>http://thedeadone.net/blog/a-thought-exercise-redbrick-web-20/</link>
		<comments>http://thedeadone.net/blog/a-thought-exercise-redbrick-web-20/#comments</comments>
		<pubDate>Thu, 02 Nov 2006 20:44:50 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Jabber]]></category>
		<category><![CDATA[Planet]]></category>
		<category><![CDATA[Pligg]]></category>
		<category><![CDATA[Redbrick]]></category>
		<category><![CDATA[thoughts]]></category>
		<category><![CDATA[Vanilla]]></category>
		<category><![CDATA[Web-2.0]]></category>
		<category><![CDATA[Wiki]]></category>

		<guid isPermaLink="false">http://thedeadone.net/news/a-thought-exercise-redbrick-web-20/</guid>
		<description><![CDATA[I originally posted this on the Redbrick babble newsgroup. If you don&#8217;t know what Redbrick is, this entry will have little interest to you. However, I&#8217;m posting it here because I think it&#8217;s interesting and also I&#8217;m hoping that it might filter out to some of the other Redbrick users who don&#8217;t use the newsgroups. [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>I originally posted this on the <a HREF="http://www.redbrick.dcu.ie/">Redbrick</a> babble newsgroup. If you don&#8217;t know what Redbrick is, this entry will have little interest to you. However, I&#8217;m posting it here because I think it&#8217;s interesting and also I&#8217;m hoping that it might filter out to some of the other Redbrick users who don&#8217;t use the newsgroups.</p>
<p><span id="more-264"></span></p>
<p>I&#8217;ve recently setup <a HREF="http://www.redbrick.dcu.ie/~cammy/pig/">Pligg</a> for Redbrick. It&#8217;s only available to Redbrick users and you can only login with your Redbrick user name and password, thanks to the power of PubCookie. I only did this as a demo. I wanted Pligg for something else, but a few people have started using it.</p>
<p>Anyway, because of that some users had suggested Redbrick&#8217;s services are not very well integrated. There all little distinct bits and bobs, not really connected or talking to each other. i.e. There not &#8220;Web 2.0&#8243;. Now I think &#8220;Web 2.0&#8243; is one of those bullshit phrases, however, the idea of integrated services much like MySpace is an interesting idea and I started thinking, a thought-exercise if you will. Here is how I would see Redbrick becoming &#8220;Web 2.0&#8243;&#8230;</p>
<p>BTW Any software I suggest is only because I&#8217;m familiar and have in some capacity setup, hacked or modified. I&#8217;m not saying they are the best in class, only that I know what can and can&#8217;t be done with them.</p>
<h2>Backwards Compatibility</h2>
<p>Forget it. The first thing to do is, get rid of the newsgroups. Why? Well any new service setup has to integrate with the newsgroups or worse&#8230; synchronise in some fashion. This is never well done and discourages use of the new service as people revert back to what works. Also, because it&#8217;s a set of newsgroups, readable via only an archaic text browser, it&#8217;s impossible to take advantage of the many new web-based applications (like Pligg) and integrate them to give a complete feel. You can&#8217;t extend newsgroups with new features!</p>
<p>Also our newsgroups do not archive and do allow us to reference a post in other software. A big pain if you want to integrate with something like Pligg and allow people to submit their &#8220;posts&#8221; for voting, for example. (On the flip-side it means there is nothing to save making it easier to ditch).</p>
<p>Then there are the inevitable comparisons. &#8220;This software sucks because it doesn&#8217;t do XYZ feature in SLRN&#8221;. I&#8217;ve heard arguments in the past in a different community on a mailing list from people who stubbornly didn&#8217;t want to have a web forum, cries of &#8220;splitting the community!&#8221; and that email is so much better than using a web interface. Do you see me shedding any tears? And there is also the social aspect to consider, people use it because they know it and <strong>everyone</strong> else is using it. Until the majority <strong>stop</strong> using it, the majority won&#8217;t move.</p>
<p>I&#8217;ll come to &#8220;hey&#8221; in a minute&#8230;</p>
<p>I&#8217;d like to point out that I&#8217;m not advocating that Redbrick does this, only that this is probably what is needed to &#8220;move forward&#8221; into Web2.0.  I don&#8217;t think Redbrick would need to get rid of all its technical<br />
services like shell access, user webspace, vhosting, etc. to do this either. Both can easily live side by side.</p>
<p>Now that we can start with a clean slate, what should Redbrick 2.0 do?</p>
<h2>Now What?</h2>
<p>The boards formed the social centre point for the users of Redbrick software. So to replace the newsgroups, we need a web forum. One that&#8217;s extendable, hackable and just plain cool. My personal preference is for <a HREF="http://getvanilla.com">Vanilla (http://getvanilla.com)</a> which is a very nice looking piece of software and is certainly not like phpBB. We need to be able to easily extend the software and I&#8217;ve played with Vanilla and it&#8217;s quite easy to extend. It&#8217;s built on adding &#8220;extensions&#8221; and has extensions for RSS feeds, permalinks, signatures, bookmarked discussions, blocking categories, threads and users, etc. I haven&#8217;t tried integrating it with Vanilla but I&#8217;m pretty confident it can be done.</p>
<p>BTW It does have a spell checker plugin. This uses GoogleSpell, however it won&#8217;t work on Redbrick because it won&#8217;t work through the proxy with https. We&#8217;ll need to get curl installed on PHP to do it.</p>
<p>Now we can start integrating the other services. Let&#8217;s start with Pligg. To integrate with the Vanilla forum, we need to make a &#8220;virtual&#8221; category that actually submits a story to Pligg. A simple approach would be to create a theme for Pligg that matches the forum and then create an extension for Vanilla that shows Pligg has a category. Submission and voting would be still via Pligg.</p>
<p>With the <a HREF="http://wiki.redbrick.dcu.ie">Wiki</a>, it depends on the level of integration we want. MediaWiki is a monster of a piece of software. Modifying the look and feel is a headache. The most basic integration would be that the &#8220;Talk Pages&#8221; actually go to discussions on the forum. This could be just redirection or something more integrated. I don&#8217;t particularly like the idea of importing Wiki entries from discussions posts or threads (or vice versa) but you could easily write an extension to autolink to Redbrick Wiki entries and there is a Wiki markup plugin available for Vanilla.</p>
<p>As for <a HREF="http://planet.redbrick.dcu.ie">Planet</a>&#8230; well Planet is good for the combined Redbrick Blogs feed. The best thing to do is have entries in Planet submitted as new stories to Pligg. The interesting ones get voted up and become &#8220;published&#8221;. It is questionable though if you want to provide users with web services like blogs, if they should be automatically submitted to Planet and Pligg or should it be an opt-in/out like service.</p>
<h2>Chatting</h2>
<p><a HREF="http://hey.redbrick.dcu.ie">&#8220;Hey&#8221;</a>: the other corner stone of Redbrick. It&#8217;s great now that <a HREF="http://www.redbrick.dcu.ie/jabber">Redbrick has a Jabber server</a>. Why do we need Hey? For the same reasons as the newsgroups, why do we need to have a Jabber to Hey service?</p>
<p>I think people would need to start using Jabber more, in fact exclusively. Jabber and some magic web coding could be the greatest replacement for Hey. Like <a HREF="http://gmail.google.com">Gmail</a>, when you&#8217;re browsing the new Web2.0 Redbrick forum, signed in to Pligg or the Wiki, you could have a &#8220;chat&#8221; window popup when someone tries to talk to you. It would be nice that you can also use Jabber to &#8220;hey&#8221; someone who happens to be logged in using a shell.</p>
<p>As for IRC and chat services&#8230; well, em, I don&#8217;t really use them too much. I leave that up to someone else.</p>
<h2>Tagging</h2>
<p>&#8220;Tagging&#8221; stuff on Redbrick would be the big thing or the most challenging. Tags can be just superficial and give a nice visualisation/&#8221;tag cloud&#8221; of Redbrick or they can be useful like in Flickr where people use tags to group stuff.</p>
<p>You need some sort of API or service that would allow Redbrick users to freely add and remove tags from any forum thread, wiki page, pligg entry and possible from user&#8217;s webpages and blogs. I&#8217;m sure it can be done but it&#8217;d need some thought.</p>
<h2>Making it look the same</h2>
<p>I think this is a pretty major and important thing. If the services are integrated, they need to look the same. However this isn&#8217;t challenging. It&#8217;s just a lump of work that someone would have to do.</p>
<h2>Frontpage or rather, bringing it all together</h2>
<p>Yea. Redbrick Frontpage. If we&#8217;re going to have all these services really tightly integrated, the frontpage is the place to bring it together. This isn&#8217;t just &#8220;links&#8221; but rather a summary of the latest Wiki pages, new forum threads, published pliggs, etc. But that&#8217;s not all though, I mean if you&#8217;re like me, you&#8217;ll pick and choose the RSS feeds you want and never have to visit the Redbrick frontpage.</p>
<p>The frontpage has to encourage discussion, commentary, etc. In a sense, it should be more &#8220;blog&#8221; like. News should have comments and trackbacks so we know Redbrick bloggers are interested. It should have an RSS feed as basic! Podcasts and guest blog entries from Redbrick users. Rants from Associates, etc. Moderated by the current committee/admins. A sort of &#8220;best of Redbrick&#8221;, kind of place.</p>
<h2>Conclusion</h2>
<p>Why bother? Everything works well enough for us now. <img src='http://thedeadone.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/blog/who-reads-this-blog-anyway/' title='Who reads this blog anyway?'>Who reads this blog anyway?</a></li>
<li><a href='http://thedeadone.net/lj/add-a-pligg-it-button-to-your-webpage/' title='Add a &#8220;pligg it&#8221; button to your webpage!'>Add a &#8220;pligg it&#8221; button to your webpage!</a></li>
<li><a href='http://thedeadone.net/blog/frustrating/' title='Frustrating!'>Frustrating!</a></li>
<li><a href='http://thedeadone.net/how-to/integrating-pligg-beta-810-with-pubcookie/' title='Integrating Pligg beta 8.1.0 with PubCookie'>Integrating Pligg beta 8.1.0 with PubCookie</a></li>
<li><a href='http://thedeadone.net/blog/258/' title='Dubliners and &#8220;Blow-ins&#8221;'>Dubliners and &#8220;Blow-ins&#8221;</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/blog/a-thought-exercise-redbrick-web-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating Pligg beta 8.1.0 with WordPress 2.0.4 (v1.1)</title>
		<link>http://thedeadone.net/how-to/integrating-pligg-beta-810-with-wordpress-204/</link>
		<comments>http://thedeadone.net/how-to/integrating-pligg-beta-810-with-wordpress-204/#comments</comments>
		<pubDate>Tue, 17 Oct 2006 10:59:18 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Game-Crafters-Guild]]></category>
		<category><![CDATA[Pligg]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://thedeadone.net/software/integrating-pligg-beta-810-with-wordpress-204/</guid>
		<description><![CDATA[I&#8217;ve managed to get Pliggto use WordPress authentication and user database. You can see it running on the Game Crafter&#8217;s Guild website. I recently got Pligg using Pubcookie and that formed the basis of this work, however they are very different. I&#8217;ve only tested this with Pligg Beta 8.1.0. I believe future versions may have [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>I&#8217;ve managed to get <a href="http://www.pligg.com/">Pligg</a>to use <a href="http://wordpress.org">WordPress</a> authentication and user database. You can see it running on the <a href="http://gamecraftersguild.com/p">Game Crafter&#8217;s Guild website</a>.</p>
<p>I recently got <a href="http://thedeadone.net/software/integrating-pligg-beta-810-with-pubcookie/">Pligg using Pubcookie</a> and that formed the basis of this work, however they are very different.</p>
<p>I&#8217;ve only tested this with Pligg Beta 8.1.0. I believe future versions may have a better approach for external authentication so I can&#8217;t guarantee this will work with future versions.<br />
<span id="more-260"></span><br />
This approach is very &#8220;hacky&#8221;. I&#8217;ve also been slightly lazy. It assumes that you will use WordPress&#8217; login, logout and register pages. This will break the existing login, logout and register forms in Pligg. The ultimate solution would allow the Pligg forms to login and logout also on WordPress and the register form to create new users in WordPress.</p>
<p>It also does not attempt to merge the user databases from WordPress and Pligg together. Instead they are left seperate. This means that administrators have two places to manage users. If you want to delete a user, you&#8217;ve got to delete them from WordPress and Pligg seperately.</p>
<p>I&#8217;ve done previous external application integrations with WordPress, most notable with <a href="http://thedeadone.net/software/getting-dokuwiki-to-use-wordpress-authentication/">DokuWiki</a>. In these previous case, I was able to allow the use of WordPress template tags in DokuWiki. However, in the case of Pligg, it is not possible as there are several function name clashes. Pligg and WordPress are considered CMSs (Content Management Systems) and it is inevitable that function names and variables clash.</p>
<h2>Version History</h2>
<h3>1.1 (19/10/2006)</h3>
<p>Stray header redirection in login.php removed.</p>
<h3>1.0 (17/09/2006)</h3>
<p>First Release</p>
<h2>Installation locations</h2>
<p>The first thing to do is decide on where you will install Pligg and WordPress. Pligg must be installed in either a directory on the same level as WordPress or a subdirectory of WordPress. In my code examples, I&#8217;ve installed WordPress and Pligg on the same level. I will refer to the WordPress directory as &#8220;wp&#8221; and Pligg as &#8220;p&#8221;. So, for reference, I have Pligg and WordPress installed like this:</p>
<pre>
/public_html/wp
/public_html/p
</pre>
<p>Equally valid would be:</p>
<pre>
/public_html/wp
/public_html/wp/p
</pre>
<p>Pligg and WordPress should be part of the same domain. Otherwise the WordPress cookies won&#8217;t be picked up by Pligg.</p>
<h2>Installing the software</h2>
<p>Install WordPress normally and configured it how you will. Make sure it&#8217;s all working. Make a not eof your database prefix and site url. You can get your database prefix from &#8216;wp-config.php&#8217;. It is the &#8216;$table_prefix&#8217; variable. Your site url (or URI if you want to be pedantic), is where you access WordPress from. You can get the exact value from your &#8220;Options&#8221;, &#8220;General&#8221; panel when you log in to WordPress as admin. Your site url should have no trailing slash. It is important you get this right as you won&#8217;t be able to log in to Pligg later otherwise. For example, if you install into a different directory, then your webpage&#8217;s url will be different from your WordPress url.</p>
<p>Now install Pligg, but use the same database. Make sure everything is working, in particular that you can log in using the &#8220;god&#8221; account.</p>
<h2>Modifying Pligg</h2>
<p>All the work to modify Pligg takes place in &#8216;libs/login.php&#8217;. What we want to do is get Pligg to login using WordPress cookies/authentication. If the user doesn&#8217;t yet exist in Pligg, create it. Also, copy over all the existing user data to the Pligg database. We won&#8217;t be using Pligg&#8217;s login, authentication or logout any more.</p>
<p>However, we can&#8217;t just include wordpress and call wordpress functions. Instead, we&#8217;re going to have to do it manually. What I&#8217;ve done is added a function called is_user_logged_onto_wp(), which does all the extra work.</p>
<p>Here is the modified &#8216;libs/login.php&#8217;. Make sure to correctly set the $wp_db_prefix to your database prefix (including the underscore) and $wp_siteurl to your WordPress url.</p>
<p>< ?php<br />
// The source code packaged with this file is Free Software, Copyright (C) 2005 by<br />
// Ricardo Galli <gallir at uib dot es>.<br />
// It&#8217;s licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.<br />
// You can get copies of the licenses here:<br />
// 		http://www.affero.org/oagpl.html<br />
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called &#8220;COPYING&#8221;.<br />
// Modified by Mark Cunningham <mark dot cunningham at gmail dot com><br />
// (http://thedeadone.net). Log in using WordPress<br />
// WordPress path (you don&#8217;t really need this)<br />
//if(!defined(&#8216;WP_ROOT&#8217;)) define(&#8216;WP_ROOT&#8217;, mnmpath.&#8217;/../wp/&#8217;);<br />
//<br />
// Can&#8217;t do this, sadly as &#8220;get_permalink&#8221; collides in both code bases.<br />
// Must do everything manually!<br />
//require_once WP_ROOT.&#8217;wp-config.php&#8217;;<br />
$wp_db_prefix = &#8220;wp_&#8221;;<br />
$wp_siteurl = &#8220;http://www.myblog.com/wp&#8221;;<br />
// Generate cookie keys!<br />
if( !defined(&#8216;WP_COOKIEHASH&#8217;) ) {<br />
   // this value should be the same as siteurl<br />
   $cookiehash = md5($wp_siteurl);<br />
   define(&#8216;WP_COOKIEHASH&#8217;, $cookiehash);<br />
}<br />
if ( !defined(&#8216;WP_USER_COOKIE&#8217;) )<br />
   define(&#8216;WP_USER_COOKIE&#8217;, &#8216;wordpressuser_&#8217;. WP_COOKIEHASH);<br />
if ( !defined(&#8216;WP_PASS_COOKIE&#8217;) )<br />
   define(&#8216;WP_PASS_COOKIE&#8217;, &#8216;wordpresspass_&#8217;. WP_COOKIEHASH);<br />
// TODO: storing copy of password in pligg?<br />
class UserAuth {<br />
	var $user_id  = 0;<br />
	var $user_login = &#8220;&#8221;;<br />
	var $md5_pass = &#8220;&#8221;;<br />
	var $authenticated = FALSE;<br />
    function is_user_logged_onto_wp(){<br />
        global $db, $wp_db_prefix;<br />
        // Most of this stuff I&#8217;ve taken (and modified) from WordPress codebase<br />
        // Do we have a username and password?<br />
	    if ( !empty($_COOKIE[WP_USER_COOKIE]) &#038;&#038; !empty($_COOKIE[WP_PASS_COOKIE]) ){<br />
	       $wp_username = $_COOKIE[WP_USER_COOKIE];<br />
	       $wp_password = $_COOKIE[WP_PASS_COOKIE];<br />
           // Does the user exist in wordpress?<br />
           if(!$wp_user = $db->get_row(&#8220;SELECT * FROM &#8220;.$wp_db_prefix.&#8221;users WHERE user_login = &#8216;$wp_username&#8217;&#8221;)){<br />
              // User doesn&#8217;t exist in wordpress&#8230; so&#8230;<br />
              // &#8230; should I delete this user in Pligg?<br />
              echo &#8220;<strong><font color=\"red\">This user $wp_username does not exist in WordPress!</font></strong><br />&#8220;;<br />
              return false;<br />
           }<br />
           // Grab data for user<br />
           $wp_userdata = $db->get_results(&#8220;SELECT meta_key, meta_value FROM &#8220;.$wp_db_prefix.&#8221;usermeta WHERE user_id = &#8216;$wp_user->ID&#8217;&#8221;);<br />
           if ($wp_userdata) {<br />
		      foreach ( $wp_userdata as $meta ) {<br />
		   	     @ $value = unserialize($meta->meta_value);<br />
		   		 if ($value === FALSE)<br />
		   		    $value = $meta->meta_value;<br />
		   		    $wp_user->{$meta->meta_key} = $value;<br />
		   			// We need to set user_level from meta, not row<br />
		   			if ( $wp_db_prefix.&#8221;user_level&#8221; == $meta->meta_key )<br />
		   				$wp_user->user_level = $meta->meta_value;<br />
		   		}<br />
		   }<br />
		   // Check if username and password are valid!<br />
		   if ( md5($wp_user->user_pass) != $wp_password) {<br />
		      // bad password!<br />
		      echo &#8220;<strong><font color=\"red\">Bad password in cookie for $wp_username!</font></strong><br />&#8220;;<br />
		      return false;<br />
		   }<br />
           // Okay, user exists and _is_ logged into wordpress!<br />
	       // check if user exists in pligg!<br />
		   $ok = 1;<br />
		   // if a user doesn&#8217;t exit&#8230; create the user<br />
		   if(!user_exists($wp_username)){<br />
		     $userip = $_SERVER['REMOTE_ADDR'];<br />
		     $ok = $db->query(&#8220;INSERT INTO users (user_login, user_email, user_pass, user_date, user_ip) VALUES (&#8216;$wp_username&#8217;, &#8216;$wp_user->user_email&#8217;, &#8216;password&#8217;, now(), &#8216;$userip&#8217;)&#8221;);<br />
		   }<br />
		   // if user creation was okay or user was already created, sync and log in<br />
		   if($ok) {<br />
               // grab pligg user data<br />
			   $user=$db->get_row(&#8220;SELECT user_id, user_pass, user_login FROM users WHERE user_login = &#8216;$wp_username&#8217;&#8221;);<br />
			   // Copy user data from wordpress!<br />
			   $sql  = &#8220;UPDATE users set &#8220;;<br />
			   // admins should be set as &#8220;god&#8221; in pligg. What other levels should be mapped?<br />
               if($wp_user->user_level >= &#8217;10&#8242;){<br />
                  $sql .= &#8220;user_level=&#8217;god&#8217;, &#8220;;<br />
               } else {<br />
                  $sql .= &#8220;user_level=&#8217;normal&#8217;, &#8220;;<br />
               }<br />
               $sql .= &#8220;user_date=&#8217;$wp_user->user_registered&#8217;, &#8220;;<br />
			   $sql .= &#8220;user_url=&#8217;$wp_user->user_url&#8217;, &#8220;;<br />
			   $sql .= &#8220;user_aim=&#8217;$wp_user->user_aim&#8217;, &#8220;;<br />
			   $sql .= &#8220;user_yahoo=&#8217;$wp_user->user_yim&#8217;, &#8220;;<br />
               $sql .= &#8220;user_gtalk=&#8217;$wp_user->jabber&#8217;, &#8220;;<br />
               $sql .= &#8220;user_email=&#8217;$wp_user->user_email&#8217; &#8220;;<br />
               $sql .= &#8220;WHERE user_id=$user->user_id&#8221;;<br />
               // there are other fields in pligg that don&#8217;t exist in wordpress.<br />
               // Just ignoring them for the time being.<br />
               $db->query($sql);<br />
               // These are required for login to Pligg<br />
               $this->user_login = $user->user_login;<br />
			   $this->user_id = $user->user_id;<br />
			   $this->authenticated = TRUE;<br />
			   $this->md5_pass = md5($user->user_pass);<br />
			   $this->SetIDCookie(1, false);<br />
               // Oh, don&#8217;t forget to log the ip!<br />
			   $lastip=$_SERVER['REMOTE_ADDR'];<br />
			   mysql_query(&#8220;UPDATE users SET user_lastip = &#8216;$lastip&#8217; WHERE user_id = {$user->user_id} LIMIT 1&#8243;);<br />
			   mysql_query(&#8220;UPDATE users SET user_lastlogin = now() WHERE user_id = {$user->user_id} LIMIT 1&#8243;);<br />
               // All good!<br />
			   return true;<br />
	       }<br />
	       else<br />
	       {<br />
	          echo &#8220;<strong><font color=\"red\">Problem creating user in Pligg!</font></strong><br />&#8220;;<br />
	       }<br />
	    }<br />
	    else<br />
	    {<br />
	       //debug<br />
	       //echo &#8220;<strong>No wordpress user found!</strong><br />&#8220;;<br />
	    }<br />
	    return false;<br />
    }<br />
    function UserAuth() {<br />
		global $db;<br />
        // Are we logged into wordpress?<br />
        // Don&#8217;t do anything unless we are!<br />
        if($this->is_user_logged_onto_wp()){<br />
			if(isset($_COOKIE['mnm_user']) &#038;&#038; isset($_COOKIE['mnm_key']) &#038;&#038; $_COOKIE['mnm_user'] !== &#8221;) {<br />
				// Si ya está autentificado de antes, rellenamos la estructura.<br />
				$userInfo=explode(&#8220;:&#8221;, base64_decode($_REQUEST['mnm_key']));<br />
				if(crypt($userInfo[0], 22)===$userInfo[1]<br />
					&#038;&#038; $_COOKIE['mnm_user'] === $userInfo[0]) {<br />
					$dbusername = $db->escape($_COOKIE['mnm_user']);<br />
					$dbuser=$db->get_row(&#8220;SELECT user_id, user_pass, user_level FROM users WHERE user_login = &#8216;$dbusername&#8217;&#8221;);<br />
					if($dbuser->user_id > 0 &#038;&#038; md5($dbuser->user_pass)==$userInfo[2]) {<br />
						$this->user_id = $dbuser->user_id;<br />
						$this->user_level = $dbuser->user_level;<br />
						$this->user_login  = $userInfo[0];<br />
						$this->md5_pass = $userInfo[2];<br />
						$this->authenticated = TRUE;<br />
					}<br />
				}<br />
			}<br />
	    // Logout of Pligg if not logged in to wordpress<br />
		} else {<br />
		   $this->user_login = &#8220;&#8221;;<br />
		   $this->authenticated = FALSE;<br />
		   $this->SetIDCookie (0,false);<br />
		   header(&#8220;Cache-Control: no-cache, must-revalidate&#8221;);<br />
		   header(&#8220;Expires: &#8221; . gmdate(&#8220;r&#8221;, time()-3600));<br />
		}<br />
	}<br />
	function SetIDCookie($what, $remember) {<br />
		switch ($what) {<br />
			case 0:	// Borra cookie, logout<br />
				setcookie (&#8220;mnm_user&#8221;, &#8220;&#8221;, time()-3600, &#8220;/&#8221;); // Expiramos el cookie<br />
				setcookie (&#8220;mnm_key&#8221;, &#8220;&#8221;, time()-3600, &#8220;/&#8221;); // Expiramos el cookie<br />
				break;<br />
			case 1: //Usuario logeado, actualiza el cookie<br />
				// Atencion, cambiar aqu?cuando se cambie el password de base de datos a MD5<br />
				$strCookie=base64_encode(join(&#8216;:&#8217;,<br />
					array(<br />
						$this->user_login,<br />
						crypt($this->user_login, 22),<br />
						$this->md5_pass)<br />
					)<br />
				);<br />
				if($remember) $time = time() + 3600000; // Lo dejamos v?idos por 1000 horas<br />
				else $time = 0;<br />
				setcookie(&#8220;mnm_user&#8221;, $this->user_login, $time, &#8220;/&#8221;);<br />
				setcookie(&#8220;mnm_key&#8221;, $strCookie, $time, &#8220;/&#8221;);<br />
				break;<br />
		}<br />
	}<br />
	function Authenticate($username, $pass, $remember=false) {<br />
		global $db;<br />
		$dbusername=$db->escape($username);<br />
		$user=$db->get_row(&#8220;SELECT user_id, user_pass, user_login FROM users WHERE user_login = &#8216;$dbusername&#8217;&#8221;);<br />
		$saltedpass=generateHash($pass, substr($user->user_pass, 0, SALT_LENGTH));<br />
		if ($user->user_id > 0 &#038;&#038; $user->user_pass === $saltedpass) {<br />
			$this->user_login = $user->user_login;<br />
			$this->user_id = $user->user_id;<br />
			$this->authenticated = TRUE;<br />
			$this->md5_pass = md5($user->user_pass);<br />
			$this->SetIDCookie(1, $remember);<br />
			$lastip=$_SERVER['REMOTE_ADDR'];<br />
			mysql_query(&#8220;UPDATE users SET user_lastip = &#8216;$lastip&#8217; WHERE user_id = {$user->user_id} LIMIT 1&#8243;);<br />
            mysql_query(&#8220;UPDATE users SET user_lastlogin = now() WHERE user_id = {$user->user_id} LIMIT 1&#8243;);<br />
			return true;<br />
		}<br />
		return false;<br />
	}<br />
	function Logout($url=&#8217;./&#8217;) {<br />
		$this->user_login = &#8220;&#8221;;<br />
		$this->authenticated = FALSE;<br />
		$this->SetIDCookie (0);<br />
		//header(&#8220;Pragma: no-cache&#8221;);<br />
		header(&#8220;Cache-Control: no-cache, must-revalidate&#8221;);<br />
		header(&#8220;Location: $url&#8221;);<br />
		header(&#8220;Expires: &#8221; . gmdate(&#8220;r&#8221;, time()-3600));<br />
		header(&#8220;ETag: \&#8221;logingout&#8221; . time(). &#8220;\&#8221;");<br />
		die;<br />
	}<br />
}<br />
$current_user = new UserAuth();<br />
?><br />
[/soure]</p>
<p>Now login to wordpress and go to your Pligg frontpage. You may have to reload, but you should be automatically logged into Pligg! Remember, don&#8217;t use Pligg&#8217;s login or logout any more. I&#8217;ll deal with what you need to change in the templates to handle that soon. If you use your wordpress admin account, you&#8217;ll have full &#8216;god&#8217; mode in Pligg.</p>
<h2>Final modifications</h2>
<p>Your site isn&#8217;t fully secure yet. Delete &#8216;register.php&#8217; so that no-one can create accounts using Pligg. We can also simply remove &#8216;login.php&#8217; but lets not be so drastic. Lets modify &#8216;login.php. Look for these lines:</p>
<p>1<br />
if($_POST["processlogin"] == 1) {<br />
                $username = trim($_POST['username']);<br />
                $password = trim($_POST['password']);<br />
                $persistent = $_POST['persistent'];<br />
                if($current_user->Authenticate($username, $password, $persisten$<br />
                        $errorMsg=PLIGG_Visual_Login_Error;} else {<br />
                        if(strlen($_REQUEST['return']) > 1) {<br />
                                header(&#8216;Location: &#8216;.$_REQUEST['return']);<br />
                        } else {<br />
                                header(&#8216;Location: &#8216;.my_pligg_base.&#8217;/');<br />
                        }<br />
                        die;<br />
                }<br />
        }</p>
<p>We want to prevent hackers from using direct URLs to log in. So comment out the normal authentication test, as below.</p>
<p>if($_POST["processlogin"] == 1) {<br />
                $username = trim($_POST['username']);<br />
                $password = trim($_POST['password']);<br />
                $persistent = $_POST['persistent'];<br />
                if($current_user->Authenticate($username, $password, $persisten$<br />
                        $errorMsg=PLIGG_Visual_Login_Error;} else {<br />
                        if(strlen($_REQUEST['return']) > 1) {<br />
                                header(&#8216;Location: &#8216;.$_REQUEST['return']);<br />
                        } else {<br />
                                header(&#8216;Location: &#8216;.my_pligg_base.&#8217;/');<br />
                        }<br />
                        die;<br />
                }<br />
        }</p>
<p>Pligg also comes preconfigured with one special user account, the &#8220;god&#8221; account. You can&#8217;t delete this account via the admin interface. You can create the &#8220;god&#8221; account in WordPress to prevent some user creating it and gaining &#8220;god&#8221; rights on Pligg. Or if you know sql or have access some sort of web access to your database, you can rename the &#8220;god&#8221; account to match the username of an existing admin user or delete the user outright.</p>
<h2>Required Template Changes</h2>
<p>So, now your WordPress users can log in on WordPress and then be automatically logged in to Pligg. But you&#8217;ve got to point the login, logout and register links to your WordPress equivelents. If your happy enough modifying the template then your ready to go. However, heres a run down of the minimal changes required to make sure it&#8217;s okay.</p>
<p>Lets create a copy of the existing template, mollio-beat. To do this, just make a copy of &#8216;templates/mollio-beat&#8217; in &#8216;templates/&#8217; (including all subdirectories). Make sure the permissions are correct, etc. I renamed this copy &#8220;gcg1&#8243; (for Game Crafters Guild version1), so I now had a &#8216;template/gcg1&#8242;. I went into the admin interface in Pligg and under the Template configuration, changed &#8216;mollio-beat&#8217; to &#8216;gcg1&#8242; and disabled the option that lets users change the template. We don&#8217;t want users being able to go back to the old way of authentication.</p>
<p>We can&#8217;t use WordPress template tags. You can always write PHP and SQL code that access the data manually in your database if your that way inclined. This means we have to use direct links.</p>
<h3>template/gcg1/header.tpl</h3>
<p>Open up &#8216;template/gcg1/header.tpl&#8217;. Look for these lines:</p>
<li class="last"><a href="{$URL_logout}">{#PLIGG_Visual_Logout#}</a></li>
<p>{else}</p>
<li><a href="{$URL_login}">{#PLIGG_Visual_Login#}</a></li>
<li class="last"><a href="{$URL_register}">{#PLIGG_Visual_Register#}</a></li>
<p>Change them to:</p>
<li class="last"><a href="{$my_base_url}/wp/wp-login.php?action=logout&#038;redirect_to=<?php echo $_SERVER['REQUEST_URI']; ?>&#8220;>{#PLIGG_Visual_Logout#}</a></li>
<p>{else}</p>
<li><a href="{$my_base_url}/wp/wp-login.php?redirect_to=<?php echo $_SERVER['REQUEST_URI']; ?>&#8220;>{#PLIGG_Visual_Login#}</a></li>
<li class="last"><a href="{$my_base_url}/wp/wp-register.php">{#PLIGG_Visual_Register#}</a></li>
<p><strong>Note</strong>: In my installation of Pligg, I&#8217;ve updated &#8220;my_base_url&#8221; (via the admin interface) correctly. I also have WordPress as a subdirectory of that same base url, so it became a handy shortcut to use &#8216;{$my_base_url}/wp&#8217; to reference any WordPress links directly.</p>
<p>header.tpl controls the header of all the Pligg pages so these changes will make sure those login, logout and register links are fixed across the entire Pligg site.</p>
<h3>template/gcg1/profile_center.tpl</h3>
<p>&#8216;template/gcg1/profile_center.tpl&#8217; controls what users can modify in their profile. We&#8217;ll want to disable as much as possible of this as their profiles are overwritten from WordPress everytime they login.</p>
<p>Some where in the file, add this so users know where to modify their profile:</p>
<p>Please use <a href="{$my_base_url}/wp/wp-admin/">this form</a> to modify your profile.</p>
<p>Delete these lines. Users won&#8217;t be able to modify their passwords here, so remove the option:</p>
<p class="l-mid">{#PLIGG_Visual_Profile_ChangePass#}</p>
<table style="border:none">
<tr>
<td width="30%">
<p class="l-mid"><label for="password">{#PLIGG_Visual_Profile_NewPass#}:</label></p>
<input type="password" id="password" name="password" size="25" tabindex="13"/>
</td>
<td>
<p class="l-mid"><label for="verify">{#PLIGG_Visual_Profile_VerifyNewPass#}: </label></p>
<input type="password" id="verify" name="password2" size="25" tabindex="14"/>
</td>
</tr>
</table>
<p>Now we need to disable the fields that are copied over by wordpress. These are aim, email, yahoo, url and gtalk.</p>
<input name="aim" tabIndex="2" disabled="true" id="aim" />
<input name="email" tabIndex="3" disabled="true" id="email" /><em>{#PLIGG_Visual_Profile_OnlyAdmins#}</em></p>
<input name="yahoo" tabIndex="6" disabled="true" id="yahoo" />
<input name="url" tabIndex="7" disabled="true" id="url" />
<input name="gtalk" tabIndex="8" disabled="true" id="gtalk" />
<h3>template/gcg1/story_center.tpl</h3>
<p>&#8216;template/gcg1/story_center.tpl&#8217; controls the display of individual stories. If a non-logged in user, views a story, they will see a login and logout link!</p>
<p>Replace:</p>
<p align="center" style="clear: both; font-weight: bold; padding-bottom: 8px; margin-left: auto; width: 400px; margin-right: auto; text-align: center; border: #ccc 1px solid" id="commentform"><a href="{$login_url}">{#PLIGG_Visual_Story_LoginToComment#}</a> {#PLIGG_Visual_Story_Register#} <a href="{$register_url}">{#PLIGG_Visual_Story_RegisterHere#}</a>.</p>
<p>With:</p>
<p align="center" style="clear: both; font-weight: bold; padding-bottom: 8px; margin-left: auto; width: 400px; margin-right: auto; text-align: center; border: #ccc 1px solid" id="commentform"><a href="http://thedeadone.net/wp-admin/%7B$my_base_url%7D/wp/wp-login.php?redirect_to=&lt;?php echo $_SERVER['REQUEST_URI']; ?&gt;">Login</a><br />
<a href="{$my_base_url}/wp/wp-register.php">Register</a></p>
<h3>template/gcg1/sidebar/login.tpl</h3>
<p>&#8216;template/gcg1/sidebar/login.tpl&#8217; is the sidebar login form you see. Replace it with this:</p>
<h3>{#PLIGG_Visual_Login_Title#}</h3>
</p>
<p id="register"><a href="{$my_base_url}/wp/wp-register.php">Register</a></p>
<p id="login"><a href="http://thedeadone.net/wp-admin/%7B$my_base_url%7D/wp/wp-login.php?redirect_to=&lt;?php echo $_SERVER['REQUEST_URI']; ?&gt;">Login</a></p>
<h3>template/gcg1/sidebar/logged_in.tpl</h3>
<p>&#8216;template/gcg1/sidebar/logged_in.tpl&#8217; is the sidebar panel you see when logged in. Replace the logout link:</p>
<p><a href="{$URL_logout}">{#PLIGG_Visual_Logout#}</a></p>
<p>With something like this:</p>
<p><a href="http://thedeadone.net/wp-admin/%7B$my_base_url%7D/wp/wp-login.php?action=logout&amp;redirect_to=&lt;?php echo $_SERVER['REQUEST_URI']; ?&gt;">{#PLIGG_Visual_Logout#}</a></p>
<p>I also add a link to the WordPress Admin panel for convience here.</p>
<li><a href="{$my_base_url}/wp/wp-admin/">WP Admin</a></li>
<h2>Ready to go!</h2>
<p>After all these changes, you should be able to login using WordPress only and be logged in on your Pligg page too! If you have any comments, feedback or find any bugs, just leave a comment here. Thanks.</mark><br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/lj/add-a-pligg-it-button-to-your-webpage/' title='Add a &#8220;pligg it&#8221; button to your webpage!'>Add a &#8220;pligg it&#8221; button to your webpage!</a></li>
<li><a href='http://thedeadone.net/blog/frustrating/' title='Frustrating!'>Frustrating!</a></li>
<li><a href='http://thedeadone.net/download/getting-dokuwiki-to-use-wordpress-authentication/' title='Getting DokuWiki to use WordPress Authentication (v1.2)'>Getting DokuWiki to use WordPress Authentication (v1.2)</a></li>
<li><a href='http://thedeadone.net/blog/gcg-its-alive/' title='GCG&#8230; it&#8217;s alive!'>GCG&#8230; it&#8217;s alive!</a></li>
<li><a href='http://thedeadone.net/blog/where-has-tdo-mini-forms-plugin-gone/' title='Where has TDO Mini Forms plugin gone?'>Where has TDO Mini Forms plugin gone?</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/how-to/integrating-pligg-beta-810-with-wordpress-204/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Integrating Pligg beta 8.1.0 with PubCookie</title>
		<link>http://thedeadone.net/how-to/integrating-pligg-beta-810-with-pubcookie/</link>
		<comments>http://thedeadone.net/how-to/integrating-pligg-beta-810-with-pubcookie/#comments</comments>
		<pubDate>Fri, 13 Oct 2006 09:38:49 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Pligg]]></category>
		<category><![CDATA[PubCookie]]></category>
		<category><![CDATA[Redbrick]]></category>

		<guid isPermaLink="false">http://thedeadone.net/software/integrating-pligg-beta-810-with-pubcookie/</guid>
		<description><![CDATA[I&#8217;ve managed to get Pligg to use Redbrick&#8217;s PubCookie to authenticate logins. For the moment, you can see it in action here. However, this was done for demo purposes so I don&#8217;t know if it&#8217;ll stay there forever. I reused the approach that worked for integrating MediaWiki with PubCookie for our Redbrick Wiki. This was [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>I&#8217;ve managed to get <a href="http://www.pligg.com/">Pligg</a> to use <a href="http://www.redbrick.dcu.ie">Redbrick&#8217;s</a> <a href="http://www.pubcookie.org/">PubCookie</a> to authenticate logins. For the moment, you can see it in action <a href="http://www.redbrick.dcu.ie/~cammy/pig">here</a>. However, this was done for demo purposes so I don&#8217;t know if it&#8217;ll stay there forever.</p>
<p>I reused the approach that worked for integrating <a href="http://www.mediawiki.org/">MediaWiki</a> with PubCookie for our <a href="http://wiki.redbrick.dcu.ie">Redbrick Wiki</a>. This was based on <a href="http://wiki.case.edu/Pubcookie_Configuration">the work originally described here</a>.</p>
<p>I&#8217;ve only tested this with Pligg Beta 8.1.0. I believe future versions may have a better approach for external authentication so I can&#8217;t guarantee this will work with future versions.<br />
<span id="more-259"></span><br />
I&#8217;m assuming that you already have an existing and working pubcookie installation. The first thing to do is install Pligg. Get it up and running with it&#8217;s own authentication. Make sure you can login with the pre-created &#8220;god&#8221; account.</p>
<p>We&#8217;re going to need to modify the template quite a bit, so create a copy of the existing template, mollio-beat. To do this, just make a copy of &#8216;templates/mollio-beat&#8217; in &#8216;templates/&#8217; (including all subdirectories). Make sure the permissions are correct, etc. I renamed this copy &#8220;rb&#8221; (for Redbrick), so I now had a &#8216;template/rb&#8217;. I went into the admin interface in Pligg and under the Template configuration, changed &#8216;mollio-beat&#8217; to &#8216;rb&#8217; and disabled the option that lets users change the template. We don&#8217;t want users being able to go back to the old way of authentication.</p>
<p>Next, create a &#8216;custom_auth&#8217; directory in your pligg directory.</p>
<p>Create a &#8216;login1.php&#8217; with these contents in &#8216;custom_auth&#8217;. Make sure to replace &#8216;[url to your pligg install]&#8216; with the correct URL to your pligg directory. This file simply redirects the user to a pubcookie protected page.</p>
<p>< ?php</p>
<p>session_start();</p>
<p>//we don't want people accessing this page directly!<br />
if (isset($_SERVER['HTTP_REFERER'])) {<br />
  //save the referrer so we can redirect back to the page they came from<br />
  $_SESSION['http_referrer'] = $_SERVER['HTTP_REFERER'];</p>
<p>  //now send them off to the PubCookie protected login page<br />
  header('Location: https://[url to your pligg install]/custom_auth/login2.php');<br />
}<br />
else {<br />
  header('HTTP/1.1 403 Forbidden');<br />
  echo "This page cannot be accessed directly";<br />
}</p>
<p>?></p>
<p>Create a &#8216;login2.php&#8217; with these contents in &#8216;custom_auth&#8217;. This page will be protected by pubcookie. The user will then login via pubcookie, be redirected back here and be logged into pligg. You can replace the &#8220;@redbrick.dcu.ie&#8221; in the email field to something that makes more sense for your setup.</p>
<p>< ?php</p>
<p>// Needed by Pligg</p>
<p>include_once('../Smarty.class.php');<br />
$main_smarty = new Smarty;<br />
include('../config.php');<br />
//include(mnminclude.'html1.php');<br />
//include(mnminclude.'link.php');<br />
//include(mnminclude.'smartyvariables.php');</p>
<p>require_once "HTTP/Request.php";</p>
<p>//this script must be run behind some type of Apache user authorization<br />
//fail immediately if it isn't<br />
if (!isset($_SERVER['REMOTE_USER'])) {<br />
  die("The remote user variable is not set");<br />
}</p>
<p>//get the login username<br />
$username = strtolower($_SERVER['REMOTE_USER']);</p>
<p>session_start();</p>
<p>$redirect = $_SESSION['http_referrer'];<br />
unset($_SESSION['http_referrer']);</p>
<p>global $db;</p>
<p>$ok = 1;<br />
// if a user doesn't exit... create the user<br />
if(!user_exists($username)){<br />
  // come up with some default email<br />
  $email = $username."@redbrick.dcu.ie";<br />
  $userip = $_SERVER['REMOTE_ADDR'];<br />
  $ok = $db->query(&#8220;INSERT INTO users (user_login, user_email, user_pass, user_date, user_ip) VALUES (&#8216;$username&#8217;, &#8216;$email&#8217;, &#8216;password&#8217;, now(), &#8216;$userip&#8217;)&#8221;);<br />
}</p>
<p>// if everything is okay&#8230;<br />
if($ok) {<br />
  // log in!<br />
  $user=$db->get_row(&#8220;SELECT user_id, user_pass, user_login FROM users WHERE user_login = &#8216;$username&#8217;&#8221;);<br />
  $current_user->user_login = $user->user_login;<br />
  $current_user->user_id = $user->user_id;<br />
  $current_user->authenticated = TRUE;<br />
  $current_user->md5_pass = md5($user->user_pass);<br />
  $current_user->SetIDCookie(1, false);<br />
  $lastip=$_SERVER['REMOTE_ADDR'];<br />
  mysql_query(&#8220;UPDATE users SET user_lastip = &#8216;$lastip&#8217; WHERE user_id = {$user->user_id} LIMIT 1&#8243;);<br />
  mysql_query(&#8220;UPDATE users SET user_lastlogin = now() WHERE user_id = {$user->user_id} LIMIT 1&#8243;);<br />
}</p>
<p>//finally redirect the user back to his original page<br />
header(&#8220;Location: $redirect&#8221;);<br />
?></p>
<p>Now create a &#8216;.htaccess&#8217; file. This will make &#8216;login2.php&#8217; protected by pubcookie. On my setup, to do this, I use this:</p>
<pre>
PubcookieAppID cpig1
AuthType pubcookie

<files "login2.php">
       require valid-user
</files>
</pre>
<p>Now you need to modify your template to use this new login approach. Go into your template directory (in my case thats &#8216;template/rb&#8217;) and modify &#8220;login_center.tpl&#8221;. Add these lines near the top of tile and replace [url to your pligg install] with the correct URL to your pligg directory. This will cause all logins to redirect to the new login scripts.</p>
<p>< ?php<br />
/* these lines added to enable pub cookie login! */<br />
header("Location: http://[url to your pligg install]/custom_auth/login1.php");<br />
exit;<br />
?></p>
<p>Now, open up your Pligg in a browser of choice. Assuming your not currently logged in, follow the login link at the top. You should now have to login using pubcookie. If login is sucessful, you should now be logged into Pligg.</p>
<p>However, you&#8217;ll want to give yourself admin powers. So login using your own pubcookie account so that the user account is created in Pligg. Now change the template from &#8216;rb&#8217; back to &#8216;mollio-beat&#8217;. Hopefully now you should be able to login using the original &#8216;god&#8217; account. Once logged in, change your pubcookie account to &#8216;god&#8217; level. Nowe change the the template back to &#8216;rb&#8217; (or whatever you called it).</p>
<p>People can now log into your Pligg using pubcookie. However, your site isn&#8217;t fully secure. Delete &#8216;register.php&#8217; so that no-one can create accounts. We do not want to delete &#8216;login.php&#8217; however as this does our &#8216;logout&#8217;. Instead we will modify &#8216;login.php. Look for these lines:</p>
<p>if($_POST["processlogin"] == 1) {<br />
                $username = trim($_POST['username']);<br />
                $password = trim($_POST['password']);<br />
                $persistent = $_POST['persistent'];<br />
                if($current_user->Authenticate($username, $password, $persisten$<br />
                        $errorMsg=PLIGG_Visual_Login_Error;} else {<br />
                        if(strlen($_REQUEST['return']) > 1) {<br />
                                header(&#8216;Location: &#8216;.$_REQUEST['return']);<br />
                        } else {<br />
                                header(&#8216;Location: &#8216;.my_pligg_base.&#8217;/');<br />
                        }<br />
                        die;<br />
                }<br />
        }</p>
<p>We want to prevent hackers from using URLs to log in. So comment out the normal authentication test, as below.</p>
<p>if($_POST["processlogin"] == 1) {<br />
                /*$username = trim($_POST['username']);<br />
                $password = trim($_POST['password']);<br />
                $persistent = $_POST['persistent'];<br />
                if($current_user->Authenticate($username, $password, $persisten$<br />
                        $errorMsg=PLIGG_Visual_Login_Error;} else {<br />
                        if(strlen($_REQUEST['return']) > 1) {<br />
                                header(&#8216;Location: &#8216;.$_REQUEST['return']);<br />
                        } else {<br />
                                header(&#8216;Location: &#8216;.my_pligg_base.&#8217;/');<br />
                        }<br />
                        die;<br />
                }*/<br />
        }</p>
<p>Your site is now ready to be used. However I would suggest some further template changes. These are not required to make your site work, but they do improve usablity for your members.</p>
<p>In the template file &#8216;header.tpl&#8217;, remove the line:</p>
<li class="last"><a href="{$URL_register}">{#PLIGG_Visual_Register#}</a></li>
<p>This will remove the &#8220;register option&#8221; from the top of the page.</p>
<p>In the template file &#8216;profile_center.tpl&#8217;, remove these lines:</p>
<p class="l-mid">{#PLIGG_Visual_Profile_ChangePass#}</p>
<table style="border: medium none">
<tr>
<td width="30%">
<p class="l-mid"><label>{#PLIGG_Visual_Profile_NewPass#}:</label></p>
<input name="password" size="25" type="password" tabIndex="13" id="password" /></td>
<td>
<p class="l-mid"><label>{#PLIGG_Visual_Profile_VerifyNewPass#}: </label></p>
<input name="password2" size="25" type="password" tabIndex="14" id="verify" /></td>
</tr>
</table>
<p>This will remove the change password option from users profiles. It&#8217;s harmless, as the password is not used, but it could convince your users.</p>
<p>In the template file &#8216;sidebar_modules/login.tpl&#8217;, you may want to replace, pretty much everything in this file so that users don&#8217;t see a login form in the sidebar. This is what I put in it.</p>
<h3>{#PLIGG_Visual_Login_Title#}</h3>
<p>You can log in using your <a href="http://www.redbrick.dcu.ie/">Redbrick</a><br />
username and password due to the magic of pubcookie. Just follow the link<br />
below.</p>
<p><a href="{$URL_login}">{#PLIGG_Visual_Login#}</a></p>
<p>A final suggestion, in the admin panel in langauge configuration, I&#8217;d recommend changing all instances of &#8220;login&#8221; to &#8220;sign in&#8221; and &#8220;logout&#8221; to &#8220;sign out&#8221;.<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/lj/add-a-pligg-it-button-to-your-webpage/' title='Add a &#8220;pligg it&#8221; button to your webpage!'>Add a &#8220;pligg it&#8221; button to your webpage!</a></li>
<li><a href='http://thedeadone.net/blog/a-thought-exercise-redbrick-web-20/' title='A thought-exercise: Redbrick &#8220;Web 2.0&#8243;'>A thought-exercise: Redbrick &#8220;Web 2.0&#8243;</a></li>
<li><a href='http://thedeadone.net/blog/a-new-look-for-thedeadonenet/' title='A new look for thedeadone.net'>A new look for thedeadone.net</a></li>
<li><a href='http://thedeadone.net/blog/phew-made-it/' title='Phew! Made it!'>Phew! Made it!</a></li>
<li><a href='http://thedeadone.net/blog/thedeadonenet-is-back/' title='thedeadone.net is back!'>thedeadone.net is back!</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/how-to/integrating-pligg-beta-810-with-pubcookie/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

