Created
July 26, 2013 10:23
-
-
Save renekreijveld/6087846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# findjoomlas-csv -- Find Joomla instances on your (DirectAdmin based) server. Output as csv. | |
# Supports Joomla versions 1.0/1.5/1.6/1.7/2.5/3.0/3.1 | |
# | |
# usage: findjoomlas-csv > myjoomlasites.csv | |
# | |
# Copyright 2013 Rene Kreijveld - [email protected] | |
# | |
# This program is free software; you may redistribute it and/or modify it. | |
# Define variables | |
STARTDIR="/home" | |
JOOMLACONF=./configuration.php | |
VERSIONF1017=./includes/version.php | |
VERSIONF1516=./libraries/joomla/version.php | |
VERSIONF253031=./libraries/cms/version/version.php | |
# Grab Joomla 1.0 information | |
do_joomla10() | |
{ | |
# Grab information from Joomla 1.0 configuration. | |
sitename=`grep '$mosConfig_sitename =' ${JOOMLACONF}| cut -d \' -f 2` | |
database=`grep '$mosConfig_db =' ${JOOMLACONF} | cut -d \' -f 2` | |
dbuser=`grep '$mosConfig_user =' ${JOOMLACONF} | cut -d \' -f 2` | |
password=`grep '$mosConfig_password =' ${JOOMLACONF} | cut -d \' -f 2` | |
host=`grep '$mosConfig_host =' ${JOOMLACONF} | cut -d \' -f 2` | |
prefix=`grep '$mosConfig_dbprefix =' ${JOOMLACONF} | cut -d \' -f 2` | |
versr=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF1017} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF1017} | cut -d \' -f 2` | |
} | |
# Grab Joomla 1.5 information | |
do_joomla15() | |
{ | |
# Grab information from Joomla 1.5 configuration. | |
sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2` | |
database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2` | |
dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2` | |
password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2` | |
host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2` | |
prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2` | |
versr=`grep '$RELEASE' ${VERSIONF1516} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF1516} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF1516} | cut -d \' -f 2` | |
} | |
# Grab Joomla 1.6 information | |
do_joomla16() | |
{ | |
# Grab information from Joomla 1.6 configuration. | |
sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2` | |
database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2` | |
dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2` | |
password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2` | |
host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2` | |
prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2` | |
versr=`grep '$RELEASE' ${VERSIONF1516} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF1516} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF1516} | cut -d \' -f 2` | |
} | |
# Grab Joomla 1.7 information | |
do_joomla17() | |
{ | |
# Grab information from Joomla 1.5 configuration. | |
sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2` | |
database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2` | |
dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2` | |
password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2` | |
host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2` | |
prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2` | |
versr=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF1017} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF1017} | cut -d \' -f 2` | |
} | |
# Grab Joomla 2.5 information | |
do_joomla25() | |
{ | |
# Grab information from Joomla 2.5/3.0/3.1 configuration. | |
sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2` | |
database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2` | |
dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2` | |
password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2` | |
host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2` | |
prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2` | |
versr=`grep '$RELEASE' ${VERSIONF253031} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF253031} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF253031} | cut -d \' -f 2` | |
} | |
# Grab Joomla 3.0 information | |
do_joomla30() | |
{ | |
# Grab information from Joomla 2.5/3.0/3.1 configuration. | |
sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2` | |
database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2` | |
dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2` | |
password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2` | |
host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2` | |
prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2` | |
versr=`grep '$RELEASE' ${VERSIONF253031} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF253031} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF253031} | cut -d \' -f 2` | |
} | |
# Grab Joomla 3.1 information | |
do_joomla31() | |
{ | |
# Grab information from Joomla 2.5/3.0/3.1 configuration. | |
sitename=`grep '$sitename =' ${JOOMLACONF} | cut -d \' -f 2` | |
database=`grep '$db =' ${JOOMLACONF} | cut -d \' -f 2` | |
dbuser=`grep '$user =' ${JOOMLACONF} | cut -d \' -f 2` | |
password=`grep '$password =' ${JOOMLACONF} | cut -d \' -f 2` | |
host=`grep '$host =' ${JOOMLACONF} | cut -d \' -f 2` | |
prefix=`grep '$dbprefix =' ${JOOMLACONF} | cut -d \' -f 2` | |
versr=`grep '$RELEASE' ${VERSIONF253031} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF253031} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF253031} | cut -d \' -f 2` | |
} | |
# start output as csv | |
echo "\"versie\",\"site\",\"db\",\"dbuser\",\"dbpass\",\"dbhost\",\"prefix\"" | |
# search Joomla's | |
for dir in `find $STARTDIR -type d -name "public_html" -print` | |
do | |
if [ -f $dir/configuration.php ] | |
# possible joomla found | |
then | |
cd $dir | |
echo Possible Joomla found in $dir. | |
# Testing for Joomla version 1.0 or 1.7 | |
if [ -e ./includes/version.php ] | |
then | |
release=`grep '$RELEASE' ${VERSIONF1017} | cut -d \' -f 2` | |
if [ "$release" == "1.0" ] | |
then | |
do_joomla10 | |
fi | |
if [ "$release" == "1.7" ] | |
then | |
do_joomla17 | |
fi | |
fi | |
# Testing for Joomla version 1.5 en 1.6 | |
if [ -f ./libraries/joomla/version.php ] | |
then | |
release=`grep '$RELEASE' ${VERSIONF1516} | cut -d \' -f 2` | |
if [ "$release" == "1.5" ] | |
then | |
do_joomla15 | |
fi | |
if [ "$release" == "1.6" ] | |
then | |
do_joomla16 | |
fi | |
fi | |
# Testing for Joomla version 2.5, 3.0 and 3.1 | |
if [ -f ${VERSIONF253031} ] | |
then | |
release=`grep '$RELEASE' ${VERSIONF253031} | cut -d \' -f 2` | |
if [ "$release" == "2.5" ] | |
then | |
do_joomla25 | |
fi | |
if [ "$release" == "3.0" ] | |
then | |
do_joomla30 | |
fi | |
if [ "$release" == "3.1" ] | |
then | |
do_joomla31 | |
fi | |
fi | |
# Output information | |
echo "\"$versr.$versd $verss\",\"$sitename\",\"$database\",\"$dbuser\",\"$password\",\"$host\",\"$prefix\"" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment