Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. What lines in jquery.js specifically are causing the issue? Post the relevant sections on the code.
  2. You'd look at your autoloader settings to see what directory the namespace maps too then follow that. If you're using composer and the file is part of a library then search the vendor/composer/autoload_* files. If you're using some other setup you'll have to determine how it handles autoloading and figure out the path from it.
  3. With apache you'd need to have mod_headers enabled, then you can just add this to either your main configuration or a .htaccess Header add Content-Security-Policy "default-src 'self' https://www.google.com/recaptcha/api.js"
  4. How large is large? If you're talking a few MB or less I'd just keep it in the database. Keep things simple and not have to mess around with keeping external files in sync. If you're using a TEXT type for the column then mysql will store it outside the primary data area so having a bunch of text in the database shouldn't affect performance much. Mysql won't be trying to access it unless you specifically request it. If you're getting into the hundreds of MB or larger then it may be worth moving it out to a separate storage location to keep the overall DB size down so you can backup the database quicker and easier.
  5. Most spam bots are going to completely ignore the robots.txt file so they will never see your hidden link either. They will also spoof user agents so they appear as a legit browser so you cannot detect them that way. The only effective way to prevent them from submitting your forms is to include a CAPTCHA as has been mentioned. reCaptcha is popular and pretty good, but even something like a simple math problem or "password" will generally stop generic automated bots.
  6. You missed a " after your cellpadding attribute. As a result your title class is getting applied to the entire table.
  7. Only move the data directory, leave the my.ini file where it is. Also only update the datadir entry to the new location. Basedir is supposed to point to where mysql is installed, ie 'C:/Program Files/MySQL/MySQL Server 5.7/'
  8. If you click the quote button, type something, then hit preview you can see what happens. I can anyway. It seems like what happens is when you click quote it for some reason creates an empty <p></p> tag. Since it's empty it takes up no height but after posting / previewing that empty tag becomes <p><br></p> and so now it shows as a blank line. No idea why it creates the empty tag though.
  9. Maybe some library you are using is making use of the variable.
  10. It is possible sure. For example I use PHP 5.4, 5.6, and 7.0 on my development box for different applications in order to better match what they run in production. Each virtual host configures which version to use with a directive like: FcgidInitialEnv PATH "W:/PHP7.0;C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem" FcgidInitialEnv PHPRC "W:/PHP7.0" <Files ~ "\.php$>" SetHandler fcgid-script FcgidWrapper "W:/PHP7.0/php-cgi.exe" </Files> That's using mod_fcgid. The exact configuration you'd use would depend on what kind of Apache setup you are using. Using mod_proxy_fcgi with php-fpm would be different for example.
  11. kicken

    Similar queries

    Just make it null and then change it if the post data contains a value. $staff_id = null; if (isset($_POST['staff_id'])){ $staff_id = $_POST['staff_id']; }
  12. kicken

    Similar queries

    If you consider $staff_id = NULL to mean all records and non-null to mean a single record with that ID then you can handle it by simply binding the value twice. $staff_id = 34; $query = "SELECT fname, lname, city, email, cell FROM staff WHERE ? IS NULL OR staff_id=?"; $stmt = $con->prepare($query); $stmt->bind_param('ii',$staff_id, $staff_id); $stmt->execute(); $stmt->bind_result($fname, $lname, $city, $email, $cell); $stmt->store_result(); $stmt->close();
  13. Recall my post in one of your other threads If you want to define a function as a service, use the protect to prevent Pimple from executing it as the service constructor.
  14. That site only checks your HTTP setup. PHPMailer is concerned with your SMTP setup, which generally just comes pre-configured with a self-signed certificate which will fail verifications due to it not being from a trusted source. What you need to do is configure your mail server software to use a certificate from a trusted authority. The certificate's host name needs to match that of your mail server's name. So if your mail server is mail.example.com you need a certificate for mail.example.com
  15. If you're trying to understand how the container object (which provides access to your application objects) works, I'd suggest just spending some time looking at how Pimple does it. It is pretty basic and shouldn't take too long to grasp. The basic idea of the container is two parts: Configuring how objects are created and providing access to object instances. In Pimple both of these are provided by means of the ArrayAccess interface and it's offsetSet and offsetGet methods. You configure an object by assigning a closure to a given key in the container. This closure function handles creating the object instance and returns it for pimple to store and provide to anything that needs it. To obtain an object instance you just read the same key. When attempting to read the key Pimple will first check if the instance has already been created. If so it will return the existing instance. If not it will execute the closure to obtain an instance then mark it as having already been created so future reads won't try and re-create it. Other container implementations may work differently and may provide more features but the overall goal is the same. As for why you would want to use Dependency Injection and a container object, it allows you to keep the details of how a particular object is created (generally part of implementation details) separate from code that needs to make use of that object. It also lets you centralize the construction of those objects so if you need to make a change to you can do so in only one place rather than having to find all the places where you use it. Since things are generally defined in the container to only be constructed once it also means that you don't end up with a bunch of duplicate objects when multiple parts of your application all need access to the same object. For example with your database connection you could switch from using PDO directly to using a class that extends PDO and provides extra helper methods easily by defining it in the container then injecting instances of it into your object objects. Likewise if you wanted to change from say MySQL to Sqlite you could do so by just changing the container definition, provided your other code doesn't rely on any mysql-specific queries. Being able to switch to an alternate but compatible implementation can make testing a lot easier. When you create and run unit tests you have a special testing container that creates Mock versions of your dependencies such as an instance of PDO that always throws an error when trying to run a query or that returns specific results for a given query.
  16. What he's referring to is known as Dependency Injection. Basically it boils down to having some component of your application be responsible for constructing all your various objects and giving each of those objects whatever they need to function properly as arguments to the constructor (or via setter methods or whatever).As you've noticed before, the Slim framework you've been using handles this by using Pimple. So what you do is define your Foo class as something like this: class Foo { private $db; public function __construct(\PDO $db){ $this->db = $db; } } Then configure Pimple to construct that service when it is requested. $container['foo'] = function($container){ return new Foo($container['db']); }; Notice we pass the DB service to the instance of Foo that is created. This means you also have to define your DB service on the container, such as $container['db'] = function(){ return new PDO('mysql:host=localhost;dbname=test', 'user', 'pass'); }; Now when you try and access your foo service with $container['foo'] pimple will first get an instance of the DB service then construct your Foo object and give it an instance of the DB service as the first constructor parameter.
  17. I'd guess it's probably due to some problem with your email client keeping focus after opening the page. Your attempts to scroll would then be directed to the email client rather than the browser. I've had similar things occur on my system from time to time where some program will start up in front of my other apps but somehow doesn't actually get keyboard/mouse focus. I have to alt-tab to some other app then back to the one that just launched before it'll take focus. As for why it just recently started happening I can't say. I can say however that whatever the issue is, it has nothing to do with the PHPFreaks website and is not something anyone here could fix.
  18. Not all IP addresses have a host name. In those cases, the function just returns the original IP address.
  19. Usually one would just get a rich text editor such as TinyMCE and allow the user to edit the page content through that. Then you save the generated HTML to your database and display it when someone tries to view that page.
  20. It's ok to throw exceptions under unexpected conditions. For example if it's expected that someone trying to access a URL is authenticated and it turns out they are not, then you can throw some sort of access denied / authorization required exception. It's also ok to catch an exception if you have a way to do something about it. For example, you could catch the above authorization required exception and generate an appropriate error response with a 401 status code. Symfony does something like this to handle various HTTP error responses.
  21. Sorting is done using the ORDER BY clause.
  22. PHP (and the web in general) has changed quite a bit since then. Well written code from that era may still work fine on a modern PHP version, but poorly written code may have problems. If it's truly code from that era, you maybe looking at a complete re-write to bring it up to modern standards. How much of the original code could be re-used would depend on how well it was written at the time. If you post the code here someone may be able to review it and at the least give you an idea of what it might take to fix it. If you'd prefer to keep the code private you'd likely have to hire someone to look at it.
  23. You need to check the return value of the command you executed, which is provided to you through the third parameter to exec ($return_var). The manual page for zip lists a bunch of possible return codes, but the one you're interested in is: So you'd have something like this: exec('cd /websites/N2eGK46OjC/; zip -r -o /call/remote_skeleton.zip *', $output, $return); if ($return !== 0){ //Error encountered trigger_error("Error running command", E_USER_ERROR); } else { //Success } Once you know if it failed or was successful you could pass back some JSON to your javascript using json_encode containing whatever data you need.
  24. It's a long standing bug. There's an open pull request to try and fix it, no idea if it'll get merged and released any time soon. In the mean time, you'll just have to try and work around it the best you can by fiddling with the numbers or trying to do your own bounds checking by scanning the pixels of the image.
  25. SELECT fd.fname, fd.lname, fd.role, fd.fid, fd.city, fd.cell, fd.email FROM fd GROUP by fd.role LIMIT 1, 10 The group by and limit clauses mean you'll only get at most 10 rows from that query, 1 for each fd.role. Probably given that subset of data there is not always a fid match.
×
×
  • 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.