Wowza Live Cam Secure Expired Token

Hits: 5795  
Wowza Live Cam Secure Expired Token
Wowza Live Cam Secure Expired Token

// Encrypt original stream URL http://wowza-server:port/stream/playlist.m3u8
$base64ized = encryptDecrypt($secret_key, $streamURL, 0);

// Decrypt stream URL
$streamURL = encryptDecrypt($secret_key, $base64ized, 1);


// Expire stream URL after time interval & check secure token
if (($current – $timestamp) <= $expired && ($checkhash == $hash)) { include("m3u8.php"); } m3u8.php

header(“content-type: application/”);
echo file_get_contents(“http://wowza-server:port/stream/playlist.m3u8”);

Creating Zip Without Recording ROOT Paths

Hits: 4070  

Simply use chdir() to change the working directory before you exec()

Or you can use ….

exec(“cd /var/www/html/media; zip -r -9 . 2>&1”, $log);

exec(“mv /var/www/html/media/ /var/www/html/”);

Get zip file size

exec(“ls -ls /var/www/html/ | awk ‘{print $6}’ 2>&1”, $size);

$zipsize = implode(” “, $size);

Without this solution

Length Date Time Name
——– —- —- —-
0 03-08-13 15:10 /var/www/html/media/dialogs/
125305 08-07-12 16:31 /var/www/html/media/dialogs/1.3.mp3
125305 08-07-12 16:33 /var/www/html/media/dialogs/1.5.mp3
184864 08-07-12 16:32 /var/www/html/media/dialogs/1.4.mp3
125305 08-07-12 16:30 /var/www/html/media/dialogs/1.1.mp3
125305 02-24-13 16:48 /var/www/html/media/dialogs/1.2.mp3
125305 08-07-12 16:34 /var/www/html/media/dialogs/1.6.mp3

With this solution

Length Date Time Name
——– —- —- —-
0 03-08-13 16:40 dialogs/
125305 08-07-12 16:51 dialogs/1.3.mp3
125305 08-07-12 16:53 dialogs/1.5.mp3
184864 08-07-12 16:52 dialogs/1.4.mp3
125305 08-07-12 16:50 dialogs/1.1.mp3
125305 02-24-13 16:58 dialogs/1.2.mp3
125305 08-07-12 17:04 dialogs/1.6.mp3

Best PHP Encryption Decryption

Hits: 5901  

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


function encryptDecrypt($key, $string, $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;
        $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", "", 0);
echo $echo."<br>";
echo encryptDecrypt("123", $echo, 1);





Amazon S3 Expiring Link

Hits: 9864  

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

      * 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){

      * 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 (
      * @param string $path The target file path
      * @param int $expires In minutes
      * @return string Temporary Amazon S3 URL
      * @see
      function el_s3_getTemporaryLink($accessKey,$secretKey,$bucket,$path,$expires=5){
          // Calculate expiry time
          // Fix the path; encode and sanitize
          // Path for signature starts with the bucket
          // S3 friendly string to sign
          // Calculate the hash
          $signature= el_crypto_hmacSHA1($secretKey,$signsz);
          // Glue the URL ...
          // ... to the query string ...
          // ... and return the URL!



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

Demo Amazon S3 Cloud HTML5 MP3 Player


PHP Run Background Process using Exec

Hits: 8992  

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


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

PHP Process
PHP Process

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


Check if process is running


function isProcessRunning($PID)

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

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




Display Process Logs


function displayProcessLog($logfile)

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




Kill Process


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



Save Process ID to file

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

Install Apache, PHP, MySQL on HP Cloud

Hits: 5674  

I am playing with all cloud services these days, so today we will try to setup Apache, PHP, MySQL on HP Cloud. HP Cloud is based on OpenStack Compute

Hope you already read our old article “Installing Apache, MySQL, PHP in CentOS 5.5 on Rackspace Cloud”?

In the HP Cloud Console Area you can manage

– Servers / Storage
– Floating IPs
– Images
– Key Pairs
– Security Groups
– Volumes

First you need to create Key Pairs and some rule in security default group…

Security Group Rules
Security Group Rules

HP Cloud Compute Overview

HP Cloud Object Storage Overview

You can start any type of server CentOS, Ubuntu using HP Cloud GUI …

Server on HP Cloud
Server on HP Cloud

Also you can manage running instances easily…

Manager Server on HP Cloud
Manager Server on HP Cloud

You can connect to server using SSH on port 22

# ssh -i KEYPair.pem root@IP-Address

In windows.. create PPK file from PEM Keypair using PuTTYgen

Install Apache

# sudo yum install httpd mod_ssl

Install MySQL

# yum install mysql mysql-server
# /etc/init.d/mysqld start

Install PHP

# yum install php php-common php-gd php-mcrypt php-pear php-pecl-memcache php-mhash php-mysql php-xml php-mbstring

# /etc/init.d/httpd start

You can access HP Cloud using HP Cloud Services APIs and HP Cloud Services CLI

Install Red5 on Google Compute Engine

Hits: 7012  

Yesterday we have installed basic web server (apache, php, mysql) on Google Compute Engine. Today our target is to install Red5 on Ubuntu server for Google Compute Engine.

First we need to check Java version installed on Google Compute Engine

$ java -version
The program ‘javac’ can be found in the following packages:

* default-jdk
* ecj
* gcj-4.6-jdk
* openjdk-6-jdk
* gcj-4.5-jdk
* openjdk-7-jdk
Ask your administrator to install one of them

Now you have to install java using

$ sudo apt-get update
$ sudo apt-get install java-package
# sudo apt-get install openjdk-6-jdk
$ sudo apt-get install openjdk-6-jre

Install Ant

$ sudo apt-get install ant

Install Subversion

$ sudo apt-get install subversion

You can download latest Red5 from here

$ sudo wget
$ sudo tar xvfz red5-1.0.0.tar.gz
$ sudo mv red5-1.0.0 red5
$ sudo mv red5 /usr/share/

Now try to run Red5 Server

$ cd /usr/share/red5
$ sudo sh

Yeah! Firewall always block you to access red5 port 5080 so please allow port 5080 & 1935 using below commands

$ gcutil addfirewall red5 –description=”Let open port 5080.” –allowed=”tcp:5080″

$ gcutil addfirewall rtmp –description=”Let open 1935 rtmp port.” –allowed=”tcp:1935″

$ sudo sh

Check Red5 is running

$ sudo netstat -ant
Find port 5080 Listening

Now try http://your-server-address:5080 in a web-browser.

Red5 on Google Compute Engine
Red5 on Google Compute Engine

Install oflaDemo from installer http://your-server-address:5080/installer/ then check 😉

Red5 Demo on Google Compute Engine - Port Tester
Red5 Demo on Google Compute Engine – Port Tester

Install Webmin on Google Compute Engine

$ sudo wget
$ sudo gunzip webmin-1.610.tar.gz
$ sudo tar xf webmin-1.610.tar
$ sudo cd webmin-1.610
$ sudo ./ /usr/local/webmin

Open port 10000 using gcutil addfirewall

$ gcutil addfirewall webmin –description=”Let coordinator and snitches chatter.” –allowed=”tcp:10000″

Install Apache, PHP, MySQL on Google Compute Engine

Hits: 13244  

I am so happy to get access for Google Compute Engine Limited Preview 🙂

Google Compute is a service that provides virtual machines on Google infrastructure. Google Compute (virtual machines with distributed computing power) provides some options that enable to configure, deploy, and manage multiple virtual machines in multiple data centers.

– Command-line tool called gcutil
– SSH Keys

Instructions on Installing and using gcutil; the command-line tool that is used to manage your Google Compute resources.

Run virtual machines at Google Scale

Google Compute Engine offers scalable and flexible virtual machine in the cloud to solve large scale processing and analytic problems on Google’s computing, storage, and networking infrastructure.

Google Compute Engine
Google Compute Engine

You need to generate your keys using ssh-keygen.. check more details here

Google Compute Engine - Add ssh Keys
Google Compute Engine – Add ssh Keys

You SSH Keys looks something like ….

ssh-rsa DfgdfeDFDFdghGHg ……………………..

Then you can login to server using Google Compute Engine’s external IP and PPK (Private key for authentication) file..


If all goes well you will get nice screen 😉

SSH Google Compute Engine using SSH Keys
SSH Google Compute Engine using SSH Keys

This is typical Ubuntu server and you can easily install Apache, PHP, MySQL here

First I tried “Hello World” Application provided in instructions

Before installing Apache you need to add port 80 to firewall 😉

$ gcutil addfirewall http2 –description=”Incoming http allowed.” –allowed=”tcp:http”
INFO: Waiting for asynchronous operation to complete. Current status: RUNNING. Sleeping for 5s.

$ gcutil getfirewall http2

Install Apache HTTP Server

$ sudo apt-get update

$ sudo apt-get install apache2

Install PHP & MySQL

$ sudo apt-get install apache2 mysql-server php5 php-pear php5-suhosin php5-mysql

$ sudo apt-get install php5 libapache2-mod-php5

Restart Apache

$ sudo /etc/init.d/apache2 restart

Install PHPMyAdmin

$ sudo apt-get install phpmyadmin

Follow steps for phpmyadmin 😉

Set mysql root password

$ mysql -u root

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);

Your Apache, PHP, MYSQL and phpMyAdmin is ready in Ubuntu on Google Compute Engine, start clouding….

Upgrade PHP 5.1 or 5.2 to 5.3 on CentOS

Hits: 6457  

CentOS 5.5 have PHP 5.2 whereas CentOS 5.6 have package PHP 5.3

Upgrade CentOS

# yum update

Upgrade PHP 5.2 to PHP 5.3

# yum list installed | grep php

Now check packages php53 available or not?

# yum search php53 | grep php

If above command return list of php53 packages .. then stop Apache

# service httpd stop

Remove old php

# yum remove php php-cli php-common php-devel php-gd php-mbstring php-curl …. and many more

Now install php53 available packages

# yum install php53 php53-cli php53-common php53-devel php53-gd php53-curl php53-json …. and many more

Then check new php version

# php -v

It will return PHP 5.3.x 🙂