Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by requinix

  1. So /blog/post-title does not exist as a file, right?
  2. Fix what? A null will be coerced to false.
  3. PHP? There's basically always a home directory set up for each user, though it might not actually exist, but that's a system thing.
  4. On a typical Debian/Ubuntu system, website stuff is at /var/www. There's nothing wrong with putting their home directories in there - tons of system accounts do things like that, just check /etc/passwd. And make sure you've disabled logins for those users.
  5. The original line was $V341be97d = preg_replace('/\^([^\^<])/e', "'`' . \$V70dda5df[ord('\\1') % 8]", $V341be97d); That was updating $V341be97d, on the left-hand side of the = assignment, with a new value coming from preg_replace. Your updated version preg_replace_callback('/\^([^\^<])/', fn($matches) => '`' . $V70dda5df[ord($matches[1]) % 8], $V341be97d); changed the preg_replace into a preg_replace_callback but it lost the $V341be97d= that was there before. Still need it, otherwise whatever this replacement was designed to handle (namely the ^0s and ^7s and such that you're now seeing) won't happen.
  6. $V341be97d = preg_replace('/\^x([a-fA-F0-9]{6})/i', "`#\\1", $V341be97d); preg_replace_callback('/\^([^\^<])/', fn($matches) => '`' . $V70dda5df[ord($matches[1]) % 8], $V341be97d); On that second line you lost the assignment that was on the left of the function. So preg_replace_callback is running but the result isn't going anywhere. (what I posted was meant as only the bit about the function, not to be the whole line)
  7. It's a shame the code is open-source but extremely unreadable... I'll use those two as an example. Moving away from /e goes basically like: 1. Switch the function to preg_replace_callback and drop the /e flag, obviously. 2. Change the second argument (a string) to be a function following the template function($matches) { return ___; } where you put in there the replacement string but minus the outer quotes. 3. Replace "\\1" with $matches[1], "\\2" with $matches[2], and so on, and correct any issues with the PHP syntax. So this preg_replace("/\+([\x01-\x7F])#/e", "chr(ord('\\1') + 127)", $V341be97d) starts as preg_replace_callback("/\+([\x01-\x7F])#/", function($matches) { return chr(ord('\\1') + 127); }, $V341be97d) and you replace the '\\1' string to get preg_replace_callback("/\+([\x01-\x7F])#/", function($matches) { return chr(ord($matches[1]) + 127); }, $V341be97d) What you have now is quite a bit different to the point that it won't actually work correctly. If you're using PHP 7.4 or later, you can simplify the function syntax if you want by using a function shorthand: function(...) { return ... } can be shortened to fn(...) => ... preg_replace_callback("/\+([\x01-\x7F])#/", fn($matches) => chr(ord($matches[1]) + 127), $V341be97d) The second one preg_replace("/#(#|[0-9a-f]{2})/ie", "'\\1' == '#' ? '#' : chr(hexdec('\\1'))", $V341be97d) is similar preg_replace_callback("/#(#|[0-9a-f]{2})/i", function($matches) { return '\\1' == '#' ? '#' : chr(hexdec('\\1')); }, $V341be97d) but has a little more to replace, creating preg_replace_callback("/#(#|[0-9a-f]{2})/i", function($matches) { return $matches[1] == '#' ? '#' : chr(hexdec($matches[1])); }, $V341be97d) or with the PHP 7.4 shorthand, preg_replace_callback("/#(#|[0-9a-f]{2})/i", fn($matches) => $matches[1] == '#' ? '#' : chr(hexdec($matches[1])), $V341be97d) The latest one you're working on preg_replace('/\^([^\^<])/e', "'`' . \$V70dda5df[ord('\\1') % 8]", $V341be97d) goes very much the same way preg_replace_callback('/\^([^\^<])/', function($matches) { return '`' . \$V70dda5df[ord('\\1') % 8]; }, $V341be97d) preg_replace_callback('/\^([^\^<])/', function($matches) { return '`' . \$V70dda5df[ord($matches[1]) % 8]; }, $V341be97d) except it has a wrinkle: it tries to use the $V70dda5df variable. You need to adjust the syntax a bit by removing the backslash (it was needed because the code lived inside a string) but also for the fact that variables aren't accessible inside functions... unless you explicitly tell PHP you want that with a "use" attached to the function. That results in, preg_replace_callback('/\^([^\^<])/', function($matches) use ($V70dda5df) { return '`' . $V70dda5df[ord($matches[1]) % 8]; }, $V341be97d) The thing about variables doesn't apply to shorthand functions, so with PHP 7.4 you could simply write preg_replace_callback('/\^([^\^<])/', fn($matches) => '`' . $V70dda5df[ord($matches[1]) % 8], $V341be97d)
  8. No offense but I've removed the file from your post. It doesn't look like something that's meant to be shared, but it also doesn't need to be to address this particular problem. I don't suppose there's a more up to date version of this script available, right? Because that would be ideal. If not, what did you try? The second argument is essentially PHP code, so you just need to translate that string into normal code and use it with preg_replace_callback...
  9. Simple: don't do the routing in your PHP code. Set up your web server to automatically rewrite /blog/* to /views/blog/page.php?page_slug=*. The term you'll want to research is "URL rewriting"...
  10. I take it that means you don't plan to try to restate your question?
  11. If you're going with an OOP model (and that's a completely separate discussion) then you should continue with it. Typically the Car class will handle any type of search against its data, meaning that there would be a method like Car::getByUser(user id). In addition to that, you can provide a shorthand from the User class to find that - namely, $user->getCars() that obviously can supply the user ID to getByUser automatically.
  12. Does it make sense for the model to have a method related to its data? Does it make sense to do the same thing over and over again? Code belongs in the one, single place (hopefully) that it is most related to. If the name is related to the model then it should be the model that deals with the name. If code is related to the controller, that being the place where you have code to deal with requests and responses and deciding what to render, then that is where it should go. Is finding the most recent user something that relates mostly to the data managed by your model or to process managed by the controller?
  13. Your composer.json says it needs to use PHP ^7.2, meaning 7.2 or 7.3 or 7.4. laravel/passport needs ^7.2 as well. So downgrade your version of PHP to 7.2/7.3/7.4, or update your composer.json and laravel/passport dependency such that you can use PHP 8.1 with it.
  14. Sure would help if you posted the rest of the output, not just the first line of it.
  15. I don't see those lines included in your first post. Please post the full thing.
  16. And what lines are PHP saying that have $total_price and $total_quantity undefined? Make sure to read the message carefully for exactly which lines it says that happens on.
  17. I'm not sure how you're getting that error. Are you sure the code you posted is exactly what you are running that creates the warnings? Because you very clearly do set those two variables with values ahead of time - they are not undefined.
  18. https://www.google.com/search?q=download+mysql+8 The first few links all looked relevant. If that's not working for you then tell us which page you tried to download from.
  19. There is no single best provider. They all have different offerings at different prices. Compare and decide what serves your purposes best.
  20. There used to be a time, long ago, where $page would be created automatically. If whatever resource you're learning from expects that to be the case and doesn't use $_GET/POST then you need to find another resource to learn from.
  21. If you want this site because it's important to have the site then have you considered a hosted WordPress site? It'll cost some amount of money but you'll get a site like you want much faster. If you want this site also because you want to do this work yourself then consider that allowing someone to go into the site and edit the content is a substantial feature - much more than a static site that displays information. Maybe you should start small: a few files that you (and/or someone with some familiarity with HTML) edit as needed that shows what you want on the site, then later after everything looks good and works well you can add stuff like a small content management system with user logins (aka a CMS).
  • 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.