Azi toti furnizorii au oferte cu mesaje gratuite in retea. De ce sa nu configuram o interfata web pe care sa o folosim in acest scop.

Necesar

- un aparat Nokia compatibil cu aplicatia gnokii. (In cazul meu Nokia 3500C).
- cablu de legatura (in cazul meu cablu USB din pachet).

Instalare si configurare gnokii

Instalam aplicatia gnokii:

#urpmi gnokii

modificam fisierul de configurare a aplicatiei: /etc/gnokiirc

[global]
port = /dev/ttyACM0
model = AT
connection = serial
debug=on

Conectam aparatul si il comutam pe modul Nokia - ori modul de conectare cu aplicatia dedicata de la NOKIA.

Verificam detectarea aparatului de catre gnokii

gnokii --identify

In caz de detectare veti primi la final urmatoarele:

IMEI         : 35768701xxxxxx
Manufacturer : Nokia
Model        : Nokia 3500c
Product name : Nokia 3500c
Revision     : V 05.51
Serial device: closing device

Adaugam userul apache la grupul dialout in fisierul /etc/group

dialout:x:83:apache

repornim serverul apache

#service httpd restart

Creare interfata web

Creem intr-un folder (de ex sms/) pe serverul nostru web urmatoarea interfata (in index.php):

<?php
/**
 *
 * Script para enviar SMS desde una pagina web usando PHP como lenguage script y Gnokii como interfaz de conexión entre el teléfono y la aplicación
 *
 * Desarrollado por Filein Rommel León Méndez
 * Script liberado bajo la licencia GPL
 *
 */
 
 echo siteHeader();
 $option = $_POST["status_page"];
 
 switch($option){
        case "":
                        echo showForm();
                break;
        case "sms_sender":
                        pipes(ValidateNumber( $_POST["phone_number"]), $_POST["sms_message"]);
                break;
 }
 
 function showForm(){
        $frontEnd =
        "<div align=center>" .
        "<form name=smssender method=post action=\"$_SERVER[PHP_SELF]\" >".
                "<table  class=MAINFORM>".
                "<tr> <td colspan=2 >Compuneti SMS</td> </tr>".
                "<tr> <td colspan=2></td> </tr>".
                "<tr> <td class=NAME_FIELD>Telefon:</td>  <td><input type=text name=phone_number size=70 maxlenght=16 class=TEXT_BOX></td> </tr>".
                "<tr> <td class=NAME_FIELD>Mesaj:</td>  <td><textarea name=sms_message cols=60 rows=5 class=TEXT_AREA></textarea></td> </tr>".
                "<tr> <td></td>  <td><input type=button name=send_message value='Enviar' onClick='javascript:document.forms[0].submit();' class=TXT_BUTTON></td> </tr>".
                "<input type=hidden name=status_page value=\"sms_sender\" >".
                "</table>".
        "</form>" .
        "</div>";
        return $frontEnd;              
 }
 

 
 function siteHeader(){
        $header = "<link rel=stylesheet type=text/css href=estilo.css>";
        return $header;
 }
 
 
        function pipes($number="", $message=""){
 
        if(is_numeric($number)!="" and is_string($message) and $message!=""){
                        error_reporting(E_ALL);
                //message      
                        $echo_pipe = popen(" echo \"$message\" ", 'r');
                        //echo "'$echo_pipe'; " . gettype($echo_pipe) . "\n";
                //gnokii       
                        $gnokii_pipe = popen("gnokii --sendsms $number -r", 'w');
                        //echo "'$gnokii_pipe'; " . gettype($gnokii_pipe) . "\n";
                //pipes validate      
                    if ((!$echo_pipe) || (!$gnokii_pipe)) {
                                fprintf(stderr, "One or both pipes failed.\n");
                                return EXIT_FAILURE;
                    }
                    $bytes_read = 0;
                //execute pipes
                    while ($buffer = fread($echo_pipe, 2096)) {
                                fwrite($gnokii_pipe, $buffer);
                                $bytes_read += strlen($buffer);
                    }
                //close pipes
                    //printf("Total bytes read = %d\n", $bytes_read);
                    $status_function = 0;
                    if (pclose($echo_pipe) != 0) {
                                fprintf(stderr, "Could not run 'echo', or other error.\n");
                                $status_function++;
                    }
                    if (pclose($gnokii_pipe) != 0) {
                                fprintf(stderr, "Could not run 'festival', or other error.\n");
                                $status_function++;
                    }
                    if($status_function>=2){
                        echo sms_successful($number, $message);
                    }
                        echo sms_successful($number, $message);
                   
                }
        }
       
       
        function sms_successful($number="", $message=""){
                return "<div align=center>" .
                "<table class=MAINFORM><tr class=successful><td colspan=2>Mensaj expediat cu succes</td></tr>" .
                "<tr><td class=name_field>Telefon: </td><td class=value_field>$number</td></tr>" .
                "<tr><td class=name_field>Mesaj: </td><td class=value_field>$message</td></tr>" .
                "</table>" .
                "</div>";      
        }
       
        function ValidateNumber($number ){
                return eregi_replace("[^0-9]", "", $number);
        }
 
?>

precum si fisierul CSS

.GENERAL{visibility:hidden; position:absolute; top:80; left:350; width:500; height:250; color:red; background-color:#F1F1F1; font-size:13; font-weight:bold; vertical-align:top; text-decoration:none; text-align:center; border-width:1; border-style:groove; border-color:black; }
	
.MAINFORM{color:black; background-color:#C3CDFE; font-size:14; font-weight:bold; text-align:left; border-width:0;}

.TEXT_FIELD{color:black; background-color:#8DFF4D; font-size:13; font-weight:bold; vertical-align:top; text-decoration:none; text-align:center; border-width:1; }
.TEXT_AREA{color:black; background-color:#FFEC4D; font-size:13; font-weight:bold; vertical-align:top; text-decoration:none; text-align:center; border-width:1; }
.NAME_FIELD{color:black; background-color:#FFFFFF; font-size:13; font-weight:bold; vertical-align:top; text-decoration:none; text-align:center; border-width:1; }
.VALUE_FIELD{color:black; background-color:#F4B5FE; font-size:13; font-weight:bold; vertical-align:top; text-decoration:none; text-align:center; border-width:1; }

.SUCCESSFUL{color:blue; background-color:#D5FFEF; font-size:13; font-weight:bold; vertical-align:top; text-decoration:none; text-align:center; border-width:1; border-style:groove; border-color:black; }

Interfata o vom putea accesa la adresa http://127.0.0.1/sms/

Sursa: http://phylevn.mexrom.net/index.php/blog/show/187.html

software/altele/web2sms.txt · Ultima modificare: 2010/03/30 20:28 (editare externă)
 
Exceptând locurile unde este altfel specificat, conţinutul acestui wiki este licenţiat sub următoarea licenţă: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki