Help - Search - Members - Calendar
Full Version: question to programmers
Get Paid Forum - Get Paid Discussion > Webmaster's Corner > General Discussion on Building, Running & Making Money from a Website
Akuma
there is something I have been wondering lately and I would like to know if you don't mind about your secrets revealed ab.gif

it is about avoiding the members to click a link more than once...
how do you prefer to do it?
using cookies or storing the member id and date in your db?

cookies seem a pretty good idea but I think most of the scripts use the database...
if you do use the db to store that data, what do you prefer: cleaning old entries manually or automatically -using triggers or anything like that?
ReDucTor
cookies have the massive downfall, of its very easy to bypass

storing it all in one table with who has clicked what and what they clicked has the space aspect.

You could either store a limit of links, or else remove all tracks on expire, removing tracks on expiration is good and easy, although one thing wrong there, not everyone has enough users for everything to expire.

An alternative is using bitwise operations on a number of ints has a limit, unless you add multiple fields everytime one expires, if you use a 32-bit integer that means its going to take you 32 integers to record 1000 of them taking up 4000bytes(3.9kb) per user, with 1000 users thats 4,000,000bytes(3.8mb) while the space is better then having to store the id and the member id, although its only half of it, if your using ints of the same size.

or you could use sessions although its easy enough to cause the session to get destroyed.
Akuma
I do not think sessions are useful for this kind of issues...
sessions are fine to login/logout but I would not use them to avoid double-clicks

btw I am not making a GPT script right now
just that I was thinking about the pro and the cons of cookies and db storage for GPT programs
and had curiosity =]

which one would you use?
SupaDupaFly
DB..

If i make a PTR script i would make 2 or more tables for members and links etc. For examle, if the site have 1000 members it would be much better to make two tables for members (500 records for each, and more than 1000 will need the 3rd table and so on..). This way you can do searches etc much faster. You can do this on links as well. Do something like link_id=1233 (where 1st digit = table number) will get the link from table 1 and if you have link_id=2233 you will get the link from table 2. Just an idea aa.gif I dont know if there are problems with this structure but should work.
ReDucTor
while I haven't looked at MySQL source, I should download it some time, see some ways I could optimise my queries, although I would think if its a primary, unique field thats auto incremented, then I would think that It would already have it calculated the size of rows and amount to jump.

e.g.

addr=(DWORD*)(index*sizeof(table_t)+data_offset)

Although, that is doubt fall, if you use your own db type, ya, that would be easy and fast aa.gif

Considering it would only need to do, the following.

go to first row
check field if value is this if true use if not continue

There is a few simple instructions involved here, CMP, JZ, ADD and JMP

0x00000001: CMP DWORD PTR [EAX], index
0x00000002: JZ 0x000000005
0x00000003: ADD EAX, 0x00000004
0x00000004: JMP 0x00000001
0x00000005: RET

Although, there is likely to be other things that MySQL uses, although it might create its own code for the queries, but it also has debugging, and stuff, and checking for the end of the data, but thats about as simple as things could get.

If its just an integer it should work fine comparing the data, even if you went as far as doing QWORDs it shouldn't generate that much of a loose that you can see it, just don't be like some and use a string.

If it does run bad, I recommend find some way to optimise your code or get a new processor, or ram if it moves it all to the ram and its slow, or your hdd if its slow reading that, well there could be all sorts of things, processor mainly..
3a3
the only correct answer is to use some kind of database or text file.

using cookies - that's rediculous - anybody can delete them from his PC .. and there are a lot of people, who have disabled them as well .. so that's the most stupid thing to do

using sessions - that's actually the same, only the session data is stored on server. and the data is deleted when the session expires .. usually session expires when the visitors closes his browser .. so by opening the browser again, he could click again. Of course you can save the session info longer .. but I assure you, that's not a good choice

the thing I would recommed is to store that in a MySQL table .. and when the ad exires - generate a report (and save it) and then delete the data from your MySQL table.

of course you can use text files as a storage place .. but I don't think that's a good choice, because it can be rather hard for you to search for the members who have clicked the links already. The easiest way to do this is MySQL or any other type of database.

[ROFL @ ReDucTOR] - a guy just asks you a simple solution and you give him some ASM code snippets ab.gif ad.gif ae.gif ao.gif
ReDucTor
Ya, sometimes I can't help it, was just trying to point it out that splitting different tables isn't going to affect it much.

Ya, Sessions are just as easy to destroy.

For your own file, Just make your own search features to check things, I recommend making it a binary file, storing data as integers so then its faster, although if you do all your processing with strings using plain text might be faster, because there is no conversion, although depending on the language there could still be converison.

But for finding speed it would definately be faster no matter what database type, I won't go into code for reasons why. aa.gif
petcalent
which command increments index in the asm sample?
3a3
QUOTE (petcalent @ Mar 3 2003, 02:57 AM)
which command increments index in the asm sample?

probably:
QUOTE
0x00000003: ADD EAX, 0x00000004


I haven't studied ASM a lot .. but some things you can guess from the syntax ab.gif ad.gif ae.gif
petcalent
Now I think the index pointer was updating
automatically each time you used it
but cannot remember for sure. aj.gif
SupaDupaFly
I use asm for cracking not for websites -.-
Only good programmers know asm not php coders.. Yes sorry to say this but PHP is hmmmm easy? Nway,

Making more than 1 table will help! There can be 5000 members and 100+ of them can access ur db at the same time, so if you have 5000 rows in your db that will take ages. But if you have 5 tables each with 1000 records you will have much shorter time.

You can have ids like a00 to z99 3 char, and a=table A, z= table Z, or you can have aaa to zzz. So first letter is the table name. Instead of doing 000001 034833 5473473..

I did this db struct in one of my sites today and it improved everything. Making more than 1 table for most accessed stuff is the best thing to do. Well in my case it did, you should try it aa.gif
ReDucTor
QUOTE
Total Records: 1657
Query: SELECT * FROM url WHERE url=1600
Time: 0.0064500570297241 Seconds

--------------------------------------------------------------------------------

Total Records: 5
Query: SELECT * FROM payments WHERE payment_id=3
Time: 0.00030601024627686 Seconds


only 0.0061s difference with 1652 more rows..this is on a busy server these tests, yes, there is a difference, but tell me do you notice that 0.0061 seconds? you would need for this extra additonal speed, per second 156.25 queries..anyone got a few million to do some tests on? I couldn't be bothered looking through stuff for good places to grab stats on.

QUOTE
I use asm for cracking not for websites -.-


I don't use it for coding websites, but thats the way the machine processes your information, as you should know, those opcodes(0x90 - nop, etc) are ASM, so your machine is thinking that stuff, so if you are getting down to the fine line of speed optimisation thats what you need to get into..
top-designing
First question: What if the user browser do not accept cookies? You will loose a customer.
Second: What if the user is clever enough to delete his cookies? How many times you will pay it? But if you will have 100 clever users? You will be broke in one day aa.gif.

Simply the best way is to secure through database, but here you can manage the process to work faster.
Unfortunately in this moment a lot of CAC scripts are making some unnecesary steps which will take more bandwith and time. For example i'm against forced login for every operation (like when you are reeding a sent email).

Also if you will think well your database structure, you will be able to bring only a minimal set of data, which of course it will be reflected in your site speed (in a good sense).

Best Regards
top-designing
Ha ha ha do you know what is the problem with the public hosts?

Are hosting a lot of P2R sites, which unfortunately are made by some strange "programmers".
For example how much of them are using this: "mysql_free_result();" after a select querry?
I saw at least 20 CAC scripts and no one use that. Think at all the data loaded in the MySQL server memory
and this may be a possible answer for your question.

Also MySQL is the fastest database server available mow (not so powerful like Oracle or MSSQL) but fastest and of course free aa.gif.

Best regards
ReDucTor
I free the result, only in the following cases.

  • Script does that fetch in a loop(while, for, etc)
  • Large fetch
  • Very very busy file
  • Runs as a processes


There is no point in unallocating that block manually if that page is only there for a very little while, and isn't extremely large, its unallocated at the end of the script anyway.

Ya, MySQL is the best for compatability also, its just about everywhere, also very easy to install, Just grab the rpm and "rpm -i mysql.rpm" aa.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.