include('../top_1.include'); ?>
define('ACCESS_ALLOWED', 1);
require_once('database.php');
$number=$_POST['number'];
global $number;
$confirm_code=$_POST['confirm_code'];
$submission_time=$date = date('Y-m-d h:i:00');
$show_form = true;
$response_msg = "";
$response_code = true;
function isValid( $what, $data ) {
switch( $what ) {
// validate a number number
case 'number':
$pattern = "/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i";
// 1- 555- 555- 5555
// or 555- 555- 5555
break;
// validate email address
case 'email':
$pattern = "/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i";
// $pattern = "/\b[^@]*@(brooklyn\.cuny.\edu|google\.com)\b/";
//$pattern = "/\b[^@]*@(brooklyn\.cuny.\edu|google\.com)\b/";
break;
// validate name
//case 'name':
// $pattern = "/^[A-Z][a-zA-Z -]+$/";
// $pattern="/^[a-zA-Z]?[a-zA-Z-]+$/";
//break;
default:
return false;
break;
}
return preg_match($pattern, $data) ? true : false;
}
$errors = array();
if( isset($_POST['btn_submit']) )
{
//if( !isValid( 'name', $_POST['name'] ) ) {
// $errors[] = '
Name must contain letters, dashes and spaces only.';
// }
if( !isValid( 'email', $_POST['email'] ) ) {
$errors[] = '';
$response_msg ="Please enter a valid email address";
$show_form = true;
$response_code = false;
}
if( !isValid( 'number', $_POST['number'] ) ) {
$errors[] = '';
$response_msg ="Please enter a valid phone number";
$show_form = true;
$response_code = false;
}
if( !empty($errors) ) {
foreach( $errors as $e ) echo "$e
";
}
if(empty($errors) ){
// generate "random" 6-digit verification code
$code = rand(100000, 999999);
$result = mysql_query ("SELECT * from numbers WHERE phone_number='$number'");
if(!mysql_num_rows($result) == 0) {
$response_msg ="Looks like this phone number is already registered";// row not found, do stuff...
//check if it was verified
$show_form = false;
$response_code = true;
}
else {
mysql_query ("INSERT INTO numbers (name, email, phone_number, verification_code, date) VALUES ('$_POST[name]', '$_POST[email]', '$number', '$code', '$submission_time')");
for ($i=0;$i<14; $i++)
{
$sys_param_name = 'system_'.$i;
$sys_name = $_POST[$sys_param_name];
if ($sys_name == 1)
{
mysql_query ("INSERT INTO subscriptions (phone_number, system) VALUES ('$_POST[number]','$i')");
}
}
//if (mysql_errno() == 1062)
// {
// print '
Looks like your phone is already on our system. Please enter a new phone or click here if you want to unsubscribe.
';
//}
if (!mysql_errno())
{
//$phone = preg_replace('/[^a-zA-Z0-9]/', '-', $phone);
//echo $phone;
$response_msg="Thank you!
Before your account is activated you need to verify your number. You should recieve your verification code soon.
When you do, please enter your verification code here.";
echo "";
$show_form = false;
$response_code = true;
//send verification code to phone#
require ('Services/Twilio.php');
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "AC791f5ab61280408db381669ae99894c0";
$AuthToken = "396fdb73fc78339e02d3ab9ae1e1f2f4";
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
$sms = $client->account->messages->sendMessage
(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased, or the (deprecated) Sandbox number "YYY-YYY-YYYY"
"718-701-8491",
// the number we are sending to - Any phone number
$number,
// the sms body
"$code"
);
// Display a confirmation message on the screen
//echo "";
//END SEND TEXT MESSAGE
//
}
}
}
mysql_close();
}
?>
if ($show_form) {
?>
Frequently Asked Questions
I already subscribed to text alerts on the BC Portal-do I have to enroll again?
Yes-BC-STATUS is designed to keep you in the loop even when campus systems are unavailable, so it must be self-contained. Note that subscribing to BC-STATUS alerts does not automatically enroll you in any other text alert subscriptions.
How can I unsubscribe from BC-STATUS alerts?
Simply click HERE and use the same credentials you used when you initially subscribed. You will receive a text message confirming the change.
How can I change the email address or phone number for my subscription?
Simply unsubscribe and then re-subscribe with the new information
Why is there a test text message verification step when I subscribe?
This step ensures that you did not make a typo when entering your telephone number, tests that our service can reach your device, and alerts you to anyone subscribing you without your permission.
Where do I enter the text verification code?
Enter the verification code at: http://www.bc-status.info/sendtxt/verify.php. You must enter the verification code to start receiving BC-STATUS text messages.
![Unsubscribe](../images/unsubscribe.gif)
}
?>