Ejemplo n.º 1
0
function counterize_display_dashboard_page_callback()
{
    echo '
	<div id="icon-plugins" class="icon32"></div>
	<h1>' . __('Counterize', COUNTERIZE_TD) . ' - ' . __('Dashboard', COUNTERIZE_TD) . '</h1>
	';
    //Show charts
    counterize_showStats(true);
    if (current_user_can('manage_options')) {
        $updateText = '';
        if (isset($_GET['killmass']) && check_admin_referer('action_killmass')) {
            if ($_GET['killmass'] == 'yes') {
                if (isset($_POST['counterize_killemall'])) {
                    foreach ($_POST['counterize_killemall'] as $key => $val) {
                        $val = intval($val);
                        counterize_killEntry($val);
                        $updateText .= __('Entry: ' . $val . ' removed<br />', COUNTERIZE_TD);
                    }
                    counterize_updateText($updateText);
                    unset($updateText);
                }
            }
        }
        // For the zap-an-entry-option
        if (isset($_GET['kill']) && check_admin_referer('action_uri_kill')) {
            $val = intval($_GET['kill']);
            counterize_killEntry($val);
            counterize_updateText(__('Deleting entry ', COUNTERIZE_TD) . $val);
        }
        //Show latest entries
        counterize_show_history(COUNTERIZE_MENU_SLUG, false);
    }
    //Print the footer
    counterize_pagefooter();
}
Ejemplo n.º 2
0
function counterize_send_report_by_email($new_options = FALSE)
{
    if ($new_options !== FALSE) {
        $options = $new_options;
    } else {
        $options = get_option('counterize_options');
    }
    $subject = __('[Counterize] New report available', COUNTERIZE_TD);
    if (!empty($options['mailsubjectoverride'])) {
        $subject = $options['mailsubjectoverride'];
    }
    $report_what = array('all');
    if (!empty($options['reportwhat'])) {
        $report_what = explode(',', $options['reportwhat']);
    }
    // Get the site domain and get rid of www.
    $sitename = strtolower($_SERVER['SERVER_NAME']);
    if (substr($sitename, 0, 4) == 'www.') {
        $sitename = substr($sitename, 4);
    }
    $sender = 'wordpress@' . $sitename;
    $recipient_list = $sender_fallback = get_bloginfo('admin_email');
    if (!empty($options['recipientlist'])) {
        $recipient_list = $options['recipientlist'];
    }
    //generate the report
    ob_start();
    foreach ($report_what as $what) {
        if ($what == 'all') {
            $ret = counterize_showStats();
        }
    }
    $content = ob_get_contents();
    ob_end_clean();
    //let plugins add their own shortcode
    $content = apply_filters('counterize_report', $content, $report_what);
    //Fix for non ASCII characters. Many thanks to Vadym Shvachko!
    $subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
    $html = '<html><head><title>' . $subject . '</title>';
    $html .= '<link rel="stylesheet" id="counterize_stylesheet-css" href="' . COUNTERIZE_PLUGIN_URL . '/counterize.css.php" type="text/css" media="all" />';
    $html .= '<script type="text/javascript" src="' . COUNTERIZE_PLUGIN_URL . '/counterize.js.php"></script>';
    $html .= '</head><body><h1>' . __('Counterize report', COUNTERIZE_TD) . '</h1>' . $content . '</body></html>';
    $headers = array(0 => 'MIME-Version: 1.0', 1 => 'Content-Type: text/html; charset=utf-8', 2 => 'From: Counterize <' . $sender . '>');
    //send the email
    $sent = wp_mail($recipient_list, $subject, $html, $headers);
    if (!$sent) {
        //try with the fallback email address (the blog admin email address)
        $headers[1] = 'From: Counterize <' . $sender_fallback . '>';
        $sent = wp_mail($recipient_list, $subject, $html, $headers);
        if (!$sent) {
            //try with the PHP mail function
            $sent = mail($recipient_list, $subject, $html, $headers);
        }
    }
    return $sent;
}