| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')){ |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
function softaculous_page_settings($title = 'Softaculous Dashboard'){ |
| 8 |
global $softaculous_lang, $softaculous_error, $softaculous_msg; |
| 9 |
|
| 10 |
softaculous_admin_notice(1); |
| 11 |
|
| 12 |
if(!empty($softaculous_error)){ |
| 13 |
echo '<div id="message" class="error"><p>'.esc_html($softaculous_error).'</p></div>'; |
| 14 |
} |
| 15 |
|
| 16 |
if(!empty($softaculous_msg)){ |
| 17 |
echo '<div id="message" class="updated"><p>'.esc_html($softaculous_msg).'</p></div>'; |
| 18 |
} |
| 19 |
echo '<div style="margin: 10px 20px 0 2px;"> |
| 20 |
<div class="metabox-holder columns-2"> |
| 21 |
<div class="postbox-container"> |
| 22 |
<div class="wrap"> |
| 23 |
<h1><!--This is to fix promo--></h1> |
| 24 |
<table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0"> |
| 25 |
<tr> |
| 26 |
<td valign="top"><h1>'.esc_html($title).'</h1> |
| 27 |
</td> |
| 28 |
<td align="right" width="40"><a target="_blank" href="https://twitter.com/softaculous"><img src="'.esc_attr(SOFTACULOUS_PLUGIN_URL).'assets/images/twitter.png" /></a></td> |
| 29 |
<td align="right" width="40"><a target="_blank" href="https://www.facebook.com/softaculous"><img src="'.esc_attr(SOFTACULOUS_PLUGIN_URL).'assets/images/facebook.png" /></a></td> |
| 30 |
</tr> |
| 31 |
</table> |
| 32 |
<hr/> |
| 33 |
<br/> |
| 34 |
<div class="postbox"> |
| 35 |
<div class="postbox-header"> |
| 36 |
<h2 class="hndle ui-sortable-handle"> |
| 37 |
<span>'.esc_html__('General Settings', 'softaculous').'</span> |
| 38 |
</h2> |
| 39 |
</div> |
| 40 |
<div class="inside"> |
| 41 |
<!--Main Table--> |
| 42 |
<table cellpadding="8" cellspacing="1" width="100%" class="form-table"> |
| 43 |
<form action="" method="post"> |
| 44 |
<tr> |
| 45 |
<th valign="top"><label for="soft_conn_key">'.esc_html__('Softaculous Connection Key', 'softaculous').'</label></th> |
| 46 |
<td> |
| 47 |
<input type="text" name="softaculous_conn_key" id="soft_conn_key" value="'.esc_attr(softaculous_get_connection_key()).'" size="60" readonly> |
| 48 |
<input type="submit" name="reset_conn_key" class="button button-primary action" value="'.esc_html__('Reset Key', 'softaculous').'" > |
| 49 |
</td> |
| 50 |
</tr> |
| 51 |
<tr> |
| 52 |
<th valign="top"><label for="soft_allowed_ips">'.esc_html__('Allowed IP(s)', 'softaculous').'</label></th> |
| 53 |
<td> |
| 54 |
<input type="text" name="softaculous_allowed_ips" id="soft_allowed_ips" value="'.(isset($_POST['softaculous_allowed_ips']) ? esc_html(sanitize_text_field($_POST['softaculous_allowed_ips'])) : esc_attr(implode(',' , softaculous_get_allowed_ips()))).'"><br /> |
| 55 |
<span>'.esc_html__('Please enter comma separated IP address(s) of panels which will be allowed to make API calls', 'softaculous').'</span> |
| 56 |
<br/> |
| 57 |
</br/> |
| 58 |
<input type="submit" name="softaculous_save" class="button button-primary action" value="'.esc_html__('Save Settings', 'softaculous').'" > |
| 59 |
</td> |
| 60 |
</tr> |
| 61 |
'.wp_nonce_field('softaculous-options').' |
| 62 |
</form> |
| 63 |
</table> |
| 64 |
</div> |
| 65 |
</div> |
| 66 |
|
| 67 |
<br/> |
| 68 |
<br/> |
| 69 |
<div style="width:45%;background:#FFF;padding:15px; margin:auto"> |
| 70 |
<b>'.esc_html__('Let your followers know that you are managing WordPress websites like a Pro using Softaculous', 'softaculous').' :</b> |
| 71 |
<form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);"> |
| 72 |
<textarea name="text" cols="45" row="3" style="resize:none;">'.esc_html__('I easily manage my #WordPress #site using @softaculous', 'softaculous').'</textarea> |
| 73 |
<input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/> |
| 74 |
</form> |
| 75 |
|
| 76 |
</div> |
| 77 |
<br /> |
| 78 |
<hr /> |
| 79 |
<a href="'.esc_attr(SOFTACULOUS_WWW_URL).'" target="_blank">Softaculous</a> v'.esc_attr(SOFTACULOUS_VERSION).' You can report any bugs <a href="https://wordpress.org/plugins/softaculous/" target="_blank">here</a>. |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
</div> |
| 83 |
</div>'; |
| 84 |
} |
| 85 |
|
| 86 |
if(isset($_POST['reset_conn_key'])){ |
| 87 |
|
| 88 |
global $softaculous_lang, $softaculous_error, $softaculous_msg; |
| 89 |
|
| 90 |
/* Make sure post was from this page */ |
| 91 |
check_admin_referer('softaculous-options'); |
| 92 |
|
| 93 |
if(!current_user_can('manage_options')){ |
| 94 |
wp_die('Sorry, but you do not have permissions to reset connection key.'); |
| 95 |
} |
| 96 |
|
| 97 |
softaculous_get_connection_key(1); |
| 98 |
|
| 99 |
if(empty($softaculous_error)){ |
| 100 |
$softaculous_msg = __('Connection key reset successfully', 'softaculous'); |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
if(isset($_POST['softaculous_save'])){ |
| 105 |
global $softaculous_lang, $softaculous_error, $softaculous_msg; |
| 106 |
|
| 107 |
/* Make sure post was from this page */ |
| 108 |
check_admin_referer('softaculous-options'); |
| 109 |
|
| 110 |
if(!current_user_can('manage_options')){ |
| 111 |
wp_die('Sorry, but you do not have permissions to save settings.'); |
| 112 |
} |
| 113 |
|
| 114 |
if(isset($_REQUEST['softaculous_allowed_ips'])){ |
| 115 |
|
| 116 |
$_allowed_ips = array(); |
| 117 |
|
| 118 |
$allowed_ips = softaculous_optPOST('softaculous_allowed_ips'); |
| 119 |
$_a_ips = explode(',', $allowed_ips); |
| 120 |
|
| 121 |
foreach($_a_ips as $aip){ |
| 122 |
$aip = trim($aip); |
| 123 |
if(empty($aip)){ |
| 124 |
continue; |
| 125 |
} |
| 126 |
|
| 127 |
if(!softaculous_valid_ip($aip)){ |
| 128 |
$softaculous_error = __('Please enter valid IP(s)', 'softaculous'); |
| 129 |
continue; |
| 130 |
} |
| 131 |
|
| 132 |
$_allowed_ips[] = $aip; |
| 133 |
} |
| 134 |
|
| 135 |
if(empty($_allowed_ips)){ |
| 136 |
$softaculous_error = $softaculous_lang['empty_allowed_ips']; |
| 137 |
} |
| 138 |
|
| 139 |
if(empty($softaculous_error)){ |
| 140 |
update_option('softaculous_allowed_ips', $_allowed_ips); |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
if(empty($softaculous_error)){ |
| 145 |
$softaculous_msg = __('Settings saved successfully', 'softaculous'); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
softaculous_page_settings(); |
| 150 |
|