+

Leave possibility to run script without sending SMS (just display)

Benjamin Renard [2015-01-07 09:39:48]
Leave possibility to run script without sending SMS (just display)
Filename
send.php
diff --git a/send.php b/send.php
index 10f22cc..122a82e 100644
--- a/send.php
+++ b/send.php
@@ -25,15 +25,15 @@ if (isset($options["c"]) && $options["c"]!==false) {
 }
 else die("You must provide cine code with -c=XXX parameter.\n");

+$send_to=false;
+$mail_domain=false;
 if (isset($options["t"]) && $options["t"]!==false) {
 	$send_to=$options["t"];
+	if (isset($options["d"]) && $options["d"]!==false) {
+		$mail_domain=$options["d"];
+	}
+	else die("You must provide SMS mail domain with -d=domain.tld parameter.\n");
 }
-else die("You must provide phone number with -t=XXXX parameter.\n");
-
-if (isset($options["d"]) && $options["d"]!==false) {
-	$mail_domain=$options["d"];
-}
-else die("You must provide SMS mail domain with -d=domain.tld parameter.\n");

 try {
 	$helper = new AlloHelper;
@@ -106,11 +106,16 @@ foreach($fmovies as $m => $ps){
 // Remove accents
 $msg=$msg=withoutAccents($msg);

-// Format mail
-$mail="$send_to@$mail_domain";
+if ($send_to && $mail_domain) {
+	// Format mail
+	$mail="$send_to@$mail_domain";

-// Display message
-echo "Send to $mail :\n\n$msg";
+	// Display message
+	echo "Send to $mail :\n\n$msg";

-// Send message
-mail($mail,'',$msg);
+	// Send message
+	mail($mail,'',$msg);
+}
+else {
+	echo "$msg";
+}
ViewGit