Tmpwatch – recursively delete files

If you are a Linux administrator, then you certainly need tool to delete old files – especially old backup files or /tmp directory. Here comes tmpwatch. With parameter time and path, tmpwatch will recursively delete all files older then a given time. But if you use NetBackup, then you might have a problem with deleting files.

From MySQL to HTML with PHP and XML

In my post “From MySQL to XML with PHP”, I described how to generate XML from the MySQL database. Instead of printing out XML, generated XML can be buffered and transformed with XSL to the HTML. Maybe it sounds complicated for a simple process of displaying MySQL data on the WEB page. But if you set a WEB architecture this way, you will have a separated presentation layer from the database and business logic.

Fedora VPN client and routing

This post is second part of “Configuring VPN client”. After completion steps in previous post, VPN will work with starting pppd and manually adding route. With a few PHP lines and configuration of ip-up.local file, VPN connection can be automated and reduced to only one script.

Yum install mplayer in Fedora

After upgrade to the Fedora Core 10 and Fedora Core 12, I was surprised when ‘yum install mplayer’ didn’t find any package. I’m sure yum worked in Fedora Core 9 with installed Livna repository. I checked my Livna configuration once again, but there was no luck with mplayer. Something has definitely changed in the meantime.

Write to a log file with PHP

After writing custom PHP “log” function several times I finally decided to create a simple Logging PHP class. First call of lwrite method will open log file implicitly and write line to the file. Every other lwrite will use already opened file pointer until closing file with lclose. It is always a good idea to close file when it’s done. This should prevent file from corruption and overhead in closing file is negligible.

Sending checkbox values with JavaScript

This example shows how to collect values from the checked checkboxes. JavaScript function uses getElementsByTagName method to collect all input objects of the HTML page (HTML form is not needed). With for loop, every collected object is tested against type and checked property. If type is checkbox and checkbox is checked then value will be concatenated to the final string.

From MySQL to XML with PHP

PHP XML generator can be written in less then 100 lines. In this example, data from the MySQL database are converted to the XML. PHP function sql2xml has optional second parameter to describe the XML hierarchy, while first parameter is SQL query. Second parameter is string in form of integers separated by commas.

PHP Web server monitor

With this simple PHP script, you’ll be able to monitor the availability of Web servers. Write a list of URLs to monitor and run the script from cron. If a site becomes unavailable, monitor PHP script will generate alert and send e-mail to the default e-mail address. Monitor script is also able to send e-mail message to the various e-mail address (e-mail address per URL).

Configuring VPN client

In this post you can read how to configure the VPN client in Fedora Core 10. I tried to configure VPN client in NetworkManager, but there was no success. I turned off NetworkManager with chkconfig and uncheck Controlled by NetworkManager in system-config-network. In my case, VPN server is on Microsoft platform, so my domain name must precede the user name.

Linux upgrade in a few hours

If your work is organized in a way to have all documents inside /home partition and e-mails on remote server then you have qualities for easy upgrade to the new Linux desktop. Easy upgrade means to have a fully functional Linux desktop in a few hours. Is it installation or upgrade? Well, technically I will write about installation, but it will look like an upgrade.

Clear form with JavaScript

JavaScript is the only option, if you want to have the ability to clear all form fields. Yes, HTML form has Reset method, but if the form has initial values, then Reset will return the form to the initial state instead of clear input fields. In this post you will find clearForms JavaScript function and live demo.

Moving WordPress

In few steps, WordPress can be moved to another host. Idea is to move complete installation from public host to local host. Why? Because this way you will have test and production site. Test site isn’t public and you can play and try some modifications before publishing. Posts can be written locally, and after finishing, just perform copy & paste from test to production site.