Last active
December 6, 2018 13:53
-
-
Save renekreijveld/6079281 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 -- Find Joomla instances on your (DirectAdmin based) server. | |
# Supports Joomla versions 1.0/1.5/1.6/1.7/2.5/3.0/3.1/3.2/3.2 | |
# | |
# Copyright 2014 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 | |
VERSIONF25303132=./libraries/cms/version/version.php | |
# process the arguments | |
short="no" | |
while getopts s opt | |
do | |
case "$opt" in | |
s) short="yes";; | |
esac | |
done | |
# 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' ${VERSIONF25303132} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF25303132} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF25303132} | cut -d \' -f 2` | |
} | |
# Grab Joomla 3.x information | |
do_joomla3x() | |
{ | |
# 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' ${VERSIONF25303132} | cut -d \' -f 2` | |
versd=`grep '$DEV_LEVEL' ${VERSIONF25303132} | cut -d \' -f 2` | |
verss=`grep '$DEV_STATUS' ${VERSIONF25303132} | cut -d \' -f 2` | |
} | |
for dir in `find $STARTDIR -maxdepth 4 -type d -name "public_html"` | |
do | |
if [ -f $dir/configuration.php ]; then | |
# possible joomla found | |
cd $dir | |
if [ "$short" == "yes" ]; then | |
echo $dir | |
else | |
echo Possible Joomla found in $dir | |
fi | |
if [ "$short" == "no" ]; then | |
# 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 ${VERSIONF25303132} ]; then | |
release=`grep '$RELEASE' ${VERSIONF25303132} | cut -d \' -f 2` | |
if [ "$release" == "2.5" ] | |
then | |
do_joomla25 | |
fi | |
if [ "$release" == "3.0" ] | |
then | |
do_joomla3x | |
fi | |
if [ "$release" == "3.1" ] | |
then | |
do_joomla3x | |
fi | |
if [ "$release" == "3.2" ] | |
then | |
do_joomla3x | |
fi | |
if [ "$release" == "3.3" ] | |
then | |
do_joomla3x | |
fi | |
fi | |
# Output information | |
echo -e "Joomla information found:" | |
echo -e "Sitename : $sitename" | |
echo -e "Version : $versr.$versd $verss" | |
echo -e "DB Name : $database" | |
echo -e "DB User : $dbuser" | |
echo -e "DB Password : $password" | |
echo -e "DB Host : $host" | |
echo -e "DB Prefix : $prefix\n" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment