function laecho_socialstats_add($api_key)
{
    if (!$api_key) {
        $errdesc = laechonw_error_msgs('invalid key');
        echo $errdesc;
        return FALSE;
    }
    $link = 'http://www.linksalpha.com/a/statsadd';
    $body = array('api_key' => $api_key, 'link' => get_bloginfo('url'), 'plugin' => 'sd-ss');
    $response_full = laecho_socialstats_http_post($link, $body);
    $results = laecho_socialstats_http_process($response_full);
    if (!$results) {
        return;
    }
    $options = get_option(LAECHO_SOCIALSTATS_PLUGIN_NAME_INTERNAL);
    $options['api_key'] = $api_key;
    $options['id'] = $results->id;
    update_option(LAECHO_SOCIALSTATS_PLUGIN_NAME_INTERNAL, $options);
    $html = '<div class="msg_success">API Key has been added successfully. It may take 24 hours for data to show for the first time.</div>';
    echo $html;
    return TRUE;
}
function laechonw_networkpub_remove($key_full)
{
    $options = get_option(LAECHONW_WIDGET_NAME_INTERNAL);
    if ($key_full) {
        $key_only = substr($key_full, 4);
        $link = 'http://www.linksalpha.com/a/networkpubremove?id=' . $options['laechonw_id'] . '&key=' . $key_only;
        $response_full = laechonw_networkpub_http($link);
        $response_code = $response_full[0];
        if ($response_code != 200) {
            $errdesc = laechonw_error_msgs($response_full[1]);
            echo $errdesc;
            return FALSE;
        }
        $api_key = $options['laechonw_api_key'];
        $api_key_array = explode(',', $api_key);
        $loc = array_search($key_only, $api_key_array);
        if ($loc !== FALSE) {
            unset($api_key_array[$loc]);
        }
        $api_key = implode(",", $api_key_array);
        $options['laechonw_api_key'] = $api_key;
        update_option(LAECHONW_WIDGET_NAME_INTERNAL, $options);
        return $key_full;
    }
}