/** * Initializes Connection and Log's In * * @return bool */ public function init() { $this->version = $this->read(true); if (!$this->login()) { // UPDATE LAST STREAM STATUS // ADDED BY SHARPBUNNY serverDown(); return false; } else { // UPDATE LAST STREAM STATUS // ADDED BY SHARPBUNNY updateSetting('server_last_stream', time()); updateSetting('server_status', 'up'); updateSetting('notify_sent', 'false'); return true; } }
/** * serverDown() * Report that the server is down, eventually activate the notifier * * @return str 'Reported' */ function serverDown() { global $settings; updateSetting('server_status', 'down'); /* * NOTIFIER * * - Sends an e-mail when the server is down */ if ($settings['notify'] == 'true' && $settings['notify_sent'] == 'false') { // Message $message = 'Hello!' . PHP_EOL . 'The servertool could not connect to your BFP4F server, please check your server and your RCON information.' . PHP_EOL . 'Click on this link to access the ControlPanel: ' . HOME_URL . PHP_EOL . PHP_EOL . 'BF2 Servertool Notifier'; // Send e-mail Email($settings['notify_email'], $settings['notify_email'], 'Server is down!', $message); // Update the notifier, so it won't send another e-mail the next time updateSetting('notify_sent', 'true'); } return 'Reported'; }
/** * save Settings * * @param $dbTable * @param $settings */ function saveSettings($dbTable, $settings) { global $cfg, $db; foreach ($settings as $key => $value) { if (array_key_exists($key, $cfg)) { if (is_array($cfg[$key]) || is_array($value)) { if (serialize($cfg[$key]) != serialize($value)) { updateSetting($dbTable, $key, $value); } } elseif ($cfg[$key] != $value) { updateSetting($dbTable, $key, $value); } } else { insertSetting($dbTable, $key, $value); } } }
/** * store new jobs-list setting * * @param $jobs jobs-list as array * @return boolean */ function _jobsUpdateSetting($jobs) { global $cfg; // build setting value $setting = $this->_jobsSerialize($jobs); if ($setting === false) { return false; } // update setting updateSetting("tf_settings", "fluxd_Watch_jobs", $setting); // log AuditAction($cfg["constants"]["fluxd"], "Watch Jobs Saved : \n" . $setting); return true; }
exec("kill -9 \$(ps -efx | grep \"php -S localhost:15298\" | grep -v grep | awk '{print \$2}')"); return; } $ret = updateSetting($w, 'country_code', $user->country); if ($ret == false) { echo "There was an error when updating settings"; exec("kill -9 \$(ps -efx | grep \"php -S localhost:15298\" | grep -v grep | awk '{print \$2}')"); return; } $ret = updateSetting($w, 'display_name', $user->display_name); if ($ret == false) { echo "There was an error when updating settings"; exec("kill -9 \$(ps -efx | grep \"php -S localhost:15298\" | grep -v grep | awk '{print \$2}')"); return; } $ret = updateSetting($w, 'userid', $user->id); if ($ret == false) { echo "There was an error when updating settings"; exec("kill -9 \$(ps -efx | grep \"php -S localhost:15298\" | grep -v grep | awk '{print \$2}')"); return; } echo "Hello {$user->display_name} ! You are now successfully logged and you can close this window."; } else { echo "There was an error during the authentication (could not get token)"; } } else { echo "There was an error during the authentication (could not get code)"; } } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { echo "There was an error during the authentication (exception " . $e . ")"; }
<?php include_once "../dao/DBHelper.php"; include_once "../dao/getSetting.php"; $sliderSetting = $_POST['sliderSetting']; updateSetting($sliderSetting);
/** * getSettings function. * * @access public * @param mixed $w * @return void */ function getSettings($w) { if (file_exists($w->data() . '/settings.db') && !file_exists($w->data() . '/settings.json')) { // migrate settings.db to settings.json // // Read settings from DB // $getSettings = 'select all_playlists,is_spotifious_active,is_alfred_playlist_active,radio_number_tracks,is_lyrics_active,max_results, alfred_playlist_uri,alfred_playlist_name,country_code,theme,last_check_update_time,oauth_client_id,oauth_client_secret,oauth_redirect_uri,oauth_access_token,oauth_expires,oauth_refresh_token,display_name,userid,echonest_api_key from settings'; $dbsettingsfile = $w->data() . '/settings.db'; try { $dbsettings = new PDO("sqlite:{$dbsettingsfile}", "", "", array(PDO::ATTR_PERSISTENT => true)); $dbsettings->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbsettings->query("PRAGMA synchronous = OFF"); $dbsettings->query("PRAGMA journal_mode = OFF"); $dbsettings->query("PRAGMA temp_store = MEMORY"); $dbsettings->query("PRAGMA count_changes = OFF"); $dbsettings->query("PRAGMA PAGE_SIZE = 4096"); $dbsettings->query("PRAGMA default_cache_size=700000"); $dbsettings->query("PRAGMA cache_size=700000"); $dbsettings->query("PRAGMA compile_options"); $stmt = $dbsettings->prepare($getSettings); $settings = $stmt->execute(); $setting = $stmt->fetch(); $migrated = array('all_playlists' => $setting[0], 'is_alfred_playlist_active' => $setting[2], 'radio_number_tracks' => $setting[3], 'now_playing_notifications' => 1, 'max_results' => $setting[5], 'alfred_playlist_uri' => $setting[6], 'alfred_playlist_name' => $setting[7], 'country_code' => $setting[8], 'last_check_update_time' => $setting[10], 'oauth_client_id' => $setting[11], 'oauth_client_secret' => $setting[12], 'oauth_redirect_uri' => 'http://localhost:15298/callback.php', 'oauth_access_token' => $setting[14], 'oauth_expires' => $setting[15], 'oauth_refresh_token' => $setting[16], 'display_name' => $setting[17], 'userid' => $setting[18], 'echonest_api_key' => '5EG94BIZEGFEY9AL9', 'is_public_playlists' => 0); $ret = $w->write($migrated, 'settings.json'); } catch (PDOException $e) { logMsg("Error(getSettings): (exception " . print_r($e) . ")"); } deleteTheFile($w->data() . '/settings.db'); } $settings = $w->read('settings.json'); if ($settings == false) { $default = array('all_playlists' => 1, 'is_alfred_playlist_active' => 1, 'radio_number_tracks' => 30, 'now_playing_notifications' => 1, 'max_results' => 50, 'alfred_playlist_uri' => '', 'alfred_playlist_name' => '', 'country_code' => '', 'last_check_update_time' => 0, 'oauth_client_id' => '', 'oauth_client_secret' => '', 'oauth_redirect_uri' => 'http://localhost:15298/callback.php', 'oauth_access_token' => '', 'oauth_expires' => 0, 'oauth_refresh_token' => '', 'display_name' => '', 'userid' => '', 'echonest_api_key' => '5EG94BIZEGFEY9AL9', 'is_public_playlists' => 0, 'quick_mode' => 0); $ret = $w->write($default, 'settings.json'); displayNotificationWithArtwork("Settings have been set to default", './images/info.png', 'Settings reset'); $settings = $w->read('settings.json'); } // add quick_mode if needed if (!isset($settings->quick_mode)) { updateSetting($w, 'quick_mode', 0); $settings = $w->read('settings.json'); } return $settings; }
send('</form>'); } elseif (isset($_REQUEST["23"])) { // 23 - Configuration - Server Settings save sendHead(" - Configuration"); send("<h1>" . _TITLE . "</h1>"); send("<h2>Configuration - Server Settings Save</h2>"); $docroot = $_REQUEST["docroot"]; if (is_file(_FILE_DBCONF)) { require_once _FILE_DBCONF; $dbCon = getAdoConnection($cfg["db_type"], $cfg["db_host"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_name"]); if (!$dbCon) { send('<font color="red"><strong>Error</strong></font><br>'); send("cannot connect to database.<p>"); } else { $settingsSaveCtr = 0; if (updateSetting("tf_settings", "docroot", $docroot) === true) { $settingsSaveCtr++; } if ($settingsSaveCtr == 1) { send('<font color="green"><strong>Ok</strong></font><br>'); send('Server Settings saved.'); send("<h2>Next : Rename Files and Dirs</h2>"); sendButton(3); } else { send('<font color="red"><strong>Error</strong></font><br>'); send('could not save Server Settings.'); send('<form name="setup" action="' . _FILE_THIS . '" method="post">'); send('<input type="Hidden" name="docroot" value="' . $docroot . '">'); send('<input type="Hidden" name="21" value="">'); send('<input type="submit" value="Back">'); send('</form>');
} else { displayNotificationWithArtwork("Error while updating settings", './images/settings.png', 'Error!'); } return; } else { if ($other_action == "enable_public_playlists") { $ret = updateSetting($w, 'is_public_playlists', 1); if ($ret == true) { displayNotificationWithArtwork("New playlists will be now public", './images/enable_public_playlists.png', 'Settings'); } else { displayNotificationWithArtwork("Error while updating settings", './images/settings.png', 'Error!'); } return; } else { if ($other_action == "disable_public_playlists") { $ret = updateSetting($w, 'is_public_playlists', 0); if ($ret == true) { displayNotificationWithArtwork("New playlists will be now private", './images/disable_public_playlists.png', 'Settings'); } else { displayNotificationWithArtwork("Error while updating settings", './images/settings.png', 'Error!'); } return; } else { if ($other_action == "play_track_in_album_context") { // start now playing if needed $mopidy_arg = ""; if ($use_mopidy) { $mopidy_arg = "MOPIDY"; } exec("./src/spotify_mini_player_notifications.ksh -d \"" . $w->data() . "\" -a start -m \"" . $mopidy_arg . "\" >> \"" . $w->cache() . "/action.log\" 2>&1 & "); if (!$use_mopidy) {
/** * updates jobs * * @param $content * @return boolean */ function _jobsUpdate($content) { global $cfg; $jobsSane = array(); $jobs = explode($this->_delimJobs, trim($content)); if ($jobs !== false && count($jobs) > 0) { while (count($jobs) > 0) { $job = array_shift($jobs); $jobAry = explode($this->_delimJob, trim($job)); $savedir = trim(array_shift($jobAry)); $url = trim(array_shift($jobAry)); $filtername = trim(array_shift($jobAry)); if (strlen($savedir) > 0 && strlen($url) > 0 && strlen($filtername) > 0) { array_push($jobsSane, array('savedir' => trim(checkDirPathString($savedir)), 'url' => $url, 'filtername' => $filtername)); } } $jobsString = ""; $resultCount = count($jobsSane); for ($i = 0; $i < $resultCount; $i++) { $jobsString .= $jobsSane[$i]["savedir"] . $this->_delimJob; $jobsString .= $jobsSane[$i]["url"] . $this->_delimJob; $jobsString .= $jobsSane[$i]["filtername"]; if ($i < $resultCount - 1) { $jobsString .= $this->_delimJobs; } } // update setting updateSetting("tf_settings", "fluxd_Rssad_jobs", $jobsString); // log AuditAction($cfg["constants"]["fluxd"], "Rssad Jobs Saved : \n" . $jobsString); return true; } else { return false; } }
$errors[] = $lang['tool_mrot_err2']; } else { foreach ($_POST['rotation'] as $map) { $rotation[] = explode('|', $map); } } } // Check rpm if (!is_numeric($_POST['rpm'])) { $errors[] = $lang['tool_sl_err3']; } else { $_POST['rpm'] = round($_POST['rpm']); } // Check errors and stuff if (count($errors) == 0) { if (updateSetting('tool_mrot_rpm', $_POST['rpm'])) { $sv = new rcon\Server(); $sv->clearRotation(); foreach ($rotation as $map) { $sv->appendMap($map[0], $map[1]); } $sv->setNumOfRounds($_POST['rpm']); $status = '<div class="alert alert-success alert-block"><h4><i class="fa fa-check"></i> ' . $lang['word_ok'] . '</h4><p>' . $lang['msg_settings_saved'] . '</p></div>'; $log->insertActionLog($userInfo['user_id'], 'Map rotation edited'); } else { $status = '<div class="alert alert-danger alert-block"><h4><i class="fa fa-times"></i> ' . $lang['word_error'] . '</h4><p>' . $result['message'] . '</p></div>'; } } else { $status = '<div class="alert alert-danger alert-block"><h4><i class="fa fa-times"></i> ' . $lang['word_error'] . '</h4><p>' . $lang['msg_error'] . '</p><ul><li>' . implode('</li><li>', $errors) . '</li></ul></div>'; } }
* sl = Shotgun limiter * ll = Level limiter * cl = Class limiter * whl = Whitelist * dsl = Dual-slot limiter * igcmds = In-game commands */ $tools = array('wl', 'pl', 'al', 'sl', 'll', 'cl', 'whl', 'dsl', 'igcmds'); if (in_array($_POST['vars']['tool'], $tools)) { if ($settings['tool_' . $_POST['vars']['tool']] == 'true') { updateSetting('tool_' . $_POST['vars']['tool'], 'false'); $response['status'] = 'OK'; $response['msg'] = $lang['word_disabled']; $log->insertActionLog($userInfo['user_id'], 'tool_' . $_POST['vars']['tool'] . ' disabled'); } else { updateSetting('tool_' . $_POST['vars']['tool'], 'true'); $response['status'] = 'OK'; $response['msg'] = $lang['word_enabled']; $log->insertActionLog($userInfo['user_id'], 'tool_' . $_POST['vars']['tool'] . ' enabled'); } } else { $response['msg'] = $lang['msg_cmd_noaccess']; } } else { $response['msg'] = $lang['msg_cmd_noaccess']; } } else { $response['msg'] = $lang['msg_cmd_missingvars']; } break; /**
function saveSettings($settings) { global $cfg, $db; if ($settings == null) { return; } foreach ($settings as $key => $value) { if (array_key_exists($key, $cfg)) { if (is_array($cfg[$key]) || is_array($value)) { if (serialize($cfg[$key]) != serialize($value)) { updateSetting($key, $value); } } elseif ($cfg[$key] != $value) { updateSetting($key, $value); } else { // Nothing has Changed.. } } else { insertSetting($key, $value); } } }
* IN-GAME ADMIN MESSAGES * * - Displays a message with the currently in-game admins */ if ($settings['tool_am'] > 0 && time() - $settings['tool_am_last'] >= $settings['tool_am']) { if (count($admins) > 0) { $message = replace($settings['tool_am_msg'], array('%admins%' => implode(', ', $admins))); } else { $message = replace($settings['tool_am_msg_alt']); } $ct->send($message); updateSetting('tool_am_last', time()); } /** * THE SMALL ADVERTISMENT * I would really appreciate it if you enable this! :3 */ if ($settings['iga_ad'] > 0 && time() - $settings['iga_ad_last'] >= $settings['iga_ad']) { $ct->send(replace($settings['iga_ad_msg'])); updateSetting('iga_ad_last', time()); } /** * Display message */ die('[' . date($settings['cp_date_format_full']) . '] Executed' . PHP_EOL); } else { /** * Failed... */ die('[' . date($settings['cp_date_format_full']) . '] Could not connect' . PHP_EOL); }
if ($_POST['notifier'] == 'true') { if (!filter_var($_POST['notify_email'], FILTER_VALIDATE_EMAIL)) { $errors[] = $lang['tool_set_err4']; } } // Check iga_ad if (!in_array($_POST['iga_ad'], array(0, 30, 60, 90, 120, 180, 240, 300))) { $errors[] = $lang['tool_set_err2']; } // Check bml //if(!preg_match('{(http://|https://)(www.)?(battlefield.play4free.com/bookmark/server:)([a-z0-9-]+)}', $_POST['bml'], $matches)) { // $errors[] = $lang['tool_set_err5']; //} // Check errors and stuff if (count($errors) == 0) { if (updateSetting('cp_default_lang', $_POST['lang']) && updateSetting('cp_date_format', $_POST['df']) && updateSetting('cp_date_format_full', $_POST['df_full']) && updateSetting('notify', $_POST['notifier']) && updateSetting('notify_email', $_POST['notify_email']) && updateSetting('iga_ad', $_POST['iga_ad'])) { $status = '<div class="alert alert-success alert-block"><h4><i class="fa fa-check"></i> ' . $lang['word_ok'] . '</h4><p>' . $lang['msg_settings_saved'] . '</p></div>'; $log->insertActionLog($userInfo['user_id'], 'Settings edited'); // Reload settings fetchSettings(); } else { $status = '<div class="alert alert-danger alert-block"><h4><i class="fa fa-times"></i> ' . $lang['word_error'] . '</h4><p>' . $result['message'] . '</p></div>'; } } else { $status = '<div class="alert alert-danger alert-block"><h4><i class="fa fa-times"></i> ' . $lang['word_error'] . '</h4><p>' . $lang['msg_error'] . '</p><ul><li>' . implode('</li><li>', $errors) . '</li></ul></div>'; } } ?> <div class="row"> <div class="col-md-8 col-md-offset-2">