<?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>Bin-Blog &#187; installer</title>
	<atom:link href="http://www.bin-co.com/blog/tag/installer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bin-co.com/blog</link>
	<description>Learn about the latest in Web Development - as soon as I do.</description>
	<lastBuildDate>Tue, 13 Oct 2009 18:55:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Web Installer: The Code</title>
		<link>http://www.bin-co.com/blog/2007/07/web-installer-the-code/</link>
		<comments>http://www.bin-co.com/blog/2007/07/web-installer-the-code/#comments</comments>
		<pubDate>Tue, 10 Jul 2007 20:50:21 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/07/web-installer-the-code/</guid>
		<description><![CDATA[The last two posts on web installer did not include any code. I wanted to dump all code into one post &#8211; this is it. Please note that this is what I did &#8211; you don&#8217;t have to copy my code as it is. Just look at the code and modify it according to your [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">The <a href="http://www.bin-co.com/blog/2007/07/web-application-installer/">last two posts</a> on <a href="http://www.bin-co.com/blog/2007/07/3-simple-steps-to-create-a-web-installer/">web installer</a> did not include any code. I wanted to dump all code into one post &#8211; this is it. Please note that this is what I did &#8211; you don&#8217;t have to copy my code as it is. Just look at the code and modify it according to your needs.</p>
<h2>Getting Database Details</h2>
<h3>The Form/Frontend</h3>
<pre><code class="html">&lt;form action="" method="post"&gt;
&lt;h1&gt;Installation : Step 1&lt;/h1&gt;
Please provide the database connection details...
&lt;fieldset&gt;
&lt;legend&gt;Database Details&lt;/legend&gt;

&lt;label for='host'&gt;Database Host&lt;/label&gt;&lt;input type='text' name='host' value='localhost' /&gt;&lt;br /&gt;
&lt;label for='db_user'&gt;Database User&lt;/label&gt;&lt;input type='text' name='db_user' value='root' /&gt;&lt;br /&gt;
&lt;label for='password'&gt;Database Password&lt;/label&gt;&lt;input type='text' name='password' /&gt;&lt;br /&gt;
&lt;label for='database'&gt;Database&lt;/label&gt;&lt;input type='text' name='database' value='nexty' /&gt;&lt;br /&gt;
&lt;/fieldset&gt;

&lt;input type="hidden" name="step" value="2" /&gt;&lt;br /&gt;
&lt;input type="submit" name="action" value="Continue &gt;&gt;" /&gt;&lt;br /&gt;
&lt;/form&gt;</code></pre>
<h3>Backend</h3>
<p>Make sure that the given database details are correct.</p>
<pre><code class="php">// The First step is Setting up Database connection
//					   (the '2' is NOT a typo)
if($_REQUEST['step'] == 2) {
	//Save the data to the Session
	if(isset($_REQUEST['host'])) $_SESSION['host'] = $_REQUEST['host'];
	if(isset($_REQUEST['db_user'])) $_SESSION['db_user'] = $_REQUEST['db_user'];
	if(isset($_REQUEST['password'])) $_SESSION['password'] = $_REQUEST['password'];
	if(isset($_REQUEST['database'])) $_SESSION['database'] = $_REQUEST['database'];
	if(isset($_REQUEST['url'])) $_SESSION['url'] = $_REQUEST['url'];

	if(mysql_connect($_SESSION['host'],$_SESSION['db_user'],$_SESSION['password'])) { //Try to connect to the DB.
		$QUERY['success'][] = 'Connection to Database server successful';

		if(mysql_select_db($_SESSION['database'])) {//Select the provided database.
			$QUERY['success'][] = "Database '$_SESSION[database]' selected";

		} else {
			$QUERY['error'][] = 'The given database('.$_SESSION['database'].') does not exist. Please povide a valid database.';
			$_REQUEST['step'] = 1;
		}
	} else {
		$QUERY['error'][] = 'Unable to connect to the database. Make sure that the entered details are correct';
		$_REQUEST['step'] = 1;
	}
}</code></pre>
<p>Notice the over use of $_SESSION? That will come in use if I decide to add a Back button that enables the users to modify the data entered previously.</p>
<h2>Database Creation</h2>
<pre><code class="php">//Create the database only if it does not exist
//See if the database exists
$tables_sql = mysql_query("SHOW TABLES") or die(mysql_error());
$necessary_tables = array('Context','Project','Reminder','Setting','Task','TaskContext','User');
while($table = mysql_fetch_row($tables_sql)) {
	$necessary_tables = array_diff($necessary_tables,array($table[0])); //Remove the table from the array if it exists
}

//If there are no tables in the array that means that the all the necessary tables are present in the Database
//If some tables are missing, that means we have to create those tables...
if($necessary_tables) {
	$quries = &lt;&lt;&lt;END
-- Insert all the SQL to create the necessary tables here...
END;

	//Execute all the queries
	$all_quires = explode(";",$quries);
	$query_count = 0;
	foreach($all_quires as $query) {
		$query = trim($query);
		if($query) {
			@mysql_query($query);
			$query_count++;
		}
	}
	$QUERY['success'][] = "Database Populated.";
} else {
	$QUERY['error'][] = "Tables already in Database - I did not overwrite it. If you want to remove the old data, please delete the tables and run the installer script agian.";
}
</code></pre>
<h2>Saving the Database connection details</h2>
<pre><code class="php">
//I don't know how to escape the $ charector in heredocs - so I did this...
$config = '$config';//Heh, Heh <img src='http://www.bin-co.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />
$system_installed = '$system_installed';
$configuration = &lt;&lt;&lt;END
&lt;?php
//Configuration file for Nexty
$system_installed = true;
$config = array(
	'db_host'		=&gt;	'$_SESSION[host]',
	'db_user'		=&gt;	'$_SESSION[db_user]',
	'db_password'	=&gt;	'$_SESSION[password]',
	'db_database'	=&gt;	'$_SESSION[database]',
	'url'			=&gt;	'$_SESSION[url]',
	'absolute_path'	=&gt;	'$abs'
);

END;
if(is_writable('../configuration.php')) {
        // ...Write the $config text into the configuration.php file...

	$QUERY['success'][] = 'Saved the configuration file. &lt;a href="'.$_REQUEST['url'].'"&gt;Go to Nexty&lt;/a&gt;';
} else {
	$QUERY['error'][] = 'Configuration file (configuration.php) is not writable. Please copy the configuration code and enter it into the "configuration.php" file. Then press continue.';
}
</code></pre>
<p>See the <a href="https://nexty.svn.sourceforge.net/svnroot/nexty/install/">install folder for Nexty</a> in the Subversion server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/07/web-installer-the-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Simple Steps to create a Web Installer</title>
		<link>http://www.bin-co.com/blog/2007/07/3-simple-steps-to-create-a-web-installer/</link>
		<comments>http://www.bin-co.com/blog/2007/07/3-simple-steps-to-create-a-web-installer/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 16:00:48 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/07/3-simple-steps-to-create-a-web-installer/</guid>
		<description><![CDATA[Creating a web installer is not hard &#8211; as a matter of fact &#8211; it is downright easy. You just have to know a few things. Get the database details, create the database, save the details. That&#8217;s it!
Getting Database Details

A simple four field form will suffice. The important thing to remember is that the data [...]]]></description>
			<content:encoded><![CDATA[<p class="intro"><a href="http://www.bin-co.com/blog/2007/07/web-application-installer/">Creating a web installer</a> is not hard &#8211; as a matter of fact &#8211; it is downright easy. You just have to know a few things. <strong class="highlight">Get the database details, create the database, save the details</strong>. That&#8217;s it!</p>
<h2>Getting Database Details</h2>
<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2007/07/nexty.png' title='Nexty Installer Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/07/nexty.thumbnail.png' alt='Nexty Installer Screenshot' /></a></p>
<p>A simple four field form will suffice. The important thing to remember is that the <strong class="highlight">data must be saved as session variables</strong> &#8211; as we are using a multi-page form.</p>
<p>As soon as you get the DB details, try to <strong class="highlight">connect to the database and confirm that the DB details is correct</strong>. If the connection attempt fails, take the user back to the DB details form. Else go to step two.</p>
<h2>Insert Initial Data</h2>
<p>This part is easy &#8211; just <strong class="highlight">run a bunch of SQL statements to create the necessary table structure and insert the initial data</strong>.</p>
<h2>Save the Details</h2>
<p>This should be the last step of the installation. Just take all the data from the session variables and <strong class="highlight">write it to a file, say &#8216;configuration.php&#8217;</strong>. Write the data as PHP code &#8211; so all you have to do to retrieve the data is include the file.</p>
<p>The code for the installer in the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/07/3-simple-steps-to-create-a-web-installer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web Application Installer</title>
		<link>http://www.bin-co.com/blog/2007/07/web-application-installer/</link>
		<comments>http://www.bin-co.com/blog/2007/07/web-application-installer/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 18:07:17 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[basic]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[nexty]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/07/web-application-installer/</guid>
		<description><![CDATA[Almost all distributed web applications has an installer &#8211; it makes installation process easier for the end user. I will try to outline some of the most important things to look out for when creating an installer.
Examples of Web Installers
WordPress

Joomla

Nexty
I have created an installer for Nexty &#8211; I used the same installer for Jus5 as [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">Almost all distributed web applications has an installer &#8211; it makes installation process easier for the end user. I will try to outline some of the most important things to look out for when creating an installer.</p>
<h2>Examples of Web Installers</h2>
<h3><a href="http://wordpress.org/">WordPress</a></h3>
<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2007/07/wordpress.png' title='WordPress Installer Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/07/wordpress.thumbnail.png' alt='WordPress Installer Screenshot' /></a></p>
<h3><a href="http://www.joomla.com/">Joomla</a></h3>
<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2007/07/joomla.png' title='Joomla Installer Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/07/joomla.thumbnail.png' alt='Joomla Installer Screenshot' /></a></p>
<h3>Nexty</h3>
<p>I have created an installer for Nexty &#8211; I used the same installer for <a href="http://www.bin-co.com/blog/2007/05/jus5-light-weight-cms/">Jus5</a> as well. Here&#8217;s a screenshot&#8230;</p>
<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2007/07/nexty.png' title='Nexty Installer Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/07/nexty.thumbnail.png' alt='Nexty Installer Screenshot' /></a></p>
<h2>Functions of an Installer</h2>
<h3>Check Requirements</h3>
<p>If you software needs the GD PHP extension, check for it &#8211; it it is not present, show an error. If any folder must be writable, check for that. Make sure that the user cannot go to the next page without solving all the problems.</p>
<p>Make sure you have provided clear instructions on how to solve the problems &#8211; changing the permission might be easy for you and me &#8211; but the average user will find it very hard.</p>
<h3>Database Connection Details</h3>
<p>The user have to provide this data if our system uses a database.</p>
<ul>
<li>Host</li>
<li>User</li>
<li>Password</li>
<li>Database</li>
</ul>
<p>In some applications, the user must manually enter these data into the config file(for eg. WordPress). In other software, the user have to enter it at the time of installation. For example, Joomla uses this method &#8211; as does my application, <a href="http://nexty.sourceforge.net/">Nexty</a>.</p>
<h3>Create tables and insert initial data</h3>
<p>Check for existing data first &#8211; you don&#8217;t want to delete the existing data when reinstalling the software. This step is necessary only if you are using a Database in your application.</p>
<h3>Save the inputted data</h3>
<p>The user inputted data must be saved &#8211; in my application I just write it to the config file. But for that to work, the config file must have write permission. I also give the user an option to copy the code and place it in the config file themself.</p>
<p>Joomla also writes the values to a config file. However, WordPress inserts the data into the database. The only thing in the config file in wordpress is the database connection details &#8211; which the user must enter manually.</p>
<h3>Disable the Installer</h3>
<p>Make sure that the installer cannot be run after the installation is successfully compleated. This is important for the security of the application. You really don&#8217;t want any Yahoos opening up the install URL of your application and resetting all the data!</p>
<p>The easiest way of doing this is just deleting the installation script/folder. Joomla insists that you remove the installation folder before letting you use the application. In Nexty, removing the installation directory is recommended &#8211; but not enforced.</p>
<p>More on Web Installers in the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/07/web-application-installer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
