Jump to content

gizmola

Administrators
  • Posts

    5,878
  • Joined

  • Last visited

  • Days Won

    139

Everything posted by gizmola

  1. Based on this page, the Euclidean distance function requires 2 points (p1, p2) so a function to calculate it would be something like this: function EuclideanDistance($p1x, $p1y, $p2x, $p2y) { return sqrt(pow($p1x - $p2x, 2) + pow($p1y - $p2y, 2)); }
  2. I watched most of this, and the step where doctrine is installed and configured seems to be right. You might want to try deleting the vendors directory and running another composer install.
  3. From the example data, that's what it looked like to me -- group by cust_id.
  4. There are some tools that can help you: A source scanner: https://github.com/kgoedecke/unused-css-parser A site that will analyze your pages: https://unused-css.com/ Unused-css will let you analyze one site for free up to 100 pages.
  5. Yes, or the DIRECTORY_SEPARATOR constant, which is equivalent to '/'
  6. The placement and organization of apache configuration files has no standard. Application packagers have added organization and conventions over the years. The sites-available directory is a debian thing (afaik) and went along with another directory, where the idea was that you would put a configuration file for each vhost/site you were hosting. There was also another directory (sites-enabled) where you would make a symlink to any sites-enabled conf files you wanted to actually be live, and then restart apache. Again this is the convention of that particular package maintainer, and different distros (Centos/Redhat) for example don't use it. At the end of the day, it doesn't matter where you put things, so long as you understand what directories are looked at for configuration. You could use one giant httpd.conf file if you want. The important thing is to look for those include statements, grok the various directories that are included, and any files that might be in those directories, and in general just be sure you understand where they are loaded. If you have rewrite rules that you want to include for a vhost, there is nothing wrong in sticking the in the default vhost files, if those are all you are using, but keep in mind that those files were placed there with the intention that they would be examples you would use as templates for the actual vhost files people typically have, and which are named for the domains they are meant to serve up. This is also why the sites-enabled scheme was beneficial, because it doesn't matter with that scheme if you have other unused files in sites-available.
  7. There is some information about it. I agree that step one on this is to echo out $target_file, and determine if that file exists on the file system.
  8. Depending on the way the app is written you also might be able to get away with a backwards compatability shim. I don't recommend or endorse this, but in some cases, it might be an acceptable way to avoid having to change all your mysql_ calls to mysqli_ (assuming that is all you are actually going to do, rather than actually updating the SQL statement calls and rewriting your code to utilize parameters). A "Shim" is a library that retrofits old code in some way so that newer code works, so perhaps this is not technically a shim, depending on how you look at it, but the idea is that you use a library that fills in the missing library calls (mysql_) so your existing code will still work. This would work best if you at least have your mysql connections created in include files, otherwise you will have to go through changing every script that makes a connection. If you have to make changes all over the place, you are probably better off consolidating code into includes, and changing to mysqli or PDO as others have suggested. This is a quick retrofit using a mysql backwards compatibility library. There are some things you need to do in advance. 1st you must have installed a working version of composer You need PDO installed in your PHP 2nd you need to add a composer.json, assuming you don't have one. At minimum you would update your project composer.json require section { "require": { "mattbit/mysql-compat": "^1.1" } } Use composer to generate an autoloader for you. This will be created in the {project}/vendor directory. Let's suppose you have a script in your project root that gets called. You would add code similar to this to call the autoloader, and to load the compatibility library. require __DIR__ . '/vendor/autoload.php'; Mattbit\MysqlCompat\Mysql::defineGlobals(); This will add the shims for the old mysql_ code, and if all goes as planned, your existing code will work unaltered. Again, I'm not recommending this, but it if's an old site that you have no plans to update, and just want to keep it working as is, this does work, and doesn't require you to go find all your mysql_ calls and change them.
  9. One traditional way to get around this issue is to use Expect. Expect is one of the first automation languages I am aware of and is great for handling user input prompts that come from utility programs that might be used in a shell script. It's been around for a long time and there is a version for both for linux and windows. Are you using windows btw? All the system and process functions are closely tied to the OS you are using.
  10. You just need to use the Ubuntu package installers inside the shell in your ubuntu vm, which in your case is probably something like this to get both packages: sudo apt-get update && sudo apt-get install libsodium-dev; sudo pecl install -f libsodium sudo apt install php-cas You are going to need to stop/start php-fpm & apache after you installed the packages. Do checks with php -i and phpinf() and make sure that the packages are being seen by by command line php and php in apache.
  11. Functionally, it is true that you could use a string or a timestamp to store your times. You should use a timestamp. It works better from a database standpoint, since you can do queries to find timestamps <>= NOW() or some arbitrary time. Also a timestamp takes 4 bytes, whereas a varchar takes as many bytes per row as needed to store the string one for each character, so -- 'mm-dd-yyyy hh:mm:ss' 19 bytes vs. 4 per row? String comparisons are done character by character, which might not work the way you expect, whereas mysql datetime/timestamp types work exactly as you would expect. In your case you would not need to pass anything into the query -- just determine the offset interval you want and encode that into the static query.
  12. It's really important to have a scheme like the one requinix is suggesting. Let's consider it this way (without the rewriting) #home page. You can make this the default page by routing to home if there is no route parameter index.php?route=home #rewrite route /home #contact page index.php?route=contact #rewrite route /contact #faq index.php?route=faq #rewrite route /faq #faq item #3 index.php?route=faq&item=3 #rewrite route /faq/3 #acme customer store page list of items index.php?route=shop&customer=acme #rewrite route /shop/acme #individual item #14 page in acme store index.php?route=shop&customer=acme&item=14 #rewrite route /shop/acme/14
  13. This SO thread covers a lot of the probable issues with getting phpMyAdmin running and accessing it including: Did you start the MySQL server? Did you configure phpMyAdmin to access the MySQL server? What url should phpmyadmin be at?
  14. Provide an example of what you mean by that, and how you plan to use it.
  15. Here's a really good article about this issue (and other related ones you might not have though about either: https://www.danielmorell.com/guides/htaccess-seo/redirects/https-www-and-trailing-slash For example another related problem: https://www.mysite.com/foo/bar and https://www.mysite.com/foo/bar/ Will be seen as 2 different urls, so you want to effectively remove the trailing slash when you are routing a non-directory.
  16. This is a self fulfilling prophecy of failure. First off, you don't need to be an OOP expert to use classes and objects. With all the time you've spent here explaining to everyone why you can't or won't take their advice, you could have already watched the video, and learned a few things about modern PHP. Consider this my white flag. I give up. 🏳️
  17. I'm not familiar with this protocol. Are there other details (authentication or encryption for example) that might explain your result?
  18. This is not a teacher - student situation. As it happens, I have a good friend who is a college professor, as is his wife, and we talk about his classes and students fairly regularly. I know from his point of view, having standards that students have to meet is very much part of the job. There are assignments and tests. None of this is part of our discourse. In general, one of the most important elements of a community like this is the exposure to new ideas, technologies and methodologies, as well as exposure to a consensus on a baseline of competency. Your replies frequently seem to me to have elements of both FUD and NIH. I'm guessing you are familiar with both acronyms. I understand that you are concerned about what you don't know, and are unsure in regards to your ability to learn things that are new to you in the short and long term, but these topics did not come up by happenstance. You posted questions soliciting feedback, which is what you've received. In all the replies and feedback, I don't know if there's an instance where someone gave you an answer or opinion you've agreed with, that wasn't yours to begin with. It feels to me like an echo chamber, where you only want people to tell you that you were right from the get go. You seem to want to reduce this to a matter of opinion amongst equals, when that just isn't the case. I've done system architecture and engineering for my entire career. I know what's important, and I've tried to help you understand what that is, in dribs and drabs. I could at this point make a nice list of all the things you've disregarded, along with various excuses for why you know better than me what you need right now. At the end of the day, if we listed the requirements for what you want, what you've already built and how they can be integrated, sans a serious discussion of whether your requirements are sane or logical, or even prioritized correctly, there's a best practices way to build something new, and there's a way to make spaghetti, that will likely be a costly bug ridden failure. What the experienced practitioners here all know, is that doing it the right way isn't more difficult, nor does it take longer. Quite the contrary in fact. Doing it the right way produces a better product in less time because it's based on the assembly of pre-built and tested pieces, that more often than not have documentation and support. Again, I do this to try and help others, as do the other respondents who frequent this site. Some percentage of people find what they are looking for and some percentage do not. Most of us have been participating in this forum for many years. We've seen every type of question and questioner there is at this point. You might want to consider that when you question the relevance or urgency of the advice you've received.
  19. Did you look at the links I provided? There's not much more to it. Pack will let you pack the bytes into a binary string. You make the socket connection and fwrite the packed string to it.
  20. The comments and concerns expressed in that SO question are in no way applicable to what you are talking about doing. You might also note that the author of the comment, never demonstrates the supposed danger or where the section you quoted in any way matters. The most comical thing about it, is that there is no semi-truck table. The original requirement was completely lost. The ultimate model added to the original question does nothing other than to add tables only relevant to the car tree hierarchy. Adding a unique index and referencing that as a foreign key only matters in that scenario because there is a cars table where lots of different car subtypes could go. Are you implementing a hierarchy with multiple subclasses and sub-subclasses? No you aren't. Did you look at the other answer from Walter Mitty? It literally calls out the solution I provided you with the tag shared-primary-key I made you a model and generated the DDL. You could have run it in a test db and played with it, and created a few queries. Could you create a row in a subtype table for the wrong product type? Yes. But considering the missing semi-truck table, the same issue existed in the non-solution presented and accepted in the question you referenced. The main focus of the solution was the hierarchy of car types, which again isn't relevant to your product subtypes. It's not a concern for you because the procedural code you need to write, which uses the product_type attribute to determine which child table the subtype row needs to be created in, must do that properly for your system to work. If it doesn't do that properly 100% of the time, then your system doesn't work at all, and we are talking very simple logic. If you are super paranoid, then a simple trigger could be written to prevent it happening in any of the child tables. You could also, as an alternative, write a trigger to create the row in the correct subtype table, when you insert the product row. Ordinarily I am not a big fan of MySQL triggers or sprocs, as they reduce concurrency and insert performance, but your system will not have a lot of insert/update activity against the tables in question, and will primarily be selecting the data, so it's worth considering.
  21. Aside from the things Requinix listed, another thing that influences spam scoring is having a valid reverse DNS. Here's a list of some services you can use to check your rep: https://sendgrid.com/blog/5-ways-check-sending-reputation/. You also have to make sure your domain and your MTA IP is not on a RBL. The reality is that sending email from a Shared server is only as reliable as the worst client they have had on the server, or your ISP, depending on how email works for you with your hosting company. The other issue is that some systems may consider your emails to be spammy. Most analysis works on a scoring system, so if your emails are getting rejected outright as spam, that tells you something. Throttling isn't going to help you improve your score, and depending on the server you are communicating with, getting help with finding out how and why you are being rejected may be next to impossible for you. This is another reason to use a commercial email delivery company, since it's their business to insure delivery of client emails, and they have paid staff to correspond with sysadmins of major email systems.
  22. Yes. Take a look at stream_socket_client and pack. I don't think this type of application is PHP's forte, but it is possible. Creating an executable with c, c++ or Go would be a simpler final product upon completion, but PHP is certainly capable.
  23. You have Xampp, so you do have a database. The 'M' in Xamp stands for MySQL database. You can use the phpMyAdmin that is installed with your Xamp to create the tables. Again, you have to learn something about MySQL and the SQL queries, but as they will be very simple as far as SQL goes, that should not be a problem. Let's assume you name your table Medialist... All you will need is: SELECT * FROM Medialist INSERT INTO Medialist (columns..) VALUES (?, ?, ?...) DELETE FROM Medialist where id = ? UPDATE Medialist set column = ? where id = ? The basics of doing this is covered in the tutorial video I linked. My suggestion to you is to follow along and create the application with the tutorial. Doing so will teach you 95% of what you need. Then use what you have learned to create your app. Once you have most of it working, it will be feasible for people here to help you with the last 5%
  24. Here's what you want: header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0 "); // Proxies. Major Stackoverflow discussion of this topic. Keep in mind that if you are using sessions, PHP session configuration can screw with your cache control settings: Read about session-cache-limiter.
×
×
  • 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.