asterisk2billing.org
http://forum.asterisk2billing.org/

reseller module, again
http://forum.asterisk2billing.org/viewtopic.php?f=15&t=2436
Page 1 of 4

Author:  coborop [ Thu Aug 09, 2007 5:06 pm ]
Post subject:  reseller module, again

Yes after reading the past threads, I imagine that's very annoying, sorry:

what about the reseller module ?

Please clarify if there is already some availability, maybe in the svn trunk;
because grepping the sources of a2b 1.3 you'll find some traces of 'reseller' stuff,
why ?

Putting 500USD on the plate (and i assume, together with the other bounty donations) would let me have a reseller module by the end of the month of August ?
Or maybe later ?

Or should I forget it and buy the (I assume it's well known to you) third-party made module, which violates the GPL ?

Thank you all for your attention, your great work and support,
have a nice day

Author:  globaltech [ Fri Aug 10, 2007 12:50 pm ]
Post subject:  Re: reseller module, again

coborop wrote:
Yes after reading the past threads, I imagine that's very annoying, sorry:

what about the reseller module ?

Please clarify if there is already some availability, maybe in the svn trunk;
because grepping the sources of a2b 1.3 you'll find some traces of 'reseller' stuff,
why ?

Putting 500USD on the plate (and i assume, together with the other bounty donations) would let me have a reseller module by the end of the month of August ?
Or maybe later ?

Or should I forget it and buy the (I assume it's well known to you) third-party made module, which violates the GPL ?

Thank you all for your attention, your great work and support,
have a nice day


I am asking the same question and propose the same as above.
thanks

Author:  coborop [ Sat Oct 20, 2007 5:45 pm ]
Post subject: 

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

Author:  stavros [ Sat Oct 20, 2007 6:26 pm ]
Post subject: 

Good job coborop, that looks like it would work. I've been meaning to write up the way I do things, but I've been really pressed for time recently.

Very briefly, I use Linux-VServer to obtain total separation between the 'resellers' and the master system. This method does involve more overhead in that each partition runs its own Asterisk and A2Billing, but is extremely flexible in that resellers can't see your buy-rates and can each have different sell-rates, prompts, administrators, web interface, etc.

I'm hoping that soon I'll have time to look at implementing this to save a little CPU time on the master system.

Author:  jroper [ Tue Oct 23, 2007 12:34 pm ]
Post subject: 

Hi

Nice howto.

I'd like to plagiarise this and get it written up in the Wiki. Any objections.

Stavros,

I would really like to add the Vserver stuff into the Wiki as well, as i can see that it would have some use, do you have any good step by step links or more info on this.

Joe

Author:  stavros [ Tue Oct 23, 2007 12:45 pm ]
Post subject: 

jroper wrote:
I would really like to add the Vserver stuff into the Wiki as well, as i can see that it would have some use, do you have any good step by step links or more info on this.
All my notes for this are in my head alone currently. There are some instructions over at Telephreak, but they are very dated and overly complicated.

If we exclude getting ztdummy to work (for meetme conferences, etc) within the guests it's trivial to run A2B in a VServer. The only requirement I can think of currently is simply a matter of changing the 'bindaddr' in sip.conf and manager.conf to be the guest's IP.

I'm not finished with it yet, but my intention is to use Slony1 to replicate the Postgres tables and rdiff-backup to mirror the Vserver's folder so it's possible to fail-over to a different server. It won't be seamless for the clients, but the downtime should be negligable.

Author:  coborop [ Tue Oct 23, 2007 1:03 pm ]
Post subject: 

jroper wrote:
Hi

Nice howto.

I'd like to plagiarise this and get it written up in the Wiki. Any objections.

Joe


no objections at all, wiki it up!

Author:  ash [ Wed Feb 20, 2008 6:57 am ]
Post subject: 

Hi Guys,

I am installing a2billing in a a few VPS to achieve the reseller sort of functionality. So far the instruction here has been superb.

I have 3 seperate a2billing installed in 3 different virtual private servers and each with their own seperate databases. The problem I am having is with the cc_sip_buddies database table. I use Asterisk realtime to get the SIP clients from database. With just one instance of a2billing, I could use the table that comes with a2billing with Asterisk. Asterisk was getting SIP clients from cc_sip_buddies. Now with 3 seperate instances, I have 3 different cc_sip_buddies tables in 3 different servers. I don't think Asterisk can work with 3 seperate databases to get sip clients.

Any idea how this can be attained? How difficult would it be to change a2billing so that 3 of those instances of 2billing write to a central cc_sip_buddies table? I can then point my Asterisk server(s) to use that one cc_sip_buddies table to get the sip clients.

How you guys are dealing with this?

Thanks all in advance.

Author:  coborop [ Wed Feb 20, 2008 8:56 am ]
Post subject: 

Hi Ash,

I'm glad that my hack turned out to be useful.

Unfortunately I don't use real time Asterisk in any of my deployments
but I'm sure that someone else can help you
or that you'll reach your goal by yourself.

I'd ask you to share with us your results, once archived,
for the sake of completion.
Btw: jroper, what about the wiki stuff ?

Have a nice day,
Mike

Author:  jroper [ Wed Feb 20, 2008 9:02 am ]
Post subject: 

Hi

It is on my list at the moment - I'm in the middle of a massive A2Billing documentation project at the moment.

So if any one with good technical writing skills wants to contribute... PM me

Joe

Author:  coborop [ Wed Feb 20, 2008 9:09 am ]
Post subject: 

wow, I think that you deserve a ton of kudos jroper!

Author:  ash [ Sun Feb 24, 2008 9:46 pm ]
Post subject: 

With this solution, can you really limit a reseler within a certain balance?

I have a reseller, I want him to be able to use (and/or create customers) as long as he doe snot exceed a total of $1000 USD. Can this limit be set somehow?

Author:  stavros [ Sun Feb 24, 2008 10:17 pm ]
Post subject: 

I'm sorry, I'm editing because I've realised I'm in completely the wrong thread. Apologies for my previous reply Ash.
Which solution are you referring to, as there are two mentioned in this thread aren't there?

Added after 28 minutes:

I should learn to read before posting. You stated earlier you're using VPS, presumably Linux-VServer?
As each reseller is a customer on a parent A2Billing server, yes you can limit exposure on post-paid accounts using the credit limit. Be aware that, as this customer must be set for simultaneous usage, there may be a little 'leakage' over the credit limit proportional to the number of active calls at that moment.

Author:  ash [ Fri Feb 29, 2008 3:54 am ]
Post subject: 

Thanks starvros. Using Virtuozzo here.

I am sorry for not making myself clearer.

I am using the reseller VPS for pre-paid resellers. I need to limit the reseller (who is the only user of an a2billing installed in a given VPS with his own copy of interface, database, a2billing.conf, AGI ... etc) not to be able to spend $X amount worth calls. He can sell as many pre-paid cards as he wants but ultimately the card users will not be able to use the service unless the reseller is maintaining a positive balance.

Anyone already implemented this, or can suggest how this can be done in the simplest manner? I am ready to develop if anyone wants to provide some guideline in achieving this feature.

Thanks in advance.

Author:  krzykat [ Fri Feb 29, 2008 4:03 am ]
Post subject: 

I haven't used a reseller module yet (can't wait to get into that), but if you've got 2 A2B's back to back, then I assume you would just have your first A2B system with the reseller's account as the trunk that he uses to process all of his calls.

System A = your main system
System B = reseller's virtual system

System A has a A2B user created that is Wholesaler (B)
System B sets up a SIP trunk to System-A as he is a user of this system.

Did I make any sense on this? Your system is the provider for the Virtual system. So he can't use more than you allow him with his account on System-A.

Page 1 of 4 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/