<?xml version="1.0" encoding="iso-8859-1" ?>
<rss version="2.0">
<channel>
	<title>DevFuse Forums - Tutorials: IP.Board Developer Tips</title>
	<link>http://www.devfuse.com/forums/tutorials/category/3-ip-board-developer-tips/</link>
	<pubDate>Wed, 08 Sep 2010 18:35:58 +0000</pubDate>
	<ttl>1800</ttl>
	<description>IP.Board (IPB) developer tips.</description>
	<item>
		<title>Importing large databases into Wamp</title>
		<link>http://www.devfuse.com/forums/tutorials/article/54-importing-large-databases-into-wamp/</link>
		<description><![CDATA[You can use tools such as bigdump to import large databases as phpmyadmin will only accept relatively small databases to import, but I prefer this on a localhost install as you already have easy access already and its quick and easy to do.<br />
<br />
Download your database from your live site (if that's the one you want to use). Extract the .gz so you have just a .sql file.<br />
<br />
For this example (remember yours will be different) , you need the following...<br />
<br />
The root users name and password (for mysql) , its normally just "root" and no password.<br />
<br />
The name of the new blank database (if you have not already created one, visit your localhost phpmyadmin and create a new blank database now)<br />
<br />
Use windows explorer or a command prompt. Navigate your way to the folder where wamp is installed. You need to go into the folder where mysql.exe is. In my case it is D:&#092;_DEV&#092;bin&#092;mysql&#092;mysql5.1.30&#092;bin . Most cases it will be c:&#092;program files&#092;wamp&#092;bin&#092;mysql&#092;mysql version&#092;bin etc...<br />
<br />
Copy the .sql file into here. It must be in the same directory as mysql.exe<br />
<br />
Open a command prompt in this directory if you have not already. If you have the "command prompt here" powertoy, this can be quicker than having to navigate via a command prompt to here. You can download this from Microsoft if you want it. Failing that, simply navigate your way to the appropriate directory using cd.<br />
<br />
For this example, the database I am importing is called mybackup.sql and the new empty database I created is called test<br />
<br />
Assuming you do NOT have a root password, type in the following...<br />
<br />
mysql.exe -u root test &lt; mybackup.sql<br />
<br />
<br />
This may take a few minutes depending on the database size and your CPU power, your firewall may prompt you so you will have to allow temporary access (should only be mysql wanting localhost access)<br />
<br />
When its finished, remove the mybackup.sql file you put in that directory.<br />
<br />
Done <img src='http://www.devfuse.com/forums/public/style_emoticons/default/grin.png' class='bbc_emoticon' alt=':D' /><br />
<br />
As an extra note, if you have a root password for mysql, you will need to use this instead (changing pass for the password)<br />
<br />
mysql.exe -u root -p pass test &lt; mybackup.sql<br />
<br />
<img src='http://www.devfuse.com/forums/public/style_emoticons/default/happy.png' class='bbc_emoticon' alt=':)' />]]></description>
		<pubDate>Sun, 25 Oct 2009 15:56:38 +0000</pubDate>
		<guid isPermaLink="false">54</guid>
		<creator>AndyF</creator>
		<category>3</category>
	</item>
	<item>
		<title>Email Debug</title>
		<link>http://www.devfuse.com/forums/tutorials/article/53-email-debug/</link>
		<description><![CDATA[A simple tutorial to setup email debugging. Ideally this is for your localhost test board, but it will work just fine on a live install too. If you are testing a mod that has email capability, it may be useful to catch these mails to check them amongst other things. <img src='http://www.devfuse.com/forums/public/style_emoticons/default/happy.png' class='bbc_emoticon' alt=':)' /><br />
<br />
Open /conf_global.php. Before the closing ?&gt; , add this line<br />
<br />
<pre class='prettyprint'>$INFO&#91;'fake_mail'&#93;			=	'1';</pre><br />
<br />
Inside your forum root, create a new directory and name it _mail (it must be exactly that: leading underscore and lowercase)<br />
<br />
If you are doing this on a Linux install (your live board for example) , that folder must be writeable (CHMOD to 777)<br />
<br />
For safety, copy the index.htm out of one of the other directories (such as /public or style_emoticons) and place it into this directory to prevent the directory content being listed, or create a new one if needed. Do not leave this directory without an .htm file present.<br />
<br />
That's it <img src='http://www.devfuse.com/forums/public/style_emoticons/default/happy.png' class='bbc_emoticon' alt=':)' /> , when you send an email it will now log it into this _mail directory instead of sending it out.]]></description>
		<pubDate>Sun, 25 Oct 2009 15:55:34 +0000</pubDate>
		<guid isPermaLink="false">53</guid>
		<creator>AndyF</creator>
		<category>3</category>
	</item>
	<item>
		<title><![CDATA[[IPB 3.0.x] Database Queries]]></title>
		<link>http://www.devfuse.com/forums/tutorials/article/44-ipb-30x-database-queries/</link>
		<description><![CDATA[IP.Board 3.30.x comes with a built in database class. This will perform just about any database query you may have. Below are some of the basics.<br />
<br />
Database Select<br />
<pre class='prettyprint'>$this-&#62;DB-&#62;build&#40; array&#40; 'select' =&#62; '*', 'from' =&#62; 'db_table' &#41; &#41;; 
  $this-&#62;DB-&#62;execute&#40;&#41;;
  $r = $this-&#62;DB-&#62;fetch&#40;&#41;;</pre><br />
<br />
Database Insert<br />
<pre class='prettyprint'>$this-&#62;DB-&#62;insert&#40; 'db_table', array &#40; 'row1' =&#62; &#34;row1&#34;, 'row2' =&#62; &#34;row2&#34;, 'row3' =&#62; &#34;row3&#34;, &#41; &#41;;</pre><br />
<br />
Database Delete<br />
<pre class='prettyprint'>$this-&#62;DB-&#62;delete&#40; 'db_table', 'id=1' &#41;;</pre><br />
<br />
You can also add different code to your query, including where, order and limit.<br />
<br />
Where<br />
<pre class='prettyprint'>'where' =&#62; 'id=1'</pre><br />
<br />
Order<br />
<pre class='prettyprint'>'order' =&#62; 'date DESC'</pre><br />
<br />
Limit<br />
<pre class='prettyprint'>'limit' =&#62; array&#40;0,1&#41;</pre> <br />
<br />
Some areas of IP.Board 3 may require you to setup the DB object at the construct like so.<br />
<br />
<pre class='prettyprint'>$this-&#62;DB	   = $this-&#62;registry-&#62;DB&#40;&#41;;</pre>]]></description>
		<pubDate>Wed, 25 Feb 2009 10:38:45 +0000</pubDate>
		<guid isPermaLink="false">44</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
	<item>
		<title>New IPB 3.0.x code changes</title>
		<link>http://www.devfuse.com/forums/tutorials/article/42-new-ipb-3-0-x-code-changes/</link>
		<description><![CDATA[While I'm converting my own mods I've been building a list of changes. I'll be updating this list as I add new code changes as well as new beta or RC changes. <strong class='bbc'>This so far is compatible with IPB 3 Beta 3.</strong><br />
<br />
<strong class='bbc'>Database Changes</strong><br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;simple_contruct<br />
New: $this-&gt;DB-&gt;build<br />
<br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;simple_exec<br />
 New: $this-&gt;DB-&gt;execute<br />
<br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;simple_exec_query<br />
 New: $this-&gt;DB-&gt;buildAndFetch<br />
<br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;get_num_rows<br />
  New: $this-&gt;DB-&gt;GetTotalRows<br />
<br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;fetch_row<br />
  New: $this-&gt;DB-&gt;fetch<br />
<br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;do_update<br />
   New: $this-&gt;DB-&gt;update<br />
<br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;do_delete<br />
    New: $this-&gt;DB-&gt;delete<br />
<br />
Old: $this-&gt;ipsclass-&gt;DB-&gt;do_insert<br />
     New: $this-&gt;DB-&gt;insert<br />
<br />
<br />
<strong class='bbc'>Old Ipsclass</strong><br />
Old: $this-&gt;ipsclass-&gt;vars<br />
New: $this-&gt;settings<br />
<br />
Old: $this-&gt;ipsclass-&gt;lang<br />
New: $this-&gt;lang-&gt;words<br />
<br />
Old: $this-&gt;ipsclass-&gt;member<br />
New: $this-&gt;memberData<br />
<br />
Old: $this-&gt;ipsclass-&gt;cache<br />
New: $this-&gt;caches<br />
<br />
Old: $this-&gt;ipsclass-&gt;Error<br />
 New: $this-&gt;registry-&gt;output-&gt;showError<br />
(Can pass the full text as the first parameter instead of an array with MSG in it.)<br />
<br />
<br />
<strong class='bbc'>Url Changes</strong><br />
Old: autocom=<br />
New: app=<br />
<br />
Old: code=<br />
 New: do=<br />
<br />
<br />
IPB3 no longer uses the ipsclass in it's code. Instead the objects are setup and available in applications like above coding illustrates. Some parts of IPB3 require you to setup the objects on your construct function. Example of this is below.<br />
<br />
<pre class='prettyprint'>/* Make registry objects */
 $this-&#62;registry	= $registry;
 $this-&#62;DB		= $this-&#62;registry-&#62;DB&#40;&#41;;
 $this-&#62;settings =& $this-&#62;registry-&#62;fetchSettings&#40;&#41;;
 $this-&#62;request  =& $this-&#62;registry-&#62;fetchRequest&#40;&#41;;
 $this-&#62;lang		= $this-&#62;registry-&#62;getClass&#40;'class_localization'&#41;;
 $this-&#62;member	= $this-&#62;registry-&#62;member&#40;&#41;;
 $this-&#62;memberData =& $this-&#62;registry-&#62;member&#40;&#41;-&#62;fetchMemberData&#40;&#41;;
 $this-&#62;cache	= $this-&#62;registry-&#62;cache&#40;&#41;;
 $this-&#62;caches   =& $this-&#62;registry-&#62;cache&#40;&#41;-&#62;fetchCaches&#40;&#41;;</pre>]]></description>
		<pubDate>Tue, 24 Feb 2009 12:27:40 +0000</pubDate>
		<guid isPermaLink="false">42</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
	<item>
		<title><![CDATA[[IPB 3.0.x] Bypass Admin CP Login]]></title>
		<link>http://www.devfuse.com/forums/tutorials/article/39-ipb-30x-bypass-admin-cp-login/</link>
		<description><![CDATA[This is a little edit to get into the Admin CP without loggin in, extremely useful for development boards, where logging in can be a pain. Open admin/sources/base/ipsRegistry.php<br />
Find:<br />
<pre class='prettyprint'>			if &#40; &#40; ipsRegistry&#58;&#58;$request&#91;'module'&#93; != 'login' &#41; AND &#40; ! $validationStatus &#41; &#41;</pre><br />
<br />
Replace With:<br />
<pre class='prettyprint'>			$memberData&#91;'member_id'&#93; = &#34;1&#34;;
			$memberData&#91;'members_display_name'&#93; = &#34;Admin&#34;;			

			if &#40; $nothing &#41;</pre><br />
<br />
Save admin/sources/base/ipsRegistry.php and your done.<br />
<span style='color: #ff0000'><strong class='bbc'>Please Note: This tip is mainly for localhost development boards, and is a extreme risk when used on live boards, use at your own risk. </strong></span>]]></description>
		<pubDate>Tue, 24 Feb 2009 11:00:04 +0000</pubDate>
		<guid isPermaLink="false">39</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
	<item>
		<title><![CDATA[[IPB 2.3.x] Adding your own task]]></title>
		<link>http://www.devfuse.com/forums/tutorials/article/45-ipb-23x-adding-your-own-task/</link>
		<description><![CDATA[There is many reasons while you might need a task in your modification, from clearing out your mods logs to performing resource intensives tasks in the background, like updating categories views.<br />
<br />
IP.Board allows you to add a task without editing any files. To start off we need to add a file to the sources/tasks/ folder. You can name this file what ever you want, in this example we are going to call it news.php.<br />
<br />
<pre class='prettyprint'>&lt;?php

if ( ! defined( 'IN_IPB' ) )
{
    print "&lt;h1&gt;Incorrect access&lt;/h1&gt;You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
    exit();
}

class task_item
{
    var $class     = "";
    var $root_path = "";
    var $task      = "";
    
    function run_task()
    {
        // Run what ever we need in a task here, this is just like any other file and should be able to
        // run what ever you had in components_public and want to run as a task.
        
        // Add to task log?        
        $this-&gt;class-&gt;append_task_log( $this-&gt;task, 'Task news.php has run.' );
        
        // Unlock Task 
        // leave this one alone, you need to unlock a task.
        $this-&gt;class-&gt;unlock_task( $this-&gt;task );
    }
    
    function register_class(&$class)
    {
        $this-&gt;class     = &$class;
        $this-&gt;ipsclass  =& $class-&gt;ipsclass;
        $this-&gt;root_path = $this-&gt;class-&gt;root_path;
    }
    
    function pass_task( $this_task )
    {
        $this-&gt;task = $this_task;
    }    
}
?&gt;</pre><br />
<br />
It's best to leave all the functions alone and just add your task code above $this-&gt;class-&gt;append_task_log( $this-&gt;task, 'Task news.php has run.' );<br />
<br />
Next you will need to setup the task details in the admin cp. Go to Admin CP &gt; Tools & Settings Tab &gt; Task Manager &gt; Add New Task button. I've added a screenshot of the example details we need to fill out. Remember to name the <strong class='bbc'>Task PHP File To Run</strong> field the same name as your sources/tasks/ file with .php added to the end of it.<br />
<br />
<a class='resized_img' rel='lightbox[45]' id='ipb-attach-url-162-0-53932100 1283970958' href="http://www.devfuse.com/forums/index.php?app=core&module=attach&section=attach&attach_rel_module=tutorials&attach_id=162" title="task_manager.png - Size: 26.21K, Downloads: 17505"><img src="http://www.devfuse.com/forums/uploads/monthly_01_2009/post-1-1232534836_thumb.png" id='ipb-attach-img-162-0-53932100 1283970958' style='width:100;height:70' class='attach' width="100" height="70" alt="Attached Image: task_manager.png" /></a>]]></description>
		<pubDate>Wed, 21 Jan 2009 10:47:26 +0000</pubDate>
		<guid isPermaLink="false">45</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
	<item>
		<title><![CDATA[[IPB 2.3.x] Create an IPB components init page]]></title>
		<link>http://www.devfuse.com/forums/tutorials/article/46-ipb-23x-create-an-ipb-components-init-page/</link>
		<description><![CDATA[This is a module type way of loading your cache rather than editing a file. In this example our component key will be news. So paste the below contents into a file and call it news.php and save it to the sources/components_init/ folder.<br />
<br />
<pre class='prettyprint'>&#60;?php

if &#40; ! defined&#40; 'IN_IPB' &#41; &#41;
{
	print &#34;&#60;h1&#62;Incorrect access&#60;/h1&#62;You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.&#34;;
	exit&#40;&#41;;
}

class component_init
{
	var $ipsclass;

	function run_init&#40;&#41;
	{
		$this-&#62;ipsclass-&#62;cache_array&#91;&#93; = 'news';
	}
}
?&#62;</pre><br />
<br />
There is no need to change the class name, but the cache array your calling should reflect how you have named your cache. It's best to keep your component key in this example <strong class='bbc'>news</strong> the same.]]></description>
		<pubDate>Wed, 21 Jan 2009 10:22:06 +0000</pubDate>
		<guid isPermaLink="false">46</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
	<item>
		<title><![CDATA[[IPB 2.3.x] Create an IPB components location page]]></title>
		<link>http://www.devfuse.com/forums/tutorials/article/47-ipb-23x-create-an-ipb-components-location-page/</link>
		<description><![CDATA[Instead of placing your mods location in the lang_online.php file, IPB 2.3.x offers you the ability to add a mods location without editing files.<br />
<br />
This file should be placed in the sources/components_location/ folder and be named to reflect your component. I find it easier to name the components_public and components_location file the same.<br />
<br />
Here is an example of an components_location file.<br />
<br />
<pre class='prettyprint'>&lt;?php

if ( ! defined( 'IN_IPB' ) )
{
    print "&lt;h1&gt;Incorrect access&lt;/h1&gt;You cannot access this file directly. 
If you have recently upgraded, make sure you upgraded 'admin.php'.";
    exit();
}

class components_location_news
{
    var $ipsclass;
    
    function get_session_variables()
    {
        return array( '1_type' =&gt; 'news',
                      '1_id'   =&gt; $this-&gt;ipsclass-&gt;input&#91;'id'&#93;,
                    );
    }
        
    function parse_online_entries( $array=array() )
    {
        $this-&gt;ipsclass-&gt;load_language( 'lang_news' );
    
        $return = array();
    
        if ( is_array( $array ) and count( $array ) )
        {
            foreach( $array as $session_id =&gt; $session_array )
            {
                $return&#91; $session_id &#93; = array_merge( $session_array, array( 
'_url' =&gt; $this-&gt;ipsclass-&gt;base_url.'autocom=news', 
'_text' =&gt; $this-&gt;ipsclass-&gt;lang&#91;'viewing_news'&#93;, '_parsed' =&gt; 1 ) );
            }
        }
        
        return $return;
    }
}
?&gt;</pre><br />
<br />
You would of course change the component key <strong class='bbc'>news</strong> to your components key. This is a very simple example of what you can do, you also have the ability to assign a location for individual pages of your component. <br />
<br />
You can find more examples in sources/components_location/chat_sigma.php and chat_para.php including more details on the functions within the files.]]></description>
		<pubDate>Wed, 21 Jan 2009 10:11:38 +0000</pubDate>
		<guid isPermaLink="false">47</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
	<item>
		<title><![CDATA[[IPB 2.3.x] Export settings with postition order]]></title>
		<link>http://www.devfuse.com/forums/tutorials/article/48-ipb-23x-export-settings-with-postition-order/</link>
		<description><![CDATA[When you export groups settings, it exports it by ordering with conf_id. This tutorial will show you how to change that to conf_position, as it's a lot easier to review the settings.xml file later on.<br />
<br />
Open sources/action_admin/settings.php<br />
<br />
Find: (around line 2857)<br />
<br />
<pre class='prettyprint'>		$this-&#62;ipsclass-&#62;DB-&#62;simple_select&#40; '*', 'conf_settings', &#34;conf_group = {$this-&#62;ipsclass-&#62;input&#91;'conf_group'&#93;}&#34; &#41;;
		$this-&#62;ipsclass-&#62;DB-&#62;exec_query&#40;&#41;;</pre><br />
<br />
Replace With:<br />
<br />
<pre class='prettyprint'>		//$this-&#62;ipsclass-&#62;DB-&#62;simple_select&#40; '*', 'conf_settings', &#34;conf_group = {$this-&#62;ipsclass-&#62;input&#91;'conf_group'&#93;}&#34; &#41;;
		//$this-&#62;ipsclass-&#62;DB-&#62;exec_query&#40;&#41;;
		
		$this-&#62;ipsclass-&#62;DB-&#62;simple_construct&#40; array&#40; 'select' =&#62; '*',  'from' =&#62; 'conf_settings', 'order'  =&#62; &#34;conf_position ASC&#34;, 'where' =&#62; &#34;conf_group = {$this-&#62;ipsclass-&#62;input&#91;'conf_group'&#93;}&#34; &#41;&#41;;
		$this-&#62;ipsclass-&#62;DB-&#62;simple_exec&#40;&#41;;</pre> <br />
<br />
Save sources/action_admin/settings.php and your done. <img src='http://www.devfuse.com/forums/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' />]]></description>
		<pubDate>Sun, 18 Jan 2009 03:20:58 +0000</pubDate>
		<guid isPermaLink="false">48</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
	<item>
		<title><![CDATA[[IPB 2.3.x] API: Topics and Posts]]></title>
		<link>http://www.devfuse.com/forums/tutorials/article/41-ipb-23x-api-topics-and-posts/</link>
		<description><![CDATA[With IPB new API there are so many more options to mod authors, with frequently used tasks being much easier to access. One important one is the API: Topics and Posts.<br />
The below code will create my test topic, and redirect me to it automatically.<br />
<br />
<pre class='prettyprint'>/*-------------------------------------------------------------------------*/
// Dev Fuse Example - Include and Set API
/*-------------------------------------------------------------------------*/
include_once&#40;&#34;sources/api/api_topics_and_posts.php&#34;&#41;;
$api = new api_topics_and_posts&#40;&#41;;
$api-&#62;ipsclass = &$this-&#62;ipsclass;
$api-&#62;set_author_by_name&#40;&#34;Michael&#34;&#41;; /* Use the actual member name not id */
$api-&#62;set_post_content&#40;&#34;Hello test post.&#34;&#41;; /* Post */
$api-&#62;set_forum_id&#40;&#34;2&#34;&#41;; /* The forum ID to post in */
$api-&#62;set_topic_title&#40;&#34;Michaels test post&#34;&#41;; /* The topic title */
$api-&#62;set_topic_description&#40;&#34;Testing&#34;&#41;; /* The topic description */
$api-&#62;set_topic_state&#40;'open'&#41;; /* The topic state 'open' or 'closes' to choose from */
$api-&#62;create_new_topic&#40;&#41;;
$this-&#62;ipsclass-&#62;print-&#62;redirect_screen&#40;&#34;Redirecting to topic now&#34;, &#34;showtopic={$api-&#62;topic_id}&#34; &#41;;</pre><br />
<br />
Some optional settings<br />
<br />
<pre class='prettyprint'>$api-&#62;delay_rebuild = 1; /* Choose to delay stats rebuilding */
$api-&#62;topic_id; /* Id number of the new topic */</pre>]]></description>
		<pubDate>Fri, 09 Jan 2009 00:25:39 +0000</pubDate>
		<guid isPermaLink="false">41</guid>
		<creator>Michael</creator>
		<category>3</category>
	</item>
</channel>
</rss>