fixed pw value on options page

This commit is contained in:
Paul Kirby 2019-01-24 14:05:46 -06:00
parent 066900ec08
commit 3f0ae920ec
2 changed files with 19 additions and 17 deletions

View file

@ -116,9 +116,20 @@ class LBRY_Admin
*/ */
public function sanitize($input) public function sanitize($input)
{ {
if (!empty($input['lbry_speech_pw'])) { if (!empty($input[LBRY_SPEECH_CHANNEL])) {
$channel = $input[LBRY_SPEECH_CHANNEL];
$channel = str_replace('@', '', $channel);
$input[LBRY_SPEECH_CHANNEL] = $channel;
}
if (!empty($input[LBRY_SPEECH_PW])) {
$encrypted = $this->encrypt($input['lbry_speech_pw']); $encrypted = $this->encrypt($input['lbry_speech_pw']);
$input['lbry_speech_pw'] = $encrypted; $input[LBRY_SPEECH_PW] = $encrypted;
} else {
// If we have a password and its empty, keep orginal password
if (!empty(get_option(LBRY_SETTINGS)[LBRY_SPEECH_PW])) {
$input[LBRY_SPEECH_PW] = get_option(LBRY_SETTINGS)[LBRY_SPEECH_PW];
}
} }
return $input; return $input;
@ -180,10 +191,9 @@ class LBRY_Admin
public function speech_pw_callback() public function speech_pw_callback()
{ {
printf( printf(
'<input type="password" id="%1$s" name="%2$s[%1$s]" value="%3$s" placeholder="**********"', '<input type="password" id="%1$s" name="%2$s[%1$s]" value="" placeholder="Leave empty for same password"',
LBRY_SPEECH_PW, LBRY_SPEECH_PW,
LBRY_SETTINGS, LBRY_SETTINGS
isset($this->options[LBRY_SPEECH_PW]) ? $this->get_pw_length() : ''
); );
} }
@ -280,17 +290,6 @@ class LBRY_Admin
} }
} }
private function get_pw_length()
{
$pw = $this->options[LBRY_SPEECH_PW];
if (empty($pw)) {
return '';
}
$pw = $this->decrypt($pw);
$length = strlen($pw);
return str_repeat("X", $length);
}
private function encrypt($plaintext) private function encrypt($plaintext)
{ {
$ivlen = openssl_cipher_iv_length($cipher="AES-256-CTR"); $ivlen = openssl_cipher_iv_length($cipher="AES-256-CTR");

View file

@ -70,8 +70,11 @@ class LBRY_Speech
$speech_channel = get_option(LBRY_SETTINGS)[LBRY_SPEECH_CHANNEL]; $speech_channel = get_option(LBRY_SETTINGS)[LBRY_SPEECH_CHANNEL];
$speech_pw = LBRY()->admin->get_speech_pw(); $speech_pw = LBRY()->admin->get_speech_pw();
if (!empty($speech_channel) && !empty($speech_pw)) { if (!empty($speech_channel) && !empty($speech_pw)) {
$params['channelName'] = $speech_channel; $params['channelName'] = '@' . $speech_channel;
$params['channelPassword'] = $speech_pw; $params['channelPassword'] = $speech_pw;
error_log($params['channelName']);
error_log($params['channelPassword']);
} }
$ch = $this->build_request('publish', $params); $ch = $this->build_request('publish', $params);