source: trunk/www.guidonia.net/wp/wp-content/plugins/parteibuch-aggregator/pba-admin-options.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 15 years ago
File size: 17.7 KB
RevLine 
[44]1<?php
2
3if ($user_level < 6) die ( __('Cheatin&#8217; uh?') );
4
5global $bdprss_db;
6$result = $bdprss_db->get_all_options();
7
8//initialisation
9$pba_enable_caching="auto";
10$pba_enable_rewriting="Y";
11$pba_full_cache_time=60;
12$pba_kalenderquery_cache_time=7200;
13$pba_feedlistquery_cache_time=3600;
14$pba_options_enable_loaddetection="auto";
15$pba_highloadthreshold="3";
16
17if(!$result ) {
18 echo "<p><b>Unexpected error:</b> could not find feed $rss, or it differed from $cidentifier</p>\n";
19} else {
20 foreach($result as $key => $r){
21 if($r->name == 'enable_caching') $pba_enable_caching=$r->value;
22 if($r->name == 'enable_rewriting') $pba_enable_rewriting=$r->value;
23 if($r->name == 'full_cache_time') $pba_full_cache_time=$r->value;
24 if($r->name == 'kalenderquery_cache_time') $pba_kalenderquery_cache_time=$r->value;
25 if($r->name == 'feedlistquery_cache_time') $pba_feedlistquery_cache_time=$r->value;
26 if($r->name == 'enable_loaddetection') $pba_options_enable_loaddetection=$r->value;
27 if($r->name == 'highloadthreshold') $pba_highloadthreshold=$r->value;
28 }
29
30// print_r($result);
31// echo $pba_enable_caching;
32
33 echo '<h2>Edit some global options of the <a href="edit.php?page=parteibuch-aggregator/bdp-rssadmin.php">Parteibuch Aggregator</a> plugin</h2>';
34?>
35
36
37<fieldset>
38
39<form method="post" action="<?php echo $selfreference; ?>">
40
41 <table width="100%" cellspacing="2" cellpadding="5">
42
43<tr valign="top">
44 <td align="left" colspan="3"><h3>Caching</h3>
45
46 Info: Sensible caching can speed up the Parteibuch Aggregator and reduce the server load<br><br>
47
48 <?php
49 if($bdprss_db->serverstatus['pbacache']['status'] != 'ok') echo '(<b>Attention</b>: Caching can only work, if your cache directory ' . PBA_CACHE_PATH . ' is writable for your webserver. You may do this with your ftp client by setting permissions of the cache directory to read, write, execute for all, ie "chmod 777 pbacache")<br/>';
50 echo '<br/>';
51 ?>
52 </td>
53</tr>
54<tr valign="top">
55 <td width="25%">
56 Enable Caching?
57 <br />&nbsp;<br />&nbsp;<br />
58 </td>
59 <td width="25%">
60<select name="pba_options_enable_caching">
61<?php
62$namedescarray=array('Y' => 'Yes', 'N' => 'No', 'auto' => 'Automatic&nbsp;&nbsp;');
63foreach($namedescarray as $key => $value){
64$selected="";
65if($pba_enable_caching == $key ) $selected = ' selected';
66 echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
67}
68echo '</select></td><td width="50%" align="left">';
69$boldcacheinfo=array('','');
70if($bdprss_db->serverstatus['pbacache']['status'] == 'unusable') $boldcacheinfo=array("<b>","</b>");
71echo $boldcacheinfo[0] . "Memory info for 'pbacache': " . $bdprss_db->serverstatus['pbacache']['status'] . ", Notice: " . $bdprss_db->serverstatus['pbacache']['notice'] . $boldcacheinfo[1];
72
73?>
74
75</td></tr>
76
77<tr valign="top">
78 <td>
79 Cache time for main loop
80 <br />&nbsp;<br />&nbsp;<br />
81 </td>
82 <td>
83 <input type="text" name="pba_full_cache_time" value="<?php echo $pba_full_cache_time; ?>" size="10" />
84 <br/>(In seconds)<br/>
85<?php echo '</td><td align="left">';
86if(isset($bdprss_db->serverstatus['full_cache_time']['status'])){
87 echo "Memory info for 'full_cache_time': " . $bdprss_db->serverstatus['full_cache_time']['status'] . ", Notice: " . $bdprss_db->serverstatus['full_cache_time']['notice'] . '<br />';
88}
89?>
90This cache is a file cache around the whole output workhorse routine. Zero (0) will disable this cache. Default value is 60 seconds.
91</td></tr>
92
93<tr valign="top">
94 <td>
95 Cache time for calendar query
96 <br />&nbsp;<br />&nbsp;<br />
97 </td>
98 <td>
99 <input type="text" name="pba_kalenderquery_cache_time" value="<?php echo $pba_kalenderquery_cache_time; ?>" size="10" />
100 <br/>(In seconds)<br/>
101<?php echo '</td><td align="left">';
102if(isset($bdprss_db->serverstatus['kalenderquery_cache_time']['status'])){
103 echo "Memory info for 'kalenderquery_cache_time': " . $bdprss_db->serverstatus['kalenderquery_cache_time']['status'] . ", Notice: " . $bdprss_db->serverstatus['kalenderquery_cache_time']['notice'] . '<br />';
104}
105?>
106This cache is a file cache around the query to build calendars. Zero (0) will disable this cache. Default value is 7200 seconds.
107</td></tr>
108
109<tr valign="top">
110 <td>
111 Cache time for the feedlist query
112 <br />&nbsp;<br />&nbsp;<br />
113 </td>
114 <td>
115 <input type="text" name="pba_feedlistquery_cache_time" value="<?php echo $pba_feedlistquery_cache_time; ?>" size="10" />
116 <br/>(In seconds)<br/>
117<?php echo '</td><td align="left">';
118if(isset($bdprss_db->serverstatus['feedlistquery_cache_time']['status'])){
119 echo "Memory info for 'feedlistquery_cache_time': " . $bdprss_db->serverstatus['feedlistquery_cache_time']['status'] . ", Notice: " . $bdprss_db->serverstatus['feedlistquery_cache_time']['notice'] . '<br />';
120}
121?>
122This cache is a file cache around the query to build feedlists. Zero (0) will disable this cache. Default value is 3600 seconds.
123</td></tr>
124
125<tr valign="top">
126 <td >
127 Clear the cache now?
128 </td>
129 <td>
130 <input type="checkbox" name="pba_clear_cache_now"
131 value="Y" >
132 </td><td>Checking this box will completely clean your Parteibuch Aggregator cache. If you clear your cache and you have a lot of files cached, please be patient, it may take a while
133 </td>
134</tr>
135
136
137
138<tr valign="top">
139 <td align="left" colspan="3"><h3>Permalinks</h3>
140 Rewritten permalinks are a popular feature of wordpress. They make URIs of the blog look like http://_mydomain_/_aboutme_/ instead of http://_mydomain_/index.php?pagename=_pagename_ If you like, the Parteibuch Aggregator can hook into the permalink structure of wordpress and generate similar rewritten permalinks for the pages delivered by the Parteibuch Aggregator<br><br>
141 (<b>Attention</b>: You need to <a target="_blank" title="Opens in new window: refresh the permalinks of your blog" href="options-permalink.php">refresh your permalinks</a> after changing this option, if you don't do this, the change will have no effect. You don't have to change your blog's rewrite options, ie just hit the button to "save changes" there, just hit the button to "save changes" and that's it.)<br/><br/>
142 </td>
143</tr>
144
145<tr valign="top">
146 <th scope="row">
147 Enable Permalinks?
148 <br />&nbsp;<br />&nbsp;<br />
149 </th>
150 <td>
151<select name="pba_options_link_rewriting">
152<?php
153
154$namedescarray=array('Y' => 'Yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'N' => 'No');
155foreach($namedescarray as $key => $value){
156$selected="";
157if($pba_enable_rewriting == $key ) $selected = ' selected';
158 echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
159}
160echo '</select>
161</td><td align="left">';
162
163echo "Memory info for 'rewriting': " . $bdprss_db->serverstatus['rewriting']['status'] . ", Notice: " . $bdprss_db->serverstatus['rewriting']['notice'] . "<br />";
164
165 $rewrite_array=get_option('rewrite_rules');
166 if(!is_array($rewrite_array)) {
167 echo 'This blog has not enabled permalinks. To use permalink rewriting feature of the Parteibuch Aggregator you have to <a target="_blank" title="Opens in new window: enable permalinks for your blog" href="options-permalink.php">enable permalinks for your blog</a>.';
168 }elseif(count($rewrite_array) == 0){
169 echo 'Either your blog doesn&#39;t use permalinks or we can&#39;t detect them. Parteibuch Aggregator recommends therefore to <a target="_blank" title="Opens in new window: refresh permalinks of your blog" href="options-permalink.php">refresh your permalinks</a>.';
170 }elseif(count($rewrite_array) > 0){
171 $rulematch=false;
172 foreach($rewrite_array as $key => $value){
173 if(strstr($key,'ticker-feed')) $rulematch=true;
174 }
175 if(!$rulematch && $pba_enable_rewriting != 'N') {
176 echo 'Though enabled, the Parteibuch Aggregator permalinks seem not to be in effect. Parteibuch Aggregator recommends therefore to <a target="_blank" title="Opens in new window: refresh permalinks of your blog" href="options-permalink.php">refresh your permalinks</a>.';
177 }elseif(!$rulematch && $pba_enable_rewriting == 'N') {
178 echo 'Enable the permalink rewriting feature of the Parteibuch Aggregator to make the Aggregator URLs look like /page/2/ instead of ?tickerpage=2';
179 }elseif($rulematch && $pba_enable_rewriting != 'N') {
180 echo 'Fine. Permalink rewriting feature of Parteibuch Aggregator is enabled and shall be working.';
181 }elseif($rulematch && $pba_enable_rewriting == 'N'){
182 echo 'Though disabled, there seem to be still Parteibuch Aggregator rules enabled in your blog. Parteibuch Aggregator recommends therefore to <a target="_blank" title="Opens in new window: refresh permalinks of your blog" href="options-permalink.php">refresh your permalinks</a>.';
183 }
184 }
185
186//echo "The rules are: " . str_replace("\n",'<br>',PBALIB::get_r(get_option('rewrite_rules')));
187
188?> </td></tr>
189
190<tr valign="top">
191 <td align="left" colspan="3"><h3>Memory tables</h3>
192 MySQL is able to write <a target="_blank" title="Opens in new window: MySQL 5.0 documentation for memory tables" href="http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html">tables into memory</a>. Having index tables in memory will speed up large databases a lot. Disadvatage is, that these memory tables will occupy memory permanently, even if nobody accesses the site and that they need to be refilled always when MySQL is restarted. Parteibuch Aggregator is designed to use memory tables. However, it is possible to turn off this feature.<br><br>
193 </td>
194</tr>
195
196<tr valign="top">
197 <td>
198 Enable memory tables?
199 <br />&nbsp;<br />&nbsp;<br />
200 </td>
201 <td>
202<select name="pba_options_enable_memtables">
203<?php
204$oldvaluetmp=$bdprss_db->pbaoption('enable_memtables');
205if($oldvaluetmp == 'Y'){
206 $old_pba_options_enable_memtables ='Y';
207}elseif($oldvaluetmp == 'N') {
208 $old_pba_options_enable_memtables ='N';
209}elseif($oldvaluetmp == 'auto') {
210 $old_pba_options_enable_memtables ='auto';
211}else{
212 $old_pba_options_enable_memtables ='undefined';
213}
214
215$namedescarray=array('Y' => 'Yes', 'N' => 'No', 'auto' => 'Automatic&nbsp;&nbsp;');
216foreach($namedescarray as $key => $value){
217$selected="";
218if($old_pba_options_enable_memtables == $key ) $selected = ' selected';
219 echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
220}
221echo '</select>';
222echo '<input type="hidden" name="old_pba_options_enable_memtables" value="' . $old_pba_options_enable_memtables . '" />';
223echo '</td><td align="left">';
224
225echo "Information from server: ";
226
227$pba_max_heap_table_size=$bdprss_db->get_mysql_variables('max_heap_table_size');
228if($pba_max_heap_table_size != "") echo "This MySQL Server allows a maximum size of " . $pba_max_heap_table_size . " bytes for memory tables. ";
229
230$pba_memtables_array=array('mtablestatus' => $bdprss_db->mtablestatus, 'mitemtable' => $bdprss_db->mitemtable, 'msitetable' => $bdprss_db->msitetable);
231
232foreach($pba_memtables_array as $pba_shorttablename => $pba_tablenameindb){
233 $pba_not_tmp='not ';
234 if($bdprss_db->detect_memtable($pba_tablenameindb)) {
235 $pba_not_tmp = '';
236 }
237 $pba_table_status_row_object=$bdprss_db->get_mysql_tablestatus($pba_tablenameindb);
238
239 //echo "The pba_table_status_row_object: " . str_replace("\n",'<br>',PBALIB::get_r($pba_table_status_row_object));
240 $pba_table_size='Something strange happens. Parteibuch Aggregator cannot retrieve status information for table '.$pba_tablenameindb.'.';
241 if(is_object($pba_table_status_row_object)){
242 $pba_table_size= 'Size is ' . ($pba_table_status_row_object->Data_length + $pba_table_status_row_object->Index_length) . ' bytes. ';
243 }
244 echo 'Table '.$pba_shorttablename.' is '.$pba_not_tmp.'a memory table. ' . $pba_table_size;
245}
246
247?>
248
249</td></tr>
250
251<tr valign="top">
252 <td align="left" colspan="3"><h3>Uninstaller</h3>
253 By default, the Parteibuch Aggregator will keep it's data and configuration settings, when you disable the plugin.
254 This has the advantage, that you can re-enable the Aggregator plugin and you will not have lost your data.
255 However, if you want to completely remove the Parteibuch Aggregator and all it's data and all the configuration settings,
256 you shall check the checkbox below before deactivation of the Parteibuch Aggregator plugin.<br><br>
257 </td>
258</tr>
259
260<tr valign="top">
261 <td >
262 Delete all data on plugin deactivation?
263 </td>
264 <td>
265 <input type="checkbox" name="pba_delete_alldata"
266 value="Y" >
267 </td><td>Checking this box will delete all the data of the Parteibuch Aggregator, when you deactivate the Parteibuch Aggregator plugin. <b>There is no way back</b>. If you use Parteibuch Aggregator widgets, remove the widgets before deactivation from your sidebar. If you use the rewritten URL feature, flush your permalinks after plugin deactivation.
268 </td>
269</tr>
270
271<tr valign="top">
272 <td align="left" colspan="3"><h3>Server load detection</h3>
273 The Parteibuch Aggregator can try to detect the serverload with sys_getloadavg or as the first load average figure from the output of a Unix system call to <a target='_blank' title='Opens in new window: Find articles about uptime via Google' href='http://www.google.com/search?q=uptime+command+UNIX'>uptime</a> and decide on that basis, if it is a good time to do some resource intensive housekeeping jobs or if they better should be processed at a later time.<br><br>
274 </td>
275</tr>
276
277<tr valign="top">
278 <td>
279 Enable load detection?
280 <br />&nbsp;<br />&nbsp;<br />
281 </td>
282 <td>
283<select name="pba_options_enable_loaddetection">
284<?php
285$namedescarray=array('Y' => 'Yes', 'N' => 'No', 'auto' => 'Automatic&nbsp;&nbsp;');
286foreach($namedescarray as $key => $value){
287$selected="";
288if($pba_options_enable_loaddetection == $key ) $selected = ' selected';
289 echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
290}
291echo '</select></td><td align="left">';
292
293echo "Info from server: ";
294if(function_exists('sys_getloadavg')) {
295 $load=sys_getloadavg();
296 $pbaload=$load[0];
297 echo "Fine. Your php has a function sys_getloadavg, so we have no problems to get server load data.";
298}elseif(ini_get('safe_mode')){
299 echo 'The <a target="_blank" title="Opens in new window: See php manual: safe_mode" href="http://php.net/features.safe-mode">safe_mode feature</a> of PHP is enabled on your server. ';
300 if(ini_get('safe_mode_exec_dir') == ""){
301 echo ' No safe_mode_exec_dir is set, if you want to use the load detection feature of the Parteibuch Aggregator, your server administrator has to disable safe_mode or set a safe_mode_exec_dir.';
302 $pbaload=0;
303 }else{
304 $pbaload=$bdprss_db->pba_loaddetection();
305 if($pbaload>0) echo 'Using safe_mode uptime wrapper script. ';
306 if($pbaload==0) echo ' PHP safe_mode_exec_dir is set to ' . ini_get('safe_mode_exec_dir') . '. ' .
307 " Parteibuch Aggregator doesn't get back a sensible value from uptime_wrapper.sh.
308 If you want to use the Parteibuch Aggregator load detection feature then make sure you copy uptime_wrapper.sh into your safe_mode_exec_dir, that it is readable and
309 executable for your php environment and that it produces an ouput like a standard unix call
310 to uptime. Make sure that paths in the wrapper script fit to your server and <a target='_blank' title='Opens in new window: See newline article in Wikipedia' href='http://en.wikipedia.org/wiki/Newline'>newline</a> line breaks
311 in the script are Unix like.";
312 }
313}else{
314 //no safe mode
315 $pbaload=$bdprss_db->pba_loaddetection();
316 if($pbaload == 0) echo ' The Parteibuch Aggregator cannot detect a server load.
317 If you want to use the Parteibuch Aggregator load detection feature then you may try to
318 modify the script uptime_wrapper.sh in directory "'.dirname(__FILE__) . '/wrapper/'. '",
319 so that there will be produced output as like from a uptime unix system command.' .
320 " Make sure that the script is readable and executable for your php environment and
321 that paths in the wrapper script fit to your server and
322 <a target='_blank' title='Opens in new window: See newline article in Wikipedia' href='http://en.wikipedia.org/wiki/Newline'>newline</a>
323 line breaks in the script are Unix like.";
324}
325
326if($pbaload > 0) echo ' Server load we got from your system is at this moment: ' . $pbaload . '. ';
327if(isset($bdprss_db->serverstatus['loaddetection']['notice'])){
328 echo " Memory notice for 'loaddetection': Notice: " . $bdprss_db->serverstatus['loaddetection']['notice']. '. ';
329}
330echo " Memory notice for 'pbaload': Notice: " . $bdprss_db->serverstatus['pbaload']['notice']. '. ';
331if(isset($bdprss_db->serverstatus['highloadthreshold']['notice'])){
332 echo " Memory notice for 'highloadthreshold': Notice: " . $bdprss_db->serverstatus['highloadthreshold']['notice']. '. ';
333}
334?>
335
336<br /><br /><br /><br /></td></tr>
337
338<?php if($pbaload > 0){
339 //we will hide this configuration row, if we cannot detect a load
340?>
341
342<tr valign="top">
343 <td>
344 Define a high load threshold
345 <br />&nbsp;<br />&nbsp;<br />
346 </td>
347 <td>
348<select name="pba_highloadthreshold">
349<?php
350$namedescarray=array('1' => '&nbsp;&nbsp;1&nbsp;&nbsp;',
351 '2' => '&nbsp;&nbsp;2&nbsp;&nbsp;',
352 '3' => '&nbsp;&nbsp;3&nbsp;&nbsp;',
353 '4' => '&nbsp;&nbsp;4&nbsp;&nbsp;',
354 '5' => '&nbsp;&nbsp;5&nbsp;&nbsp;',
355 '10' => '&nbsp;&nbsp;10&nbsp;&nbsp;',
356 '20' => '&nbsp;&nbsp;20&nbsp;&nbsp;');
357
358foreach($namedescarray as $key => $value){
359$selected="";
360if($pba_highloadthreshold == $key ) $selected = ' selected';
361 echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
362}
363echo '</select></td><td align="left">';
364
365echo "If server load detection is enabled, the high load threshold tells the Parteibuch Aggregator, above what server load value housekeeping jobs shall be deferred. Please tell the Parteibuch Aggregator above what uptime load average value the Parteibuch Aggregator shall run in high serverload mode. Default is a highload threshold value of 3. ";
366
367echo "</td></tr>";
368
369} //end conditional row if pbaload > 0
370
371?>
372
373 <tr valign="top">
374 <td colspan="3" align="right"><br><br>
375 <a href="edit.php?page=parteibuch-aggregator/bdp-rssadmin.php">All fine</a>&nbsp;(exit this page without saving any changes) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="pba_edit_options_button" value="Save configuration &raquo;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
376 </td>
377 </tr>
378
379 </table>
380
381<?php
382}
383?>
384</form>
385</fieldset>
Note: See TracBrowser for help on using the repository browser.