Open source – Port25

If you have trouble getting the PHP’s mail() function to work on your server. If the function returned true, but never send the emails to target account. Some ISP’s block port 25 (mail port), so you can’t send directly but you can send indirectly using your ISP’s mail server. 😉 Many email providers keep lists … Read more

How to create subaccounts and share buckets using IAM and CloudBerry S3 Explorer

Note: this post applies to CloudBerry Explorer 2.4.2 and later. As always we are trying to stay on top of the new functionality offered by Amazon S3 to offer the most compelling Amazon S3 and CloudFront client on Windows platform. A few weeks ago Amazon introduced Identity and Authentication Management (IAM) Service. It is a … Read more

Run Shell Commands from CGI-BIN

Hey, here are some simple steps to run shell commands under cgi-bin using Apache web server (/var/www/cgi-bin), which is configured with cgi access. Apache CGI allows files with executable permission in cgi-bin directory treated as application and run on web browsers. We have to send the MIME type before outputting data to the web from … Read more

Create WebThumb using LAMP

We have to install opera/firefox  first on server. Then install Xvfb for Xvfb virtual framebuffer html2image.sh ………………………. #! /bin/sh /etc/init.d/xvfb start export DISPLAY=:7 DISPLAY=:7 opera –remote ‘openURL(‘$1′)’ & sleep 20 DISPLAY=:7  import -window root $2 /etc/init.d/xvfb stop Uses: # ./html2image.sh  https://www.svnlabs.com   webthumb/svnlabs.png Open FireFox in Xvfb: firefox.sh #!/bin/sh mozilla-firefox -a firefox -remote ‘openURL(‘$1′, new-tab)’ || … 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

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

No route to host

Often, when we get error “No route to host” to connect remote server via linux command line e.g. wget, curl etc. or web services (webserviceserver). The first solution we want to try to troubleshot firewalls and proxies? But before that try hostname entry in linux box… # vi /etc/hosts add & save 192.168.0.100 webserviceserver If … Read more

Backup mysql database to amazon S3

Below is the simple code to create sql script of database on Amazon EC2 server using “mysqldump”… then upload this sql script to Amazon S3 bucket using command line S3 tool “s3cmd”… <?php $sqlbackup=”/usr/bin/mysqldump -v -u root -h localhost -r /var/www/html/backup/”.date(“Y-m-d-H-i-s”).”_db.sql -pdbusername  databasename 2>&1″; exec($sqlbackup, $o); echo implode(“<br /> “, $o); $file = “/var/www/html/backup/”.date(“Y-m-d-H-i-s”).”_db.sql”; $bucket = “s3bucketname”; exec(“/usr/bin/s3cmd  put –acl-public –guess-mime-type  –config=/var/www/html/.s3cfg   “.$file.”  s3://”.$bucket.”  2>&1″, $o); echo implode(“<br /> “, $o); ?> 0 */12 * * * env php -q /var/www/html/s3bkup/s3bkup.php > /dev/null 2>&1 (per 12 … Read more