economysizegeek / postie

A plugin for WordPress that makes mobloging and blogging by email much much better

This URL has Read+Write access

postie / cronless_postie.php
93cc7fac » Dirk Elmendorf 2008-04-30 Brought over the code from ... 1 <?php
2 /*
3 Plugin Name: Cronless Postie
4 Plugin URI: http://www.economysizegeek.com/?page_id=395
5 Description: This plugin allows you to setup your rss feeds to trigger postie (See <a href="../wp-content/plugins/postie/cronless_postie.php?cronless_postie_read_me=1">Quick Readme</a>)
6 Author: Dirk Elmendorf
7 Version: 1.1.1
8 Author URI: http://www.economysizegeek.com/
9 */
10
11 include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR. "wp-config.php");
12 function check_postie() {
13 $host = get_option('siteurl');
14 preg_match("/http:\/\/(.[^\/]*)(.*)/",$host,$matches);
15 $host = $matches[1];
16 $url = "";
17 if (isset($matches[2])) {
18 $url .= $matches[2];
19 }
20 $url .= "/wp-content/plugins/postie/get_mail.php";
21 $port = 80;
22 $fp=fsockopen($host,$port,$errno,$errstr);
23 fputs($fp,"GET $url HTTP/1.0\r\n");
24 fputs($fp,"User-Agent: Cronless-Postie\r\n");
25 fputs($fp,"Host: $host\r\n");
26 fputs($fp,"\r\n");
27 $page = '';
28 while(!feof($fp)) {
29 $page.=fgets($fp,128);
30 }
31 #var_dump($page);
32 fclose($fp);
33 }
34 function cronless_read_me() {
35 include_once("cronless_read_me.php");
36 }
37 if (isset($_GET["cronless_postie_read_me"])) {
38 include_once(ABSPATH . "wp-admin/admin.php");
39 $title = __("Edit Plugins");
40 $parent_file = 'plugins.php';
41 include(ABSPATH . 'wp-admin/admin-header.php');
42 cronless_read_me();
43 include(ABSPATH . 'wp-admin/admin-footer.php');
44 exit();
45 }
46
47
48 add_action('init','postie_cron');
49 function postie_cron() {
50 if (!wp_next_scheduled('check_postie')) {
51 wp_schedule_event(time(),'hourly','check_postie');
52 }
53 }
54 add_action('check_postie', 'check_postie');
55 /**
56 * Now just add the following line to all of the rss/atom pages
57 * Just make sure it is after the opening if statement
58
59 do_action('check_postie');
60
61 */
62
63 ?>