PDA

View Full Version : Plesk Web Stats password change


Coldfusion2006
4th April 2007, 01:16 PM
I have noticed that when I first create a new domain on my server and choose to provide that domain with "Web Stats" all of the ftp passwords and user names are assigned to the "Web Stats" access page.

While that is fine by me and works great, I have noticed something that does not work.

Updating passwords on FTP accounts doesn't seem to carry over to the Web Stats access pages. Basically if I started off with a user name and password of:

user123
pass123

Then change to:

user543
pass543

It doesnt work with "Web Stats" and I can still access "Web Stats" using the old info that I originally setup.

Even if I restart Apache it doesn't help. Does any one know why this would be happening or if there is something that I am missing?

Thanks in Advance!

toneworks
24th May 2007, 08:56 AM
Paste the following script in a file named 'psa_statpass.php', and chmod that file to 700.
Execute te script every day (for example using Crontab):


#!/usr/bin/php
<?

$ADMIN_PASS=trim(file_get_contents("/etc/psa/.psa.shadow"));
$PRODUCT_ROOT_D=trim(shell_exec('grep PRODUCT_ROOT_D /etc/psa/psa.conf | awk \'{print $2}\''));

$dbres = mysql_connect("localhost", "admin", $ADMIN_PASS);
if (false == $dbres)
{
FatalError("Can't connect to MySQL server");
}

if (!mysql_select_db("psa",$dbres))
{
FatalError("Error selecting database.");
}


$result = mysql_query("
SELECT d.`name` , s.`login` , a.`password`
FROM `hosting` h
INNER JOIN `domains` d ON d.`id` = h.`dom_id`
INNER JOIN `sys_users` s ON s.`id` = h.`sys_user_id`
INNER JOIN `accounts` a ON a.`id` = s.`account_id` /* WHERE d.`name` = '[VARIABLE]' */
ORDER BY d.`name`
",$dbres);

if (false === $result)
{
FatalError("Error executing query");
}

while ($qrow = mysql_fetch_array($result, MYSQL_ASSOC))
{
$domain = $qrow['name'];
$login = $qrow['login'];
$pass = $qrow['password'];
#print "\nDomain: $domain\n";
shell_exec("$PRODUCT_ROOT_D/bin/domain.sh -u '$domain' -webstat-protdir-access 'true'\n");
shell_exec("$PRODUCT_ROOT_D/bin/protdir.sh -r 'plesk-stat' -domain '$domain'\n");
shell_exec("$PRODUCT_ROOT_D/bin/protdir.sh -c 'plesk-stat' -domain '$domain' -type 'nonssl' -title 'Statistics'\n");
shell_exec("$PRODUCT_ROOT_D/bin/protdir.sh -u 'plesk-stat' -domain '$domain' -add_user '$login' -passwd '$pass'\n");
}

mysql_free_result($result);
mysql_close($dbres);

exit;

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

function FatalError($msg)
{
print "\n\nFATAL ERROR: $msg\n\n";
exit;
}

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

?>


I just paste my solution here, sorry I don't have time to help everybody implementing it.

Kind regards, Jeroen Vermeulen - www.toneworks.nl (Dutch)