Posts By: jonny

Shell Script: Search for Strings in Web Files

I used this shell script to search through some web directories for references to particular strings – just for future reference.The find command only greps in html, php and pdf files: the -o switch is an OR. #!/bin/bashPATHTOSEARCH=/path/to/webrootFIND=/usr/bin/findNICE=/bin/nicePATTERN=’Media,1234,en.pdf|Media,1235,en.pdf|Media,1236,en.pdf’ $NICE $FIND $PATHTOSEARCH -type f \( -name ‘*.html’ -o -name ‘*.php’ -o -name ‘*.htm’ -o -name ‘*.pdf’… Read more »

Shell Script: Search Apache Logs

This shell script is for future reference. Used to copy zip apache log files into a temporary directory by day/month. Log files are unzipped and then searched for the strings we are looking for. It could be tidied up! #!/bin/bashPATHTOLOGS=/mypath/to/logs/wwwWORKINGDIR=/tmplogsYEAR=2009MONTHS=(2009-01 2009-02 2009-03 2009-04 2009-05 2009-06 2009-07 2009-08 2009-09)for MONTH in ${MONTHS[@]}dofor LOGFILE in $(ls $PATHTOLOGS/$YEAR/$MONTH-??.access_log.gz)… Read more »

Example robots.txt

Not all crawlers obey all of these rules but as a reference point. The crawl delay is the number of seconds between requests and the newer request-rate is set here to not more than 1 every 5 seconds. The crawlers are also asked to visit during the night. User-agent: *Disallow: /media/Crawl-delay: 10Request-rate: 1/5Visit-time: 2100-0545

Printing Random Array Elements in PHP and Javascript

Non-dynamic tag cloud?  <script language=”JavaScript” type=”text/javascript”>                                var mytags = new Array(                                “histories”,”names”,                                “land”,”lists”,”free”                                );                                var randomseed=Math.floor(Math.random()*8)                                for(i=0;i<mytags.length;i++){                                        var randomnumber=Math.floor(Math.random()*141)                                        randomnumber=randomnumber+40;                                        if(randomnumber%randomseed!=0){                                        document.write(“<a style=’font-size:”+ randomnumber +”%;’>”+ mytags[i] + “</a> “);                                        }                                }                        </script> <?php$input = array(“histories”,”names”,                                “land”,”lists”,”free”);$rand_keys = array_rand($input, 30);for($i;$i<30;$i++){$randomnumber=rand(40,181);echo “<a style=’font-size:”.$randomnumber.”%;’>”.$input[$rand_keys[$i]] . “</a>\n”;}?>

Apache LDAP Authentication to Active Directory

I was testing authentication against Active Directory (LDAP) using Apache 2. The following worked for me in a .htaccess file but only after adding: LDAPVerifyServerCert Off in the main httpd.conf file. I presume this is related to the server name in the SSL certificate on the Active Directory server. AuthBasicProvider ldapAuthzLDAPAuthoritative OffAuthLDAPURL ldaps://adserver.prefix.tld.co.uk:636/DC=prefix,DC=tld,DC=co,DC=uk?sAMAccountName?sub?(objectClass=user)AuthLDAPBindDN “CN=someuser,OU=some ou,OU=another… Read more »

Windows 7

Having a look at Windows 7 and coming from using Ubuntu solidly for the last 4 years I find it just as irritating as Vista – but I need to give it a bit more time to form an unbiased opinion.From a personal perspective there are some things I prefer for my own usability: Quick… Read more »

PHP, Pear, PECL and UploadProgress

I had need to use the UploadProgress and SMTP Mail PECL PHP extensions so a brief overview: Check pear is installed and working: # which pear To get a list of help/commands: # pear help Run the updates: # pear channel-update pear.php.net Show the installed packages: # pear list This will install the Mail package… Read more »

MySQL 4 to MySQL 5 Character Sets and Collation

Moving from MySQL 4 to MySQL 5 caused a few issues on Joomla websites. The problems stem from MySQL 4 using latin1 swedish as default but some applications like Joomla want utf8 so: 1. Re-export the database (it is Ok to do this from the existing MySQL 5 database): mysqldump -u username -p –default-character-set=latin1 –compatible=mysql40… Read more »

Ubuntu Desktop Showing Home Folder Contents

I was playing with a shell script to rename a bunch of image files to lowercase then resize them but I had a typo in one of my variables resulting in accidentally renaming all the folders in my home directory with lowercase names. After next log in I now see the home folder contents displayed… Read more »

Joomla 1.5 – Customising

A few minor notes on changing some of the text in Joomla 1.5: Welcome to the FrontageIn the Admin Control Panel go to Menus > Main Menu > Home > Parameters – System > Page Title. Footer TextIn the Admin Control Panel go to Extensions > Template Manager > Template Name > Edit HTMLIn the… Read more »