function show_subscribe_form($profile) {
common_element_start('form', array('id' => 'subscribe', 'method' => 'post',
'action' => common_local_url('subscribe')));
+ common_hidden('token', common_session_token());
common_element('input', array('id' => 'subscribeto',
'name' => 'subscribeto',
'type' => 'hidden',
function show_unsubscribe_form($profile) {
common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post',
'action' => common_local_url('unsubscribe')));
+ common_hidden('token', common_session_token());
common_element('input', array('id' => 'unsubscribeto',
'name' => 'unsubscribeto',
'type' => 'hidden',
return;
}
+ # CSRF protection
+
+ $token = $this->trimmed('token');
+
+ if (!$token || $token != common_session_token()) {
+ common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)));
+ return;
+ }
+
$other_nickname = $this->arg('subscribeto');
$result=subs_subscribe_user($user, $other_nickname);
return;
}
+ # CSRF protection
+
+ $token = $this->trimmed('token');
+
+ if (!$token || $token != common_session_token()) {
+ common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)));
+ return;
+ }
+
$other_nickname = $this->arg('unsubscribeto');
$result=subs_unsubscribe_user($user,$other_nickname);
if($result!=true) {