mirror of
				https://github.com/ShaYmez/FreeSTAR-Status-Engine.git
				synced 2025-10-27 10:30:19 -04:00 
			
		
		
		
	Merge pull request #3 from thnilsen1/move_config_options
Removed Telegram and email notification setup from install routine.
This commit is contained in:
		
						commit
						5d99ed7ccb
					
				| @ -19,6 +19,24 @@ else{ | ||||
|   define("WEB_URL", $db->getSetting($mysqli,"url")); | ||||
|   define("MAILER_NAME", $db->getSetting($mysqli,"mailer")); | ||||
|   define("MAILER_ADDRESS", $db->getSetting($mysqli,"mailer_email")); | ||||
| 
 | ||||
|   define("GOOGLE_RECAPTCHA", $db->getBooleanSetting($mysqli, "google_recaptcha")); | ||||
|   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")); | ||||
|   define("CRON_SERVER_IP", $db->getSetting($mysqli, "cron_server_ip")); | ||||
|    | ||||
|   // Process the subscriber notification queue
 | ||||
|   // If CRON_SERVER_IP is not set, call notification once incident has been saved
 | ||||
|   if ( empty(CRON_SERVER_IP) ) | ||||
| @ -95,11 +113,11 @@ else{ | ||||
|       case 'options': | ||||
|         require_once("options.php"); | ||||
|         break; | ||||
|          | ||||
| 
 | ||||
|       case 'logout': | ||||
|         User::logout(); | ||||
|         break; | ||||
|        | ||||
| 
 | ||||
|     	default: | ||||
|     		require_once("dashboard.php"); | ||||
|     		break; | ||||
|  | ||||
| @ -1,4 +1,9 @@ | ||||
| <?php | ||||
| function getToggle($variable){ | ||||
|   $res = ((isset($variable) && ($variable == "on")) ? "yes" : "no"); | ||||
|   return $res; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| if (!file_exists("../config.php")) | ||||
| { | ||||
| @ -15,29 +20,78 @@ else{ | ||||
|   require_once("../classes/db-class.php"); | ||||
| } | ||||
|   $db = new SSDB(); | ||||
|   if(trim($db->getSetting($mysqli,"notifyUpdates")) == "yes"){ | ||||
|       $notifyUpdates_status = true; | ||||
|   } else { | ||||
|       $notifyUpdates_status = false; | ||||
|   } | ||||
|   $notifyUpdates_status = $db->getBooleanSetting($mysqli, "notifyUpdates"); | ||||
|   $emailSubscription_status = $db->getBooleanSetting($mysqli, "subscribe_email"); | ||||
|   $telegramSubscription_status = $db->getBooleanSetting($mysqli, "subscribe_telegram"); | ||||
|   $tg_bot_api_token = $db->getSetting($mysqli, "tg_bot_api_token"); | ||||
|   $tg_bot_username = $db->getSetting($mysqli, "tg_bot_username"); | ||||
|   $php_mailer_status = $db->getBooleanSetting($mysqli, "php_mailer"); | ||||
|   $php_mailer_smtp_status = $db->getBooleanSetting($mysqli, "php_mailer_smtp"); | ||||
|   $php_mailer_secure_status = $db->getBooleanSetting($mysqli, "php_mailer_secure"); | ||||
|   $php_mailer_path = $db->getSetting($mysqli, "php_mailer_path"); | ||||
|   $php_mailer_host = $db->getSetting($mysqli, "php_mailer_host"); | ||||
|   $php_mailer_port = $db->getSetting($mysqli, "php_mailer_port"); | ||||
|   $php_mailer_user = $db->getSetting($mysqli, "php_mailer_user"); | ||||
|   $php_mailer_pass = $db->getSetting($mysqli, "php_mailer_pass"); | ||||
|   $cron_server_ip = $db->getSetting($mysqli, "cron_server_ip"); | ||||
|   $google_rechaptcha_status = $db->getBooleanSetting($mysqli, "google_recaptcha"); | ||||
|   $google_recaptcha_sitekey = $db->getSetting($mysqli, "google_recaptcha_sitekey"); | ||||
|   $google_recaptcha_secret = $db->getSetting($mysqli, "google_recaptcha_secret"); | ||||
| 
 | ||||
|   $db->getSetting($mysqli, ""); | ||||
|   $set_post = false; | ||||
|   if(!empty($_POST)){ | ||||
|     if($_POST["nu_toggle"] == "on"){ $nu_toggle = "yes"; } else { $nu_toggle = "no"; } | ||||
|     $db->deleteSetting($mysqli,"notifyUpdates"); | ||||
|     $db->setSetting($mysqli,"notifyUpdates",$nu_toggle); | ||||
|     $db->deleteSetting($mysqli,"name"); | ||||
|     $db->setSetting($mysqli,"name",$_POST["sitename"]); | ||||
|     $db->updateSetting($mysqli, "notifyUpdates", getToggle($_POST["nu_toggle"])); | ||||
|     $db->updateSetting($mysqli, "name",htmlspecialchars($_POST["sitename"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "subscribe_email", getToggle($_POST["email_subscription_toggle"])); | ||||
|     $db->updateSetting($mysqli, "subscribe_telegram", getToggle($_POST["telegram_subscription_toggle"])); | ||||
|     $db->updateSetting($mysqli, "tg_bot_api_token", htmlspecialchars($_POST["tg_bot_api_token"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "tg_bot_username", htmlspecialchars($_POST["tg_bot_username"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "php_mailer", getToggle($_POST["php_mailer_toggle"])); | ||||
|     $db->updateSetting($mysqli, "php_mailer_smtp", getToggle($_POST["php_mailer_smtp_toggle"])); | ||||
|     $db->updateSetting($mysqli, "php_mailer_secure", getToggle($_POST["php_mailer_secure_toggle"])); | ||||
|     $db->updateSetting($mysqli, "php_mailer_path", htmlspecialchars($_POST["php_mailer_path"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "php_mailer_host", htmlspecialchars($_POST["php_mailer_host"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "php_mailer_port", htmlspecialchars($_POST["php_mailer_port"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "php_mailer_user", htmlspecialchars($_POST["php_mailer_user"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "php_mailer_pass", htmlspecialchars($_POST["php_mailer_pass"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "cron_server_ip", htmlspecialchars($_POST["cron_server_ip"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "google_recaptcha", getToggle($_POST["google_rechaptcha_toggle"])); | ||||
|     $db->updateSetting($mysqli, "google_recaptcha_sitekey", htmlspecialchars($_POST["google_recaptcha_sitekey"], ENT_QUOTES)); | ||||
|     $db->updateSetting($mysqli, "google_recaptcha_secret", htmlspecialchars($_POST["google_recaptcha_secret"], ENT_QUOTES)); | ||||
| 
 | ||||
|     $set_post = true; | ||||
|     if($nu_toggle == "yes"){ | ||||
|     /*if($nu_toggle == "yes"){ | ||||
|       $notifyUpdates_status = true; | ||||
|     } else { | ||||
|       $notifyUpdates_status = false; | ||||
|     } | ||||
|     define("NAME", $db->getSetting($mysqli,"name")); | ||||
|     }*/ | ||||
|     // TODO - Reload page to prevent showing old values! or update variables being displayed
 | ||||
|     header("Location: " .$uri = $_SERVER['REQUEST_URI']); | ||||
|     // TODO - The code below will not happen ...
 | ||||
| 
 | ||||
|     /*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")); | ||||
|     define("SUBSCRIBER_EMAIL", $db->getSetting($mysqli,"subscriber_email")); | ||||
|     define("SUBSCRIBER_TELEGRAM", $db->getSetting($mysqli,"subscriber_telegram")); | ||||
|     define("TG_BOT_API_TOKEN", $db->getSetting($mysqli,"tg_bot_api_token")); | ||||
|     define("TG_BOT_USERNAME", $db->getSetting($mysqli,"tg_bot_username")); | ||||
|     define("GOOGLE_RECAPTCHA", $db->getSetting($mysqli,"google_recaptcha")); | ||||
|     define("GOOGLE_RECAPTCHA_SITEKEY", $db->getSetting($mysqli,"google_recaptcha_sitekey")); | ||||
|     define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli,"google_recaptcha_secret")); | ||||
|     define("PHP_MAILER", $db->getSetting($mysqli,"php_mailer")); | ||||
|     define("PHP_MAILER_PATH", $db->getSetting($mysqli,"php_mailer_path")); | ||||
|     define("PHP_MAILER_SMTP", $db->getSetting($mysqli,"php_mailer_smtp")); | ||||
|     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->getSetting($mysqli,"php_mailer_secure")); | ||||
|     define("PHP_MAILER_USER", $db->getSetting($mysqli,"php_mailer_user")); | ||||
|     define("PHP_MAILER_PASS", $db->getSetting($mysqli,"php_mailer_pass")); | ||||
|     define("CRON_SERVER_IP", $db->getSetting($mysqli,"cron_server_ip")); | ||||
|     */ | ||||
|   } | ||||
|   Template::render_header(_("Options"), true); | ||||
| ?>
 | ||||
| @ -52,5 +106,78 @@ else{ | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="Username" aria-describedby="basic-addon1" name="sitename" value="<?php echo NAME; ?>"> | ||||
|     </div> | ||||
| 
 | ||||
|     <?php Template::render_toggle("Enable Email Subscription","email_subscription_toggle",$emailSubscription_status); ?>
 | ||||
|     <?php Template::render_toggle("Enable Telegram Subscription","telegram_subscription_toggle",$telegramSubscription_status); ?>
 | ||||
| 
 | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">Telegram BOT API Token</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="telegram_bot_api_token" aria-describedby="basic-addon1" name="tg_bot_api_token" value="<?php echo $tg_bot_api_token; ?>"> | ||||
|     </div> | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">Telegram BOT Username</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="telegram_bot_username" aria-describedby="basic-addon1" name="tg_bot_username" value="<?php echo $tg_bot_username; ?>"> | ||||
|     </div> | ||||
| 
 | ||||
|     <?php Template::render_toggle("Use PHPMailer for notifications","php_mailer_toggle",$php_mailer_status); ?>
 | ||||
|     <?php Template::render_toggle("Use SMTP with PHPMailer","php_mailer_smtp_toggle",$php_mailer_smtp_status); ?>
 | ||||
|     <?php Template::render_toggle("Use Secure SMTP with PHPMailer","php_mailer_secure_toggle",$php_mailer_secure_status); ?>
 | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">PHPMailer Path</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="phpmailer_path" aria-describedby="basic-addon1" name="php_mailer_path" value="<?php echo $php_mailer_path; ?>"> | ||||
|     </div> | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">PHPMailer SMTP Host</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="php_mailer_host" aria-describedby="basic-addon1" name="php_mailer_host" value="<?php echo $php_mailer_host; ?>"> | ||||
|     </div> | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">PHPMailer SMTP Port</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="php_mailer_port" aria-describedby="basic-addon1" name="php_mailer_port" value="<?php echo $php_mailer_port; ?>"> | ||||
|     </div> | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">PHPMailer Username</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="php_mailer_username" aria-describedby="basic-addon1" name="php_mailer_user" value="<?php echo $php_mailer_user; ?>"> | ||||
|     </div> | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">PHPMailer Password</span> | ||||
|         </div> | ||||
|         <input type="password" class="form-control" placeholder="" aria-label="php_mailer_password" aria-describedby="basic-addon1" name="php_mailer_pass" value="<?php echo $php_mailer_pass; ?>"> | ||||
|     </div> | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">Cron Server IP</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="cron_server_ip" aria-describedby="basic-addon1" name="cron_server_ip" value="<?php echo $cron_server_ip; ?>"> | ||||
|     </div> | ||||
| 
 | ||||
|     <?php Template::render_toggle("Use Google reChaptcha for subscriber signup","google_rechaptcha_toggle",$google_rechaptcha_status); ?>
 | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">Google reChaptcha Sitekey</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="google_sitekey" aria-describedby="basic-addon1" name="google_recaptcha_sitekey" value="<?php echo $google_recaptcha_sitekey; ?>"> | ||||
|     </div> | ||||
|     <div class="input-group mb-3"> | ||||
|         <div class="input-group-prepend"> | ||||
|         <span class="input-group-text" id="basic-addon1">Google reChaptcha Secret</span> | ||||
|         </div> | ||||
|         <input type="text" class="form-control" placeholder="" aria-label="google_secret" aria-describedby="basic-addon1" name="google_recaptcha_secret" value="<?php echo $google_recaptcha_secret; ?>"> | ||||
|     </div> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     <button class="btn btn-primary pull-right" type="submit">Save Settings</button> | ||||
| </form> | ||||
|  | ||||
| @ -40,4 +40,16 @@ class SSDB | ||||
|             } | ||||
| 
 | ||||
|     } | ||||
|     function updateSetting($conn, $settingname, $settingvalue){ | ||||
|         $this->deleteSetting($conn, $settingname); | ||||
|         $this->setSetting($conn, $settingname, $settingvalue); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     function getBooleanSetting($conn, $setting) { | ||||
|       if (trim($this->getSetting($conn, $setting)) == "yes"){ | ||||
|         return true; | ||||
|       } | ||||
|       return false; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -98,7 +98,7 @@ class Queue | ||||
|         $this->set_task_status($this->all_status['ready']); // Make task available for release
 | ||||
|     } | ||||
| 
 | ||||
|     public function update_notfication_retries($task_id, $subscriber_id) { | ||||
|     public function update_notification_retries($task_id, $subscriber_id) { | ||||
|         global $mysqli; | ||||
|         $stmt = $mysqli->prepare("UPDATE queue_notify SET retries = retries+1 WHERE task_id = ? AND subscriber_id = ?"); | ||||
|         $stmt->bind_param("ii", $task_id, $subscriber_id); | ||||
| @ -126,12 +126,12 @@ class Queue | ||||
|           $tmp = $stmt2->get_result(); | ||||
|           $result2 = $tmp->fetch_assoc(); | ||||
|           $typeID = $result2['type_id']; | ||||
|            | ||||
| 
 | ||||
|           // Handle telegram
 | ||||
|           if ($typeID == 1) { | ||||
|               $msg = str_replace("#s", $result['firstname'], $result2['template_data2']); | ||||
|               if ( ! Notification::submit_queue_telegram($result['userID'], $result['firstname'], $msg) ) { | ||||
|                 Queue::update_notfication_retries($result['task_id'], $result['subscriber_id']); // Sent
 | ||||
|                 Queue::update_notification_retries($result['task_id'], $result['subscriber_id']); // Sent
 | ||||
|               } else { | ||||
|                 Queue::delete_notification($result['task_id'], $result['subscriber_id']); // Failed
 | ||||
|               } | ||||
|  | ||||
| @ -31,26 +31,10 @@ define("POLICY_MAIL", "##policy_mail##"); //contact email in policy | ||||
| define("POLICY_PHONE", "##policy_phone##"); | ||||
| define("WHO_WE_ARE","##who_we_are##"); | ||||
| define("POLICY_URL","##policy_url##"); | ||||
| define('SUBSCRIBE_EMAIL', true); | ||||
| define('SUBSCRIBE_TELEGRAM', false); | ||||
| define("TG_BOT_API_TOKEN", "##tg_bot_token##"); //Telegram Bot Token | ||||
| define("TG_BOT_USERNAME", "##tg_bot_username##"); //Telegram Bot username | ||||
| define("INSTALL_OVERRIDE", false); | ||||
| define("DEFAULT_LANGUAGE", "en_GB"); | ||||
| define("GOOGLE_RECAPTCHA", false); | ||||
| define("GOOGLE_RECAPTCHA_SITEKEY", "##google_site_key##"); | ||||
| define("GOOGLE_RECAPTCHA_SECRET", "##google_secret##"); | ||||
| define("PHP_MAILER", false);  // Enable if we are to use extenral PHPMailer() library | ||||
| define("PHP_MAILER_PATH", "##phpmailer_path##"); // Path to src folder of PHPMailer() library - without ending / | ||||
| define("PHP_MAILER_SMTP", false); // Set to true if we are to use SMTP | ||||
| define("PHP_MAILER_HOST", "##phpmailer_host##");  // SMTP host | ||||
| define("PHP_MAILER_PORT", "##phpmailer_port##");  // SMTP Port | ||||
| define("PHP_MAILER_SECURE", ""); // Set to TLS or SSL or leave blank for plaintext | ||||
| define("PHP_MAILER_USER", "##phpmailer_user##");  // SMTP Authentication user | ||||
| define("PHP_MAILER_PASS", "##phpmailer_pass##");  // SMTP authenticatin password | ||||
| define("CUSTOM_LOGO_URL",""); // This will use the default logo if left empty | ||||
| define("COPYRIGHT_TEXT",""); // Leave this empty if you don't want your copyright displayed | ||||
| define("CRON_SERVER_IP",""); // IP Address that will be used to call cron task. Leave empty if not used! | ||||
| // Without COPYRIGHT_TEXT Set | ||||
| // 2020 Server Status Project Contributors | ||||
| // With COPYRIGHT_TEXT Set | ||||
|  | ||||
| @ -13,6 +13,23 @@ 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")); | ||||
| 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(); | ||||
| @ -25,18 +42,18 @@ if ( isset($_GET['new']) ) { | ||||
|     // Form validation for subscribers signing up
 | ||||
|     $message = ""; | ||||
|     Template :: render_header(_("Email Subscription")); | ||||
|      | ||||
| 
 | ||||
|     if (isset($_POST['emailaddress'])) { | ||||
|          | ||||
| 
 | ||||
|         if (0 == strlen(trim($_POST['emailaddress']))){ | ||||
|             $messages[] = _("Email address"); | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         // Perform DNS domain validation on
 | ||||
|         if ( ! $mailer->verify_domain($_POST['emailaddress']) ) { | ||||
|             $messages[] = _("Domain does not apper to be a valid email domain. (Check MX record)"); | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         if (GOOGLE_RECAPTCHA) { | ||||
|             // Validate recaptcha
 | ||||
|             $response = $_POST["g-recaptcha-response"]; | ||||
| @ -70,7 +87,7 @@ if ( isset($_GET['new']) ) { | ||||
|     if(isset($_POST['emailaddress']) && empty($message)) | ||||
|     { | ||||
| 
 | ||||
|         // Check if email is already registered        
 | ||||
|         // Check if email is already registered
 | ||||
|         $boolUserExist = false; | ||||
|         $subscriber->userID = $_POST['emailaddress']; | ||||
|         $subscriber->typeID = 2; // Email
 | ||||
| @ -82,17 +99,17 @@ if ( isset($_GET['new']) ) { | ||||
|             // Create a new subscriber as it does not exist
 | ||||
|             $subscriber->add($subscriber->typeID, $_POST['emailaddress']); | ||||
|             $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"));             | ||||
|    | ||||
|             $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")); | ||||
| 
 | ||||
|         } else { | ||||
|             if ( ! $subscriber->active ) { | ||||
|                 // Subscriber is registered, but has not been activated yet...
 | ||||
|                 $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")); | ||||
|                 $subscriber->activate($subscriber->id); | ||||
|                  | ||||
| 
 | ||||
|             } else { | ||||
|                 // subscriber is registered and active
 | ||||
|                 $msg = sprintf(_("Click on the following link to update your existing subscription:  <a href=\"%s\">%s</a>"), $url, NAME .' - ' . _("Manage subscription"));                 | ||||
|                 $msg = sprintf(_("Click on the following link to update your existing subscription:  <a href=\"%s\">%s</a>"), $url, NAME .' - ' . _("Manage subscription")); | ||||
|                 $subscriber->update($subscriber->id); | ||||
|             } | ||||
|         } | ||||
| @ -101,10 +118,10 @@ if ( isset($_GET['new']) ) { | ||||
|         $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   
 | ||||
|         // Send email about new registration
 | ||||
|         $subject = _('Email subscription registered').' - '.NAME; | ||||
|         $mailer->send_mail($_POST['emailaddress'], $subject, $msg); | ||||
|          | ||||
| 
 | ||||
|         $boolRegistered = true; | ||||
|     } | ||||
| 
 | ||||
| @ -116,8 +133,8 @@ if ( isset($_GET['new']) ) { | ||||
|         } | ||||
|         $strPostedEmail = (isset($_POST['emailaddress']))  ?  $_POST['emailaddress'] : ""; | ||||
|     ?>
 | ||||
|      | ||||
|      | ||||
| 
 | ||||
| 
 | ||||
|     <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"> | ||||
| @ -154,7 +171,7 @@ if ( isset($_GET['new']) ) { | ||||
|     // check if userid/token combo is valid, active or expired
 | ||||
|     $subscriber->typeID = 2; //EMAIL
 | ||||
|     if ( $subscriber->is_active_subscriber($_GET['token']) ) { | ||||
|         // forward user to subscriber list....       
 | ||||
|         // forward user to subscriber list....
 | ||||
|         $subscriber->set_logged_in(); | ||||
|         header('Location: subscriptions.php'); | ||||
|         exit; | ||||
| @ -165,38 +182,38 @@ if ( isset($_GET['new']) ) { | ||||
|         $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'];  | ||||
|                  | ||||
|         $subscriber->typeID = (int) $_GET['type']; | ||||
| 
 | ||||
|         if ( $subscriber->get_subscriber_by_token($_GET['token'])) { | ||||
|             $subscriber->delete($subscriber->id); | ||||
|             $subscriber->set_logged_off(); | ||||
|             Template :: render_header(_("Email Subscription")); | ||||
|              | ||||
| 
 | ||||
|             $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."); | ||||
| 			$constellation->render_success($header, $message, true, WEB_URL, _('Go back'));           | ||||
|                         | ||||
| 			$constellation->render_success($header, $message, true, WEB_URL, _('Go back')); | ||||
| 
 | ||||
|         } else { | ||||
|             // TODO Log token for troubleshooting ?
 | ||||
|             // Cannot find subscriber - show alert
 | ||||
|             Template :: render_header(_("Email Subscription")); | ||||
|             $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.");             | ||||
|             $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'));         | ||||
|     }     | ||||
|         $message = _("If you believe this to be an error, please contact the system admininistrator."); | ||||
|         $constellation->render_warning($header, $message, true, WEB_URL, _('Go back')); | ||||
|     } | ||||
| } | ||||
| Template :: render_footer(); | ||||
|  | ||||
| @ -40,6 +40,14 @@ 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")); | ||||
| 
 | ||||
| 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("GOOGLE_RECAPTCHA", $db->getBooleanSetting($mysqli,"google_recaptcha")); | ||||
| define("GOOGLE_RECAPTCHA_SITEKEY", $db->getSetting($mysqli,"google_recaptcha_sitekey")); | ||||
| define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli,"google_recaptcha_secret")); | ||||
| $offset = 0; | ||||
| 
 | ||||
| if (isset($_GET['ajax'])) | ||||
|  | ||||
							
								
								
									
										29
									
								
								install.php
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								install.php
									
									
									
									
									
								
							| @ -6,8 +6,6 @@ define("MINIMUM_PHP_VERSION", "5.4.0"); | ||||
| define("POLICY_URL", "policy.php"); //Default policy URL
 | ||||
| define("CUSTOM_LOGO_URL",""); | ||||
| define("COPYRIGHT_TEXT",""); | ||||
| define('SUBSCRIBE_EMAIL', false); | ||||
| define('SUBSCRIBE_TELEGRAM', false); | ||||
| require_once("classes/locale-negotiator.php"); | ||||
| require_once("classes/db-class.php"); | ||||
| 
 | ||||
| @ -141,14 +139,28 @@ if(isset($_POST['server']) && empty($message)) | ||||
| 		$config = str_replace("##who_we_are##", htmlspecialchars($_POST['who_we_are'], ENT_QUOTES), $config); | ||||
| 		$policy_url_conf = ( ! empty($_POST['policy_url']) ) ? htmlspecialchars($_POST['policy_url'], ENT_QUOTES) : $_POST['url']."/policy.php"; | ||||
| 		$config = str_replace("##policy_url##", $policy_url_conf, $config); | ||||
| 		$config = str_replace("##tg_bot_token##", htmlspecialchars($_POST['tgtoken'], ENT_QUOTES), $config); | ||||
| 		$config = str_replace("##tg_bot_username##", htmlspecialchars($_POST['tgbot'], ENT_QUOTES), $config); | ||||
| 
 | ||||
| 		file_put_contents("config.php", $config); | ||||
| 
 | ||||
| 		include_once "create-server-config.php"; | ||||
| 		$db->setSetting($mysqli,"dbConfigVersion","Version2Beta7"); | ||||
| 		$db->setSetting($mysqli,"notifyUpdates","yes"); | ||||
| 		$db->setSetting($mysqli,"subscribe_email","no"); | ||||
| 		$db->setSetting($mysqli,"subscribe_telegram","no"); | ||||
| 		$db->setSetting($mysqli,"tg_bot_api_token",""); | ||||
| 		$db->setSetting($mysqli,"tg_bot_username",""); | ||||
| 		$db->setSetting($mysqli,"php_mailer","no"); | ||||
| 		$db->setSetting($mysqli,"php_mailer_host",""); | ||||
| 		$db->setSetting($mysqli,"php_mailer_smtp","no"); | ||||
| 		$db->setSetting($mysqli,"php_mailer_path",""); | ||||
| 		$db->setSetting($mysqli,"php_mailer_port",""); | ||||
| 		$db->setSetting($mysqli,"php_mailer_secure","no"); | ||||
| 		$db->setSetting($mysqli,"php_mailer_user",""); | ||||
| 		$db->setSetting($mysqli,"php_mailer_pass",""); | ||||
| 		$db->setSetting($mysqli,"google_recaptcha","no"); | ||||
| 		$db->setSetting($mysqli,"google_recaptcha_secret",""); | ||||
| 		$db->setSetting($mysqli,"google_recaptcha_sitekey",""); | ||||
| 		$db->setSetting($mysqli,"cron_server_ip",""); | ||||
| 		unlink("create-server-config.php"); | ||||
| 		unlink("config.php.template"); | ||||
| 		unlink("install.sql"); | ||||
| @ -247,15 +259,6 @@ if (!empty($message)) | ||||
| 			<div class="col-sm-6"><label for="dbpassword"><?php echo _("Password");?>: </label><input type="password" name="dbpassword" value="<?php echo ((isset($_POST['dbpassword']))?htmlspecialchars($_POST['dbpassword'], ENT_QUOTES):'');?>" id="dbpassword" placeholder="<?php echo _("Password");?>" class="form-control" required></div>
 | ||||
| 		</div> | ||||
| 	</section> | ||||
| 	<section class="install-section clearfix"> | ||||
| 		<h2><?php echo _("Telegram");?></h2>
 | ||||
| 		<summary><?php echo _("You can provide a subscription feature through telegram.");?></summary>
 | ||||
| 
 | ||||
| 		<div class="form-group clearfix"> | ||||
| 			<div class="col-sm-6"><label for="tgtoken"><?php echo _("Telegram bot API Token");?>: </label><input type="text" name="tgtoken" value="<?php echo ((isset($_POST['tgtoken']))?htmlspecialchars($_POST['tgtoken'], ENT_QUOTES):'');?>" id="tgtoken" placeholder="<?php echo _("Telegram Bot API Token");?>" class="form-control"></div>
 | ||||
| 			<div class="col-sm-6"><label for="tgbot"><?php echo _("Telegram Bot Username");?>: </label><input type="text" name="tgbot" value="<?php echo ((isset($_POST['tgbot']))?htmlspecialchars($_POST['tgbot'], ENT_QUOTES):'');?>" id="tgbot" placeholder="<?php echo _("Telegram Bot Username");?>" class="form-control"></div>
 | ||||
| 		</div> | ||||
| 	</section> | ||||
| 	<section class="install-section clearfix"> | ||||
| 		<h2><?php echo _("Privacy Policy");?></h2>
 | ||||
| 		<summary><?php echo _("Since you are collecting personal information, the GDPR needs you to have a privacy policy. Enter the details below.");?></summary>
 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| <?php  | ||||
| <?php | ||||
| require_once("config.php"); | ||||
| require_once("template.php"); | ||||
| require_once("classes/constellation.php"); | ||||
| @ -11,6 +11,14 @@ 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")); | ||||
| define("SUBSCRIBE_EMAIL", $db->getBooleanSetting($mysqli, "subscribe_email")); | ||||
| define("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram")); | ||||
| define("GOOGLE_RECAPTCHA", $db->getSetting($mysqli, "google_recaptcha")); | ||||
| define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli, "google_recaptcha_secret")); | ||||
| define("GOOGLE_RECAPTCHA_SITEKEY", $db->getSetting($mysqli, "google_recaptcha_sitekey")); | ||||
| define("TG_BOT_API_TOKEN", $db->getSetting($mysqli, "tg_bot_api_token")); | ||||
| define("TG_BOT_USERNAME", $db->getSetting($mysqli, "tg_bot_username")); | ||||
| 
 | ||||
| $subscription = new Subscriptions(); | ||||
| $telegram     = new Telegram(); | ||||
| 
 | ||||
| @ -21,12 +29,12 @@ if ( SUBSCRIBE_TELEGRAM && $_SESSION['subscriber_typeid'] == 2 ) { | ||||
| } | ||||
| 
 | ||||
| if( $_SESSION['subscriber_valid'] ){ | ||||
|      | ||||
| 
 | ||||
|     $typeID       = $_SESSION['subscriber_typeid']; | ||||
|     $subscriberID = $_SESSION['subscriber_id'];    | ||||
|     $subscriberID = $_SESSION['subscriber_id']; | ||||
|     $userID       = $_SESSION['subscriber_userid']; | ||||
|     $token        = $_SESSION['subscriber_token']; | ||||
|      | ||||
| 
 | ||||
|     if(isset($_GET['add'])){ | ||||
|         $subscription->add($subscriberID, $_GET['add']); | ||||
|     } | ||||
| @ -38,11 +46,11 @@ if( $_SESSION['subscriber_valid'] ){ | ||||
|     $subscription->render_subscribed_services($typeID, $subscriberID, $userID, $token); | ||||
| 
 | ||||
| } else { | ||||
|      | ||||
| 
 | ||||
|     $header = _("Your session has expired or you tried something we don't suppprt"); | ||||
|     $message = _('If your session expired, retry your link or in case of Telegram use the login button in the top menu.'); | ||||
|     $constellation->render_warning($header, $message); | ||||
|      | ||||
| 
 | ||||
| 	header('Location: index.php'); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -2,6 +2,17 @@ | ||||
| require_once ("config.php"); | ||||
| require_once ("classes/telegram.php"); | ||||
| require_once ("classes/subscriber.php"); | ||||
| require_once ("classes/db-class.php"); | ||||
| $db = new SSDB(); | ||||
| 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")); | ||||
| define("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram")); | ||||
| define("SUBSCRIBE_TELEGRAM", $db->getBooleanSetting($mysqli, "subscribe_telegram")); | ||||
| define("TG_BOT_API_TOKEN", $db->getSetting($mysqli, "tg_bot_api_token")); | ||||
| define("TG_BOT_USERNAME", $db->getSetting($mysqli, "tg_bot_username")); | ||||
| 
 | ||||
| $telegram   = new Telegram(); | ||||
| $subscriber = new Subscriber(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user