|
1 | 1 | <?php |
| 2 | +function getToggle($variable){ |
| 3 | + $res = ((isset($variable) && ($variable == "on")) ? "yes" : "no"); |
| 4 | + return $res; |
| 5 | +} |
| 6 | + |
2 | 7 |
|
3 | 8 | if (!file_exists("../config.php")) |
4 | 9 | { |
|
15 | 20 | require_once("../classes/db-class.php"); |
16 | 21 | } |
17 | 22 | $db = new SSDB(); |
18 | | - if(trim($db->getSetting($mysqli,"notifyUpdates")) == "yes"){ |
19 | | - $notifyUpdates_status = true; |
20 | | - } else { |
21 | | - $notifyUpdates_status = false; |
22 | | - } |
| 23 | + $notifyUpdates_status = $db->getBooleanSetting($mysqli, "notifyUpdates"); |
| 24 | + $emailSubscription_status = $db->getBooleanSetting($mysqli, "subscribe_email"); |
| 25 | + $telegramSubscription_status = $db->getBooleanSetting($mysqli, "subscribe_telegram"); |
| 26 | + $tg_bot_api_token = $db->getSetting($mysqli, "tg_bot_api_token"); |
| 27 | + $tg_bot_username = $db->getSetting($mysqli, "tg_bot_username"); |
| 28 | + $php_mailer_status = $db->getBooleanSetting($mysqli, "php_mailer"); |
| 29 | + $php_mailer_smtp_status = $db->getBooleanSetting($mysqli, "php_mailer_smtp"); |
| 30 | + $php_mailer_secure_status = $db->getBooleanSetting($mysqli, "php_mailer_secure"); |
| 31 | + $php_mailer_path = $db->getSetting($mysqli, "php_mailer_path"); |
| 32 | + $php_mailer_host = $db->getSetting($mysqli, "php_mailer_host"); |
| 33 | + $php_mailer_port = $db->getSetting($mysqli, "php_mailer_port"); |
| 34 | + $php_mailer_user = $db->getSetting($mysqli, "php_mailer_user"); |
| 35 | + $php_mailer_pass = $db->getSetting($mysqli, "php_mailer_pass"); |
| 36 | + $cron_server_ip = $db->getSetting($mysqli, "cron_server_ip"); |
| 37 | + $google_rechaptcha_status = $db->getBooleanSetting($mysqli, "google_recaptcha"); |
| 38 | + $google_recaptcha_sitekey = $db->getSetting($mysqli, "google_recaptcha_sitekey"); |
| 39 | + $google_recaptcha_secret = $db->getSetting($mysqli, "google_recaptcha_secret"); |
| 40 | + |
| 41 | + $db->getSetting($mysqli, ""); |
23 | 42 | $set_post = false; |
24 | 43 | if(!empty($_POST)){ |
25 | | - if($_POST["nu_toggle"] == "on"){ $nu_toggle = "yes"; } else { $nu_toggle = "no"; } |
26 | | - $db->deleteSetting($mysqli,"notifyUpdates"); |
27 | | - $db->setSetting($mysqli,"notifyUpdates",$nu_toggle); |
28 | | - $db->deleteSetting($mysqli,"name"); |
29 | | - $db->setSetting($mysqli,"name",$_POST["sitename"]); |
| 44 | + $db->updateSetting($mysqli, "notifyUpdates", getToggle($_POST["nu_toggle"])); |
| 45 | + $db->updateSetting($mysqli, "name",htmlspecialchars($_POST["sitename"], ENT_QUOTES)); |
| 46 | + $db->updateSetting($mysqli, "subscribe_email", getToggle($_POST["email_subscription_toggle"])); |
| 47 | + $db->updateSetting($mysqli, "subscribe_telegram", getToggle($_POST["telegram_subscription_toggle"])); |
| 48 | + $db->updateSetting($mysqli, "tg_bot_api_token", htmlspecialchars($_POST["tg_bot_api_token"], ENT_QUOTES)); |
| 49 | + $db->updateSetting($mysqli, "tg_bot_username", htmlspecialchars($_POST["tg_bot_username"], ENT_QUOTES)); |
| 50 | + $db->updateSetting($mysqli, "php_mailer", getToggle($_POST["php_mailer_toggle"])); |
| 51 | + $db->updateSetting($mysqli, "php_mailer_smtp", getToggle($_POST["php_mailer_smtp_toggle"])); |
| 52 | + $db->updateSetting($mysqli, "php_mailer_secure", getToggle($_POST["php_mailer_secure_toggle"])); |
| 53 | + $db->updateSetting($mysqli, "php_mailer_path", htmlspecialchars($_POST["php_mailer_path"], ENT_QUOTES)); |
| 54 | + $db->updateSetting($mysqli, "php_mailer_host", htmlspecialchars($_POST["php_mailer_host"], ENT_QUOTES)); |
| 55 | + $db->updateSetting($mysqli, "php_mailer_port", htmlspecialchars($_POST["php_mailer_port"], ENT_QUOTES)); |
| 56 | + $db->updateSetting($mysqli, "php_mailer_user", htmlspecialchars($_POST["php_mailer_user"], ENT_QUOTES)); |
| 57 | + $db->updateSetting($mysqli, "php_mailer_pass", htmlspecialchars($_POST["php_mailer_pass"], ENT_QUOTES)); |
| 58 | + $db->updateSetting($mysqli, "cron_server_ip", htmlspecialchars($_POST["cron_server_ip"], ENT_QUOTES)); |
| 59 | + $db->updateSetting($mysqli, "google_recaptcha", getToggle($_POST["google_rechaptcha_toggle"])); |
| 60 | + $db->updateSetting($mysqli, "google_recaptcha_sitekey", htmlspecialchars($_POST["google_recaptcha_sitekey"], ENT_QUOTES)); |
| 61 | + $db->updateSetting($mysqli, "google_recaptcha_secret", htmlspecialchars($_POST["google_recaptcha_secret"], ENT_QUOTES)); |
| 62 | + |
30 | 63 | $set_post = true; |
31 | | - if($nu_toggle == "yes"){ |
| 64 | + /*if($nu_toggle == "yes"){ |
32 | 65 | $notifyUpdates_status = true; |
33 | 66 | } else { |
34 | 67 | $notifyUpdates_status = false; |
35 | | - } |
36 | | - define("NAME", $db->getSetting($mysqli,"name")); |
| 68 | + }*/ |
| 69 | + // TODO - Reload page to prevent showing old values! or update variables being displayed |
| 70 | + header("Location: " .$uri = $_SERVER['REQUEST_URI']); |
| 71 | + // TODO - The code below will not happen ... |
| 72 | + |
| 73 | + /*define("NAME", $db->getSetting($mysqli,"name")); |
37 | 74 | define("TITLE", $db->getSetting($mysqli,"title")); |
38 | 75 | define("WEB_URL", $db->getSetting($mysqli,"url")); |
39 | 76 | define("MAILER_NAME", $db->getSetting($mysqli,"mailer")); |
40 | 77 | define("MAILER_ADDRESS", $db->getSetting($mysqli,"mailer_email")); |
| 78 | + define("SUBSCRIBER_EMAIL", $db->getSetting($mysqli,"subscriber_email")); |
| 79 | + define("SUBSCRIBER_TELEGRAM", $db->getSetting($mysqli,"subscriber_telegram")); |
| 80 | + define("TG_BOT_API_TOKEN", $db->getSetting($mysqli,"tg_bot_api_token")); |
| 81 | + define("TG_BOT_USERNAME", $db->getSetting($mysqli,"tg_bot_username")); |
| 82 | + define("GOOGLE_RECAPTCHA", $db->getSetting($mysqli,"google_recaptcha")); |
| 83 | + define("GOOGLE_RECAPTCHA_SITEKEY", $db->getSetting($mysqli,"google_recaptcha_sitekey")); |
| 84 | + define("GOOGLE_RECAPTCHA_SECRET", $db->getSetting($mysqli,"google_recaptcha_secret")); |
| 85 | + define("PHP_MAILER", $db->getSetting($mysqli,"php_mailer")); |
| 86 | + define("PHP_MAILER_PATH", $db->getSetting($mysqli,"php_mailer_path")); |
| 87 | + define("PHP_MAILER_SMTP", $db->getSetting($mysqli,"php_mailer_smtp")); |
| 88 | + define("PHP_MAILER_HOST", $db->getSetting($mysqli,"php_mailer_host")); |
| 89 | + define("PHP_MAILER_PORT", $db->getSetting($mysqli,"php_mailer_port")); |
| 90 | + define("PHP_MAILER_SECURE", $db->getSetting($mysqli,"php_mailer_secure")); |
| 91 | + define("PHP_MAILER_USER", $db->getSetting($mysqli,"php_mailer_user")); |
| 92 | + define("PHP_MAILER_PASS", $db->getSetting($mysqli,"php_mailer_pass")); |
| 93 | + define("CRON_SERVER_IP", $db->getSetting($mysqli,"cron_server_ip")); |
| 94 | + */ |
41 | 95 | } |
42 | 96 | Template::render_header(_("Options"), true); |
43 | 97 | ?> |
|
52 | 106 | </div> |
53 | 107 | <input type="text" class="form-control" placeholder="" aria-label="Username" aria-describedby="basic-addon1" name="sitename" value="<?php echo NAME; ?>"> |
54 | 108 | </div> |
| 109 | + |
| 110 | + <?php Template::render_toggle("Enable Email Subscription","email_subscription_toggle",$emailSubscription_status); ?> |
| 111 | + <?php Template::render_toggle("Enable Telegram Subscription","telegram_subscription_toggle",$telegramSubscription_status); ?> |
| 112 | + |
| 113 | + <div class="input-group mb-3"> |
| 114 | + <div class="input-group-prepend"> |
| 115 | + <span class="input-group-text" id="basic-addon1">Telegram BOT API Token</span> |
| 116 | + </div> |
| 117 | + <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; ?>"> |
| 118 | + </div> |
| 119 | + <div class="input-group mb-3"> |
| 120 | + <div class="input-group-prepend"> |
| 121 | + <span class="input-group-text" id="basic-addon1">Telegram BOT Username</span> |
| 122 | + </div> |
| 123 | + <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; ?>"> |
| 124 | + </div> |
| 125 | + |
| 126 | + <?php Template::render_toggle("Use PHPMailer for notifications","php_mailer_toggle",$php_mailer_status); ?> |
| 127 | + <?php Template::render_toggle("Use SMTP with PHPMailer","php_mailer_smtp_toggle",$php_mailer_smtp_status); ?> |
| 128 | + <?php Template::render_toggle("Use Secure SMTP with PHPMailer","php_mailer_secure_toggle",$php_mailer_secure_status); ?> |
| 129 | + <div class="input-group mb-3"> |
| 130 | + <div class="input-group-prepend"> |
| 131 | + <span class="input-group-text" id="basic-addon1">PHPMailer Path</span> |
| 132 | + </div> |
| 133 | + <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; ?>"> |
| 134 | + </div> |
| 135 | + <div class="input-group mb-3"> |
| 136 | + <div class="input-group-prepend"> |
| 137 | + <span class="input-group-text" id="basic-addon1">PHPMailer SMTP Host</span> |
| 138 | + </div> |
| 139 | + <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; ?>"> |
| 140 | + </div> |
| 141 | + <div class="input-group mb-3"> |
| 142 | + <div class="input-group-prepend"> |
| 143 | + <span class="input-group-text" id="basic-addon1">PHPMailer SMTP Port</span> |
| 144 | + </div> |
| 145 | + <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; ?>"> |
| 146 | + </div> |
| 147 | + <div class="input-group mb-3"> |
| 148 | + <div class="input-group-prepend"> |
| 149 | + <span class="input-group-text" id="basic-addon1">PHPMailer Username</span> |
| 150 | + </div> |
| 151 | + <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; ?>"> |
| 152 | + </div> |
| 153 | + <div class="input-group mb-3"> |
| 154 | + <div class="input-group-prepend"> |
| 155 | + <span class="input-group-text" id="basic-addon1">PHPMailer Password</span> |
| 156 | + </div> |
| 157 | + <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; ?>"> |
| 158 | + </div> |
| 159 | + <div class="input-group mb-3"> |
| 160 | + <div class="input-group-prepend"> |
| 161 | + <span class="input-group-text" id="basic-addon1">Cron Server IP</span> |
| 162 | + </div> |
| 163 | + <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; ?>"> |
| 164 | + </div> |
| 165 | + |
| 166 | + <?php Template::render_toggle("Use Google reChaptcha for subscriber signup","google_rechaptcha_toggle",$google_rechaptcha_status); ?> |
| 167 | + <div class="input-group mb-3"> |
| 168 | + <div class="input-group-prepend"> |
| 169 | + <span class="input-group-text" id="basic-addon1">Google reChaptcha Sitekey</span> |
| 170 | + </div> |
| 171 | + <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; ?>"> |
| 172 | + </div> |
| 173 | + <div class="input-group mb-3"> |
| 174 | + <div class="input-group-prepend"> |
| 175 | + <span class="input-group-text" id="basic-addon1">Google reChaptcha Secret</span> |
| 176 | + </div> |
| 177 | + <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; ?>"> |
| 178 | + </div> |
| 179 | + |
| 180 | + |
| 181 | + |
55 | 182 | <button class="btn btn-primary pull-right" type="submit">Save Settings</button> |
56 | 183 | </form> |
0 commit comments