Michaël Perrin has written an article about using annotation and filters improve security.
With a more complex model, for example an order that contains products, you want also to filter on the associations of the filtered entity.
| version: '2' | |
| services: | |
| api: | |
| volumes: | |
| - "nfsmount:${CONTAINER_DIR}" | |
| volumes: | |
| nfsmount: | |
| driver: local | |
| driver_opts: |
| function generateToken() | |
| { | |
| return bin2hex(openssl_random_pseudo_bytes(16)); | |
| } | |
| function getUrl() | |
| { | |
| $url = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"]; | |
| $url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : ""; | |
| $url .= $_SERVER["REQUEST_URI"]; |
Michaël Perrin has written an article about using annotation and filters improve security.
With a more complex model, for example an order that contains products, you want also to filter on the associations of the filtered entity.
| import SimpleHTTPServer | |
| import SocketServer | |
| PORT = 8000 | |
| class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
| pass | |
| Handler.extensions_map['.shtml'] = 'text/html' |
| <?php | |
| $diff = 450752; | |
| $format = sprintf('%02d:%02d:%02d', ($diff / 3600), ($diff / 60 % 60), $diff % 60); | |
| echo $format; |
| <?php | |
| namespace Ormigo\Bundle\OrmigoBundle\Form\Type; | |
| use Symfony\Component\Form\AbstractType; | |
| use Symfony\Component\Form\FormBuilderInterface; | |
| use Symfony\Component\OptionsResolver\Options; | |
| use Symfony\Component\OptionsResolver\OptionsResolver; | |
| use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
| <?php | |
| # Nginx don't have PATH_INFO | |
| if (!isset($_SERVER['PATH_INFO'])) { | |
| $_SERVER['PATH_INFO'] = substr($_SERVER["ORIG_SCRIPT_FILENAME"], strlen($_SERVER["SCRIPT_FILENAME"])); | |
| } | |
| $request = substr($_SERVER['PATH_INFO'], 1); | |
| $file = $request; | |
| $fp = @fopen($file, 'rb'); |
| <?php | |
| /** | |
| * Recognizes mData sent from DataTables where dotted notations represent a related | |
| * entity. For example, defining the following in DataTables... | |
| * | |
| * "aoColumns": [ | |
| * { "mData": "id" }, | |
| * { "mData": "description" }, | |
| * { "mData": "customer.first_name" }, | |
| * { "mData": "customer.last_name" } |
In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:
This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
| <?php | |
| /* | |
| * This class will give us a simple interface to interact with Datatables | |
| * | |
| * Meant to work with Datatables v1.9 | |
| * | |
| * DO NOT FORGET TO ADD A GET() METHOD TO YOUR ENTITIES... | |
| * |