LATEST ARTICLES

jQuery printMe2 plugin

jquery-print-me

In some case, we cant use plugin printMe to print because of popup blocker, so how to use it, i create a new version call: printMe2 Homepage : printMe http://www.daniarlandis.es/printMe/ https://github.com/menusal/printMe And here the new code jQuery.fn.printMe2 = function(options){ // Setup options var settings = $.extend({ // Defaults options. path: , title: "", head: false, type: 'iframe' }, options ); // Set the properties and...

Flash detect by Javascript

JSconf_logo

How to detect flash by Javascript var flash = 0; try { var FlashDetect=new function(){ var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=;var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){} return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};} return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray.split("...

Function apache_request_headers on Nginx

php

Function apache_request_headers supports only on Apache, how to use it on Nginx. Here is the solution: if (!function_exists('apache_request_headers')) { function apache_request_headers() { $return = array(); foreach($_SERVER as $key=>$value) { ...

PHP CURL: How to limit read size

How to limit read size

In some case, we need to read a first part of a website page or a file (eg a big file). How to limit read size? We can use CURLOPT_WRITEFUNCTION: Example 1: <?php set_time_limit(0); $size = 1440; $ch = curl_init(); $content = ''; $callback = function ($ch, $str) { global $content,$size; $content.=$str; if(curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD)>$size) return 0; ...

How to install PHP5.6 php-fpm on Centos 7

Step 1: sudo yum update Result: # sudo yum update Loaded plugins: fastestmirror, priorities Loading mirror speeds from cached hostfile * base: ftp.plusline.de * epel: epel.vpsnet.lt * extras: mirror.de.leaseweb.net * remi-safe: nl.mirror.babylon.network * updates: mirror.tobias-wollmann.com 11873 packages excluded due to repository priority protections No packages marked for update Step 2: sudo yum groupinstall "Development tools" Result: # sudo yum groupinstall "Development tools" Loaded plugins: fastestmirror, priorities Loading mirror speeds from cached hostfile ...

PHP: Example of usage CURLOPT_WRITEFUNCTION

CURLOPT_WRITEFUNCTION

CURLOPT_WRITEFUNCTION: A callback accepting two parameters. The first is the cURL resource, and the second is a string with the data to be written. The data must be saved by this callback. It must return the exact number of bytes written or the transfer will be aborted with an error. <?php $ch = curl_init(); $result = ''; $callback = function ($ch, $str) { ...

PHP: Example of usage CURLOPT_HEADERFUNCTION

CURLOPT_HEADERFUNCTION

If you set option CURLINFO_HEADER_OUT to true, you can get request header with function curl_getinfo (see example 2) <?php $headers = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://tutorialspots.com/'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); curl_setopt($ch, CURLOPT_HEADERFUNCTION,'header_callback'); curl_setopt($ch, CURLINFO_HEADER_OUT, true); $content = curl_exec($ch); curl_close($ch); function header_callback($ch, $header_line) { global $headers; $headers = $header_line; return strlen($header_line); } var_dump($headers); CURLOPT_HEADERFUNCTION: A callback accepting two...

How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Debian 8

Step 1: install nginx: sudo apt-get update sudo apt-get install nginx Result: root@v22017054614249197:~# sudo apt-get install nginx Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libxslt1.1 nginx-common nginx-full Suggested packages: fcgiwrap nginx-doc The following NEW packages will be installed: libxslt1.1 nginx nginx-common nginx-full 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get...

How to install netstat on Linux

install netstat linux

To install netstat on Linux, use one command line yum install net-tools Result: # yum install net-tools Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.xmission.com * epel: mirrors.kernel.org * extras: mirrors.xmission.com * remi: mirrors.thzhost.com * remi-php56: mirrors.thzhost.com * remi-safe: mirrors.thzhost.com * updates: mirrors.xmission.com Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package ...

PHP function chr of unicode character

chr unicode

PHP have function chr to find a character from a ASCII value. But PHP don’t support a function to find this with unicode character. Now, we provider some method, they are equivalent with String.fromCharCode() in Javascript: /** * @author www.Tutorialspots.com * @copyright 2017 */ function unichr($dec) { if ($dec < 128) { $utf = chr($dec); } elseif ($dec < 2048){ ...