Thanks for you help in advance.
I am trying to figure out the structure of the cookie file, more specifically i want to be able to determine the expiry time. From the cookies i have created they all appear to be in a standard format. Name, Value, website,followed by 5 numbers and a star. See example below.
name
value
www.website.co.uk/
1536
3041141504
30135951
1632526096
30135949
*
Obviously the expiry time is one of the numbers, the question is which one. From experiments I have determined that the first and fifth number don't seem to change. In a case where i generated three cookies at the same time with a 1000 second time difference i noticed that the fourth number appeared to increase by 2000 suggesting that this has a connection with the expiry time.
Can anyone confirm if i am heading in the right direction? And does any one know how i convert this to a human time and date(preferably in php but any language would give me a starting point)
thanks
Jason
I am trying to figure out the structure of the cookie file...
There isn't one. It's entirely up to the browser where and how to store cookies on the client computer. You can certainly solve this for popular browsers, but it won't be the same solution for all of them. Some store cookies in flat files; others store them in individual files (per cookie, or per site), others as SQLite databases...
I have figure out the answer. Thanks to everyone who responded.
The format of the the cookie in ie8 is:
name
value
website
flags-not entirely sure what this is
expiration time (low)
expiration time (high)
creation time (low)
creation time (high)
To convert these numbers into actual times you can use the following formula:
time = 1*10-7*(high*2^32+low)-1164447360
thanks again
Jason
Related
I'm fairly new to PHP, and I'm trying to write a script that solves the following
I have an RSS feed that gets saved to my server every 10 minutes (copied from elsewhere).
There is a problem with the timestamps (pubDate tag) on the RSS feed, they always have the correct date but 00:00:00 GMT as the timestamp (I have no control over this).
Therefor, when I use an autotweeting program to tweet updates from the feed (it checks it every hour or so), it won't - It only tweets the first update of each day as a result.
Therefor, what I'm trying to do to fix it to some degree is to check if the feed has changed, and if it has, change the saved pubDate to the current server time on only the new items.
I'm also kind of confused as to how I can have it check for changes - If I have a corrected version (with fairly accurate timestamps) saved to my server, it will ALWAYS think there are changes, because the timestamps will always be 00:00:00. I'm thinking, check both feeds for items including the full strings such as <guid isPermaLink="true">http://services.runescape.com/m=adventurers-log/a=161/display_player_profile.ws?searchName=A13d&id=-463827091</guid> - Since the id= at the end stays constant, it would only change the <pubDate> of items found to be new.
http://services.runescape.com/m=adventurers-log/a=161/rssfeed?searchName=A13d Here is a feed as an example. If anyone could get me started or point me to some kind of tutorial that might help, I'd really appreciate it. This is over my head, but something I need to learn how to do.
Maybe there is something wrong with your code parsing the timestamp, date format perhaps?
I believe the method of doing full string comparisons(<title> & <description>) between items with the same <guid> is your best bet. Here is some reading about RSS duplicate detection if you are interested.
I have a crawler that crawl hundred of thousands of pages and index/parse the contents of the page, and one thing I'm struggling with is to check if the content of a page has been updated, in an efficient way, without having to crawl it and check the content of the page.
Obviously I could just load the whole page, and re-parse everything and compare it all to what I have stored in my database. However that is very inefficient and use a lot of computing resulting in high hosting bills.
I'm thinking of comparing hashes, the problem with this is that if the page has changed a single byte or character, the hash would be different. So for example if the page display the current date on the page, every single time the hash would be different and tell me that the content has been updated.
So... How would you do this? Would you look at the kb size of the HTML? Would you look at the string length and check if for example the length has changed more than 5%, the content has been "changed"? Or is there some kind of hashing algoritm where the hashes stay the same if only small parts of the string/content has been changed?
You could try and use the value contained in the "last-mofidied" header in the response from the server. Parsing this into a nice object would allow for simple date comparisons, letting you check if you should re-scrape. For example (in Python using the brilliant requests library:
import requests
r = requests.get('http://en.wikipedia.org/wiki/Monty_Python')
site_last_modified_date = r.headers["Last-Modified"]
# from here, just parse the date and compare it with the last recorded date
I'm trying to make a chat history system. So every time a person says hi to one another, they can also say something else. And each of those hi's, i wan't to add what they wrote into a history html file. Being something like this:
James Said: Hi Richard, i saw that hardware you told me about, it is compatible with our software!.
At: 23 November 2011 - 23:09 UTC-08.
________________________________________________________________________________________
Richard Said: Nice!! let's start working with it this week, the project has to be finished before the end of the world.
At: 24 November 2011 - 09:23 UTC-08.
________________________________________________________________________________________
The html file i can build with php, but how do i save it to a MySQL BLOB? Without storing it in a directory (directly to the BLOB).
You're approach to this problem isn't really a good one.
If you try to store the data in a particular output format then you're in real trouble if you suddenly find you need the data in a different format.
You're much better off just storing the particulars of the conversation, and then generating the output to display from the stored conversation. That way you can easily present it in all kinds of formats you might need it in.
EDIT TO ADD:
Something else I should have mentioned (but forgot thanks to all the Christmas brandy ;) ), trying to store the conversation data in a single big block of data will negate most of the advantages using a relational database can confer in the first place. You couldn't, for example, easily store the timestamp of each line of the conversation, or search the database for particular items in the conversation. You could find workarounds of course, but given databases are already designed to solve those kinds of problems anyway, you'd just be wasting effort and your solution wouldn't measure up to what the database already provides.
Since it is not really a binary (the B in Blob), but HTML, I suggest you use the MEDIUMTEXT type and deal with it as just a normal text field.
Currently I've been using http://www.geoiptool.com/ but I can't get the local time. I don't know what to do to get the local time.
Can someone help me out, to display location + local time? I have a mail app and I try to display IP in location + local time.
Well, this is not real answer to your question but can help you to properly understand how inaccurate this method is.
Please, read this answer as a side note.
Yes, it's OK to offer or set location/time for your users. But you should provide country/time selector for them also. Some of IP's can not be resolved properly (anonymous proxy, borrowed IPs from other countries (my case), continental IPs (like group "Europe", "Asia", etc), etc.
My case shows how this approach may be wrong.
When I've tried ipLocator from geobytes.com I've got this:
My IP address has been resolved to:
Location: Romania
Time offset: +0200 (at the moment DST is active so it's +0300)
Real problem is that my location is not Romania, and my time offset is +0100/+0200.
Look this picture:
Red arrow shows my real location. Info in black box shows correct values for my real location. Well, wrong location is not such a big problem for users, but wrong local time is very annoying thing.
Yes, I know, that's not what you're looking for. But you should not fix users location and/or local time because it can be wrong approach. IPv4 address is certainly not something accurate to get real info about user.
Also, I found that ipLocator doesn't follow DST rules and using that time offset (image #1) will show wrong local time during Summer (for countries/regions/provinces which consider DST).
Geobytes will give you the offset:
http://www.geobytes.com/IpLocator.htm?GetLocation&IpAddress=64.34.119.12
Or in an XML format (you might need to view source to see it):
http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=64.34.119.12
This will give you the offset, just add/subtract the offset to GMT/UTC.
I want to show when the comment last posted in PHP. like 5 minutes ago, 2 days ago, 7 weeks ago. How to do this?
You can find plenty of answers with full solutions in different languages, pseudocode, ideas, etc.. here.
I believe there's an example of PHP too.
You can use timeago, a jQuery plugin, to do it via Javascript. It would yield the same result, update without refreshing, and by doing it client side instead of server side, you are not precluded from caching.
http://timeago.yarp.com/
Otherwise, Annurag has a link with some good PHP solutions.
You can do manual calculation in server, to get the time difference, then translate it into human time format.
Or my preference, do it in browser using javascript. Using this approach, the time in page can be updated without refresing the page.
You can use this jQuery EasyDate library to translate a DOM element into humane time format.
You can also read the comments in this post about Pretty Date by John Resig. It contain the code, and improvement by other.
Store the comment posted in the date DB and show the the same in the front end by comparing with current date and time using php function