Pastoid

The page you are looking at now is at this URL: http://pastoid.com/aog

This paste was last updated on February 18, 2009 at 1:01 am.

Pasted Coderaw

<?php
 
class IMAPDashPlugin extends Plugin
{
    const IMAP_URL = "{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail";
 
    public function info()
    {
        return array (
            'name' => 'IMAPDash Email Module',
            'url' => '',
            'author' => '',
            'authorurl' => '',
            'version' => '0.1',
            'description' => '',
            'license' => 'Apache License 2.0',
        );
    }
 
    public function action_admin_footer()
    {
        $url = URL::get('ajax', 'context=check_gmail');
        $css_url = $this->get_url();
        echo <<<JS
<script type="text/javascript">
    var GmailChecker = {
        callback: function() {
            clearTimeout(GmailChecker.timeout);
            $.get(
                '$url',
                function( result ) {
                    if (result) {
                        $('#gmail-checker').html(result);
                        $('#gmail-checker').show('slow');
                        setTimeout("$('#gmail-checker').hide('slow')", 60000);
                        $('#gmail-checker').click(function(){
                            $(this).hide('slow');
                        });
                    }
                }
            );
            GmailChecker.timeout = setTimeout('GmailChecker.callback()', 150000);
        },
        timeout: 0
    }
    $(document).ready(function(){
        $('#gmail-checker').hide();
        GmailChecker.timeout = setTimeout('GmailChecker.callback()', 3);
    });
</script>
<style type="text/css">
#gmail-checker {
    position:fixed;
    bottom:0;
    left:0;
    width:100px;
    height:70px;
    padding: 10px;
    text-align:center;
    background: url($css_url/gmail-icon.jpg) no-repeat;
}
#gmail-checker span {
	font-size:400%;
}
</style>
<div id="gmail-checker"></div>
JS;
    }
 
    public function action_ajax_check_gmail()
    {
        $user = "email"; //Options::get('gmail_checker_username');
        $pass = "password"; //Options::get('gmail_checker_password');
        $count = $this->get_new_mail_count($user, $pass);
        if($count) {
            echo
                '<a href="http://mail.mattread.com" target="_blank">'
                . sprintf(_n('<span>%d</span><br>New E-Mail', '<span>%d</span><br>New E-Mails', $count), $count)
                . '</a>';
        }
    }
 
    private function get_new_mail_count( $user, $pass )
    {
        if ( $mbox = imap_open(self::IMAP_URL, $user, $pass) ) {
        	$status = imap_status($mbox, self::IMAP_URL, SA_UIDNEXT);
        	$count = 0;
        	if ($last = Options::get('gmail_checker_uidlast')) {
	        	$msgs = imap_fetch_overview($mbox, "$last:$status->uidnext", FT_UID);
	        	Options::set('gmail_checker_uidlast', $status->uidnext);
	        	foreach ($msgs as $msg) {
	        		if (!$msg->seen) {
	        			$count++;
	        		}
	        	}
	        }
	        else {
	        	Options::set('gmail_checker_uidlast', $status->uidnext);
	        }
        	imap_close($mbox);
        	return $count;
        }
        else {
            throw new Exception(_t('Could not connect to server', 'gmail_checker'));
        }
    }
}
 
?>

Toggle wordwrap

Referring DomainHits
Unknown Referer 127
pastoid.com 9
search.live.com 2
drunkenmonkey.org 1
mibbit.com 1
Is this paste spam?
<Hide