Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

editpref.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?PHP
  2. require_once('lib/dashboard.php');
  3. require_once('lib/account.php');
  4. require_once('lib/common.php');
  5. if (!isset($_GET['n']) || !ctype_digit($_GET['n']) || $_GET['n'] < 1 || $_GET['n'] > 5) {
  6. header('Location: '.CP_PATH.'account');
  7. exit;
  8. }
  9. $fields = array(1=>'users.user_email', 2=>'', 3=>'userdetails.ud_name',
  10. 4=>'userdetails.ud_address', 5=>'userdetails.ud_telephone');
  11. $prefs = array(1=>'e-mail address', 3=>'full name', 4=>'address',
  12. 5=>'telephone number');
  13. if (isset($_POST['value'])) {
  14. list($table, $col) = explode('.', $fields[($_GET['n'])]);
  15. if ($table == 'userdetails') {
  16. $sql = 'SELECT user_id FROM userdetails WHERE user_id = '.UID;
  17. $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  18. if (mysql_num_rows($res) == 0) {
  19. $sql = 'INSERT INTO userdetails (user_id) VALUES ('.UID.')';
  20. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  21. }
  22. }
  23. $sql = 'UPDATE '.$table.' SET '.$col.' = \''.m($_POST['value']).'\' WHERE ';
  24. $sql .= 'user_id = '.UID;
  25. logger::log('Changed '.$prefs[($_GET['n'])].' to '.$_POST['value'],logger::information);
  26. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  27. header('Location: '.CP_PATH.'account');
  28. exit;
  29. }
  30. if (isset($_POST['mail'])) {
  31. $m = array('mail_announce'=>'announcement','mail_tickets'=>'ticket reply',
  32. 'mail_warning'=>'warning','mail_over'=>'overring');
  33. $sql = 'SELECT mail_announce, mail_tickets, mail_warning, mail_over FROM ';
  34. $sql .= 'users WHERE user_id = '.UID;
  35. $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  36. $row = mysql_fetch_assoc($res);
  37. foreach ($row as $key => $value) {
  38. if ($value == 1 && !isset($_POST[$key])) {
  39. logger::log('Opted out of '.$m[$key].' e-mail.', logger::information);
  40. $sql = 'UPDATE users SET '.$key.' = 0 WHERE user_id = '.UID;
  41. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  42. }
  43. if ($value == 0 && isset($_POST[$key])) {
  44. logger::log('Opted to receive '.$m[$key].' e-mail.',logger::information);
  45. $sql = 'UPDATE users SET '.$key.' = 1 WHERE user_id = '.UID;
  46. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  47. }
  48. }
  49. header('Location: '.CP_PATH.'account');
  50. exit;
  51. }
  52. define('TITLE', 'Edit User preferences');
  53. addDashboardItem('Useful links', 'Account overview', '');
  54. require_once('lib/header.php');
  55. require_once('pages/editpref.php');
  56. require_once('lib/footer.php');
  57. ?>