/[projects]/misc/horsensspejder-web/inc/sendmessages.php
ViewVC logotype

Annotation of /misc/horsensspejder-web/inc/sendmessages.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (hide annotations) (download)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File size: 603 byte(s)
initial import
1 torben 2125 <?php
2     require_once("mysql.php");
3    
4     function sendmessages() {
5     $sql = "select id,receiver,message from outbox where status='NEW'";
6    
7     $rows = query($sql);
8    
9     foreach($rows as $row) {
10     $id = $row->id;
11    
12     $sms = "";
13     $sms .= "To: {$row->receiver}\n";
14     $sms .= "\n";
15     $sms .= $row->message;
16    
17     $file = "smsout_{$id}";
18    
19     $tmpnam = "/tmp/$file";
20    
21     file_put_contents($tmpnam, $sms);
22    
23    
24     $target = "/var/spool/sms/outgoing/$file";
25     rename($tmpnam, $target) or die("error renaming $tmpnam $target");
26    
27     $sql = "update outbox set status='TRANSMITTING', statustime=now() where id=$id";
28     squery($sql);
29     }
30    
31     } //end function

  ViewVC Help
Powered by ViewVC 1.1.20