#!/bin/bash
VER='0.08'
#################################################
# written by George Liu (eva2000) vbtechsupport.com
# partially based on queries provided by Wayne Luke
# https://www.vbulletin.com/forum/showthread.php/393317-Site-Hacked
#################################################
# Instructions
##########
# 1). Edit MYSQLUSER and MYSQLPASS variables for mysql root user/pass
# 2). Edit DBNAME for vBulletin database name
# 3). Edit DBPREFIX for tableprefix if set in vB config.php
# 4). Chmod 700 vbplugincheck.sh script
# 5). Within SSH telnet window as root user run vbplugincheck.sh script
#	./vbplugincheck.sh
#
#      You'll get a list of possible options to run
#	./vbplugincheck.sh quick (summary format output of plugin, template, announcement & phrase table matches)
#	./vbplugincheck.sh full (full format output of plugin, template, announcement & phrase table matches)
#	./vbplugincheck.sh quick {dbname} {dbprefix} (similar to above except you can specify database name)
#	./vbplugincheck.sh full {dbname} {dbprefix} (similar to above except you can specify database name)
#	./vbplugincheck.sh adminlogfull (output full adminlog with human readable dateline)
#	./vbplugincheck.sh adminloguser (output filter on user.php adminlog human readable dateline)
#	./vbplugincheck.sh adminlogtemp (output filter on template.php adminlog human readable dateline)
#	./vbplugincheck.sh adminlogactions (output filter on specific actions i.e. edit, insert, add, modify)
#	./vbplugincheck.sh adminlogfull {dbname} {dbprefix}
#	./vbplugincheck.sh adminloguser {dbname} {dbprefix}
#	./vbplugincheck.sh adminlogtemp {dbname} {dbprefix}
#	./vbplugincheck.sh adminlogactions {dbname} {dbprefix}
#	./vbplugincheck.sh qkeyword (manual prompt for search term you enter yourself output quick summary format)
#	./vbplugincheck.sh fkeyword (manual prompt for search term you enter yourself output full format)
#	./vbplugincheck.sh tempcheck {dbname} {dbprefix} (list template table entries by dateline)
#	./vbplugincheck.sh temphistcheck {dbname} {dbprefix} (list templatehistory table entries by dateline)
#	./vbplugincheck.sh usertitle (list usertitles check for malicious code)
#	./vbplugincheck.sh ads (list ad html snippets check for malicious code)
#	./vbplugincheck.sh usertitle {dbname} {dbprefix}
#	./vbplugincheck.sh ads {dbname} {dbprefix}
#	./vbplugincheck.sh ranks (list user rank code for html code in ranking field)
#	./vbplugincheck.sh ranks {dbname} {dbprefix}
#	./vbplugincheck.sh setting (check setting table value field for code ie. %script% for js scripts)
#	./vbplugincheck.sh setting {dbname} {dbprefix}
#	./vbplugincheck.sh pluginlist (output pluginlist code content fully or filtered on keyword at prompt)
#	./vbplugincheck.sh pluginlist {dbname} {dbprefix}
#	./vbplugincheck.sh customtitle (check users who have custom usertitles for %script% and %iframe%)
#	./vbplugincheck.sh customtitle {dbname} {dbprefix}
#	./vbplugincheck.sh pmtitle (check pm titles + pm text for keywords for specific spam pms)
#	./vbplugincheck.sh pmtitle {dbname} {dbprefix}
#	./vbplugincheck.sh pmtext  (check pm titles for keywords for specific spam pms)
#	./vbplugincheck.sh pmtext {dbname} {dbprefix}
#################################################
VBVERSION='4' # for vB 4.x or enter '5' for vB 5.x

# your mysql server hostname set
# in vB config.php 
# $config['MasterServer']['servername'] =
MYSQLHOST='localhost'

# mysql username/password
MYSQLUSER='yourmysqlusername'
MYSQLPASS='yourmysqlpassword'

# your database name
# vB config.php
# $config['Database']['dbname'] = 
DBNAME='vbdatabasename'

# if you set table prefix in vB config.php
# $config['Database']['tableprefix'] =
DBPREFIX=''

# vB config.php full path
# to find what you set
# in vB admincp > Language Manage -> Edit settings -> HTML Character Set
# VBCONFIGPATH='/full/path/to/your/vbforum/includes/config.php'

#####################

if [ -z $MYSQLPASS ]; then
MYSQLADMINOPT=''
else
MYSQLADMINOPT="-u$MYSQLUSER -p$MYSQLPASS -h $MYSQLHOST"
fi

#####################

pmtitlesearch() {

echo
read -ep "Enter keyword to search for i.e. %KEYWORD% : " KEYWORD
echo

echo "---------------------------------------------------------------------"
echo "   check setting tables value for %${KEYWORD}%"
echo "---------------------------------------------------------------------"
echo "return userid, username, pm title"

mysql $MYSQLADMINOPT -N -e "SELECT fromuserid, fromusername, title FROM ${DBPREFIX}pmtext WHERE message LIKE '%${KEYWORD}%' AND title LIKE '%${KEYWORD}%';" $DBNAME | grep -v '+-' | sort -u

}

pmtextsearch() {

echo
read -ep "Enter keyword to search for i.e. %KEYWORD% : " KEYWORD
echo

echo "---------------------------------------------------------------------"
echo "   check setting tables value for %${KEYWORD}%"
echo "---------------------------------------------------------------------"
echo "return userid, username, pm title"

mysql $MYSQLADMINOPT -N -e "SELECT fromuserid, fromusername, title FROM ${DBPREFIX}pmtext WHERE message LIKE '%${KEYWORD}%';" $DBNAME | grep -v '+-' | sort -u

}

#####################
pluginlistkeysearch() {

echo
read -ep "Do you want to do a filtered keyword search [y] or full output of pluginlist [n] ? : " keysearch

if [[ "$keysearch" = [yY] ]]; then

echo
read -ep "Enter keyword to search for i.e. %base64% or %preg_replace% : " KEYWORD
echo

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}datastore WHERE title='pluginlist'\G;" $DBNAME | grep $KEYWORD

else

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}datastore WHERE title='pluginlist'\G;" $DBNAME

fi
}

#####################

quickvaluekeysearch() {

echo
read -ep "Enter keyword to search for i.e. %script% or %refresh : " KEYWORD
echo

echo "---------------------------------------------------------------------"
echo "   check setting tables value for ${KEYWORD}"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}setting WHERE value LIKE '${KEYWORD}' OR optioncode LIKE '${KEYWORD}'\G;" $DBNAME | awk '/varname:/; /grouptitle/; /value/; /displayorder/; /optioncode/'
}

#####################
# list user ranks
getranklist() {
echo

mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}ranks ORDER BY rankid ASC\G" $DBNAME
}

# list usertitles
usertitlelist() {
echo

mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}usertitle ORDER BY usertitleid ASC" $DBNAME
}

# list customtitles
customtitlelist() {
echo

mysql $MYSQLADMINOPT -t -e "SELECT userid, usergroupid, username, usertitle, customtitle FROM ${DBPREFIX}user WHERE customtitle=1 AND usertitle LIKE '%script%' OR usertitle LIKE '%iframe%' ORDER BY userid ASC" $DBNAME
}

#list ad html snippets
adhtmllist() {
echo

mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}ad ORDER BY adid ASC\G" $DBNAME
}

#####################

#template table
tempdateline() {
echo
echo "---------------------------------------------------------------------"
echo "   Show template table data ordered by dateline"
echo "---------------------------------------------------------------------"
echo

mysql $MYSQLADMINOPT -t -e "SELECT templateid,styleid,title,username,dateline FROM ${DBPREFIX}template ORDER BY dateline ASC" $DBNAME | grep -ev '--' |awk -F '|' '{print "templateid:"$2, "styleid:"$3, "title:"$4, "username:"$5, "["strftime("%c",$6)"]"}' | tr -s ' ' 
}

#template history table
temphistdateline() {
echo
echo "---------------------------------------------------------------------"
echo "   Show templatehistory table data ordered by dateline"
echo "---------------------------------------------------------------------"
echo

mysql $MYSQLADMINOPT -t -e "SELECT templatehistoryid,styleid,title,username,dateline,comment FROM ${DBPREFIX}templatehistory ORDER BY dateline ASC" $DBNAME | grep -ev '--' |awk -F '|' '{print "templatehistoryid:"$2, "styleid:"$3, "title:"$4, "username:"$5, "["strftime("%c",$6)"]", "comment:"$7}' | tr -s ' ' 
}

#####################

fullkeysearch() {

echo
read -ep "Enter keyword to search for i.e. %refresh or %base64% : " KEYWORD
echo

echo "---------------------------------------------------------------------"
echo "   check templates for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title, template FROM ${DBPREFIX}template WHERE template LIKE '$KEYWORD'\G;" $DBNAME


echo "---------------------------------------------------------------------"
echo "   check templatehistory for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title, template FROM ${DBPREFIX}templatehistory WHERE template LIKE '$KEYWORD'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check announcement tables for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '$KEYWORD'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check phrase table for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '$KEYWORD'\G;" $DBNAME

if [[ "$VBVERSION" = '5' ]]; then

echo "---------------------------------------------------------------------"
echo "   check productcode for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '$KEYWORD'\G;" $DBNAME

fi

if [[ "$VBVERSION" = '4' ]]; then

echo "---------------------------------------------------------------------"
echo "   check plugins for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product, phpcode FROM ${DBPREFIX}plugin WHERE phpcode LIKE '$KEYWORD'\G;" $DBNAME

fi

echo
}

#####################
quickkeysearch() {

echo
read -ep "Enter keyword to search for i.e. %refresh or %base64% : " KEYWORD
echo

echo "---------------------------------------------------------------------"
echo "   check templates for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template LIKE '$KEYWORD'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq


echo "---------------------------------------------------------------------"
echo "   check templatehistory for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '$KEYWORD'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check announcement tables for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '$KEYWORD'\G;" $DBNAME | awk '/announcementid:/; /title/; /userid/'

echo "---------------------------------------------------------------------"
echo "   check phrase table for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '$KEYWORD'\G;" $DBNAME | awk '/phraseid:/; /languageid/; /varname:/; /username/; /dateline/'

if [[ "$VBVERSION" = '5' ]]; then

echo "---------------------------------------------------------------------"
echo "   check productcode for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '$KEYWORD'\G;" $DBNAME | awk '/productcodeid:/; /productid/'

fi

if [[ "$VBVERSION" = '4' ]]; then

echo "---------------------------------------------------------------------"
echo "   check plugins for $KEYWORD code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product FROM ${DBPREFIX}plugin WHERE phpcode LIKE '$KEYWORD'\G;" $DBNAME | awk '/title:/; /hookname/; /product/'

fi

echo
}

#####################
#template.php filter
getadminlogtemp() {
echo

mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}adminlog ORDER BY adminlogid ASC;" $DBNAME | grep -v '-' | grep template.php |awk -F '|' '{print "adminlogid:"$2, "userid:"$3, "["strftime("%c",$4)"]", "script:"$5, "action:"$6, "extrainfo: ["$7"]", "ip:"$8}' | tr -s ' '
}

#user.php filter
getadminloguser() {
echo

mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}adminlog ORDER BY adminlogid ASC;" $DBNAME | grep -v '-' | grep user.php |awk -F '|' '{print "adminlogid:"$2, "userid:"$3, "["strftime("%c",$4)"]", "script:"$5, "action:"$6, "extrainfo: ["$7"]", "ip:"$8}' | tr -s ' '
}

#full log
getfulladminlog() {
echo

mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}adminlog ORDER BY adminlogid ASC;" $DBNAME | grep -v '-' |awk -F '|' '(NR>1) {print "adminlogid:"$2, "userid:"$3, "["strftime("%c",$4)"]", "script:"$5, "action:"$6, "extrainfo: ["$7"]", "ip:"$8}' | tr -s ' ' 
}

# filter on actions
getactionadminlog() {
echo

#mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}adminlog ORDER BY adminlogid ASC;" $DBNAME | grep -v '-' |egrep '(modify|kill|find|delete|prune|remove|update|add|doimport|files|insert|edit)' | awk -F '|' '(NR>1) {print "adminlogid:"$2, "userid:"$3, "["strftime("%c",$4)"]", "script:"$5, "action:"$6, "extrainfo: ["$7"]", "ip:"$8}' | tr -s ' ' 

mysql $MYSQLADMINOPT -t -e "SELECT * FROM ${DBPREFIX}adminlog ORDER BY adminlogid ASC;" $DBNAME | grep -v '-' | awk -F '|' '(NR>1) {print "adminlogid:"$2, "userid:"$3, "["strftime("%c",$4)"]", "script:"$5, "action:"$6, "extrainfo: ["$7"]", "ip:"$8}' | tr -s ' ' 

}

function okaytemplates {

if [[ "$VBVERSION" = '4' ]]; then

cat <<EOF

---------------------------------------------------------------------
   %iframe% match should only be in the following templates: 
---------------------------------------------------------------------
	bbcode_video
	editor-ie.css
	help_bbcodes
	humanverify_recaptcha
	member.css
	search_common
	search_common_select_type
	stylegenerator.css
	vbcms.css
	vbulletin.css
---------------------------------------------------------------------

---------------------------------------------------------------------
   %exec% match should only be in the phrase table varname: 
---------------------------------------------------------------------
   varname: task_blog_cleanup_desc
   varname: task_blog_pending_desc
   varname: task_blog_views_desc
   varname: blog_search_executed
   varname: widgettype_vbcms_execphp
   varname: skimlinks_time_limit_note
   varname: cronadmin_add_edit_active_text
   varname: diagnostic_text
   varname: misc_text
   varname: notice_add_edit_criteria_text
   varname: options_options_imagetype_text
   varname: options_options_regimagetype_text
   varname: plugin_productedit_installcode_text
   varname: plugin_productedit_uninstallcode_text
   varname: queries_text
   varname: queries_title
   varname: queries_modify_title
   varname: queries_modify_autoquery_text
   varname: queries_modify_query_text
   varname: queries_modify_perpage_text
   varname: repair_text
   varname: template_search_regex_text
   varname: clipboard.copyError
   varname: clipboard.cutError
   varname: execute_sql_query
   varname: logged_in_user_x_executed_y_queries
   varname: task_activitypopularity_desc
   varname: faq_text_not_safe
   varname: no_permission_queries
   varname: php_error_exec_disabled
   varname: php_error_unspecified_exec
   varname: phrase_text_not_safe
   varname: variables_missing_suhosin
   varname: plugin_execution_order
   varname: plugin_order_desc
   varname: an_error_occured_while_attempting_to_run_your_query
   varname: auto_query
   varname: confirm_query_execution
   varname: execute_sql_query
   varname: manual_query
   varname: template_text_not_safe

---------------------------------------------------------------------

---------------------------------------------------------------------
   %system% match should only be in the phrase table varname: 
---------------------------------------------------------------------

   varname: blog_admin_tags_tagtext_text
   varname: options_options_vbblog_tagging_text
   varname: vbblog_faq
   varname: convert_blog_attachments_desc
   varname: featured_entries_warning
   varname: setting_vbblog_tagcloud_searchhistory_desc
   varname: setting_vbblog_tagging_desc
   varname: no_edit_permissions
   varname: cannot_add_cms
   varname: vbcms_faq
   varname: setting_skimlinks_allow_user_disable_desc
   varname: setting_forumrunner_cms_onoff_desc
   varname: accessmask_text
   varname: accessmask_quickedit_text
   varname: admincalendar_text
   varname: admincalendar_add_edit_showholidays_text
   varname: admininfraction_text
   varname: adminreputation_text
   varname: announcement_text
   varname: attachment_text
   varname: attachment_stats_text
   varname: attachment_storage_switchtype_text
   varname: attachment_storage_switchtype_title
   varname: attachment_switchtype_attachpath_text
   varname: avatar_text
   varname: avatar_storage_switchtype_text
   varname: avatar_storage_switchtype_title
   varname: avatar_switchtype_avatarpath_text
   varname: avatar_switchtype_profilepicpath_text
   varname: avatar_switchtype_sigpicpath_text
   varname: bbcode_text
   varname: bookmarksite_modify_text
   varname: cronadmin_text
   varname: diagnostic_text
   varname: diagnostic_dosysinfo_text
   varname: diagnostic_dosysinfo_title
   varname: diagnostic_list_text
   varname: diagnostic_list_type_text
   varname: faq_text
   varname: image_text
   varname: language_text
   varname: language_add_edit_settings_locale_text
   varname: navigation_add_edit_scripts_text
   varname: notice_modify_tableheader_text
   varname: options_options_checkcoppa_title
   varname: options_options_pc_enabled_text
   varname: options_options_rpforumid_text
   varname: options_options_taggoodwords_text
   varname: options_options_uiforumid_text
   varname: options_options_webmasteremail_text
   varname: options_options_usestrikesystem_title
   varname: options_options_threadtagging_text
   varname: options_options_loadlimit_text
   varname: options_options_usemailqueue_title
   varname: options_options_usecoppa_text
   varname: options_options_usecoppa_title
   varname: options_options_usereferrer_text
   varname: options_options_reputationenable_text
   varname: options_options_reputationenable_title
   varname: options_options_mqlimit_text
   varname: options_options_quickreply_text
   varname: options_options_activememberdays_text
   varname: options_options_enablehooks_text
   varname: options_options_enablehooks_title
   varname: phrase_text
   varname: plugin_productedit_dependencytype_text
   varname: resources_text
   varname: rssposter_edit_threadactiondelay_text
   varname: socialgroup_icon_switchtype_groupiconpath_text
   varname: socialgroup_icon_switchtype_groupiconurl_text
   varname: template_add_edit_title_text
   varname: thread_tags_tagtext_text
   varname: user_text
   varname: user_prune_title
   varname: usergroup_text
   varname: usergroup_add_edit_canseeownrep_text
   varname: usergroup_add_edit_canhiderep_text
   varname: usertitle_text
   varname: usertools_referrers_text
   varname: verify_intro_text
   varname: album_pictures_currently_file_system_with_thumb
   varname: album_pictures_currently_file_system_without_thumb
   varname: attachment_removal
   varname: attachments_are_currently_being_stored_in_the_filesystem_at_x
   varname: avatars_are_currently_being_served_from_the_filesystem_at_x
   varname: file_removal
   varname: keep_pictures_file_system_allow_thumb
   varname: keep_pictures_file_system_disable_thumb
   varname: move_items_from_database_into_filesystem
   varname: move_items_from_filesystem_into_database
   varname: move_pictures_into_file_system_with_thumb
   varname: move_pictures_into_file_system_without_thumb
   varname: move_pictures_within_file_system
   varname: pictures_moved_database_count_xyz
   varname: pictures_moved_file_system_count_xyz
   varname: pictures_moved_thumbnails_disabled_count_xyz
   varname: pictures_moved_thumbnails_enabled_count_xyz
   varname: profilepics_are_currently_being_served_from_the_filesystem_at_x
   varname: ready_move_pictures_file_system_options
   varname: sigpics_are_currently_being_served_from_the_filesystem_at_x
   varname: we_are_ready_to_attempt_to_move_your_attachments_from_database_to_filesystem
   varname: we_are_ready_to_attempt_to_move_your_attachments_from_filesystem_to_database
   varname: we_are_ready_to_attempt_to_move_your_images_from_database_to_filesystem
   varname: we_are_ready_to_attempt_to_move_your_images_from_filesystem_to_database
   varname: api_disabled_options
   varname: cache_cleared
   varname: clear_system_cache
   varname: here_you_may_edit_forum_access_on_a_user_by_user_basis
   varname: no_cache_clean
   varname: system
   varname: you_did_not_specify_a_file_to_upload
   varname: this_action_is_not_reversible
   varname: this_system_allows_you_to_mass_move_delete_users
   varname: user_moving_pruning_system
   varname: system_information
   varname: sendtofriend
   varname: attachments_moved_to_the_filesystem
   varname: attachments_not_moved_to_the_filesystem
   varname: attachpathfailed
   varname: images_moved_to_the_filesystem
   varname: nopermission_loggedin
   varname: nopermission_loggedin_ajax
   varname: pictures_moved_to_the_file_system
   varname: pictures_moved_within_the_file_system
   varname: pictures_not_moved_to_the_file_system
   varname: pictures_not_moved_within_the_file_system
   varname: product_requires_plugin_system
   varname: reputationdisabled
   varname: upload_file_system_is_not_writable
   varname: upload_file_system_is_not_writable_path
   varname: your_server_has_safe_mode_enabled
   varname: vb3_contact_members
   varname: vb3_notifications
   varname: vb3_private_messages
   varname: vb3_register
   varname: vb3_smilies
   varname: vb3_tags
   varname: show_private_forum
   varname: may_not_have_sufficient_privileges
   varname: to_maintain_compatibility_with_the_system_name_changed
   varname: locale
   varname: system_architecture
   varname: vbulletin_table_prefix_rename_system
   varname: msn_functions_only_work_in_ie
   varname: plugin_products_system
   varname: plugin_system
   varname: plugins_disabled_options
   varname: group_icons_are_currently_being_served_from_the_filesystem_at_x
   varname: move_group_icons_from_database_into_filesystem
   varname: move_group_icons_from_filesystem_into_database
   varname: we_are_ready_to_attempt_to_move_your_group_icons_from_database_to_filesystem
   varname: we_are_ready_to_attempt_to_move_your_group_icons_from_filesystem_to_database
   varname: fix_unique_indexes_intro
   varname: here_you_can_select_which_forums_the_user
   varname: setting_authorizenet_authorize_md5secret_desc
   varname: setting_authorizenet_txnkey_desc
   varname: browsing_when_receive_pm_popup
   varname: features_private_messaging_system
   varname: features_visitor_messaging_system
   varname: use_asset_manager
   varname: setting_attachfile_desc
   varname: setting_checkcoppa_title
   varname: setting_checknewpm_desc
   varname: setting_codemaxlines_desc
   varname: setting_cp_collapse_forums_desc
   varname: setting_emailsendnum_desc
   varname: setting_enablehooks_desc
   varname: setting_enablehooks_title
   varname: setting_enablepms_desc
   varname: setting_errorlogemail_desc
   varname: setting_externalcache_desc
   varname: setting_externaljs_desc
   varname: setting_externalrss_desc
   varname: setting_externalxml_desc
   varname: setting_ignorequotechars_desc
   varname: setting_postlog_maxage_desc
   varname: setting_quickreply_desc
   varname: setting_recheckfrequency_desc
   varname: setting_reputationenable_desc
   varname: setting_reputationenable_title
   varname: setting_sitemap_path_desc
   varname: setting_tagcloud_searchhistory_desc
   varname: setting_threadtagging_desc
   varname: setting_usecoppa_desc
   varname: setting_usecoppa_title
   varname: setting_usemailqueue_title
   varname: setting_usereferrer_desc
   varname: setting_usestrikesystem_desc
   varname: setting_usestrikesystem_title
   varname: settinggroup_plugin

---------------------------------------------------------------------

---------------------------------------------------------------------
   %iframe% match should only be in the phrase table varname: 
---------------------------------------------------------------------

       fakeobjects.iframe
       iframe.noUrl
       iframe.title
       iframe.toolbar

---------------------------------------------------------------------

EOF

fi

if [[ "$VBVERSION" = '5' ]]; then

cat <<EOF

---------------------------------------------------------------------
   %base64% match should only be in the following templates: 
---------------------------------------------------------------------
	css_responsive.css
---------------------------------------------------------------------

---------------------------------------------------------------------
   %exec% match should only be in the following templates: 
---------------------------------------------------------------------
	STANDARD_REDIRECT
---------------------------------------------------------------------

---------------------------------------------------------------------
   %system% match should only be in the following templates: 
---------------------------------------------------------------------
	widget_privatemessage_search
	widget_privatemessage_navigation
	conversation_toolbar
	color_style.css
	conversation_toolbar
	header
---------------------------------------------------------------------

---------------------------------------------------------------------
   %iframe% match should only be in the following templates: 
---------------------------------------------------------------------
	css_sitebuilder.css
	css_reset.css
	css_jquery-ui-1_8_14_custom.css
	css_global.css
	css_editor.css
	color_style.css
	header
	bbcode_video
---------------------------------------------------------------------

---------------------------------------------------------------------
   %exec% match should only be in the phrase table varname: 
---------------------------------------------------------------------

   varname: template_search_regex_text
   varname: repair_text
   varname: queries_text
   varname: queries_title
   varname: queries_modify_title
   varname: queries_modify_autoquery_text
   varname: queries_modify_query_text
   varname: queries_modify_perpage_text
   varname: plugin_productedit_uninstallcode_text
   varname: plugin_productedit_installcode_text
   varname: options_options_regimagetype_text
   varname: options_options_imagetype_text
   varname: notice_add_edit_criteria_text
   varname: misc_text
   varname: diagnostic_text
   varname: cronadmin_add_edit_active_text
   varname: clipboard.copyError
   varname: clipboard.cutError
   varname: after_upgrade_from_4
   varname: execute_sql_query_gcpglobal
   varname: logged_in_user_x_executed_y_queries
   varname: faq_text_not_safe
   varname: im_exec_error_x
   varname: no_permission_queries
   varname: php_error_exec_disabled
   varname: php_error_unspecified_exec
   varname: phrase_text_not_safe
   varname: template_text_not_safe
   varname: variables_missing_suhosin
   varname: hook_execution_order
   varname: hook_order_desc
   varname: an_error_occurred_while_attempting_to_run_your_query
   varname: auto_query
   varname: confirm_query_execution
   varname: execute_sql_query_gsql
   varname: manual_query

---------------------------------------------------------------------

---------------------------------------------------------------------
   %system% match should only be in the phrase table varname: 
---------------------------------------------------------------------

   varname: usergroup_text
   varname: user_prune_title
   varname: user_text
   varname: thread_tags_tagtext_text
   varname: template_add_edit_title_text
   varname: socialgroup_icon_switchtype_groupiconurl_text
   varname: socialgroup_icon_switchtype_groupiconpath_text
   varname: rssposter_edit_threadactiondelay_text
   varname: resources_text
   varname: plugin_productedit_dependencytype_text
   varname: phrase_text
   varname: options_options_enablehooks_title
   varname: options_options_enablehooks_text
   varname: options_options_mqlimit_text
   varname: options_options_usecoppa_title
   varname: options_options_usecoppa_text
   varname: options_options_usemailqueue_title
   varname: options_options_loadlimit_text
   varname: options_options_threadtagging_text
   varname: options_options_usestrikesystem_title
   varname: options_options_webmasteremail_text
   varname: options_options_taggoodwords_text
   varname: options_options_rpforumid_text
   varname: options_options_pc_enabled_text
   varname: options_options_checkcoppa_title
   varname: options_options_album_thumbsize_text
   varname: notice_modify_tableheader_text
   varname: language_add_edit_settings_locale_text
   varname: language_text
   varname: image_text
   varname: faq_text
   varname: diagnostic_list_type_text
   varname: diagnostic_list_text
   varname: diagnostic_dosysinfo_title
   varname: diagnostic_dosysinfo_text
   varname: diagnostic_text
   varname: cronadmin_text
   varname: bookmarksite_modify_text
   varname: bbcode_text
   varname: avatar_switchtype_sigpicpath_text
   varname: avatar_switchtype_avatarpath_text
   varname: avatar_switchtype_profilepicpath_text
   varname: avatar_storage_switchtype_title
   varname: avatar_storage_switchtype_text
   varname: avatar_text
   varname: attachment_storage_switchtype_title
   varname: attachment_switchtype_attachpath_text
   varname: attachment_storage_switchtype_text
   varname: attachment_stats_text
   varname: attachment_text
   varname: announcement_text
   varname: album_storage_text
   varname: adminreputation_text
   varname: admininfraction_text
   varname: accessmask_text
   varname: usergroup_add_edit_canhiderep_text
   varname: usertitle_text
   varname: usertools_referrers_text
   varname: verify_intro_text
   varname: attachment_removal
   varname: attachments_are_currently_being_stored_in_the_filesystem_at_x
   varname: avatars_are_currently_being_served_from_the_filesystem_at_x
   varname: file_removal
   varname: move_items_from_database_into_filesystem
   varname: move_items_from_filesystem_into_database
   varname: profilepics_are_currently_being_served_from_the_filesystem_at_x
   varname: sigpics_are_currently_being_served_from_the_filesystem_at_x
   varname: we_are_ready_to_attempt_to_move_your_attachments_from_database_to_filesystem
   varname: we_are_ready_to_attempt_to_move_your_attachments_from_filesystem_to_database
   varname: we_are_ready_to_attempt_to_move_your_images_from_database_to_filesystem
   varname: we_are_ready_to_attempt_to_move_your_images_from_filesystem_to_database
   varname: api_disabled_options
   varname: clear_system_cache
   varname: here_you_may_edit_channel_access_on_a_user_by_user_basis
   varname: system
   varname: you_did_not_specify_a_file_to_upload
   varname: this_action_is_not_reversible
   varname: this_system_allows_you_to_mass_move_delete_users
   varname: user_moving_pruning_system
   varname: system_information
   varname: sendtofriend
   varname: attachments_moved_to_the_filesystem
   varname: attachments_not_moved_to_the_filesystem
   varname: attachpathfailed
   varname: images_moved_to_the_filesystem
   varname: invalid_filecache_location
   varname: invalid_page_url
   varname: need_filecache_location
   varname: nopermission_loggedin
   varname: nopermission_loggedin_ajax
   varname: upload_file_system_is_not_writable
   varname: upload_file_system_is_not_writable_path
   varname: your_server_has_safe_mode_enabled
   varname: account_privatemessages_gfaqtext
   varname: account_settings_gfaqtext
   varname: albums_posted_photos_gfaqtext
   varname: bbcode_basic_gfaqtext
   varname: bbcode_smilies_gfaqtext
   varname: content_messages_gfaqtext
   varname: show_private_forum
   varname: cannot_add_system_module
   varname: cannot_remove_system_module
   varname: feature_not_implemented
   varname: pm_ajax_error_desc
   varname: site_terms_and_rules
   varname: thanks_for_signing_up_log_in
   varname: to_maintain_compatibility_with_the_system_name_changed
   varname: hook_products_system
   varname: hooks_disabled_options
   varname: hooks_system
   varname: locale
   varname: cache_cleared
   varname: system_architecture
   varname: vbulletin_table_prefix_rename_system
   varname: msn_functions_only_work_in_ie
   varname: fix_unique_indexes_intro
   varname: here_you_can_select_which_forums_the_user
   varname: setting_authorizenet_authorize_md5secret_desc
   varname: setting_authorizenet_txnkey_desc
   varname: usersetting_vm_desc
   varname: setting_attachfile_desc
   varname: setting_checkcoppa_title
   varname: setting_checknewpm_desc
   varname: setting_codemaxlines_desc
   varname: setting_cp_collapse_forums_desc
   varname: setting_emailsendnum_desc
   varname: setting_enablehooks_desc
   varname: setting_enablehooks_title
   varname: setting_enablepms_desc
   varname: setting_errorlogemail_desc
   varname: setting_externalcache_desc
   varname: setting_externaljs_desc
   varname: setting_externalrss_desc
   varname: setting_externalxml_desc
   varname: setting_ignorequotechars_desc
   varname: setting_recheckfrequency_desc
   varname: setting_sitemap_path_desc
   varname: setting_tagcloud_searchhistory_desc
   varname: setting_threadtagging_desc
   varname: setting_usecoppa_desc
   varname: setting_usecoppa_title
   varname: setting_usemailqueue_title
   varname: setting_usestrikesystem_desc
   varname: setting_usestrikesystem_title
   varname: settinggroup_plugin

---------------------------------------------------------------------

---------------------------------------------------------------------
   %iframe% match should only be in the phrase table varname: 
---------------------------------------------------------------------

       bbcode_media_gfaqtext

---------------------------------------------------------------------

EOF

fi

}

function quickcheck {

if [[ "$VBVERSION" = '4' ]]; then

echo "---------------------------------------------------------------------"
echo "   check plugins for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%base64%'\G;" $DBNAME | awk '/title:/; /hookname/; /product/'

echo "---------------------------------------------------------------------"
echo "   check plugins for eval()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%eval%'\G;" $DBNAME | awk '/title:/; /hookname/; /product/'

echo "---------------------------------------------------------------------"
echo "   check plugins for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%exec%'\G;" $DBNAME | awk '/title:/; /hookname/; /product/'

echo "---------------------------------------------------------------------"
echo "   check plugins for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%system%'\G;" $DBNAME | awk '/title:/; /hookname/; /product/'

echo "---------------------------------------------------------------------"
echo "   check plugins for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product FROM ${DBPREFIX}plugin WHERE phpcode like '%pass_thru%'\G;" $DBNAME | awk '/title:/; /hookname/; /product/'

echo "---------------------------------------------------------------------"
echo "   check plugins for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product FROM ${DBPREFIX}plugin WHERE phpcode like '%iframe%'\G;" $DBNAME | awk '/title:/; /hookname/; /product/'

fi

if [[ "$VBVERSION" = '5' ]]; then

echo "---------------------------------------------------------------------"
echo "   check productcode for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '%base64%'\G;" $DBNAME | awk '/productcodeid:/; /productid/'

echo "---------------------------------------------------------------------"
echo "   check productcode for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '%exec%'\G;" $DBNAME | awk '/productcodeid:/; /productid/'

echo "---------------------------------------------------------------------"
echo "   check productcode for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '%system%'\G;" $DBNAME | awk '/productcodeid:/; /productid/'

echo "---------------------------------------------------------------------"
echo "   check productcode for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode like '%pass_thru%'\G;" $DBNAME | awk '/productcodeid:/; /productid/'

echo "---------------------------------------------------------------------"
echo "   check productcode for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode like '%iframe%'\G;" $DBNAME | awk '/productcodeid:/; /productid/'

fi

if [[ "$VBVERSION" = '4' ]]; then

echo "---------------------------------------------------------------------"
echo "   check templates for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template LIKE '%base64%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates  for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template LIKE '%exec%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template LIKE '%system%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates  for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template like '%pass_thru%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template like '%iframe%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

fi

if [[ "$VBVERSION" = '5' ]]; then

echo "---------------------------------------------------------------------"
echo "   check templates for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template LIKE '%base64%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates  for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template LIKE '%exec%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template LIKE '%system%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates  for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template like '%pass_thru%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templates for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title FROM ${DBPREFIX}template WHERE template like '%iframe%'\G;" $DBNAME | awk '/templateid:/; /styleid:/; /title:/' | uniq

fi

if [[ "$VBVERSION" = '4' ]]; then

echo "---------------------------------------------------------------------"
echo "   check templatehistory for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%base64%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%exec%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%system%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%pass_thru%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%iframe%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

fi

if [[ "$VBVERSION" = '5' ]]; then

echo "---------------------------------------------------------------------"
echo "   check templatehistory for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%base64%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%exec%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%system%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%pass_thru%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

echo "---------------------------------------------------------------------"
echo "   check templatehistory for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%iframe%'\G;" $DBNAME | awk '/templatehistoryid:/; /styleid:/; /title:/' | uniq

fi

echo "---------------------------------------------------------------------"
echo "   check announcement tables for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '%base64%'\G;" $DBNAME | awk '/announcementid:/; /title/; /userid/'

echo "---------------------------------------------------------------------"
echo "   check announcement tables for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '%exec%'\G;" $DBNAME | awk '/announcementid:/; /title/; /userid/'

echo "---------------------------------------------------------------------"
echo "   check announcement tables for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '%system%'\G;" $DBNAME | awk '/announcementid:/; /title/; /userid/'

echo "---------------------------------------------------------------------"
echo "   check announcement tables for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext like '%pass_thru%'\G;" $DBNAME | awk '/announcementid:/; /title/; /userid/'

echo "---------------------------------------------------------------------"
echo "   check announcement tables for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext like '%iframe%'\G;" $DBNAME | awk '/announcementid:/; /title/; /userid/'

echo "---------------------------------------------------------------------"
echo "   check phrase table for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '%base64%'\G;" $DBNAME | awk '/phraseid:/; /languageid/; /varname:/; /username/; /dateline/'

echo "---------------------------------------------------------------------"
echo "   check phrase tables for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '%exec%'\G;" $DBNAME | awk '/phraseid:/; /languageid/; /varname:/; /username/; /dateline/'

echo "---------------------------------------------------------------------"
echo "   check phrase tables for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '%system%'\G;" $DBNAME | awk '/phraseid:/; /languageid/; /varname:/; /username/; /dateline/'

echo "---------------------------------------------------------------------"
echo "   check phrase tables for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text like '%pass_thru%'\G;" $DBNAME | awk '/phraseid:/; /languageid/; /varname:/; /username/; /dateline/'

echo "---------------------------------------------------------------------"
echo "   check phrase tables for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text like '%iframe%'\G;" $DBNAME | awk '/phraseid:/; /languageid/; /varname:/; /username/; /dateline/'

}

##############################

function fullcheck {

if [[ "$VBVERSION" = '4' ]]; then

echo "---------------------------------------------------------------------"
echo "   check plugins for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product, phpcode FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%base64%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check plugins for eval()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product, phpcode FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%eval%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check plugins for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product, phpcode FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%exec%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check plugins for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product, phpcode FROM ${DBPREFIX}plugin WHERE phpcode LIKE '%system%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check plugins for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product, phpcode FROM ${DBPREFIX}plugin WHERE phpcode like '%pass_thru%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check plugins for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT title, hookname, product, phpcode FROM ${DBPREFIX}plugin WHERE phpcode like '%iframe%'\G;" $DBNAME

fi

if [[ "$VBVERSION" = '5' ]]; then

echo "---------------------------------------------------------------------"
echo "   check productcode for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '%base64%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check productcode for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '%exec%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check productcode for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode LIKE '%system%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check productcode for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode like '%pass_thru%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check productcode for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT productcodeid, productid, version, installcode, uninstallcode FROM ${DBPREFIX}productcode WHERE installcode like '%iframe%'\G;" $DBNAME

fi

echo "---------------------------------------------------------------------"
echo "   check templates for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title, template FROM ${DBPREFIX}template WHERE template LIKE '%base64%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templates  for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title, template FROM ${DBPREFIX}template WHERE template LIKE '%exec%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templates for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title, template FROM ${DBPREFIX}template WHERE template LIKE '%system%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templates  for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title, template FROM ${DBPREFIX}template WHERE template like '%pass_thru%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templates for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templateid, styleid, title, template FROM ${DBPREFIX}template WHERE template like '%iframe%'\G;" $DBNAME

if [[ "$VBVERSION" = '4' ]]; then

echo "---------------------------------------------------------------------"
echo "   check templatehistory for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%base64%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%exec%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%system%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%pass_thru%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%iframe%'\G;" $DBNAME

fi

if [[ "$VBVERSION" = '5' ]]; then

echo "---------------------------------------------------------------------"
echo "   check templatehistory for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%base64%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%exec%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template LIKE '%system%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory  for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%pass_thru%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check templatehistory for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT templatehistoryid, styleid, title FROM ${DBPREFIX}templatehistory WHERE template like '%iframe%'\G;" $DBNAME

fi

echo "---------------------------------------------------------------------"
echo "   check announcement tables for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '%base64%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check announcement tables for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '%exec%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check announcement tables for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext LIKE '%system%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check announcement tables for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext like '%pass_thru%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check announcement tables for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}announcement WHERE pagetext like '%iframe%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check phrase table for base64 code"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '%base64%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check phrase tables for exec()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '%exec%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check phrase tables for system()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text LIKE '%system%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check phrase tables for pass_thru()"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text like '%pass_thru%'\G;" $DBNAME

echo "---------------------------------------------------------------------"
echo "   check phrase tables for iframe"
echo "---------------------------------------------------------------------"

mysql $MYSQLADMINOPT -e "SELECT * FROM ${DBPREFIX}phrase WHERE text like '%iframe%'\G;" $DBNAME

}

if [[ ! -z "$2" ]]; then
	DBNAME=$2
	DBPREFIX=$3
fi

#####################

CHECKVBVER=$(mysql $MYSQLADMINOPT -e "SHOW TABLES LIKE '%plugin'\G;" $DBNAME)

if [[ -z "$CHECKVBVER" ]]; then
	VBVERSION='5'
else
	VBVERSION='4'
fi

#####################

case "$1" in
quick)

	okaytemplates
	quickcheck

;;
full)

	okaytemplates
	fullcheck

;;
adminlogfull)
	getfulladminlog
;;
adminloguser)
	getadminloguser
;;
	adminlogtemp)
	getadminlogtemp
;;
adminlogactions)
	getactionadminlog
;;
qkeyword)
	quickkeysearch
;;
fkeyword)
	fullkeysearch
;;
tempcheck)
	tempdateline
;;
temphistcheck)
	temphistdateline
;;
usertitle)
	usertitlelist
;;
ads)
	adhtmllist
;;
ranks)
	getranklist
;;
setting)
	quickvaluekeysearch
;;
pluginlist)
	pluginlistkeysearch
;;
customtitle)
	customtitlelist
;;
pmtitle)
	pmtitlesearch
;;
pmtext)
	pmtextsearch
;;
*)

	echo "$0 quick"
	echo "$0 full"
	echo "$0 quick {dbname} {dbprefix}"
	echo "$0 full {dbname} {dbprefix}"
	echo "$0 adminlogfull"
	echo "$0 adminloguser"
	echo "$0 adminlogtemp"
	echo "$0 adminlogactions"
	echo "$0 adminlogfull {dbname} {dbprefix}"
	echo "$0 adminloguser {dbname} {dbprefix}"
	echo "$0 adminlogtemp {dbname} {dbprefix}"
	echo "$0 adminlogactions {dbname} {dbprefix}"
	echo "$0 qkeyword"
	echo "$0 fkeyword"
	echo "$0 qkeyword {dbname} {dbprefix}"
	echo "$0 fkeyword {dbname} {dbprefix}"
	echo "$0 tempcheck"
	echo "$0 temphistcheck"
	echo "$0 tempcheck {dbname} {dbprefix}"
	echo "$0 temphistcheck {dbname} {dbprefix}"
	echo "$0 usertitle"
	echo "$0 ads"
	echo "$0 usertitle {dbname} {dbprefix}"
	echo "$0 ads {dbname} {dbprefix}"
	echo "$0 ranks"
	echo "$0 ranks {dbname} {dbprefix}"
	echo "$0 setting"
	echo "$0 setting {dbname} {dbprefix}"
	echo "$0 pluginlist"
	echo "$0 pluginlist {dbname} {dbprefix}"
	echo "$0 customtitle"
	echo "$0 customtitle {dbname} {dbprefix}"
	echo "$0 pmtitle"
	echo "$0 pmtitle {dbname} {dbprefix}"
	echo "$0 pmtext"
	echo "$0 pmtext {dbname} {dbprefix}"
;;
esac
exit