2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once ( " template.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once ( " config.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once ( " classes/constellation.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once ( " classes/subscriber.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once ( " classes/subscriptions.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once ( " classes/mailer.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//require_once("libs/php_idn/idna.php");
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								require_once ( " classes/db-class.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$db  =  new  SSDB ();  
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								define ( " NAME " ,  $db -> getSetting ( $mysqli ,  " name " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " TITLE " ,  $db -> getSetting ( $mysqli ,  " title " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " WEB_URL " ,  $db -> getSetting ( $mysqli ,  " url " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " MAILER_NAME " ,  $db -> getSetting ( $mysqli ,  " mailer " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " MAILER_ADDRESS " ,  $db -> getSetting ( $mysqli ,  " mailer_email " ));  
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								define ( " GOOGLE_RECAPTCHA " ,  $db -> getBooleanSetting ( $mysqli ,  " google_recaptcha " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//define("", $db->getSettings($mysqli, ""));
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " GOOGLE_RECAPTCHA_SECRET " ,  $db -> getSetting ( $mysqli ,  " google_recaptcha_secret " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " GOOGLE_RECAPTCHA_SITEKEY " ,  $db -> getSetting ( $mysqli ,  " google_recaptcha_sitekey " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " SUBSCRIBE_EMAIL " ,  $db -> getBooleanSetting ( $mysqli ,  " subscribe_email " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " SUBSCRIBE_TELEGRAM " ,  $db -> getBooleanSetting ( $mysqli ,  " subscribe_telegram " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " TG_BOT_USERNAME " ,  $db -> getSetting ( $mysqli ,  " tg_bot_username " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " TG_BOT_API_TOKEN " ,  $db -> getSetting ( $mysqli ,  " tg_bot_api_token " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER " ,  $db -> getBooleanSetting ( $mysqli ,  " php_mailer " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER_SMTP " ,  $db -> getBooleanSetting ( $mysqli ,  " php_mailer_smtp " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER_PATH " ,  $db -> getSetting ( $mysqli ,  " php_mailer_path " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER_HOST " ,  $db -> getSetting ( $mysqli ,  " php_mailer_host " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER_PORT " ,  $db -> getSetting ( $mysqli ,  " php_mailer_port " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER_SECURE " ,  $db -> getBooleanSetting ( $mysqli ,  " php_mailer_secure " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER_USER " ,  $db -> getSetting ( $mysqli ,  " php_mailer_user " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								define ( " PHP_MAILER_PASS " ,  $db -> getSetting ( $mysqli ,  " php_mailer_pass " ));  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$mailer        =  new  Mailer ();  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$subscriber    =  new  Subscriber ();  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$subscription  =   new  Subscriptions ();  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$boolRegistered  =  false ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( isset ( $_GET [ 'new' ]))  {  
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // Form validation for subscribers signing up
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $message  =  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-19 19:38:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Template :: render_header ( _ ( " Email Subscription " ),  " subsmail " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( isset ( $_POST [ 'emailaddress' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( 0  ==  strlen ( trim ( $_POST [ 'emailaddress' ])))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            $messages []  =  _ ( " Email address " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Perform DNS domain validation on
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! $mailer -> verify_domain ( $_POST [ 'emailaddress' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            $messages []  =  _ ( " Domain does not apper to be a valid email domain. (Check MX record) " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( GOOGLE_RECAPTCHA )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // Validate recaptcha
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $response  =  $_POST [ " g-recaptcha-response " ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $url  =  'https://www.google.com/recaptcha/api/siteverify' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'secret'  =>  GOOGLE_RECAPTCHA_SECRET , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'response'  =>  $_POST [ " g-recaptcha-response " ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $options  =  array ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                'http'  =>  array ( 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                    'header'  =>  'Content-Type: application/x-www-form-urlencoded\r\n' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    'method'  =>  'POST' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    'content'  =>  http_build_query ( $data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $context   =  stream_context_create ( $options ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $verify    =  file_get_contents ( $url ,  false ,  $context ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $captcha_success  =  json_decode ( $verify ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( $captcha_success -> success  ==  false )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                $messages []  =  _ ( " reChaptcha validation failed " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( isset ( $messages ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            $message  =  _ ( " Please check<br> " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $message  .=  implode ( " <br>  " ,  $messages ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( isset ( $_POST [ 'emailaddress' ])  &&  empty ( $message ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Check if email is already registered
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $boolUserExist  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $subscriber -> userID  =  $_POST [ 'emailaddress' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $subscriber -> typeID  =  2 ;  // Email
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $boolUserExist  =  $subscriber -> check_userid_exist (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $url  =  WEB_URL  .  " /index.php?do=manage&token= "  .  $subscriber -> token ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! $boolUserExist )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            // Create a new subscriber as it does not exist
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $subscriber -> add ( $subscriber -> typeID ,  $_POST [ 'emailaddress' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $url  =  WEB_URL  .  " /index.php?do=manage&token= "  .  $subscriber -> token ;     // Needed again after adding subscriber since token did not exist before add
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $msg  =  sprintf ( _ ( " Thank you for registering to receive status updates via email.</br></br> Click on the following link to confirm and manage your subcription: <a href= \" %s \" >%s</a>. New subscriptions must be confirmed within 2 hours " ),  $url ,  NAME  .  ' - '  .  _ ( " Validate subscription " )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! $subscriber -> active )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                // Subscriber is registered, but has not been activated yet...
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $msg  =  sprintf ( _ ( " Thank you for registering to receive status updates via email.</br></br> Click on the following link to confirm and manage your subcription: <a href= \" %s \" >%s</a>. New subscriptions must be confirmed within 2 hours " ),  $url ,  NAME  .  ' - '  .  _ ( " Validate subscription " )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                $subscriber -> activate ( $subscriber -> id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // subscriber is registered and active
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $msg  =  sprintf ( _ ( " Click on the following link to update your existing subscription:  <a href= \" %s \" >%s</a> " ),  $url ,  NAME  .  ' - '  .  _ ( " Manage subscription " )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                $subscriber -> update ( $subscriber -> id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Show success message
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $header   =  _ ( " Thank you for subscribing " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $message  =  _ ( " You will receive an email shortly with an activation link. Please click on the link to activate and/or manage your subscription. " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $constellation -> render_success ( $header ,  $message ,  true ,  WEB_URL ,  _ ( 'Go back' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Send email about new registration
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $subject  =  _ ( 'Email subscription registered' )  .  ' - '  .  NAME ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        $mailer -> send_mail ( $_POST [ 'emailaddress' ],  $subject ,  $msg ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $boolRegistered  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // Add a new email subscriber - display form
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( isset ( $_GET [ 'new' ])  &&  ( ! $boolRegistered ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! empty ( $message ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            echo  '<p class="alert alert-danger">'  .  $message  .  '</p>' ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $strPostedEmail  =  ( isset ( $_POST [ 'emailaddress' ]))   ?   $_POST [ 'emailaddress' ]  :  " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < form  method = " post "  action = " index.php?do=email_subscription&new=1 "  class = " clearfix "  enctype = " multipart/form-data " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < h3 >< ? php  echo  _ ( 'Subscribe to get email notifications on status updates' );  ?> </h3>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < div  class = " form-group clearfix " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < label  for = " labelEmailAddress " >< ? php  echo  _ ( 'Email address' );  ?> </label>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < input  type = " email "  class = " form-control "  name = " emailaddress "  id = " emailaddress "  aria - describedby = " emailHelp "  placeholder = " <?php echo _('Enter email address'); ?> "  value = " <?php echo  $strPostedEmail ; ?> "  required > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < ? php  if  ( GOOGLE_RECAPTCHA )  {  ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < div  class = " col-md-12 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    < div  class = " form-group " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        < div  class = " captcha_wrapper " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            < div  class = " g-recaptcha "  data - sitekey = " <?php echo GOOGLE_RECAPTCHA_SITEKEY; ?> " ></ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < ? php  }  ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < summary > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $msg  =  sprintf ( _ ( 'By subscribing to recieve notifications you are agreeing to our <a href="%s">Privacy Policy</a>' ),  POLICY_URL ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                echo  $msg ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            </ summary > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < div  class = " form-group form-check " > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < a  href = " <?php echo WEB_URL; ?> "  id = " cancel "  name = " cancel "  class = " btn btn-default " >< ? php  echo  _ ( 'Close' );  ?> </a>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < button  type = " submit "  class = " btn btn-primary " >< ? php  echo  _ ( 'Subscribe' );  ?> </button>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ form > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /* Handle management and activation of email subscriptions */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  else  if  ( isset ( $_GET [ 'do' ])  &&  $_GET [ 'do' ]  ==  'manage' )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // check if userid/token combo is valid, active or expired
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $subscriber -> typeID  =  2 ;  //EMAIL
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( $subscriber -> is_active_subscriber ( $_GET [ 'token' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        // forward user to subscriber list....
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $subscriber -> set_logged_in (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        header ( 'Location: subscriptions.php' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        exit ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-19 19:38:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        Template :: render_header ( _ ( " Email Subscription " ),  " subsmail " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $header   =  _ ( " We cannot find a valid subscriber account matching those details " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $message  =  _ ( " If you have recently subscribed, please make sure you activate the account within two hours of doing so. You are welcome to try and re-subscribe. " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $constellation -> render_warning ( $header ,  $message ,  true ,  WEB_URL ,  _ ( 'Go back' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  else  if  ( isset ( $_GET [ 'do' ])  &&  $_GET [ 'do' ]  ==  'unsubscribe' )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // Handle unsubscriptions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // TODO This function is universal and should probably live elsewhere??
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( isset ( $_GET [ 'token' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $subscriber -> typeID  =  ( int )  $_GET [ 'type' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( $subscriber -> get_subscriber_by_token ( $_GET [ 'token' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            $subscriber -> delete ( $subscriber -> id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $subscriber -> set_logged_off (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-19 19:38:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            Template :: render_header ( _ ( " Email Subscription " ),  " subsmail " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $header   =  _ ( " You have been unsubscribed from our system " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $message  =  _ ( " We are sorry to see you go. If you want to subscribe again at a later date please feel free to re-subscribe. " ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $constellation -> render_success ( $header ,  $message ,  true ,  WEB_URL ,  _ ( 'Go back' )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // TODO Log token for troubleshooting ?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // Cannot find subscriber - show alert
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-19 19:38:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            Template :: render_header ( _ ( " Email Subscription " ),  " subsmail " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-05 16:54:04 +03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            $header  =  _ ( " We are unable to find any valid subscriber detail matching your submitted data! " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $message  =  _ ( " If you believe this to be an error, please contact the system admininistrator. " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $constellation -> render_warning ( $header ,  $message ,  true ,  WEB_URL ,  _ ( 'Go back' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // TODO Log $_GET[] for troubleshooting ?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $header  =  _ ( " We are unable to find any valid subscriber detail matching your submitted data! " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $message  =  _ ( " If you believe this to be an error, please contact the system admininistrator. " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $constellation -> render_warning ( $header ,  $message ,  true ,  WEB_URL ,  _ ( 'Go back' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Template :: render_footer ();