function telephone_verification($member, $payment, $vars, &$errors) { global $config, $t, $db; require_once "{$config['root_dir']}/includes/ccfd/TelephoneVerification.php"; $phone_number = $vars['cc_phone']; $phone_number = preg_replace("/[^\\d]+/i", "", $phone_number); // only digits allowed $was_error = false; $error = ""; $payment_records_edit_log = array(); if ($config['use_number_identification'] && !number_identification($phone_number, $error)) { if ($error) { $error = _TPL_CC_ERROR_TNI . " (" . $error . ")"; } else { $error = _TPL_CC_ERROR_TNI; } $was_error = true; $db->log_error($error); $payment_records_edit_log[] = $error; } $tv = new TelephoneVerification(); $h = array(); // Set inputs and store them in a hash // See http://www.maxmind.com/app/telephone_form for more details on the input fields // Enter your license key here $h["l"] = $config['ccfd_license_key']; // Enter your telephone number here $h["phone"] = $phone_number; $verify_code = ''; $acceptedChars = '09271324537458567879809'; $max = strlen($acceptedChars) - 1; for ($i = 0; $i < 4; $i++) { $verify_code .= $acceptedChars[mt_rand(0, $max)]; } $verify_code = $verify_code * mt_rand(2, 9); $verify_code = substr($verify_code, 0, 4); $h["verify_code"] = $verify_code; $_SESSION['ccfd_verify_code'] = $verify_code; // If you want to disable Secure HTTPS or don't have Curl and OpenSSL installed // uncomment the next line // $tv->isSecure = 0; //set the time out to be 30 seconds $tv->timeout = 30; //uncomment to turn on debugging //$tv->debug = 1; //how many seconds the cache the ip addresses $tv->wsIpaddrRefreshTimeout = 3600 * 5; //where to store the ip address $tv->wsIpaddrCacheFile = "/tmp/maxmind.ws.cache"; // if useDNS is 1 then use DNS, otherwise use ip addresses directly $tv->useDNS = 1; // next we set up the input hash to be passed to the server $tv->input($h); // then we query the server $tv->query(); // then we get the result from the server $h = $tv->output(); if ($h['err']) { $error = _TPL_CC_ERROR_TV . " (" . $h['err'] . ")"; $was_error = true; $db->log_error($error); $payment_records_edit_log[] = $error; } if ($payment_records_edit_log) { $payment = $db->get_payment($payment['payment_id']); $payment['data']['tv_errors'] = $payment_records_edit_log; $db->update_payment($payment['payment_id'], $payment); } if ($was_error) { $errors[] = _TPL_CC_ERROR_TV; } else { // display confirmation form and exit // save $vars to session $_SESSION['stored_vars'] = $vars; $t->assign('member_id', $member['member_id']); $t->assign('payment_id', $payment['payment_id']); $t->assign('error', $errors); $t->assign('phone_number', $member['cc_phone']); $t->display('cc/cc_telephone_verification.html'); exit; } }
// $h["l"] = "YOUR_LICENSE_KEY_HERE"; // Enter your telephone number here // $h["phone"] = "YOUR_TELEPHONE_NUMBER_HERE"; // $h["verify_code"] = "5783"; // If you want to disable Secure HTTPS or don't have Curl and OpenSSL installed // uncomment the next line // $tv->isSecure = 0; //set the time out to be 30 seconds $tv->timeout = 30; //uncomment to turn on debugging // $tv->debug = 1; //how many seconds the cache the ip addresses $ccfs->wsIpaddrRefreshTimeout = 3600 * 5; //where to store the ip address $ccfs->wsIpaddrCacheFile = "/tmp/maxmind.ws.cache"; // if useDNS is 1 then use DNS, otherwise use ip addresses directly $ccfs->useDNS = 0; // next we set up the input hash to be passed to the server $tv->input($h); // then we query the server $tv->query(); // then we get the result from the server $h = $tv->output(); //then finally we print out the result $outputkeys = array_keys($h); $numoutputkeys = count($h); for ($i = 0; $i < $numoutputkeys; $i++) { $key = $outputkeys[$i]; $value = $h[$key]; print $key . " = " . $value . "\n"; }