Ejemplo n.º 1
0
function doAutosend($frequency)
{
    echo "autosending for '{$frequency}' <br/>\n";
    global $uid;
    $do = DB_DataObject::factory(playsms_featAutoSend);
    $do->frequency = $frequency;
    $do->find();
    if ($frequency == "startup") {
        gw_waitForStartup();
    }
    while ($do->fetch()) {
        echo "sending {$do->id}, {$do->frequency}, {$do->number}, \"{$do->msg}\"... <br/>\n";
        if (gpcode2gpid($uid, $do->number)) {
            websend2group("admin", $do->number, $do->msg);
        } else {
            websend2pv("admin", $do->number, $do->msg);
        }
    }
}
Ejemplo n.º 2
0
 function websend2group($username, $gp_code, $message, $sms_type = "text")
 {
     $datetime_now = $this->datetime_now();
     $gateway_module_send = $this->gateway_module_send;
     $uid = $GLOBALS['phpgw']->accounts->name2id($username);
     $mobile_sender = $this->username2mobile($username);
     $max_length = 160;
     if ($sms_sender = $this->username2sender($username)) {
         $max_length = $max_length - strlen($sms_sender) - 1;
     }
     if (strlen($message) > $max_length) {
         $message = substr($message, 0, $max_length - 1);
     }
     if (is_array($gp_code)) {
         $array_gp_code = $gp_code;
     } else {
         $array_gp_code[0] = $gp_code;
     }
     $j = 0;
     for ($i = 0; $i < count($array_gp_code); $i++) {
         $c_gp_code = strtoupper($array_gp_code[$i]);
         $gpid = gpcode2gpid($uid, $c_gp_code);
         $db_query = "SELECT * FROM phpgw_sms_tblUserPhonebook WHERE gpid='{$gpid}'";
         $db_result = $this->db->query($db_query);
         while ($this->db->next_record()) {
             $p_num = $this->db->f('p_num');
             $sms_to = $p_num;
             $sms_msg = $message;
             $sms_msg = str_replace("\r", "", $sms_msg);
             $sms_msg = str_replace("\n", "", $sms_msg);
             $sms_msg = str_replace("\"", " ", $sms_msg);
             $mobile_sender = str_replace("\\'", "", $mobile_sender);
             $mobile_sender = str_replace("\"", "", $mobile_sender);
             $sms_sender = str_replace("\\'", "", $sms_sender);
             $sms_sender = str_replace("\"", "", $sms_sender);
             $sms_to = str_replace("\\'", "", $sms_to);
             $sms_to = str_replace("\"", "", $sms_to);
             $the_msg = "{$sms_to}\n{$sms_msg}";
             $db_query1 = "\n\t\t\t\t\tINSERT INTO phpgw_sms_tblsmsoutgoing\n\t\t\t\t\t(uid,p_gateway,p_src,p_dst,p_footer,p_msg,p_datetime,p_gpid,p_sms_type)\n\t\t\t\t\tVALUES ('{$uid}','{$gateway_module_send}','{$mobile_sender}','{$sms_to}','{$sms_sender}','{$message}','{$datetime_now}','{$gpid}','{$sms_type}')\n\t\t\t\t\t";
             $this->db2->query($db_query1);
             $smslog_id = $this->db2->get_last_insert_id('phpgw_sms_tblsmsoutgoing');
             $to[$j] = $sms_to;
             $ok[$j] = 0;
             if ($smslog_id) {
                 if ($this->gw_send_sms($mobile_sender, $sms_sender, $sms_to, $sms_msg, $c_gp_code, $uid, $smslog_id, $sms_type, $unicode)) {
                     $ok[$j] = $sms_to;
                 }
             }
             $j++;
         }
     }
     return array($ok, $to);
 }