Jump to content

gizmola

Administrators
  • Posts

    5,878
  • Joined

  • Last visited

  • Days Won

    139

Everything posted by gizmola

  1. I don't know what you found on SO, but it's unrelated to the intl extension. What operating system are you running? What version of php? How is your development environment configured? Are you using Docker? Note: The library you are trying to use states that it is "depreciated" (sic). It was also forked by the originator to a different repo, with the intention of passing it on to other maintainers. Since you are using Laravel, this one might be a better fit for your project: https://github.com/TechTailor/Laravel-Binance-Api It states it is still in alpha, but depending on what you intend to do it might be a better fit for you.
  2. I don't disagree with requinix's advice here, as you need to be aware of what breaking changes are, but there are some popular tools that can help you understand the quality and inherent issues in your code. In general, one category of these tools is "static analysis" which evaluate your source files and report on a variety of problems or things that violate best practices or a particular coding standard. There are a number of these tools, with one of the most popular currently, being phpstan. Depending on what editor you use, there may be a phpstan integration available that helps with evaluating and fixing problems it finds. There's also a nice article, albeit a bit old now, about php8 migration with a lot of good information I would encourage you to check out: https://haydenjames.io/php-8-compatibility-check-and-performance-tips/
  3. There is nothing in the spamassassin daemon api that is designed for spam marking. As far as I know what you need to do with spamassassin is run sa-learn to train it: https://geekthis.net/post/spamassassin-training/ Notice that it is just as important to have the "ham" as it is to have the "spam". So in general, you want to get your box in a state, where you have marked the spam, and then run sa-train on those boxes. In general, marking something as spam in a client is basically for the purposes of moving it to a spam folder that has a retention limit on it that will automatically delete the spam emails when the email gets to a particular age. Of course in doing so, based on your configuration you can then use that as the basis for running sa-learn, perhaps as a cron job. FWIW large emails sites can't trust the userbase to train their systems, and there is also mail filtering that goes on to knock down a lot of spam before it ever gets to the point of being in the mail system.
  4. I think that requinix gave you some very good abstract advice. Stepping back from this, a big part of your conundrum, without a doubt, was the choice to create a real estate portfolio management application in Drupal, where Drupal is not providing you the vast majority of value. Drupal is a CMS, and its value proposition is based upon people that have a variety of media (text, images, video, documents) they want to categorize and organize (taxonomy) for the purposes of publishing information in a variety of ways. I have no idea why Drupal was chosen in this circumstance. It's no different than when people start with wordpress, then build out a whole custom, because the system will have a blog page. Either symfony or laravel would have been a much more appropriate starting point in my opinion. While it sounds like it's far too late to change course for you, that doesn't mean that recognition of the disconnect isn't worth recognition, because you can sometimes look at the gap, and build in thing to fill the gap using models from frameworks and perhaps orm's like Doctrine. I saw this portion of your original post" So starting with getTentantsByUnit, if you were working with a standard MVC framework like symfony, it's clear using doctrine that this the type of thing that you would have in a Doctrine "Repository" class. Essentially, a repository class is associated with a "model" (aka a class associated with a database table) that can be used to make queries against that model. One of the values of an orm is also that you are able to define the underlying relationships between models (which again map to tables) and get certain built in behaviors when querying, like in this case, querying for a unit and getting all the related tenant rows in the result. The name says to me, that this is a function that should be in a class associated with the "Unit" table/model. Doctrine implements the "Data mapper" pattern, as opposed to the "Active Record" pattern implemented by many other frameworks most notably for php, by laravel eloquent, or famously by Ruby on Rails. I personally prefer the Data Mapper pattern, and the key thing to recognize is that these are "patterns" and even though you aren't using an ORM, doesn't mean you can't implement your own version of these patterns. As an example, I worked for a consumer service company that had a large legacy laravel code base, and even though they started with Laravel, over time, developers had essentially added classes to implement the "Repository" pattern on top of Eloquent. "recordActivity" sounds more to me like a "service" that you would create. One of the major engineering decisions of Drupal, was when they rebuilt it using the symfony components as a starting point, so that it would be a dependency injection framework, and support integration and extensibility with php components. This means that you can "wire" and/or configure your own services and use them in your application. Perhaps you already know this, so please excuse this digression if you do. Here's a quick pointer to some discussion of that: https://www.drupal.org/docs/drupal-apis/services-and-dependency-injection/structure-of-a-service-file So the idea behind this is that you use interfaces to describe your core dependency objects (things for database manipulation, mailers, logging etc.) and if you need that service, the DI container is able to instantiate the service at runtime, and you will be able to use it, taking advantage of configuration, lazy loading etc. rather than having to do all the setup work yourself. This is another reason why you want to separate things into appropriate classes, since you are using Drupal and Drupal is now a Dependency injection framework at its core. To do all this you want logical organization of classes using dependency injection principles, and you want to use interfaces where appropriate, or at the very least, typing of classes that will be inject into other classes or services as dependencies. You also mentioned traits, and traits should by used sparingly and only when you 100% understand and can justify why you need them. Typically this is to merge code into a class that is highly generic across a lot of classes. The classic example of this, is having a code base, where you generically want some logging capabilities. Since PHP is a single inheritance model, that is the way to go. Just a throw away thought for you, but lately there's been a lot of talk by PHP developers about declaring most of your top level class methods as "final", and in many cases the class itself as final, so that it won't be used in inheritance when that ends up being a kludge. I'd throw in that practice. Here's a nice blog post by a symfony/doctrine core developer who has written a huge amount of code for those projects on the practice: https://ocramius.github.io/blog/when-to-declare-classes-final/
  5. Assuming you are able to pinpoint the point at which the object is created and you have a variable assigned to it to work with: // Use object attribute access syntax echo $obj->data->ip;
  6. I believe it was meant as a colorful reply. Requinix is saying that things will "explode". What I believe will happen is that auto_increment will not work the way you expect. Rather than start at 1, the first allocated auto_increment value will be the largest id that exists, plus 1. So the first new inserted value in the table will have id 31. There won't be an error, so I guess the main question is whether or not you actually care about the loss of available key values. BTW, a similar issue exists with tables you might truncate or delete all values from. That does not by itself reset the auto_increment value. You can however, use a mysql/mariadb specific sql statement on the table to reset the auto_increment counter back to 1 ALTER TABLE tablename AUTO_INCREMENT = 1 This however would not work with Innodb tables (which is what you should always be using with mysql) as the auto_increment counter can never be set below the highest available one that exists.
  7. Yes, storing a path is the way to go, but you also need good reliable routines for maintaining the images. Typically, you need a table that stores: the "stored" filename When you move the uploaded file, you should change the name to something you use internally via a sha1 hash. this insures that you won't have name collisions from users uploading a file with the same name it protects you against named based exploits The original name when the image was submitted You can use this if you allow users to download the file as the original name it was uploaded as The mimetype (not strictly required, but a best practice in many cases) The path to the image file
  8. He meant, did you try adding more parameters to the array. You have a basic misunderstanding of the manual: https://www.php.net/manual/en/function.sqlsrv-query.php "params" is an array of arrays, where each array element represents one, in, out or in/out parameter. Your code seems to imply that you think there are separate arrays for input and output. That is not the case. There is only one array, and you need a child array for each parameter (in order of declaration for the sproc). Since you did not provide us the source of the sproc, we don't know how it is defined. Just trying to intuit what you are doing from your sample code, this looks more likely to work: $params = array( array($myPMSource, SQLSRV_PARAM_IN), array($period, SQLSRV_PARAM_IN), array($myDB, SQLSRV_PARAM_INOUT), array($myCLSource, SQLSRV_PARAM_INOUT) ); This style requires that the sql server driver assume the php and mssql server data types from a preset of the variables, but there are optional parameters (3 and 4) that can be used with constants documented on the query page, you could pass to explicitly tell the driver what is expected, within each single parameter array. I haven't done any PHP with mssql in a long time, but it is possible that for any output variables you may need to pass those by reference. That at least is what the current microsoft documentation shows. So you might need something like this: $params = array( array($myPMSource, SQLSRV_PARAM_IN), array($period, SQLSRV_PARAM_IN), array(&$myDB, SQLSRV_PARAM_INOUT), array(&$myCLSource, SQLSRV_PARAM_INOUT) ); Last but not least, mssql does have a PDO driver, and that might be simpler and easier to use, as you would simply bind each parameter prior to the call. See: https://learn.microsoft.com/en-us/sql/connect/php/pdo-sqlsrv-driver-reference?view=sql-server-ver16
  9. Hope your studies are going well flap. Web development is a huge area of study, with a lot of interdependent technologies and complexity. If you want to do development with PHP, then you should focus on the front end things you need (html, css, js) and a backend technology (php or python or nodejs or ruby or... ) + mvc framework. Typically any backend application needs a way to persist and organize data, so that often leads into SQL and relational databases, or possibly a document database or some other alternative. That is a substantial and highly valuable area of study in itself, separate from a server side language. It tends to be that, for example, a good understanding of relational database design and SQL is a skill that is applicable across backend languages. Each has one or more client library implementations that allow you to interact with the database, but all of them work from the same set of fundamentals, and it's only the specific language syntax that is different. When you are proficient in building apps, then it's great to become a polyglot. From a computer science student point of view, I would recommend that rather than go from, let's say, learning PHP to learning Python, a student is far better off learning C. From that point, learn whatever you want. Many languages are either object oriented or have an object oriented layer/extension to the language. PHP is no different and has added many oop features in the last 10 years, most of them aimed at framework developers and professionals who want to implement OOP design patterns in their PHP applications. So this is one other area of complexity. From a front-end standpoint css frameworks like bootstrap or materialUI and Tailwind have proliferated. Javascript frameworks like react and Vue are being employed to create interactive web UI. Your time would be best spent figuring out a stack of tech that works for you, and creating apps with that stack.
  10. I have not looked through all the code, but to begin with, no you can not store image data (binary data) in a varchar field. FIrst of all, varchar fields have a fixed maximum length (64k), but they also are limited to characters and a character set. The data for an image is a byte stream of values, so you must use a blob field to store raw image data. There is a way to "encode" binary data in a format that transforms it into a text version, and in fact this format (base64) is built into browsers, such that it is possible to include in an html page an "inline image", and this format is base64. Here is an example of that (which is the mysql logo as a jpg image): <img src=" data:image/jpeg; data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQ gFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQM EBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB QUFBQUFBQUFBT/wAARCAAuADUDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAw QFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS 0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXq DhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6er x8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBA cFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygp KjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoq OkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMB AAIRAxEAPwD9EKKKKACq+oXyadZy3Eiu6xjO2NdzHnAA/HueB1JAqxTZI1mjZHUOjDaysMgg9QafqIzrH xHY30yweabe6LFPs1ypik3AZIAP3uOcrkEcgkc1p1i2ul2+p6XNYX0f2uKNjBlySGCn5WHOQwBHzDB3DO eBTPD9xcWd5daNeztdS26rLb3Eh+eWBiQN3q6kFSe42seWIFuK1sQpPS5u0UUVmaBRXj/wn+Iuoroesz eKtQF20enx+I7eXaoK2MqufLwoGSjRODx/EtHgf4haz4d0fxBJ4zklvLmz1q2tpTCqAWaXSQMgPTKRtMA TyeCea6Xh5ptdjkjiYNRff8PU9gorlNf8YTx3Wv6RpFnNc6xp+mJfK2wNGWkMiogGclv3THGOmPWq+l67 a6f4Z1PW7fXLrXYreB5XhuTGCkigkqQqBkPbaeB6V4mIx1PDV/Y1F9nmb02187vbWydtL7o9mhhJ4il7W D+1y213/JeV99exsxaPfQ+IPti33/EvSN0WyUYDtI4Z3f1ZSo246BnBzkEL4ksU8uPVBdS2U+nK8omijMuY 8ZdGQDLqdoOBzlVxzXN6o2t+HfDqeIpdYmu7qERz3diyILZ4yRvRBt3KQCdrZJJAznNbmh6jc3XirxFbyTNJ bW/2byIyBhN0ZLY78n1rGlm0Z1oUZ03GUrWTts4zkno3/JJNb38tTSplrjSlUhNSir9904prVL+ZNdLeZo6H qbatp6XLRGNW+4/G2VcAiReSQpB6HkfqSrNpY29grrbQpAjuZGWNdoLHknA7k8n1NFey7X0PMV7ank M/wh1e40b4eWyvDC1jZJpWuxswbzrPEbvGDj5vnhVOO0jH1zqa54Nj874nya/c2un6Br9tAkV3NMq7Ct syOxzjbtIUj6Zr1Gq19ptnqiRpeWsF2kciyos8YcI46MMjgjsa6Pbyb1/rW5y/V4Jaf1pY8/8AhDb6xdeGb3x XqVkkev6+Ibj7LK5jCRRxLHErHBK7gGkxjIMpBHFX5vCd34m1e/u7ywi0SK506awl8uVZZbgvtw77RjCYO OSfm7V3VFeRjsHTzCadZvlX2dLeWtub7mvPqerg8TPAwapL3v5tb+fW33p+XQ891qPxBeeGYtI1PSc248 qK+vLGXzjJEpBYxxYDEsFxjGV3cbsVqx2usaT4t1a6t9MS9s79rfEouVjMYRArHaRz1J/CutorzllCU1U9tLm VrP3brlUlb4bNWm91e7vc73mTcHD2UbO9171ndxd973vFdbeQyNnZnDoFAPBBzkUU+iveSsrXPHep/9 k= " alt="MySQL" /> So, it would be technically possible to base64 encode the raw image data, and store it in a text type field, then either include it in an inline tag or decode it from base64 after it's fetched and return that data. I'm not going to go into the many issues and reasons that for most people this would be a bad idea, but since you asked, I presented the technical background. I don't know what your reasoning is behind wanting to try and store image data in your database as something other than as a blob. I would suggest you explain your reasoning, and the desire to make this type of change, so people can provide you some usable feedback and suggestions.
  11. I went through and tried to clean up/make sense of the OP's posts, and lack of experience with the forum tools. To @prosperchild Start with your description text etc. in the editor window Don't write up everything in another editor and try and paste it all into a code snippet When it is time to put a snippet into the post Use the code snippet button: <> Paste the code snippet into that window, set language appropriately to reflect the language DO: use one or more snippets for each file you are trying to get help with DON'T: paste the code from a bunch of different source files/multiple languages into one snippet. Use different code Snippets for each portion of the code Example: "Hey, this code has a bug, around line xyz that says: blah blah blah. I am not sure how to fix this" /Index.html Use <> Code snippet button here <html> <header> </header> <body> </body> </html> sources/code.php Use <> Code snippet button again here <?php phpinfo(); die('What is going on?');
  12. We need more information. First off, you probably can't change a lot of these setting using ini_set if you are using mod_php. Many distributions have a scheme of ini files that will separate the cli settings from the settings applied to the web server. Provide us the output from a page that only has this in it: <?php phpinfo(); Last but not least, when you change any php.ini settings you need to restart either apache or php_fpm (depending on your setup and which you are using). post_max_size is certainly in this list of things that can not be changed on a script by script basis. The phpinfo() has important information about the runtime settings, starting with the location of any ini files read. You may be surprised to find that the file you have been changing is not the one actually being read. It will also show you the actual runtime values, so you can verify any settings.
  13. The other obvious problem with your code is that it appears to be based on a database query result set, but you didn't include that in your code, nor is there a "foreach" loop over the result set building up the csv file with the results. So while you may or may not need the csv header row, your code as presented has no hope of actually working, without the availability of the data in a $row variable that is fetched from the result set in a loop. Another issue you need to be aware of is that strings should always be delimited with double quotes around them. So you need to be cognizant of which columns are strings, and also you need to make sure that any embedded double quotes are escaped. So for example, these lines are improper: $output .= $productTitle . ","; $output .= 'Visit our website for more info.' . ","; That needs to be this: $output .= $productTitle . ","; $output .= '"Visit our website for more info."' . ","; These problems are already solved for you in the function requinix linked you to.
  14. Well the first thing I typically would do in a situation like yours is to do some googling for something like "php revolut api". I will then look to see if there are any libraries available, where someone has already put in the time and effort to understand what is needed. I found what looks to be a relatively up to date project that you should look into: https://github.com/sverraest/revolut-php There are other things you should do like searching packagist using "revolut" (notice the double quotes to eliminate partial matches).
  15. Don't confuse sum and count. It works here, but the two functions are very different. Highly recommend you not get used to substituting sum for count as if they are interchangeable. I also always alias computed columns so I can predict what the column name will be when fetched. SELECT rating, count(*) AS count_of FROM reviews GROUP BY rating Now I heartily agree with @requinix that a simple class or function is best here. There is no way for the database to know the available universe of values with a scheme like this, which might facilitate an outer join solution to your problem. With that said, here is a SQL solution that makes a number of assumptions that might not be directly applicable to your database structure, but at least illustrates the idea. I don't think this is a good solution for a number of reasons, including the fact, that you have to hardwire the ratings into your SQL statement AND you are doing a distinct query to figure out which values you need to exclude. There might be a better way to accomplish this (maybe @Barand has something better? This does work, and I provided everything you would need to verify in a test database. create table reviews (id int unsigned PRIMARY KEY AUTO_INCREMENT, rating int); insert into reviews(rating) values (5), (5), (2), (3), (1), (3), (2), (5), (1); SELECT * FROM (SELECT * FROM (SELECT 1 as rating, 0 as count_of union SELECT 2 as rating, 0 as count_of union SELECT 3 as rating, 0 as count_of union SELECT 4 as rating, 0 as count_of union SELECT 5 as rating, 0 as count_of) as t1 WHERE t1.rating NOT IN (SELECT distinct(rating) as rating FROM reviews) union select rating, count(*) as count_of FROM reviews GROUP BY rating ) as u1 ORDER BY rating ASC; With this test data you get your desired result: rating count_of 1 2 2 2 3 2 4 0 5 3 Just to reiterate, a php function using range to pre-populate an array you then use to merge with your result, would be a great way to handle this in your PHP code, and that's what I would do here rather than utilize the convoluted solution I demonstrate here.
  16. I just checked in on this now. The function I pulled is part of a utility class, and not a standalone function, so it was scoped. I'm glad you got that figured out. Learning a bit about PHP Object Oriented Programming would be a great next step for you. The main thing I wanted to contribute was the best way to store IP addresses, and it appears you've implemented that successfully.
  17. I'm guessing something like this might work for you (assuming you have a reverse proxy or load balancer). protected function getClientIP() { // This assumes a classic AWS Load Balancer is proxying if (filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && !filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { $ip = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); return $ip[0]; } else { return $_SERVER['REMOTE_ADDR']; } }
  18. In general, the less information you provide the better. The message should simply say something like "Too Many Requests" and shouldn't disclose that you are banning things by IP, or what the IP actually is. Don't provide information to bad actors that helps them work around your system. One other thing about apc: it's memory on a specific server, so if you ever have load balancing in place, these stats are going to be spread out across servers. It's also fairly standard to store bad attempts against a particular username, and perform an account lockout if a particular bad password attempt threshold is reached.
  19. No. If it's linux you can do something like this with mount: <?php exec('mount', $output, $result); if ($result == 0) { echo "<pre>"; var_dump($output); echo "</pre>"; } else { echo "Failed with result: $result<br>"; } If that works, I leave the parsing of filesystem from the output to you. You'd also have to determine which filesystem is relevant perhaps using getcwd or realpath(__FILE__)
  20. I would do what @ginerjm suggested and make this script a self posting form. Wrap the html form elements in a standard form tag of type post. Get your variables from $_POST and not $_GET. Otherwise it should work in similar fashion. Your markup as presented is very messed up. You have an entire body inside the head tag, and then you try and create another html document for your output. You can't do that. You only should have one html/head/body tag. Another problem with your current code, is that php runs "serverside" and not "clientside". You can not intermix php and javascript this way (as you did in the snippet I quoted). The javascript code is delivered statically to the client when the page is requested. If you use the chrome debug tools for example, you should see that your javascript function is invalid. When people want dynamic data, they use ajax, which is a level of complexity higher, so to keep your project simple, just use the standard html form, which will post back to the php script on submit, do the calculation (serverside in your php script) and re-render your output. For simplicity, I've just shown a simple div/pre as you already are trying to echo out variables for debugging purposes. Notice that I moved your blocks around, with your functions at the start of the script. Functions are typically included prior to your logic, and it makes the flow of control clearer when you are intermixing html and php in this way. Something similar to this should work (I editted your code, but don't guarantee that there are no errors). <?php // Function to get the closest value of dcu to the calculated one function closestValueTo($calculated_dcu, $db_file) { $db = new SQLite3($db_file); $query = "SELECT dcu FROM table ORDER BY ABS(dcu - $calculated_dcu) LIMIT 1"; $results = $db->query($query); if($results){ $row = $results->fetchArray(); return $row['dcu']; } else { return null; } } // Function to get a specific value from the database function getValueFromDB($dcu, $db_file, $column) { $db = new SQLite3($db_file); $query = "SELECT $column FROM table WHERE dcu = '$dcu'"; $results = $db->query($query); if($results){ $row = $results->fetchArray(); return $row[$column]; } else { return null; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Calculator electromagnet</title> </head> <body> <form method="post"> <div class="ele-calculator"> <a href="https://imgbb.com/"><img src="https://i.ibb.co/hZLHzMG/download.png" alt="download" border="0" /></a> <h2>Calculator electromagnet</h2> <section> <fieldset> <div class="row"> <label for="ele-raport">Raportul h/(d2-d1)</label> <select id="ele-raport" class="ele-raport" name="ele-raport"> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </div> <div class="row ele-inductie-row"> <label for="Inductia">Inductia (T)</label> <input type="text" id="ele-inductie" class="ele-inductie" name="ele-inductie" size="2" maxlength="10" value="" /> </div> <div class="row ele-forta-row"> <label for="ele-forta">Forta (N)</label> <input type="text" id="ele-forta" class="ele-forta" name="ele-forta" size="2" maxlength="10" value="" /> </div> <div class="row"> <label for="ele-intrefier">Intrefierul (mm)</label> <input type="text" id="ele-intrefier" class="ele-intrefier" name="ele-intrefier" size="2" maxlength="10" value="" /> </div> <div class="row last"> <input type="submit" id="ele-calc" class="ele-calc" name="ele-calc" value="Calculeaza" /> </div> </fieldset> </section> </div> </form> <?php if(isset($_POST['ele-calc'])){ $Forta = $_POST['ele-forta']; // value for Forta $Inductia = $_POST['ele-inductie']; // value for Inductia $Intrefierul = $_POST['ele-intrefier']; // value for Intrefierul $mSelect = $_POST['ele-raport']; if ($mSelect === '3') { $raport = 3; } if ($mSelect === '4') { $raport = 4; } if ($mSelect === '5') { $raport = 5; } // Equation A1 $A1 = (2* 1.257*pow(10,-6)*$Forta)/pow($Inductia, 2); // Equation d1 $d1 = sqrt((4*$A1)/3.14); // Equation A1 (repeated) $A1 = (pow($d1, 2)* 3.14)/4; // Equation F1 $F1 = ($A1*pow($Inductia, 2))/ (2* 1.257*pow(10,-6)); // Equation Sol $Sol = ($Inductia * $Intrefierul) / ( 0.7 * 1.257*pow(10,-6)); // Equation h $h = pow (((5* 2.115 * pow (10, -8) * pow ($Sol, 2) * 0.5)/(2*4*40/100* 40), 1/3)); // Equation d2 $d2 = $h/$raport – $d1; // Equation d3 $d3 = sqrt((pow($d1, 2)/0.8 + pow($d2,2))); // Equation g $g = $d2 – $d1; // Equation dcu $dcu = sqrt((4* 2.115 * pow (10, -8) * ($d1 + $d2) * $Sol)/ 24); // Compare DCU with values from a .db file $dcuiz = closestValueTo($dcu, 'sarma.db'); // Get dcuiz from database $dcuiz = getValueFromDB($dcuiz, 'sarma.db', 'dcuiz'); // Equation Nst $Nst = $h/$dcuiz; // Equation N $N = (4*40/100 * $g* $h)/ 3.14 * pow($dcu); echo "<div><pre>"; echo "d1: " . $d1 . "<br>"; echo "d2: " . $d2 . "<br>"; echo "d3: " . $d3 . "<br>"; echo "g: " . $g . "<br>"; echo "h: " . $h . "<br>"; echo "N: " . $N . "<br>"; echo "</pre></div>"; } ?> </body> </html>
  21. The way to do this in mysql is to store the address in a varbinary(16). This is because the IP address is a number, and the formatting is simply to make the IP scheme understandable. MySQL has specific functions for converting an ip address to and from this format, and handles the issue of whether the IP address is in v4 or v6 format. Use the v6 functions as they handle both v4 and v6 ip addresses. inet6-aton inet6-ntoa
  22. My experience is with larger Hosting companies, using VPS servers. What is right for you depends a lot on what you are doing with your server. What does the server do for you? Is it a business, and if so what market(s) does it serve? The location of the server is important to any decision you make. I have experience with all 4 of these services and can recommend them for someone who is not based in the US. Amazon Web Services (AWS) Microsoft Azure Linode Vultr All of these services have a presence that should be suitable for you in Israel, although you might need to experiment. With a VPS provider, you can easily create VPS server, and experiment with it, and shut it down if you don't feel it's providing the performance you want, given your location. AWS in particular is soon to open a Tel Aviv "Region" which means one or more data centers located in that city.
  23. I had to maintain and enhance a React app a few years ago, and I also found it bothersome in many ways. I'm sure having to get up to speed on someone else's convoluted code, while at the same time learning something that was in transition at the time, didn't help my level of enjoyment, but I left feeling like there had to be something better. I also have found Vue more to my liking. I still have a ways to go to get to the point where I would reach for it as my first preference for UI, but I'm fairly confident that I'm not going back to React unless I have a significant incentive to do so.
  24. How did you think you were going to install the pecl imagick package with no php or pecl? 🤣 As requinix advised, stop now before you really screw up your machine. This is not good debugging. Instead of trying to figure out what the issue was using yum, you just pivot to trying something else entirely, when your entire server is based on and dependent on packages. Did you search for the name of the php packages with remi active? Remi has a page on this, that I'm guessing you haven't looked at: https://blog.remirepo.net/post/2022/02/07/Install-PHP-8.1-on-Fedora-RHEL-CentOS-Alma-Rocky-or-other-clone
  25. Don't use include. Use require_once(). The fact that you are having these issues speaks to lack of structure in the code you are writing, and the high probability that using MVC with a front controller would be advisable.
×
×
  • 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.