Jump to content

Banner Exchange Credit System


ShibSta

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
Link to comment
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.
Link to comment
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
Link to comment
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.
Link to comment
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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.