Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. In what way? Against CSRF it would appear.
  2. Given that you are the linguist and we are the programmers, why don't you tell us what doing "Advanced Language Analysis" constitutes?
  3. But that will be slower. sort() uses the quicksort algorithm, so it has a complexity of O(n*log(n)). Just going through all the elements unsorted from the start is a linear search which is O(n).
  4. Maybe something like this? <?php function truncateLink($link, $maxLength) { $length = strlen($link); if (strlen($link) <= $maxLength) { return $link; } $split = floor(($maxLength - 3) / 2); return substr($link, 0, $split) . '...' . substr($link, -$split); } $link = 'http://www.domain.com/editaccount.php?notifications&md=ZmVlZF9jb21tZW50O2Zyb209NTA5MTM2MzA2O3VpZD03MTcxNTI4Mjk7b3duZXI9NzE3MTUyODI5O29pZD0xMzYzMTcxNTE1MTQ7dG89NzE3MTUyODI5&mid=edf630G2abee23dG2677304G36'; printf('<a href="%s">%s</a>', $link, truncateLink($link, 50));
  5. It it was their invention, it's per definition them who is doing it right, and everybody else who is doing it wrong, isn't it?
  6. v8 can also refer to version 8, as in version 8 of Internet Explorer.
  7. You can solve this in a few ways. You know that the hour part must be from 0-23 and the minute part from 0-59. Optionally with a leading zero for single digit hours. Using regular expressions you could do this: if (preg_match('#[0-2]?[0-9]:[0-5][0-9]#', $start_time)) { // is valid } You could also split it up and check each part manually: $parts = explode(':', $start_time); if (count($parts) == 2 && $parts[0] >= 0 && $parts[0] <= 23 && $parts[1] >= 0 && $parts[1] <= 59) { // is valid } If you want to know more about regular expressions we have an introductory tutorial that you might want to take a look at.
  8. I'll have to agree with that. The only reason why I'm sticking with FF is because of the extensions. Otherwise I would probably be using Chrome. It is much faster than FF. Maybe it would get bogged down with my extensions and bookmarks too though. I'm not sure.
  9. And how is it related to mathematics?
  10. Knowing nothing about the site, and the fact that it no longer exists so we can check, makes it somewhat difficult answering that question. It could be RFI or maybe another script on the server was vulnerable. I make anything but wild guesses.
  11. If you cannot accept our rules, you are at the same time not accepting our Terms of Service. If you do not accept these you are not authorized to use this website, its forum or any other resources available on this website. As long as you are here you will be required to follow our rules. End of discussion. If you don't like it you can go elsewhere, but I'm pretty sure that few other places allow you to blatantly disregard their rules. We have a rule that prohibits posting the same topic in multiple sections. That's a pretty normal rule that exist on the majority of forums. You are in no way any special person, so there is no reason why you should be allowed to disregard our rules. It's a MySQL issue because you are having trouble writing a query. The fact that the query is run via PHP is irrelevant. You are not having trouble with running the query, but trouble with creating the query itself. That is a MySQL issue. You may have a table and some content like this: CREATE TABLE `test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `date` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `test` (`id`, `name`, `date`) VALUES (1, 'Previous month', '2009-07-13'), (2, 'This month', '2009-08-13'), (3, 'Next month', '2009-09-13'); And you may then run these queries: mysql> SELECT CURDATE(); +------------+ | CURDATE() | +------------+ | 2009-08-13 | +------------+ 1 row in set (0.00 sec) mysql> SELECT MONTH(CURDATE()); +------------------+ | MONTH(CURDATE()) | +------------------+ | 8 | +------------------+ 1 row in set (0.00 sec) mysql> SELECT * FROM `test` WHERE MONTH(`date`) = MONTH(CURDATE()); +----+------------+------------+ | id | name | date | +----+------------+------------+ | 2 | This month | 2009-08-13 | +----+------------+------------+ 1 row in set (0.00 sec) Now, date('Y-m-d') will evaluate to 2009-08-13 today, so if we run: mysql> SELECT MONTH('2009-08-13'); +---------------------+ | MONTH('2009-08-13') | +---------------------+ | 8 | +---------------------+ 1 row in set (0.00 sec) We get the exact same thing. So the two queries are equivalent. Again, read this entire page. If there is anything there, which do cannot accept I'm afraid you are no longer allowed to use this website. If you find any of our rules to be unreasonable I suppose you can bring it up in the feedback/suggestions board, but only with a compelling reason why it should be changed.
  12. Something like this? function in_array_recursive($item, array $array) { foreach ($array as $element) { if (is_array($element) && in_array_recursive($item, $element)) { return true; } else if ($element == $item) { return true; } } return false; }
  13. Sorry, that doesn't make sense. Apache doesn't serve PHP code, but it does serve raw HTML code. Apache doesn't know anything about PHP code except that you told it to pass anything ending with .php to PHP before doing any further stuff with it. You cannot compare apples to bananas.
  14. Yes, you can. http://en.wikipedia.org/wiki/Mock_object
  15. But that binds the app to be a small app. Eventually you might want another feature, and another, and one more. It's just a small app, so we'll disregard anything even remotely related to good practice. At one point it's one giant pile of spaghetti code with a lot of interdependencies. You could have just passed the variable as an argument instead. Another issue is unit testing. When doing unit testing you test individual components of the application individually. Good luck doing that with code that relies on global objects. You couldn't for instance create a mock database object either. Because you wasn't able to properly unit test your code, and you now have a tightly coupled application, there is a great risk that fixing one bug creates a different bug another place. Because you have no unit tests, you have no means of finding out before it's too late. You'll be spending more time hunting down bugs and fixing them than writing new features. You've experienced what is called "code rot" or "software decay". There is never a good reason why you would use a global variable.
  16. You cannot. Likely another hole was used.
  17. Have you ever tried working on a project that made heavy use of globals, but you didn't create? It's a pain in the ass trying to figure out where anything comes from and trying to debug it. The only reason why it works for the current developers is because they can remember that. Should they leave it and come back later on, chances are they'll be pulling their hair as well. It's also a problem with interoperability/portability. What if two 3rd party libraries use the same global variable for different purposes? Case in point, when developing the website for PHP Freaks I wanted to use the SMF API for a couple of things. However, in true SMF style it messed with global things, the super globals, the sessions and a lot of other crap that made it completely incompatible with Zend Framework. The SMF API only works if you build your site around it. It doesn't work as a third party library even though it would have been possible if the SMF team didn't churn out a lot of shit code constantly. Also, a couple of times when people had requested some mods for the forum I've taken a look at trying to do it, but it's virtually impossible finding your way around the SMF code base because everything depends on each other and that global object you're using could literally come from anywhere. Regarding the speed thing. If you're looking for maximum performance, why are you writing PHP code in the first place? You should be writing assembly. Raw performance is not everything.
  18. Uh, yeah I do mind. And it's not a PHP issue just because you wrote your script in PHP. The issue is with the query, which by nature is a database problem. The reason why what you wrote didn't work is because you used the wrong syntax in the query. Anyway, why didn't you just do what I posted: $sql = "Select * from $DB_TBLName2 where vent_today='y' and MONTH (bundle_date) = MONTH(CURDATE())"; MySQL can figure out the current month just fine on its own.
  19. They both break encapsulation, which is bad. The difference is that a global variable for sure breaks encapsulation no matter what, while a class property can be marked as private or protected. Even so, the global variable is still available throughout the entire script while the object is only available in the local scope.
  20. SELECT * FROM table WHERE MONTH(date) = MONTH(CURDATE()); Where date is the field containing the date obviously.
  21. You should store dates in a DATE field type.
  22. Approximately 45.7% of our users are from USA, UK, Canada or Australia. We also have users who are not from any of these, but speak fine English regardless. If you want to practice your English you could start with capitalization of words and using the spell checker. No offense, but it's somewhat paradoxical being sloppy when writing in a language you are trying to become better at.
  23. Given the nature of the internet, I think you'd be hard pressed to find a forum exclusively with American members yet covers general topics like the ones you mentioned.
  24. Multiply with 100 and round.
  25. Comparing a framework to a language isn't exactly fair. You can compare ZF or symfony to .NET. You cannot compare PHP to .NET.
×
×
  • 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.