Jump to content

requinix

Administrators
  • Posts

    15,227
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. 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.
  2. I don't see what would be responsible. Did you alter any other files?
  3. 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.
  4. $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)
  5. 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)
  6. 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...
  7. 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"...
  8. I take it that means you don't plan to try to restate your question?
  9. 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.
  10. 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?
  11. 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.
  12. The error seems clear to me. What don't you understand about it?
  13. Sure would help if you posted the rest of the output, not just the first line of it.
  14. I don't see those lines included in your first post. Please post the full thing.
  15. 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.
  16. 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.
  17. 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.
  18. There is no single best provider. They all have different offerings at different prices. Compare and decide what serves your purposes best.
  19. 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.
  20. 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).
  21. I've moved the thread to a place that might get some more attention. (No harm done.) It'll be pretty hard for us to figure out how to turn the design into a webpage if it's all in your head. Can you sketch it out graphically? Like with an image or using some free online sketch/design website place. Also, what purpose do you want for your site? Do you just want to talk about you, like with an email to contact you? Do you want to host information like where you will be performing on what dates? Do you want one page with everything or multiple pages for different topics? As you try to answer that, keep in mind that you are new to this so simpler will be easier - you can always add more or change what you've done over time as you continue learning, of course.
  22. No. The session is stored on the server so as long as the server isn't compromised then the session data won't be compromised. It's like my refrigerator. There's no lock on it so anyone could take and leave what they wanted at any time, so in that sense it's insecure, however the doors to my home are locked so people can't get inside.
  23. 1. It clutters the session. If you have a lot pages storing their arbitrary data in there then you start to lose track of what values are in there and why. It's the same problem as with global variables. 2. Making sure the session is clean of old data can be hard. Consider if someone browses through the quiz and then stops partway: what happens to the data? It stays in there until something either overwrites it or removes it (like doing another quiz) so the longer a user is on the site and the more they don't conform to the expected behavior for a user, the more data piles up. 3. Upgrading users through data changes becomes a problem. If the quiz works one way for a long time and then it's changed to work differently (requiring the session data be stored differently) then you have to worry about users with long-lived sessions who have old data still in there. 4. It is actually slower to some degree. Every time you fire up the session, PHP has to deserialize the entire session from its cache, and if there are large chunks in there you don't care about then it is wasteful.
  24. I mean which page (with the information) are you on? Like there's an Activity tab at the top of the page which has "streams" like unread content or stuff I've commented in.
×
×
  • 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.