Changeset 1058
- Timestamp:
- 12/05/05 02:57:08 (3 years ago)
- Location:
- trunk/rss
- Files:
-
- 5 modified
-
admin/config.php (modified) (2 diffs)
-
admin/index.php (modified) (4 diffs)
-
admin/plugins.php (modified) (10 diffs)
-
config.php (modified) (1 diff)
-
intl/en.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rss/admin/config.php
r1035 r1058 40 40 ."</tr>\n"; 41 41 42 $sql = "select * from " .getTable("config") ." order by key_ asc"; 42 $sql = "select * from " .getTable("config") ." where key_ like 43 'rss.%' order by key_ asc"; 43 44 44 45 $res = rss_query($sql); … … 47 48 $value = real_strip_slashes($row['value_']); 48 49 $class_ = (($cntr++ % 2 == 0)?"even":"odd"); 49 50 50 51 // Fix for #279. Plugins have their own section. 51 52 if ($row['key_'] == 'rss.config.plugins') { 52 continue;53 continue; 53 54 } 54 55 -
trunk/rss/admin/index.php
r1051 r1058 63 63 define ('CST_ADMIN_DOMAIN_OPML','opml'); 64 64 define ('CST_ADMIN_DOMAIN_PLUGINS','plugins'); 65 define ('CST_ADMIN_DOMAIN_PLUGIN_OPTIONS','plugin_options'); 65 66 66 67 // OPML import target … … 112 113 113 114 echo "\n<div id=\"channel_admin\" class=\"frame\">"; 114 115 115 if ($authorised) { 116 116 admin_menu(); … … 132 132 $show = plugins_admin(); 133 133 break; 134 case CST_ADMIN_DOMAIN_PLUGIN_OPTIONS: 135 $show = plugin_options_admin(); 136 break; 134 137 default: 135 138 break; … … 167 170 case CST_ADMIN_DOMAIN_PLUGINS: 168 171 plugins(); 172 break; 173 case CST_ADMIN_DOMAIN_PLUGIN_OPTIONS: 174 plugin_options(); 169 175 break; 170 176 default: -
trunk/rss/admin/plugins.php
r1045 r1058 1 1 <?php 2 2 3 3 4 function plugins_admin() { … … 5 6 } 6 7 8 function plugin_options_admin() { 9 if (array_key_exists('plugin_name',$_REQUEST)) { 10 return CST_ADMIN_DOMAIN_PLUGIN_OPTIONS; 11 } else { 12 return CST_ADMIN_DOMAIN_PLUGINS; 13 } 14 } 7 15 8 16 function plugins() { 9 17 10 // Submit changes18 // Submit changes 11 19 if (isset($_POST['admin_plugin_submit_changes'])) { 12 20 $active_plugins=array(); … … 23 31 } 24 32 25 26 // Check for updates 33 // Check for updates 27 34 $doUpdates = false; 28 35 $updates = array(); … … 34 41 35 42 36 // Rendering43 // Rendering 37 44 echo "<h2 class=\"trigger\">".LBL_ADMIN_PLUGINS."</h2>\n" 38 45 ."<div id=\"admin_plugins\">\n"; 39 46 40 47 41 echo LBL_ADMIN_PLUGINS_GET_MORE;48 echo LBL_ADMIN_PLUGINS_GET_MORE; 42 49 43 50 echo "<form method=\"post\" action=\"" .$_SERVER['PHP_SELF'] ."\">\n"; … … 48 55 ."<th>".LBL_ADMIN_PLUGINS_HEADING_VERSION."</th>\n" 49 56 ."<th>".LBL_ADMIN_PLUGINS_HEADING_AUTHOR."</th>\n" 50 ."<th>".LBL_ADMIN_PLUGINS_HEADING_DESCRIPTION."</th>\n"; 57 ."<th>".LBL_ADMIN_PLUGINS_HEADING_DESCRIPTION."</th>\n" 58 ."<th>".LBL_ADMIN_PLUGINS_HEADING_OPTIONS."</th>\n"; 51 59 if ($doUpdates) { 52 60 echo "<th>".LBL_ADMIN_PLUGINS_HEADING_UPDATES."</th>\n"; … … 63 71 $active= in_array($entry,$active_plugins); 64 72 if (count($info)) { 65 66 67 73 $updateDl = null; 68 74 if (is_array($updates) && array_key_exists($info['file'],$updates)) { … … 83 89 .($active?"checked=\"checked\"":"")." />\n" 84 90 ."</td>\n"; 85 echo "<td><label for=\"_gregarius_plugin_$entry\">".(array_key_exists('name',$info)?$info['name']:" "). "</label></td>\n"; 86 echo "<td class=\"cntr\">" .(array_key_exists('version',$info)?$info['version']:" "). "</td>\n"; 91 echo "<td><label 92 for=\"_gregarius_plugin_$entry\">".(array_key_exists('name',$info)?$info['name']:" "). 93 "</label></td>\n"; 94 echo "<td class=\"cntr\">" 95 .(array_key_exists('version',$info)?$info['version']:" "). "</td>\n"; 87 96 echo "<td>" .(array_key_exists('author',$info)?$info['author']:" "). "</td>\n"; 88 97 echo "<td>" .(array_key_exists('description',$info)?$info['description']:" "). "</td>\n"; 98 99 // output the column to call a plugin's config page. 100 echo "<td>"; 101 if(array_key_exists('configuration',$info)) { 102 $escaped_plugin_name = str_replace("/", "%2F", $entry); 103 echo "<a href=\"".$_SERVER['PHP_SELF']. "?".CST_ADMIN_DOMAIN."=". 104 CST_ADMIN_DOMAIN_PLUGIN_OPTIONS 105 ."&action=". CST_ADMIN_EDIT_ACTION. "&plugin_name=".$escaped_plugin_name."\">" . LBL_ADMIN_EDIT 106 ."</a>"; 107 } else { 108 echo " "; 109 } 110 echo "</td>\n"; 89 111 90 112 if ($doUpdates && $updateDl) { … … 92 114 echo "<a href=\"$updateDl\">$lastV</a>"; 93 115 echo "</td>"; 94 } elseif($doUpdates) { 116 } 117 elseif($doUpdates) { 95 118 echo "<td> </td>"; 96 119 } … … 101 124 echo "</table>\n"; 102 125 echo "<p><input type=\"hidden\" name=\"". CST_ADMIN_METAACTION ."\" value=\"LBL_ADMIN_SUBMIT_CHANGES\"/>\n"; 103 echo "<input type=\"submit\" name=\"admin_plugin_submit_changes\" value=\"".LBL_ADMIN_SUBMIT_CHANGES."\" />\n"; 126 echo "<input type=\"submit\" name=\"admin_plugin_submit_changes\" value=\"".LBL_ADMIN_SUBMIT_CHANGES."\" />\n"; 104 127 echo "<input type=\"submit\" name=\"admin_plugin_check_for_updates\" value=\"".LBL_ADMIN_CHECK_FOR_UPDATES."\" /></p></form>\n"; 105 106 107 128 echo "</div>"; 108 129 } 109 130 131 function plugin_options() { 132 if (!array_key_exists('plugin_name',$_REQUEST)) { 133 return; 134 } 135 $plugin_filename = $_REQUEST['plugin_name']; 136 $plugin_filename = str_replace("%2F", "/", $plugin_filename); 137 if (preg_match('/([a-zA-Z0-9_\/\-]+).php/',$plugin_filename,$matches)) { 138 $plugin_filename = $matches[1] .".php"; // sanitize input 139 $plugin_info = getPluginInfo($plugin_filename); 140 if($plugin_info && array_key_exists('configuration', $plugin_info)) { 141 $plugin_config_func = $plugin_info['configuration']; 142 require_once("../".RSS_PLUGINS_DIR. "/" . $plugin_filename); 143 if(function_exists($plugin_config_func)) { 144 call_user_func($plugin_config_func); // Are you happy now? 145 } 146 } 147 } 148 } 110 149 111 150 … … 235 274 } 236 275 276 /** 277 * Wrapper functions for plugins 278 */ 279 function rss_plugins_add_option($key, $value, $type = "string", $default = "", $desc= "", $export = NULL) { 280 if (!$key || !$value) { 281 return false; 282 } 283 $pKey = "plugins." . rss_real_escape_string($key); 284 285 286 // first check for duplicates 287 $res = rss_query("select value_,default_,type_ from " .getTable('config') . " where key_='$pKey'"); 288 if(!rss_num_rows($res)) { // Then insert the config value 289 $value = rss_real_escape_string($value); 290 $default = $default? $default: $value; 291 return rss_query("insert into " . getTable("config") 292 . " (key_,value_,default_,type_,desc_,export_) VALUES (" 293 . "'$pKey','$value','$default','$type','$desc','$export')" ); 294 } else { // the key exists, so update the option 295 return rss_plugins_update_option($key, $value, $type, $default, $desc, $export); 296 } 297 298 299 } 300 301 function rss_plugins_update_option($key, $value, $type = "string", $default = "", $desc= "", $export = NULL) { 302 $pKey = "plugins." . rss_real_escape_string($key); 303 $value = rss_real_escape_string($value); 304 return rss_query("update " . getTable("config") . " set value_=" . 305 $value . " where key_ ='$pKey'"); 306 } 307 308 function rss_plugins_get_option($key) { 309 if (!$key) { 310 return; 311 } 312 $pKey = "plugins." . rss_real_escape_string($key); 313 $res = rss_query("select value_ from " . getTable("config") . " where key_='$pKey'"); 314 $res_count = rss_num_rows($res); 315 if ($res_count == 1) { 316 list($value) = rss_fetch_row($res); 317 return $value; // should we unescape the string? 318 } else { 319 return; 320 } 321 322 } 323 324 function rss_plugins_delete_option($key) { 325 if (!$key) { 326 return; 327 } 328 $pKey = "plugins." . rss_real_escape_string($key); 329 return rss_query("delete from " . getTable("config") . " where key_='$pKey'"); 330 331 } 332 333 function rss_plugins_redirect_to_admin() { 334 rss_redirect("/admin/index.php?" . CST_ADMIN_VIEW . "=" . CST_ADMIN_DOMAIN_PLUGINS); 335 } 336 337 function rss_plugins_redirect_to_plugin_config($filename) { 338 rss_redirect("/admin/index.php" . "?".CST_ADMIN_DOMAIN."=". CST_ADMIN_DOMAIN_PLUGIN_OPTIONS ."&action=". CST_ADMIN_EDIT_ACTION. "&plugin_name=" . $filename); 339 } 340 341 function rss_plugins_get_plugins_http_path() { 342 //returns http://example.com/rss/plugins/ 343 return guessTransportProto().$_SERVER['HTTP_HOST'] . getPath() . RSS_PLUGINS_DIR . "/"; 344 } 345 237 346 ?> -
trunk/rss/config.php
r1056 r1058 32 32 if ($config == null) { 33 33 $cfgQry = "select key_,value_,default_,type_,desc_,export_ " 34 ." from " .getTable("config") ;34 ." from " .getTable("config") ." where key_ LIKE 'rss.%'"; 35 35 36 36 $res = rss_query($cfgQry); -
trunk/rss/intl/en.php
r1044 r1058 147 147 define ('LBL_ADMIN_PLUGINS_HEADING_DESCRIPTION','Description'); 148 148 define ('LBL_ADMIN_PLUGINS_HEADING_ACTION','Active'); 149 define ('LBL_ADMIN_PLUGINS_HEADING_OPTIONS','Options'); 149 150 150 151
