OpenBH Installer Part 1

Posted by admin on November 14, 2011
Blackhat, OpenBH, PHP Code

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’s see…

As OpenBH is made for Cpanel, I will also create a Cpanel installer.

A quick summary of what the installer is going to do:

  • Create FTP account
  • Create subdomain
  • Upload a zip with the OpenBH files
  • Unzip
  • Finish the OpenBH installations (keywords etc)
  • Clean up

Sadly I couldn’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.

First we will have to grab OpenBH here: https://www.syndk8.com/openbh

Make sure you create a custom zipfile because otherwise it will just install into a subfolder.

I was quite glad when I found out that Cpanel offers an API. I didn’t like the thought of having to write a scraper for the admin interface that might even break depending on the selected design.

First, let’s grab the xmlapi-php from Cpanel’s github: https://github.com/CpanelInc/xmlapi-php

Then create another php file with the following script in the same folder. Put the openbh.zip in the same folder as well.

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.

<?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->set_port(2082);
$xmlapi->password_auth($username,$password);
$xmlapi->set_debug(1);
$xmlapi->set_output('xml');

/*
   Create FTP account for file uploads
*/
$args = array(
  'user'=>$ftplogin,
  'pass'=>$ftppassword,
  'homedir'=>'/public_html/',
  'quota'=>'unlimited'
);
$res = $xmlapi->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->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->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'=>$ftplogin,
);
$res = $xmlapi->api2_query($username, 'Ftp', 'delftp', $args);

Tags: , , , ,

17 Comments to OpenBH Installer Part 1

  • Parthena says:

    Hot damn, looking pertty useful buddy.

    • Nishaa says:

      Appreiate your ithsgins. I have PowerPoint and .pdf’s along with audios and videos to upload. And I was happy for a refesher of how to do that. Cheers!.

    • Gopal says:

      The setup is hfpuell, but can you expand upon this with assistance on how to create a user and then set up access to a specific folder? I can’t seem to get this to work at all… and I thought I was pretty computer-savy. The new windows 7 administrative configuration is definitely giving me problems. Thank you in advance!

  • kdpunkvw says:

    UApT32 , [url=http://ldfxvwccpkwd.com/]ldfxvwccpkwd[/url], [link=http://huywxrjbkiyr.com/]huywxrjbkiyr[/link], http://cionjitjilrp.com/

    • Mauricio says:

      Hi Caucus,One of the first thigns you should do when reading a book about computing is to read the book’s updates and corrections page. A book represents a fixed moment in time. Sometimes there are mistakes or misprints. Often, there are new developments with the software.Both Apache and PHP are “a program that works”. If you look at the updates pages on the friends of ED site, you will find up-to-date information. You’ll also find detailed instructions in the Tutorials section of this site for using the .If you want help, you also need to be more precise in your description of what happens. Saying that “PHP is a no go” tells me nothing, apart from the fact that it doesn’t work. You need to describe what happens. You also need to say which versions you’re using, and which operating system. Vista is different from XP.It’s also better to post requests for help in a public forum, such as the one at friends of ED, rather than in an author’s blog. I’m up to my eyeballs in writing a book about Dreamweaver CS3, so don’t get much chance to devote to troubleshooting installation problems. In a public forum, there’s the likelihood that someone else might be able to come to your assistance more quickly.

    • Badjingan says:

      Update: Google looks to be rnmvoieg Wave from their catalogue, expect it to also be removed from Apps. If you have grown accustomed to Wave, there is a way of exporting every Wave you have. Please Google “Export Google Waves” for more information.

    • Harriette says:

      StudioLine Web is sowrfate that combines all the functions for creating, publishing and professional site updates. With it you have many tools to make a well-designed site, how to import images from digital cameras and scanners, create collages of images, many image editing tools like special effects and more figures.keygen=serials-hawe in this song ;Rifadije Grajcevci Kenga me e mire e- 2010

  • bigb says:

    very nice,exactly what i was looking for ! thxs

  • hehejo » Blog Archive » OpenBH Installer Part 1 I was recommended this web site by my cousin. I’m not sure whether this post is written by him as no one else know such detailed about my trouble. You are incredible! Thanks! your article about hehejo » Blog Archive » OpenBH Installer Part 1Best Regards Nick

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>