Jump to content

requinix

Administrators
  • Posts

    15,053
  • Joined

  • Last visited

  • Days Won

    413

requinix last won the day on March 12

requinix had the most liked content!

About requinix

Profile Information

  • Gender
    Not Telling
  • Location
    America/Los_Angeles

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

requinix's Achievements

Prolific Member

Prolific Member (5/5)

1.2k

Reputation

360

Community Answers

  1. requinix

    Anti XSS

    What "fallback"? It doesn't make sense to have a "fallback". What you're doing is altering the data being passed to your script. You're saying "yes, you did type one thing, but I'm going to change it and pretend you typed something else". There are two basic parts to things like HTML and SQL and JSON and the like: you have the bits with values that you want to fill in (data), and you have the bits that are not data but fundamentally define how the HTML/SQL/JSON works (structure). Sanitization is about making sure that the data stays "data" and never crosses over into "structure".
  2. requinix

    Anti XSS

    1. Never modify $_GET and $_POST. 2. Never sanitize values ahead of time. 3. Always work with pure, unaltered values, and reserve sanitizing values until the very last step according to what you're doing with those values. So yes, there is a problem with that there. Don't do it. You should only ever be doing two(ish) things: use prepared statements for your SQL, and use htmlspecialchars when outputting an unknown value into HTML. More than that is probably wrong and going to create problems for yourself in the present and/or future.
  3. You want to encrypt a stream using functionality that encrypts files? That doesn't sound right... "No such file or directory" sounds relevant. Does the $messageData file exist, and is it readable by PHP? Does the $encryptedMessage file exist, or at least its parent directory, and is it writable by PHP?
  4. That response doesn't look like the data you need. In the earlier code, you had three arrays: one of Region, one of McTotal, and one of McAssigned. Now you have one single array with all of the Branch (not Region?), McTotal, and McAssigned values. If you make your PHP return the three arrays separately from each other (such as in an object) then your Javascript can take the three arrays and use them with the graph.
  5. What part are you having a problem with? Is it the Javascript? Can you change your Javascript so that the graph can update when one of those variables changes? Make a function to do this, make its arguments be those three values, then call that function when the page loads. Is it the PHP? Can you change the code so that it filters in the way you want, getting whatever values it needs to do so from $_POST?
  6. You're throwing a lot of CSS at this problem. If you have a problem, adding more CSS rarely ever makes things any better. Rethink how your different blocks of content are arranged. If you want the border to span the width of the input as well as the button, don't put the border on the container. If you want the button to sit next to the input, don't use absolute positioning. If you want a gap between the input and the button, don't add padding to the inside of the input. Learn about margins vs. padding, about inline-block, and if you want bonus points, about flexbox.
  7. I would first check the VS PHP extension to see what support it has; probably not PHP_CodeSniffer, but quite possibly Xdebug. If not then there's a good chance you're out of luck - because nobody uses Visual Studio for PHP. And, frankly, you should take that as a hint, and go for a PHP IDE (like PhpStorm) or switch to VS Code (at least for this). Don't get me wrong, I like Visual Studio. I think it's a great platform. But software development is about using the right tool for the job.
  8. Your command will set the "Content Block" value to a string which happens to contain JSON data. If you want that string value to be interpreted into a JSON value then try CAST-ing it.
  9. Visual Studio or VS Code? Anything you haven't been able to figure out with some searching on your own? Myself, I'm seeing a number of results on how to set both of those IDEs up for PHP development...
  10. Your .swiper-slide is being overridden by the "swiper-bundle" rules. Don't fight the framework. If the swiper wants to have width:100% then put it inside a fixed-width container.
  11. 1. If you use /s for regex delimiters (at the beginning and end) then any /s you want inside the regex have to be escaped. Look at what your original had. 2. What's the rest of the code?
  12. Why would you use Javascript for this? It's okay to have the regex be multiple patterns. You don't, not necessarily, have to use a single capture group to get the one value you care about. youtube.com/shorts/(\w+)|youtube.com/watch\?v=(\w+)|youtu.be/whatever else Only one of $1 or $2 (or what you put in the "whatever else") will ever have a value. And do remember that "." matches anything, so "youtubexcom/short/blah" will match the above too.
  13. Ha ha, what? That's their solution? To make you get another API key so you can query for 2x the SKUs? What happens when you need 9? 10? 20? Is the API so expensive for them to run that they can, really, only handle 3 at a time? And then, why not simply run multiple requests? You already have that there - just use the same key. Is there also time-based throttling on what you can do? This is so weird. That aside, work it like this: Using one API key, get yourself a loop that can do all the SKUs. So basically what you have there (if it didn't have the key stuff). That's the basic functionality you need here, and you can think of the "swap between API keys" as a small layer to be added on top of the functionality. Then, set up an array of keys - because distinct variables makes this awkward to work with, and even more awkward to maintain if/when you discover that you need to add a third key. To pick the key to use, think of it in the general sense of "I have multiple keys and I want to cycle through them". Because a mindset of a fixed number of keys (especially 2) will get you stuck into a narrow line of thinking (like needing to alternate between them). "Cycling" works simply and doesn't need to be adjusted based on the number of keys: cycling is picking key 1, then key 2, then key 3... then when you're on the last key, you go back to the beginning. Cycling requires a counter, of course, but tou can get one from the foreach/array_chunk and that will count up automatically without you having to increment it yourself. Then take your counter, add modulus based on the number of keys, grab that key, and stick it into your API. const MAX_SKUS_PER_REQUEST = 3; $keys = ["one", "two", "three", ...]; foreach (array_chunk($sku_numbers, MAX_SKUS_PER_REQUEST) as $i => $chunk) { $key = $keys[$i % count($keys)]; ... }
  14. Split. What are you talking about, what is your code, and what is the problem with it?
×
×
  • 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.