Ejemplo n.º 1
0
function handle_meta_box_add()
{
    global $wpdb;
    $table_name = $wpdb->prefix . TZELAN_TBL;
    $titles = $_REQUEST['metabox_title'];
    $text = $_REQUEST['metabox_text'];
    if (empty($titles)) {
        return;
    }
    $unique = random_id();
    foreach ($titles as $key => $title) {
        if (!empty($title)) {
            $wpdb->insert($table_name, array('metaboxid' => $unique, 'title' => $title, 'content' => $text[$key]));
        }
    }
    $current_url = $_SERVER["REQUEST_URI"];
    $redir_url = add_query_arg(array('updated' => '1'), $current_url);
    header("Location: " . $redir_url);
}
Ejemplo n.º 2
0
/**
 * Creates an association.
 *
 * This function calls {@link openid_dh_server_assoc()} where required, to 
 * generate the cryptographic values required for an association response.
 *
 * @param int $mode either ASSOCIATION_SHARED or ASSOCIATION_PRIVATE
 * @param string $assoc_type a valid OpenID association type
 * @param string $session_type a valid OpenID session type
 * @param string $dh_modulus for Diffie-Hellman key exchange, the modulus encoded in Base64
 * @param string $dh_gen for Diffie-Hellman key exchange, g encoded in Base64
 * @param string $dh_consumer_public for Diffie-Hellman key exchange, the public key of the relying party encoded in Base64
 * @return mixed if $mode is ASSOCIATION_SHARED, an OpenID response
 * to the association request, if $mode is ASSOCIATION_PRIVATE, the
 * association data for storage.
 * @link http://openid.net/specs/openid-authentication-1_1.html#anchor14, http://openid.net/specs/openid-authentication-2_0.html#anchor20
 */
function _simpleid_create_association($mode = ASSOCIATION_SHARED, $assoc_type = 'HMAC-SHA1', $session_type = 'no-encryption', $dh_modulus = NULL, $dh_gen = NULL, $dh_consumer_public = NULL)
{
    global $version;
    $assoc_types = openid_association_types();
    $session_types = openid_session_types(is_https(), $version);
    $mac_size = $assoc_types[$assoc_type]['mac_size'];
    $hmac_func = $assoc_types[$assoc_type]['hmac_func'];
    $assoc_handle = random_id();
    $expires_in = SIMPLEID_ASSOC_EXPIRES_IN;
    $secret = random_bytes($mac_size);
    $response = array('assoc_handle' => $assoc_handle, 'assoc_type' => $assoc_type, 'expires_in' => $expires_in);
    // If $session_type is '', then it must be using OpenID 1.1 (blank parameter
    // is not allowed for OpenID 2.0.  For OpenID 1.1 blank requests, we don't
    // put a session_type in the response.
    if ($session_type != '') {
        $response['session_type'] = $session_type;
    }
    if ($session_type == 'no-encryption' || $session_type == '') {
        $mac_key = base64_encode(call_user_func($hmac_func, $secret, $response['assoc_handle']));
        $response['mac_key'] = $mac_key;
    } elseif ($session_type == 'DH-SHA1' || $session_type == 'DH-SHA256') {
        $hash_func = $session_types[$session_type]['hash_func'];
        $dh_assoc = openid_dh_server_assoc($secret, $dh_consumer_public, $dh_modulus, $dh_gen, $hash_func);
        $mac_key = base64_encode($secret);
        $response['dh_server_public'] = $dh_assoc['dh_server_public'];
        $response['enc_mac_key'] = $dh_assoc['enc_mac_key'];
    }
    $association = array('assoc_handle' => $assoc_handle, 'assoc_type' => $assoc_type, 'mac_key' => $mac_key, 'created' => time());
    if ($mode == ASSOCIATION_PRIVATE) {
        $association['private'] = 1;
    }
    cache_set('association', $assoc_handle, $association);
    if ($mode == ASSOCIATION_SHARED) {
        log_info('Created association: ' . log_array($response));
        log_debug('***** MAC key: ' . $association['mac_key']);
        return $response;
    } else {
        log_info('Created association: private; ' . log_array($association, array('assoc_handle', 'assoc_type')));
        log_debug('***** MAC key: ' . $association['mac_key']);
        return $association;
    }
}
/**
 * Detects the current installed version of SimpleID, selects the individual upgrade
 * functions applicable to this upgrade and displays the upgrade
 * selection page.
 */
function upgrade_selection()
{
    global $xtpl, $upgrade_access_check;
    cache_gc(0, 'upgrade');
    if (!validate_form_token($_POST['tk'], 'upgrade_info')) {
        set_message('SimpleID detected a potential security attack.  Please try again.');
        upgrade_info();
        return;
    }
    $functions = upgrade_get_functions();
    if (count($functions) == 0) {
        if (!$upgrade_access_check) {
            $xtpl->parse('main.selection.selection_complete.upgrade_access_check');
        }
        $xtpl->parse('main.upgrade_selection.selection_complete');
    } else {
        $handle = random_id();
        cache_set('upgrade', $handle, $functions);
        $xtpl->assign('handle', $handle);
        $xtpl->assign('token', get_form_token('upgrade_selection'));
        $xtpl->parse('main.upgrade_selection.selection_continue');
    }
    $xtpl->assign('original_version', upgrade_get_version());
    $xtpl->assign('this_version', SIMPLEID_VERSION);
    $xtpl->parse('main.upgrade_selection');
    $xtpl->assign('title', 'Upgrade');
    $xtpl->parse('main');
    $xtpl->out('main');
}