Posts

Showing posts from August, 2016

Prevent parent anchor tag to redirect when a child is clicked

Listen to click event of a child element within anchor tag. <a href="www.google.com" id="parent">    <img src="image.jpeg"/>     <div id="child">Delete</div> </a> jquery approach $('a#parent').on('click', '#child', function(e){     e.preventDefault();          //you only need this if you have a click event in parent element     //e.stopPropagation();      alert($(this).html()); });

Use php exec(), php_exec() wamp server windows 8

Steps: Turn off safe mode in php.ini (Make sure you are editing the correct php.ini that corresponds to the right version of active php e.g. D:\wamp\bin\php\php5.3.5\php.ini) safe_mode = Off safe_mode_exec_dir = Off Usage: If you have myexecutable.exe in the same folder with test.php in your local server . Accessing http://localhost/test.php. You should see the output message of your executabe.   test.php <?php exec("myexecutable.exe", $output); var_dump($output);   //Page will not wait for the executable to finish. Uncomment pclose()if you //don't want the page to load waiting for the exe to finish //http://www.php.net/manual/en/function.exec.php //pclose(popen("start /B myexecutable.exe ", "r"));   ?> The page will wait for the executable to finished.

Issue with incorrect filename downloading or saving pdf file using acrobat plugins

When we try to secure our pdf files from direct url access using .htacess, we then encounter the problem in incorrect file name of downloaded pdf file. This is just a small issue but to the client this is a big hassle renaming each downloaded pdf to the correct filename. Solution   Just by including the url filename in the url like below will do the trick www.wtfthiscode.com/secure.php /mypdfilename ?key=hashkeytomypdffile Simple example on how to secure your public pdf file Since we can't directly transfer the files away from public folder and due to time constraints. We decided to settle with .htaccess   .htaccess RewriteEngine on RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wtfthiscode.com [NC] RewriteRule \.(pdf)$ - [NC,F,L] The rewrite rule prevents any direct access to pdf files where the .htaccess file is located. We put the .htaccess file in uploads directory. If you don't have problem with rewrite in your web server, accessing the url like...