Browse Source

php - add notifications

master
kanoi 10 years ago
parent
commit
0b4c1df085
  1. 2
      pool/base.php
  2. 66
      pool/email.php
  3. 49
      pool/page_settings.php

2
pool/base.php

@ -354,7 +354,7 @@ function logout()
# #
function requestRegister() function requestRegister()
{ {
$reg = getparam('Register', false); $reg = getparam('Register', true);
$reg2 = getparam('Reset', false); $reg2 = getparam('Reset', false);
if ($reg !== NULL || $reg2 !== NULL) if ($reg !== NULL || $reg2 !== NULL)
{ {

66
pool/email.php

@ -106,6 +106,72 @@ function passReset($to, $code, $whoip, $emailinfo)
return sendnoheader($to, "Password Reset", $message, $emailinfo); return sendnoheader($to, "Password Reset", $message, $emailinfo);
} }
# #
function payoutAddressChanged($to, $whoip, $emailinfo)
{
global $eol;
if (!isset($emailinfo['KWebURL']))
return false;
$web = $emailinfo['KWebURL'];
$ret = emailEnd('payout address change', $whoip, $emailinfo);
if ($ret === false)
return false;
$message = "Your payout address has been changed.$eol$eol";
$message .= $ret;
return sendnoheader($to, "Payout Address Change", $message, $emailinfo);
}
#
function emailAddressChanged($to, $whoip, $emailinfo, $old)
{
global $eol;
if (!isset($emailinfo['KWebURL']))
return false;
$web = $emailinfo['KWebURL'];
$ret = emailEnd('email address change', $whoip, $emailinfo);
if ($ret === false)
return false;
$message = "Your email address has been changed to:$eol <$to>$eol$eol";
if ($old != null && $old != '')
{
$message .= "You will no longer receive notifications at the address:$eol <$old>$eol$eol";
$send = "$to,$old";
}
else
$send = $to;
$message .= $ret;
return sendnoheader($send, "EMail Address Change", $message, $emailinfo);
}
#
function passChanged($to, $whoip, $emailinfo)
{
global $eol;
if (!isset($emailinfo['KWebURL']))
return false;
$web = $emailinfo['KWebURL'];
$ret = emailEnd('password change', $whoip, $emailinfo);
if ($ret === false)
return false;
$message = "Your password was changed.$eol$eol";
$message .= "If you didn't change it, then you need to urgently use$eol";
$message .= "the password reset at the pool to change it again.$eol$eol";
$message .= $ret;
return sendnoheader($to, "Password Change", $message, $emailinfo);
}
#
# getOpts required for email # getOpts required for email
# If they aren't all setup in the DB then email functions will return false # If they aren't all setup in the DB then email functions will return false
function emailOptList() function emailOptList()

49
pool/page_settings.php

@ -1,5 +1,7 @@
<?php <?php
# #
include_once('email.php');
#
function settings($data, $user, $email, $addr, $err) function settings($data, $user, $email, $addr, $err)
{ {
$pg = '<h1>Account Settings</h1>'; $pg = '<h1>Account Settings</h1>';
@ -10,6 +12,8 @@ function settings($data, $user, $email, $addr, $err)
$pg .= '<table cellpadding=20 cellspacing=0 border=1>'; $pg .= '<table cellpadding=20 cellspacing=0 border=1>';
$pg .= '<tr class=dc><td><center>'; $pg .= '<tr class=dc><td><center>';
$_SESSION['old_set_email'] = $email;
$pg .= makeForm('settings'); $pg .= makeForm('settings');
$pg .= '<table cellpadding=5 cellspacing=0 border=0>'; $pg .= '<table cellpadding=5 cellspacing=0 border=0>';
$pg .= '<tr class=dc><td class=dr colspan=2>'; $pg .= '<tr class=dc><td class=dr colspan=2>';
@ -101,6 +105,7 @@ function dosettings($data, $user)
$email = getparam('email', false); $email = getparam('email', false);
$pass = getparam('pass', false); $pass = getparam('pass', false);
$ans = userSettings($user, $email, null, $pass); $ans = userSettings($user, $email, null, $pass);
$err = 'EMail changed';
$check = true; $check = true;
break; break;
case 'Address': case 'Address':
@ -110,6 +115,7 @@ function dosettings($data, $user)
$addrarr = array(array('addr' => $addr)); $addrarr = array(array('addr' => $addr));
$pass = getparam('pass', false); $pass = getparam('pass', false);
$ans = userSettings($user, null, $addrarr, $pass); $ans = userSettings($user, null, $addrarr, $pass);
$err = 'Payout address changed';
$check = true; $check = true;
} }
break; break;
@ -132,13 +138,18 @@ function dosettings($data, $user)
} }
break; break;
} }
$doemail = false;
if ($check === true) if ($check === true)
{
if ($ans['STATUS'] != 'ok') if ($ans['STATUS'] != 'ok')
{ {
$err = $ans['STATUS']; $err = $ans['STATUS'];
if ($ans['ERROR'] != '') if ($ans['ERROR'] != '')
$err .= ': '.$ans['ERROR']; $err .= ': '.$ans['ERROR'];
} }
else
$doemail = true;
}
$ans = userSettings($user); $ans = userSettings($user);
if ($ans['STATUS'] != 'ok') if ($ans['STATUS'] != 'ok')
dbdown(); // Should be no other reason? dbdown(); // Should be no other reason?
@ -151,6 +162,44 @@ function dosettings($data, $user)
$addr = $ans['addr:0']; $addr = $ans['addr:0'];
else else
$addr = ''; $addr = '';
if ($doemail)
{
if ($email == '')
{
if ($err != '')
$err .= '<br>';
$err .= 'An error occurred, check your details below';
goto iroiroattanoyo;
}
$emailinfo = getOpts($user, emailOptList());
if ($emailinfo['STATUS'] != 'ok')
{
if ($err != '')
$err .= '<br>';
$err .= 'An error occurred, check your details below';
goto iroiroattanoyo;
}
switch ($chg)
{
case 'EMail':
if (isset($_SESSION['old_set_email']))
$old = $_SESSION['old_set_email'];
else
$old = null;
emailAddressChanged($email, zeip(), $emailinfo, $old);
break;
case 'Address':
payoutAddressChanged($email, zeip(), $emailinfo);
break;
case 'Password':
passChanged($email, zeip(), $emailinfo);
break;
}
}
iroiroattanoyo:
$pg = settings($data, $user, $email, $addr, $err); $pg = settings($data, $user, $email, $addr, $err);
return $pg; return $pg;
} }

Loading…
Cancel
Save