Jump to content

requinix

Administrators
  • Posts

    15,067
  • Joined

  • Last visited

  • Days Won

    414

Everything posted by requinix

  1. This is an Apache question and not a PHP question, so now we're in the Apache forum. 1. Use SERVER_NAME instead of HTTP_HOST. After making sure your server is configured with the correct domain as the canonical name. 2. Instead of checking for https in one redirect and www in another, do both at the same time: if HTTPS is off or the HTTP_HOST != SERVER_NAME then redirect to the SERVER_NAME + REQUEST_URI.
  2. "Incorrect string value" means you're trying to insert data that isn't valid for the column. In your case, the column is defined as utf8mb4 (aka UTF-8) but your string is not UTF-8. If the value is binary data then do not use VARCHARs in the first place. Those are for character data. Use VARBINARY instead. https://dev.mysql.com/doc/refman/8.0/en/binary-varbinary.html Either that, or you aren't supposed to be inserting raw binary data but either hex digits or a base-64 encoded version of the data...
  3. You and your server disagree about where the file is. You put it in the place you want it, and you know what the path is, but what you're telling the server is not the same thing. So let's see if we can't just resolve this immediately: 1. What is the full, absolute path to the PDF file as a file? Not a URL. I mean where it exists on your server - for example, /var/www/mywebsite/admin/assets/cvs/myfile.pdf 2. What is the full, absolute path to the PHP script you want to use to download the PDF file? If you still want one. You don't have to have it. 3. In case it's not obvious from those answers, what is the full, absolute path of where your website files are hosted? For example, /var/www/mywebsite.
  4. Either the path is wrong or the file is not where you think it is. I don't know what else to tell you. If the first one works then why do you want to change it?
  5. You've dumped a whole bunch of Javascript code and asked to "convert this from Javascript array". You need to be a LOT more specific about what you want help with because nobody here is going to read through that whole thing and try to guess what you want.
  6. No, the path is not correct. Because if it were then all this would be working, wouldn't it? If you want to link to the PDF in your HTML then read this and give it another try: https://stackoverflow.com/questions/2005079/absolute-vs-relative-urls If you want to read the PDF with PHP code then read this one and give it another try: https://phpdelusions.net/articles/paths
  7. You can't encrypt the location because the end result is that you're still giving someone a URL to the file. Having gibberish instead of the word "documents" doesn't change that. The actual answer here is pretty simple: don't give direct links to your PDFs. Use a PHP script which authenticates the user and then outputs the file. You can use URL rewriting to transform /documents/whatever.pdf to something like /document.php?filename=whatever.pdf (which means existing URLs still work), then do something like <?php session_start(); if (!isset($_SESSION["userid"])) { // or whatever so you know if the user isn't logged in http_response_code(403); exit; } if (!isset($_GET["filename"])) { http_response_code(400); exit; } $filename = $_GET["filename"]; if (!preg_match('/^[a-z0-9_.-]+$/i', $filename)) { // potentially other characters in there http_response_code(404); exit; } $path = $_SERVER["DOCUMENT_ROOT"] . "/documents/" . $filename; // or whatever the path should be if (!is_file($path)) { http_response_code(404); exit; } $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); $mime = [ // default $extension => "application/octet-stream", // list of file types you might have "pdf" => "application/pdf", // ... ][$extension]; header("Content-Type: $mime"); header("Content-Length: " . filesize($path)); header("Content-Disposition: inline;filename=$filename"); readfile($path);
  8. When you look at most sorts of Javascript UI frameworks, you see a common design: they keep an internal "model" of what the UI looks like, do work on that, and then update the actual UI with the changes. While it seems like a lot of extra work, it makes the design a lot simpler as you can manage the internal model whatever way you want instead of being forced to observe how the page is laid out. Repeating that concept here would be helpful. 1. For each row that you need to update, keep an internal array of the values of the 12 input boxes. Each one starts with a value of zero (apparently). 2. When an input is changed, go into that row's array and update the month's value. That's one half of the functionality: keeping track of when the value changes. Every time this process completes you'll have an array of the current values for the row. 3. Take that array and update the row's total. 4. Update the MS% value too? I don't know what that's supposed to be. That's the other half. Each of those halves can be done more-or-less independently of each other. Here is where I would say "Before I continue, let's clean up that HTML some because it's painful to look at" but that would take quite a bit of effort. So I won't. 😓 But there are some changes that would be really, really helpful: * Change the markup for the input boxes so that you don't have to list out the months so often by adding a data-month attribute for the month number (counting from 0) * Get rid of their IDs because (a) they're more often a bad thing than a good thing and (b) you aren't using them anyways <input type="number" class="form-control" name="Jan[]" value="" style="width:100%" data-month="0" required/> Then add some Javascript. * Don't use keyup. There's a perfectly good event exactly for this sort of thing: input * Instead of adding event handlers for every single month input, make use of the fact that Javascript "bubbles up" events and add a single event handler to cover all of them $(function() { // for each row in the table, $("#example tbody tr").each(function() { // the 12 values for the months const values = Array(12).fill(0); // a running total that can be updated every time a value changes let total = 0; // arrow function means "this" is inherited from the current scope (ie. this == the table row) const updateTotal = () => { $("[name='Total[]']", this).val(total.toString()); }; // every time something with a data-month changes its value, $(this).on("input", "[data-month]", function() { // get the new value const newvalue = parseInt(this.value || "0", 10); // update the running total total += newvalue - values[this.dataset.month]; // put the new value into the array values[this.dataset.month] = newvalue; // update the total updateTotal(); }); }); }); Demo: https://jsfiddle.net/gyhu2k57/
  9. strtoupper is a PHP function. You are using Javascript. They are completely different things. newent.value is (presumably) a string. This page may be helpful to show you what you can do with it.
  10. $param is an array of values. It is not an array of values where one of them is the values combined together separated by spaces. If your query has 3 integers then your parameters array needs to have 3 integers.
  11. Your description doesn't say whether the signature is raw bytes in base 64-encoding or hexadecimal bytes, so you need to confirm which is those is desired. Otherwise, for the first line of code, my guess is you're not formatting the price with the correct "two decimal format". For the second, you seem to be using the merchant code value twice. Seems pretty clear to be just by looking at that line...
  12. Do you mean that you have it outputting "please work" at the moment you want to? The only things wrong with that second piece of code are (1) it doesn't call $citizen->selectCitizen() and (2) it's supposed to return a value ($res) that you can use to determine if it worked. You haven't really shown very much of your code, but it doesn't feel like standard MVC so far...
  13. If you want help understanding what an error message means and how to fix it then you really need to tell us what the error message is.
  14. What are you trying to execute? When what button is pressed? And what is your question that we can help you with?
  15. Well, first thing you're missing is valid HTML. Second is that you're using inline Javascript events from the '90s instead of modern event handlers. And third is that if you want to know about the form submitting then you should be having the form tell you when it's about to be submitted instead of the button when it's being "clicked". Fourth is that either of these is better than a confirm() dialog: 1. A checkbox in the form that says they want to do whatever it is the form does. Mark it required so the form won't submit without it being checked. Then you don't have to write any code at all. 2. A modal popup where you can customize everything and make it fit with the appearance of your site. The form's button instead triggers the modal, and the modal is what actually submits the form. Fifth is that cancelling an event requires either returning false from the inline code (which is also '90s code) or using an Event object that you can .preventDefault() on (modern).
  16. Aww, then it's adjusting for timezones. You can go the longer route too: const from = new Date($("#from").val()).toLocaleDateString(); Javascript isn't particularly good with dates, but it can do the basics if you're willing to learn more about it.
  17. Are #from and #to date <input>s? Use .valueAsDate to get Date objects, then call their .toLocaleDateString() methods to get the date in a locale-based format. It might not be exactly dd-mm-yyyy, but (a) it's probably still good and (b) you can customize it some if you want. const from = $("#from")[0].valueAsDate.toLocaleDateString(); const to = $("#to")[0].valueAsDate.toLocaleDateString();
  18. I have no idea what your hosting provider offers; if you/she uploaded the original files then you should be able to upload those files again, or if the hosting provider set up WP then they should be able to do that again. Finding out what was deleted would be really helpful - for you. Find out what files you're supposed to have, perhaps by setting up WP somewhere, and compare with the site to see what's missing. A bit more drawn out process will be to find and read whatever error messages are being created (because WP won't be just "down" without saying why) and use that as a clue. Perhaps some of those messages will be talking about trying to use files that don't exist...
  19. They're log files? Is it important to recover them? Since they are just, you know, logs... Files are files. Any sort of file recovery thing appropriate for that OS and/or filesystem would work, but those tend to need low-level disk access. Did you try asking the hosting provider if they can do anything?
  20. Are we talking "make an election" like CIA? I could help you with that... but then I'd have to shoot you.
  21. Is this another "someone else did some work for me earlier and I don't understand what they did so please do the work for me this time too" question? This $loggedin = $_SESSION['member_id'] ?? 0; plus this if ($loggedin) { both look very much like they qualify as "activated only when logged in as a user or admin". Have you tried applying that to "the link" (I don't know what link you're talking about) so that it only appears when the person is logged in?
  22. I'm confident that the less complicated one is the better solution. In terms of code, all you need is something that can tell what option the user selected, and something that can do what it needs to do to give the user the PDF they requested. Try writing the code yourself. If you have problems getting it to work then post what you have with a description of what you're trying to do and what problem(s) you're having with it.
  23. I hear a lot of "Barand did this" and "Barand did that". Do you actually know what he did? Because if you don't then that's a problem and you need to start learning... If you can read the code then the first thing you can do is find out/remember whether it's using mail() or a library. Which is it?
  24. One of those options is significantly less complicated than the other, and the outcome is the same.
  25. If the tutorial is telling you to do something you don't want to do then why are you using the tutorial? Tutorials are not documentation. Try reading the documentation.
×
×
  • 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.