Join us on Facebook

Please wait..10 Seconds Cancel
Showing posts with label Web Development Tips & Tricks. Show all posts
Showing posts with label Web Development Tips & Tricks. Show all posts

2.08.2014

// // 4 comments

Send SMS via GSM Modem Using PHP

 
 
<?php

//SMS via GSM Modem - A PHP class to send SMS messages via a GSM modem 
  attached to the computers serial port.

//Windows only (tested on XP with PHP 5.2.6)
//Tested with the EZ863 (Telit GE863) GSM modem
//Requires that PHP has permission to access "COM" system device, 
  and system "mode" command

error_reporting(E_ALL);

//Example

$gsm_send_sms = new gsm_send_sms();
$gsm_send_sms->debug = false;
$gsm_send_sms->port = 'COM1';
$gsm_send_sms->baud = 115200;
$gsm_send_sms->init();

$status = $gsm_send_sms->send('+44123456789', 'testing 123');
if ($status) {
 echo "Message sent\n";
} else {
 echo "Message not sent\n";
}

$status = $gsm_send_sms->send('+44123456789', 'testing 456');
if ($status) {
 echo "Message sent\n";
} else {
 echo "Message not sent\n";
}

$gsm_send_sms->close();







//Send SMS via serial SMS modem
class gsm_send_sms {

 public $port = 'COM1';
 public $baud = 115200;

 public $debug = false;

 private $fp;
 private $buffer;

 //Setup COM port
 public function init() {

  $this->debugmsg("Setting up port: \"{$this->port} @ \"{$this->baud}\" baud");

  exec("MODE {$this->port}: BAUD={$this->baud} PARITY=N DATA=8 STOP=1", $output, $retval);

  if ($retval != 0) {
   throw new Exception('Unable to setup COM port, check it is correct');
  }

  $this->debugmsg(implode("\n", $output));

  $this->debugmsg("Opening port");

  //Open COM port
  $this->fp = fopen($this->port . ':', 'r+');

  //Check port opened
  if (!$this->fp) {
   throw new Exception("Unable to open port \"{$this->port}\"");
  }

  $this->debugmsg("Port opened");
  $this->debugmsg("Checking for responce from modem");

  //Check modem connected
  fputs($this->fp, "AT\r");

  //Wait for ok
  $status = $this->wait_reply("OK\r\n", 5);

  if (!$status) {
   throw new Exception('Did not receive responce from modem');
  }

  $this->debugmsg('Modem connected');

  //Set modem to SMS text mode
  $this->debugmsg('Setting text mode');
  fputs($this->fp, "AT+CMGF=1\r");

  $status = $this->wait_reply("OK\r\n", 5);

  if (!$status) {
   throw new Exception('Unable to set text mode');
  }

  $this->debugmsg('Text mode set');

 }

 //Wait for reply from modem
 private function wait_reply($expected_result, $timeout) {

  $this->debugmsg("Waiting {$timeout} seconds for expected result");

  //Clear buffer
  $this->buffer = '';

  //Set timeout
  $timeoutat = time() + $timeout;

  //Loop until timeout reached (or expected result found)
  do {

   $this->debugmsg('Now: ' . time() . ", Timeout at: {$timeoutat}");

   $buffer = fread($this->fp, 1024);
   $this->buffer .= $buffer;

   usleep(200000);//0.2 sec

   $this->debugmsg("Received: {$buffer}");

   //Check if received expected responce
   if (preg_match('/'.preg_quote($expected_result, '/').'$/', $this->buffer)) {
    $this->debugmsg('Found match');
    return true;
    //break;
   } else if (preg_match('/\+CMS ERROR\:\ \d{1,3}\r\n$/', $this->buffer)) {
    return false;
   }

  } while ($timeoutat > time());

  $this->debugmsg('Timed out');

  return false;

 }

 //Print debug messages
 private function debugmsg($message) {

  if ($this->debug == true) {
   $message = preg_replace("%[^\040-\176\n\t]%", '', $message);
   echo $message . "\n";
  }

 }

 //Close port
 public function close() {

  $this->debugmsg('Closing port');

  fclose($this->fp);

 }

 //Send message
 public function send($tel, $message) {

  //Filter tel
  $tel = preg_replace("%[^0-9\+]%", '', $tel);

  //Filter message text
  $message = preg_replace("%[^\040-\176\r\n\t]%", '', $message);

  $this->debugmsg("Sending message \"{$message}\" to \"{$tel}\"");

  //Start sending of message
  fputs($this->fp, "AT+CMGS=\"{$tel}\"\r");

  //Wait for confirmation
  $status = $this->wait_reply("\r\n> ", 5);

  if (!$status) {
   //throw new Exception('Did not receive confirmation from modem');
   $this->debugmsg('Did not receive confirmation from modem');
   return false;
  }

  //Send message text
  fputs($this->fp, $message);

  //Send message finished indicator
  fputs($this->fp, chr(26));

  //Wait for confirmation
  $status = $this->wait_reply("OK\r\n", 180);

  if (!$status) {
   //throw new Exception('Did not receive confirmation of messgage sent');
   $this->debugmsg('Did not receive confirmation of messgage sent');
   return false;
  }

  $this->debugmsg("Message sent");

  return true;

 }

}

?>
Read More

1.29.2014

// // Leave a Comment

80+ Free Responsive HTML5 CSS3 Website Templates

You know ,today,websites have to be more appealing and interactive.You can achieve this using quite a few development technologies but for most designers and developers HTML5 and CSS3 is the best solution.
In today’s post,we have collected (handpicked) really high quality HTML5 CSS3 website templates to use freely.Yes,they are all free and responsive.You can play with them however you want.
Here is the collection of 90 absolutely free responsive HTML5 CSS3 website templates.

Designa

free-html5-responsive-website-templates 
Download | Demo

Flexapp

2.free-html5-responsive-website-templates 
Download | Demo

Liquid Gem

3.free-html5-responsive-website-templates 
Download | Demo

Respond 1.5

4.free-html5-responsive-website-templates 
Download | Demo

Brownie

5.free-html5-responsive-website-templates 
Download | Demo

Zeni

6.free-html5-responsive-website-templates 
Download | Demo

Madison

7.free-html5-responsive-website-templates 
Download | Demo

Response

8.free-html5-responsive-website-templates 
Download | Demo

Sunrise

9.free-html5-responsive-website-templates 
Download | Demo

OnePager

10.free-html5-responsive-website-templates 
Download | Demo

Brushed

11.free-html5-responsive-website-templates 
Download | Demo

Folder

12.free-html5-responsive-website-templates 
Download | Demo

Modus

13.free-html5-responsive-website-templates 
Download | Demo

Abc

14.free-html5-responsive-website-templates 
Download | Demo

It Fits

15.free-html5-responsive-website-templates 
Download | Demo

Serendipity

16.free-html5-responsive-website-templates 
Download | Demo

Responsiva

17.free-html5-responsive-website-templates 
Download | Demo

Obscura

18.free-html5-responsive-website-templates 
Download | Demo

Zerofour

19.free-html5-responsive-website-templates 
Download | Demo

Base 2013

20.free-html5-responsive-website-templates 
Download | Demo

ImCreative

21.free-html5-responsive-website-templates 
Download | Demo

Burn Studio

22.free-html5-responsive-website-templates 
Download | Demo

Photography

23.free-html5-responsive-website-templates 
Download | Demo

Prologue

24.free-html5-responsive-website-templates 
Download | Demo

Helios

25.free-html5-responsive-website-templates 
Download | Demo

Vivid Photo

26.free-html5-responsive-website-templates 
Download | Demo

ResponseEve

27.free-html5-responsive-website-templates 
Download | Demo

Proximet

28.free-html5-responsive-website-templates 
Download | Demo

Miniport

29.free-html5-responsive-website-templates 
Download | Demo

Dopetrope

30.free-html5-responsive-website-templates 
Download | Demo

Striped

31.free-html5-responsive-website-templates 
Download | Demo

Verti

32.free-html5-responsive-website-templates 
Download | Demo

Curve

33.free-html5-responsive-website-templates 
Download | Demo

Retina

34.free-html5-responsive-website-templates 
Download | Demo

Digy

35.free-html5-responsive-website-templates 
Download | Demo

Simple

36.free-html5-responsive-website-templates 
Download | Demo

RS-1200 PTT 22

37.free-html5-responsive-website-templates 
Download | Demo

Txt

38.free-html5-responsive-website-templates 
Download | Demo

Keyners

39.free-html5-responsive-website-templates 
Download | Demo

zBoomMusic

40.free-html5-responsive-website-templates 
Download | Demo

zParalexy

41.free-html5-responsive-website-templates 
Download | Demo

zCumbeton

43.free-html5-responsive-website-templates 
Download | Demo

zBamboo

44.free-html5-responsive-website-templates 
Download | Demo

Portfolio Template

45.free-html5-responsive-website-templates 
Download | Demo

Telephasic

46.free-html5-responsive-website-templates 
Download | Demo

Strongly Typed

47.free-html5-responsive-website-templates 
Download | Demo

Parallelism

48.free-html5-responsive-website-templates 
Download | Demo

Escape Velocity

49.free-html5-responsive-website-templates 
Download | Demo

Astral

50.free-html5-responsive-website-templates 
Download | Demo

Retina Ready Responsive App Landing Page

51.free-html5-responsive-website-templates 
Download | Demo

Arcana

52.free-html5-responsive-website-templates 
Download | Demo

Halcyonic

53.free-html5-responsive-website-templates 
Download | Demo

Minimaxing

54.free-html5-responsive-website-templates 
Download | Demo

One Page Template

55.free-html5-responsive-website-templates 
Download | Demo

One Page Resume Template

56.free-html5-responsive-website-templates 
Download | Demo


Produkta

58.free-html5-responsive-website-templates 
Download | Demo

Register Template with Fullscreen Background Slideshow

59.free-html5-responsive-website-templates 
Download | Demo

Vintage

60.free-html5-responsive-website-templates 
Download | Demo

Megacorp

61.free-html5-responsive-website-templates 
Download | Demo

Tapestry

62.free-html5-responsive-website-templates 
Download | Demo

Ex Machina

63.free-html5-responsive-website-templates 
Download | Demo

Citrusy

64.free-html5-responsive-website-templates 
Download | Demo

Skylined

65.free-html5-responsive-website-templates 
Download | Demo

Heavy Industry

66.free-html5-responsive-website-templates 
Download | Demo

Azure

67.free-html5-responsive-website-templates 
Download | Demo

Colorized

68.free-html5-responsive-website-templates 
Download | Demo

Affinity

69.free-html5-responsive-website-templates 
Download | Demo

Eleganta

70.free-html5-responsive-website-templates 
Download | Demo

Elemental

71.free-html5-responsive-website-templates 
Download | Demo

Altitude

72.free-html5-responsive-website-templates 
Download | Demo

Royale

73.free-html5-responsive-website-templates 
Download | Demo

Monochromed

74.free-html5-responsive-website-templates 
Download | Demo

İridium

75.free-html5-responsive-website-templates 
Download | Demo

Imagination

76.free-html5-responsive-website-templates 
Download | Demo

Affection

77.free-html5-responsive-website-templates 
Download | Demo

Di’Verso

78.free-html5-responsive-website-templates 
Download | Demo

Keyners

79.free-html5-responsive-website-templates 
Download | Demo

Wedding

80.free-html5-responsive-website-templates 
Download | Demo

Mori Dark

81.free-html5-responsive-website-templates 
Download | Demo

Flat Design Portfolio Template

82.free-html5-responsive-website-templates 
Download | Demo

Legend

83.free-html5-responsive-website-templates 
Download | Demo

Appology

84.free-html5-responsive-website-templates 
Download | Demo

zBusiness

85.free-html5-responsive-website-templates 
Download | Demo

zStartup

86.free-html5-responsive-website-templates 
Download | Demo

zAgroPlus

87.free-html5-responsive-website-templates 
Download | Demo

Codester

89.free-html5-responsive-website-templates 
Download | Demo

HalfTone

90.free-html5-responsive-website-templates 
Download | Demo

Triangle

91.free-html5-responsive-website-templates 
Download | Demo
Read More