Skip to content

Instantly share code, notes, and snippets.

@grok
Created April 28, 2014 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grok/11374717 to your computer and use it in GitHub Desktop.
Save grok/11374717 to your computer and use it in GitHub Desktop.
This script found all sites using certain CMS platforms on a server I used to manage. This is for historical purposes. Really old code I wrote. I don't want to get rid of it because it reminds me of a time long long ago when I broke more then I fixed without realizing it :)
#!/bin/bash
Colors() {
Escape="\033";
BlackF="${Escape}[30m"; RedF="${Escape}[31m"; GreenF="${Escape}[32m";
YellowF="${Escape}[33m"; BlueF="${Escape}[34m"; PurpleF="${Escape}[35m";
CyanF="${Escape}[36m"; WhiteF="${Escape}[37m";
BlackB="${Escape}[40m"; RedB="${Escape}[41m"; GreenB="${Escape}[42m";
YellowB="${Escape}[43m"; BlueB="${Escape}[44m"; PurpleB="${Escape}[45m";
CyanB="${Escape}[46m"; WhiteB="${Escape}[47m";
BoldOn="${Escape}[1m"; BoldOff="${Escape}[22m";
ItalicsOn="${Escape}[3m"; ItalicsOff="${Escape}[23m";
UnderlineOn="${Escape}[4m"; UnderlineOff="${Escape}[24m";
BlinkOn="${Escape}[5m"; BlinkOff="${Escape}[25m";
InvertOn="${Escape}[7m"; InvertOff="${Escape}[27m";
Reset="${Escape}[0m";
}
FindJoomla() {
clear && echo -e "${BoldOn}${GreenF}Searching For Joomla Websites...${Reset}";
JoomlaSiteList=`find /home/virtual -maxdepth 6 -regex '.*/html/pathway.php'`;
Paths=(${JoomlaSiteList});
printf "${BoldOn}%40s${BoldOff} ${BoldOn}%15s${BoldOff} ${BoldOn}%15s${BoldOff} ${BoldOn}%25s${BoldOff}\n" "Domain" "Product" "Version" "VirtueMart";
for Path in ${Paths[@]}
do
Site=${Path:14:${#Path}-43};
SiteDomainVariable=`grep '^\$mosConfig_live_site' /home/virtual/${Site}/fst/var/www/html/configuration.php`;
SiteDomain=${SiteDomainVariable:24};
SiteDomain=${SiteDomain:0:${#SiteDomain}-2};
Product=`grep '\$PRODUCT' /home/virtual/${Site}/fst/var/www/html/includes/version.php`;
Product=`expr match "${Product}" ".*\('[A-Z].*\)"`;
Product=${Product:1:${#Product}-3};
Version=`grep '\$RELEASE' /home/virtual/${Site}/fst/var/www/html/includes/version.php`;
Version=`expr match "${Version}" ".*\('[0-9].*\)"`;
Version=${Version:1:${#Version}-3};
SubVersion=`grep '\$DEV_LEVEL' /home/virtual/${Site}/fst/var/www/html/includes/version.php`;
SubVersion=`expr match "${SubVersion}" ".*\('[0-9].*\)"`;
SubVersion="."${SubVersion:1:${#SubVersion}-3};
ICanHazComponent=`ls /home/virtual/$Site/fst/var/www/html/administrator/components | grep 'com_virtuemart'`;
VirtueMartVersion="N/A";
if [ $ICanHazComponent ]
then
VirtueMartVersion=`grep '\$RELEASE' /home/virtual/$Site/fst/var/www/html/administrator/components/com_virtuemart/version.php`;
VirtueMartVersion=${VirtueMartVersion:17};
VirtueMartVersion=${VirtueMartVersion:0:${#VirtueMartVersion}-2};
fi
printf "${BlueF}%40s ${YellowF}%15s ${PurpleF}%15s${CyanF}%25s${Reset}\n" "${SiteDomain}" "${Product}" "${Version}${SubVersion}" "${VirtueMartVersion}";
done
echo -e "${BoldOn}${GreenF}Search Complete!${Reset}\n" && MainMenu;
}
FindXCart() {
clear && echo -e "${BoldOn}${GreenF}Searching For X-Cart Websites...${Reset}";
JoomlaSiteList=`find /home/virtual/ -maxdepth 7 -regex '.*/html/[^.]*/wysiwyg.php'`;
Paths=(${JoomlaSiteList});
printf "${BoldOn}%40s${BoldOff} ${BoldOn}%15s${BoldOff} ${BoldOn}%25s${BoldOff}\n" "Domain" "Product" "Version";
for Path in ${Paths[@]}
do
Site=${Path:14};
Site=`expr match ${Site} '\(....[0-9]*\)'`;
Store=${Path:0:${#Path}-12};
Store=`expr match ${Store} '.*\(/.*\)'`;
Store=${Store:1};
SiteDomainVariable=`grep '^$xcart_http_host' /home/virtual/${Site}/fst/var/www/html/${Store}/config.php`;
SiteDomain=${SiteDomainVariable:19};
SiteDomain=${SiteDomain:0:${#SiteDomain}-2};
Product='X-Cart';
Version=`grep '^Version' /home/virtual/$Site/fst/var/www/html/$Store/VERSION`;
Version=${Version:8};
printf "${BlueF}%40s ${YellowF}%15s ${PurpleF}%25s${Reset}\n" "${SiteDomain}" "${Product}" "${Version}";
done
echo -e "${BoldOn}${GreenF}Search Complete!${Reset}\n" && MainMenu;
}
Colors # Turn on colors!
MainMenu() {
MainMenu="${BoldOn}[Main Menu]${BoldOff}\n1) List All Joomla Sites\n2) List All X-Cart Sites\n3) Exit\n";
echo -e ${MainMenu} && echo "What would you like to do?" && read Option;
case $Option in
1) FindJoomla;;
2) FindXCart;;
3) clear; exit;;
*) clear;
echo -e "${BoldOn}${RedF}[Invalid Option]${Reset}\n";
MainMenu;;
esac
}
clear;
MainMenu;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment