Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
brolaugh committed Oct 2, 2017
2 parents 295780d + 839f17e commit c882b69
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions sendsms.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

// If the text is too long we exit
if (strlen($_POST['text']) > 160) {
//header("Location:/");
echo "length";
header("Location:/");
}


Expand All @@ -34,28 +33,27 @@
$api->add($sms);
}

//header("Location:/?sent=success");

header("Location:/?sent=success");

// Turns the numbers into the correct format
function fixNumber(string $number): string{
$prefix = '07';
$alternativePrefix = '+467';

// Remove unnecessary symbols
$number = str_replace(['-','(',')'], '', $number);
$number = str_replace(['-','(',')',' '], '', $number);
$number = trim($number);

// If a number is invalid
if (!preg_match('/(07|\+46|46)[0-9]{1,15}/', $number)) {
//header("Location:/");
var_dump($number);
header("Location:/");
}

// Replace 07 with 467
if (substr($number, 0, strlen($prefix)) == $prefix) {
$number = substr($number, strlen($prefix));
$number = "467" . $number;
}
// Replace +467 with 467
if (substr($number, 0, strlen($alternativePrefix)) == $alternativePrefix) {
$number = substr($number, strlen($alternativePrefix));
$number = "467" . $number;
Expand Down

0 comments on commit c882b69

Please sign in to comment.