<?php if ($mobile_value) { ?> <div class="form-group"> <label for="mobile_code_input" class="col-sm-2 control-label">Код підтвердження</label> <div class="col-sm-4"> <input type="text" class="form-control" id="mobile_code_input" name="mobile_code_input" maxlength="10" placeholder="Введіть код з SMS" value=""> </div> </div> <div class="row"> <div class="col-sm-offset-2 col-sm-4"> Якщо SMS з кодом не приходить протягом 5 хвилин натисніть кнопку "На початок" і пройдіть перевірку заново.<br><br> Код необхідно ввести до <?php echo session_expires_hhmm(); ?> </div> </div> <?php } // $mobile_value ?> <br> <div> <a href="index.php" class="btn btn-default">« На початок</a> <button type="submit" class="btn btn-primary">Продовжити »</button> </div> </form> <?php
/** * send SMS via Kyivstar CPI */ function send_mobile_code($mobile, $code) { global $settings; if (!preg_match('/^380\\d{9}$/', $mobile)) { return false; } $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<message mid="%s" paid="%s" bearer="SMS">' . "\n" . '<sn>NAB vote</sn><sin>%s</sin>' . "\n" . '<body content-type="text/plain">%s</body></message>'; $mid = time() . "." . $mobile; $sin = $mobile; $paid = $settings['kyivstar_cpi_paid']; $text = "Kod perevirky {$code} \n" . "dijsnyj do " . session_expires_hhmm(); $postdata = sprintf($xml, $mid, $paid, $sin, $text); $url = $settings['kyivstar_cpi_url']; $username = $settings['kyivstar_cpi_username']; $password = $settings['kyivstar_cpi_password']; $curlopts = array(CURLOPT_URL => $url, CURLOPT_TIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => "{$username}:{$password}", CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $postdata); $ch = curl_init(); curl_setopt_array($ch, $curlopts); $res = curl_exec($ch); curl_close($ch); $res = strtr($res, "\r\n", " "); $res = "mid={$mid} sin={$sin} " . $res; log_debug("send_mobile_code", $res); }