From cce5e7710295021b41d9aaecc503a60fb99256be Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 4 Oct 2008 10:38:03 +0000 Subject: Initial revision --- utils/pressrelease.php | 165 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 utils/pressrelease.php (limited to 'utils/pressrelease.php') diff --git a/utils/pressrelease.php b/utils/pressrelease.php new file mode 100644 index 0000000..3ae25b4 --- /dev/null +++ b/utils/pressrelease.php @@ -0,0 +1,165 @@ + + + + + + + + + + + + + **/ + + +/** + * CONFIG + */ +$subject_prefix = "DIE Pressrelease"; +$sender = "DIE "; +$replyto = $sender; +$footer = " + +Stay Brutal! +// DIE +http://www.executionroom.com +info@executionroom.com +"; + +class Email { + public $name; + public $url; + public $email; + + public function Email($name, $url, $email) + { + $this->name = $name; + $this->url = $url; + $this->email = $email; + } + + function send($subject, $message) { + global $subject_prefix; + global $sender; + global $replyto; + global $footer; + + $message .= $footer; + $headers = "From: " . $sender . "\r\n"; + $headers .= "Reply-To: " . $replyto . "\r\n"; + $headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n"; + $headers .= "X-Mailer: PHP/" . phpversion(); + $subject = "[".$subject_prefix."] " . $subject; + + $ret = mail($this->email, $subject, $message, $headers); + if(!$ret) echo "Fail(".$this->email.")"; + + //usleep(100000); + } +} + +class PressRelease { + private $file; + private $mailinglist = array(); + + public function add($email) { + $key = $email->email; + $this->mailinglist[$key] = $email; + } + + public function remove($email) { + if(array_key_exists($email, $this->mailinglist)) { + unset($this->mailinglist[$email]); + } + } + + public function write() + { + /* + $fp = fopen($this->file, "w"); + fwrite($fp, "\n"); + + fwrite($fp, "\n"); + foreach($this->mailinglist as $email) { + fwrite($fp, " email, ENT_QUOTES, "UTF-8") . "\"\n"); + fwrite($fp, " timestamp=\"" . $email->timestamp . "\">\n"); + fwrite($fp, " \n"); + } + fwrite($fp, "\n"); + + fclose($fp); + */ + } + + private function read() + { + $dom = new DomDocument; + $dom->preserveWhiteSpace = FALSE; + $dom->load($this->file); + $params = $dom->getElementsByTagName('email'); + + foreach ($params as $param) { + $email = new Email($param->getAttribute('name'), + $param->getAttribute('url'), + $param->getAttribute('email')); + $this->add($email); + } + } + /* + public function subscribe($email) + { + $email = new EMail($email, time()); + $this->add($email); + $this->write(); + } + + public function unsubscribe($email) + { + $this->remove($email); + $this->write(); + } + */ + public function post($subject, $message) + { + $sz = sizeof($this->mailinglist); + + echo "
Sending ". $sz ." mails
\n<"; + ob_flush(); + flush(); + + $num = 0; + $lvl = 0; + $steps = floor($sz / 10) + 1; + + foreach($this->mailinglist as $email) { + $email->send($subject, $message); + $pct = $num / $sz * 100; + if($pct >= $lvl) { + printf("%.0f%%", $lvl); + $lvl += 100/$steps; + } else { + echo "."; + } + ob_flush(); + flush(); + $num++; + } + echo "[100%]>\n
done
\n"; + echo "[CLOSE]"; + echo "
\n"; + ob_flush(); + flush(); + } + + public function PressRelease($file) + { + $this->file = $file; + $this->read(); + } +} + +?> \ No newline at end of file -- cgit v1.2.3