Hi all,
this is an alternative solution to obtain the reseller feature.
Having deployed this hack on a couple of production running platforms,
for a total of five clones,
with no complains,
i hope it's ready for a public 'release'.
The main idea is to
- clone an empty (or already running) a2b installation, into different folders
- clone the a2b database
- change some configuration options in a2b and asterisk
- force in 'readonly' some fields in the a2b gui
by doing that,
you will obtain a separate a2b platform, with both admin and customers
backends,
with no resources overhead on the machine: not on asterisk, nor the web
server, neither the database.
The strongest lack of this solution is total indipendence between clones:
you won't have the ability to centralize the clones in order to obtain, for example,
viewing of your profits in real-time.
However, by understanding this patch, you will be able to rearrange this
whole thing to better fit your needs.
I suggest to accomplish this how-to a minimum knowledge of the a2b codebase and folder structure.
Ok, let's start:
- change your current working directory in /etc/asterisk and create another
context in extensions.conf, poiting to another a2billing agi script,
something like, for example:
[a2billing2]
exten => _X.,1,DeadAGI,a2billing2.php
exten => _X.,2,Wait,2
exten => _X.,3,Hangup
- clone the a2b database
- touch and give write access to the web server user to /etc/asterisk/additional_a2billing_sip2.conf and /etc/asterisk/additional_a2billing_iax2.conf
- copy /var/lib/asterisk/agi-bin/libs_a2billing in /var/lib/asterisk/agi-bin/libs_a2billing2
change the includes in /var/lib/asterisk/agi-bin/a2billing2.php from line 27 to 32
change the define in /var/lib/asterisk/agi-bin/libs_a2billing2/Class.A2Billing.php on line 21
- copy /var/www/A2Billing_UI in /var/www/A2Billing_UI2
change the define in /var/www/A2Billing_UI2/lib/Class.A2Billing.php on line 21
change the load_conf in /var/www/A2Billing_UI2/lib/defines.php on line 9
- copy /var/www/A2BCustomer_UI in /var/www/A2BCustomer_UI2
change the define in /var/www/A2BCustomer_UI2/lib/Class.A2Billing.php on line 21
change the load_conf in /var/www/A2BCustomer_UI2/lib/defines.php on line 10
- add the lines:
#include additional_a2billing_sip2.conf
and
#include additional_a2billing_iax2.conf
to the /etc/asterisk/sip.conf file
- copy /etc/asterisk/a2billing.conf in /etc/asterisk/a2billing2.conf
and change the database section to point to the newly created a2b database
clone.
You may also want to change the 'backup_path' option,
buddy_sip_file and buddy_iax_file to something like
/etc/asterisk/additional_a2billing_sip2.conf and /etc/asterisk/additional_a2billing_iax2.conf,
force the 'context' option in the 'peer_friend' section to something like
'a2billing2'
and, in general, change the other options to make them point to the new
clone.
- you may also want to force in 'readonly' some fields in the a2b customer
back-end,
to prevent them being changed by the reseller.
For example, if you want to force the context field of the sip friend, you can
add the 'readonly' attribute to the
/var/www/A2BCustomer_UI2/Public/form_data/FG_var_friend.inc file on line 296,
like that:
"size=40 maxlength=40 $CONTEXT_default readonly",
And, for example, if you want to change to 'readonly' also the buying
price field of all the rates,
you can change the
/var/www/A2BCustomer_UI2/Public/form_data/FG_var_def_ratecard.inc file on
line 130 like this:
"size=30 maxlength=20 readonly",
then do the same on lines 139 and 148
- harden the a2b login routine, by editing, in every clone, the file:
~A2Billing_UI*/lib/module.access.php
and force a2b to re-check the credentials in every page, by adding,
around line 135, just before the "FUNCTIONS" part, this:
$DBHandle = DbConnect();
$return = login ($_SESSION["pr_login"], $_SESSION["pr_password"]);
if (!is_array($return) || $return[1]==0 ) {
header ("HTTP/1.0 401 Unauthorized");
Header ("Location: index.php?error=1");
die();
}
- consider also to give a restricted access to the reseller and his
customers:
via acl,
by modifying the 'webcustomerui' section of the /etc/asterisk/a2billing2.conf file,
by hiding the menu links in the
/var/www/A2BCustomer_UI2/Public/templates/default/main.tpl file
- reload asterisk
Now point your browser to http://[a2b-url]/A2Billing_UI2 and
http://[a2b-url]/A2BCustomer_UI2,
you may want to change the ui passwords, cleanup the customers and change
the rates.
Best Regards,
Mike
Last edited by coborop on Mon Mar 24, 2008 6:22 pm, edited 1 time in total.
|