/** * WP PLUGIN CONFIGURATION **/
$fbz_data = array( 'feedblitz_feedid' => '', 'feedblitz_text' => 'Keep me up to date via email');
add_option('feedblitz_settings',$fbz_data,'FeedBlitz Newsletter Options');
$feedblitz_settings = get_option('feedblitz_settings');
function fbz_is_hash_valid($form_hash) { $ret = false; $saved_hash = fbz_retrieve_hash(); if ($form_hash === $saved_hash) { $ret = true; } return $ret;}
function fbz_generate_hash() { return md5(uniqid(rand(), TRUE));}
function fbz_store_hash($generated_hash) { return update_option('feedblitz_token',$generated_hash,'FeedBlitz Security Hash');}
function fbz_retrieve_hash() { $ret = get_option('feedblitz_token'); return $ret;}
/* Heavily borrowed auth code from the FeedBurner FeedSmith plugin */function fbz_ol_is_authorized() { global $user_level; if (function_exists("current_user_can")) { return current_user_can('activate_plugins'); } else { return $user_level > 5; }}
function fbz_ol_add_feedblitz_options_page() { if (function_exists('add_options_page')) { add_options_page('FeedBlitz', 'FeedBlitz', 8, basename(__FILE__), 'fbz_ol_feedblitz_options_subpanel'); }}
function fbz_ol_feedblitz_options_subpanel() { global $fbz_ol_flash, $feedblitz_settings, $_POST, $wp_rewrite; if (fbz_ol_is_authorized()) { // Easiest test to see if we have been submitted to if(isset($_POST['feedblitz_feedid']) isset($_POST['feedblitz_text'])) { // Now we check the hash, to make sure we are not getting CSRF if(fbz_is_hash_valid($_POST['token'])) { if (isset($_POST['feedblitz_feedid'])) { $feedblitz_settings['feedblitz_feedid'] = $_POST['feedblitz_feedid']; update_option('feedblitz_settings',$feedblitz_settings); $fbz_ol_flash = "Your settings have been saved."; } if (isset($_POST['feedblitz_text'])) { $feedblitz_settings['feedblitz_text'] = $_POST['feedblitz_text']; update_option('feedblitz_settings',$feedblitz_settings); $fbz_ol_flash = "Your settings have been saved."; } } else { // Invalid form hash, possible CSRF attempt $fbz_ol_flash = "Security hash missing."; } // endif fb_is_hash_valid } // endif isset(feedblitz_xxx) } else { $fbz_ol_flash = "You don't have enough access rights."; } if ($fbz_ol_flash != '') echo '
' . $fbz_ol_flash . '
'; echo '
FeedBlitz Newsletter Settings
'; echo 'This plugin makes it easy keep visitors up to date with your FeedBlitz newsletter by integrating newsletter sign up with the end user registration process.
Keine Kommentare:
Kommentar veröffentlichen