Changeset 440988
- Timestamp:
- 09/20/2011 08:28:19 PM (15 years ago)
- Location:
- wp-green-cache/trunk
- Files:
-
- 7 edited
-
lib.php (modified) (9 diffs)
-
options.php (modified) (9 diffs)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
screenshot-1.png (modified) (previous)
-
screenshot-2.png (modified) (previous)
-
screenshot-3.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
wp-green-cache/trunk/lib.php
r434346 r440988 71 71 add_action('pingback_post', 'wpgc_post_changed', 0); 72 72 add_action('comment_post', 'wpgc_post_changed', 0); 73 add_action('edit_comment', 'wpgc_post_changed', 0); 74 add_action('wp_set_comment_status', 'wpgc_post_changed', 0); 73 add_action('edit_comment', 'wpgc_post_changed', 0); 75 74 add_action('delete_comment', 'wpgc_post_changed', 0); 76 75 add_action('wp_cache_gc', 'wpgc_post_changed', 0); 77 76 add_action('switch_theme', 'wpgc_post_changed', 100); //** 77 add_action('wp_set_comment_status', 'wpgc_post_changed', 0); 78 78 add_action('edit_user_profile_update', 'wpgc_post_changed', 100); 79 79 add_action('trash_post', 'wpgc_delete_cache_trashed', 10); … … 254 254 function wpgc_set_defaults() 255 255 { 256 $options = array();256 $options = wpgc_get_options(); 257 257 $options['cache_ttl'] = 8*60; 258 258 $options['enabled'] = false; … … 302 302 $ret = True; 303 303 304 echo file_get_contents( ABSPATH.'wp-content/advanced-cache.php' ); 304 $options = wpgc_get_options(); 305 if (!$options['enabled']) 306 return $ret; 305 307 306 308 # Check WP_CACHE define … … 683 685 } 684 686 687 function wpgc_determineOS() { 688 689 list($os) = explode('_', PHP_OS, 2); 690 691 // This magical constant knows all 692 switch ($os) { 693 694 // These are supported 695 case 'Linux': 696 case 'FreeBSD': 697 case 'DragonFly': 698 case 'OpenBSD': 699 case 'NetBSD': 700 case 'Minix': 701 case 'Darwin': 702 case 'SunOS': 703 return 'nix'; 704 break; 705 case 'WINNT': 706 return 'win'; 707 break; 708 case 'CYGWIN': 709 return 'cygwin'; 710 break; 711 712 // So anything else isn't 713 default: 714 return false; 715 break; 716 } 717 } 718 719 /* linfo destekleniyormu kontrolu */ 720 function wpgc_linfo_support(&$hw) 721 { 722 # PHP 5+ 723 if (intval(substr(PHP_VERSION, 0, 1)) < 5) { 724 $hw['linfo_err'] = 'Linfo requires PHP 5+.'; 725 return false; 726 } 727 728 $os = wpgc_determineOS(); 729 730 # On *nix system /proc and /sys must be accesseble 731 if (($os == 'nix') or ($os == 'cygwin')) 732 if (!is_dir('/sys') || !is_dir('/proc')) { 733 $hw['linfo_err'] = 'Linfo needs access to /proc or/and /sys to work.'; 734 return false; 735 } 736 737 # On Windows, needs access to WMI 738 if (($os == 'win')) { 739 $wmi = new COM('winmgmts:{impersonationLevel=impersonate}//./root/cimv2'); 740 if (!is_object($wmi)) { 741 $hw['linfo_err'] = 'Linfo needs access to WMI. Please enable DCOM in php.ini and allow the current user to access the WMI DCOM object.'; 742 return false; 743 } 744 } 745 746 if (isset($hw['linfo_err'])) 747 return false; 748 749 return True; 750 } 751 752 685 753 function wpgc_get_system_electricity_consumption(&$hw) 686 754 { 687 include_once(dirname(__FILE__).'/lib/linfo/lib.php'); 688 755 # Get hardware information such as 689 756 # cpu_count, hdd_count, eth_count, main_board_devices_count 690 $hw = wpgc_get_hardware_info(); 691 757 wpgc_linfo_support($hw); 758 if (!empty($hw['linfo_err'])) 759 return 0; 760 761 include_once('lib/linfo/lib.php'); 762 wpgc_get_hardware_info($hw); 763 if (!empty($hw['linfo_err'])) 764 return 0; 765 692 766 # calculating CPU comsumption 693 767 # http://en.wikipedia.org/wiki/List_of_CPU_power_dissipation 694 768 $cpu_watts = array(1=>55, 2=>70, 3=>90, 4=>100, 8=>130, 16=>200); 695 769 $cpu_c = $hw['cpu_count']; 696 $cpu_pw = (array_key_exists($cpu_c, $cpu_watts) ? $cpu_watts[$cpu_c] : $cpu_c * 25) * 0.8;770 $cpu_pw = (array_key_exists($cpu_c, $cpu_watts) ? $cpu_watts[$cpu_c] : $cpu_c * 25) * 0.8; 697 771 698 772 # hdd using in full capacity comsupt 12 watt … … 700 774 701 775 # mainboard using 702 $mb_pw = $hw['m ain_board_devices_count'] * 1.5 * 0.075;776 $mb_pw = $hw['mb_dev_count'] * 1.5 * 0.075; 703 777 704 778 # ethernet card using … … 708 782 } 709 783 784 710 785 function wpgc_get_cache_gains() 711 786 { 712 function c($str, $color) 713 { 787 function c($str, $color) { 714 788 return "<font color='$color'>$str</font>"; 715 789 } … … 719 793 $a_exec = sprintf("%.2f", $options['active_exec_time']); 720 794 $n_exec = sprintf("%.2f", $options['normal_exec_time']); 721 // zero division on first install 795 796 # zero division on first install 722 797 if ($options['normal_exec_time']) 723 798 $diff_exec_percent = (int) (100 - ($options['active_exec_time'] * 100 / $options['normal_exec_time'])); 724 799 $diff_exec_seconds = sprintf("%.2f", $options['normal_exec_time'] - $options['active_exec_time']); 725 800 726 801 # Bandwidth values 727 802 $n_sent = $options['normal_sent_size']; … … 730 805 $c_sent = wpgc_formatBytes($c_sent, 0); 731 806 732 # Calculate electricity comsumption values733 # Info: a tree 592,39163522 gr (0,6kg US Average) gr CO2 per kWh734 $sys_watt = wpgc_get_system_electricity_consumption($hw);735 $profited_watt = sprintf("%.3f", $sys_watt * (($n_exec- $a_exec) / (60 * 60)) / 1000);736 $profited_tree = sprintf("%.3f", $profited_watt * 0.59239163522);737 738 807 $mes .= "Total code run time decreased to %s which was %s before plugin, "; 739 808 $mes .= 'so you saved %s (%s) of code run time. '; 740 809 $mes .= "This plugin also enabling the bandwidth compression which ends up with "; 741 $mes .= "reduced total bandwidth from %s to %s. "; 742 $mes .= "In this way, according to the current %s "; 743 $mes .= "saved about %s energy and saved %s "; 744 745 $server_conf = sprintf("(Your server has %s CPU cores, %s HD, %s network interfaces and %s mainboard devices.)", 746 $hw['cpu_count'], 747 $hw['hdd_count'], 748 $hw['eth_count'], 749 $hw['main_board_devices_count']); 750 810 $mes .= "reduced total bandwidth from %s to %s. "; 811 751 812 $mes = sprintf($mes, 752 813 c($a_exec.' seconds', 'green'), … … 755 816 $diff_exec_seconds.' seconds', 756 817 c($n_sent, '#CD5C5C'), 757 c($c_sent, 'green'), 758 c($profited_watt.' kWh', 'green'), 759 '<span title="'.$server_conf.'"><u>server configuration you</u></span>', 760 c($profited_tree.' trees being shorn, thank you.', 'green') 818 c($c_sent, 'green') 761 819 ); 762 820 821 # ---------------------------------------- 822 # Calculate electricity comsumption values 823 # ---------------------------------------- 824 if ($sys_watt = wpgc_get_system_electricity_consumption($hw)) { 825 826 # Info: a tree 592,39163522 gr (0,6kg US Average) gr CO2 per kWh 827 $profited_watt = sprintf("%.3f", $sys_watt * (($n_exec- $a_exec) / (60 * 60)) / 1000); 828 $profited_tree = sprintf("%.3f", $profited_watt * 0.59239163522); 829 830 # Power consumption message 831 $pc_mes = "In this way, according to the current %s saved about %s energy and saved %s "; 832 $server_conf = sprintf("(Your server has %s CPU cores, %s HD, %s network interfaces and %s mainboard devices.)", 833 $hw['cpu_count'], 834 $hw['hdd_count'], 835 $hw['eth_count'], 836 $hw['main_board_devices_count']); 837 838 $pc_mes = sprintf($pc_mes, 839 c($profited_watt.' kWh', 'green'), 840 '<span title="'.$server_conf.'"><u>server configuration you</u></span>', 841 c($profited_tree.' trees being shorn, thank you.', 'green') 842 ); 843 } else { 844 $pc_mes = "<br><font color='gray'>Notice: Electricity compsumption could not calculated because " 845 ."<a href='http://linfo.sourceforge.net/' target='_blank'>Linfo</a> not supported by your server. " 846 .$hw['linfo_err']."</font>"; 847 } 848 849 850 $mes .= $pc_mes; 763 851 $mes = _($mes); 764 852 return $mes; -
wp-green-cache/trunk/options.php
r434338 r440988 29 29 { 30 30 // Clear inbound parameters 31 $old_options = wpgc_get_options(); 31 $old_options = wpgc_get_options(); 32 32 $options = stripslashes_deep($_POST['options']); 33 33 34 34 // Clean cache switching on compressed/uncompressed modes 35 35 if ( $options['compress'] != $old_options['compress'] ) 36 36 wpgc_clean_cache(); 37 38 wpgc_update_options($options); 37 39 38 wpgc_update_options($options); 39 40 // Activate/deactivate cache mechanism of wordpress 40 // Activate/deactivate cache mechanism 41 41 if ( $options['enabled'] != $old_options['enabled'] ) 42 42 if ( $options['enabled'] ) … … 105 105 </tr> 106 106 <tr valign="top"> 107 <td><?php echo wpgc_get_cache_gains(); ?></td> 107 <td><?php 108 echo wpgc_get_cache_gains(); 109 echo "<input name='options[normal_sent_size]' value='{$options['normal_sent_size']}' type='hidden'>"; 110 echo "<input name='options[compressed_sent_size]' value='{$options['compressed_sent_size']}' type='hidden'>"; 111 echo "<input name='options[request_count]' value='{$options['request_count']}' type='hidden'>"; 112 echo "<input name='options[normal_exec_time]' value='{$options['normal_exec_time']}' type='hidden'>"; 113 echo "<input name='options[active_exec_time]' value='{$options['active_exec_time']}' type='hidden'>"; 114 ?> 115 </td> 108 116 </tr> 109 117 <tr> 110 <td> 111 112 <input class="button" type="submit" name="save" value="<?php _e('Save'); ?>" <?php echo (!$wpgc_ok) ? 'disabled':''; ?>> 113 118 <td> 119 <input class="button" type="submit" name="save" value="<?php _e('Save'); ?>" <?php echo (!$wpgc_ok) ? 'disabled':''; ?>> 114 120 </td> 115 121 </tr> … … 129 135 <td> 130 136 <input type="text" size="5" name="options[cache_ttl]" value="<?php echo htmlspecialchars($options['cache_ttl']); ?>"/> (<?php _e('minutes', 'wpgc'); ?>) <br /> 137 <font color='gray'> 131 138 <?php _e('Minutes a cached page is valid and served to users. A zero value means a cached page is valid forever.', 'wpgc'); ?> 132 139 <?php _e('If a cached page is older than specified value (expired) it is no more used and will be regenerated on next request of it.', 'wpgc'); ?> 133 140 <?php _e('720 minutes is half a day, 1440 is a full day and so on.', 'wpgc'); ?> 141 </font> 134 142 </td> 135 143 </tr> … … 139 147 <input type="hidden" name="options[last_cleaning]" value="<?php echo $options['last_cleaning']; ?>"> 140 148 <input type="text" size="5" name="options[clean_interval]" value="<?php echo htmlspecialchars($options['clean_interval']); ?>"/> (<?php _e('minutes', 'wpgc'); ?>) <br /> 149 <font color='gray'> 141 150 <?php _e('Frequency of the autoclean process which removes to expired cached pages to free disk space.', 'wpgc'); ?> 142 151 <?php _e('If Cache autoclean is set to zero, autoclean never runs.', 'wpgc'); ?> 152 </font> 143 153 </td> 144 154 </tr> … … 151 161 <input type="hidden" name="options[compress]" value="0"> 152 162 <input type="checkbox" name="options[compress]" value="<?php echo wpgc_check_gz_funcs(); ?>" <?php echo $options['compress']?'checked':''; ?> /> <br /> 163 <font color='gray'> 153 164 <?php _e('If possible the page will be sent and stored as compressed to save bandwidth and storege quate.', 'wpgc'); ?> 154 165 <?php _e('If you switch this option then the cache will be cleaned.', 'wpgc'); ?> 166 </font> 155 167 <?php } ?> 156 168 </td> … … 161 173 <input type="hidden" name="options[perf_footer]" value="0"> 162 174 <input type="checkbox" name="options[perf_footer]" value="1" <?php echo $options['perf_footer']?'checked':''; ?>/> <br /> 175 <font color='gray'> 163 176 <?php _e('When activated the performance box it will be attached to top-right of every page.', 'wpgc'); ?> 164 177 <?php _e('Performance box views SQL query count and page generation time that you inform about blog performance.', 'hyper-cache'); ?> 165 178 <?php _e('I suggest you to see advantage of wpgc compare the values when wpgc is enabled and disabled.', 'wpgc'); ?> 179 </font> 166 180 </td> 167 181 </tr> … … 186 200 <td> 187 201 <input type="text" size="70" name="options[include_php]" value="<?php echo htmlspecialchars($options['include_php']); ?>"/><br> 202 <font color='gray'> 188 203 <?php _e('When wpgc is active if you run any php script write the path of script starting from server root.', 'wpgc'); ?><br> 189 204 <?php _e('Example: ', 'wpgc'); ?> 190 205 <?php echo '<i>'.dirname(__FILE__).'/example.php'.'</i>'; ?> 206 </font> 191 207 </td> 192 208 </tr> … … 198 214 </td> 199 215 </tr> 200 </table> 216 </table> 201 217 </div> 202 218 </div> … … 209 225 </div> 210 226 </div> 227 <a title='To send bu report you must login the WordPress.org' href='http://wordpress.org/support/bb-login.php?redirect_to=http://wordpress.org/tags/wp-green-cache#postform' target='_blank'>Send bug report about WP Green Cache</a> 228 </div> 211 229 <?php 212 230 } -
wp-green-cache/trunk/plugin.php
r434349 r440988 3 3 Plugin Name: WP Green Cache 4 4 Plugin URI: http://www.tankado.com/wp-green-cache/ 5 Version: 0.1. 55 Version: 0.1.6 6 6 Description: WP Green Cache plugin is a cache system for WordPress Blogs to improve performance and save the World. 7 7 Author: Özgür Koca 8 Author URI: http://www. tankado.com/8 Author URI: http://www.facebook.com/zerostoheroes 9 9 */ 10 10 -
wp-green-cache/trunk/readme.txt
r437104 r440988 45 45 46 46 * [WP Onlywire Auto Poster](http://www.tankado.com/onlywire-auto-poster-WordPress-eklentisi/ "Autosubmits a excerpt of a posts to Onlywire when the post published.") 47 48 47 * [WP MySQL Console](http://www.tankado.com/wp-mysql-console/ "WP MySQL Console is a web shell to operate databases such as mysql command shell.") 49 48 … … 120 119 == Changelog == 121 120 121 = 0.1.6 = 122 123 * Fixed bugs 124 * Added more control 125 * Some cosmetic fixs 126 122 127 = 0.1.5 = 123 128 … … 151 156 == More Info == 152 157 153 For more info, please visit [WP Green Cache](http://www.tankado.com/wp-green-cache/ "WP Green Cache") .158 For more info, please visit [WP Green Cache](http://www.tankado.com/wp-green-cache/ "WP Green Cache") or mail me at <[email protected]>
Note: See TracChangeset
for help on using the changeset viewer.