<commit_before>#!/bin/bash

#An list of addresses to send the info.
EMAILS=(<EMAIL>)
#Path to the VestaCP command line tools.
VESTA_PATH=/usr/local/vesta/bin/
#Wildcard pattern for entering all sites.
DIRS=($1/*/web/*/public_html)
#The time is now.
NOW=$(date +"%m_%d_%Y")
#Name of the CSV file for lastpass
CSVFILE=users-$2-${NOW}.csv

#WordPress admin user
WP_ADMIN_USER=dev_adhus
WP_ADMIN_EMAIL=<EMAIL>

#Clear the CSV file
#Add the header
echo "url,type,username,password,hostname,extra,name,folder" > ${CSVFILE}

echo Dirs: ${DIRS[@]}
echo
for DIR in "${DIRS[@]}"
do
	FILE=$DIR/wp-config.php
	if [ -f $FILE ];
	then
		echo Changing passwords and secrets for: $DIR
		echo ------------------------------------------------------------------------------------------------------------------
		#Split the path by '/' to isolate user and domain
		REL_PATH=$(echo "$DIR" | rev | cut -d"/" -f1-5 | rev)
		DIR_PARTS=(${REL_PATH//\// })
		USER=${DIR_PARTS[0]}
		DOMAIN=${DIR_PARTS[2]}
		ADMIN_URL="http://$DOMAIN/wp-admin"

		PASS=($(openssl rand -base64 12))
		DB_PASS=($(openssl rand -base64 12))
		WP_ADMIN_PASS=($(openssl rand -base64 12))
		echo "Domain: $DOMAIN"
		echo "Admin URL: $ADMIN_URL"
		echo "VestaCP URL: $2:8083"
		echo "User: $USER"
		echo "New user password: $<PASSWORD>"
		echo "Database user: ${USER}_db"
		echo "New database password: $<PASSWORD>"
		echo "WordPress admin user: $WP_ADMIN_USER"
		echo "WordPress admin email: $WP_ADMIN_PASS"
		echo ------------------------------------------------------------------------------------------------------------------
		
		python2 change-wp-conf-secrets.py ${FILE} -u ${USER}_db -n ${USER}_db -p ${DB_PASS} -s -b
		if [ $? -ne 0 ]
		then
			echo "ERROR: Failed updating $FILE"
		fi
		echo
		echo "Changing user and database user using Vesta."
		${VESTA_PATH}v-change-user-password $USER $PASS
		if [ $? -ne 0 ]
		then
			echo "ERROR: Failed changing user password"
		fi
		${VESTA_PATH}v-change-database-password ${USER} ${USER}_db ${DB_PASS}
		if [ $? -ne 0 ]
		then
			echo "ERROR: Failed changing database password"
		fi
		#Export CSV data for user and database
		echo "$2:8083,,$USER,$PASS,$DOMAIN,,$DOMAIN user,Vesta & FTP users" >> ${CSVFILE}
		echo "$2:3306,,${USER}_db,$DB_PASS,$DOMAIN,,$DOMAIN database user,Database users" >> ${CSVFILE}
		
		#Get the table prefix.
		head -n -2 ${FILE} > wp-config.php.tmp
		echo "echo \$table_prefix; ?>" >> wp-config.php.tmp
		TABLE_PREFIX=$(php wp-config.php.tmp)
		rm wp-config.php.tmp
		echo
		echo "WordPress database table prefix: ${TABLE_PREFIX}"	
		
		echo
		echo "WordPress users: "
		echo "SELECT * FROM ${TABLE_PREFIX}users" | mysql -u root ${USER}_db
		
		echo<commit_msg>Use phpmyadmin as target URL for DB users<commit_after>#!/bin/bash

#An list of addresses to send the info.
EMAILS=(<EMAIL>)
#Path to the VestaCP command line tools.
VESTA_PATH=/usr/local/vesta/bin/
#Wildcard pattern for entering all sites.
DIRS=($1/*/web/*/public_html)
#The time is now.
NOW=$(date +"%m_%d_%Y")
#Name of the CSV file for lastpass
CSVFILE=users-$2-${NOW}.csv

#WordPress admin user
WP_ADMIN_USER=dev_adhus
WP_ADMIN_EMAIL=<EMAIL>

#Clear the CSV file
#Add the header
echo "url,type,username,password,hostname,extra,name,folder" > ${CSVFILE}

echo Dirs: ${DIRS[@]}
echo
for DIR in "${DIRS[@]}"
do
	FILE=$DIR/wp-config.php
	if [ -f $FILE ];
	then
		echo Changing passwords and secrets for: $DIR
		echo ------------------------------------------------------------------------------------------------------------------
		#Split the path by '/' to isolate user and domain
		REL_PATH=$(echo "$DIR" | rev | cut -d"/" -f1-5 | rev)
		DIR_PARTS=(${REL_PATH//\// })
		USER=${DIR_PARTS[0]}
		DOMAIN=${DIR_PARTS[2]}
		ADMIN_URL="http://$DOMAIN/wp-admin"

		PASS=($(openssl rand -base64 12))
		DB_PASS=($(openssl rand -base64 12))
		WP_ADMIN_PASS=($(openssl rand -base64 12))
		echo "Domain: $DOMAIN"
		echo "Admin URL: $ADMIN_URL"
		echo "VestaCP URL: $2:8083"
		echo "User: $USER"
		echo "New user password: $<PASSWORD>"
		echo "Database user: ${USER}_db"
		echo "New database password: $<PASSWORD>"
		echo "WordPress admin user: $WP_ADMIN_USER"
		echo "WordPress admin email: $WP_ADMIN_PASS"
		echo ------------------------------------------------------------------------------------------------------------------
		
		python2 change-wp-conf-secrets.py ${FILE} -u ${USER}_db -n ${USER}_db -p ${DB_PASS} -s -b
		if [ $? -ne 0 ]
		then
			echo "ERROR: Failed updating $FILE"
		fi
		echo
		echo "Changing user and database user using Vesta."
		${VESTA_PATH}v-change-user-password $USER $PASS
		if [ $? -ne 0 ]
		then
			echo "ERROR: Failed changing user password"
		fi
		${VESTA_PATH}v-change-database-password ${USER} ${USER}_db ${DB_PASS}
		if [ $? -ne 0 ]
		then
			echo "ERROR: Failed changing database password"
		fi
		#Export CSV data for user and database
		echo "$2:8083,,$USER,$PASS,$DOMAIN,,$DOMAIN user,Vesta & FTP users" >> ${CSVFILE}
		echo "$2/phpmyadmin,,${USER}_db,$DB_PASS,$DOMAIN,,$DOMAIN database user,Database users" >> ${CSVFILE}
		
		#Get the table prefix.
		head -n -2 ${FILE} > wp-config.php.tmp
		echo "echo \$table_prefix; ?>" >> wp-config.php.tmp
		TABLE_PREFIX=$(php wp-config.php.tmp)
		rm wp-config.php.tmp
		echo
		echo "WordPress database table prefix: ${TABLE_PREFIX}"	
		
		echo
		echo "WordPress users: "
		echo "SELECT * FROM ${TABLE_PREFIX}users" | mysql -u root ${USER}_db
		
		echo
{'fraction_non_alphanumeric': 0.22735674676524953, 'fraction_numerical': 0.013308687615526803, 'mean_word_length': 2.7342995169082127, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '493082', 'n_tokens_mistral': 2070, 'n_tokens_neox': 1852, 'n_words': 530}