diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-08-01 01:22:36 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-08-01 01:22:36 -0400 |
commit | 09dfe32eb6b538225686fd6ed0220240010bc574 (patch) | |
tree | 29c1afc5e79519ba8689a3d5d170c312d3cf5033 /src/plugins |
initial commit.
Partway through a rewrite. I have some old files I didn't want to entirely delete.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/SenderGVSMS.class.php | 35 | ||||
-rw-r--r-- | src/plugins/SenderIdentica.class.php | 36 | ||||
-rw-r--r-- | src/plugins/maildir.php | 58 |
3 files changed, 129 insertions, 0 deletions
diff --git a/src/plugins/SenderGVSMS.class.php b/src/plugins/SenderGVSMS.class.php new file mode 100644 index 0000000..777586c --- /dev/null +++ b/src/plugins/SenderGVSMS.class.php @@ -0,0 +1,35 @@ +<?php + +require_once('SenderPrivate.class.php'); +require_once('GoogleVoice.class.php'); + +class SenderGVSMS extends SenderPrivate { + protected $config = array('username'=>'', + 'password'=>'', + 'length'=>160); + private $obj; + + public static function description() { + return 'Send messages over SMS via GoogleVoice.'; + } + + public static function configList() { + return array('username'=>'text', + 'password'=>'password'); + } + + public function init() { + $this->obj = new GoogleVoice($this->config['username'], + $this->config['password']); + } + + public function send($phoneNum, $id, $subject, $body) { + global $shorturl, $messenger; + $url = $shorturl->get($messenger->id2url($id)); + $maxlen = $this->config['length']-(strlen($url)+1); + if($maxlen < strlen($subject)) { + $subject = substr($subject,0,$maxlen-3).'...'; + } + $this->obj->sms($phoneNum, $subject.' '.$url); + } +} diff --git a/src/plugins/SenderIdentica.class.php b/src/plugins/SenderIdentica.class.php new file mode 100644 index 0000000..4bb20c9 --- /dev/null +++ b/src/plugins/SenderIdentica.class.php @@ -0,0 +1,36 @@ +<?php + +require_once('SenderBroadcast.class.php'); +require_once('Identica.class.php'); + +class SenderIdentica extends SenderBroadcast { + protected $config = array('username'=>'', + 'password'=>'', + 'length'=>140); + private $obj; + + public static function description() { + return ''; + } + + public static function configList() { + return array('username'=>'text', + 'password'=>'password', + 'length'=>'int'); + } + + public function init() { + $this->obj = new Identica($this->config['username'], + $this->config['password']); + } + + public function send($id, $subject, $body) { + global $shorturl, $messenger; + $url = $shorturl->get($messenger->id2url($id)); + $maxlen = $this->config['length']-(strlen($url)+1); + if($maxlen < strlen($subject)) { + $subject = substr($subject,0,$maxlen-3).'...'; + } + $this->obj->updateStatus($subject.' '.$url); + } +} diff --git a/src/plugins/maildir.php b/src/plugins/maildir.php new file mode 100644 index 0000000..28211b5 --- /dev/null +++ b/src/plugins/maildir.php @@ -0,0 +1,58 @@ +<?php +require_once('Getter.class.php'); +//////////////////////////////////////////////////////////////////////////////// +class Maildir implements Getter { + private $config = array('dir'=>''); + + public function configList() { + return array('dir'=>'text'); + } + + public function init() {} + + public function get() { + $this->handle_new(); + $this->handle_cur(); + $this->handle_tmp(); + } + + private function handle_new() { + // move files in new to cur + $new = $this->config['dir'].'/new'; + $cur = $this->config['dir'].'/cur'; + $dh = opendir($new); + + while (($file = readdir($dh)) !== false) { + if (substr($file,0,1)!='.' && is_file($new.'/'.$file)) { + rename($new.'/'.$file, + $cur.'/'.$file.':'); + } + } + } + private function handle_cur() { + $cur = $this->config['dir'].'/cur'; + $dh = opendir($cur); + + while (($file = readdir($dh)) !== false) { + if (substr($file,0,1)!='.' && is_file($cur.'/'.$file)) { + + } + } + } + private function handle_tmp() { + // Clean up files that haven't been accessed for 36 hours + $tmp = $this->config['dir'].'/tmp'; + $dh = opendir($cur); + + while (($file = readdir($dh)) !== false) { + if (is_file($tmp.'/'.$file)) { + $atime = fileatime($tmp.'/'.$file); + $time = time(); + if (($time-$atime)>(36*60*60)) { + unlink($tmp.'/'.$file); + } + } + } + } + +} |