Jump to content

JasonLewis

Members
  • Posts

    3,347
  • Joined

  • Last visited

Posts posted by JasonLewis

  1. Very interesting. Not that I frequent here anymore (I'm sorry!) I'll be interested to see how it all goes. I'll check in from time to time. After all.. this is probably my longest standing account on the internet.

     

    Good luck to you!

  2. I've come to the conclusion that Twitter most likely uses JavaScript to update their dates. You can check this by changing your computers date/time and refreshing the page.

    As an educated guess I'd say Twitter keeps the timezone setting as a server-side fall back in case something goes wrong client-side. Fair enough. I've gone the same way.

     

    I'm using PHPDate for jQuery to make formatting my dates easier and also using this conversion script found on StackOverflow.

     

    This has turned into a client-side thing now. Ah well, hopefully this can help someone.

  3. Developing apps is great until I have to start dealing with blasted timezones. For some reason this aspect of it always does my head in.

     

    At the moment I'm storing all dates in the DB as GMT with the format Y-m-d H:i:s. I figure it's good to be consistent and store dates in GMT then convert to the users desired timezone. So I allow users to choose there timezone, based off the defined PHP timezones that can be used with the DateTimeZone class.

     

    My problem, however, arises with the whole syncing of times. Let's say I post something right now. The date gets stored in in the database as: 2012-04-14 02:35:49

    Now I'm in GMT +10 (possibly the greatest of timezones :)), so I've set my timezone in my settings as Australia/Melbourne and when displaying date/times locally I do something like this:

     

    public static function local($user, $date, $format = 'F j, Y, h:ia')
    {
    $date = new DateTime($date);
    
    return $date->setTimezone(new DateTimeZone($user->timezone))->format($format);
    }

     

    So running the stored date above through my method gives me a date like this: April 14, 2012, 12:35pm

     

    Awesome.

     

    My question is: I noticed that on say, Twitter, when you change your timezone your tweet dates don't change. They remain as the date/time of my actual timezone, regardless of what I set it too. With my implementation however, if I change my timezone to GMT +12 (Fiji) my post is now posted at: April 14, 2012, 02:35pm

     

    So is what I'm doing right? My head has about had it.

     

    Thanks.

     

     

  4. Thanks for your reply kicken! :)

     

    What I'm getting at is this. Say I post a new update or something, when that update is inserting into the database should I push the notification through to socket.io which then broadcasts that notification to the connected clients? Does that sound feasible? What I want to try to avoid is polling the database every couple of seconds to check for new notifications. I'm using MySQL and I've read that other database's handle that sort of thing a tad better.

     

    Edit:

     

    This is a quote from another forum:

     

    To communicate between php and web sockets I suppose you will need some comet solution. We did it on this way:

    1. Have Redis (pub/sub feature) to send/retrieve messages (channel No is user ID)

    2. Have PHP to send notifications into Redis when something happen

    3. Have Node.js app listen all channels and send notification to web sockets

     

    How to identify user:

    1. After user login we added to Redis hash pair: sessionID => userID

    1. After user connected to socket, it send auth command to node.js with session ID.

    2. Node.js check hash in Redis for sessionID and get userID.

    3. Node.js subscribe connection to userID channel

     

    I can make sense of that... I'll just need to implement Redis since I don't have it at the moment.

  5. I'm looking for advice at the moment on achieving real-time notifications using a mix of PHP, NodeJS and socket.io.

    At the moment I have done next to nothing with Node and socket.io so I'm at a loss with the best way to achieve this. I've done some basically listening and what not but nothing extreme.

     

    For now my questions are:

     

    1. How will socket.io know of new notifications, should PHP be responsible for sending the data (say a post was created) to socket.io and from there broadcasting to connected clients?

    2. How does socket.io know which clients want the notifications?

     

    I'm really not sure what else. This is all a bit much for me at the moment. I just can't get my head around how the notifications will be distributed.

     

    Any advice would be greatly appreciated. I don't expect a detailed walk through, just a push in the right direction or some knowledge on how it all meshes.

     

    Cheers.

  6. How do you propose to gain a foothold on Facebook if you're making a clone?

    No one wants another Facebook. I'd stop making this clone if I were you and make something better than Facebook.

     

    Unless you're just screwing around, in which case go nuts.

  7. Are you being serious about charging per line? That just sounds ri-god-damn-diculous.

     

    If you are going to charge them (although I really think you shouldn't as you said yourself this is your first PHP project) do it per hour or as a lump sum you can work out with client. See how much they are willing to pay.

  8. These days people tend to lean towards using a JavaScript library, such as jQuery.

    They indeed do, but jQuery would be a humongous overkill here.

     

    Of course. Unless there will be more JS usage across the website. :P

  9. You're correct, it requires a combination of JavaScript and CSS. These days people tend to lean towards using a JavaScript library, such as jQuery. This allows for easy animating of elements and more.

  10. I have the illusion that with these points it will get significantly less, even though I must say -- or should have said to begin with -- that it is not as bad on PHP forums as it is on general HTML forums. (So I'm deleting the exclamation mark in the final draft.)

     

    People are just under the assumption that a title of "HELP!!!!!!!!!!!!!!!!!!!!!!" stands out more and people will be more inclined to click into it. Sadly that's not the case, unless I'm keen for a laugh at the contents of the topic contained within. :P

  11. You are binding the click event handler twice: inline with the onclick attribute and in the onclicks function close_box. That's a no no. It's doubling up and getting confused.

    You can have one or the other. You can pass this from the onclick attribute, or just define an ID attribute with the ID to delete then grab it with the jQuery event.

  12. Looks okay... except points 5 and 6. You're always going to get horrible spellers and badly titled topics. Mainly due to (like you sort of mentioned) a proportion of PHPF being international as well as an age range from somewhere between 12 and 60+. The younger generation are always going to write 'u' or 'r'. Or they'll throw a huge wall of text at you because they've never heard of paragraphs.

     

    I'd also put in something to do with thinking hard about where this problem belongs. Is it really related to the topic of the board or should it go elsewhere. But again, people sometimes just don't give a rats ass.

  13. This relates to Ajax as well but more-so JavaScript.

     

    Let me use an example. I have a tagging system that's using Ajax to auto-suggest tags. The user can then select a tag from the suggested tags or add the tag they want. If they select a tag, is the best way to go about it adding that tag ID to a hidden field as a comma separated list. Or... keep the selected tags in an array and attach an event to the submit handler of the form, then once submitted insert X amount of hidden inputs (where X is the number of tags) so that I'll have an array of selected tags when they submit.

     

    In the past when I've done things like this I've just updated a hidden input each time a tag is added/edited, however I'm just wondering if the second approach is possible and if it's better. The only possibility I can think of is that it won't work due to the form already being submitted and thus the inputs aren't actually added to the post data. I am yet to test this.

     

    Cheers.

  14. No, I doubt the examples you listed would provide username/access code information publicly.

    Okay, so then this depends on the circumstances that surround it.

     

    I tested a few sites: Westpac (my bank), Forrst, GitHub, Flingbits, Facebook and this website.

    The websites that said my password was incorrect were: Flingbits, Facebook and PHP Freaks.

     

    All the others said that my login combination was incorrect or something to that effect.

  15. If you don't have "bad login attempt counting/login lockout" logic in your login code (i.e. you allow unlimited attempts), then yes, telling a bot script/hacker specifically first if the username doesn't exist, then if the password was wrong is a security problem.

     

    Of course, a login spam filter should be consider for all logins. But still, usernames are publicly available? So they shouldn't be getting it wrong anyway, unless it's a bot script that is simply trying to brute force it's way through. But again the lockout will be applied if they try too many times.

×
×
  • 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.