Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. First, you want hashing. Encryption is when you can get the original password back from your database. That sounds good but it isn't. What you need is hashing, which is taking something like a password and turning it into another thing that looks random but will give you the same result for the same password. (Basically.) Then you compare hashes. Use password_hash and password_verify like // when setting or changing a password $hash = password_hash($_POST["password"]); /* put $hash in the database */ // when checking a password if (password_verify($_POST["password"], $hash_from_database)) { // password matches } else { // password does not match }
  2. I assumed the question was about extensions - .html and .php. But any way I interpret the question, the answer is the same.
  3. The question marks are supposed to be there. That's how prepared statements work. Wikipedia
  4. What is the new error message?
  5. Stuff doesn't just stop working without a reason. If your .htaccess is being parsed and you're not getting 500s as it is now then everything there should be working - unless something changed to break it. So. What changed in the last couple days?
  6. You're binding just fine. SQLSTATE[23000]: Integrity constraint violation: 19 users.active may not be NULLSince active isn't in your list of columns to insert, the database will use the default value. But the default is (apparently) null. The result is that you have to specify the active value when adding a new user.
  7. It matches both because you aren't using anchors to enforce a match against the entire string. All you're doing now is checking if the string contains those patterns.
  8. Use usort() with strnatcmp() to implement your own sorting algorithm. usort($FIRST_NAT_SORT, function($a, $b) { $a1 = strtok($a, "-"); $a2 = strtok(""); $b1 = strtok($b, "-"); $b2 = strtok(""); return strnatcmp($a1, $b1) ?: -strnatcmp($a2, $b2); });[edit] It's been asked so I'll explain: The function to usort() has to return 0 depending on how the two arguments ($a and $b) compare to each other - negative if $a $b. Fortunately that's exactly how strnatcmp() behaves too. return strnatcmp($a1, $b1) will handle sorting for just the parts before the hyphens, but if they're equal then you need to compare the parts after the hyphens. $x ?: $y is shorthand for $x ? $x : $y, so return strnatcmp($a1, $b1) ? strnatcmp($a1, $b1) : -strnatcmp($a2, $b2);(except the shorthand will only evaluate the first strnatcmp() once) Since strnatcmp() returns 0 if the two are equal and nonzero if not, the function will return that number if the two are not equal because it won't try to do the second comparison. If they are equal then the second strnatcmp() does get evaluated. It works the exact same way as the first one, except it has a minus sign to negate the return value. Thus the result is backwards: negative if $a2 > $b2 and positive if $a2 $b2. The effect is a descending sort on the values after the hyphens. To be absolutely explicit about everything you could write that line as $compare1 = strnatcmp($a1, $b1); if ($compare1 < 0) { // $a1 < $b1 return -1; } else if ($compare1 > 0) { // $a1 > $b1 return 1; } // $compare1 == 0 and $a1 == $b1 $compare2 = strnatcmp($a2, $b2); if ($compare2 < 0) { // $a2 < $b2 return 1; // opposite result } else if ($compare2 > 0) { // $a2 > $b2 return -1; // opposite result } else { return 0; }
  9. Type something random and invalid into the file and see if your site starts returning 500 errors. If not then it means your .htaccess file isn't being interpreted anymore and you should talk to your host.
  10. Clearly OP doesn't have the understanding or the inclination to let us help him.
  11. To me it depends on what the date represents. If it's an actual piece of relevant data then you should put it in the database, but if it's just an artifact of the file itself then leave it with the file. So probably the former.
  12. If it's your own content then that deals with the more problematic restrictions, but you still can't scrape their site to get what you need. The API does provide a way, but it requires generating access tokens by logging into their site; there's no indication how long those tokens are good for (just an ominous warning that they might expire in the future) so you will probably have to re-login to keep the feed working indefinitely. So here's what I propose: You take the officially-supported API route. Make an application according to their guidelines, and to alleviate most of the burden of the API you can use a third-party library to do the communication parts, then use their /users/self/media/recent endpoint to get the images. Yes, it will take you a little longer, yes, it's not as simple as scraping, but that's the method they require so that's what you'll need to do.
  13. Okay, see, now we've got a bit of a problem: Instagram doesn't like people doing what you're doing. Their Terms of Service specifically disallows crawling media (General Condition #9), their API policy says you can't "simply display User Content" without permission (General Terms #16), and the less precise "Platform Policy" list in their documentation says you can't crawl media without users' consent or automate requests (#4, #5). And on a more technical note, their API doesn't provide a way for you to access user media without them specifically logging into Instagram. As far as I can tell. I'm not sure there are any alternatives open to you...
  14. I haven't seen anything to suggest this sort of behavior is not allowed... What's your code? If it handles those URLs at some point between the RSS and Telegram then you can simply remove the query string before submitting them.
  15. Why remove it? What's the problem?
  16. Okay, great, so now we've established that the code you're posting is not the actual code you have. The first step is to post your actual code. Also, if you need to know three states for the input (default, checked, unchecked) then a mere checkbox is not enough because all it can tell you is whether it was checked. You'll have to combine that with knowledge about whether the form was submitted.
  17. To validate the HTML... well, you know HTML is rather flexible. "string" is valid. " string" is valid". Some stuff you might consider invalid is still acceptable to browsers. I'm thinking (a) just load it with anything in PHP that supports HTML and see if it complains, or (b) try Tidy. Maybe your end result should be less valid/invalid but whether it's supposed to be valid already and you can just fix it if it has minor errors?
  18. I don't get why you expect it to show anything other than 5. It's what you put into the HTML. Directly. No PHP code, no variables, no Javascript to update the value on page load... Why do you think it should be anything other than "5"?
  19. Notification emails would have been broken too. Are they working now? Actually, I can see some emails to you being sent. A couple bounces. You should be receiving a lot of them about now...
  20. Direct access to the database is a really bad idea. Really bad idea. Why can't you modify the application, in order to implement an API? That is the best option.
  21. Once again, validation and notification emails broke on the server. They should be fixed now. I don't remember what the earlier issue was but I think this one is different. It's going through the backlog of verification emails so anybody missing theirs will probably get them within the next day or so. If you still haven't received yours by then, or want it now, then use the Resend link at the top-right of the page. (If you don't have a link then you don't need to validate.)
  22. Apache's mod_speling has something to "fix" case-sensitivity problems. In your case it should respond with a redirect to the properly-cased filename. CheckCaseOnly onCheck your server access logs periodically over the next few months. When you see that the number of requests to the uppercase filenames has dropped to nearly zero then you should remove the directive and let nature take its course with the remaining stragglers.
  23. There are too many things that are optional in that regex. Either you need to make some stuff required or you should combine some of them with alternation and make the whole set required. (first?)(second?)(third?) -> (?:first|second|third)If neither of those then we might have to rebuild the regex from scratch...
  24. I can't tell what you're asking for. Do you have an example of the input string, current output, and desired output? "or one". Not many. * is none or many.
×
×
  • 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.