Jump to content

requinix

Administrators
  • Posts

    15,045
  • Joined

  • Last visited

  • Days Won

    413

Everything posted by requinix

  1. By the way, the one-liner: $input = "dog,white cat,white cat,black cat,white dog,black bird,white"; $output = current(array_map(function($i){return ksort($i)&&array_walk($i,function(&$v){$v=implode(": ",array_reverse(func_get_args()));})?implode("\n",$i):array();},array(array_map(function($i){return arsort($i)&&array_walk($i,function(&$v){$v=implode(" ",func_get_args());})?implode(", ",$i):array();},array_reduce(preg_split('/\r\n?|\n/',$input),function($c,$i){return@++$c[strtok($i,",")][strtok("")]?$c:$c;},array()))))); echo $output;Obfuscated a bit so it's longer than it needs to be.
  2. It's not a super-simple one-liner. You say you have code that isn't working? What is it?
  3. gizmola found and fixed a problem with the emailing system, which handles things like notifications, verification emails, and password resets. It'll be chugging through a backlog of emails for a bit so you may receive some emails for stuff that doesn't matter anymore. There was also a problem with the CAPTCHA verification on the registration page that has also been addressed.
  4. If you're saying that by moving the PDFs outside the web root then that's not entirely true. What matters is whether Google can find a URL (and it's very good at that*) and whether it can get the contents of the URL. Simply hiding the PDFs behind a PHP script isn't enough - it needs to require authentication too. It'll help you with the good bots, but you won't be protected from the bad bots who don't respect robots.txt. * If you use Google Talk, share a link with someone over it, and they click the link, Google will pick it up. At work, we've had them discover development sites that way - they weren't supposed to be publicly accessible but they were misconfigured. The sites got indexed. After applying a robots.txt to our environments and firewalling the boxes, it took a few weeks for the index to lose the sites.
  5. If the PDFs can be publicly viewable, as in anybody on the internet should be able to see them (if they had the link), then go ahead and leave the directory web-accessible. If not, and I suspect not since these are bills that users are sending to people, then don't. Put the directory somewhere else and then make a PHP script which authenticates the user and then serves (outputs the contents of) the PDF.
  6. How often to do you need to access the information? Can it change during the lifetime of the user's session? When and why?
  7. Is what you posted your real code? Because it's incomplete. Like, you need a call to .send() in there. I'm not sure he meant "websockets" as in the tech - more like "open a socket to a website" in the general networking terms.
  8. AJAX is asynchronous - it does not happen linearly with the rest of your code. web_socket_open() will finish executing immediately and then eventually sometime later the onreadystatechange function will fire. Nevermind that the return will only return from that anonymous function and not web_socket_open(). function web_socket_open(href){ var request = new XMLHttpRequest(href); request.onreadystatechange = function() { if (request.readyState === 4 && request.status === 200) { console.log(true); } console.log(false); } } web_socket_open('http://127.0.0.1:8080');And notice that if everything is good you'll see a true and false output.
  9. Done. You should be receiving an email notification about it.
  10. Javascript cannot interact directly with PHP code or with your database. Use a form. <form action="" method="post"> <button type="submit" name="comehome">Click Me</button> </form>then if (isset($_POST["comehome"])) { // insert the record } // continue on as normalIt's not onclick because that requires AJAX and you said you wanted this thing done quickly. Which is a bad mentality for a programmer to have but whatever.
  11. Don't put the placeholders (which is what they are) inside of quotes. They aren't strings but, well, placeholders. Placeholders for real values which will come after you've called bindparam() and execute().
  12. But... isn't your AJAX hitting PHP in the first place? Because that's where the "html" comes from, and that's presumably the "id=msg results" you're talking about.
  13. I agree with scootstah: this is better served with an interface and an implementing class. Closures/callbacks/anonymous functions are more for simple tasks, like how Jacques's example where it just dumps out a value. The mere fact that the function is named "save" suggests it should conform to a specific signature (be that ($col1, $col2) or (array $cols)) and thus in a class. Fun fact: PHP 7 supports anonymous classes, so one could do... well, it doesn't look particularly pretty so I won't post the example code for it. But if you're concerned about lots of one-off classes, this would be marginally better.
  14. The point of this thread was to find out what data type to use in MySQL. Barand said TIME which is, technically speaking, the appropriate format at it models the actual data you're working with. You talked about how your code would convert the value into seconds which is why I asked about simply storing the number of seconds. If your new question is about how you can have PHP convert "HH:MM:SS" into a number of seconds, the simplest answer is the most obvious: list($h, $m, $s) = explode(":", $time); $seconds = 3600 * $h + 60 * $h + $s;
  15. If you're going to convert it all the time, would it be better to store the number of seconds instead?
  16. Only for the next day or two. Until I remember to change my avatar - I'm overdue. [edit] Annnd changed.
  17. Upgrade the password for the user. Do a SELECT PASSWORD('123456')and make sure you get a long string starting with an asterisk. Assuming you do, SET PASSWORD FOR 'user'@'host' = PASSWORD('password')
  18. Yeah, there's a lot. 1. Near the top is probably a "Configure Command". What is it? 2. Is there a section named "filter"? If so, what does it include?
  19. What version of PHP are you running on the site (echo PHP_VERSION;)? What does phpinfo output?
  20. OP is advertising demonstrating their video about setting up sendmail on Windows.
  21. Why did you delete all the comments in the sendmail.ini!?
  22. It's because end() wants to modify internal information about an array, so it needs to be passed a variable and by reference. If the function returned an array by reference, that would work too. A combination of strrpos and substr will work for a one-liner too.
  23. ICANN/IANA also maintains a list of literally the top-level domains. Meaning it lists "uk" but not "co.uk". Doesn't include the IDN versions of the xn-- labels but that's not difficult to deal with in code. Keep in mind that "foo.bar" is a valid domain name - a user could put forward even the slightest bit of effort to circumvent any sort of general-purpose domain name verification you may put in place.
  24. Your serialize methods aren't doing anything with $regList, so that information will get lost during serialization. Drop the Serializable interface and its two methods and let PHP do what it normally would do. Serializable is only really if you want to change how serialization works.
×
×
  • 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.