Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

Gemini 🤖

Administrators
  • Posts

    15,264
  • Joined

  • Last visited

  • Days Won

    431

Everything posted by Gemini 🤖

  1. Regarding Docker, there are two fairly common problems with software: 1. If I want to edit and test and run code, if the code has particular requirements, I have to set up my machine with those requirements. And that makes it hard to edit/test/run other code which has similar but different requirements. 2. When I want to deploy my edited code, it has to run on a server, and that server has basically the same sorts of requirement problems. What Docker does is solve those by providing a self-contained environment. So I can edit and test and run code in its own isolated environment, with its own requirements, then do that with other code at the same time without worrying about the two of them conflicting. Those problems used to be solved, not that long ago, by virtualization. Which is a self-contained environment too. The difference is that virtualization was basically a tiny little software-based computer that you'd have to boot up and such just like an actual computer, while Docker uses features in your operating system to give you something isolated without having to deal with that full "computer" experience. "Docker Hub" is a central place for people to upload their "images", which are basically archives of all the files needed for whatever. For PHP, there are images that give you php-fpm, and those images contain all the files php-fpm needs to run. Same for MySQL, and Apache, and tons and tons of other things. What one typically does is then assemble those images into a "stack" and then add a little configuration to make them talk to each other. So you take php-fpm plus MySQL plus Apache, have php-fpm talk to MySQL, have Apache talk to php-fpm, and then you can point your browser to the Apache piece and have a fully-functioning site. All without having to actually install php-fpm or MySQL or Apache on your computer. It's not a total improvement, though. Like, it is going to take up more disk space: those images have php-fpm/MySQL/Apache installed in them, but remember that each image is isolated, and that means each image also needs some amount of installed libraries and whatnot, resulting in taking up more space. Plus, the way images work, there's also some wasted space going to happen. However, the benefits of dealing with Docker greatly outweigh concerns of space usage - especially in a day and age where disk space is plentiful and cheap. GitHub provides an internet-hosted git repository for you to use, but it's not a replacement to having files on your own computer. You still want everything available to you to edit and all that. But it does offer a number of advantages, like acting as a backup, and having a place to coordinate work with other people, and a bunch of other things. That's why I say you don't have to worry about it for now. It doesn't provide some sort of brand-new development experience that will fundamentally change what you're doing now. It provides additional features. That said, the one thing that would be useful to take out of it now would be as a place to back up your work: do what you want, "commit" (save) your changes, "push" (upload) them to GitHub, and then not have to worry about losing all your work because your computer caught on fire. GitHub isn't the only such place, of course. GitLab and Bitbucket are two popular alternatives, and they all provide basically the same sorts of features. "Mode" isn't right, but otherwise yes. When you make a git repository in GitHub, you have the choice of making it public or private. Public repositories are public: anyone can see it and read the code, anyone can "fork" (copy) it for themselves, and anyone can "submit pull requests" (suggest changes) - though you're not forced to accept the changes, of course. Private repositories are the opposite. And yes, you can change your mind later.
  2. That there is especially important code you have to look at - it does say "http://" after all. But you should fix this by not doing any https:// or HTTP_HOST stuff. You should use simple URLs that are just paths on your site. As in "/admin/propertyImages/stuff.jpg" and not "https://www.luxurybeach.com/admin/propertyImages/stuff.jpg". The browser can take the path and figure out the rest perfectly well. So with that $ImageUrl variable, keep the /admin/ because your URLs in the database don't have that, but get rid of the rest. I would do it like: $printTXT = ""; while ($line = mysql_fetch_row($resuls)) { $ImagePath = "/admin/" . $line[2]; $pname = $this->wordcount(trim(str_replace("Puerto Vallarta Rental", "", str_replace("-","", $line[1]))), 25); $printTXT .= "<div class=\"sldie\">\n"; $printTXT .= " <a href=\"/". $line[0] . "/" . $line[1] ."\"><img alt=\"$pname\" border=\"0\" height=\"390\" src=\"$ImagePath\" width=\"625\" /></a>\n"; $printTXT .= " <div class=\"caption\"><h2><a href=\"/". $line[0] . "/" . $line[1] ."\">" . $pname . " <span>" . $line[4] . "</span></a></h2></div>\n"; $printTXT .= "</div>\n"; } $printTXT .= "\n"; return $printTXT; where I get rid of $prphost and $host, rename $ImageUrl to $ImagePath (it's more accurate of a name that way), and write the "/" and "/admin/" prefixes right there on the lines (since it's just a slash now and not the more complicated stuff).
  3. You test it by entering "http://luxurybeach.com" in your browser and seeing what happens. But I'll do it... The redirects look fine. You're using Apache and really ought to be doing the redirects with that instead of PHP. I saw a 404 on the homepage once but couldn't see what it was for, and I'm not seeing it again, so I don't know. I do see that a lot of images are being loaded over HTTP, but the browser is being smart and knowing it should go over HTTPS instead. You still ought to fix that. The images are /admin/propertyImages/stuff.jpg and I don't know for sure where those particular URLs are coming from. Now, Correct. But this isn't a PHP problem. This is a server configuration problem. It doesn't know how to handle a URL like /real-estate-sales/1/2. My guess is that you have a HTTP server configuration and a second HTTPS server configuration, and the latter isn't set up the same way as the former.
  4. ...okay, yeah, new, I can see that... I don't know what you mean by that. JSON is a syntax for writing data, and VS Code does use JSON for most of its data, but it's also not something you typically have to deal with - like, there is a regular UI for changing most settings. Where? VS Code is designed for use with many things done through a keyboard. By which I mean, for a lot of things you might want to do, you do so through the "command palette" and not by clicking a button somewhere. For example, if I want to select a lot of lines in a file and sort them, there is no menu I can click through to find that. But if I open the command palette and type "sort", I have the option of "Sort Lines Ascending" (and some other things) that I can choose. That's not to say you don't use the mouse. There's still lots of things that you can/should do through clicking, but VS Code isn't like MS Word or something where there are toolbars to navigate through. So that's what I think you mean by "commands". I don't know what "paths" you are talking about, but that word typically means a file or directory. I don't know what the installer is asking for, but you don't have to answer everything right now. If you don't know what it's asking about then just skip it and deal with everything after. Once you get it installed and started up, you can install extensions. VS Code does a few things "out of the box", but there are many things it won't and you're supposed to install extensions to support it. And there are tons of extensions. Basically, if you want PHP stuff, you open up the extensions page and type "php" and then install whatever you want. Extensions are a community project so sometimes you'll find there are multiple competing or overlapping extensions and you'll probably have to do a little research to decide which ones you want - if you don't just judge popularity by their download counts. For PHP, the main extension I use is "PHP Intelephense", so that's a good start. For MySQL, it'll depend on what all you want to be able to do, but I bet VS Code has some syntax highlighting built-in so maybe you don't have to install anything more. For Python, it looks like the "Python" extension (by Microsoft) is the main one, potentially "Python Debugger" if you want to do that, and maybe a couple more of the popular ones might be good too. Javascript support is mostly built-in so I don't know if you need any extensions for that - I don't have any and everything works as I want. Docker is... well, too complicated for you right now. Don't worry about it. Basically, it's a way of running things on your computer without having to install them alongside all your other regular software. GitHub is a code storage site: you sign up and they let you upload your code there so it doesn't all have to stay on your computer. Don't worry about that for now either.
  5. It's hard to tell from just that... It seems, at first glance, that the changes are correct: you have something that will force a www redirect but not an HTTPS redirect, but that isn't necessarily wrong. Let's pretend your site is example.com. There are four combinations of names that could work: * http://example.com - should redirect with HTTPS+www * http://www.example.com - should redirect with HTTPS * https://example.com - should redirect with www * https://www.example.com - working site Besides the menu buttons and whatever not working, when you try those four examples, do they work as stated? Does your browser always get redirected to the HTTPS+www site?
  6. Was HTTPS working on your site before it was forced?
  7. Don't overthink the procedure so much and just have it do the absolute most obvious thing: an INSERT statement.
  8. That's right, it wouldn't be - if that was what the Queens Problem actually was. But it isn't, as you missed an important restriction in the puzzle: at most one queen per diagonal. ...but the title says no 2D arrays (a trivial restriction to get around) or recursion or backtracking? If you can do recursion and backtracking then do recursion and backtracking. That's the straightforward solution. Which means you need to think about how to do recursion. Recursion is about breaking the problem down into a tiny example, solving that, and then figuring out how to take that tiny solution and expand it a little bit more. So you should be thinking like this: 1. How can I solve this for a 1x1 grid? 2. How can I take a NxN grid that is valid and place another queen in a valid position using either the N+1 row or N+1 column? You're having a hard time because you're not describing your solution in enough detail. Programming is about telling the computer how to do what you have in mind. But that means you have to have something in mind first. Don't have that and you won't be able to tell the computer anything.
  9. That procedure is wacky. Why is it trying to make a simple INSERT be so complicated? And so prone to not working? The error is telling you, in a weird way that doesn't seem very obvious, that the value you used is not valid. Which it clearly isn't.
  10. But where? How do you decide where to make each move? And how do you make sure you don't make the same set of moves in future attempts? Doesn't that count as backtracking?
  11. Pythagorean theorem? What? Describe the solution you have in mind and we'll figure out how to convert it into code.
  12. Instead of deciding on all the different sites that someone could be accessing, think about this in terms of whether or not they're accessing the site you want them to. It's much easier that way. Somewhat separately from that, RewriteRule matches on paths, not on hostnames or full URLs.
  13. Did you edit the correct file? The one mentioned by phpinfo? And you restarted? I don't think there are any DLL dependencies so that should be all you need to do...
  14. ...It's running. It's already running. You know it's running because you get the "it works" page. So what was this about trying to start it? If you're looking at Windows's services list, "Automatic" means that the service will run automatically on startup. Which is good, and means you don't have to run it yourself manually. You don't need to change that. (Suggestion: change that to Delayed, meaning it's a little lower priority, to help with better startup times.) If you have PHP basically working then mysqli is a matter of php.ini settings. Edit your php.ini (phpinfo will tell you exactly where that is), creating it if you don't have one yet, find the "extension=" area, and uncomment the extensions you want to use. Then restart Apache.
  15. Set the canonical URL as whatever page it is, so English and Spanish and German. Also make sure you're specifying the language. Then wait and see if GSC still thinks they're duplicates.
  16. It's better to paste the (relevant) code, and/or screenshots for stuff that's visual, directly into your post: most people here try to keep safe and so won't download random files from strangers on the internet. That stuff you included there is XML, and it's easy to read with PHP. But you're talking about margins and line breaks, which isn't actually PHP, though the line between what is and isn't PHP does get a little blurry sometimes. Can you give a more detailed description about what you're doing, what you've written so far, what happens when you run it, and what you were expecting it to do instead? Remembering to post code as you go, of course.
  17. An alternative to using HTML markup for the value would be to put it directly into the Javascript code. const END_TIMESTAMP_MS = <?= $whatever_end_time ?> * 1000; You need to consider the same sorts of things you would with putting values into HTML, in that you should make sure the value is safe - safe for Javascript, that is. (But since I'm assuming $whatever_end_time is a number, it's naturally safe without needing any escaping.) And tip: don't literally count down to the time, as in do things like "seconds--". Because you won't be able to get to-the-second accuracy with Javascript, and it will drift as it runs: for example, you'll find you did "seconds--" 60 times but it's actually been 61 seconds, and now the timer is off by a second. It may sound weird, but instead of counting down, recalculate how much time is left on every "tick". As in function update() { const remaining = END_TIMESTAMP_MS - Date.now(); if (remaining > 0) { // calculate hours/minutes/seconds and display } else { // count down complete } } The drift will still happen, and you'll notice that occasionally the timer will skip a second because of it, but (a) some drift is unavoidable and (b) it's probably more important that you provide an accurate timer than you provide a "smooth" count down.
  18. The server should be configured as: - en.mobirom.ro uses that /en/ directory as its root - the English URL paths do not have an "/en/" prefix, as in "/en/whatever/page.html" - they should be the same as the normal Romanian ones Doing a little checking on your site, that's not the case: the English site is also using the root directory, which means I have to go to en.mobirom.ro/en for it to work. After fixing the site to use /en/ as its root, and hopefully you can but if not then keep reading and we'll solve that problem separately, - The .htaccess for the Romanian site (/.htaccess) will only apply to mobirom.ro - The .htaccess for the English site (/en/.htaccess) should only apply to en.mobirom.ro, however: - Unless you tell Apache otherwise, mobirom.ro/en/whatever/page.html will work. This is bad for SEO and you should make sure the English site is only accessible at en.mobirom.ro. That will also mean the /en/.htaccess only gets used for the English site. - This thread is public to the internet. Please don't create debugging pages like you have now for /en/ unless you want anybody to be able to see them... Checking the REMOTE_ADDR to only allow you would solve this. So /.htaccess should look something like RewriteEngine on # # HTTP->HTTPS and WWW redirect # RewriteCond %{HTTPS} off RewriteRule ^ https://www.mobirom.ro%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !=www.mobirom.ro # you should not need these two... #RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ #RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ # you do not need this, Let's Encrypt will follow redirections # they also won't validate the SSL cert, so an expired or even self-signed cert will be okay #RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteRule ^ https://www.mobirom.ro%{REQUEST_URI} [L,R=301] # # English site redirect # RewriteRule ^en/(.*) https://en.mobirom.ro/$1 [L,R=301] # # HTML pages # RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(2)\.html$ /mese/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(6)\.html$ /scaune-curbate/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(3)\.html$ /mese-bar/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(5)\.html$ /scaune-bar/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(4)\.html$ /tabureti/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(7)\.html$ /seturi-mese-si-scaune/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(15)\.html$ /mobilier-lemn-curbat/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(9)\.html$ /masute-cafea/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(11)\.html$ /scaune-balansoar/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(13)\.html$ /mobilier-terasa/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(1)\.html$ /scaune/$1_$2_$3.html [L,R=301] And /en/.htaccess will look similar: RewriteEngine on # # HTTP->HTTPS and WWW redirects # RewriteCond %{HTTPS} off RewriteRule ^ https://en.mobirom.ro%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !=en.mobirom.ro # you should not need these two #RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ #RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ # you do not need this, Let's Encrypt will follow redirections # they also won't validate the SSL cert, so an expired or even self-signed cert will be okay #RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteRule ^ https://en.mobirom.ro%{REQUEST_URI} [L,R=301] # # HTML pages # RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(2)\.html$ /tables/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(6)\.html$ /bent-chairs/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(3)\.html$ /bar-tables/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(5)\.html$ /bar-chairs/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(4)\.html$ /stools/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(7)\.html$ /table-chair-sets/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(15)\.html$ /bent-wood-furniture/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(9)\.html$ /coffee-tables/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(11)\.html$ /rocking-chairs/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(13)\.html$ /outdoor-furniture/$1_$2_$3.html [L,R=301] RewriteRule ^([a-zA-Z0-9-]+)_(\d+)_(1)\.html$ /chairs/$1_$2_$3.html [L,R=301] Since your server looks properly configured for the two sites, you could actually use %{SERVER_NAME} in place of the hostnames, making some of this easier to copy and paste. One more thing: PHP 7.4 is really old so please upgrade if you can.
  19. What page are you talking about? Your PHP code suggests images hosted on the server, but looking around all I see are images hosted on that CDN.
  20. The message is "Could not connect to database" but I don't see that in the code you posted... So where is it coming from?
  21. .htaccess files are for people who can't modify server configuration. Can you? If you can then you should be putting stuff into the VirtualHost definitions - you'll get slightly better performance that way. And it would also solve your problem as you'd be putting the Romanian rules in the main site config and the English rules in the en subdomain site config.
  22. Yup. Which means it's not executing. Did you put this code into a file with a .php extension?
  23. You have code that is able to get their location. You need to take that location data and put it into the link at that time - you can't put it in there ahead of time. Take a look at MDN's geolocation examples for something that's actually very close to what you want to do.
×
×
  • 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.