Advertisement
johnmahugu

gsm

May 25th, 2016
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.18 KB | None | 0 0
  1. <?php
  2.   $strResult = "n/a";
  3.   $strRecipient = "[ToAddress]";
  4.   $strPincode = "";
  5.  
  6.   $objGsm = new COM("AxSms.Gsm", NULL, CP_UTF8 );
  7.   $objGsm->LogFile = sys_get_temp_dir()."Gsm.log";
  8.   //Windows default: 'C:\Windows\Temp\Gsm.log'
  9.  
  10.   //Form submitted
  11.   if (isset( $_POST["btnSendMessage"] ))
  12.   {
  13.     $obj;
  14.     $strMessageReference;
  15.     $objSmsMessage   = new COM("AxSms.Message",    NULL, CP_UTF8 );
  16.     $objSmsConstants = new COM("AxSms.Constants" , NULL, CP_UTF8 );
  17.    
  18.     $strName = $_POST["ddlDevices"];
  19.     $strPincode = $_POST["txtPincode"];
  20.     $strRecipient = $_POST["txtToAddress"];
  21.     $iDeviceSpeed = $_POST["ddlDeviceSpeed"];
  22.    
  23.     $objGsm->Clear();
  24.     $objGsm->LogFile = $_POST["txtResult"];
  25.     $objGsm->Open($strName, $strPincode, $iDeviceSpeed);
  26.    
  27.     if ($objGsm->LastError != 0)
  28.     {
  29.       $strResult = $objGsm->LastError . ": " . $objGsm->GetErrorDescription($objGsm->LastError);
  30.       $objGsm->Close();
  31.     }
  32.     else
  33.     {
  34.       //Message Settings
  35.       $objSmsMessage->Clear();
  36.       $objSmsMessage->ToAddress = $strRecipient;
  37.       $objSmsMessage->Body = $_POST["txtMessage"];
  38.      
  39.       if (isset( $_POST["cbxUnicode"] ))
  40.       {
  41.         $objSmsMessage->DataCoding = $objSmsConstants->DATACODING_UNICODE;
  42.       }
  43.      
  44.       //Send the message !
  45.       $obj = $objSmsMessage;
  46.       $objGsm->SendSms($obj, $objSmsConstants->MULTIPART_ACCEPT, 0);
  47.       $objSmsMessage = $obj;
  48.      
  49.       $strResult = $objGsm->LastError . ": " . $objGsm->GetErrorDescription($objGsm->LastError);
  50.      
  51.       $objGsm->Close();
  52.     }
  53.   }  
  54.    
  55. //HTML-CSS layout includes, no code there!
  56. include('css/Header.html');
  57. include('css/Menu.html');
  58. ?>
  59.     <div class="container">
  60.       <h1>SMS Component PHP GSM Sample</h1>
  61.       <hr />
  62.       <p>
  63.         This demo requires a GSM modem or GSM phone connected to your computer. A SIM card
  64.         is required in this GSM modem. The product works with almost all available GSM modems.
  65.       </p>
  66.       <form action="gsm.php" method="post">
  67.         <h2>SMS Component:</h2>
  68.         <h3>Build: <?php echo $objGsm->Build; ?>; Module: <?php echo $objGsm->Module; ?></h3>
  69.        
  70.         <!-- Device -->
  71.         <label for="Devices">Device:</label>
  72.         <p>
  73.           <select id="Devices" name="ddlDevices">
  74.           <?php
  75.             $strDevice = $objGsm->FindFirstDevice();            
  76.             while ($objGsm->LastError == 0)
  77.             {
  78.               echo '
  79.            <option value="'.$strDevice.'">'.$strDevice.'</option>';
  80.               $strDevice = $objGsm->FindNextDevice();
  81.             }
  82.            
  83.             $strPort = $objGsm->FindFirstPort();
  84.             while ($objGsm->LastError == 0)
  85.             {
  86.               echo '
  87.            <option value="'.$strPort.'">'.$strPort.'</option>';
  88.               $strPort = $objGsm->FindNextPort();
  89.             }
  90.           ?>
  91.          
  92.           </select>
  93.         </p>
  94.        
  95.         <!-- Device Speed -->
  96.         <label for="DeviceSpeed">Device Speed:</label>
  97.         <p>
  98.           <select id="DeviceSpeed" name="ddlDeviceSpeed">
  99.             <option value="0">Default</option>
  100.             <option value="110">110</option>
  101.             <option value="300">300</option>
  102.             <option value="600">600</option>
  103.             <option value="1200">1200</option>
  104.             <option value="2400">2400</option>
  105.             <option value="4800">4800</option>
  106.             <option value="9600">9600</option>
  107.             <option value="14400">14400</option>
  108.             <option value="19200">19200</option>
  109.             <option value="38400">38400</option>
  110.             <option value="56000">56000</option>
  111.             <option value="57600">57600</option>
  112.             <option value="64000">64000</option>
  113.             <option value="115200">115200</option>
  114.             <option value="128000">128000</option>
  115.             <option value="230400">230400</option>
  116.             <option value="256000">256000</option>
  117.             <option value="460800">460800</option>
  118.             <option value="921600">921600</option>
  119.           </select>
  120.           Only applies to direct ports, i.e. COM1, COM2, etc.
  121.         </p>
  122.        
  123.         <!-- Pincode -->
  124.         <label for="Pincode">Pincode:</label>
  125.         <p>
  126.           <input type="password" id="Pincode" name="txtPincode" value="<?php echo $strPincode; ?>" />
  127.           Only use when SIM card requires PIN code
  128.         </p>
  129.        
  130.         <!-- Empty row -->
  131.         <div class="clearRow"></div>
  132.        
  133.         <!-- ToAddress -->
  134.         <label for="ToAddress">ToAddress:</label>
  135.         <p>
  136.           <input type="text" id="ToAddress" name="txtToAddress" value="<?php echo $strRecipient; ?>" />
  137.           <a href="http://www.activexperts.com/support/xmstoolkit/?kb=Q4200015" target="_blank">Recipient number format</a>
  138.         </p>
  139.        
  140.         <!-- Body, Unicode -->
  141.         <label for="Body">Body:</label>
  142.         <p>
  143.           <textarea id="Message" name="txtMessage" style="height:45px;"><?php if (!empty ($_POST['txtMessage'])) echo $_POST['txtMessage']; else echo "Hello world send from ActiveXperts SMS Component!" ?></textarea><br />
  144.          
  145.           <input type="checkbox" class="cbFix" id="Unicode" name="cbxUnicode" <?php if (isset($_POST['cbxUnicode'])) echo "checked=\"yes\""; ?> />
  146.           <label for="Unicode">Unicode</label>
  147.         </p>
  148.        
  149.         <!-- Empty row -->
  150.         <div class="clearRow"></div>
  151.        
  152.         <!-- Send button -->
  153.         <div class="clearLabel"></div>
  154.         <p>
  155.           <input type="submit" name="btnSendMessage" value="Send SMS Message!" />
  156.         </p>
  157.        
  158.         <!-- Result -->
  159.         <label for="Result"><b>Result:</b></label>
  160.         <p>
  161.           <input type="text" id="Result" name="txtResult" class="FullWidth Bold" value="<?php echo $strResult; ?>" />
  162.         </p>
  163.       </form>
  164.       <p>
  165.         This demo uses the ActiveXperts SMS Component, an <a href="http://www.activexperts.com" target="_blank">ActiveXperts Software</a> product.<br />
  166.         <a href="index.php">Back to main page</a>
  167.       </p>
  168.     </div><!-- /container -->
  169. <?php
  170. //HTML-CSS layout include, no code there!
  171. include('css/Footer.html'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement