User Agent Parsing with PHP

Tobie Langel’s ua-parser, a great library which provides simple UA parsing in PHP, JavaScript and Python.

<?php require_once 'uaparser.php';

$ua = $_SERVER['HTTP_USER_AGENT'];
$parser = new UAParser();
$result = $parser->parse($ua);

echo '<pre>';
print_r($result);

?>

Mistserver Manager Login

Find more libraries here...

https://github.com/rjd22/ua-parser/tree/master/php
https://github.com/Synchro/ua-parser

Best PHP Encryption Decryption

I was working on Secured & Expired MP3 Link in HTML5 MP3 Player. Hope you already read previous article “Amazon S3 Expiring Link”

You can use below code for hiding real mp3 link inside html source using base64_encode, mcrypt_encrypt, base64_decode, mcrypt_decrypt and md5.

This function is also useful when you need to secure & expire media links …

Remote Secure Token
Secure Token Plugin with PHP
JavaScript Encryption Library

<?php

function encryptDecrypt($key, $string, $decrypt)
{
    if($decrypt)
    {
        
        $string = str_replace("|", "/", $string);
        
        $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "12");
        return $decrypted;
    }else{
        $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));        
        
        $stripping = true;
        while ($stripping){
         if(substr($encrypted, -1) == "="){
         $encrypted = substr($encrypted, 0, strlen($encrypted)-1);
        } else {
         $stripping = false;
        }
        }
        return str_replace("/", "|", $encrypted);
    }
}


$echo = encryptDecrypt("123", "https://www.svnlabs.com/mp3/svnlabs1.mp3", 0);
echo $echo."<br>";
echo encryptDecrypt("123", $echo, 1);

?>

 

Output:
yTWxdWnzTqh2OHxrfVX5Xxa+K8vGso9|upjRs+oQJLTDmKNyzVfLCvEcvd3ube|Mk+bxxMpijLjAgusr0EDawQ

Reference: http://commons.oreilly.com/wiki/index.php/PHP_Cookbook/Encryption_and_Security

Amazon S3 Expiring Link

I was working on Amazon S3 Cloud HTML5 MP3 Player for S3 Bucket security and Expiring Media links.

Amazon S3 Cloud HTML5 MP3 Player
Amazon S3 Cloud HTML5 MP3 Player
<?php

  if(!function_exists('el_crypto_hmacSHA1')){
      /**
      * Calculate the HMAC SHA1 hash of a string.
      *
      * @param string $key The key to hash against
      * @param string $data The data to hash
      * @param int $blocksize Optional blocksize
      * @return string HMAC SHA1
      */
      function el_crypto_hmacSHA1($key,$data,$blocksize=64){
          if(strlen($key)>$blocksize)$key=pack('H*',sha1($key));
          $key=str_pad($key,$blocksize,chr(0x00));
          $ipad=str_repeat(chr(0x36),$blocksize);
          $opad=str_repeat(chr(0x5c),$blocksize);
          $hmac=pack('H*',sha1(
              ($key^$opad).pack('H*',sha1(
                  ($key^$ipad).$data
              ))
          ));
          returnbase64_encode($hmac);
      }
  }

  if(!function_exists('el_s3_getTemporaryLink')){
      /**
      * Create temporary URLs to your protected Amazon S3 files.
      *
      * @param string $accessKey Your Amazon S3 access key
      * @param string $secretKey Your Amazon S3 secret key
      * @param string $bucket The bucket (bucket.s3.amazonaws.com)
      * @param string $path The target file path
      * @param int $expires In minutes
      * @return string Temporary Amazon S3 URL
      * @see http://awsdocs.s3.amazonaws.com/S3/20060301/s3-dg-20060301.pdf
      */
      function el_s3_getTemporaryLink($accessKey,$secretKey,$bucket,$path,$expires=5){
          // Calculate expiry time
          $expires=time()+intval(floatval($expires)*60);
          // Fix the path; encode and sanitize
          $path=str_replace('%2F','/',rawurlencode($path=ltrim($path,'/')));
          // Path for signature starts with the bucket
          $signpath='/'.$bucket.'/'.$path;
          // S3 friendly string to sign
          $signsz=implode("\n",$pieces=array('GET',null,null,$expires,$signpath));
          // Calculate the hash
          $signature= el_crypto_hmacSHA1($secretKey,$signsz);
          // Glue the URL ...
          $url=sprintf('http://%s.s3.amazonaws.com/%s',$bucket,$path);
          // ... to the query string ...
          $qs=http_build_query($pieces=array(
              'AWSAccessKeyId'=>$accessKey,
              'Expires'=>$expires,
              'Signature'=>$signature,
          ));a
          // ... and return the URL!
          return$url.'?'.$qs;
      }
  }

  ?>

Uses:

$ExpiringLink = el_s3_getTemporaryLink(‘AWS-KEY’, ‘AWS-SECRET-KEY’, ‘BUCKET’, ‘FILENAME’, ‘EXPIRING-TIME’);

Demo Amazon S3 Cloud HTML5 MP3 Player

Reference: http://snipplr.com/view/46753.57507/

PHP Run Background Process using Exec

If you need to start process in background and get its PID to manage it later using PHP.

<?php

function runInBackground($command,$log,$priority=0)
{
if($priority)
   $PID=shell_exec("nohup nice -n $priority $command > $log 2>&1 & echo $!");
else
   $PID=shell_exec("nohup $command > $log 2>&1 & echo $!");
return($PID);
}

?>
PHP Process
PHP Process

echo $! will return process ID
# Command & echo $!

 

Check if process is running

<?php

function isProcessRunning($PID)
{

if($PID==0)return false;
if($PID=="")return false;

exec("ps -p $PID 2>&1",$state);
return(count($state)>=2);

}

?>

 

Display Process Logs

<?php

function displayProcessLog($logfile)
{

exec('cat $logfile 2>&1',$log);
return implode("\r\n",$log);

}

?>

 

Kill Process

<?php

function killProcess($PID)
{
 exec('kill '.$PID.' 2>&1',$status);
 return implode("\r\n",$status);
}

?>

 

Save Process ID to file

#!/bin/bash
Command &
echo $! >/path/to/pid.file

Design lookup

Orlando Web Design

 

Web Design and WordPress Support.

We usually search good design ideas for our web development needs. I have some useful links on this page. Please review and share more in comment area 🙂

 

http://www.sohtanaka.com/

http://preloaders.net/
http://www.noupe.com/
http://antsmagzine.com/
http://designm.ag/tutorials/sticky-sidenav-layout/
http://www.learningjquery.com/
http://www.pierrebertet.net/projects/jquery_superbox/
http://usejquery.com/
http://vandelaydesign.com/
http://roshanbh.com.np/
http://www.templatemo.com/
http://www.webtemplates.webfirstcreations.com/
http://hambodevelopment.com/
http://www.osvaldas.info/
http://www.veboolabs.com/
http://www.sourcebits.com/
http://twipho.net/
http://jquerystyle.com/
http://www.1stwebdesigner.com/
http://www.1stwebdesigner.com/tutorials/53-jquery-tutorials-resources-tips-and-tricks-ultimate-collection/
http://arnaud-k.fr/
http://www.mplusz.com/
http://marcgrabanski.com/article/jquery-google-maps-tutorial-basics
http://marcgrabanski.com/webroot/resources/jquery-ui-google-maps/tutorial-part1.html
http://jqueryfordesigners.com/
http://www.templates.com/
http://www.proclipart.com/
http://www.queness.com/post/456/16-impressive-flash-like-javascript-animation-inspirations-tutorials-and-plugins
http://www.k4lab.info/eng/indexeng.htm
http://www.clubclub.fr/
http://abduzeedo.com/web-design-awesome-magazine-style-sites
http://www.creative-outsourcing.com/
http://www.studio7designs.com/blog/101-design-resource-links/
http://www.templamatic.com/
http://bestwebgallery.com/
http://www.css-website.com/
http://www.cssclip.com/
http://csscollection.com/
http://cssdrive.com/
http://www.csselite.com/
http://www.cssflavor.com/
http://cssmania.com/
http://cssremix.com/
http://www.designmeltdown.com/
http://www.designshack.co.uk/
http://www.mostinspired.com/
http://www.professionalontheweb.com/
http://www.dailyslurp.com/
http://www.w3csites.com/
http://www.cssheaven.com/
http://www.cssbeauty.com/

FFmpeg – ERROR: librtmp not found

I was installing FFmpeg for segmenting Red5 Streams to stream live video from Red5 Server to iOS or Android devices.

RTMP (Red5) -> FFMpeg -> Segementer -> .ts files -> iOS (m3u8)

I really needed mp4 (AAC/H.264) and ogg (Vorbis/Theora) format for best HTML5 output.

I checkout FFmpeg source and tryed below command to install / configure it

# ./configure –enable-gpl –enable-nonfree –enable-libmp3lame –enable-libfaac –enable-librtmp –enable-libtheora –enable-libvorbis –enable-libx264 –enable-shared –enable-postproc

error while loading shared libraries: libfaac.so.0:

I have already installed all dependencies, but links to shared libraries was not found … so …

# echo “/usr/local/lib” >> /etc/ld.so.conf
# echo “/usr/lib” >> /etc/ld.so.conf
# ldconfig

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.

Another error ERROR: librtmp not found

# ls /usr/local/lib/librtmp*

/usr/local/lib/librtmp.a /usr/local/lib/librtmp.so

On CenOS before compiling ffmpeg, make sure you have valid path of packages in PKG_CONFIG_PATH

# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

We worked on RTMP (Live Red5 CAM) to iOS (iPhone or iPad). Get more help for HTTP Live Video Stream Segmenter and Distributor Contact Us

Read more…. VOD to iOS | Red5 Media Server iOS Android Setup

Mobile Apps for Safety

Mobile apps across various operating systems that can help to save our souls and keep our loved ones informed about each other.

Lot of people are searching mobile applications for personal security these days, I am trying to help to find some useful Mobile Applications on Android Google Play Market.

Life360 Family Locator http://www.life360.com/

Life360 Family Locator
Family Locator by Life360 is the most accurate and powerful locator service.

Family Locator by Life360 is the most accurate and powerful family locator service. Using the latest GPS tracking technology.

SOS Whistle

The whistle sound is played when pressed. stop if you press the button again.
The whistle sound is played when pressed.
stop if you press the button again.

Ask for help when a disaster and nobody even noticed.

Circle of 6

Circle of 6 to automatically send your circle a pre-programmed SMS alert message
Circle of 6 to automatically send your circle a pre-programmed SMS alert message

Circle of 6 lets you choose six trusted friends to add to your circle. If you get into an uncomfortable or risky situation, use Circle of 6 to automatically send your circle a pre-programmed SMS alert message, with your exact location.

Fight Back

FightBack Mobile Application SOS
FightBack Mobile Application SOS

FightBack uses GPS, SMS, location maps, GPRS, email and your Facebook account to inform your loved ones in case you are in danger.

Guardly | Alert. Connect. Stay safe.

Guardly | Alert. Connect. Stay safe.
Guardly | Alert. Connect. Stay safe.

Guardly is an enterprise platform for emergency communication, management and response in education, commercial, mass transit and healthcare.

YWCA Safety Alert

YWCA Safety Alert
YWCA Safety AlertYWCA Safety Alert

The YWCA Safety Alert App is designed to enhance the safety of young women at any time and anywhere.

Scream Alarm!

Scream Alarm
Scream Alarm

FREE safety alarm that does only one thing: push the button for making the phone scream loudly with a woman’s voice!

Glympse – Share your where

Share your where
Share your where

Safely share your location in real-time via email, SMS, Facebook, or Twitter.

Eyewatch Basic – The “No More Panic” Button

Eyewatch Basic
Eyewatch Basic

Eyewatch allows you to trigger instant emergency alerts to your trusted contacts, alerting them of your emergency along with your location, audio visuals of the situation and other critical details.

S&S Rescue Pack

S&S Rescue Pack
S&S Rescue Pack

S&S App has prepared to quick access useful tools for any time you need. Access the features is realy simple, you can reach all features with just one click.

One Touch SOS

One Touch SOS
One Touch SOS

Ultra-quick, single click SOS when you’re in danger. Gets your location and sends the address to your buddy with a marker on a map.

Bsafe

bSafe is what you need! This GPS-based safety alarm is packed features to make you safer. With bSafe you never walk alone!
bSafe is what you need! This GPS-based safety alarm is packed features to make you safer. With bSafe you never walk alone!

bSafe is GPS-based safety alarm is packed features to make you safer.

Real Alert

Real Alert
Real Alert

REAL ALERT helps you to stay alert and aware of your surroundings, provides quick access to emergency services & directs you to the closest hospital.

DriveSafe.ly

drivesafely
drivesafely

It is a mobile application (solution to texting while driving) that reads text (SMS) messages and emails aloud in real time and automatically responds without drivers touching the mobile phone.

Amber Alert GPS Parent

Amber Alert GPS
To track your Smartphone-carrying tween or teen, or to track multiple Smartphones and Amber Alert GPS devices

Amber Alert GPS Parent can track your Smartphone-carrying tween or teen, or to track multiple Smartphones.

IWatch Beta

IWatch Beta
An initiative by Rajashtan Police to connect citizens to stop crime and provide services without much trouble.

An initiative by Rajasthan Police to connect citizens using Android Mobile App to stop crime and provide services without much trouble.

Make New Application in Red5

1. Make a new directory “svnlabs” under the webapps directory, it will be name of the application “svnlabs”.

Red5 New Apps
Red5 New Apps

2. Create a sub-directory called WEB-INF

– red5-web.properties
– red5-web.xml
– web.xml

webapp.contextPath=/svnlabs
webapp.virtualHosts=*, localhost, localhost:8088, 127.0.0.1:8088

Download “svnlabs” Red5 App here…

3. Restart Red5 Server

HTML5 Video Canvas to Capture Image Frames

Mobile will continue to be the big trends in 2013 because more users accessing websites on mobile devices. HTML5 Canvas help you for optimizing your site and video ads for mobile will become increasingly important.

Video to Canvas Capture
Video to Canvas Capture

canvas2image – A tool for saving or converting canvas as images 😉

HTML5 Video to Image gallery is very easy using HTML5 Video Canvas. CSS Sprite Animation can be used on various mobile ads solution application.

video canvas image gallery sprite animation
video canvas image gallery sprite animation

HTML5 Video Canvas to Capture Image is good tool to extract frames on Image Canvas. FFMpeg Video Image is not useful in real-time image capture.

imgs.appendChild(Canvas2Image.convertToImage(canvasFromVideo, 300, 200, ‘png’));

Demo: http://demo.svnlabs.com/html5videocapture/

Download: http://demo.svnlabs.com/html5videocapture/html5videocapture.zip

PHP Download MP3 File by URL

PHP Download MP3 File by URL

1. WGET
It will save files on web server then use php header for prompting to download file.

2. CURL
CURL will not work efficiently for big files i.e. MP3, ZIP, MP4 etc.

3. file_get_contents()
This will consume too much memory on server. It can first read remote URL then save and download.

4. Content-type: application/x-file-to-save

<?php

if(isset($_REQUEST['inputurl']) && $_REQUEST['inputurl']!="") {

$file = $_REQUEST['inputurl']; 

header("Content-type: application/x-file-to-save"); 
header("Content-Disposition: attachment; filename=".basename($file)); 
readfile($file); 

}

?>

<form name="from" method="post" action="">
<input name="inputurl" type="text" id="inputurl"  value="" />
<input type="submit" name="Button1" value="Get File" id="Button1" />
</form>