<?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; How To</title>
	<atom:link href="http://thedeadone.net/category/how-to/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>Modifying the WordPress query in your theme without breaking plugins</title>
		<link>http://thedeadone.net/how-to/modifying-the-wordpress-query-in-your-theme-without-breaking-plugins/</link>
		<comments>http://thedeadone.net/how-to/modifying-the-wordpress-query-in-your-theme-without-breaking-plugins/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 08:25:46 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[tdo-tag-fixes]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp_query]]></category>

		<guid isPermaLink="false">http://thedeadone.net/?p=556</guid>
		<description><![CDATA[In the WordPress codex, it explains how to modify what posts are in the loop by modifying the WordPress Query object. However there is a catch with this, because by using rewind_posts() for example, you are generating a brand new query to the database that doesn&#8217;t trigger plugins. Specifically this came up when creating the [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>In the <a href="http://codex.wordpress.org/">WordPress codex</a>, it explains <a href="http://codex.wordpress.org/The_Loop">how to modify what posts are in the loop by modifying the WordPress Query object</a>. However there is a catch with this, because by using <span class="code">rewind_posts()</span> for example, you are generating a brand new query to the database that doesn&#8217;t trigger plugins.</p>
<p>Specifically this came up when creating the current theme for my webpage. I wanted to use <a href="http://thedeadone.net/download/tdo-tag-fixes-wordpress-plugin/">my tdo-tag-fixes plugin</a> that filters posts on a category template based on a tag. This initially worked fine, but I wanted to tweak the theme so that some category pages displayed<em> all </em>posts from that category but yet could be filtered by tags. (Check out <a href="http://thedeadone.net/category/download/">my download section where you can filter downloads by clicking on the tag cloud on the left</a>). Apparently other people are suffering similar problems too when they use the tdo-tag-fixes plugin while trying to modify the query within their theme. </p>
<p>To list all the posts in a category template isn&#8217;t hard at all. I just had to set the query var &#8220;<span class="code">nopaging</span>&#8221; to true and do a <span class="code">rewind_posts()</span>. (You also have to set the category_name again). Once I had implemented this in my category template, the tag filtering stopped working. What was happening was that r<span class="code">rewind_posts()</span> created a brand new query, overwriting any previous set query vars and basically going around my tdo-tag-fixes plugin.</p>
<p>However there is a solution to this (basically how tdo-tag-fixes is implemented in fact). So what you need to do is modify the query before it gets to the template. This way it should be in addition to any other plugins that modify the query (unless your theme overwrites them).</p>
<p>So in my functions.php I did something like this:</p>
<pre><code>
add_action('parse_request','show_all_entries_in_category');

function show_all_entries_in_category(
    $args
)
{
    $categories_list = array( 1, 3, 4 );

    // this if checks if it's for a category template
    //
    if(isset($args->query_vars['category_name']))
    {

        $cat = get_category_by_path($args->query_vars['category_name']);

        // if one of the special categories, disable paging
        //
        if(in_array($cat->term_id,$categories_list))
        {
            // make sure all posts are displayed in this category
            //
            $args->set_query_var('nopaging',true);
        }
    }
}
</code></pre>
<p>This piece of code will check set the &#8220;<span class="code">nopaging</span>&#8221; query var on the wp_query for categories with ids 1, 3 or 4, which means that for those category pages all posts will be listed with no previous and next page links.</p>
<p>You can of course alter the code with in <span class="code">show_all_entries_in_category()</span> with what ever query modifications you need to do.<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/blog/tutorial-video-for-tdo-mini-forms/' title='Tutorial Video for TDO Mini Forms!'>Tutorial Video for TDO Mini Forms!</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>
<li><a href='http://thedeadone.net/blog/pet-projects-tdo-mini-forms-and-forums/' title='Pet Projects, TDO-Mini-Forms and Forums'>Pet Projects, TDO-Mini-Forms and Forums</a></li>
<li><a href='http://thedeadone.net/blog/working-on-a-taxonomy-widget-for-tdo-mini-forms/' title='Working on a Taxonomy Widget for TDO Mini Forms'>Working on a Taxonomy Widget for TDO Mini Forms</a></li>
<li><a href='http://thedeadone.net/blog/an-alternative-to-tdo-mini-forms/' title='An alternative to TDO Mini Forms?'>An alternative to TDO Mini Forms?</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/how-to/modifying-the-wordpress-query-in-your-theme-without-breaking-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making the content field WYSIWYG in TDO Mini Forms (using TinyMCE)</title>
		<link>http://thedeadone.net/how-to/tinymce-tdomf/</link>
		<comments>http://thedeadone.net/how-to/tinymce-tdomf/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 11:18:02 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[TDOMF]]></category>
		<category><![CDATA[TinyMCE]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[WYSIWYG]]></category>

		<guid isPermaLink="false">http://thedeadone.net/?p=511</guid>
		<description><![CDATA[It&#8217;s becoming a common query about how to make the content field in a TDO Mini Forms WYSIWYG (&#8220;What-You-See-Is-What-You-Get&#8221;). A WYSIWYG editor is where you see that your input is bold when you set it to bold, instead of seeing it plain with bold tags around the text. This tutorial will run you through quickly [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>It&#8217;s becoming a common query about how to make the content field in a TDO Mini Forms WYSIWYG (&#8220;What-You-See-Is-What-You-Get&#8221;). A WYSIWYG editor is where you see that your input is bold when you set it to bold, instead of seeing it plain with bold tags around the text. This tutorial will run you through quickly how to set this up.</p>
<p><strong>Update #1:</strong> There is a bug with this tutorial. There is an incompatiblity between the AJAX code in TDOMF and using TinyMCE. Please disable AJAX before proceeding with this tutorial. If you have already done this, please disable AJAX. Then reset the form and then re-do the steps in this tutorial.<br />
<span id="more-511"></span><br />
There are tons of javascript implementations of this that can change a normal HTML textarea into one of these WYSIWYG editors such as <a href="http://tinymce.moxiecode.com/">TinyMCE</a> or <a href="http://nicedit.com/">NiceEdit</a>. The post content field (and Custom Fields set to Text Area) use the standard textarea element and so can be &#8220;skinned&#8221; by these libraries quite easily. This is why I haven&#8217;t really integrated one of these libraries into TDOMF, I don&#8217;t want to restrict user choice and I also don&#8217;t want the huge bloat. You could, for example, use the same installation of TinyMCE to skin your comments input form as well as your TDOMF form. However I&#8217;m constantly asked how to do it. So lets take TinyMCE, and run though how you might add it to your TDO Mini Forms form.</p>
<p>1. Download latest version from <a href="http://tinymce.moxiecode.com/">http://tinymce.moxiecode.com/</a></p>
<p>2. Unpack the <span class="code">tinymce_&lt;ver&gt;.zip</span></p>
<p>3. Using an FTP client, upload the contents of jscripts (i.e. the tiny_mce folder) to your wordpress site. Best place to do this is under wp-content (i.e. wp-content/tiny_mce).</p>
<p>4. Make sure its readable from the web. You may have to set the permissions using <span class="code">chmod 755</span> or <span class="code">chmod 777</span> on the directory and it&#8217;s contents depending on your host configuration. You can probably do this from your FTP client.</p>
<p>5. Now, you need a form with a Content widget it on it. If you use the default, unmodified form, you will have one. If not&#8230;</p>
<p>5.1. Go to the &#8220;Form Widgets&#8221; page.</p>
<p>5.2. Drag and drop the Content Widget from &#8220;Available Widgets&#8221; to &#8220;Your Form&#8221;.</p>
<p>5.3. Click on the icon beside &#8220;Content&#8221; and disable/uncheck the &#8220;Use Quicktags&#8221; and &#8220;Restrict Tags&#8221; options if they are checked. You can perform any other customisation of the &#8220;Content&#8221; Widget here.</p>
<p>5.4. Do any other widget customisation and then click &#8220;Save Changes&#8221;.</p>
<p>6. Now go to the &#8220;Form Manager and Options&#8221; and go to the options page for your Form. Make sure that &#8220;Use AJAX&#8221; is unchecked. (With the current version of TDOMF, the AJAX code is incompatible with the TinyMCE scripts).</p>
<p>7. Now go to the Form Hacker and add this to the top:</p>
<p><code>&lt;!-- TinyMCE --&gt;<br />
&lt;script type="text/javascript" src="&lt;?php echo get_bloginfo('wpurl'); ?&gt;/wp-content/tiny_mce/tiny_mce.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript"&gt;<br />
tinyMCE.init({<br />
mode : "exact",<br />
elements : "content_content",<br />
theme : "simple"<br />
});<br />
&lt;/script&gt;<br />
&lt;!-- /TinyMCE --&gt;</code></p>
<p>Save the hacked form.</p>
<p>8. View your form. The Post Content now should have a WYSIWYG editor!</p>
<p>I used the &#8220;simple theme&#8221; in this tutorial. TinyMCE supports more advanced editor and other options, so please check the <a href="http://wiki.moxiecode.com/index.php/Main_Page">TinyMCE documentation and examples</a>.</p>
<p>And NO! You cannot use the TinyMCE editor that is built into WordPress. The WordPress TinyMCE has been seriously hacked to work with the WordPress UI and cannot be used independently.</p>
<p>You can also extend this approach to use TinyMCE for Custom Fields.</p>
<p>9. Add a Custom Field widget to your Form using &#8220;Form Widgets&#8221;. Set the Custom Field &#8220;Type&#8221; to &#8220;Text Area&#8221;. Disable &#8220;Use Quicktags&#8221; and &#8220;Restrict Tags&#8221; options. Save the widgets.</p>
<p>10. On the &#8220;Form Hacker&#8221; use the &#8220;Reset&#8221; button to pick up the latest changes.</p>
<p>11. Now scan the code of the form for the Custom Field textarea tag. It should be something like this:</p>
<p><code>&lt;textarea title="true" rows="10" cols="40" name="<strong>customfields-textarea-1</strong>" id="customfields-textarea-1" &gt;&lt;?php echo htmlentities($value,ENT_NOQUOTES,get_bloginfo('charset')); ?&gt;&lt;/textarea&gt;</code></p>
<p>Please note the name of the custom field textarea element. In this case it&#8217;s <em>customfields-textarea-1.</em></p>
<p>12. Now at the top of the form add this:</p>
<pre><code>&lt;!-- TinyMCE --&gt;
&lt;script type="text/javascript" src="&lt;?php echo get_bloginfo('wpurl'); ?&gt;/wp-content/tiny_mce/tiny_mce.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
   tinyMCE.init({
      mode : "exact",
      elements : "content_content,<strong>customfields-textarea-1</strong>",
      theme : "simple"
   });
&lt;/script&gt;
&lt;!-- /TinyMCE --&gt;</code></pre>
<p>Note that I&#8217;ve appended the name of the textarea to the &#8220;elements&#8221; array.</p>
<p>13. Save the hacked form.</p>
<p>14. View your form. Now your content and your custom field widget use TinyMCE.</p>
<p>If you want to configure TinyMCE in even more complicated ways, please refer to the <a href="http://wiki.moxiecode.com/index.php/Main_Page">TinyMCE documentation</a>. You can, for example, configure a Custom Field differently to the post content, by having the tinyMCE.init called separately <strong>before</strong> the different elements. In a similar way, you can add WYSIWYG editor to your comments, if you are so inclined.</p>
<p>Any questions and queries are probably best served on the <a href="http://thedeadone.net/forum/">TDOMF support forum</a>. <a href="http://tinyurl.com/yvgcs9">If you did find this helpful, please consider dropping me a few euros, thank you</a>.<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<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>
<li><a href='http://thedeadone.net/blog/pet-projects-tdo-mini-forms-and-forums/' title='Pet Projects, TDO-Mini-Forms and Forums'>Pet Projects, TDO-Mini-Forms and Forums</a></li>
<li><a href='http://thedeadone.net/blog/working-on-a-taxonomy-widget-for-tdo-mini-forms/' title='Working on a Taxonomy Widget for TDO Mini Forms'>Working on a Taxonomy Widget for TDO Mini Forms</a></li>
<li><a href='http://thedeadone.net/blog/an-alternative-to-tdo-mini-forms/' title='An alternative to TDO Mini Forms?'>An alternative to TDO Mini Forms?</a></li>
<li><a href='http://thedeadone.net/blog/you-want-custom-taxonomies-in-tdo-mini-forms/' title='You want Custom Taxonomies in TDO Mini Forms?'>You want Custom Taxonomies in TDO Mini Forms?</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/how-to/tinymce-tdomf/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<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>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>
		<item>
		<title>LiveJournal and WordPress</title>
		<link>http://thedeadone.net/how-to/livejournal-and-wordpress/</link>
		<comments>http://thedeadone.net/how-to/livejournal-and-wordpress/#comments</comments>
		<pubDate>Thu, 22 Jun 2006 14:45:57 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Irish-Gaming]]></category>
		<category><![CDATA[thedeadone.net]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://thedeadone.net/news/livejournal-and-wordpress/</guid>
		<description><![CDATA[So the online Irish gaming community has moved, without a word, to livejournal. They even have a &#8220;community&#8221; setup. But to be honest, I&#8217;ve already got my own homepage setup so I don&#8217;t particularly want to setup another blog just to join in. Well, luckly I found Live+Press, a little plugin for WordPress that allows [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>So the <a href="http://www.irishgaming.com/forum/viewtopic.php?t=105">online Irish gaming community has moved</a>, without a word, to <a href="http://www.livejournal.com">livejournal</a>. They even have a <a href="http://community.livejournal.com/irishgaming/">&#8220;community&#8221;</a> setup.</p>
<p>But to be honest, I&#8217;ve already got my own <a href="http://thedeadone.net">homepage</a> setup so I don&#8217;t particularly want to setup another blog just to join in. Well, luckly I found <a href="http://somuchgeek.com/code/livepress/">Live+Press</a>, a little plugin for WordPress that allows you to synch blog entires from WordPress to LiveJournal.</p>
<p><span id="more-231"></span></p>
<p>I&#8217;ve setup a LiveJournal account with the uninspired name <a href="http://tdo-ie.livejournal.com/">&#8220;tdo_ie&#8221;</a> (thedeadone and many variants have already been taken). This post will actually be the first inaugural post on the account and also be synced on both sites! Lets see if it works&#8230; <img src='http://thedeadone.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update:</strong> That was a flop. I spent some time trying to debug the plugin but I couldn&#8217;t get to the source of why the sync failed. Ah, it was worth a try.</p>
<p><strong>Update #2:</strong> So Live+Press sucks but I found <a href="http://ebroder.net/livejournal-crossposter/">LiveJournal Crossposter</a>. Lets see what happens&#8230;</p>
<p><strong>Update #3:</strong> Still having difficulty but at least with Crossposter the code is much easier to debug. The problem lies with WordPress file class-IXR.php. It has no support for proxies. Seeing if I can hack it a bit&#8230;</p>
<p><strong>Update #4:</strong> The error is “Something went wrong &#8211; -32300 : transport error &#8211; could not open socket: 110 Connection timed out&#8221;. This comes from the file class-IXR.php from WordPress. AFAIK, my host, <a href="http://www.redbrick.dcu.ie">Redbrick</a>, does allow outgoing connections. Is this a LiveJournal thing or a Redbrick thing? There are no settings for proxies in either the plugin or the WordPress file.</p>
<p><strong>Update #5:</strong> It appears the &#8220;110 Connection timed out&#8221; is a proxy problem. I hacked class-IXR.php a bit to use the redbrick proxy.</p>
<p>        if ($this->timeout) {<br />
            //$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);<br />
            $fp = @fsockopen(&#8216;proxy.dcu.ie&#8217;, 3128, $errno, $errstr, $this->timeout);<br />
        } else {<br />
            //$fp = @fsockopen($this->server, $this->port, $errno, $errstr);<br />
            $fp = @fsockopen(&#8216;proxy.dcu.ie&#8217;, 3128, $errno, $errstr);<br />
        }</p>
<p>Unfortunantly this isn&#8217;t enough. The fsockopen is successful but the fputs isn&#8217;t. The error is now: &#8220;HTTP/1.0 400 Bad Request&#8221;. I&#8217;m getting closer at least.</p>
<p><strong>Update #6:</strong> Final update. I got it to work!</p>
<p>It requires a further update to class-IXR.php however. The request string that is passed to fputs is missing info that I guess the proxy needs. I needed to add the full url, not just the path and a &#8220;http://&#8221; to the beginning of the Host field.</p>
<p>        $request = &#8220;POST http://{$this-&gt;server}{$this-&gt;path} HTTP/1.0$r&#8221;;<br />
        $request .= &#8220;Host: http://{$this->server}$r&#8221;;<br />
        $request .= &#8220;Content-Type: text/xml$r&#8221;;<br />
        $request .= &#8220;User-Agent: {$this->useragent}$r&#8221;;<br />
        $request .= &#8220;Content-length: {$length}$r$r&#8221;;<br />
        $request .= $xml;</p>
<p>I guess I better pass this info around!<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/blog/some-fun-with-planet-irish-gaming/' title='Some fun with Planet Irish Gaming'>Some fun with Planet Irish Gaming</a></li>
<li><a href='http://thedeadone.net/blog/is-this-a-good-idea-a-livejournal-friends-page-on-my-wordpress-site/' title='Is this a good idea: a livejournal &#8220;friends&#8221; page on my wordpress site?'>Is this a good idea: a livejournal &#8220;friends&#8221; page on my wordpress site?</a></li>
<li><a href='http://thedeadone.net/blog/speaking-of-upgrading-software/' title='Speaking of upgrading software'>Speaking of upgrading software</a></li>
<li><a href='http://thedeadone.net/blog/arg-how-i-hate-internet-explorer/' title='Arg, how I hate Internet Explorer!'>Arg, how I hate Internet Explorer!</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/livejournal-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Redbrick Planet for X-Dashboard</title>
		<link>http://thedeadone.net/how-to/redbrick-planet-for-x-dashboard/</link>
		<comments>http://thedeadone.net/how-to/redbrick-planet-for-x-dashboard/#comments</comments>
		<pubDate>Thu, 28 Jul 2005 08:50:23 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Irish-Gaming]]></category>
		<category><![CDATA[Planet]]></category>
		<category><![CDATA[Redbrick]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[X-Dashboard]]></category>

		<guid isPermaLink="false">http://thedeadone.net/?p=204</guid>
		<description><![CDATA[This is rather funky. If your a WordPress user there is this nice plugin called X-Dashboard which allows you to configure the &#8216;dashboard&#8217; on the WordPress interface. I only recently figured out how to get the Dashboard working properly on Redbrick (see the Redbrick Wiki Topic &#8220;Installing WordPress&#8221;) so I fired up the plugin and [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>This is rather funky. If your a WordPress user there is this nice plugin called <a href="http://wp-plugins.net/index.php?id=225">X-Dashboard</a> which allows you to configure the &#8216;dashboard&#8217; on the WordPress interface.</p>
<p>I only recently figured out how to get the Dashboard working properly on Redbrick (see the <a href="http://www.redbrick.dcu.ie/~wiki/bin/view.pl/Rbwiki/InstallingWordpress">Redbrick Wiki Topic &#8220;Installing WordPress&#8221;</a>) so I fired up the plugin and am now able to configure what appears in it.</p>
<p>Whats just a little bit cooler is that you can write mini plugins for the plugin that allow you to include different feeds. So I wrote two, one for <a href="http://planet.redbrick.dcu.ie">Planet Redbrick</a> and one for <a href="http://irishgamingwiki.com/planet/">Planet Irish Gaming</a>.<br />
<span id="more-204"></span><br />
Install the X-Dashboard plugin normally. There should be a folder in your plugins directory called x-dash-plugins. Create a file called redbrick_feed.php (you can use nano, pico or touch) with these contents:</p>
<p>< ?php<br />
/*<br />
x-Dash-Plugin-Name:Planet Redbrick</p>
<p>*/</p>
<p>global $wpdb, $user_ID;</p>
<p>$rss = @fetch_rss('http://planet.redbrick.dcu.ie/rss20.xml');<br />
if ( isset($rss->items) &#038;&#038; 0 != count($rss->items) )<br />
{<br />
        xdash_show_title(&#8216;Planet Redbrick&#8217;);</p>
<p>        if ($xdash_cur_section == &#8216;main&#8217;) {<br />
        ?></p>
<p>< ?php _e('Below is the latest blogs from Redbrick users, click on a title to go that site.'); ?></p>
<p>        < ?php } ?></p>
<ul>
        < ?php<br />
        $rss->items = array_slice($rss->items, 0, 6);<br />
        foreach ($rss->items as $item )<br />
        {<br />
        ?></p>
<li><a href='<?php echo wp_filter_kses($item['link']); ?>&#8216;>< ?php echo wp_specialchars($item['title']); ?></a> &#8212; < ?php echo human_time_diff( strtotime($item['pubdate'], time() ) ); ?> < ?php _e('ago'); ?></li>
<p>        < ?php<br />
        }<br />
        echo "</ul>
<p>&#8220;;<br />
}<br />
?></p>
<p>and chmod it to 755. Now you can have the latest redbrick blog posts in your dashboard!</p>
<p>Likewise for the Irish Gaming Planet feed, create a file called igp_feed.php with this:</p>
<p>< ?php<br />
/*<br />
x-Dash-Plugin-Name:Irish Gaming Feed</p>
<p>*/</p>
<p>global $wpdb, $user_ID;</p>
<p>$rss = @fetch_rss('http://irishgamingwiki.com/planet/rss20.xml');<br />
if ( isset($rss->items) &#038;&#038; 0 != count($rss->items) )<br />
{<br />
        xdash_show_title(&#8216;Planet Irish Gaming&#8217;);</p>
<p>        if ($xdash_cur_section == &#8216;main&#8217;) {<br />
        ?></p>
<p>< ?php _e('Below is the latest news from Irish Gaming, click on a title to go that site.'); ?></p>
<p>        < ?php } ?>
        </ul>
<ul>
        < ?php<br />
        $rss->items = array_slice($rss->items, 0, 6);<br />
        foreach ($rss->items as $item )<br />
        {<br />
        ?></p>
<li><a href='<?php echo wp_filter_kses($item['link']); ?>&#8216;>< ?php echo wp_specialchars($item['title']); ?></a> &#8212; < ?php echo human_time_diff( strtotime($item['pubdate'], time() ) ); ?> < ?php _e('ago'); ?></li>
<p>        < ?php<br />
        }<br />
        echo "</ul>
<p>&#8220;;<br />
}<br />
?></p>
<p>and also chmod it to 755. <img src='http://thedeadone.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </ul>
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/blog/frustrating/' title='Frustrating!'>Frustrating!</a></li>
<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/blog/some-fun-with-planet-irish-gaming/' title='Some fun with Planet Irish Gaming'>Some fun with Planet Irish Gaming</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/maybe-not-the-end-of-an-era-but-the-end-of-something/' title='Maybe not the end of an era, but the end of something!'>Maybe not the end of an era, but the end of something!</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/how-to/redbrick-planet-for-x-dashboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial How to Create New Skies for VtMR</title>
		<link>http://thedeadone.net/how-to/tutorial-how-to-create-new-skies-for-vtmr/</link>
		<comments>http://thedeadone.net/how-to/tutorial-how-to-create-new-skies-for-vtmr/#comments</comments>
		<pubDate>Sun, 07 Sep 2003 22:07:09 +0000</pubDate>
		<dc:creator>Mark Cunningham</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[3D Stuff]]></category>
		<category><![CDATA[Vampire-the-Masquerade:-Redemption]]></category>

		<guid isPermaLink="false">http://thedeadone.net/wp/?p=87</guid>
		<description><![CDATA[This is a tutorial for creating new &#8220;skies&#8221; for the levels and maps for the computer game Vampire the Masquerade: Redemption. It was originally written for ModHaven (when it was still around). Have a look at my &#8220;Akashic Records&#8221; level for a sample of a new sky in a level. Contents Assumptions Background Info Tools [...]]]></description>
			<content:encoded><![CDATA[
<!-- google_ad_section_start -->
<!--INFOLINKS_ON-->
<p><p>This is a tutorial for creating new &#8220;skies&#8221; for the levels and maps for the computer game Vampire the Masquerade: Redemption.</p>
<p>It was originally written for ModHaven (when it was still around).</p>
<p>Have a look at my &#8220;<a href="http://thedeadone.net/?p=86">Akashic Records&#8221;</a> level for a sample of a new sky in a level.<br />
<span id="more-87"></span><br />
<a name="#top" /><b>Contents</b></p>
<ul>
<li><a href="#assumptions">Assumptions</a></li>
<li><a href="#background_info">Background Info</a></li>
<li><a href="#tools">Tools</a></li>
<li><a href="#how_to">How to</a></li>
<li><a href="#troubleshooting">Troubleshooting</a></li>
</ul>
<p><a name ="#assumptions" /><b>Assumptions</b></p>
<ul>
<li>You have some experince already mapping</li>
<li>You have meddled around with extracting files from Resource.NOB and other base NOB files in Vampire</li>
</ul>
<p><a name ="#background_info" /><b>Background Info</b></p>
<p>New skies are not simply a new texture. Skies in a compiled map are actually models. Therefore<br />
to create a new sky you must skin it. What follows is simply a simple skinning tutorial modified<br />
specifically for new skies.</p>
<p><a name ="#tools" /><b>Tools</b></p>
<ul>
<li>Some sort of paint program
</li>
<li>Some sort of zip tool to extract files from the NOBs
</li>
<li>A Hex Editor (such as UltraEdit from www.ultraedit.com)
</li>
<li>A Transparent Texture
</li>
</ul>
<p><a name ="#how_to" /><b>How to</b></p>
<ul>
<li><b>Step 1. Deciding what you want to do</b>
<p>Have an idea of what kind of sky you want. Say you want just to have a sky that doesn&#8217;t have that annoying<br />
black bit the the other default day skies have. Or perhaps you want to create a sunset rather then straight day.</p>
<p><strike>With this in mind, inspect the default skies and pick one that matchs as closely as possible to what you want. (I&#8217;ve posted a list of the default skies along with pictures on <a href="http://www.planetvampire.com/ModHaven">ModHaven</a> to help you).</strike></p>
<p>But for the sake of completeness here is the list of the default skies avaliable:</p>
<table cellspacing=0 cellpadding=5  border="1">
<tr>
<td><b>NAD file</b></td>
<td><b>NOD file</b></td>
</tr>
<tr>
<td>PragueCastleNight.nad</td>
<td>PragueCastleNight.nod</td>
</tr>
<tr>
<td>pragueDaySky.nad</td>
<td>pragueDaySky.nod</td>
</tr>
<tr>
<td>pragueEastNight.nad</td>
<td>pragueEastNight.nod</td>
</tr>
<tr>
<td>Prague2Night.nad</td>
<td>Prague2Night.nod</td>
</tr>
<tr>
<td>Prague2NightVysehrad.nad</td>
<td>Prague2NightVysehrad.nod</td>
</tr>
<tr>
<td>PragueWestDay.nad</td>
<td>PragueWestDay.nod</td>
</tr>
<tr>
<td>PragueWestNight.nad</td>
<td>PragueWestNight.nod</td>
</tr>
<tr>
<td>judithBridgeDay.nad</td>
<td>judithBridgeDay.nod</td>
</tr>
<tr>
<td>judithBridgeNight.nad</td>
<td>judithBridgeNight.nod</td>
</tr>
<tr>
<td>londonNightSky.nad</td>
<td>LondonNightSky.nod</td>
</tr>
<tr>
<td>londontower.nad</td>
<td>londontower.nod</td>
</tr>
<tr>
<td>newyorkdocks.nad</td>
<td>newyorkdocks.nod</td>
</tr>
<tr>
<td>newyorkuptown.nad</td>
<td>newyorkuptown.nod</td>
</tr>
<tr>
<td>ViennaDay1.nad</td>
<td>ViennaDay1.nod</td>
</tr>
<tr>
<td>ViennaNight1.nad</td>
<td>ViennaNight1.nod</td>
</tr>
<tr>
<td>ViennaSky.nad</td>
<td>ViennaSky.nod</td>
</tr>
<tr>
<td>Sky.nad</td>
<td>Sky.nod</td>
</tr>
</table>
<p>For example, the default sky (sky.nod/sky.nad), covers fully and would be useful for maps &#8220;floating&#8221; in the sky but for a sunset it would be useless because it&#8217;s kinda blocky rather then from bottom to up.</p>
</li>
<li><b>Step 2. Selecting your starting point</b>
<p>Extract the sky&#8217;s nod file (using the list above) (from your Resource.NOB) into your Vampire directory including the subdirectories (which should give you the dir structure 3d\Models\*.nod).</p>
<p>Open the nod file in your hex editor. You should see something like this (click on the image to see in full size):</p>
<p><a href="http://thedeadone.net/maps/vampire_the_masquerade/NewSkyTutorial_HexEditor.jpg" title="Click on image to see a bigger version!"><img src="http://thedeadone.net/maps/vampire_the_masquerade/NewSkyTutorial_HexEditor_small.jpg" border="0" /></a></p>
<p>You&#8217;ll notice you can read several names at the top of the file (clouds1, moon, StarField2 and dfltMatte). These are the &#8220;skins&#8221; or textures for your sky.</p>
<p>Extract the files with extensions tga and nam and with the same name from Resource.NOB into your Vampire directory including the subdirectories (which should give you the dir structure 3d\Materials). Open them in your paint<br />
program to get an idea of what they are. Now you should figure out how and what you want to change in the sky textures. </p>
<p>Choose the textures you want to edit and copy them. Rename them, but for the sake of simplicity, keep the filenames the same length (example, rename clouds1.tga to myouds1.tga). </p>
<p>If any of the textures you want to use have nam files you&#8217;re going to have to edit them, which isn&#8217;t difficult: After you&#8217;ve renamed, open up the nam file in<br />
any text editor you like. You should see at least one entry:</p>
<p><i>texture name.tga</i></p>
<p>where name.tga is the name of the original texture. Just change the entry to point to your renamed texture.</p>
</li>
<li><b>Step 3. Lets go</b>
<p>Copy the sky&#8217;s nod file and rename it. Such as mySky.nod or fulldarkSky.nod.</p>
<p>Open it in your hex editor and for the textures you wish to modify, rename them (by replacing character by character).</p>
</li>
<li><b>Step 4. Create your new sky!</b>
<p>Modify the new textures (most skinning tutorials should apply here).</p>
</li>
<li><b>Step 5. View your new sky!</b>
<p>Assuming you have a map prepared, open it and open the scene editor. Go to sky and in the nod text field, put in the name of your nod file. For the nad file, take the nad file from the original unedited sky.</p>
<p>Export your map and Walla!</p>
</li>
<li><b>Step 6. Including your new sky with your exported map in a nob</b>
<p>Package your map as normal for a release in a NOB file. Make sure to include the nod file you created and any of the new textures you created maintaining the correct directory structure in your NOB file.
</li>
</ul>
<p><a name ="#troubleshooting" /><b>Troubleshooting</b></p>
<p>You used default sky (or any sky) and you still have that black shape of a city! </p>
<p>Replace the dfltMatte texture (or that odd texture thats all black) with a transparent texture <strike>(refer to the MapDepo&#8217;s Dynamic FAQ avaliable on <a href="http://www.planetvampire.com/ModHaven">ModHaven</a> on how<br />
to create transparent/masked textures)</strike>.<br />
Walla, it&#8217;s gone.</p>
<p>For other problems, I suggest reading up on skinning and/or ask the skinners.</p>
<p>Originally posted <i>29<sup>th</sup> June 2001</i><br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://thedeadone.net/download/akashic-records/' title='Akashic Records (A VtM:R level)'>Akashic Records (A VtM:R level)</a></li>
<li><a href='http://thedeadone.net/blog/seriousily-do-you-think-i-might-be-a-terrorist/' title='Seriousily, do you think I might be a terrorist?'>Seriousily, do you think I might be a terrorist?</a></li>
<li><a href='http://thedeadone.net/download/tankstorm/' title='TankStorm'>TankStorm</a></li>
</ul>

<!--INFOLINKS_OFF-->
<!-- google_ad_section_end -->
]]></content:encoded>
			<wfw:commentRss>http://thedeadone.net/how-to/tutorial-how-to-create-new-skies-for-vtmr/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

