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
Ringrazio in anticipo a chi voglia aiutarmi
vi posto il mio codice
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

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: