From 0df91fd9a2a78d12378fcb7d9f7cba33f33e845e Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Tue, 4 Jan 2011 14:46:08 +0100 Subject: [PATCH 1/3] Manage user registrations in REGISTER_APPROVE mode. --- include/main.js | 4 ++++ mod/notifications.php | 28 +++++++++++++++++++++++++++- mod/ping.php | 11 ++++++++++- util/strings.php | 1 + view/en/registrations-top.tpl | 3 +++ view/en/registrations.tpl | 1 + view/it/registrations-top.tpl | 3 +++ view/it/registrations.tpl | 1 + view/it/strings.php | 1 + 9 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 view/en/registrations-top.tpl create mode 100644 view/en/registrations.tpl create mode 100644 view/it/registrations-top.tpl create mode 100644 view/it/registrations.tpl diff --git a/include/main.js b/include/main.js index ef6b059c..0fe20955 100644 --- a/include/main.js +++ b/include/main.js @@ -77,8 +77,12 @@ if(mail == 0) { mail = ''; } $('#mail-update').html(mail); var intro = $(this).find('intro').text(); + var register = $(this).find('register').text(); if(intro == 0) { intro = ''; } + if(register != 0 && intro != '') { intro = intro+'/'+register; } + if(register != 0 && intro == '') { intro = '0/'+register; } $('#notify-update').html(intro); + }); }) ; } diff --git a/mod/notifications.php b/mod/notifications.php index 1c680794..f11676eb 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -126,5 +126,31 @@ function notifications_content(&$a) { else notice( t('No notifications.') . EOL); + if ($a->config['register_policy'] = REGISTER_APPROVE && + $a->config['admin_email'] = $a->user['email']){ + $o .= load_view_file('view/registrations-top.tpl'); + + $r = q("SELECT `register`.*, `contact`.`name`, `user`.`email` + FROM `register` + LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid` + LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;"); + if(($r !== false) && (count($r))) { + $tpl = load_view_file("view/registrations.tpl"); + foreach($r as $rr) { + $o .= ""; + } + } + else + notice( t('No registrations.') . EOL); + + } + return $o; -} \ No newline at end of file +} diff --git a/mod/ping.php b/mod/ping.php index 0831e57b..00c4a310 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -25,6 +25,15 @@ function ping_init(&$a) { ); $intro = $r[0]['total']; + if ($a->config['register_policy'] = REGISTER_APPROVE && + $a->config['admin_email'] = $a->user['email']){ + $r = q("SELECT COUNT(*) AS `total` FROM `register`"); + $register = $r[0]['total']; + } else { + $register = "0"; + } + + $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ; $r = q("SELECT COUNT(*) AS `total` FROM `mail` WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", @@ -35,7 +44,7 @@ function ping_init(&$a) { $mail = $r[0]['total']; header("Content-type: text/xml"); - echo "\r\n$intro$mail$network$home\r\n"; + echo "\r\n$register$intro$mail$network$home\r\n"; killme(); } diff --git a/util/strings.php b/util/strings.php index e8f3b47a..0871da51 100644 --- a/util/strings.php +++ b/util/strings.php @@ -242,6 +242,7 @@ $a->strings['Friend/Connect Request'] = 'Friend/Connect Request'; $a->strings['New Follower'] = 'New Follower'; $a->strings['Approve'] = 'Approve'; $a->strings['No notifications.'] = 'No notifications.'; +$a->strings['No registrations.'] = 'No registrations.'; $a->strings['Login failed.'] = 'Login failed.'; $a->strings["Welcome back "] = "Welcome back "; $a->strings['Photo Albums'] = 'Photo Albums'; diff --git a/view/en/registrations-top.tpl b/view/en/registrations-top.tpl new file mode 100644 index 00000000..d8faf343 --- /dev/null +++ b/view/en/registrations-top.tpl @@ -0,0 +1,3 @@ +

User registrations waiting for confirm

+ + diff --git a/view/en/registrations.tpl b/view/en/registrations.tpl new file mode 100644 index 00000000..c8646043 --- /dev/null +++ b/view/en/registrations.tpl @@ -0,0 +1 @@ +
  • $fullname ($email) : Approve - Deny
  • diff --git a/view/it/registrations-top.tpl b/view/it/registrations-top.tpl new file mode 100644 index 00000000..8134aa21 --- /dev/null +++ b/view/it/registrations-top.tpl @@ -0,0 +1,3 @@ +

    Registrazioni in attesa di conferma

    + + diff --git a/view/it/registrations.tpl b/view/it/registrations.tpl new file mode 100644 index 00000000..698c766f --- /dev/null +++ b/view/it/registrations.tpl @@ -0,0 +1 @@ +
  • $fullname ($email) : Approva - Rifiuta
  • diff --git a/view/it/strings.php b/view/it/strings.php index 0e6def3d..b18904ea 100644 --- a/view/it/strings.php +++ b/view/it/strings.php @@ -244,6 +244,7 @@ $a->strings['Friend/Connect Request'] = 'Richiesta Amicizia/Connessione'; $a->strings['New Follower'] = 'Nuovo Seguace'; $a->strings['Approve'] = 'Approva'; $a->strings['No notifications.'] = 'Nessuna notifica.'; +$a->strings['No registrations.'] = 'Nessuna registrazione.'; $a->strings['Login failed.'] = 'Accesso fallito.'; $a->strings["Welcome back "] = "Bentornato "; $a->strings['Photo Albums'] = 'Album Foto'; From 45d8676dc294b3d275a5d62138ad3c0dcfa8fc13 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 4 Jan 2011 14:35:12 -0800 Subject: [PATCH 2/3] use shift-home instead to take you home --- include/main.js | 7 ++++--- index.php | 9 ++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/main.js b/include/main.js index d137d4c9..5c436369 100644 --- a/include/main.js +++ b/include/main.js @@ -44,10 +44,11 @@ $('#pause').html(''); } } - if(event.keyCode == '36') { - event.preventDefault(); - if(homebase) + if(event.keyCode == '36' && event.shiftKey == true) { + if(homebase !== undefined) { + event.preventDefault(); document.location = homebase; + } } }); }); diff --git a/index.php b/index.php index cbc85acc..456c0a14 100644 --- a/index.php +++ b/index.php @@ -173,8 +173,15 @@ if($a->module_loaded) { } +// let javascript take you home + if(x($_SESSION,'visitor_home')) - $a->page['content'] .= ''; + $homebase = $_SESSION['visitor_home']; +elseif(local_user()) + $homebase = $a->get_baseurl() . '/profile/' . $a->user['nickname']; + +if(isset($homebase)) + $a->page['content'] .= ''; if(stristr($_SESSION['sysmsg'], t('Permission denied'))) { header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.')); From bb0c24bd4fd159cc005f60a0808a4b37b91060b0 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 4 Jan 2011 22:17:58 -0800 Subject: [PATCH 3/3] prevent admin hijacks --- mod/notifications.php | 2 +- mod/regmod.php | 5 +++++ mod/settings.php | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mod/notifications.php b/mod/notifications.php index f11676eb..c425d092 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -127,7 +127,7 @@ function notifications_content(&$a) { notice( t('No notifications.') . EOL); if ($a->config['register_policy'] = REGISTER_APPROVE && - $a->config['admin_email'] = $a->user['email']){ + $a->config['admin_email'] === $a->user['email']){ $o .= load_view_file('view/registrations-top.tpl'); $r = q("SELECT `register`.*, `contact`.`name`, `user`.`email` diff --git a/mod/regmod.php b/mod/regmod.php index 772351ac..eabbec09 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -12,6 +12,11 @@ function regmod_content(&$a) { return $o; } + if((! (x($a->config,'admin_email'))) || ($a->config['admin_email'] !== $a->user['email'])) { + notice( t('Permission denied.') . EOL); + return ''; + } + if($a->argc != 3) killme(); diff --git a/mod/settings.php b/mod/settings.php index a40883f3..9a9fde5c 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -95,6 +95,10 @@ function settings_post(&$a) { $email_changed = true; if(! valid_email($email)) $err .= t(' Not valid email.'); + if((x($a->config,'admin_email')) && (strcasecmp($email,$a->config['admin_email']) == 0)) { + $err .= t(' Cannot change to that email.'); + $email = $a->user['email']; + } } if(strlen($err)) {