Add global proxy support
							parent
							
								
									cf41316998
								
							
						
					
					
						commit
						7b3f792f76
					
				| 
						 | 
				
			
			@ -335,6 +335,16 @@ function psm_curl_get($href, $header = false, $body = true, $timeout = null, $ad
 | 
			
		|||
 | 
			
		||||
	curl_setopt($ch, CURLOPT_URL, $href);
 | 
			
		||||
 | 
			
		||||
	$proxy_url = psm_get_conf('proxy_url','');
 | 
			
		||||
	if (psm_get_conf('proxy','0') === '1') {
 | 
			
		||||
		curl_setopt($ch, CURLOPT_PROXY, $proxy_url);
 | 
			
		||||
		$proxy_user = psm_get_conf('proxy_user','');
 | 
			
		||||
		$proxy_password = psm_get_conf('proxy_password','');
 | 
			
		||||
		if (!empty($proxy_user) && !empty($proxy_password)) {
 | 
			
		||||
			curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_user . ':' . $proxy_password);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if($add_agent) {
 | 
			
		||||
		curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; phpservermon/'.PSM_VERSION.'; +http://www.phpservermonitor.org)');
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -188,6 +188,10 @@ $sm_lang = array(
 | 
			
		|||
		'show_update' => 'Check for updates?',
 | 
			
		||||
		'password_encrypt_key' => 'The encryption key password',
 | 
			
		||||
		'password_encrypt_key_note' => 'This key is used to encrypt passwords that are stored on servers for access to websites. If the key will change the stored password is invalid!',
 | 
			
		||||
		'proxy' => 'Enable proxy',
 | 
			
		||||
		'proxy_url' => 'Proxy URL',
 | 
			
		||||
		'proxy_user' => 'Proxy username',
 | 
			
		||||
		'proxy_password' => 'Proxy password',
 | 
			
		||||
		'email_status' => 'Allow sending email',
 | 
			
		||||
		'email_from_email' => 'Email from address',
 | 
			
		||||
		'email_from_name' => 'Email from name',
 | 
			
		||||
| 
						 | 
				
			
			@ -234,6 +238,8 @@ $sm_lang = array(
 | 
			
		|||
		'alert_type_status' => 'Status change',
 | 
			
		||||
		'alert_type_offline' => 'Offline',
 | 
			
		||||
		'alert_type_always' => 'Always',
 | 
			
		||||
		'alert_proxy' => 'Even if enabled, proxy is never used for services',
 | 
			
		||||
		'alert_proxy_url' => '<b>Format:</b> Host:Port',
 | 
			
		||||
		'log_status' => 'Log status',
 | 
			
		||||
		'log_status_description' => 'If log status is set to TRUE, the monitor will log the event whenever the Notification settings are passed.',
 | 
			
		||||
		'log_email' => 'Log emails sent by the script',
 | 
			
		||||
| 
						 | 
				
			
			@ -248,6 +254,7 @@ $sm_lang = array(
 | 
			
		|||
		'settings_pushover' => 'Pushover settings',
 | 
			
		||||
		'settings_notification' => 'Notification settings',
 | 
			
		||||
		'settings_log' => 'Log settings',
 | 
			
		||||
		'settings_proxy' => 'Proxy settings',
 | 
			
		||||
		'auto_refresh' => 'Auto-refresh',
 | 
			
		||||
		'auto_refresh_servers' =>
 | 
			
		||||
			'Auto-refresh servers page.<br/>'.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,7 @@ class ConfigController extends AbstractController {
 | 
			
		|||
	 * @var array $checkboxes
 | 
			
		||||
	 */
 | 
			
		||||
	protected $checkboxes = array(
 | 
			
		||||
		'proxy',
 | 
			
		||||
		'email_status',
 | 
			
		||||
		'email_smtp',
 | 
			
		||||
		'sms_status',
 | 
			
		||||
| 
						 | 
				
			
			@ -52,6 +53,9 @@ class ConfigController extends AbstractController {
 | 
			
		|||
	 * @var array $fields
 | 
			
		||||
	 */
 | 
			
		||||
	protected $fields = array(
 | 
			
		||||
		'proxy_url',
 | 
			
		||||
		'proxy_user',
 | 
			
		||||
		'proxy_password',
 | 
			
		||||
		'email_from_name',
 | 
			
		||||
		'email_from_email',
 | 
			
		||||
		'email_smtp_host',
 | 
			
		||||
| 
						 | 
				
			
			@ -293,11 +297,16 @@ class ConfigController extends AbstractController {
 | 
			
		|||
			'label_settings_pushover' => psm_get_lang('config', 'settings_pushover'),
 | 
			
		||||
			'label_settings_notification' => psm_get_lang('config', 'settings_notification'),
 | 
			
		||||
			'label_settings_log' => psm_get_lang('config', 'settings_log'),
 | 
			
		||||
			'label_settings_proxy' => psm_get_lang('config', 'settings_proxy'),
 | 
			
		||||
			'label_general' => psm_get_lang('config', 'general'),
 | 
			
		||||
			'label_language' => psm_get_lang('config', 'language'),
 | 
			
		||||
			'label_show_update' => psm_get_lang('config', 'show_update'),
 | 
			
		||||
			'label_password_encrypt_key' => psm_get_lang('config', 'password_encrypt_key'),
 | 
			
		||||
			'label_password_encrypt_key_note' => psm_get_lang('config', 'password_encrypt_key_note'),
 | 
			
		||||
			'label_proxy' => psm_get_lang('config', 'proxy'),
 | 
			
		||||
			'label_proxy_url' => psm_get_lang('config', 'proxy_url'),
 | 
			
		||||
			'label_proxy_user' => psm_get_lang('config', 'proxy_user'),
 | 
			
		||||
			'label_proxy_password' => psm_get_lang('config', 'proxy_password'),
 | 
			
		||||
			'label_email_status' => psm_get_lang('config', 'email_status'),
 | 
			
		||||
			'label_email_from_email' => psm_get_lang('config', 'email_from_email'),
 | 
			
		||||
			'label_email_from_name' => psm_get_lang('config', 'email_from_name'),
 | 
			
		||||
| 
						 | 
				
			
			@ -346,6 +355,8 @@ class ConfigController extends AbstractController {
 | 
			
		|||
			'label_log_email' => psm_get_lang('config', 'log_email'),
 | 
			
		||||
			'label_log_sms' => psm_get_lang('config', 'log_sms'),
 | 
			
		||||
			'label_log_pushover' => psm_get_lang('config', 'log_pushover'),
 | 
			
		||||
			'label_alert_proxy' => psm_get_lang('config', 'alert_proxy'),
 | 
			
		||||
			'label_alert_proxy_url' => psm_get_lang('config', 'alert_proxy_url'),
 | 
			
		||||
			'label_auto_refresh' => psm_get_lang('config', 'auto_refresh'),
 | 
			
		||||
			'label_auto_refresh_servers' => psm_get_lang('config', 'auto_refresh_servers'),
 | 
			
		||||
			'label_seconds' => psm_get_lang('config', 'seconds'),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -130,6 +130,10 @@ class Installer {
 | 
			
		|||
		$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "users_servers` (`user_id`,`server_id`) VALUES (1, 1), (1, 2);";
 | 
			
		||||
		$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE
 | 
			
		||||
					('language', 'en_US'),
 | 
			
		||||
					('proxy', '0'),
 | 
			
		||||
					('proxy_url', ''),
 | 
			
		||||
					('proxy_user', ''),
 | 
			
		||||
					('proxy_password', ''),
 | 
			
		||||
					('email_status', '1'),
 | 
			
		||||
					('email_from_email', 'monitor@example.org'),
 | 
			
		||||
					('email_from_name', 'Server Monitor'),
 | 
			
		||||
| 
						 | 
				
			
			@ -442,6 +446,11 @@ class Installer {
 | 
			
		|||
		psm_update_conf('password_encrypt_key', sha1(microtime()));
 | 
			
		||||
		$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` CHANGE `ip` `ip` VARCHAR(500) NOT NULL;";
 | 
			
		||||
		$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "servers` ADD `website_username` varchar(255) NULL, ADD `website_password` varchar(255) NULL AFTER `website_username`;";
 | 
			
		||||
		$queries[] = "INSERT INTO `" . PSM_DB_PREFIX . "config` (`key`, `value`) VALUE
 | 
			
		||||
					('proxy', '0'),
 | 
			
		||||
					('proxy_url', ''),
 | 
			
		||||
					('proxy_user', ''),
 | 
			
		||||
					('proxy_password', '');";
 | 
			
		||||
 | 
			
		||||
		$this->execSQL($queries);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,6 +69,32 @@
 | 
			
		|||
					<input type="text" class="input-mini" id="log_retention_period" name="log_retention_period" value="{{ log_retention_period }}" data-toggle="tooltip" title="{{ label_log_retention_period_description }}" /> {{ label_log_retention_days }}
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <legend>{{ label_settings_proxy }}</legend>
 | 
			
		||||
            <div class="control-group">
 | 
			
		||||
                <div class="controls">
 | 
			
		||||
                    <label class="checkbox" for="proxy"><input type="checkbox" id="proxy" name="proxy[]" {{ proxy_checked|raw }} />{{ label_proxy }}</label>
 | 
			
		||||
                    <p class="help-block">{{ label_alert_proxy|raw }}</p>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="control-group">
 | 
			
		||||
                <label class="control-label" for="proxy_url">{{ label_proxy_url }}</label>
 | 
			
		||||
                <div class="controls">
 | 
			
		||||
                    <input type="text" id="proxy_url" name="proxy_url" value="{{ proxy_url }}" maxlength="100" placeholder="{{ label_proxy_url }}" />
 | 
			
		||||
                    <p class="help-block">{{ label_alert_proxy_url|raw }}</p>
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="control-group">
 | 
			
		||||
                <label class="control-label" for="proxy_user">{{ label_proxy_user }}</label>
 | 
			
		||||
                <div class="controls">
 | 
			
		||||
                    <input type="text" id="proxy_user" name="proxy_user" value="{{ proxy_user }}" maxlength="100" placeholder="{{ label_proxy_user }}" />
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="control-group">
 | 
			
		||||
                <label class="control-label" for="proxy_password">{{ label_proxy_password }}</label>
 | 
			
		||||
                <div class="controls">
 | 
			
		||||
                    <input type="password" id="proxy_password" name="proxy_password" value="{{ proxy_password }}" maxlength="100" placeholder="{{ label_proxy_password }}" />
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="form-actions">
 | 
			
		||||
                <button class="btn btn-success" type="submit" name="general_submit">{{ label_save }}</button>
 | 
			
		||||
            </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue