Jump to content

Archived

This topic is now archived and is closed to further replies.

ShibSta

Banner Exchange Credit System

Recommended Posts

I am trying to make a banner exchange which I can define the return ratio in the configuration file.
For ex. If I insert a 10:9 ratio...
Every 10 Banner Impressions They Have On Their Site
They Receive 9 Banner Impressions On Other Sites...

The problem is: How would I do this in php?
I know I could give 9 credits on each impression and remove 10 on each given impression but that seems like a lazy way and inaccurate count in credits.
I know I could take the credits and divide by 10 to get the real amount. I'd like to find a way to bypass all that lazy stuff.
Is there a mathematical way I can do this?

Thanks

Share this post


Link to post
Share on other sites
[quote]Is there a mathematical way I can do this?[/quote]

I bet there is, and you'll find it in the php help forum which is where I'm moving this thread.

Share this post


Link to post
Share on other sites
Well, do they need to earn 10 impressions in order to get the 9? 

How about just adding 9/10 of a credit for each impression?  Then they require at least one credit to get an impression.  This would mean they wouldn't get an impression for the first impression, but would for the nine subsequent impressions.

Share this post


Link to post
Share on other sites
True, I could do that... Anyway, few more questions...
[b]1)[/b] Are decimals hard to deal with?
[b]2)[/b] Lets say I want an affiliate system where they get 5% of what the affiliate gets... How would I determine 5% of 0.9?
----(Sorry, been a long time since I messed with percentages...)
[b]3)[/b] I don't want several mysql connections at once... Since this is a banner exchange, there would be hundreds or thousands a second... I was thinking of  using a cron. However, the problem with that is the person has to have 1 credit or more to get an impression... If he already got the impression but that impression is in cron he may get another and then have a negative credit count...
Ex.
Banner 1 = 1 Credit
Banner 1 >= 1 Credit
Banner 1 Displayed
Banner 1 - 1 Credit -> In Cron
Banner 1 >= 1 Credit
Banner 1 Displayed
Banner 1 - 1 Credit -> In Cron
Cron Runs
Banner 1 = -1 Credit

Share this post


Link to post
Share on other sites
[quote author=ShibSta link=topic=110177.msg446400#msg446400 date=1159917634]
True, I could do that... Anyway, few more questions...
[b]1)[/b] Are decimals hard to deal with?
[/quote]
No. 
[quote author=ShibSta link=topic=110177.msg446400#msg446400 date=1159917634]
[b]2)[/b] Lets say I want an affiliate system where they get 5% of what the affiliate gets... How would I determine 5% of 0.9?
----(Sorry, been a long time since I messed with percentages...)
[/quote]
.9 * .05 is 5% of .9.  That is the same as .9 * 5 / 100.
[quote author=ShibSta link=topic=110177.msg446400#msg446400 date=1159917634]
[b]3)[/b] I don't want several mysql connections at once... Since this is a banner exchange, there would be hundreds or thousands a second... I was thinking of  using a cron. However, the problem with that is the person has to have 1 credit or more to get an impression... If he already got the impression but that impression is in cron he may get another and then have a negative credit count...
Ex.
Banner 1 = 1 Credit
Banner 1 >= 1 Credit
Banner 1 Displayed
Banner 1 - 1 Credit -> In Cron
Banner 1 >= 1 Credit
Banner 1 Displayed
Banner 1 - 1 Credit -> In Cron
Cron Runs
Banner 1 = -1 Credit
[/quote]
How would you get the data to cron?  You are going to have to have multiple connections to something, and a database is way better at that than a flat file.

Just a side note, and I am trying as hard as I can to not be insulting in this statement.  I'm wondering why you are making a banner exchange.  I believe there are plenty of free banner exchanges out there; and, they kind of went out of style around 1998.

Share this post


Link to post
Share on other sites
I'd make a cron by having my PHP code write queries to a file (protected by .htaccess) which is then processed by a php file thats ran by the cron.
Wouldn't that many connections on a database be too many? I mean, hundreds a minutes for a new exchange alone...

I am making a banner exchange because I:
1) Am trying to learn PHP, this is my first fairly large project.
2) I own an arcade and owning a banner exchange will be that much better...
--Kinda like owning a football team and a stadium..
3) I want a script that I made and I'm familar with the source code and how it's layed out so that I can easily upgrade and constantly add new features...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.