Jump to content

requinix

Administrators
  • Posts

    15,266
  • Joined

  • Last visited

  • Days Won

    431

Everything posted by requinix

  1. Is the upload page on an HTTPS URL? Is the action of the upload form using an HTTPS URL?
  2. There was a specific part of the docs I wanted you to see, but apparently it's in a user comment and not part of the official documentation:
  3. Hint: 153 + 212 = 365 And clarification: don't do subtraction to fix it (that's not quite accurate) but think about what "direction" the difference uses.
  4. By my math that's 1.6GB, not 8GB. If you don't need them all at once then generate them one at a time. function sampling($chars, $size) { $base = count($chars); $limit = pow($base, $size); for ($i = 0; $i < $limit; $i++) { $combination = ""; $n = $i; for ($j = 0; $j < $size; $j++) { $combination = $chars[fmod($n, $base)] . $combination; $n = floor($n / $base); } yield $combination; } } $chars = str_split('qwertyuiopasdfghjklzxcvbnm1234567890'); $generator = sampling($chars, 5); foreach ($generator as $combination) { // ... }You have to use a foreach on $generator because it will generate each combination as you need it. Not all at once.
  5. - Put vendor/ at the same level as your own directory for classes and such - probably at the top - "public" can be called whatever the hell you want it to be - IMO "src" doesn't make sense for PHP so call it something else - Ignore files that you don't want in source control - Putting public files in a "public" directory is reasonable; symbolic links are a hassle to deploy - If you want to know whether there's a PSR then you should check if there's a PSR - The industry is not consistent
  6. There will be more than 60 million strings of that length. As you generate them, multiple copies of arrays are being held in memory: $combinations and $new_combinations. Add to that PHP's own overhead and I could see you running out of memory... though 8GB seems a bit too much. What are you going to do with this array? Do you actually need all 60M combinations at once or will you work with them one at a time?
  7. What does "corrupt" mean? How are the files corrupted? What is wrong with them?
  8. Take a look at the array_diff_* functions.
  9. Check your firewall. I imagine the data is within $request. Again, not very familiar with React, but I wouldn't expect it to be truly asynchronous. Rather the code would be designed such that execution moves between different pieces of code quickly based on certain conditions - the same way Javascript isn't actually asynchronous but feels that way.
  10. Run it on another machine. Like POST? That's a cURL thing. Use the CURLOPT_POST and CURLOPT_POSTFIELDS options. Having all connections handled within one PHP process. It's all in one script - don't need databases or shared memory or whatever to "remember" data across requests. And you can run each instance on its own port. I don't use it myself so I'm kinda just guessing there.
  11. So you have a MySQL database that contains a copy of all the data stored in SQLite databases which are themselves spread across multiple servers? And you have control over all these servers? Why such a disjointed approach? Why not have just the one database, or perhaps one writable database and multiple read-only replicas? Anyway, this is basically replication so you can take a page from the MySQL playbook: a "version" identifier, such as a plain number. When master or slave has a change it increments the number locally and sends that number with the data to the other server. When the other server receives such a message, it verifies that the number is only one operation ahead of itself and then replays the data change. If the number doesn't match then the two servers are out of sync and you do a full sync (however you'd like to do that).
  12. If you make changes to the database then that means changes to the underlying file, right? You can know if there were changes if the timestamp changes.
  13. This is really just templating. Just about any templating solution will work. Do you really want the input and template files to be valid PHP code? Doesn't seem like a good idea to me. I mean, it's not like you can execute them as they are now. How about simpler stuff like (input.ini) colour = "brown" animal = "cat" (template.php.tpl) <?php echo "<p>This is a {{colour}} $animal.</p>"; <?php $variables = parse_ini_file("input.ini"); $template = file_get_contents("template.php.tpl"); $pairs = array(); foreach ($variables as $name => $value) { $pairs["{{" . $name . "}}"] = $value; } echo strtr($template, $pairs);
  14. Modification time of the SQLite file?
  15. The public one. You know, for sharing publicly. With the public.
  16. Timestamp. Versioning. Deltas. Stuff like that. Hashes can tell you that something changed but won't help you identify what it was.
  17. "$resp->Ack" would only have worked if was a child of the root element. Sounds like it wasn't, but I can't be sure because you didn't post the XML you're working with.
  18. 1. The PHP is irrelevant. Only the HTML it outputs matters. 2. Actually it kinda does. Those three selectors are all essentially "if"s: if this matches, or if that matches, or if the other one matches, then...
  19. If you're taking the approach of putting an ID on the body then you can do everything with pure CSS. <body id="home"> <ul id="menu"> <li id="menu-home"> <a href="/index">Home</a> </li> </ul> /* something along the lines of */ body#home #menu #menu-home a, body#foo #menu #menu-foo a, body#bar #menu #menu-bar a { whatever; }
  20. Because that's all the "simple" syntax allows: one property. If you're looking for a rationale from the PHP developers as to why only one property indirection is permitted then you're probably going to have to ask them directly. [edit] Ohhh, you mean why is it an error. Not why is it not allowed. Nevermind.
  21. Right, they're the same for particular types of items, but not for all items. That means the data structure will have to vary somehow, and you can accomplish that with a JSON string or by creating an arbitrary array. To refine the example I gave earlier, <input type="hidden" name="items[0]" value="door"> <input type="hidden" name="options[0][opening]" value="chain"> <input type="hidden" name="options[0][numwindows]" value="2"> <input type="hidden" name="options[0][storey]" value="1">0 is the first item added to the order. It is a "door". The door comes with multiple options, which arrive in your code as an array in $_POST. $option_keys = array( "door" => array("opening", "numwindows", "storey") ); $items = array(); foreach ($_POST["items"] as $n => $type) { if (!isset($option_keys[$type])) { // error: invalid item type continue; } $item = array("type" => $type, "options" => array()); if (isset($_POST["options"][$n])) { // extract options from the form and validate against $option_keys $item["options"] = array_intersect_key($_POST["options"][$n], array_flip($option_keys[$type])); if (count($item["options"]) != count($option_keys[$type])) { // error: not all options set in form continue; } } $items[$n] = $item; } // $items = array( // 0 => array( // type => "door", // options => array( // opening => "chain", // numwindows => 2, // storey => 1 // ) // ) // )The JSON option isn't that much different. <input type="hidden" name="items[0][type]" value="door"> <input type="hidden" name="items[0][options]" value="{"opening":"chain","numwindows":2,"storey":1}"> $option_keys = array( "door" => array("opening", "numwindows", "storey") ); $items = array(); foreach ($_POST["items"] as $n => $item) { if (!isset($item["type"], $option_keys[$item["type"]])) { // error: invalid item type continue; } if (!isset($item["options"])) { $item["options"] = array(); } // extract options from the form and validate against $option_keys $options = array_intersect_key($item["options"], array_flip($option_keys[$item["type"]])); if (count($options) != count($option_keys[$item["type"]])) { // error: not all options set in form continue; } $item["options"] = $options; $items[$n] = $item; } // $items = array( // 0 => array( // type => "door", // options => array( // opening => "chain", // numwindows => 2, // storey => 1 // ) // ) // )And there are multiple variations possible for both of those, depending on what's easiest to work with both in the Javascript and the PHP.
  22. JSON might be useful if the inputs vary a lot - like there isn't a consistent structure every time you prompt for particular details regarding an item. Make sure to validate it on the next page so that someone can't tamper with the data before submitting the form. The normal answer is to use arrays, which could also help here but probably isn't the only thing you need. <input type="hidden" name="whatever[]" value="1"> <input type="hidden" name="whatever[]" value="2"> <input type="hidden" name="whatever[]" value="3">and $_POST["whatever"] is an array.
  23. Compare $data between the working and non-working versions to find out what the difference is.
  24. An easy way to determine which file the user is looking at would be basename($_SERVER["REQUEST_FILENAME"])That'll be "index.php" or "index-02.php" or whatever. Put that value into a variable then test it for each of the links: if it matches then show the class, otherwise don't. class="active">01
  25. :/ It's running from within PHP so why would it be not be affected by PHP settings?
×
×
  • 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.