# HG changeset patch # User Dan # Date 1215849314 14400 # Node ID 8733c22969e708ca7c97e3de551da78f37b17990 # Parent ab6f55abb17e117c7eebecbfaa199a0f9e6745f8 Added Gravatar support in UserManager in admin panel diff -r ab6f55abb17e -r 8733c22969e7 includes/sessions.php --- a/includes/sessions.php Sat Jul 12 03:32:57 2008 -0400 +++ b/includes/sessions.php Sat Jul 12 03:55:14 2008 -0400 @@ -3480,7 +3480,7 @@ // give the server our values frm.' . $crypt_key . '.value = secret_hash; - frm.' . $dh_client_pubkey . '.value = dh_pub; + ' . ( $dh_supported ? 'frm.' . $dh_client_pubkey . '.value = dh_pub;' : '' ) . ' // console.info("DiffieHellman: set public values"); diff -r ab6f55abb17e -r 8733c22969e7 language/english/admin.json --- a/language/english/admin.json Sat Jul 12 03:32:57 2008 -0400 +++ b/language/english/admin.json Sat Jul 12 03:55:14 2008 -0400 @@ -830,6 +830,7 @@ avatar_lbl_remove: 'Delete this user\'s avatar', avatar_lbl_set_http: 'Replace avatar using a new image from a URL', avatar_lbl_set_file: 'Replace avatar using a new image from my computer', + avatar_lbl_set_gravatar: 'Replace avatar with Gravatar', heading_adminonly: 'Administrator-only options', diff -r ab6f55abb17e -r 8733c22969e7 plugins/admin/UserManager.php --- a/plugins/admin/UserManager.php Sat Jul 12 03:32:57 2008 -0400 +++ b/plugins/admin/UserManager.php Sat Jul 12 03:55:14 2008 -0400 @@ -24,6 +24,11 @@ return; } + require_once(ENANO_ROOT . '/includes/math.php'); + require_once(ENANO_ROOT . '/includes/diffiehellman.php'); + + $GLOBALS['dh_supported'] = $dh_supported; + //die('
' . htmlspecialchars(print_r($_POST, true)) . ''); if ( isset($_POST['action']['save']) ) @@ -312,6 +317,19 @@ $to_update_users['user_has_avatar'] = '0'; } break; + case 'set_gravatar': + // set avatar to use Gravatar + // first, remove old image + if ( $has_avi ) + { + @unlink($avi_path); + } + // set to gravatar mode + $to_update_users['user_has_avatar'] = '1'; + $to_update_users['avatar_type'] = 'grv'; + + $has_avi = 1; + break; } if ( count($errors) < 1 ) @@ -793,6 +811,7 @@ { global $db, $session, $paths, $template, $plugins; // Common objects global $lang; + global $dh_supported; if ( file_exists( ENANO_ROOT . "/themes/$template->theme/admin_usermanager_form.tpl" ) ) { $parser = $template->makeParser('admin_usermanager_form.tpl'); @@ -897,6 +916,9 @@ + + +
@@ -1039,22 +1061,30 @@ | + {AES_JAVASCRIPT} @@ -1195,7 +1229,26 @@ } $form_action = makeUrlNS('Special', 'Administration', 'module=' . $paths->cpage['module'], true); - $aes_javascript = $session->aes_javascript("useredit_$this->uuid", 'new_password', 'use_crypt', 'crypt_key', 'crypt_data', 'challenge_data'); + $aes_javascript = $session->aes_javascript("useredit_$this->uuid", 'new_password', 'use_crypt', 'crypt_key', 'crypt_data', 'challenge_data', 'dh_supported', 'dh_public', 'dh_mypublic'); + + // FIXME should this be in logic rather than presentation code? + if ( $dh_supported ) + { + global $_math; + + $dh_key_priv = dh_gen_private(); + $dh_key_pub = dh_gen_public($dh_key_priv); + $dh_key_priv = $_math->str($dh_key_priv); + $dh_key_pub = $_math->str($dh_key_pub); + // store the keys in the DB for later fetching + $q = $db->sql_query('INSERT INTO ' . table_prefix . "diffiehellman( public_key, private_key ) VALUES ( '$dh_key_pub', '$dh_key_priv' );"); + if ( !$q ) + $db->_die(); + } + else + { + $dh_key_pub = ''; + } $parser->assign_vars(array( 'UUID' => $this->uuid, @@ -1204,6 +1257,8 @@ 'USER_ID' => $this->user_id, 'MD5_CHALLENGE' => $session->dss_rand(), 'PUBLIC_KEY' => $session->rijndael_genkey(), + 'DH_SUPPORTED' => ( $dh_supported ? 'true' : 'false' ), + 'DH_PUBLIC' => $dh_key_pub, 'REAL_NAME' => $this->real_name, 'SIGNATURE_FIELD' => $template->tinymce_textarea('signature', $this->signature, 10, 50), 'USER_LEVEL_MEMBER' => USER_LEVEL_CHPREF, @@ -1219,7 +1274,8 @@ 'JOB' => $job, 'HOBBIES' => $hobbies, 'FORM_ACTION' => $form_action, - 'REG_IP_ADDR' => $this->reg_ip_addr + 'REG_IP_ADDR' => $this->reg_ip_addr, + 'GRAVATAR_URL' => make_gravatar_url($this->email, 16) )); if ( $this->has_avatar ) |