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
- Simplx
#!/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;
<?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>");
}
?>
$r_op = cdsql($redirect_op);
$r_tile = cdsql($redirect_tile);
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);
}
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