PHP Shell Script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear All,

I  have  question  about  syntax  to  make http request and send email
through CLI command

I have script while the sender [Mobile Phone] send sms to my gateway and then if
their  request have right result, the gateway will reply back to their
mobile  phone, but if the result is nothing, the sms gateway will send
an email to webmaster
here  is  my php script, pls revise if my script have some thing wrong
or missing


#!/usr/local/bin/php -q
<?
// file name : pickup.php
// Ambil data last row di table sms_store

include "setup.php";

$query = "SELECT * from sms_store where smsc='Receive SMS' ORDER BY sms_number DESC LIMIT 0,1";
$result = mysql_query($query);
if (!$result) error_message(sql_error());

  // show field for current row
  while($show = mysql_fetch_array($result)) {
      $sms_time=$show["sms_time"];
      $smsc=$show["smsc"];
      $org_sms=$show["org_sms"];
      $dest_sms=$show["dest_sms"];
      $msg_content=$show["msg_content"];

      // pemisahan char di msg_content berdasarkab rule
      // 1 untuk Menampilkan Summary dari IP,IPK dan IP sem kermarin dari sender
      // 2 untuk menampilkan nila per KODE mata kuliah sender pada current semester
      // kemudian baru di ikuti nomor NBI dari sender
      // Sementara ini coba langusung ke NBI aja ya...

      //  $rule = substr($show["msg_content"],0,1);   //nah ini belum di berlakukan
      // sementara pake ini dulu --> Langsung tulis NBI nya aja
      $matang=substr($show["msg_content"],0,9);

      $sms_time = substr($show["sms_time"],6,2).'-'.
      substr($show["sms_time"],4,2).'-'.
      substr($show["sms_time"],0,4).' - '.
      substr($show["sms_time"],8,2).':'.
      substr($show["sms_time"],10,2).':'.
      substr($show["sms_time"],12,2);

      echo "Waktu : $sms_time <br>";
      echo "Action : $smsc <br>";
      echo "Dari : $org_sms <br>";
      echo "Ke : $dest_sms <br>";
      echo "Isi SMS : $msg_content <br>";
      echo "<br>";

      echo "Isi MSG Content : $matang <br>";
      echo "<br>";

      //Sekarang query ke DB MHS
      $cari_nbi= "SELECT * FROM m_mhs where nbi = $matang";
      $ketemu = mysql_query ($cari_nbi);

      if (!$ketemu) then
      {
       $receipent ="webmaster@untag-sby.ac.id";
       $subject ="Failed to pickup DATA for $matang";
       $body_mail ="Some on try to get information about IPK by $org_sms for $nbi";

       //Sending email for every failed pickup data to webmaster
       //ini  juga  saya  tanyakan bener tdk untuk kirim email through
       //CLI
       
       mail ($receipent,$subject,$body_mail);
       }
       else
       {  while($tampil = mysql_fetch_array($ketemu)) {

      $nbi=$tampil["nbi"];
      $nama_mhs=$tampil["nama_mhs"];
      $current_ip=$tampil["current_ip"];
      $old_ip=$tampil["old_ip"];
      $ipk=$tampil["ipk"];

      //tampakan hasil query ke layar;

      echo "Nama = $nama_mhs <br>";
      echo "NBI  = $nbi <br>";
      echo "IP Sekarang = $current_ip <br>";
      echo "IP Lalu = $old_ip <br>";
      echo "IPK = $ipk <br>";
      }
      
      // nah ini yg saya tanyakan benerkah syntax nya demikian ..???
  exec "lynx --dump
http://sms.untag-sby.ac.id/cgi-bin/sendsms?username=untag&password=nginden&to=$org_sms&text=$nama_mhs+&$nbi+$current_ip+$old_ip+&ipk";;
  
}
}
?>

highly appreciate for yr help

-- 
Warm regards,
Afif
mailto:afif@sur.ogs-id.com



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux