Admins eHow SysAdmin Tips & Tricks

May 27, 2011

file_post_contents php function

Filed under: PHP — Tags: , , — admin @ 6:30 pm

This php function is useful when you want to send arguments by POST method instead of GET. very handy 😉
The usage is same as file_get_contents

function file_post_contents($url,$headers=false) {
    $url = parse_url($url);

    if (!isset($url['port'])) {
      if ($url['scheme'] == 'http') { $url['port']=80; }
      elseif ($url['scheme'] == 'https') { $url['port']=443; }


    $headers2 =  "POST ".$url['protocol'].$url['host'].$url['path']." HTTP/1.0".$eol. 
                "Host: ".$url['host'].$eol. 
                "Referer: ".$url['protocol'].$url['host'].$url['path'].$eol. 
                "Content-Type: application/x-www-form-urlencoded".$eol. 
                "Content-Length: ".strlen($url['query']).$eol.
    $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30); 
    if($fp) {
      fputs($fp, $headers2);
      $result = '';
      while(!feof($fp)) { $result .= fgets($fp, 128); }
      if (!$headers) {
        //removes headers
      return $result;

May 25, 2011

YouTube Monkeys

Filed under: General — admin @ 7:59 am

No Comments 😀

May 16, 2011

iPhone 4 awarded Guinness World Records – Poor Apple

Filed under: General — Tags: , , , , — admin @ 7:09 am

After market of smart phones is conquered by an army of Android phones and iOS market share is falling so fast,
I heard the news that iPhone 4 is awarded some Guinness Word Records , it seems a good news for fruit company fans at the first glance, but they should hope no one reads the full story 😀
Lets see what is the Record for : “Fastest-Selling Portable Gaming System” wtf ! and it is compared to PSP and Nintendo.

Guinness states that the iPhone 4’s first-day sales estimates of 1.5 million make it the fastest selling game system in history. By comparison the PSP only sold 200,000 units its first day and the Nintendo DS sold 600,000 units in its first week.

I guess fruit company should sue Guinness for this record because everyone was thinking iPhone is a smartphone and does not fall into the category of portable gaming systems ! lol
and now we may expect some new records for iPhone in near future :
The fastest selling portable internet TV ( cause you can watch youtube on it )
The fastest selling portable WC notification system ( cause it shows the place of public WC’s on the map )
and many more …
After fruit company shot itself in the leg by suing Samsung for some nonsense claims, now we see this desperate attempt to save iPhone.
I am sorry Steve, let me tell you what you should do to save iPhone market.
You should create an iPhone with Android OS on it , If I remember correctly it is what you have already done for your desktops and laptops after your share of desktop and laptop market dropped to nothing. right ?
you let users buy your products and install windows on it. that was a wise decision 🙂
Why don’t you learn a lesson from history ?

May 9, 2011

PayPal Online Subscription Link Generator

Filed under: General — Tags: , , , , — admin @ 10:59 am

Your PayPal E-mail:
Amount: USD

May 4, 2011

Backup Files or MySQL DBs to a remote FTP server with compression and encryption

Filed under: CentOS,Debian,General,linux,Security — Tags: , , , , , , , — admin @ 6:30 pm

After my previous article which explained how to backup MySQL DBs to an email address , I am going to provide a more perfect solution in this article 🙂
The previous solution had some drawbacks and some advantages but the biggest problem was about the size of backup. although we compress the data with bzip2 algorithm which provides a high level of compression but in many cases, the attachment size will exceed 25MB or the limit of your email box. so it can not be used with public email services or will need a personal email server.
a better solution is to backup the data to a remote FTP server. in this case we will have almost no limit on file size (depending on your remote FTP server).
A perfect place to backup your files is , it offers 500GB of space for free and FTP access to it ! it is awesome ! I would recommend to upgrade to their premium service.
click on this link to signup for your free account : Free Account
also we will employ encryption to make sure our data is safe in transmit and in remote location.
to use this solution make sure bzip2, mcrypt and ncftp are installed on your server. I am not going into the details of installing each package, Google is your friend 🙂
so lets say you want to backup /var/www folder, use the following command :

tar jcf - /var/www | mcrypt -k 'SOME_LONG_COMPLEX_KEY' |  ncftpput -c -u FTP_USER -p FTP_PASS FTP_HOST /PREFIX-`date +%Y%m%d`

this only command will compress the whole /var/www folder by tar and bzip2 at the same time encrypt it by your key and at the same time will upload it to remote FTP server !
omg ! thats why I love Linux ! you can put it in your crontab to create automatic backups.
now lets say you want to backup all MySQL DBs , you can use the following command :

mysqldump --user=USERNAME --password=PASSWORD -A | bzip2 | mcrypt -k 'SOME_LONG_COMPLEX_KEY' |  ncftpput -c -u FTP_USER -p FTP_PASS FTP_HOST /PREFIX-`date +%Y%m%d`

the combinations and possibilities are limitless !
I just gave you the idea and showed you the power, use your own brain to make your perfect solution 😉
Just something else , if you needed to decrypt the file , you can use the following command :


Powered by WordPress