invio sms multipli dal prorio sito

Marco196943

Utente Attivo
19 Ago 2012
66
0
0
Eccomi appena registrato fresco, fresco.
Come già detto nella presentazione iniziale, dovrei rompervi le scatole un pochino pochino...
Sto cercando di inserire nel mio sito, la possibilità di inviare degli sms multipli di promozioni flash, ho scaricato dal sito latintsms un piccolo script per l'invio degli sms.
ora dovrei adattarlo alle mie esigenze:
il mio primo punto è quello di recuperare tutti i numeri di telefono dal db facendo in modo che ogni numero finisca con il punto e virgola , ho creato una query ma mi da solo un numero di telefono.
per ora mi fermerei qui sennò pare brutto tutto insieme:cool:
Ringrazio in anticipo a chi voglia aiutarmi
vi posto il mio codice

PHP:
<?php require_once('../../Connections/iscritti.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_iscritti, $iscritti);
$query_Rs_telefono = "SELECT telefono FROM iscrizioni ORDER BY telefono ASC";
$Rs_telefono = mysql_query($query_Rs_telefono, $iscritti) or die(mysql_error());
$row_Rs_telefono = mysql_fetch_assoc($Rs_telefono);
$totalRows_Rs_telefono = mysql_num_rows($Rs_telefono);
?>
<?php


/*
###SCRIPT DI ESEMPIO PER INVIO SMS DI LATINETSMS.IT###
Per tutte le funzionalità e gli script completi di invio SMS e documentazione 
consultare il sito http://www.latinetsms.it/download/
*/

function do_post($host,$uri,$values) {

if (!($socket = fsockopen($host, 80, $errno, $errstr))) return false;

$reqbody='';
while (list($k,$v) = each($values)) $reqbody .= $k."=".urlencode($v)."&";
$contentlength = strlen($reqbody);
$req =
"POST $uri HTTP/1.0\r\n".
"Host: $host\n". "User-Agent: SMS POST AGENT\r\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: $contentlength\r\n\r\n".
$reqbody."\r\n";

if (fputs($socket, $req) < 0 ) return false;
while (!feof($socket)) $result[] = trim(fgets($socket, 4096));
fclose($socket);

if (is_array($result)) return $result;
return false;
}

function SMS_Send($login,$password,$message,$dest,$sender,$flash,$quality,$notify,$wappush,$quantity,$tspan,$userip) {

$VALS = array(
		'login' => $login,
		'password' => $password,
		'message' => $message,
		'dest' => $dest,
		'sender' => $sender,
		'flash' => $flash,
		'quality' => $quality,
		'notify' => $notify,
		'wappush' => $wappush,
		'quantity' => $quantity,
		'timespan' => $tspan,
		'userip' => $userip
		);

$resp = do_post("www.pannellosms.com","/smspost.php",$VALS);

if (!is_array($resp)) return array(false,0);
if (!ereg("OK",$resp[0])) return array(false,0);
foreach ($resp as $ll) if (ereg("^CREDITS:(.*)$",$ll,$p)) return array(true,$p[1]);
return array(false,0);
}

$login		= 'xxxxxxxxxxxxxx';	//nome utente
$password	= 'xxxxxxxxxxxxx';	//password utente

if(isset($_POST["dest"]) && isset($_POST["message"])){
	list ($status,$credits) = SMS_Send($login,$password,$_POST["message"],$_POST["dest"],$_POST["sender"],0,'Alta',$_POST["notify"],'',0,0,$HTTP_SERVER_VARS['REMOTE_ADDR']);
	$output = ($status) ? 'Messaggio inviato. Credito residuo: '.$credits.'<br>' : 'Errore di invio del messaggio<br><br>';
}
?>
<body bgcolor="#D7E6EA">
<table align="center">
  <form action="inviosms.php" method="POST">
    <tr> 
      <td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><?php echo @$output; ?></b></font></td>
    </tr>
    <tr> 
      <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Messaggio:</font></td>
      <td> 
        <textarea name="message" rows="5" cols="40" wrap="virtual"></textarea>
      </td>
    </tr>
    <tr> 
      <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Destinatario:</font></td>
      <td>
          <textarea name="dest" cols="15"><?php echo $row_Rs_telefono['telefono']; ?></textarea>
          </td>
    </tr>
    <tr> 
      <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Mittente:</font></td>
      <td> 
        <input type="text" name="sender" size="10">
      </td>
    </tr>   
    <tr> 
      <td colspan=2> 
        <div align="center"> 
          <input type="submit" value="Invia">
        </div>
      </td>
    </tr>
  </form>
</table>
<div align="center"></div>
<?php
mysql_free_result($Rs_telefono);
?>
 
Ultima modifica di un moderatore:

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
recuperare tutti i numeri di telefono dal db facendo in modo che ogni numero finisca con il punto e virgola
intanto come vuoi recuperarli?
una stringa unica es.
$numeri="3332569;356987;123456;789321;";
o singolamnete es. con un array?
nel primo caso potresti fare
PHP:
<?php
//.......
mysql_select_db($database_iscritti, $iscritti);
$query_Rs_telefono = "SELECT telefono FROM iscrizioni ORDER BY telefono ASC";
$Rs_telefono = mysql_query($query_Rs_telefono, $iscritti) or die(mysql_error());
//$row_Rs_telefono = mysql_fetch_assoc($Rs_telefono);
$totalRows_Rs_telefono = mysql_num_rows($Rs_telefono);
if($totalRows_Rs_telefono> 0){
	$numeri="";
	while($riga=mysql_fetch_array($Rs_telefono)){
		$numeri.=$riga['telefono'].";";//se non ti serve eventualmente poi togli l'ultimo ;
		//ottieni la stringa 3332569;356987;123456;789321; ecc....
	}
}else{
	echo "non ci sono numeri nel db";
}
//........
?>
nel secondo
PHP:
<?php
//.......
mysql_select_db($database_iscritti, $iscritti);
$query_Rs_telefono = "SELECT telefono FROM iscrizioni ORDER BY telefono ASC";
$Rs_telefono = mysql_query($query_Rs_telefono, $iscritti) or die(mysql_error());
//$row_Rs_telefono = mysql_fetch_assoc($Rs_telefono);
$totalRows_Rs_telefono = mysql_num_rows($Rs_telefono);
if($totalRows_Rs_telefono>0){
	$numeri=array();
	while($riga=mysql_fetch_array($Rs_telefono)){
		$numeri[]=$riga['telefono'].";";
		/*ottieni un array del tipo
		$numeri[0] => 3332569;
		$numeri[1] => 356987;
		$numeri[2] => 123456;
		ecc....
		*/
	}
}else{
	echo "non ci sono numeri nel db";
}
//........
?>

p.s.
guarda che in $login = xxxxxxxxxxxxxx'; //nome utente
ti eri dimenticato un apice
$login = 'xxxxxxxxxxxxxx'; //nome utente
 
Ultima modifica:

Marco196943

Utente Attivo
19 Ago 2012
66
0
0
Carisssimo!!!!

Ti ringrazio per la tua celerità, ma oggi è domenica, e c'è il sole, non mi aspettavo tanta grazia:fonzie:
hai colto nel segno, con un array è perfetto, ho controllato il tuo codice ed è moto interessante la costruzzione dell'array, me lo son già segnato:)
ho provato come hai detto tu con la query e l'array, poi nel form nella casella telefono ho provato a recuperarla con <?php echo $telefono ?>,o <?php echo $riga ?> ma senza risultati non visualizzo i due numeri di telefono memorizzati nel database dove mi sto impicciando?:crying:

ciao

intanto come vuoi recuperarli?
una stringa unica es.
$numeri="3332569;356987;123456;789321;";
o singolamnete es. con un array?
nel primo caso potresti fare
PHP:
<?php
//.......
mysql_select_db($database_iscritti, $iscritti);
$query_Rs_telefono = "SELECT telefono FROM iscrizioni ORDER BY telefono ASC";
$Rs_telefono = mysql_query($query_Rs_telefono, $iscritti) or die(mysql_error());
//$row_Rs_telefono = mysql_fetch_assoc($Rs_telefono);
$totalRows_Rs_telefono = mysql_num_rows($Rs_telefono);
if($totalRows_Rs_telefono> 0){
	$numeri="";
	while($riga=mysql_fetch_array($Rs_telefono)){
		$numeri.=$riga['telefono'].";";//se non ti serve eventualmente poi togli l'ultimo ;
		//ottieni la stringa 3332569;356987;123456;789321; ecc....
	}
}else{
	echo "non ci sono numeri nel db";
}
//........
?>
nel secondo
PHP:
<?php
//.......
mysql_select_db($database_iscritti, $iscritti);
$query_Rs_telefono = "SELECT telefono FROM iscrizioni ORDER BY telefono ASC";
$Rs_telefono = mysql_query($query_Rs_telefono, $iscritti) or die(mysql_error());
//$row_Rs_telefono = mysql_fetch_assoc($Rs_telefono);
$totalRows_Rs_telefono = mysql_num_rows($Rs_telefono);
if($totalRows_Rs_telefono>0){
	$numeri=array();
	while($riga=mysql_fetch_array($Rs_telefono)){
		$numeri[]=$riga['telefono'].";";
		/*ottieni un array del tipo
		$numeri[0] => 3332569;
		$numeri[1] => 356987;
		$numeri[2] => 123456;
		ecc....
		*/
	}
}else{
	echo "non ci sono numeri nel db";
}
//........
?>

p.s.
guarda che in $login = xxxxxxxxxxxxxx'; //nome utente
ti eri dimenticato un apice
$login = 'xxxxxxxxxxxxxx'; //nome utente
 

Malware

Utente Attivo
19 Lug 2012
112
0
0
Ciao

Mi intrometto un'attimo

PHP:
echo $telefono;
echo $riga;

Non esiste nessuna variabile $telefono o $riga.



I numeri di telefono devi visualizzarli dall'array $numeri:

PHP:
$num_totale_di_numeri=count($numeri); //trovo il numero totale dei numeri

for ($n=0; $n<$num_totale_di_numeri; $n++) {

echo $numeri[$n];

}


Se vuoi giocare con gli array guarda qui: link :)
 
Ultima modifica di un moderatore:

Marco196943

Utente Attivo
19 Ago 2012
66
0
0
Scusate...

come posso potrei, abbracciarv, e stringervi forte forte, e dirvi guardandovi negli occhi.... GRAZZZZZZZZZIIIIIIIIIEEEEEEEEE:fonzie:
 

Marco196943

Utente Attivo
19 Ago 2012
66
0
0
Ora se puo' essere utile....

QUESTO è IL CODICE COMPLETO GRAZIE AL VOSTRO AIUTO DI INVIO DI SMS MULTIMPLI IN PHP


PHP:
<?php  include('../../Connections/iscritti.php'); 
//.......
mysql_select_db($database_iscritti, $iscritti);
$query_Rs_telefono = "SELECT telefono FROM iscrizioni ORDER BY telefono ASC";
$Rs_telefono = mysql_query($query_Rs_telefono, $iscritti) or die(mysql_error()); 
//$row_Rs_telefono = mysql_fetch_assoc($Rs_telefono);
$totalRows_Rs_telefono = mysql_num_rows($Rs_telefono);
if($totalRows_Rs_telefono>0){
    $numeri=array();
    while($riga=mysql_fetch_array($Rs_telefono)){
        $numeri[]=$riga['telefono'].";";
        /*ottieni un array del tipo
        $numeri[0] => 3332569;
        $numeri[1] => 356987;
        $numeri[2] => 123456;
        ecc....
        */
    }
	
}else{
    echo "non ci sono numeri nel db";
}
//........ 
?>
<?php


/*
###SCRIPT DI ESEMPIO PER INVIO SMS DI LATINETSMS.IT###
Per tutte le funzionalità e gli script completi di invio SMS e documentazione 
consultare il sito http://www.latinetsms.it/download/
*/

function do_post($host,$uri,$values) {

if (!($socket = fsockopen($host, 80, $errno, $errstr))) return false;

$reqbody='';
while (list($k,$v) = each($values)) $reqbody .= $k."=".urlencode($v)."&";
$contentlength = strlen($reqbody);
$req =
"POST $uri HTTP/1.0\r\n".
"Host: $host\n". "User-Agent: SMS POST AGENT\r\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: $contentlength\r\n\r\n".
$reqbody."\r\n";

if (fputs($socket, $req) < 0 ) return false;
while (!feof($socket)) $result[] = trim(fgets($socket, 4096));
fclose($socket);

if (is_array($result)) return $result;
return false;
}

function SMS_Send($login,$password,$message,$dest,$sender,$flash,$quality,$notify,$wappush,$quantity,$tspan,$userip) {

$VALS = array(
		'login' => $login,
		'password' => $password,
		'message' => $message,
		'dest' => $dest,
		'sender' => $sender,
		'flash' => $flash,
		'quality' => $quality,
		'notify' => $notify,
		'wappush' => $wappush,
		'quantity' => $quantity,
		'timespan' => $tspan,
		'userip' => $userip
		);

$resp = do_post("www.pannellosms.com","/smspost.php",$VALS);

if (!is_array($resp)) return array(false,0);
if (!ereg("OK",$resp[0])) return array(false,0);
foreach ($resp as $ll) if (ereg("^CREDITS:(.*)$",$ll,$p)) return array(true,$p[1]);
return array(false,0);
}

$login		= 'XXXXXX';	//nome utente
$password	= 'XXXXXX';	//password utente

if(isset($_POST["dest"]) && isset($_POST["message"])){
	list ($status,$credits) = SMS_Send($login,$password,$_POST["message"],$_POST["dest"],$_POST["sender"],0,'Alta',$_POST["notify"],'',0,0,$HTTP_SERVER_VARS['REMOTE_ADDR']);
	$output = ($status) ? 'Messaggio inviato. Credito residuo: '.$credits.'<br>' : 'Errore di invio del messaggio<br><br>';
}
?>
<body bgcolor="#D7E6EA">
<table align="center">
  <form action="inviosms.php" method="POST">
    <tr> 
      <td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><?php echo @$output; ?></b></font></td>
    </tr>
    <tr> 
      <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Messaggio:</font></td>
      <td> 
        <textarea name="message" rows="5" cols="40" wrap="virtual"></textarea>
      </td>
    </tr>
    <tr> 
      <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Destinatario:</font></td>
      <td>
        <textarea name="dest" cols="15"><?php $num_totale_di_numeri=count($numeri); //trovo il numero totale dei numeri

For ($n=0; $n<$num_totale_di_numeri; $n++) {

echo $numeri[$n];

}   ?></textarea>
      </td>
    </tr>
    <tr> 
      <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Mittente:</font></td>
      <td> 
        <input type="text" name="sender" size="10">
      </td>
    </tr>   
    <tr> 
      <td colspan=2> 
        <div align="center"> 
          <input type="submit" value="Invia">
        </div>
      </td>
    </tr>
  </form>
</table>
<div align="center"></div>
<?php
mysql_free_result($Rs_telefono);
?>
 

Marco196943

Utente Attivo
19 Ago 2012
66
0
0
Scusate se riapro il post...

gentilmente se volessi avere sempre presente, il credito residuo, e poter scegliere quanti sms voglio inviare, tipo pacchetti da 10, 20, ecc.. come posso integrarlo in questo script? grazie e scusate la riapertura.
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
sarebbe meglio un altro post (un problema => un post) comunque (dovrei sapere meglio come è il tuo db) ma da quello che ho capito un tuo iscritto può "acquistare" un pacchetto di 10, 20,.... sms. qquindi all'atto dell'acquisto metti tale valore nel db in corrispondenza dell'utente e quando questi invia un sms decrementi il valore di uno e mfai in modo che se la quantità è zero non possa inviare, per vederli poi nelle astessa maniere con cui vedi gli altri dati
 
Discussioni simili
Autore Titolo Forum Risposte Data
I [PHP] Invio sms multipli PHP 4
ComfortablyNumb [PHP] Invio sms automatici PHP 1
F Codice invio sms da integrare PHP 1
F invio e ricezione sms PHP 4
G web application per l'invio di sms gratis dai vostri siti Presenta il tuo Sito 2
D Sito invio sms - questioni di privacy Leggi, Normative e Fisco 2
V Invio sms da web senza appoggiarsi ad alcun servizio PHP 11
F invio sms Javascript 0
WorldWideWeb Invio SMS da VB6 Visual Basic 0
R Invio dai tessera sanitaria PHP 1
M telecamera Foscam - mancato invio mail ad account gmail IP Cam e Videosorveglianza 0
G Invio di più valori con la stessa checkbox PHP 4
M Invio dati database via email php PHP 0
K [php]form invio dati PHP 0
G form invio multiplo con checkbox PHP 12
nivaria.achinet Intercettare form solo dopo invio Javascript 1
M Memorizzare i dati nei campi prima dell'invio al db PHP 4
M Unire 2 funzioni per l'invio di un form e con l'apertura di un div Javascript 0
Z PHP.INI - STMP per invio email con PHP Server Dedicati e VPS 0
M Form: come tornare ai campi già compilati dopo invio PHP 1
G Invio form con PHP PHP 3
M Invio di email PHP 0
A invio massivo dati a file php Javascript 4
P Funzione jQuery Ajax invio file a php jQuery 1
Cosina Upload multiplo con invio allegati per email PHP 0
C Mailchimp ritardo invio newsletter subscribers Email Marketing 1
G creazione menu a tendina e invio a pagina php PHP 1
R Invio mail con allegati multipli PHP 0
R Invio mail con allegati da directory PHP 1
Cosina Invio messaggio a mailing list su file txt PHP 9
W Invio Dati ad un altra pagina Classic ASP 1
S Invio email da form PHP 8
psicomia Server e url per invio di file Server Dedicati e VPS 3
max1974 Invio email PHP 12
Daniele_Carrara Problema timeout - invio mail PHP 7
U PHP bottone per invio mail o ritorno al form PHP 15
G Invio mail con php da dati prelevati da un database PHP 9
L [PHP] Invio Immagini PHP 1
AC1 [PHP] Invio Mail PHP 18
S Consigli per invio di comunicati stampa Discussioni Varie 2
A [PHP] Invio automatico dati da form PHP 6
F Estrazione Email di persone selezionate e attive / facebook + invio di massa! Annunci servizi di Social Media Marketing 0
ANDREA20 [PHP] Modulo email invio PHP 5
Shyson [PHP] Codice iscrizione e invio avviso nuovi articoli PHP 3
Tommy03 Errore invio email con PHP PHP 1
B [PHP] Invio mail automatico dopo compilazione form - db PHP 25
Cosina [PHP] Preservare i campi del form solo se l'invio non ha successo PHP 5
A [PHP] errore 404 e invio mai path pagina con link interrotto PHP 2
A [PHP] Invio messaggio a tutti gli iscritti PHP 2
M [PHP] Problema script ricezione e invio posta... PHP 1

Discussioni simili