Create ZIP archives with PHP script and PEAR class

We can use PEAR to process zip files in PHP using Archive_Zip…. First set PEAR path in php include path using set_include_path Make Zipped file <?php include (‘Archive/Zip.php’);        // include PEAR ZIP package $obj = new Archive_Zip(‘test.zip’);  // zipped file name $files = array(‘svnlabs/1.gif’, ‘svnlabs/resume.doc’, ‘svnlabs/invoice.xls’);   // files add to zip if ($obj->create($files)) { echo … Read more

Stream MP3 using PHP – m3u

M3U is a computer file format that stores multimedia playlists. <?php function m3u_stream($dir) { $mp3=””; $siteurl=”http://www.domain.com/mp3/”; $h1 = opendir($dir); while ($file = readdir($h1)) { if ($file == ‘.’ || $file == ‘..’) continue; $mp3.=$siteurl.basename($dir).”/”.$file.”\r\n”; } closedir($h1); return $mp3; } $folder = “svnlabs”; file_put_contents($folder.”.m3u”, m3u_stream($_SERVER[“DOCUMENT_ROOT”].”/mp3/”.$folder.”/”)); ?> Here “svnlabs” is a folder where all mp3 files exists… … Read more

How can we use PHP to access shared library functions?

PHP function dl() – Loads a PHP extension at runtime <?php // Example loading an extension based on OS if (!extension_loaded(‘svnlabs’)) { if (strtoupper(substr(PHP_OS, 0, 3)) === ‘WIN’) { dl(‘php_svnlabs.dll’); } else { dl(‘svnlabs.so’); } } // Or, the PHP_SHLIB_SUFFIX constant is available as of PHP 4.3.0 if (!extension_loaded(‘svnlabs’)) { $prefix = (PHP_SHLIB_SUFFIX === ‘dll’) ? ‘php_’ : ”; dl($prefix . ‘svnlabs.’ . PHP_SHLIB_SUFFIX); } ?> We can use linux “nm” or “objdump” command to list symbols in object files… # nm -C … Read more

Install libpurple with PHP

libpurple is intended to be the core of an IM program. This libpurple PHP binding, which defines a set of internal classes, gives a possibility to use aol and icq (oscar), yahoo, msn, jabber, irc and much more protocols directly from PHP. Write your own IM chat client in PHP, as simply as PHP enables … Read more

Session lost when switching from HTTP to HTTPS in PHP

Sometime we face the problem when we navigate from HTTP URL to HTTPS URL our session lost. You can manage session between HTTP to HTTPS or HTTPS to HTTP: 1. Transmit session ID between page using GET 2. POST session ID by POST 3. Use files to save sessions 4. Use Cookies for sessions 5. … Read more

FFmpeg

# ffmpeg is a command line tool to convert one video file format to another. It can also grab and encode in real time from a TV card. # ffserver is an HTTP and RTSP multimedia streaming server for live broadcasts. It can also time shift live broadcast. # ffplay is a simple media player … Read more

PHP – File Upload Stream

PHP supports upload file stream… we can stream data to server using PHP stream_open() & stream_write() functions. There is alternate method in PEAR to transfer files to server1 to server2. PEAR have HTTP package for uploading files. HTTP_Request supports GET/POST/HEAD/TRACE/PUT/DELETE, Basic authentication, Proxy, Proxy Authentication, SSL, file uploads etc. <?php require_once “HTTP/Request.php”; $req =& new HTTP_Request(“http://domain.com/upload”); $req->setBasicAuth(“login”, “pass”); $req->setMethod(HTTP_REQUEST_METHOD_POST); $result = $req->addFile(“data”, “/home/svnlabs.mp4”); … Read more

Linux Network Configuration

# system-config-network # redhat-config-network # vi /etc/resolve.conf # vi /etc/hosts # /sbin/ifconfig eth0 192.168.10.120 netmask 255.255.255.0 broadcast 192.168.10.255 # /etc/init.d/network restart ifup – bring a network interface up ifdown – take a network interface down

How to Create OpenSearch Plugins?

OpenSearch is a collection of simple formats for the sharing of search results. OpenSearch description file https://www.svnlabs.com/opensearch.xml We have to create  a simple xml file for websites and search engines to publish search results in a standard and accessible format. See below the code in action……. <?xml version=”1.0″ encoding=”UTF-8″?> <OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/”> <ShortName>svnlabs</ShortName> <LongName>svnlabs – Concentrate … Read more

Install the Alternative PHP Cache (APC)

The Alternative PHP Cache (APC) is a free, open, and robust framework for caching and optimizing PHP intermediate code. yum install php-pear yum install php-devel httpd-devel yum groupinstall ‘Development Tools’ yum groupinstall ‘Development Libraries’ pecl install apc http://si2.php.net/manual/en/install.pecl.php