Skip to main content

Posts

Showing posts from December, 2016

PHP function to get MAC and IP address

PHP function to obtain the machine MAC and IP address. By this function, you will be able to get the physical address of the machine. function getMAC(){ ob_start(); system('ipconfig /all'); $mycom=ob_get_contents(); ob_clean(); $findme = "Physical"; $pmac = strpos($mycom, $findme); $mac=substr($mycom,($pmac+36),17); return $mac; } function getIP(){ $ip=$_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } $ips = explode(",", $ip); $ipss=$ips[0]; return $ipss; }

PHP function for checking IMEI

Luhn algorithm for IMEI Check public function __checkIMEI($imei){ if(strlen($imei)==15){ $imeia=($imei[1]*2); if(strlen($imeia)==2){$imeia=str_split($imeia,1); $imeia=$imeia[0]+$imeia[1]; } $imeib=($imei[3]*2); if(strlen($imeib)==2){$imeib=str_split($imeib,1); $imeib=$imeib[0]+$imeib[1]; } $imeic=($imei[5]*2); if(strlen($imeic)==2){$imeic=str_split($imeic,1); $imeic=$imeic[0]+$imeic[1]; } $imeid=($imei[7]*2); if(strlen($imeid)==2){$imeid=str_split($imeid,1); $imeid=$imeid[0]+$imeid[1];} $imeie=($imei[9]*2); if(strlen($imeie)==2){$imeie=str_split($imeie,1); $imeie=$imeie[0]+$imeie[1]; } $imeif=($imei[11]*2); if(strlen($imeif)==2){$imeif=str_split($imeif,1); $imeif=$imeif[0]+$imeif[1]; } $imeig=($imei[13]*2); if(strlen($imeig)==2){$imeig=str_split($imeig,1); $imeig=$imeig[0]+$imeig[1]; } $IMEI= ($ime

GRANT and REVOKE in MySQL

DCL commands are used to enforce database security in multiple user database environments. Two types of DCL commands are GRANT and REVOKE. Only Database Administrator's or owner's of the database object can provide/remove privileges on a database object. SQL GRANT is a command used to provide access or privileges on the database objects to the users Syntax- GRANT privilege_name ON object_name TO { user_name | PUBLIC | role_name } [ WITH GRANT OPTION ];     CREATE ROLE testing GRANT CREATE TABLE TO testing ; The REVOKE command removes user access rights or privileges to the database objects. REVOKE privilege_name ON object_name FROM { user_name | PUBLIC | role_name }   REVOKE CREATE TABLE FROM testing ;

Code for Mail in PHP

PHP mail function and mail configuration in  XAMPP  and sending mail is done from sendmail through localhost. I hope it will help you. mail() function <? php $to = 'dubeynitish22@hotmail.com' ; $subject = 'Test' ; $message = 'Hello' ; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion ();   if (! mail ( $to , $subject , $message , $headers )){ echo "Error !!" ; } else { echo "Email Sent !!" ; } ?> 2. php.ini configuration (For SEND-MAIL) [ mail function ] ; For Win32 only . ; http : //php.net/smtp ; SMTP = localhost ; http : //php.net/smtp-port ; smtp_port = 25   ; For Win32 only . ; http : //php.net/sendmail-from ; sendmail_from = me@example . com   ; For Unix only . You may supply arguments as well ( default : "sendmail -t -i&q

How to install LARAVEL5 with Xampp (Windows)

Hi,  Today I am with the installation guide of LARAVEL5 in windows. Step 1)  Requirements a) PHP >= 5.5.9 b) OpenSSL PHP Extension c) PDO PHP Extension d) Mbstring PHP Extension e) Tokenizer PHP Extension Step 2)  Install Xampp First of all, we need Xampp, so we can download it from the official page: Download Xampp Step 3)  INSTALL Composer If you've downloaded and installed Xampp, you need to install Composer.                 "Composer is a PHP package manager that is integrated with Laravel Framework.                  In Windows, we can install it easy going to the official page and download the installer." Composer Download page After installing it, open a Windows terminal and write composer. Step 4) Xampp Virtual Host    We will configure a Virtual Host in Xampp for a Laravel project, and in this example, we want            to configure the domain laravel.dev for our project.    We need to edit httpd-vhost

How do you connect remote MySQL in R?

Connecting to MySQL is made very easy with the RMySQL package. To connect to a MySQL database simply install the package and load the library. install.packages("RMySQL") library(RMySQL) Connecting to MySQL: Once the RMySQL library is installed create a database connection object. You need to create a user on the remote MySQL and GRANT ALL PRIVILEGES ON to that database. And in place of host put remote machine IP. mydb = dbConnect(MySQL(), user='user', password='password', dbname='database_name', host='host')

OS By Indian Government (BOSS)

#BOSS (Bharat Operating System Solutions) An OS Developed and  Design by Indian Government (BOSS) Bharat Operating System Solutions. BOSS is an Indian GNU/Linux distribution developed by CDAC and is customized to suit Indian's digital environment. It supports most of the Indian languages.

A perfect answer by someone, why FACEBOOK used PHP.

If someone like Mark Zuckerberg were creating Facebook today (2012 as I am writing this answer), sure, no doubt they would consider many other languages, frameworks, platforms, architectures. It's impossible to say whether they would still choose PHP today if they were starting out. Other social-network companies are starting today, and clearly, some fraction of them are still choosing PHP. They may choose PHP because it does the job they need to do, and they know they can hire developers who know it and can be productive with it. Facebook has obviously been very successful using PHP (even though at that time PHP 5.0.0 was still beta).  There's a strong argument to be made that  writing viable software has little to do with the choice of language .  One can find anecdotes of successful projects or disastrous projects using any language. According to the history described on the Wikipedia page for Facebook, Zuckerberg wrote the initial code for Facebook in October 2003.

Program for Making a table of given row and column where column are filled vertically in increment like 1234....

<!--Program for Making a table of given row and column where the column is filled vertically in increment like 1234....--> <! DOCTYPE html > <html> <body> <?php $i = 8 ; $j = 10 ; for ( $row = 0 ; $row < $i ; $row ++) { echo "<table border='1' width='50%'><tr>" ; for ( $col = 0 ; $col < $j ; $col ++) { if ( $col == 0 ){ echo "<td>" .( $row + 1 ). "</td>" ; $c =( $row + 1 ); } else { echo "<td>" .( $c + $i ). "</td>" ; $c =( $c + $i ); } } echo "</tr></table>" ; } ?> </body> </html> #Output

Reducing Image File Size (Compression) using PHP GD

<!--Code snippets for Reducing of image size--> <?php header ( 'Content-Type: image/jpeg' ); function compress_image ( $source_url , $destination_url , $quality ) { $info = getimagesize ( $source_url ); if ( $info [ 'mime' ] == 'image/jpeg' ) $image = imagecreatefromjpeg ( $source_url ); elseif ( $info [ 'mime' ] == 'image/gif' ) $image = imagecreatefromgif ( $source_url ); elseif ( $info [ 'mime' ] == 'image/png' ) $image = imagecreatefrompng ( $source_url ); //save it var_dump ( $destination_url ); header ( 'Content-Type: image/jpeg' ); imagejpeg ( $image , $destination_url , $quality ); //return destination file url return $destination_url ; } $source_photo = 'http://localhost/test/uploads/image2.jpg' ; $dest_photo = $_SERVER [ 'DOCUMENT_ROOT' ]. '/test/uploads/image5.jpg' ; $d = compress_image ( $source_photo , $