Jump to content

How to get a counter related value that works with my server?


Marcus2000

Recommended Posts

Hi guys,

 

I know this is a bit of a messy question, but i have a problem with some code that my friend wrote, and now i don't know how to fix it.

 

Basically there is a line of code on my site, and what my friend told me was that this specific line of code has to do with the server and is similar to a ticking clock.

 

What he told me is that it is a "counted related value" which needs to been changed every now and then when it hits the servers limit.

 

This actually means nothing to me, but i'm hoping some one out there knows what my friend means. Anyway this is the line of code i need to change, or in fact the number i need to change. The problem is that as i dont really know what i'm doing i have no idea as to what to change the number to.

 

Please help guys, I really need to fix this asap. Anyways this is the code:

 

// unique references

define ('NID', floor(hexdec(substr(uniqid(''),0,11))/100)-52330000000); // table id

define ('SID', strtoupper(uniqid(''))); // short unique id

define ('UID', strtoupper(md5(uniqid('')))); // 32char id

 

Its the number 52330000000 that i had to change the last time i had this problem.

 

Many thanks in advance.

Link to comment
Share on other sites

Maybe this may help you guys out a bit. This is what my friend told me to do the last time I had this problem:

 

REPLACE

define ('NID', floor(hexdec(substr(uniqid(''),0,11))/100)-52230000000); // table id

 

BY

define ('NID', floor(hexdec(substr(uniqid(''),0,11))/100)-52330000000); // table id

 

(52230000000 to 52330000000, 52330000000 BEING THE CORRECT VALUE, it’s a counter related value, and on some servers, the counter already reaches its limit with the initial figure)

 

This did in fact work for about 3 or 4 weeks. But now I have the same problem, where my uses can't make any changes on their accounts on my website.

 

Link to comment
Share on other sites

this has to do with the integer limit of PHP. I have ran the expression that you have provided and get an int of 2250700398. Since it is dependant on uniqid, this number is always incresing since it is based off of the current time in milliseconds which then gets converted with hexdec. I'm assuming that your platform is 32 bit otherwise you would not be having this issue. Basically what is happening is the number has reached its maximum integer limit and is being converted into type float, which apparently is a bad thing. I don't know the specifics here so it is hard to tell you exactly what you need to do. Making the subtracted number (52230000000) is on way of handling this, but it is inefficient as it will require you to change the number frequently. My thinking right now is that this is the only solution, as you could subtract an ever increasing number like (time() * 20), this would increase the time span that the number would remain valid, but you will still need to change it.

 

Further reading: http://us2.php.net/manual/en/language.types.integer.php

 

There is most likely a better way to do whatever it is that this does.

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.