From adec979fd5453cf213b776d7dceaaaac4eb05713 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 12 Aug 2012 15:07:03 +0200 Subject: more subscription refactoring BROKEN now the actual sending of bulk messages (digest, list) is reimplemented and partially tested. Still not complete --- inc/common.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index ac7e744d8..29940d8a6 100644 --- a/inc/common.php +++ b/inc/common.php @@ -107,9 +107,11 @@ function pageinfo() { $info['isadmin'] = false; $info['ismanager'] = false; if(isset($_SERVER['REMOTE_USER'])) { + $sub = new Subscription(); + $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); - $info['subscribed'] = get_info_subscribed(); + $info['subscribed'] = $sub->user_subscription(); $info['client'] = $_SERVER['REMOTE_USER']; if($info['perm'] == AUTH_ADMIN) { -- cgit v1.2.3 From 835242b0f53a72a555ad30543a1677108ce210af Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 12 Aug 2012 17:17:34 +0200 Subject: subscription system should work now again This readds the last part of the subscription system: the normal "every" subscriptions. --- inc/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 29940d8a6..3cfeb3092 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1122,7 +1122,7 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = $data = array('id' => $id, 'addresslist' => '', 'self' => false); trigger_event( 'COMMON_NOTIFY_ADDRESSLIST', $data, - 'subscription_addresslist' + array(new Subscription(), 'notifyaddresses') ); $bcc = $data['addresslist']; if(empty($bcc)) return false; -- cgit v1.2.3 From 84c1127cc070777c8cbcf488f5422bc4b71470a8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 12 Aug 2012 17:30:01 +0200 Subject: correctly check if subscriptions are enabled --- inc/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 3cfeb3092..b4a57b154 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1117,7 +1117,7 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = $to = $conf['notify']; $bcc = ''; } elseif($who == 'subscribers') { - if(!$conf['subscribers']) return false; //subscribers enabled? + if(!actionOK('subscribe')) return false; //subscribers enabled? if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) return false; //skip minors $data = array('id' => $id, 'addresslist' => '', 'self' => false); trigger_event( -- cgit v1.2.3 From 2ed38036a53a489d2fcadc46ce601f8c876fca31 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 21 Sep 2012 11:53:17 +0200 Subject: consolidate more notification code in subscription class This is untested and probably broken currently --- inc/common.php | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index b4a57b154..d17061a1b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1113,9 +1113,8 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = // decide if there is something to do, eg. whom to mail if($who == 'admin') { if(empty($conf['notify'])) return false; //notify enabled? - $text = rawLocale('mailtext'); - $to = $conf['notify']; - $bcc = ''; + $tpl = 'mailtext'; + $to = $conf['notify']; } elseif($who == 'subscribers') { if(!actionOK('subscribe')) return false; //subscribers enabled? if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) return false; //skip minors @@ -1124,57 +1123,29 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = 'COMMON_NOTIFY_ADDRESSLIST', $data, array(new Subscription(), 'notifyaddresses') ); - $bcc = $data['addresslist']; - if(empty($bcc)) return false; - $to = ''; - $text = rawLocale('subscr_single'); + $to = $data['addresslist']; + if(empty($to)) return false; + $tpl = 'subscr_single'; } elseif($who == 'register') { if(empty($conf['registernotify'])) return false; $text = rawLocale('registermail'); $to = $conf['registernotify']; - $bcc = ''; } else { return false; //just to be safe } - // prepare replacements (keys not set in hrep will be taken from trep) - $trep = array( - 'NEWPAGE' => wl($id, '', true, '&'), - 'PAGE' => $id, - 'SUMMARY' => $summary - ); - $trep = array_merge($trep, $replace); - $hrep = array(); - // prepare content if($who == 'register') { $subject = $lang['mail_new_user'].' '.$summary; - } elseif($rev) { - $subject = $lang['mail_changed'].' '.$id; - $trep['OLDPAGE'] = wl($id, "rev=$rev", true, '&'); - $df = new Diff(explode("\n", rawWiki($id, $rev)), - explode("\n", rawWiki($id))); - $dformat = new UnifiedDiffFormatter(); - $tdiff = $dformat->format($df); - - $DIFF_INLINESTYLES = true; - $dformat = new InlineDiffFormatter(); - $hdiff = $dformat->format($df); - $hdiff = ''.$hdiff.'
'; - $DIFF_INLINESTYLES = false; } else { - $subject = $lang['mail_newpage'].' '.$id; - $trep['OLDPAGE'] = '---'; - $tdiff = rawWiki($id); - $hdiff = nl2br(hsc($tdiff)); + $subscription = new Subscription(); + return $subscription->send_diff($to, $tpl, $id, $rev, $summary); } - $trep['DIFF'] = $tdiff; - $hrep['DIFF'] = $hdiff; + // send mail $mail = new Mailer(); $mail->to($to); - $mail->bcc($bcc); $mail->subject($subject); $mail->setBody($text, $trep, $hrep); if($who == 'subscribers') { -- cgit v1.2.3 From 790b77202079261b11d425e0c814608d626eea70 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 30 Nov 2012 13:09:15 +0100 Subject: moved registration notification to subscription class --- inc/common.php | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index d17061a1b..20e0af389 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1126,36 +1126,13 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = $to = $data['addresslist']; if(empty($to)) return false; $tpl = 'subscr_single'; - } elseif($who == 'register') { - if(empty($conf['registernotify'])) return false; - $text = rawLocale('registermail'); - $to = $conf['registernotify']; } else { return false; //just to be safe } // prepare content - if($who == 'register') { - $subject = $lang['mail_new_user'].' '.$summary; - } else { - $subscription = new Subscription(); - return $subscription->send_diff($to, $tpl, $id, $rev, $summary); - } - - - // send mail - $mail = new Mailer(); - $mail->to($to); - $mail->subject($subject); - $mail->setBody($text, $trep, $hrep); - if($who == 'subscribers') { - $mail->setHeader( - 'List-Unsubscribe', - '<'.wl($id, array('do'=> 'subscribe'), true, '&').'>', - false - ); - } - return $mail->send(); + $subscription = new Subscription(); + return $subscription->send_diff($to, $tpl, $id, $rev, $summary); } /** -- cgit v1.2.3 From cfbb9916556595cd8987f6c79771883dde656185 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 18 Jan 2013 10:47:21 +0100 Subject: removed unused vars --- inc/common.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 20e0af389..bc49e76b2 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1105,10 +1105,7 @@ function saveOldRevision($id) { * @author Andreas Gohr */ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array()) { - global $lang; global $conf; - global $INFO; - global $DIFF_INLINESTYLES; // decide if there is something to do, eg. whom to mail if($who == 'admin') { -- cgit v1.2.3 From 58bedc8a310955dbc00e738bec1dc4f442eaff4e Mon Sep 17 00:00:00 2001 From: borekb Date: Wed, 30 Jan 2013 21:51:39 +0100 Subject: Updated idfilter() function for IIS There is a condition inside idfilter() function that helps Apache on Windows to properly handle colon as a namespace separator by replacing it with semicolon. However, this is not necessary on Microsoft IIS server so the condition was improved. --- inc/common.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index bc49e76b2..a270e4eaf 100644 --- a/inc/common.php +++ b/inc/common.php @@ -311,7 +311,7 @@ function breadcrumbs() { * * This is run on a ID before it is outputted somewhere * currently used to replace the colon with something else - * on Windows systems and to have proper URL encoding + * on Windows non-IIS systems and to have proper URL encoding * * Urlencoding is ommitted when the second parameter is false * @@ -322,7 +322,8 @@ function idfilter($id, $ue = true) { if($conf['useslash'] && $conf['userewrite']) { $id = strtr($id, ':', '/'); } elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && - $conf['userewrite'] + $conf['userewrite'] && + strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') === false ) { $id = strtr($id, ':', ';'); } -- cgit v1.2.3 From 907f24f7352841e6c3030e143ec75661c55244d8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 3 Feb 2013 21:12:06 +0100 Subject: added comment on use of whitelist vs blacklist --- inc/common.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index a270e4eaf..db39affc6 100644 --- a/inc/common.php +++ b/inc/common.php @@ -311,7 +311,11 @@ function breadcrumbs() { * * This is run on a ID before it is outputted somewhere * currently used to replace the colon with something else - * on Windows non-IIS systems and to have proper URL encoding + * on Windows (non-IIS) systems and to have proper URL encoding + * + * See discussions at https://github.com/splitbrain/dokuwiki/pull/84 and + * https://github.com/splitbrain/dokuwiki/pull/173 why we use a whitelist of + * unaffected servers instead of blacklisting affected servers here. * * Urlencoding is ommitted when the second parameter is false * -- cgit v1.2.3