Panormitis
Verified User
- Joined
- Sep 13, 2014
- Messages
- 37
Hello,
When phpMyAdmin is not set to be public and the user clicks the Logout link, a blank page is displayed with the text "Access to phpMyAdmin is only allowed from control panel.". This doesn't look nice, it could be planned better.
Also, information_schema database doesn't have to be displayed.
Unless I'm doing something wrong and these two things are already addressed, I think they should be.
For now I have created a hook post script to address these two issues by hiding them. Feel free to use the script if you find it useful.
Add it to /usr/local/directadmin/custombuild/custom/hooks/phpmyadmin/post give a name (in my case editphpmyadmin.sh) and 700 permissions.
When phpMyAdmin is not set to be public and the user clicks the Logout link, a blank page is displayed with the text "Access to phpMyAdmin is only allowed from control panel.". This doesn't look nice, it could be planned better.
Also, information_schema database doesn't have to be displayed.
Unless I'm doing something wrong and these two things are already addressed, I think they should be.
For now I have created a hook post script to address these two issues by hiding them. Feel free to use the script if you find it useful.
Add it to /usr/local/directadmin/custombuild/custom/hooks/phpmyadmin/post give a name (in my case editphpmyadmin.sh) and 700 permissions.
Bash:
#!/bin/bash
# Search for the required files (case insensitive search, just to cover all possibilities).
CONFIG_FILE=$(find /var/www/html -ipath '*/phpMyAdmin-*/config.inc.php' 2>/dev/null)
CSS_FILE=$(find /var/www/html -ipath '*/phpMyAdmin-*/themes/pmahomme/css/theme.css' 2>/dev/null)
# Check if CONFIG_FILE was found, do not proceed otherwise.
if [ -z "$CONFIG_FILE" ]; then
echo "Required file(s) not found, changes aborted!"
exit 1
fi
# Check if CSS_FILE was found, do not proceed otherwise.
if [ -z "$CSS_FILE" ]; then
echo "Required file(s) not found, changes aborted!"
exit 1
fi
# Define the lines to be added or replaced.
HIDE_DB_LINE="\$cfg['Servers'][\$i]['hide_db'] = 'information_schema|performance_schema|mysql';"
SHOW_LOGOUT_LINE="\$cfg['ShowLogout'] = false;"
CSS_LINE="div#pma_navigation div#navipanellinks a.logout { display: none !important; }"
# Check if the hide_db line already exists.
if grep -q "^\$cfg\['Servers'\]\[\$i\]\['hide_db'\]" "$CONFIG_FILE"; then
# If found, replace the existing line.
sed -i "/^\$cfg\['Servers'\]\[\$i\]\['hide_db'\]/c\\$HIDE_DB_LINE" "$CONFIG_FILE"
echo "Updated existing hide_db configuration."
else
# Otherwise add the line at the end of the file.
echo "$HIDE_DB_LINE" >> "$CONFIG_FILE"
echo "Added new hide_db configuration."
fi
# Check if the ShowLogout line already exists.
if grep -q "^\$cfg\['ShowLogout'\]" "$CONFIG_FILE"; then
# If found, replace the existing line.
sed -i "/^\$cfg\['ShowLogout'\]/c\\$SHOW_LOGOUT_LINE" "$CONFIG_FILE"
echo "Updated existing ShowLogout configuration."
else
# Otherwise add the line at the end of the file.
echo "$SHOW_LOGOUT_LINE" >> "$CONFIG_FILE"
echo "Added new ShowLogout configuration."
fi
# Check if CSS is not already applied.
if ! grep -q "$CSS_LINE" "$CSS_FILE"; then
printf "\n $CSS_LINE" >> "$CSS_FILE"
echo "Added CSS changes."
else
echo "CSS changes are already applied."
fi
# All done!
echo "Done! phpMyAdmin changes completed!"
exit 0