Posts By: jonny

Apache DirectoryMatch for Intranet-Style Access

I needed to ensure that within a rather large directory structure any directory named ‘intranet’ was only accessible by internal IP addresses. Although from a security perspective this is not truly intranet it can help protect some pages./var/www/vhosts/mydomain/httpdocs/ represents the DocumentRoot for the virtual host.  This will protect /any/path/with/intranet/in/the/name – so intranet is in there… Read more »

Install RealPlayer on Ubuntu (9.04)

I wanted to try out Real Player on a radio station stream so … Visit: http://www.real.com/linux Click the Deb download link and Open with the GDebi Package Installer as prompted. The installer may pause so click the ‘Terminal’ arrow and type 1 then press enter Run Real Player from the menu ‘Sound & Video’  

Easy Peasy on the eeepc

I decided to have a play installing Easy Peasy on the 7″ eeepc I borrowed from my sister.Setting it up was quite easy:1. Download the iso (at a whopping 800Mb)2. Download the helper script, make it executable and run it3. Choose the iso and specify a USB drive to install the easy peasy live distribution… Read more »

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 »