Jump to content

kicken

Gurus
  • Posts

    4,694
  • Joined

  • Last visited

  • Days Won

    177

kicken last won the day on January 14

kicken had the most liked content!

3 Followers

About kicken

Contact Methods

  • Website URL
    http://aoeex.com/

Profile Information

  • Gender
    Male
  • Location
    Bonita, FL
  • Age
    36

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

kicken's Achievements

Prolific Member

Prolific Member (5/5)

734

Reputation

165

Community Answers

  1. Formatting values should always be a last-step operation. You want to structure your code so the prices remain as numbers and you can do whatever operations on them you need to do, then only format them right before you display them, for example directly in your template if possible. $price1 = 30; $price2 = 74.99; $bundle = $price1 + $price2; //...anything else //When everything is done and you're ready to display echo getMoneyUSD($price1); echo getMoneyUSD($price2); echo getMoneyUSD($price3); Also, you should know that floating point math can lead to issues due to lack of precision. A common way to avoid these issues is to work with your prices as integers (ie, number of cents) then convert them to decimals as part of the formatting process. Alternatively, you could find a library for dealing with currency values that handles such issues for you.
  2. If it works in the browser, but not in the command line then you probably have different configurations for the two environments. Your system may have multiple php.ini files, one that's used for web stuff and another used for CLI scripts. The output of the phpinfo() function will tell you where the INI file being parsed is. In the php.ini output you provided, you can see all the lines being with ; which means they are all commented out and not active. Try removing the leading ; from the oci lines to enable the extension. The effect should be immediate for CLI, but may need you to restart the webserver or fpm server for webpages.
  3. They need to go somewhere, unless you want to be manually entering them every time the system boots. The config files can have their permissions set so only root is able read them. If you're worried about someone else with root access reading the files, then your problem isn't "how to secure the environment variables?", it's "why does someone you don't trust have root access?". The other common solution is to not make them true environment variables at all and put them in a .env file in your application directory. Make that file readable only by the application's user and use something like symfony/dotenv to load it and access the variables using $_ENV. I do a mix of both in my applications which are based on the Symfony framework. I have SYMFONY_ENV=prod set as an environment variable in the server configuration to ensure it's running in production mode, then a .env.local file in the application directory that has all the secrets for the application.
  4. The FPM workers run in a clean environment via systemd. Setting clear_env in the pool configuration doesn't change that. You will need to either set the variables as part of the service definition in systemd or through the web server so they get passed to the fpm process. For example, if using apache add SetEnv YOUR_VAR the_value to your site configuration. Or set them in your pool configuration explicity with env[YOUR_VAR]=the_value
  5. kicken

    Greetings!

    Greetings, Laravel is popular, but I also find Symfony to be better. A lot of stuff (including Laravel) uses Symfony components under the hood so it's good to know it as well. Symfony uses Twig by default for it's templates. Twig has a lot of features, but at it's most basic level is fairly simple. You make one base template that defines your site structure then put {% block Blah '' %} anywhere that you want to be able to add content. Then you make a second file for your page and use {% extends 'base.html.twig' %} {% block Blah %}<p>The content</p>{% endblock %} To specify the content to be placed in said block. Keep up the learning and it'll all click eventually. PHP is a great and versatile language, and if you use it well and learn good design/architecture (which Symfony helps with I think) you can carry that knowledge over to other languages.
  6. This: str.append(fileInput.files.name, fileInput.files); Should be this: str.append(fileInput.name, fileInput.files[i]); You want the name of the form field to used, and the value needs to be a single file not the whole collection. Lastly, your input needs to have the name: name="file[]" So that PHP will accept it as an array.
  7. Pro tip: When asking for the output of var_export, we don't want an image of it. We want you to copy/paste it into a code block so we can copy/paste it into an editor and use it to help you debug the code. Posting an image is not useful and a great way to get people to ignore your thread. Second tip, if you want to work with individual words, you should probably be storing them individually in a their own table, not as a comma separated list in your links table. Then getting your unique list of words would be a simple select distinct query.
  8. For example, using systemd on Ubuntu server I have a small chat server script running as a service. It's run by systemd by creating a service file like this: [Unit] Description=PHP Chat Daemon [Service] Type=simple WorkingDirectory=/var/www/kicken/aoeex.com/content/chat/src/ ExecStart=/usr/bin/php phpchatd.php Restart=on-failure SyslogIdentifier=phpchatd [Install] WantedBy=default.target The script itself just sits in a loop waiting for connections. Your script would need to be setup to loop doing whatever it does as well.
  9. There are some ini settings that control how PHP rounds the precision of floating point numbers. There is a higher precision for serialization, so a quick and dirty way of seeing the "raw" numbers would be to serialize it. echo serialize('573.06'*100); shows d:57305.99999999999;
  10. This is not quite accurate. A leading slash indicates the root of the filesystem, not the root of the site. This is rarely what you want.
  11. You cannot return the result of your ajax request. The reason is because the function will have returned long before that result is available. Requests are done asynchronously (the first A in AJAX) which means your code doesn't wait for the request to complete, it keeps going wile the request runs. You get notified of the results via the callback functions (the success / error functions). Any processing you want to do with the results needs to be contained within those functions. Thus, you need to move the alert(result) code into your success function. If you don't want to literally move the code, you can move it by introducing a new callback function as a parameter. For example: function quickSubmit(form_data, sUrl, successCB){ $.ajax({ url: sUrl, method: "POST", data: form_data, contentType: false, cache: false, processData: false, success: function(data){ var result = JSON.parse(data); successCB(result); }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); } quickSubmit([], '/', function(result){ alert(result); }); The same is true with any error handling, either put it directly into the error callback function, or create a new error callback parameter you can use. There are more modern and flexible ways of handling this like Promises and async/await but using them is a little more complicated. With async/await for example, you could write your function in a way that it seems to just return the results, but you need to set everything up properly first.
  12. The white under the curve is coming from the background set by #grve-content rather than the .grve-section class, so changing it wouldn't help. Whatever background the section would have gets clipped away by the .curved-bottom class, so the background you are seeing has to come from some parent element. If you only need the change for this page, set a rule that is limited to just it: #page-35941 { background-color: #dadada; } If you need it for several pages, create a new class you can apply to the page wrapper div.
  13. Your host is probably overriding it, possibly as a way to try and detect and shutdown spam accounts. You could contact your host and see if they have a solution.
  14. .closest would be better for buttons (maybe in general) since a child of the button (eg, <img>) might be the target of the click event.
  15. Yes, see Barand's example. The jQuery bits can be replaced with their plain DOM equivalents. window.addEventListener('DOMContentLoaded', function(){ document.querySelectorAll('.form-button').forEach(function(btn){ btn.addEventListener('click', function(e){ e.preventDefault(); alert('Button ' + e.currentTarget.value + ' clicked'); }); }); });
×
×
  • 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.