HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //var/packages/phpMyAdmin/scripts/common
#!/bin/bash
# Copyright (c) 2000-2017 Synology Inc. All rights reserved.

. "$(dirname "$0")"/string_loader
. "$(dirname "$0")"/../WIZARD_UIFILES/wizard_common
. "$(dirname "$0")"/../WIZARD_UIFILES/wizard_customized

SYNOLOGY_ADDED_PATH="/var/packages/$PKG_NAME/target/synology_added"
PKG_NGINX_CONFIG="www.$PKG_NAME.conf"
NGINX_CONF_PATH="/usr/local/etc/nginx/conf.d/"
MYSQL="/usr/local/mariadb10/bin/mysql"
UNIX_SOCKET="/run/mysqld/mysqld10.sock"

DBAdminCheck()
{
	local user="$1"
	local password="$2"
	local mysql="$3"
	local error_msg="$4"

	# Check admin's account and password
	if ! $mysql -u "$user" --password="$password" -e "exit"; then
		echo "$wizard_admin_info_error" >> "$SYNOPKG_TEMP_LOGFILE"
		return 1
	fi

	# Check whether the account have all privileges *.* or not
	$mysql -u "$user" --password="$password" -e "SHOW GRANTS FOR ${user}@localhost" | grep -q "GRANT ALL PRIVILEGES ON \*\.\* TO \('${user}'@'localhost'\|\`${user}\`@\`localhost\`\).* WITH GRANT OPTION.*"
	if [ $? -eq 1 ]; then
		echo "$error_msg" >> "$SYNOPKG_TEMP_LOGFILE"
		return 1
	fi
	return 0
}

CustomRemoveBackupConf()
{
	local backup_info="/var/packages/.$PKG_DIR.conf"
	[ -s "$backup_info" ] && rm -f "$backup_info"
}

CustomMoveLegacyBackupWebDir()
{
	local legacy_backup_path="$1"
	local backup_web_dir="$(GetBackupWebDir)"
	mkdir -p "${backup_web_dir}"
	for item in $(ls -A $legacy_backup_path/ | grep -v backup_web_dir); do
		cp -a "$legacy_backup_path/$item" "${backup_web_dir}/"
	done
}

CustomChangeDBUserInfo()
{
	:
}

CustomRemove()
{
	:
}

CustomPreupgrade()
{
	:
}

CustomPreuninst()
{
	:
}

CustomBackupData()
{
	:
}

CustomPostuninst()
{
	:
}

CustomPreinst()
{
	:
}

CustomPostinst()
{
	:
}

CustomRestore()
{
	:
}

CustomRestoreUpgrade()
{
	:
}

CustomUseUnixSocket()
{
	:
}

CustomSetCleanNew()
{
	:
}

CustomNewInst()
{
	:
}

CustomSetInit()
{
	:
}

CustomWriteInfo()
{
	:
}

CustomPostupgrade()
{
	:
}

CustomStart()
{
	:
}

CustomStop()
{
	:
}

QuoteSQLString()
{
	sed -e 's|\\|\\\\|g' -e 's|`|\\`|g'
}

QuoteSed()
{
	sed -e 's|\\|\\\\|g' -e 's|&|\\\&|g'
}

QuotePHP()
{
	sed -e 's|\\|\\\\|g' -e "s|'|\\\\'|g"
}

QuoteSh()
{
	sed -e 's|\\|\\\\|g' -e 's|\"|\\\"|g' -e 's|`|\\`|g' -e 's|\$|\\\$|g'
}

EscapeSlashDelimiterAndSingleQuote()
{
	sed -e "s|'|\\\\'|g" -e 's|/|\\\/|g'
}

EscapeStandardSedString()
{
	QuoteSed | EscapeSlashDelimiterAndSingleQuote
}

EscapeStandardSedStringOnPHP()
{
	QuotePHP | EscapeStandardSedString
}

# must be in the last for overriding
. "$(dirname "$0")"/script_customized