Fehler: ' . $exception->getMessage() . '

'; if (get_class($exception) != 'Exception') { echo '(Code: ' . $exception->getCode() . ')'; } show_form(); }); if ($_POST) { $sipgate = new sipgateAPI($config['username'], $config['password']); $balance = $sipgate->getBalance(); $message = preg_replace('/\r?\n/m', '\n', trim($_POST['message'])); $blacklist = read_blacklist($config['blocked']); if (!isset($_POST['message'])) { throw new Exception('Keine Nachricht!'); } if ($message == $config['default']) { throw new Exception('Der Standart ist doch langweilig!'); } if ($_POST['antispam'] != md5($message . ceil(time() / $config['delta']))) { // check hash throw new Exception('Willst du mich bescheissen? Bitte aktiviere Javascript!'); } if (strlen($message) > 160) { throw new Exception('Deine Nachricht ist zu lang!'); } if ($balance['CurrentBalance']['TotalIncludingVat'] < $config['reserve']) { throw new Exception('Sorry, aber ich habe kein Gutenhaben mehr!'); } if ($time = is_blacklisted($blacklist, $_SERVER['REMOTE_ADDR'])) { throw new Exception('Sorry, du musst ' . format_duration($config['blocked'] - (time() - $time)) . ' warten, bevor du die nächste SMS versenden kannst!'); } $sipgate->sendSMS($config['recipient'], $message, NULL, $config['recipient']); $balance = $sipgate->getBalance(); echo '

SMS wurde gesendet!

Vielen Dank :)

'; echo '

Du kannst deine nächste SMS in ' . format_duration($config['blocked']) . ' senden!

'; echo '

Verbleibendes Guthaben: ' . round($balance['CurrentBalance']['TotalIncludingVat'], 2) . ' ' . $balance['CurrentBalance']['Currency'] . ' (das sind noch ' . floor(($balance['CurrentBalance']['TotalIncludingVat'] - $config['reserve']) / 0.079) . ' SMS)

'; if ($_SERVER['REMOTE_ADDR'] != '172.0.0.1') $blacklist[] = array($_SERVER['REMOTE_ADDR'], time()); echo '

zuück

'; write_blacklist($blacklist); } else { show_form(); } function show_form() { global $config; $message = (isset($_REQUEST['message'])) ? $_REQUEST['message'] : $config['default']; echo '
Zeichen: ' . strlen($message) . ' (übrig: ' . (160 - strlen($message)) . ')
'; } function format_duration($time) { if ($time < 60) return $time . ' Sekunden'; elseif ($time < 3600) return floor($time / 60) . ' Minuten'; else return floor($time / 3600) . ':' . sprintf('%02d', floor(($time % 3600) / 60)) . ' Stunden'; } ?>