Category Archives: Uncategorized

Call to undefined function idn_to_utf8()

If you get this PHP error message with PHP 7.0: PHP Fatal error: Uncaught Error: Call to undefined function idn_to_utf8()PHP Fatal error: Uncaught Error: Call to undefined function idn_to_utf8() You need to install php7.0-intl module: apt-get install php7.0-intlapt-get install php7.0-intl

Comply with the EU Cookie Law with Cookie Consent

Cookie Consent is a free and tiny JavaScript plugin for alerting users about the use of cookies on your website. It is designed to help you comply with the EU Cookie Law. The plugin is created by Insites, a registered trademark of Silktide Ltd. Useful links for Cookie Consent: More Information About Cookie Consent Download […]

Replace multiple spaces with a single space in PHP

Replace multiple spaces with a single space: $string = preg_replace(‘/\s+/’, ‘ ‘, $string);$string = preg_replace(‘/\s+/’, ‘ ‘, $string); For UTF-8 strings use: $string = preg_replace(‘/\s+/u’, ‘ ‘, $string);$string = preg_replace(‘/\s+/u’, ‘ ‘, $string);

Print all HTTP POST variables\values in PHP

Show all variables sent via HTTP POST in PHP: print_r($_POST);print_r($_POST); A better way is to use a table to show the key and value: echo ‘<table>’; foreach ($_POST as $key => $value) { echo "<tr><td>".htmlspecialchars($key)."</td><td>".htmlspecialchars($value)."</td></tr>"; } echo ‘</table>’;echo ‘<table>’; foreach ($_POST as $key => $value) { echo "<tr><td>".htmlspecialchars($key)."</td><td>".htmlspecialchars($value)."</td></tr>"; } echo ‘</table>’; Or simply show key […]

PHP Truncate all words longer than and add ellipsis

function truncate_all_long_strings($string, $limit = 10) { return preg_replace("/(\\b\\w{".intval($limit)."})\\w+\\b/", "$1…", $string); }function truncate_all_long_strings($string, $limit = 10) { return preg_replace("/(\\b\\w{".intval($limit)."})\\w+\\b/", "$1…", $string); } Example usage: echo truncate_all_long_strings("veryyyyyyyyyyyyyyyyyyyyyyyyy long strinnnnnnnnnnnnnnnnnnnnnnngs to testtttttttttttttttttt");echo truncate_all_long_strings("veryyyyyyyyyyyyyyyyyyyyyyyyy long strinnnnnnnnnnnnnnnnnnnnnnngs to testtttttttttttttttttt"); Example output: veryyyyyyy… long strinnnnnn… to testtttttt…veryyyyyyy… long strinnnnnn… to testtttttt…

Adsense high CTR attack (click bombing) April 20 2015

From yesterday I noticed a high CTR on Google Adsense dashboard: That is too good to be true and infact it is a click-bombing attack as referred by other sites. Basically, some bad users are using automated spam bots to visit your website to automatically click on Adsense banners, most probably with the intent to […]

CSS3Pie Basic Usage

CSS3Pie makes IE 6-9 capable of rendering some CSS3 decoration features. Example usage: form[role=login] { border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; behavior: url(; /*CSS3Pie*/ }form[role=login] { border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; behavior: url(; /*CSS3Pie*/ } In case of problems, add position and zoom property: form[role=login] button { behavior: url(; /*CSS3Pie*/ position: relative; /*CSS3Pie*/ zoom: […]

jQuery $( document ).ready(function()

<script> <!– $( document ).ready(function() { //Enter code here }); –> </script><script> <!– $( document ).ready(function() { //Enter code here }); –> </script>

Check if Bootstrap modal is already open

Best way to check if the Bootstrap modal is open: if ( !$(‘#myModal’).hasClass(‘in’) ) { $(‘#myModal’).modal(‘show’); }if ( !$(‘#myModal’).hasClass(‘in’) ) { $(‘#myModal’).modal(‘show’); } Example usage: <script type="text/javascript"> $(document).ready(function(){ $( "#myDownload" ).click(function() { if ( !$(‘#myModal’).hasClass(‘in’) ) { //Check if the modal is already showing $(‘#myModal’).modal(‘show’); }; }); }); </script><script type="text/javascript"> $(document).ready(function(){ $( "#myDownload" ).click(function() { […]