Jump to content

requinix

Administrators
  • Posts

    15,227
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. Kinda seems like the library is buggy. The code I linked to has a rather noticeable bug, and your var_dump() output shows it knows the data length but apparently can't get the data itself.
  2. Try using var_dump() instead of print_r(). That will show more specific information about each value, like whether something is a string and how long it is.
  3. Did you check if there were any errors reported by the library? Because I'm pretty sure I see a bug in it.
  4. Good thing about PHP is that it's open-source, so you can look at the library to see how it handles ETCO data. Bad news is that it's a bit perverse about the structure of the array. You specify a "timestampformat" key, and potentially "flags", but then everything else is more arrays. Those are where you add the "timestamp" and "typeid" values. $TagData['id3v2']['ETCO'] = [ "timestampformat" => 2, ["typeid" => 3, "timestamp" => 1000], ["typeid" => 4, "timestamp" => 1500], // etc ];
  5. What library are you using to write the tags? Does it actually use arrays with stuff like "timestamp" and "timestampformat"? Because that code sample you have there uses an associative array and thus will only allow a single timing code. If you're supposed to specify a "frame_name" and "data", which is basically the minimum, then the data would be the full frame data. Presumably raw bytes. So "\x02" (format) + "\x03\x00\x00\x03\xE8" (event 3, timestamp 0x000003E8ms) + additional timing codes.
  6. There's a lot of code involved in this form and email process that you aren't posting so it's going to be very hard to identify where the problem is. So generic answer: check the documentation for the form stuff to make sure you're using it correctly. Because "Array" means that the value was an array, but none of those values ought to be arrays.
  7. You could have. It's weird, you shouldn't really be adding system users to your personal group, but you could. PHP should run as an under-privileged user such as (I assume) "daemon". It should not run as your account. If you need it to be able to do certain things then you should be granting it permission. Here, I think I would change ownership on whatever directory to be owned by your user and the daemon group, then set permissions to 0775.
  8. At least one of those variables is a string containing an invalid number. Find it, figure out why it isn't the number you think it is, and fix it.
  9. Your user account is the owner and you've given yourself all the necessary permissions. But is PHP running as your user account?
  10. The first blob of code you posted was putting those results into an array and looks fine, but I can't help but notice that the request being made inside the loop is going to be the same every time. Shouldn't it be using $line somewhere?
  11. What's wrong with it? Describe your problem.
  12. style="background: url("https://safebuy.nz/images/background.png") center / cover repeat #EEEEEE;" Take a closer look at that.
  13. Post code.
  14. Every time you need a new format you'll have to modify your table schema. That's not a good thing. There is no exhaustive list of formats you can rely on, which means you are coming up with this list on your own and deciding "yeah, I think that's all of them". That's not a good thing. If there's 20 different media formats then you've got an ENUM with 20 different entries. That's not a good thing. It's the same problem as you had with the list of genres.
  15. Silly oversight on my part: if ($node instanceof DOMElement && $node->hasAttribute("href")) { should be if ($node instanceof DOMElement && $node->tagName == "a" && $node->hasAttribute("href")) {
  16. Given that there are better options for you to use, no, it is not okay.
  17. I think you missed the question. The referrer will be an absolute URL...
  18. PHP uses pkg-config. Make sure you've added your cURL libraries to it, or whatever process it takes I don't know. Then PHP should get the library from there.
  19. If you view a page at https://www.domain.com/page.html and it tries to show an image from https://www.domain.com/image/img.jpeg, what do you think the referrer string will be? Also, you cannot rely on the referrer string even being present. You should only block access if there is one.
  20. "For the sake of learning" is a good argument, but so is "use the right tool for the job". Learning about PHP includes knowing what it's good for and what it isn't good for. Surely there are other situations where you could apply PHP? Perhaps some scripting that isn't so straightforward? But if you really want to do this in PHP then there are things to consider, like - Make this a proper CLI script by taking arguments instead of prompting the user with questions - Don't use chdir to change directories and instead do whatever work needs to be done using relative paths - There's no need to call wget when PHP is perfectly capable of "copying" files from the internet - It can even extract ZIP files
  21. If you're looking for a suggestion, I would say to stop using PHP and switch to an actual bash script: there's nothing in there that needs PHP, and what's more, a lot of what it does is shell commands.
  22. https://3v4l.org/GH1pk If $buffer was what you say it was then it should all work fine. But it does not work fine. So $buffer must be something else. I know you think the contents of the file are that string, but have you checked literally what the value of $buffer is?
  23. That's great and all, but what is the value of $buffer?
  24. Basically, my solution is that you set up a state machine to deal with the markup. After you've split on tags and non-tags, you go through the array while keeping track of where you've been. But forget it. I fell for a classic mistake again: processing an HTML string like text. HTML should be treated like the structural thing it is. 1. Load your HTML string into a DOMDocument. That will also help clean up invalid markup, which regular expressions and string processing cannot do. 2. Loop through all the nodes. If it's a link, skip it. If it's text, do the replacement (which involves creating a new node, not simply adding a string). If it's some other element, go through its nodes recursively. 3. When you're done, dump the document back out. Doing that isn't exactly the easiest thing when you're not familiar with this kind of work, so https://3v4l.org/sehhK
  25. For these sorts of questions it's often a good idea to see what other sites (eg, Amazon) do, then consider whether their solution makes sense to your site. No. 1. Don't change stuff the user inputted without them knowing. It's confusing. 2. The address verification service could be wrong. It's happened to me. Not sure what you're describing. Showing the "fixed" and original addresses and asking them to pick (or to edit/enter a new one) is probably the most common solution.
×
×
  • 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.