From 21778176e6fa03d97705c1a74f24f2b49dca8aa3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 23 Jun 2013 03:30:22 +0200 Subject: [PATCH] pumpio: Resetting of authentification data is added. --- pumpio/pumpio.css | 4 +- pumpio/pumpio.php | 121 +++++++++++++++++++++++++++------------------- 2 files changed, 73 insertions(+), 52 deletions(-) diff --git a/pumpio/pumpio.css b/pumpio/pumpio.css index eba380e4..020f3697 100755 --- a/pumpio/pumpio.css +++ b/pumpio/pumpio.css @@ -1,11 +1,11 @@ -#pumpio-mirror-label,#pumpio-public-label, #pumpio-enable-label, #pumpio-username-label, #pumpio-servername-label, #pumpio-bydefault-label { +#pumpio-mirror-label,#pumpio-public-label, #pumpio-enable-label, #pumpio-username-label, #pumpio-servername-label, #pumpio-bydefault-label, #pumpio-delete-label { float: left; width: 200px; margin-top: 10px; } -#pumpio-mirror,#pumpio-public, #pumpio-checkbox, #pumpio-username, #pumpio-servername, #pumpio-bydefault { +#pumpio-mirror,#pumpio-public, #pumpio-checkbox, #pumpio-username, #pumpio-servername, #pumpio-bydefault, #pumpio-delete { float: left; margin-top: 10px; } diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index b7634bcb..da723eca 100755 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -198,47 +198,59 @@ function pumpio_settings(&$a,&$s) { $s .= '
'; $s .= '

' . t('Pump.io Post Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - $s .= '
'; $s .= ''; $s .= ''; $s .= '
'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + if (($username != '') AND ($servername != '')) { - $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; $oauth_token = get_pconfig(local_user(), "pumpio", "oauth_token"); $oauth_token_secret = get_pconfig(local_user(), "pumpio", "oauth_token_secret"); $s .= '
'; - if (($oauth_token == "") OR ($oauth_token_secret == "")) - $s .= t("You are not authenticated to pumpio"); + if (($oauth_token == "") OR ($oauth_token_secret == "")) { + $s .= '
'; + + //$s .= t("You are not authenticated to pumpio"); + } else { + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + //$s .= '
'; + + } $s .= '
'; } @@ -253,28 +265,37 @@ function pumpio_settings(&$a,&$s) { function pumpio_settings_post(&$a,&$b) { if(x($_POST,'pumpio-submit')) { - // filtering the username if it is filled wrong - $user = $_POST['pumpio_user']; - if (strstr($user, "@")) { - $pos = strpos($user, "@"); - if ($pos > 0) - $user = substr($user, 0, $pos); + if(x($_POST,'pumpio_delete')) { + set_pconfig(local_user(),'pumpio','consumer_key',''); + set_pconfig(local_user(),'pumpio','consumer_secret',''); + set_pconfig(local_user(),'pumpio','host',''); + set_pconfig(local_user(),'pumpio','oauth_token',''); + set_pconfig(local_user(),'pumpio','oauth_token_secret',''); + set_pconfig(local_user(),'pumpio','post',false); + set_pconfig(local_user(),'pumpio','post_by_default',false); + set_pconfig(local_user(),'pumpio','user',''); + } else { + // filtering the username if it is filled wrong + $user = $_POST['pumpio_user']; + if (strstr($user, "@")) { + $pos = strpos($user, "@"); + if ($pos > 0) + $user = substr($user, 0, $pos); + } + + // Filtering the hostname if someone is entering it with "http" + $host = $_POST['pumpio_host']; + $host = trim($host); + $host = str_replace(array("https://", "http://"), array("", ""), $host); + + set_pconfig(local_user(),'pumpio','post',intval($_POST['pumpio'])); + set_pconfig(local_user(),'pumpio','host',$host); + set_pconfig(local_user(),'pumpio','user',$user); + set_pconfig(local_user(),'pumpio','public',$_POST['pumpio_public']); + set_pconfig(local_user(),'pumpio','mirror',$_POST['pumpio_mirror']); + set_pconfig(local_user(),'pumpio','post_by_default',intval($_POST['pumpio_bydefault'])); } - - // Filtering the hostname if someone is entering it with "http" - $host = $_POST['pumpio_host']; - $host = trim($host); - $host = str_replace(array("https://", "http://"), array("", ""), $host); - - set_pconfig(local_user(),'pumpio','post',intval($_POST['pumpio'])); - set_pconfig(local_user(),'pumpio','host',$host); - set_pconfig(local_user(),'pumpio','user',$user); - set_pconfig(local_user(),'pumpio','public',$_POST['pumpio_public']); - set_pconfig(local_user(),'pumpio','mirror',$_POST['pumpio_mirror']); - set_pconfig(local_user(),'pumpio','post_by_default',intval($_POST['pumpio_bydefault'])); - } - } function pumpio_post_local(&$a,&$b) {