Jump to content

NotionCommotion

Members
  • Posts

    2,446
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by NotionCommotion

  1. @Zane Don't give in! We must remain united against the non-JavaScript infidels! In my father's day and his father before him, they new how do deal with these people. We must give them what they deserve, make their experience as bad as possible, and purge their existence once and for all!
  2. Actually it is working perfectly. It is doing exactly what it is suppose to do.
  3. I recently came across http://forums.phpfreaks.com/topic/293466-working-with-sockets/. Sockets? Never heard of them... I looked at the PHP documentation http://php.net/manual/en/intro.sockets.php, and it tells how to implement them, but not really what their purpose is. I then search a bit, and learned about their history http://en.wikipedia.org/wiki/Berkeley_sockets, but still not really why they are used. Okay, sockets are used to connect an application to a given port and IP, and PHP can be set up as either a socket host or socket client? Is this something like a SOAP server/client, but SOAP specifies a given port and protocol? Do sockets not necessarily specify a protocol? Still a little fuzzy. Can anyone provide examples on where they might be used? Reference: http://wiki.treck.com/Introduction_to_BSD_Sockets
  4. Well said. See you soon (but no proposal!)
  5. No it didn't. I never new hypothetical questions belonged somewhere else. Good to know!
  6. Hey, my post got moved without notification. Is this normal? Thank you all for the insightful and interesting discussion. Maybe a little harsh, but then again, I don't necessarily disagree. I've always been a bit of a libertarian, and believe it is okay for others not to enable JavaScript, but then again, okay not to cater to their needs unless we benefit by doing so.
  7. Ah, session IDs, of course! Now that has some interesting implications for doing more than just displaying logged users as it is explicitly tied to the client which holds the unique cookie. Would you mind giving me a brief non-code strategy on how this is implemented? I currently have never stored sessions in a database, but have long considered looking into it. Would this be an occasion to do so?
  8. Thank you for your very real-world recommendations. I agree with them and believe it is silly to worry about issues that are not issues. I believe in the 80/20 rule, and if I don't know what 20% of my issues are causing 80% of my problems, I will have a hard time fixing anything. That being said, are there times when we should attempt to identify bottlenecks before they become one in order to lessen the blow? I'm just looking for best practices in this topic so I am prepared.
  9. Thanks Frank, Makes sense regarding logged on users being active for a duration of time. Non-users based on IPs? Maybe not exact, but seems good enough. Even if a robot hit you, they would only be "active" for a duration of time.
  10. Sites such as this one often show the logged on users and guests. I have no reason to need to do so, but am curious on how this is accomplished. For users, yes, you've authenticated them and logged them on regardless of IP address, but how do you know they didn't just close their browser? For guests, are they just using IP address? And still, how do you know when they leave? PS. How should I include an image in a post like I did? What I did was first attach a file, and then edit the post to include that file as an image. Couldn't seem to include an image off my local PC. Not a better way?
  11. Let me give you a couple of examples. For the first example, I have a table which includes all the pages I have on a website, and includes information about them such as some directory path, the minimum user access level to view, etc. The only time it will change is if I add a page or modify settings on an existing one. Instead of performing the query each time, maybe I should do it once for each user session and store the results in a session array? But if I do, how do I force a reload should I ever make a change. Or maybe I should do it once for all users, but this probably doesn't make much sense. For a second example, I have a bunch of sites which use common code. Each has their own subdomain which in turn identifies a primary key which with multiple joins makes each site unique. The user could change the settings, however, will rarely do so. Instead of querying the big query each time, should I store the settings in a session, and only query the database if some part of the session is not set or if the session "last_updated" value is different than that stored in the database? Yes, I will still need a query, but it will be small and hopefully more efficient). For a third example, I have some JSON data available to the client. Most clients will cache the data, so I shouldn't have much problems there. I could also server cache it, but again, how do I know when to force a reload? Thank you, and Happy New Year!
  12. Not me. I have experienced, however, when I add a new post, and it shows zero views for several hours, and then instantly changes to show many views. I shouldn't bring it up, however, because last time I did, I received a warning point
  13. r-soy, The PHP script has to be located on a server which is running PHP. For timing, you could use a cron job as you indicated. To initiate the PHP script on the same server as the cron program, use something like /usr/local/bin/php -q /path/to/your/file/under/the/html/root/script.php. If it is on a different server, you can use curl(), but you need some password authentication because it is publicly assessable. When the PHP script is executed, it could check a database to see if anything is slated to go out, or do whatever you want it to do. Which part do you need more information?
  14. You could also run PHP from the command line instead of from a web server (but as ginerjm stated, you need to have PHP installed)
  15. I very much appreciate both your help, as well as that from many others on this forum. I think back at where I started and where I am now, and while not yet perfect, have made mountainous strides. Please feel free to consider this post closed.
  16. Thanks Barand and Jacques1, I knew about the colons when using bind, but not when using an array of insert values (named parameters). To have better forward compatibility, is it best to include them?
  17. Always or normally? Did the removal of the colons help?
  18. I don't think it is inserting two times, but you do have a problem. Your indexes in the array should not have the colon in front of them. Also, what is $id equal to?
  19. Use of break and not exist will be an issue as you will update your database when you did not intend to. Why worry about email length not being zero, and just check if is a valid email?
  20. I'm not worried about micro-optimizations, just curious. Do you know how to interpret memory usage? Using a switch statement: Time: 0.0052700042724609 memory_get_peak_usage(): 136328 memory_get_peak_usage(true): 262144 memory_get_usage(): 134860 memory_get_usage(true): 262144 Using an array: Time: 0.0024628639221191 memory_get_peak_usage(): 137304 memory_get_peak_usage(true): 262144 memory_get_usage(): 136200 memory_get_usage(true): 262144
  21. Thanks kicken, Testing it as we speak. The array method goes around twice as fast (but it is still like instant). I am also curious on how much memory they both use. I know it probably doesn't matter, but as I said, just curious. I've never checked real time memory usage, and if you have a pointer, it would be appreciated. If not, I am sure I will find something. EDIT. Took 2 seconds to google: http://php.net/manual/en/function.memory-get-usage.php Thanks
  22. Given a text value $path, I want to return the actual path. One option is a switch statement as shown below. Another option is put them in an associated array (or maybe a static array?) and check if the element is set and if not throw an deception. Or maybe a totally different solution. Is one solution better (i.e. more efficient) than another? I will probably be retrieving a path around 5 times for every server hit. Thanks function getPath($path) { switch($path){ case 'classes': $path=__DIR__;break; case 'application': $path=dirname(__DIR__);break; case 'root': $path=dirname(dirname(__DIR__));break; case 'twig': $path=dirname(dirname(__DIR__)).'/vendor/autoload.php';break; case 'lib': $path=dirname(__DIR__).'/lib';break; case 'help': $path=dirname(__DIR__).'/lib/help'; case 'templates': $path=dirname(__DIR__).'/lib/templates'; case 'htdocs_base': $path=dirname(dirname(__DIR__)).'/html'; case 'resources_base': $path=dirname(dirname(__DIR__)).'/user_resources'; // About 10 more default: throw new Exception("Path {$path} not valid."); } return $path; }
  23. Oh oh, not a bit weird I like the use of JavaScript object notation which is a little less verbose (i.e. security.password_algorithm). I see you are passing presumably the application ($app)? to the class, and then type hinting it as App. I usually think of the application as $this. Are you passing the parent controller or something into the config class so you could use the getConfigDir() method?
  24. I mostly if not always name my classes with the first letter capitalized. I typically use enable autoloading as follows. I don't know when I started converting the class name to under-case. As such, however, I need to make the filenames undercase. Is this the correct approach? spl_autoload_register(function ($class) { $class=strtolower($class); if(file_exists(__DIR__.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.$class.'.php')) { require_once __DIR__.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.$class.'.php'; } });
  25. Good for using var_dump()! Now, look at your HTML. It is always nice that when you witness something impossible, it is not happening Your missing a quote.
×
×
  • 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.