PageRenderTime 61ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/maintenance-mode/inc.swg-plugin-framework.php

https://github.com/sharpmachine/wakeupmedia.com
PHP | 582 lines | 360 code | 81 blank | 141 comment | 70 complexity | 3f0ab3e76890dfbd44da8bed91c4b938 MD5 | raw file
  1. <?php
  2. /**
  3. * Framework class for all plugins. For WordPress 2.3+ only
  4. * Note: ...rename the prefix name of this class...
  5. * @author Michael Wöhrer
  6. * @version 1.6, October 2010
  7. */
  8. class MaintenanceMode_SWGPluginFramework {
  9. var $g_info; # information about the plugin
  10. var $g_opt; # plugin options
  11. var $g_opt_default; # plugin default options
  12. var $g_contentmain; # content in the main area
  13. var $g_contentsidebar; # content in the sidebar
  14. /**
  15. * Set global variables & check version
  16. *
  17. * @param array $pluginInfo array of plugin information
  18. * @param array $pluginDefaultOptions array of plugin default options
  19. */
  20. function Initialize($pluginInfo, $pluginDefaultOptions) {
  21. // Set global variable
  22. $this->g_info = $pluginInfo;
  23. // Check WP version and display warning if not compatible
  24. $this->WarningIfPluginNotCompatible();
  25. // Initialize the base64 icons
  26. $this->IniBase64Icons();
  27. // Plugin default options
  28. $this->g_opt_default = $pluginDefaultOptions;
  29. // Initialize plugin options
  30. $this->IniOrUpdateOptions();
  31. // Language file
  32. // Doesn't work properly prior to WP2.7; Let's make it like in plugin 'Google Sitemap', thanks to Arne Brachhold :-)
  33. global $wp_version;
  34. if ( version_compare($wp_version, '2.7', '>=' ) ) {
  35. // >= WordPress 2.7
  36. load_plugin_textdomain($this->g_info['ShortName'], false, trailingslashit(dirname($this->GetPluginBasename())) . 'languages');
  37. } else {
  38. // < WordPress 2.7
  39. $currentLocale = get_locale();
  40. if(!empty($currentLocale)) {
  41. $moFile = dirname($this->g_info['PluginFile']) . '/languages/' . $this->g_info['ShortName'] . '-' . $currentLocale . '.mo';
  42. if(@file_exists($moFile) && is_readable($moFile)) load_textdomain($this->g_info['ShortName'], $moFile);
  43. }
  44. }
  45. // Register plugin options page
  46. if ( method_exists($this, 'PluginOptionsPage') )
  47. $this->RegisterPluginOptionsPage();
  48. }
  49. /**
  50. * Register plugin options page
  51. */
  52. function RegisterPluginOptionsPage() { // Add a menu item to the "Settings" area in the WP administration
  53. add_action('admin_menu', array(&$this, 'add_action_admin_menu_PluginMenuItem'));
  54. }
  55. function add_action_admin_menu_PluginMenuItem() {
  56. // Adding Options Page
  57. # add_options_page($this->g_info['Name'], $this->g_info['Name'], 9, basename($this->g_info['PluginFile']), array(&$this, 'PluginOptionsPage'));
  58. add_options_page($this->g_info['Name'], $this->g_info['Name'], 'manage_options', basename($this->g_info['PluginFile']), array(&$this, 'PluginOptionsPage'));
  59. // Add link "Settings" to the plugin in /wp-admin/plugins.php
  60. global $wp_version;
  61. if ( version_compare($wp_version, '2.7', '>=' ) ) {
  62. add_filter( 'plugin_action_links_' . plugin_basename($this->g_info['PluginFile']), array(&$this, 'add_filter_plugin_action_links') );
  63. }
  64. }
  65. function add_filter_plugin_action_links($links) {
  66. $settings_link = '<a href="'.$this->GetPluginOptionsURL().'">' . __('Settings') . '</a>';
  67. array_unshift($links, $settings_link);
  68. return $links;
  69. }
  70. /**
  71. * Standard Sidebar
  72. */
  73. function PrepareStandardSidebar() {
  74. $this->AddContentSidebar(__('Plugin',$this->g_info['ShortName']), '
  75. <ul>
  76. <li><a class="lhome" href="'. $this->g_info['PluginURI'] . '">'.__('Plugin\'s Homepage',$this->g_info['ShortName']).'</a></li>
  77. <li><a class="lwp" href="'. $this->g_info['SupportURI'] . '">'.__('WordPress Support',$this->g_info['ShortName']).'</a></li>
  78. <li><a class="lhome" href="http://sw-guide.de/wordpress/plugins/">'.__('Other Plugins I\'ve Written',$this->g_info['ShortName']).'</a></li>
  79. </ul>
  80. ');
  81. $this->AddContentSidebar(__('Do you like this plugin?',$this->g_info['ShortName']), '
  82. <p style="font-size:8pt;">'.__('I spend a lot of time on the plugins I\'ve written for WordPress. Any donation would be highly appreciated.',$this->g_info['ShortName']).'</p>
  83. <ul>
  84. <li><a class="lpaypal" href="http://sw-guide.de/donation/paypal/">'.__('Donate via PayPal',$this->g_info['ShortName']).'</a></li>
  85. <li><a class="lamazon" href="http://sw-guide.de/donation/amazon/">'.__('My Amazon Wish List',$this->g_info['ShortName']).'</a></li>
  86. </ul>
  87. ');
  88. }
  89. /**
  90. * Display warning message in the administration if plugin is not compatible
  91. */
  92. function WarningIfPluginNotCompatible() {
  93. global $wp_version;
  94. if( is_admin() && ($this->g_info['MinWP'] != '' ) ) {
  95. if ( ! version_compare($wp_version, $this->g_info['MinWP'], '>=' ) ) {
  96. add_action('admin_notices', array(&$this, 'add_action_admin_notices_DisplayWarningThatPluginNotCompatible'));
  97. }
  98. }
  99. }
  100. function add_action_admin_notices_DisplayWarningThatPluginNotCompatible() {
  101. global $wp_version;
  102. echo '<div class="error"><p>'.__('The activated plugin',$this->g_info['ShortName']).' &laquo;' . $this->g_info['Name'] . ' ' . $this->g_info['Version']
  103. . '&raquo; '.__('is not compatible with your installed WordPress',$this->g_info['ShortName']) . $wp_version . '. ' .
  104. __('WordPress version',$this->g_info['ShortName']) . ' ' .$this->g_info['MinWP'] . ' '.__('or higher is required when using this plugin, please deactivate it.',$this->g_info['ShortName']).'</p></div>';
  105. }
  106. /**
  107. * Initialize and (if required) save/update the options.
  108. */
  109. function IniOrUpdateOptions() {
  110. ##########################
  111. # Delete the options?
  112. ##########################
  113. $isdeleted = false;
  114. if ( isset($_POST['delete-settings-'.$this->g_info['ShortName']]) ) {
  115. delete_option($this->g_info['OptionName']);
  116. $isdeleted = true;
  117. }
  118. ##########################
  119. # Initialize options
  120. ##########################
  121. $this->g_opt = get_option($this->g_info['OptionName']);
  122. ##########################
  123. # We check if we should set the default options
  124. ##########################
  125. $ResetOpt = false;
  126. // We reset options if default options not exist
  127. if ( (!$ResetOpt) && ( !is_array($this->g_opt) || empty($this->g_opt) || $this->g_opt == false ) ) {
  128. $ResetOpt = true;
  129. }
  130. // We don't have a pluginversion option?
  131. if ( (!$ResetOpt) && ( $this->g_opt['pluginversion'] == '') ) {
  132. $ResetOpt = true;
  133. }
  134. // Check if we have updated from an old plugin version and if the version is older than the version limit ($this->g_info['UseOldOpt'])...
  135. if ( (!$ResetOpt) && ($this->g_opt['pluginversion'] != '') ) {
  136. if ( version_compare($this->g_opt['pluginversion'], $this->g_info['UseOldOpt'], '<' ) ) {
  137. $ResetOpt = true;
  138. }
  139. }
  140. ##########################
  141. # Reset to default options
  142. ##########################
  143. if ($ResetOpt) {
  144. // Options do not exist or have not yet been loaded or are old; so we set the default options
  145. $this->g_opt = $this->g_opt_default;
  146. }
  147. ##########################
  148. # Copy old option values into new option values to not loose old options
  149. # This is only used if the OptionName changed!
  150. ##########################
  151. if ( (!$isdeleted) && ( isset($this->g_opt['pluginversion']) && ($this->g_opt['pluginversion'] != $this->g_info['Version']) ) ) {
  152. if (is_array($this->g_info['DeleteOldOpt'])) {
  153. $savedoptnameArr = $this->g_info['DeleteOldOpt']; // array of old option names we want to delete later
  154. } else {
  155. $savedoptnameArr = array();
  156. }
  157. $savedoptnameArr[] = $this->g_info['OptionName']; // append current option name to array
  158. $savedoptnameArr = array_reverse($savedoptnameArr); // newest option first
  159. foreach ($savedoptnameArr as $loopval) {
  160. if ( get_option($loopval) != false ) {
  161. $opttemp = get_option($loopval);
  162. if ( (is_array($opttemp)) && (!empty($opttemp)) ) {
  163. foreach ($opttemp as $lpOptionName => $lpOptionValue) {
  164. if ($lpOptionName != 'pluginversion') {
  165. $this->g_opt[$lpOptionName] = $lpOptionValue;
  166. }
  167. }
  168. // We save the options here.
  169. $this->g_opt['pluginversion'] = $this->g_info['Version'];
  170. add_option($this->g_info['OptionName'], $this->g_opt); // adds option to table if it does not exist.
  171. update_option($this->g_info['OptionName'], $this->g_opt); // we save option since add_option does nothing if option already exists
  172. break;
  173. }
  174. }
  175. }
  176. }
  177. ##########################
  178. # If new options added or old ones removed:
  179. # Remove option entries or add the new ones
  180. ##########################
  181. $newarray = array();
  182. foreach ( $this->g_opt_default as $lpOptionName => $lpOptionValue ) {
  183. if ( array_key_exists($lpOptionName, $this->g_opt) ) {
  184. $newarray[$lpOptionName] = $this->g_opt[$lpOptionName];
  185. } else {
  186. $newarray[$lpOptionName] = $this->g_opt_default[$lpOptionName];
  187. }
  188. }
  189. $this->g_opt = $newarray;
  190. ##########################
  191. # Set the current plugin version
  192. ##########################
  193. $this->g_opt['pluginversion'] = $this->g_info['Version'];
  194. ##########################
  195. # Save/update the options if required
  196. ##########################
  197. if ( isset($_POST['update-options-'.$this->g_info['ShortName']]) ) {
  198. // Build array of options and add the $_POST values
  199. foreach ($this->g_opt as $lpOptionName => $lpOptionValue) {
  200. if (method_exists($this, 'COPTSave')) {
  201. $optionsToBeSaved[$lpOptionName] = $this->COPTSave($lpOptionName);
  202. } else {
  203. $optionsToBeSaved[$lpOptionName] = $_POST[$lpOptionName];
  204. }
  205. // for plugin version we don't have a $_POST so update it manually
  206. $optionsToBeSaved['pluginversion'] = $this->g_info['Version'];
  207. }
  208. // Update Options in the database
  209. add_option($this->g_info['OptionName'], $optionsToBeSaved); // adds option to table if it does not exist.
  210. update_option($this->g_info['OptionName'], $optionsToBeSaved); // we save option since add_option does nothing if option already exists
  211. // Update Options in the class
  212. $this->g_opt = $optionsToBeSaved;
  213. }
  214. }
  215. /**
  216. * Returns the plugin directory path, e.g. webseiten/wordpressblog/wp-content/plugins/my-great-plugin/
  217. * @return string The path to the plugin directory
  218. */
  219. function GetPluginPath() {
  220. $path = dirname($this->g_info['PluginFile']);
  221. return trailingslashit(str_replace("\\", "/", $path));
  222. }
  223. /**
  224. * Returns the plugin directory URL, e.g. http://domain.tld/blog/wp-content/plugins/my-great-plugin/
  225. * @return string The URL to the plugin directory
  226. */
  227. function GetPluginURL() {
  228. // function plugins_url() exists since WP 2.6.0
  229. if (function_exists('plugins_url')) {
  230. return trailingslashit(plugins_url(basename(dirname($this->g_info['PluginFile']))));
  231. } else {
  232. // We do it manually; will not work if wp-content is renamed or redirected
  233. $result = str_replace("\\", '/', dirname($this->g_info['PluginFile']));
  234. $result = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($result, strpos($result,'wp-content/')));
  235. return $result;
  236. }
  237. }
  238. /**
  239. * Returns the basename of a plugin (extracts the name of a plugin from its filename).
  240. * Example: If your plugin file is located at /home/www/wp-content/plugins/myplugin/myplugin.php,
  241. * it will return 'myplugin/myplugin.php'
  242. * @return string The URL to the plugin directory
  243. */
  244. function GetPluginBasename() {
  245. return trailingslashit(plugin_basename($this->g_info['PluginFile']));
  246. }
  247. /**
  248. * Add content to the main area
  249. * @param string $header Header
  250. * @param string $content Content
  251. */
  252. function AddContentMain($header, $content) {
  253. $res = $this->g_contentmain;
  254. $res .= "\n\n\t\t" . '<dl>';
  255. $res .= "\n\t\t\t" . '<dt><h3>' . $header . '</h3></dt>';
  256. $res .= "\n\t\t\t" . '<dd>' . $content . '</dd>';
  257. $res .= "\n\n\t\t" . '</dl>';
  258. $this->g_contentmain = $res;
  259. }
  260. /**
  261. * Add content to the sidebar
  262. * @param string $header Header
  263. * @param string $content Content
  264. */
  265. function AddContentSidebar($header, $content) {
  266. $res = $this->g_contentsidebar;
  267. $res .= "\n\n\t\t" . '<dl>';
  268. $res .= "\n\t\t\t" . '<dt><h4>' . $header . '</h4></dt>';
  269. $res .= "\n\t\t\t" . '<dd>' . $content . '</dd>';
  270. $res .= "\n\n\t\t" . '</dl>';
  271. $this->g_contentsidebar = $res;
  272. }
  273. /**
  274. * Replace white space with new line for displaying in text area
  275. * @param string $input
  276. */
  277. function WhitespaceToLinebreak($input) {
  278. $output = str_replace(' ', "\n", $input);
  279. return $output;
  280. }
  281. /**
  282. * Converts textarea content (separated by line break) to space separated string
  283. * since we want to store it like this in the database
  284. * @param string $input
  285. */
  286. function LinebreakToWhitespace($input) {
  287. // Remove white spaces
  288. $input = str_replace(' ', '', $input);
  289. // Replace linebreaks with white space, considering both \n and \r
  290. $input = preg_replace("/\r|\n/s", ' ', $input);
  291. // Create result. We create an array and loop thru it but do not consider empty values.
  292. $sourceArray = explode(' ', $input);
  293. $loopcount = 0;
  294. $result = '';
  295. foreach ($sourceArray as $loopval) {
  296. if ($loopval <> '') {
  297. // Create separator
  298. $sep = '';
  299. if ($loopcount >= 1) $sep = ' ';
  300. // result
  301. $result .= $sep . $loopval;
  302. $loopcount++;
  303. }
  304. }
  305. return $result;
  306. }
  307. /**
  308. * Returns the options page
  309. * @return string The options page
  310. */
  311. function GetGeneratedOptionsPage() {
  312. // Security
  313. if ( function_exists('current_user_can') && (!current_user_can('manage_options')) ) {
  314. wp_die('<p>'.__('You do not have permission to modify the options', $this->g_info['ShortName']).'</p>');
  315. }
  316. if ( isset($_POST['delete-settings-'.$this->g_info['ShortName']]) || isset($_POST['update-options-'.$this->g_info['ShortName']]) ) {
  317. check_admin_referer($this->g_info['Name']);
  318. }
  319. // Delete old options if we have any. We perform the deletion here as we only want to do it
  320. // in the admin area and not on every page load.
  321. if ( is_array($this->g_info['DeleteOldOpt']) || !empty($this->g_info['DeleteOldOpt']) ) {
  322. foreach ($this->g_info['DeleteOldOpt'] as $loopval) {
  323. if ($loopval != '') {
  324. if ( get_option($loopval) != false ) {
  325. delete_option($loopval);
  326. }
  327. }
  328. }
  329. }
  330. // Display message
  331. // We generate output here and not in IniOrUpdateOptions() as there the __()
  332. // does not show translated values.
  333. if ( isset($_POST['delete-settings-'.$this->g_info['ShortName']]) ) {
  334. echo '<div class="updated"><strong><p>' . __('Settings deleted/reset.',$this->g_info['ShortName']) . '</p></strong></div>';
  335. } elseif ( isset($_POST['update-options-'.$this->g_info['ShortName']]) ) {
  336. echo '<div class="updated"><strong><p>' . __('Settings saved.',$this->g_info['ShortName']) . '</p></strong></div>';
  337. }
  338. ?>
  339. <style type="text/css">
  340. table#outer { width: 100%; border: 0 none; padding:0; margin:0; }
  341. table#outer fieldset { border: 0 none; padding:0; margin:0; }
  342. table#outer td.left, table#outer td.right { vertical-align:top; }
  343. table#outer td.left { padding: 0 8px 0 0; }
  344. table#outer td.right { padding: 0 0 0 8px; width: 210px; }
  345. td.right ul, td.right ul li { list-style: none; padding:0; margin:0; }
  346. td.right a { text-decoration:none; background-position:0px 60%; background-repeat:no-repeat; padding: 4px 0px 4px 22px; border: 0 none; display:block;}
  347. td.right a.lhome { background-image:url(<?php echo $this->GetBase64IconURL('sw-guide.png'); ?>); }
  348. td.right a.lpaypal { background-image:url(<?php echo $this->GetBase64IconURL('paypal.png'); ?>); }
  349. td.right a.lamazon { background-image:url(<?php echo $this->GetBase64IconURL('amazon.png'); ?>); }
  350. td.right a.lwp { background-image:url(<?php echo $this->GetBase64IconURL('wp.png'); ?>); }
  351. td.right ul li { padding:0; margin:0; }
  352. table#outer td dl { padding:0; margin: 10px 0 20px 0; background-color: white; border: 1px solid #dfdfdf; }
  353. table#outer td dl { -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }
  354. table#outer dl h3, table#outer td.right dl h4 { font-size: 10pt; font-weight: bold; margin:0; padding: 4px 10px 4px 10px; background: #dfdfdf url(<?php echo $this->GetBase64IconURL('bg-header-gray.png'); ?>) repeat-x left top; }
  355. table#outer td.left dl h4 { font-size: 10pt; font-weight: bold; margin:0; padding: 4px 0 4px 0; }
  356. table#outer td.left dd { margin:0; padding: 10px 20px 10px 20px; }
  357. table#outer td.right dd { margin:0; padding: 5px 10px 5px 10px; }
  358. table#outer .info { color: #555; font-size: .85em; }
  359. table#outer p { padding:5px 0 5px 0; margin:0;}
  360. input.swg_warning:hover { background: #ce0000; color: #fff; }
  361. table#outer .swgfooter {text-align: center; font-size: .85em;}
  362. table#outer .swgfooter a, table#outer .swgfooter a:link { text-decoration:none; }
  363. table#outer td small { color: #555; font-size: .85em; }
  364. table#outer hr { border: none 0; border-top: 1px solid #BBBBBB; height: 1px; }
  365. table#outer ul { list-style:none; }
  366. table#outer ul.mybullet { list-style-type:disc; padding-left: 20px; }
  367. .swginfo { font-size:85%; line-height: 115%; }
  368. </style>
  369. <div class="wrap">
  370. <h2><?php echo __('Plugin Settings', $this->g_info['ShortName']) . ': ' . $this->g_info['Name'] . ' ' . $this->g_info['Version']; ?></h2>
  371. <table id="outer"><tr><td class="left">
  372. <!-- *********************** BEGIN: Main Content ******************* -->
  373. <form name="form1" method="post" action="<?php echo $this->GetPluginOptionsURL() ?>">
  374. <?php wp_nonce_field($this->g_info['Name']); ?>
  375. <fieldset class="options">
  376. <?php echo $this->g_contentmain; ?>
  377. <div class="submit">
  378. <?php wp_nonce_field($this->g_info['Name']) ?>
  379. <input type="submit" name="update-options-<?php echo $this->g_info['ShortName']; ?>" class="button-primary" value="<?php _e('Save Changes',$this->g_info['ShortName']) ?>" />
  380. <input type="submit" name="delete-settings-<?php echo $this->g_info['ShortName']; ?>" onclick='return confirm("<?php _e('Do you really want to delete/reset the plugin settings?',$this->g_info['ShortName']); ?>");' class="swg_warning" value="<?php _e('Delete/Reset Settings',$this->g_info['ShortName']) ?>" />
  381. </div>
  382. </fieldset>
  383. </form>
  384. <!-- *********************** END: Main Content ********************* -->
  385. <p class="swgfooter"><a style="" href="<?php echo $this->g_info['PluginURI']; ?>"><?php echo $this->g_info['Name'] . ' ' . $this->g_info['Version'] . '</a> &copy; Copyright ' . $this->g_info['CopyrightYear']; ?> <a href="<?php echo $this->g_info['AuthorURI']; ?>"><?php echo $this->g_info['Author']; ?></a></p>
  386. </td> <!-- [left] -->
  387. <td class="right">
  388. <!-- *********************** BEGIN: Sidebar ************************ -->
  389. <?php echo $this->g_contentsidebar; ?>
  390. <!-- *********************** END: Sidebar ************************ -->
  391. </td> <!-- [right] -->
  392. </tr></table> <!-- [outer] -->
  393. </div> <!-- [wrap] -->
  394. <?php
  395. }
  396. /**
  397. * Returns the plugin information. Uses the WP API to get the meta data from the top of the plugin file (comment)
  398. * @param string $info 'Name', 'Title', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version', 'TextDomain', 'DomainPath'
  399. * @return string array; to get for example the version use $returnvalue['Version']
  400. */
  401. function GetPluginData($info) {
  402. if (empty($this->g_data)) {
  403. if(!function_exists('get_plugin_data')) {
  404. if(file_exists(ABSPATH . 'wp-admin/includes/plugin.php'))
  405. require_once(ABSPATH . 'wp-admin/includes/plugin.php');
  406. else return "0.ERROR";
  407. }
  408. $this->g_data = get_plugin_data($this->g_info['PluginFile']);
  409. }
  410. return $this->g_data[$info];
  411. }
  412. /**
  413. * Returns the option URL of the plugin, e.g. http://testblog.com/wp-admin/options-general.php?page=myplugin.php
  414. * @return string
  415. */
  416. function GetPluginOptionsURL() {
  417. if (function_exists('admin_url')) { // since WP 2.6.0
  418. $adminurl = trailingslashit(admin_url());
  419. } else {
  420. $adminurl = trailingslashit(get_settings('siteurl')).'wp-admin/';
  421. }
  422. return $adminurl.'options-general.php'.'?page=' . basename($this->g_info['PluginFile']);
  423. }
  424. /**
  425. * Get Icon URL
  426. */
  427. function GetBase64IconURL($resourceID) {
  428. return trailingslashit(get_bloginfo('siteurl')) . '?resource=' . $resourceID;
  429. }
  430. /**
  431. * Initialize our Base64 Icons
  432. */
  433. function IniBase64Icons() {
  434. if( isset($_GET['resource']) && !empty($_GET['resource'])) {
  435. # base64 encoding performed by base64img.php from http://php.holtsmark.no
  436. $resources = array(
  437. 'paypal.png' =>
  438. 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAFfKj/FAAAAB3RJTUUH1wYQEhELx'.
  439. 'x+pjgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAARnQU1BAACxjwv8YQUAAAAnUExURZ'.
  440. 'wMDOfv787W3tbe55y1xgAxY/f39////73O1oSctXOUrZSlva29zmehiRYAAAABdFJ'.
  441. 'OUwBA5thmAAAAdElEQVR42m1O0RLAIAgyG1Gr///eYbXrbjceFAkxM4GzwAyse5qg'.
  442. 'qEcB5gyhB+kESwi8cYfgnu2DMEcfFDDNwCakR06T4uq5cK0n9xOQPXByE3JEpYG2h'.
  443. 'KYgHdnxZgUeglxjCV1vihx4N1BluM6JC+8v//EAp9gC4zRZsZgAAAAASUVORK5CYI'.
  444. 'I=',
  445. 'amazon.png' =>
  446. 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAFfKj/FAAAAB3RJTUUH1wYQESUI5'.
  447. '3q1mgAAAAlwSFlzAAALEgAACxIB0t1+/AAAAARnQU1BAACxjwv8YQUAAABgUExURe'.
  448. 'rBhcOLOqB1OX1gOE5DNjc1NYKBgfGnPNqZO4hnOEM8NWZSN86SO1pKNnFZN7eDOuW'.
  449. 'gPJRuOVBOTpuamo+NjURCQubm5v///9rZ2WloaKinp11bW3Z0dPPy8srKyrSzs09b'.
  450. 'naIAAACiSURBVHjaTY3ZFoMgDAUDchuruFIN1qX//5eNYJc85EyG5EIBBNACEibsi'.
  451. 'mi5UaUURJtI5wm+KwgSJflVkOFscBUTM1vgrmacThfomGVLO9MhIYFsF8wyx6Jnl8'.
  452. '8HUxEay+wYmlM6oNKcNYrIC58iHMcIyQlZRNmf/2LRQUX8bYwh3PCYWmOGrueargd'.
  453. 'XGO5d6UGm5FSmBqzXEzK2cN9PcXsD9XsKTHawijcAAAAASUVORK5CYII=',
  454. 'sw-guide.png' =>
  455. 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAFfKj/FAAAAB3RJTUUH1wYQEhckO'.
  456. 'pQzUQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAARnQU1BAACxjwv8YQUAAABFUExURZ'.
  457. 'wMDN7e3tbW1oSEhOfn54yMjDk5OTExMWtra7W1te/v72NjY0pKSs7OzpycnHNzc8b'.
  458. 'Gxr29vff3962trVJSUqWlpUJCQkXEfukAAAABdFJOUwBA5thmAAAAlUlEQVR42k2O'.
  459. 'WxLDIAwD5QfQEEKDob3/UevAtM1+LRoNFsDgCGbEAE7ZwBoe/maCndaRyylQTQK2S'.
  460. 'XPpXjTvq2osRUCyAPEEaKvM6LWFKcFGnCI1Hc+WXVRFk07ROGVBoNpvVAJ3Pzjee5'.
  461. '7fdh9dfcUItO5UD8T6aVs69jheJlegFyFmPlj/wZZC3ssKSH+wB9/9C8IH45EIdeu'.
  462. 'A/YIAAAAASUVORK5CYII=',
  463. 'wp.png' =>
  464. 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAFfKj/FAAAAB3RJTUUH1wYQEiwG0'.
  465. '0adjQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAARnQU1BAACxjwv8YQUAAABOUExURZ'.
  466. 'wMDN7n93ut1kKExjFjnHul1tbn75S93jFrnP///1qUxnOl1sbe71KMxjFrpWOUzjl'.
  467. '7tYy13q3G5+fv95y93muczu/39zl7vff3//f//9Se9dEAAAABdFJOUwBA5thmAAAA'.
  468. 's0lEQVR42iWPUZLDIAxDRZFNTMCllJD0/hddktWPRp6x5QcQmyIA1qG1GuBUIArwj'.
  469. 'SRITkiylXNxHjtweqfRFHJ86MIBrBuW0nIIo96+H/SSAb5Zm14KnZTm7cQVc1XSMT'.
  470. 'jr7IdAVPm+G5GS6YZHaUv6M132RBF1PopTXiuPYplcmxzWk2C72CfZTNaU09GCM3T'.
  471. 'Ww9porieUwZt9yP6tHm5K5L2Uun6xsuf/WoTXwo7yQPwBXo8H/8TEoKYAAAAASUVO'.
  472. 'RK5CYII=',
  473. 'bg-header-gray.png' =>
  474. 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAfCAIAAACgQJBPAAAAA3NCSVQICAjb4U/gA'.
  475. 'AAACXBIWXMAAAsSAAALEgHS3X78AAAAIXRFWHRTb2Z0d2FyZQBNYWNyb21lZGlhIE'.
  476. 'ZpcmV3b3JrcyA0LjDqJid1AAAAFnRFWHRDcmVhdGlvbiBUaW1lADEwLzI0LzA4KQ6'.
  477. 'r+wAAAClJREFUeJxjfPv2LQMSYPn//z8yn4kBFaDzqa0eXZ5U9QMtT6l5tFYPADsX'.
  478. 'LPcJwrwLAAAAAElFTkSuQmCC',
  479. ); // $resources = array
  480. if(array_key_exists($_GET['resource'],$resources)) {
  481. $content = base64_decode($resources[ $_GET['resource'] ]);
  482. $lastMod = filemtime(__FILE__);
  483. $client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false );
  484. // Checking if the client is validating his cache and if it is current.
  485. if (isset($client) && (strtotime($client) == $lastMod)) {
  486. // Client's cache IS current, so we just respond '304 Not Modified'.
  487. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 304);
  488. exit;
  489. } else {
  490. // Image not cached or cache outdated, we respond '200 OK' and output the image.
  491. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 200);
  492. header('Content-Length: '.strlen($content));
  493. header('Content-Type: image/' . substr(strrchr($_GET['resource'], '.'), 1) );
  494. echo $content;
  495. exit;
  496. }
  497. }
  498. }
  499. } // function IniBase64Icons
  500. } // class PluginOptions
  501. ?>