• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Integrating Modernbill into Plesk CP Auto Login

S

simplx

Guest
Would anyone be interested in a How-To on how I integrated modernbill into the plesk CP using a login bridge that I wrote? If so I will post it here.

- Simplx
 
Yeah sure I would as I am looking going to be installing MB shortly.
How have you found it?
 
Modernbill is nice. A bit overwhelming in the beginning, but after reading the manual and messing with multiple installations of it I got it down. I will post it here in a couple of days.

- Simplx
 
Gr8 thanks. Yeah I had figured as much..but I'm sure we'll get through it all..
 
waiting

Thanks for trying to help us out.We are still waiting.Thanks
 
First I must say the following:

I hold no responsability for what happens when you use this script. I do not claim it to be 100% perfect or secure in anyway.

Now, if you agree with the above then you may continue.

Since plesk has the ability to use custom buttons I decided that it would be a good way to insert modernbill into my control panel for the users. Now the first problem is that users have access to edit thier custom buttons. So I opened up

/usr/local/psa/admin/plib/templates/domains.tpl

and commented out {CBUTTONS_BUTTON} on line 22. This way users cannot have access to edit the buttons I create.

Next thing to do was create the buttons every time a client was created. So in the even manager I added a line to execute the following script.

Code:
#!/bin/bash

client=$1

# create the custom button under "Added Features" that will allow the client to see the stats page
/usr/local/psa/bin/custombutton.sh \
        -c -owner $client \
        -text "Account Home" \
        -place client \
        -url "https://<billing_url>/include/config/mblogin.php" \
        -url_comp email \
        -internal true \
        -file /usr/local/psa/admin/htdocs/skins/winxp.silver/images/account_home.gif \
        -sort_key 100;

/usr/local/psa/bin/custombutton.sh \
        -c -owner $client \
        -text "Account Info" \
        -place client \
        -url "https://<billing_url>/include/config/mblogin.php?op=menu&tile=myinfo_tab" \
        -url_comp email \
        -internal true \
        -file /usr/local/psa/admin/htdocs/skins/winxp.silver/images/control-panel.gif \
        -sort_key 101;

/usr/local/psa/bin/custombutton.sh \
        -c -owner $client \
        -text "Domains & Packages" \
        -place client \
        -url "https://<billing_url>/include/config/mblogin.php?op=menu&tile=mysites_tab" \
        -url_comp email \
        -internal true \
        -file /usr/local/psa/admin/htdocs/skins/winxp.silver/images/internet.gif \
        -sort_key 102;

/usr/local/psa/bin/custombutton.sh \
        -c -owner $client \
        -text "Account Billing" \
        -place client \
        -url "https://<billing_url>/include/config/mblogin.php?op=menu&tile=myfinance_tab" \
        -url_comp email \
        -internal true \
        -file /usr/local/psa/admin/htdocs/skins/winxp.silver/images/dollar.gif \
        -sort_key 103;

/usr/local/psa/bin/custombutton.sh \
        -c -owner $client \
        -text "Technical Support" \
        -place client \
        -url "https://<billing_url>/include/config/mblogin.php?op=menu&tile=getsupport_tab" \
        -url_comp email \
        -internal true \
        -file /usr/local/psa/admin/htdocs/skins/winxp.silver/images/support.gif \
        -sort_key 104;

Each line of this script creates a button to point to a different menu item in modernbill. Replace <billing_url> with the url and path to your modernbill installation.
After the buttons were created every link will point the user to the modernbill login. I decided I didn't like this so I decided to create a bridge that gets the users email from plesk using the "-url_comp email" arg.
I wrote this in PHP4, all info is submitted via secure socket layer ( SSL ) so nothing is in plain text.

PHP:
<?php
/* I added some security up here to make sure this script could not be accessed outside of plesk. I suggest you do the same. For my own security reasons I did not add it here */
// Check to see if modernbill cookies exist
$myip = $_COOKIE['myip'];
// Get the users remote ip address
$addr = $_SERVER['REMOTE_ADDR'];
// get the users email from the url
$user = $_GET['email'];
// Get the tile that modernbill will redirect to
$tile = $_GET['tile'];
// Get the op ( This is almost always menu
$op   = $_GET['op'];

// If the user is not authenticaed the myip cookie doesn't exist. So query for the client_real_pass in the modernbill database, and log them in
if ( !isset($myip) ) {
    $host = "localhost";
    $user = "<database_user>"; /* replace with actual db username */
    $pass = "<database_pass>"; /* replace with actual db password */
    $db   = "<database_name>"; /* replace with actual db name */
    @mysql_connect($host,$user,$pass);
    @mysql_select_db($db);
    $sql  = "SELECT client_real_pass FROM modernbill.client_info WHERE client_email = '" . $email . "'";
    $res  = @mysql_query($sql);
    $pass = @mysql_fetch_row($res);
    $pass = $pass['0'];
    @mysql_close();
    $formop = "login";
    print ("<form name=\"form\" method=\"post\" action=\"https://<billing_url>/index.php\">");
    print ("<input type=\"hidden\" name=\"username\" value=\"$user\">");
    print ("<input type=\"hidden\" name=\"password\" value=\"$pass\">");
    print ("<input type=\"hidden\" name=\"newtile\" value=\"$tile\">");
    print ("<input type=\"hidden\" name=\"newop\" value=\"$op\">");
    print ("<input type=\"hidden\" name=\"op\" value=\"$formop\">");
    print ("</form>");
    print ("<body onLoad=\"form.submit();\">");
}
// If the user already has the myip cookie, and is already authenticated then redirect them to the correct tile in modernbill.
elseif ( isset($myip) && $myip == $addr ) {
    print ("<script language=\"Javascript\">document.location.href='https://<billing_url>/user.php?op=$op&tile=$tile';</script>");
}
?>
Again, replace <billing_url> with the url and path to your modernbill installation.
After this was completed, I added a couple of lines to index.php in my modernbill installation to make sure once they are logged in they get redirected to the correct tile
find the lines
PHP:
$r_op   = cdsql($redirect_op);
$r_tile = cdsql($redirect_tile);
and replace with
PHP:
if ( isset($_REQUEST['newop']) && isset($_REQUEST['newtile']) ) {
    $r_op   = cdsql($_REQUEST['newop']);
    $r_tile = cdsql($_REQUEST['newtile']);
} else {
    $r_op   = cdsql($redirect_op);
    $r_tile = cdsql($redirect_tile);
}
That's it! Once again I hold no responsability for what happens when you use this script. I do not claim it to be 100% perfect or secure in anyway.
Always make backups of files you edit, and never post anything with critical information.

Feedback is always encouraged. Improvments as well.

- Simplx
 
I was just wondering if anyone had any feedback on this post? I always like to get constructive critisism.

- Simplx
 
Hi. it looks really nice. but actually it would be very nice to have it go the other way. to be able to logg in to plesk directly from modernbill. even better if it was possible to integrate the plesk interface/gui into a modernbill window/site.

my reason for this is that most of my costumers would use modernbill most of the time, to pay bills and so on. so i might as well provide all the options under modernbill.
 
I am actually in the process of connecting my MB installation with Plesk at the moment.

The program I am having is when it comes time to process a new account in the MB API Queue I get an error about

"The requested URL /cgi-bin/cu_wrapper.cgi was not found on this server."

Anyone know where I can get a copy of this file and where I need to upload it to my Plesk install.


I also like the intergration you have used of MB into Plesk with the custom button, I too will be doing this route as well.

Thanks for the help.
 
It's been a while since I have written this, but with the release of Plesk 8, and Modernbill V5 coming up very soon I will be updating it to be integrated into the desktop screen, and also on the left navigation pane. If anyone is interested please let me know.

Thanks,

- Simplx
 
Originally posted by simplx
It's been a while since I have written this, but with the release of Plesk 8, and Modernbill V5 coming up very soon I will be updating it to be integrated into the desktop screen, and also on the left navigation pane. If anyone is interested please let me know.

Thanks,

- Simplx

I'm very interested if you still have time to do it.
 
And since you're not including the security you added, would you also post what you think should be there and where we would need to look to add this bit of code?

Thanks.
 
Back
Top