Archive for August, 2013

Find out which services are using which ports

netstat -tulpn

[root@main www.ewea.org]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 95.142.174.150:10022        0.0.0.0:*                   LISTEN      1289/sshd
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      6325/mysqld
tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN      25106/perl
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      6360/vsftpd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      469/master
tcp        0      0 0.0.0.0:10080               0.0.0.0:*                   LISTEN      5944/monitorix-http
tcp        0      0 :::842                      :::*                        LISTEN      1247/xinetd
tcp        0      0 :::80                       :::*                        LISTEN      1750/httpd
tcp        0      0 ::1:25                      :::*                        LISTEN      469/master
udp        0      0 95.142.174.150:123          0.0.0.0:*                               1297/ntpd
udp        0      0 127.0.0.1:123               0.0.0.0:*                               1297/ntpd
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               1297/ntpd
udp        0      0 0.0.0.0:10000               0.0.0.0:*                               25106/perl
udp        0      0 2001:4b98:dc0:51:216:3ef:123 :::*                                    1297/ntpd
udp        0      0 ::1:123                     :::*                                    1297/ntpd
udp        0      0 fe80::216:3eff:fead:9e49:123 :::*                                    1297/ntpd
udp        0      0 :::123                      :::*                                    1297/ntpd

PHP cURL to save remote RSS feed to local xml file

Here’s a script I found to get a remote RSS feed, for example the Feedburner feed, and save it to a local XML file.
This would be useful for moments when you cannot connect to the RSS feed directly in a plugin or application.
You could then try and load the local file instead. Obviously a cron task would be added to run this script to reload the RSS feed a couple of times a day.

<?php
$ch = curl_init("http://feeds.feedburner.com/EWEABlog?format=xml");
$fp = fopen("feedburner.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

This script would then write the contents of the RSS feed to the local file “feedburner.xml”