<?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>hehejo</title>
	<atom:link href="http://www.hehejo.info/feed" rel="self" type="application/rss+xml" />
	<link>http://www.hehejo.info</link>
	<description>nothing to see here</description>
	<lastBuildDate>Mon, 14 Nov 2011 04:37:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>OpenBH Installer Part 1</title>
		<link>http://www.hehejo.info/openbh-installer-part-1</link>
		<comments>http://www.hehejo.info/openbh-installer-part-1#comments</comments>
		<pubDate>Mon, 14 Nov 2011 04:32:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blackhat]]></category>
		<category><![CDATA[OpenBH]]></category>
		<category><![CDATA[PHP Code]]></category>
		<category><![CDATA[blackhat]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[openbh]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.hehejo.info/?p=6</guid>
		<description><![CDATA[I wanted to give OpenBH a try by installing it on a lot of subdomains. There is no way that I am going to waste a few days by copying and pasting the OpenBH files and then installing each one by hand. Let&#8217;s see&#8230; As OpenBH is made for Cpanel, I will also create a [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to give OpenBH a try by installing it on a lot of subdomains. There is no way that I am going to waste a few days by copying and pasting the OpenBH files and then installing each one by hand.</p>
<p>Let&#8217;s see&#8230;</p>
<p>As OpenBH is made for Cpanel, I will also create a Cpanel installer.</p>
<p>A quick summary of what the installer is going to do:</p>
<ul>
<li>Create FTP account</li>
<li>Create subdomain</li>
<li>Upload a zip with the OpenBH files</li>
<li>Unzip</li>
<li>Finish the OpenBH installations (keywords etc)</li>
<li>Clean up</li>
</ul>
<p>Sadly I couldn&#8217;t find a way to unzip the zip into another directory. If there is a way to do this, please leave a comment as it would save a ton of wasted bandwidth and time.</p>
<p>First we will have to grab OpenBH here: <a href="https://www.syndk8.com/openbh" target="_blank">https://www.syndk8.com/openbh</a></p>
<p>Make sure you create a custom zipfile because otherwise it will just install into a subfolder.</p>
<p>I was quite glad when I found out that Cpanel offers an API. I didn&#8217;t like the thought of having to write a scraper for the admin interface that might even break depending on the selected design.</p>
<p>First, let&#8217;s grab the xmlapi-php from Cpanel&#8217;s github: <a href="https://github.com/CpanelInc/xmlapi-php" target="_blank">https://github.com/CpanelInc/xmlapi-php</a></p>
<p>Then create another php file with the following script in the same folder. Put the openbh.zip in the same folder as well.</p>
<p>Please note that this will only create a single subdomain and upload an unzip openbh.zip. I will talk about the OpenBH installation and automation of multiple installs in a later post. Of course this script can be used for anything else as well. Get creative.</p>
<pre class="wp-code-highlight prettyprint">&lt;?php

/*
   OpenBH Cpanel Installer
   by hehejo
   14.11.2011
*/

$username      = 'PWUSERNAME';
$password      = 'CPPASSWORD';
$server        = 'CPDOMAIN';
$domain        = 'ADDONDOMAIN';

$ftplogin      = 'installerftp@' . $server;
$ftppassword   = 'abcd1234';

$subdomain = 'SUBDOMAIN';

set_time_limit(300);

/*
   Load xmlapi
   xmlapi settings
*/
require_once('xmlapi.php');
$xmlapi = new xmlapi($server);
$xmlapi-&gt;set_port(2082);
$xmlapi-&gt;password_auth($username,$password);
$xmlapi-&gt;set_debug(1);
$xmlapi-&gt;set_output('xml');

/*
   Create FTP account for file uploads
*/
$args = array(
  'user'=&gt;$ftplogin,
  'pass'=&gt;$ftppassword,
  'homedir'=&gt;'/public_html/',
  'quota'=&gt;'unlimited'
);
$res = $xmlapi-&gt;api2_query($username, 'Ftp', 'addftp', $args);

/*
   Open FTP connection
*/
$ftp = ftp_connect('ftp.' . $server);
$login_result = ftp_login($ftp, $ftplogin, $ftppassword);  

/*
   Create Subdomain
*/
$args = array($subdomain,$domain,0,0,'/public_html/' . $subdomain . '.' . $domain);
$res = $xmlapi-&gt;api1_query($username,'SubDomain','addsubdomain', $args);

/*
   Upload openbh.zip to subdomain folder
*/

$upload = ftp_put($ftp,$subdomain . '.' . $domain . '/openbh.zip', 'openbh.zip', FTP_BINARY);

/*
   Unzip openbh.zip into subdomain folder
*/
$args = array('/public_html/' . $subdomain . '.' . $domain,'openbh.zip');
$res = $xmlapi-&gt;api1_query($username, 'Fileman', 'extractfile', $args);  

/*
   Delete openbh.zip
   Close FTP connection
*/
ftp_delete($ftp,$subdomain . '.' . $domain . '/openbh.zip');
ftp_close($ftp);

/*
   Delete installer ftp account
*/
$args = array(
  'user'=&gt;$ftplogin,
);
$res = $xmlapi-&gt;api2_query($username, 'Ftp', 'delftp', $args);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hehejo.info/openbh-installer-part-1/feed</wfw:commentRss>
		<slash:comments>3194</slash:comments>
		</item>
	</channel>
</rss>

