public function send($mobile = 8402059135) { $this->generateOTP(); $this->_mobile = $mobile; $this->_message = 'Your One Time Password for MIS/SIS login is ' . $this->_CODE . '. NIT Silchar 2015.'; // API call to send sms $sms = new SMS(); if ($sms->send($this->_mobile, $this->_message)) { return 1; } else { echo 'OTP problem please try again later!'; Session::delete('OTPCode'); die; } }
if (isset($_POST['bulk_send'])) { try { $sms = new SMS(); $sms->send_broadcast($_POST['message'], $_POST['bulk_send']); echo "<img src='img/true.png' width='150' height='150' /><br/><br/>"; echo "<span style='font-size: 20px;'>" . _("BROADCAST MESSAGE IS BEING SENT!") . "</span><br/><br/><br/><br/>"; echo "<a href='send_sms.php'><button class='b1'>" . _("Go Back") . "</button></a>"; } catch (SMSException $e) { echo "<img src='img/false.png' width='200' height='170' /><br/><br/>"; echo "<span style='font-size: 20px; color: red;'>" . _("ERROR SENDING MASS SMS!") . "<br/>" . $e->getMessage() . " </span><br/><br/><br/><br/>"; echo "<a href='send_sms.php'><button class='b1'>" . _("Go Back") . "</button></a>"; } } else { try { $sms = new SMS(); $sms->send('10000', $_POST['number'], $_POST['message']); echo "<img src='img/true.png' width='150' height='150' /><br/><br/>"; echo "<span style='font-size: 20px;'>" . _("MESSAGE SENT!") . "</span><br/><br/><br/><br/>"; echo "<a href='send_sms.php'><button class='b1'>" . _("Go Back") . "</button></a>"; } catch (SMSException $e) { echo "<img src='img/false.png' width='200' height='170' /><br/><br/>"; echo "<span style='font-size: 20px; color: red;'>" . _("ERROR SENDING SMS!") . "<br/>" . $e->getMessage() . " </span><br/><br/><br/><br/>"; echo "<a href='send_sms.php'><button class='b1'>" . _("Go Back") . "</button></a>"; } } } } else { print_form(0, ''); } ?>
function sendSms($mobile, $location, $name) { // get new voucher $db = new Db(); // SELECT voucher FROM vouchers WHERE location_id='".$location."' AND mobileno='' LIMIT 1 $voucher = $db->select("SELECT voucher FROM vouchers WHERE location_id='" . $location . "' AND mobileno IS NULL ORDER BY voucher LIMIT 1"); if (!empty($voucher)) { // UPDATE vouchers SET mobileno='".$mobile."', lastupdate = NOW() WHERE voucher='' $update = $db->query("UPDATE vouchers SET mobileno='" . $mobile . "', name='" . $name . "', lastupdate = NOW() WHERE voucher='" . $voucher[0]["voucher"] . "'"); // send SMS $config = parse_ini_file(INIPATH); $sms = new SMS("https://konsoleh.your-server.de/"); $domain = $config["smsdomain"]; // e.g.: «my-domain.de» (without www!) $password = $config["smspassword"]; // your FTP password (transmission is encrypted) $country = "+49"; // country code (e.g. "+49" for Germany) $text = "Your voucher code is:" . $voucher[0]["voucher"]; // the desired text (up to max. 160 characters) $sms->send($domain, $password, $country, $mobile, $text); // return true return true; } else { return false; } }
public function send($msg) { SMS::send($this->phone, $msg); }
Route::post('clients/{id}/projects', 'ProjectController@store'); Route::post('clients/{id}/invoices', 'InvoiceController@store'); Route::post('clients/{id}/quotes', 'QuoteController@store'); Route::post('projects/{id}/updates', 'ProjectUpdateController@store'); Route::post('projects/{id}/activity', 'ProjectActivityController@store'); Route::post('return', 'APIController@returnReuqest'); Route::get('test-email', 'APIController@testMailQueue'); }); Route::post('oauth/access_token', function () { return Response::json(Authorizer::issueAccessToken()); }); Route::get('protected-resource', ['middleware' => 'oauth', function () { return "ya in"; }]); Route::get('sms/{number}/{message}', function ($number, $message) { $message = SMS::send($number, $message); if ($message) { return $message->messageId; } else { return "broken"; } }); Route::get('sms/{messageId}', function ($messageId) { $message = SMS::getResponse($messageId); if ($message) { return $message; } else { return "broken"; } }); Route::post('receive-github', 'APIController@receive_push');
$sub->send($msg); } echo json_encode($stock); break; case 'stocks': $stocks = Stock::findAll(); echo json_encode($stocks); break; case 'delete': $company = Request::any('company'); $stock = Stock::find($company); $stock->delete(); echo json_encode($stock); break; case 'subscribers': $subscribers = Subscriber::findAll(); echo json_encode($subscribers); break; case 'send': $msg = Request::any('message'); $recs = Subscriber::findAll(); foreach ($recs as $r) { SMS::send($r->phone, $msg); } echo json_encode(["success" => true]); break; } } catch (Exception $e) { http_response_code(500); echo $e->getMessage(); }
foreach ($smss as $sms) { echo "Received Message From: {$sms->sender} at {$sms->time}:\n"; echo "{$sms->message}\n\n"; $sub = new Subscriber(); $sub->phone = $sms->sender; $sub->save(); $msg = $sms->message; switch (strtolower($msg)) { case '_stop': $reply = "You will no longer receive our stock updates. Thank you for using our service."; $sub->delete(); echo "Subscriber deleted...\n"; break; default: $company = $msg; $stock = Stock::find($company); if (!$stock) { $reply = "Dear Subscriber, the specified company '{$company}' was not found."; } else { $reply = "Stock Price for {$company}: {$stock->price}"; } } SMS::send($sms->sender, $reply); echo "Sent Reply to {$sms->sender}:\n{$reply}\n"; SMS::delete($sms); echo "Message deleted\n\n"; } //wait for 5 seconds echo "Sleeping..."; sleep(5); }
public function testSend() { $mobile_code = $this->random(4, 1); $content = "您的验证码是:" . $mobile_code . "。请不要把验证码泄露给其他人。"; $sender = new SMS($this->account, $this->password, $this->mobile, $content); $sender->send(); }
/** * Import metadata using a mapping * * @param RequestHTTP $po_request The current request * @param string $ps_source A path to a file or directory of files to import * @param string $ps_importer The code of the importer (mapping) to use * @param string $ps_input_format The format of the source data * @param array $pa_options * progressCallback = * reportCallback = * sendMail = * dryRun = * importAllDatasets = * log = log directory path * logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. Constants are, in descending order of shrillness: * KLogger::EMERG = Emergency messages (system is unusable) * KLogger::ALERT = Alert messages (action must be taken immediately) * KLogger::CRIT = Critical conditions * KLogger::ERR = Error conditions * KLogger::WARN = Warnings * KLogger::NOTICE = Notices (normal but significant conditions) * KLogger::INFO = Informational messages * KLogger::DEBUG = Debugging messages */ public static function importMetadata($po_request, $ps_source, $ps_importer, $ps_input_format, $pa_options = null) { $va_errors = $va_noticed = array(); $vn_start_time = time(); $o_config = Configuration::load(); if (!ca_data_importers::mappingExists($ps_importer)) { $va_errors['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t('Importer %1 does not exist', $ps_importer)), 'status' => 'ERROR'); return false; } $vs_log_dir = caGetOption('log', $pa_options, null); $vs_log_level = caGetOption('logLevel', $pa_options, "INFO"); $vb_import_all_datasets = caGetOption('importAllDatasets', $pa_options, false); $vb_dry_run = caGetOption('dryRun', $pa_options, false); $vn_log_level = BatchProcessor::_logLevelStringToNumber($vs_log_level); if (!isURL($ps_source) && is_dir($ps_source)) { $va_sources = caGetDirectoryContentsAsList($ps_source, true, false, false, false); } else { $va_sources = array($ps_source); } $vn_file_num = 0; foreach ($va_sources as $vs_source) { $vn_file_num++; if (!ca_data_importers::importDataFromSource($vs_source, $ps_importer, array('fileNumber' => $vn_file_num, 'numberOfFiles' => sizeof($va_sources), 'logDirectory' => $o_config->get('batch_metadata_import_log_directory'), 'request' => $po_request, 'format' => $ps_input_format, 'showCLIProgressBar' => false, 'useNcurses' => false, 'progressCallback' => isset($pa_options['progressCallback']) ? $pa_options['progressCallback'] : null, 'reportCallback' => isset($pa_options['reportCallback']) ? $pa_options['reportCallback'] : null, 'logDirectory' => $vs_log_dir, 'logLevel' => $vn_log_level, 'dryRun' => $vb_dry_run, 'importAllDatasets' => $vb_import_all_datasets))) { $va_errors['general'][] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Could not import source %1", $ps_source)), 'status' => 'ERROR'); return false; } else { $va_notices['general'][] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Imported data from source %1", $ps_source)), 'status' => 'SUCCESS'); //return true; } } $vn_elapsed_time = time() - $vn_start_time; if (isset($pa_options['sendMail']) && $pa_options['sendMail']) { if ($vs_email = trim($po_request->user->get('email'))) { caSendMessageUsingView($po_request, array($vs_email => $po_request->user->get('fname') . ' ' . $po_request->user->get('lname')), __CA_ADMIN_EMAIL__, _t('[%1] Batch metadata import completed', $po_request->config->get('app_display_name')), 'batch_metadata_import_completed.tpl', array('notices' => $va_notices, 'errors' => $va_errors, 'numErrors' => sizeof($va_errors), 'numProcessed' => sizeof($va_notices), 'subjectNameSingular' => _t('row'), 'subjectNamePlural' => _t('rows'), 'startedOn' => caGetLocalizedDate($vn_start_time), 'completedOn' => caGetLocalizedDate(time()), 'elapsedTime' => caFormatInterval($vn_elapsed_time))); } } if (isset($pa_options['sendSMS']) && $pa_options['sendSMS']) { SMS::send($po_request->getUserID(), _t("[%1] Metadata import processing for begun at %2 is complete", $po_request->config->get('app_display_name'), caGetLocalizedDate($vn_start_time))); } return array('errors' => $va_errors, 'notices' => $va_notices, 'processing_time' => caFormatInterval($vn_elapsed_time)); }
$required_contacts[] = $all_contacts[$c][$type]; } $recipients = implode(',', $required_contacts); //send out messages if ($type == 'sms') { $biller = $admin->getSmsBillStatus(); $balance = $biller['units_assigned'] - $biller['units_used']; $num_of_recipients = count($required_contacts); $cost = $num_of_recipients * $num_of_sms_pages; if ($balance > $cost) { $settings = $admin->getSettings(); $gateway = $settings['sms_api_gatewayURL']['value']; $username = $settings['sms_api_gatewayUsername']['value']; $password = $settings['sms_api_gatewayPassword']['value']; $sms = new SMS($gateway, $username, $password, $sender_id, $message_body, $recipients); if ($sms->send()) { $units_used = $sms->get_unitsUsed(); $q2 = "update messenger_sms_biller set units_used=(units_used + " . $units_used . ") where user_id='" . $admin->getAdminID() . "'"; $q3 = "insert into messenger_log values(NULL,'" . $admin->getAdminID() . "','{$message_body}','{$recipients}'," . time() . ",1," . time() . "," . $units_used . ")"; $result2 = mysqli_query($link, $q2); AdminUtility::logMySQLError($link); $result3 = mysqli_query($link, $q3); AdminUtility::logMySQLError($link); } $responce = $sms->get_responseText(); } else { $responce = "You do not have enough balance at the moment.<br/>"; $responce .= "You need additional " . ($cost - $balance) . " units to complete this action."; } } elseif ($type == 'email') { if (mail($recipients, 'Subject: ' . $subject, wordwrap($message, 70, '\\r\\n'), 'From: ' . $reply_to . '\\r\\n' . 'Reply-To: ' . $contact_email . '\\r\\n' . 'X-Mailer: PHP/' . phpversion())) {
/** * @param array $pa_options * progressCallback = * reportCallback = * sendMail = * log = log directory path * logLevel = KLogger loglevel. Default is "INFO" */ public static function importMetadata($po_request, $ps_source, $ps_importer, $ps_input_format, $pa_options = null) { $va_errors = $va_noticed = array(); $vn_start_time = time(); $o_config = Configuration::load(); if (!ca_data_importers::mappingExists($ps_importer)) { $va_errors['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t('Importer %1 does not exist', $ps_importer)), 'status' => 'ERROR'); return false; } $vs_log_dir = isset($pa_options['log']) ? $pa_options['log'] : null; $vn_log_level = KLogger::INFO; switch ($vs_log_level = isset($pa_options['logLevel']) ? $pa_options['logLevel'] : "INFO") { case 'DEBUG': $vn_log_level = KLogger::DEBUG; break; case 'NOTICE': $vn_log_level = KLogger::NOTICE; break; case 'WARN': $vn_log_level = KLogger::WARN; break; case 'ERR': $vn_log_level = KLogger::ERR; break; case 'CRIT': $vn_log_level = KLogger::CRIT; break; case 'ALERT': $vn_log_level = KLogger::ALERT; break; default: case 'INFO': $vn_log_level = KLogger::INFO; break; } if (!ca_data_importers::importDataFromSource($ps_source, $ps_importer, array('logDirectory' => $o_config->get('batch_metadata_import_log_directory'), 'request' => $po_request, 'format' => $ps_input_format, 'showCLIProgressBar' => false, 'useNcurses' => false, 'progressCallback' => isset($pa_options['progressCallback']) ? $pa_options['progressCallback'] : null, 'reportCallback' => isset($pa_options['reportCallback']) ? $pa_options['reportCallback'] : null, 'logDirectory' => $vs_log_dir, 'logLevel' => $vn_log_level))) { $va_errors['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Could not import source %1", $vs_data_source)), 'status' => 'ERROR'); return false; } else { $va_notices['general'] = array('idno' => "*", 'label' => "*", 'errors' => array(_t("Imported data from source %1", $vs_data_source)), 'status' => 'SUCCESS'); //return true; } $vn_elapsed_time = time() - $vn_start_time; if (isset($pa_options['sendMail']) && $pa_options['sendMail']) { if ($vs_email = trim($po_request->user->get('email'))) { caSendMessageUsingView($po_request, array($vs_email => $po_request->user->get('fname') . ' ' . $po_request->user->get('lname')), __CA_ADMIN_EMAIL__, _t('[%1] Batch metadata import completed', $po_request->config->get('app_display_name')), 'batch_metadata_import_completed.tpl', array('notices' => $va_notices, 'errors' => $va_errors, 'numErrors' => sizeof($va_errors), 'numProcessed' => sizeof($va_notices), 'subjectNameSingular' => _t('row'), 'subjectNamePlural' => _t('rows'), 'startedOn' => $vs_started_on, 'completedOn' => caGetLocalizedDate(time()), 'elapsedTime' => caFormatInterval($vn_elapsed_time))); } } if (isset($pa_options['sendSMS']) && $pa_options['sendSMS']) { SMS::send($po_request->getUserID(), _t("[%1] Metadata import processing for begun at %2 is complete", $po_request->config->get('app_display_name'), $vs_started_on)); } return array('errors' => $va_errors, 'notices' => $va_notices, 'processing_time' => caFormatInterval($vn_elapsed_time)); }
function send_verify_phone($to_phone, $title) { global $_G; $key = random(6, 1); $_SESSION['verify_phone'] = $to_phone . '_' . $key; $_SESSION['verify_phone_len'] = intval($_SESSION['verify_phone_len']) + 1; if ($_SESSION['verify_phone_len'] > 15) { return array('status' => 'error', 'msg' => '频繁发送多条短信,请等2小时后再重新发送'); } if (!$title) { $title = '您的验证码为 ' . $key . ' ,切勿告诉他人【' . $_G[setting][title] . "】"; } //开始发短信 if (!class_exists('SMS')) { include_once ROOT_PATH . 'web/lib/message/sms.class.php'; } //即时发送 $sms = new SMS(); $rt = $sms->send($to_phone, $title); if ($rt === true) { return array('status' => 'success', 'msg' => '', 'data' => $key); } else { return array('status' => 'error', 'msg' => $rt); } }
function processRegoSubmission() { // $out = new OUTPUTj(0,"","Registration currently not available"); // echo $out->toJSON(); // return false; $json = $_POST["json"]; if ($json || $_POST["reference"]) { if ($json != "") { //create new object with json data $rego = new Registration($json); //check if json data exists if ($rego->exists()) { $out = new OUTPUTj(0, "", "This registration information already exists!"); echo $out->toJSON(); return false; } //json to objects $rego->parseJSON(); //make sure the json converted is valid if ($rego->isValid() == false) { $out = new OUTPUTj(0, "", $rego->errMsg); echo $out->toJSON(); return false; } //$out = new OUTPUTj(0,"","Registration is temporarily unavailable!"); //echo $out->toJSON(); //return false; //$rego->toString(); if ($rego->commitDB()) { $ref = $rego->Reference; //send sms try { //we try this as we dont want to show error if sms fails //we still want to show the registration information //check for aussie mobile prefix if (substr($rego->Phone, 0, 5) == "+6104" || substr($rego->Phone, 0, 4) == "+614") { $sms = new SMS(); if ($sms->access_token) { $messageId = $sms->send($rego->Phone, 'Hi ' . $rego->Firstname . ', your ref: ' . $ref . '. View your rego @ http://tinyurl.com/h4glqrk?ref=' . $ref . '\\n\\nDaiHoi Melbourne2016 Team.'); if ($messageId) { $rego->updateSMSMessageId($rego->Reference, $messageId); } } } } catch (Exception $e) { //should log error in db } //we send email try { //we try this as we dont want to show error if email fails //we still want to show the registration information $show_viet_section = 0; if (startsWith($rego->Phone, "+84") || startsWith($rego->Phone, "84") || endsWith($rego->Church, "Vietnam")) { $show_viet_section = 1; } $message = $rego->getRego($ref); $email = new Mailer(); $email->sendMail($rego->Email, 'DaiHoi 2016 Registration [' . $ref . '] for: ' . $rego->FullName(), $message, $show_viet_section); } catch (Exception $e) { //should log error in db } $out = new OUTPUTj(1, $ref, $rego->errMsg); echo $out->toJSON(); } else { $out = new OUTPUTj(0, "", $rego->errMsg); echo $out->toJSON(); } } } }
<?php require_once "SMS.php"; $sms_contents = file_get_contents("/tmp/smstemplate"); SMS::send("9585518355", $sms_contents);
<?php //подключение класса require_once "sms.php"; //отправка смс SMS::send('+3***********', 'Hello World'); ?>
/** Add a donation. Takes one array as argument... * Example - $donation->add(array( * 'donor_name' => 'Binny V A', * 'donor_email' => '*****@*****.**', * 'donor_phone' => '9746068563', * 'fundraiser_id' => 4, // The ID from the 'users' table. This donation was raised by this user * 'amount' => 13, * 'created_at' => date('Y-m-d H:i:s'), * 'donation_type' => 'ecs', // IF this is present - and the value is 'globalgiving' or 'ecs' or 'online', it becomes an external donation. * )); */ function add($data) { global $sql; $eighty_g_required = 0; $donor_address = ''; extract($data); $donor_id = $this->findDonor($donor_name, $donor_email, $donor_phone, $donor_address); if (!$donor_id) { return $this->_error("Can't find a valid Donor ID for this donation."); } if (!$fundraiser_id) { return $this->_error("Can't find a valid Fundraiser ID for this donation. Try logging out of the app and logging back in again."); } if (isset($created_at) and $created_at) { if ($created_at == '1970-01-01') { $created_at = date("Y-m-d H:i:s"); } else { $created_at = date("Y-m-d H:i:s", strtotime($created_at)); } } else { $created_at = date('Y-m-d H:i:s'); } if (isset($donation_type) and ($donation_type == 'globalgiving' or $donation_type == 'ecs' or $donation_type == 'online')) { return $this->addExternal($donation_type, $data); } // Insert the donation $donation_id = $sql->insert("donations", array('donour_id' => $donor_id, 'fundraiser_id' => $fundraiser_id, 'updated_by' => $fundraiser_id, 'donation_amount' => $amount, 'created_at' => $created_at, 'updated_at' => 'NOW()', 'eighty_g_required' => $eighty_g_required ? 1 : 0, 'comment' => $comment, 'donation_status' => 'TO_BE_APPROVED_BY_POC', 'source_id' => 1, 'donation_type' => 'GEN', 'version' => 1, 'product_id' => 1)); //Send acknowledgment SMS $sms = new SMS(); $sms->message = "Dear {$donor_name}, Thanks a lot for your contribution of Rs. {$amount} towards Make a Difference. This is only an acknowledgement. A confirmation and e-receipt would be sent once the amount reaches us."; $sms->number = $donor_phone; $sms->send(); //Send acknowledgement Email $base_url = '../'; $images[] = $base_url . 'assets/mad-letterhead-left.png'; $images[] = $base_url . 'assets/mad-letterhead-logo.png'; $images[] = $base_url . 'assets/mad-letterhead-right.png'; $email = new Email(); $email->html = '<html> <head> <title>Acknowledgement Email</title> </head> <body> <table style="width: 960px;margin:0 auto;height: auto;border: 2px solid #f1f1f1;font-family:arial;font-size:20px;"> <tr><td style="vertical-align: top;"><img style="float:left;margin: 0px;" src="' . $base_url . 'assets/mad-letterhead-left.png' . '"/><img style="margin-left: -70px;" src="' . $base_url . 'assets/mad-letterhead-logo.png' . '"/><img style="float:right;margin:0px;" src="' . $base_url . 'assets/mad-letterhead-right.png' . '"/></td></tr> <tr><td style="color:#cc2028;float:right;margin:10px 20px;"> ' . date("d/m/Y") . ' </td></tr> <tr><td style="padding:10px 20px;"><strong>Dear ' . $donor_name . ',</strong></td></tr> <tr><td style="padding:10px 20px;">Thanks a lot for your contribution of Rs.<strong style="color:#cc2028;">' . $amount . '/-</strong> towards Make A Difference.</td></tr> <tr><td style="padding:10px 20px;">This is not a donation receipt. But only an acknowledgement. We will be sending you the e-receipt for the donation within the next 30 days once the amount reaches us.</td></tr> <tr><td style="padding:10px 20px;">Please feel free to contact us on <a href="mailto:info@makeadiff.in">info@makeadiff.in</a> for any clarifications.</td></tr> <tr><td style="padding:10px 20px;"><i>Little bit about Make A Difference: We are a youth run volunteer organization that mobilizes young leaders to provide better outcomes to children living in shelter homes across India.</i></td></tr> <tr><td style="padding:20px 20px;"><i>You can read more about us @ <a href="http://www.makeadiff.in"> www.makeadiff.in </a> | <a href="http://www.facebook.com/makeadiff"> www.facebook.com/makeadiff </a> | <a href="http://www.twitter.com/makeadiff">www.twitter.com/makeadiff</a></i></td></tr> <tr><td style="color:#333231;font-size:16px;padding:0 20px;">First Floor, House no. 16C, MCHS colony, 1st B Main, 14th C Cross,</td></tr> <tr><td style="color:#333231;font-size:16px;padding:0 20px;">HSR Layout, Sector 6, Bangalore - 560102.</td></tr> <tr><td style="color:#333231;float:right;font-size:16px;margin:0 20px 20px;">http://www.makeadiff.in</td></tr> </table> </body> </html>'; $email->to = $donor_email; $email->from = "noreply <*****@*****.**>"; $email->subject = "Donation Acknowledgment"; $email->images = $images; $email->send(); return $donation_id; }
// ok, if we got to here everything is cool variable-wise // let's get the data into the db db_connect(); $query = "INSERT INTO records VALUES (\r\nnull,\r\n'" . sanitize($time_f) . "',\r\n'" . sanitize($light) . "',\r\n'" . sanitize($moisture) . "',\r\n'" . sanitize($wind_dir) . "',\r\n'" . sanitize($wind_spd) . "',\r\n'" . sanitize($pressure) . "',\r\n'" . sanitize($temp) . "',\r\n'" . sanitize($humidity) . "',\r\n'" . sanitize($batt) . "',\r\n'" . sanitize($temp2) . "',\r\n'" . sanitize($rain) . "',\r\n'" . sanitize($light2) . "',\r\n'" . $ip . "')"; mysql_query($query) or die("Could not run query.<br>" . mysql_error()); db_disconnect(); // this header is for the XPORT serin stuff // ... when we get it working // ... if ever header("Zone: D"); // send new header // check to see if need to send text if ($sms_on_update) { $msgstr = "The station successfully completed an update at " . date("G:i") . "."; $newsms = new SMS($c_sms_number, $msgstr, false); $newsms->send(); $params = array(); $params['dir'] = 'includes'; $params['include_nested'] = 0; $params['search_what'] = '$sms_on_update = true'; $params['replace_to'] = '$sms_on_update = false'; $params['file_name_match'] = '/^config.inc.php/'; // <-- this mean beginning from 'test' $replacer = new FileScopeReplacer($params); $replacer->doWork(); } // stupid twit : call with both $light values so it can choose which to use callTwitter($light, $light2, $temp2, $pressure, $t_hours, $t_mins); //update to CWOP if enabled in config if ($c_usecwop) { $light_cwop = round($light / 255 * 100);
public function postLogin(Request $request) { $type = $request->input('type'); $field = filter_var($request->input('email'), FILTER_VALIDATE_EMAIL) ? 'email' : 'mobile'; $request->merge([$field => $request->input('email')]); $credentials = $request->only($field, 'password'); $data = []; if ($field == 'email') { $data['email_verify'] = 0; $email_verify = User::where('email', '=', $request->input('email'))->where('identifier', '=', $type)->where('inactive', '=', 0)->orWhere('email', '=', $request->input('email'))->where('identifier', '=', 3)->pluck('email_verify'); if ($email_verify == '1') { $credentials = array_add($credentials, 'email_verify', '1'); $data['page'] = 'home'; $data['valid'] = 1; $data['email_verify'] = 1; } else { $data['page'] = 'login'; $emailObj = User::where('email', '=', $request->input('email'))->first(['name', 'email_verify', 'email_vcode', 'email_vcode_expiry']); if ($emailObj != null && $emailObj->email_verify == 0) { $email_vcode_expiry = new \Carbon\Carbon($emailObj->email_vcode_expiry, 'Asia/Kolkata'); $now = \Carbon\Carbon::now(new \DateTimeZone('Asia/Kolkata')); $difference = $now->diffInHours($email_vcode_expiry); /*$data['now'] = $now; $data['email_vcode_expiry'] = $email_vcode_expiry; $data['diff'] = $difference;*/ if ($difference < 1) { /*$vcode = $emailObj->email_vcode; $fname = $emailObj->name; Mail::send('emails.welcome', array('fname'=>$fname, 'vcode'=>$vcode), function($message) use ($email,$fname){ $message->to($email, $fname)->subject('Welcome to Jobtip!')->from('*****@*****.**', 'JobTip'); });*/ $data['email_verify'] = 0; $data['valid'] = 1; $data['message'] = 'Your email is not verified. Please check your email for verification code.'; } else { if ($difference >= 1) { $vcode = ""; if ($request->input('email') != null) { $vcode = 'A' . rand(1111, 9999); $nowPlusOne = \Carbon\Carbon::now(new \DateTimeZone('Asia/Kolkata'))->addHours(1); // Induser::where('email', '=', $request->input('email'))->update(['email_vcode' => $vcode]); User::where('email', '=', $request->input('email'))->update(['email_vcode' => $vcode, 'email_vcode_expiry' => $nowPlusOne]); } $email = $request->input('email'); $fname = $emailObj->name; Mail::send('emails.welcome', array('fname' => $fname, 'vcode' => $vcode), function ($message) use($email, $fname) { $message->to($email, $fname)->subject('Welcome to Jobtip!')->from('*****@*****.**', 'JobTip'); }); $data['email_verify'] = 0; $data['valid'] = 1; $data['message'] = 'We have sent you an email for verification.'; } } } else { $data['valid'] = 0; } //error - email not verified /*$data['email_verify'] = 0; $data['page'] = 'login'; $data['message'] = 'email not verified';*/ } } if ($field == 'mobile') { $data['mobile_verify'] = 0; $mobile_verify = User::where('mobile', '=', $request->input('email'))->where('identifier', '=', $type)->where('inactive', '=', 0)->orWhere('mobile', '=', $request->input('email'))->where('identifier', '=', 3)->pluck('mobile_verify'); if ($mobile_verify == '1') { $credentials = array_add($credentials, 'mobile_verify', '1'); $data['page'] = 'home'; $data['valid'] = 1; $data['mobile_verify'] = 1; } else { $data['page'] = 'login'; $userForMobile = User::where('mobile', '=', $request->input('email'))->first(['name', 'mobile_verify', 'mobile_otp', 'mobile_otp_expiry', 'mobile_otp_attempt']); if ($userForMobile != null && $userForMobile->mobile_verify == 0) { $mobile_otp_expiry = new \Carbon\Carbon($userForMobile->mobile_otp_expiry, 'Asia/Kolkata'); $now = \Carbon\Carbon::now(new \DateTimeZone('Asia/Kolkata')); $difference = $now->diffInMinutes($mobile_otp_expiry); $data['now'] = $now; $data['mobile_otp_expiry'] = $mobile_otp_expiry; $data['diff'] = $difference; $data['mobile'] = $request->input('email'); $mobileNumber = $request->input('email'); if ($difference < 15 && $userForMobile->mobile_otp_attempt < 3) { // send old otp n increment the attempt $mobile_otp_attemptInc = $userForMobile->mobile_otp_attempt + 1; User::where('mobile', '=', $request->input('email'))->update(['mobile_otp_attempt' => $mobile_otp_attemptInc]); $data['mobile_verify'] = 0; $data['valid'] = 1; $data['message'] = 'Mobile number not yet verified. Please check your mobile for OTP.'; $smsMsg = "Thank you for registering Jobtip.in Your One Time Password (OTP) is " . $userForMobile->mobile_otp . ". TnC applied. Visit www.jobtip.in"; $data['delvStatus'] = SMS::send($mobileNumber, $smsMsg); } else { if ($difference >= 15 && $userForMobile->mobile_otp_attempt < 3) { // regenerate otp, update otp, reset attempt n mobile_otp_expiry $otp = rand(1111, 9999); $new_mobile_otp_expiry = \Carbon\Carbon::now(new \DateTimeZone('Asia/Kolkata'))->addMinutes(15); User::where('mobile', '=', $request->input('email'))->update(['mobile_otp' => $otp, 'mobile_otp_attempt' => 0, 'mobile_otp_expiry' => $new_mobile_otp_expiry]); // Induser::where('mobile', '=', $request->input('email'))->update(['mobile_otp' => $otp]); $data['mobile_verify'] = 0; $data['valid'] = 1; $data['message'] = 'OTP sent to your registered mobile number.'; $smsMsg = "Thank you for registering Jobtip.in Your One Time Password (OTP) is " . $otp . ". TnC applied. Visit www.jobtip.in"; $data['delvStatus'] = SMS::send($mobileNumber, $smsMsg); } else { if ($userForMobile->mobile_otp_attempt == 3) { if ($difference >= 30) { User::where('mobile', '=', $request->input('email'))->update(['mobile_otp_attempt' => 0]); } $data['mobile_verify'] = 0; $data['valid'] = 1; $data['message'] = 'You have reached to maximum limit. Try after sometime.'; } } } } else { $data['valid'] = 0; } } } /*if($field == 'email'){ $credentials = array_add($credentials, 'email_verify', '1'); }elseif($field == 'mobile'){ $credentials = array_add($credentials, 'mobile_verify', '1'); }*/ if ($request->ajax()) { $everify = 0; $mverify = 0; if (array_key_exists('email_verify', $data)) { $everify = $data['email_verify']; } if (array_key_exists('mobile_verify', $data)) { $mverify = $data['mobile_verify']; } if ($data['page'] == 'home' && ($everify == 1 || $mverify == 1) && $data['valid'] == 1) { if ($this->auth->attempt($credentials)) { $data['message'] = 'login success'; return response()->json(['success' => true, 'data' => $data]); } else { $data['page'] = 'login'; $data['user'] = '******'; $data['message'] = 'Email or Password is incorrect'; } } else { if ($data['valid'] == 0) { $data['page'] = 'login'; $data['user'] = '******'; $data['message'] = 'invalid login info'; } else { $data['page'] = 'login'; } } return response()->json(['success' => false, 'data' => $data]); } /*else{ if ($this->auth->attempt($credentials)){ return redirect()->intended($this->redirectPath()); } return redirect($this->loginPath()) ->withInput($request->only('email', 'remember')) ->withErrors([ 'email' => $this->getFailedLoginMessage(), ]); }*/ $this->validate($request, ['email' => 'required', 'password' => 'required']); }
$head = "POST " . $info['path'] . " HTTP/1.0\r\n"; $head .= "Host: " . $info['host'] . "\r\n"; $head .= "Referer: http://" . $info['host'] . $info['path'] . "\r\n"; $head .= "Content-type: application/x-www-form-urlencoded\r\n"; $head .= "Content-Length: " . strlen(trim($post_string)) . "\r\n"; $head .= "\r\n"; $head .= trim($post_string); $write = fputs($fp, $head); $header = ""; while ($str = trim(fgets($fp, 4096))) { $header .= $str; } while (!feof($fp)) { $data .= fgets($fp, 4096); } return $data; } } $config['mobile'] = 18651718003.0; $config['text'] = "你的验证码是123456"; $sms = new SMS(); // var_dump($sms->send($config)); $res = json_decode($sms->send($config), true); // var_dump($res); if ($res['code'] === 0) { echo '发送成功'; } else { echo '发送失败<br>'; echo $res['msg'] . '<br>'; echo $res['detail']; }
public function OTPresend() { $otp = rand(1111, 9999); $resend_otp = Security_check::where('user_id', '=', Auth::user()->id)->where('verify_for', '=', 'Mobile')->where('status', '=', 'Not Verified')->first(); $data = []; if ($resend_otp != null && $resend_otp->resend_attemp <= 3) { $mobile = $resend_otp->mobile; $resend_otp->otp = $otp; $resend_otp->resend_attemp = $resend_otp->resend_attemp + 1; $resend_otp->save(); $smsMsg = "Thank you for registering Jobtip.in Your One Time Password (OTP) is " . $otp . ". TnC applied. Visit www.jobtip.in"; $data['delvStatus'] = SMS::send($mobile, $smsMsg); $data['msg'] = 'Check your Mobile for OTP'; $data['types'] = 'mobile-otp'; return response()->json(['success' => true, 'data' => $data]); } else { if ($resend_otp != null && $resend_otp->resend_attemp > 3) { $data['msg'] = 'You attemped 3 times.'; return response()->json(['success' => true, 'data' => $data]); } } }