Plugin Directory

Changeset 440988


Ignore:
Timestamp:
09/20/2011 08:28:19 PM (15 years ago)
Author:
enseitankado
Message:
 
Location:
wp-green-cache/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • wp-green-cache/trunk/lib.php

    r434346 r440988  
    7171        add_action('pingback_post', 'wpgc_post_changed', 0);
    7272        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);       
    7574        add_action('delete_comment', 'wpgc_post_changed', 0);
    7675        add_action('wp_cache_gc',   'wpgc_post_changed', 0);
    7776        add_action('switch_theme',  'wpgc_post_changed', 100); //**
     77        add_action('wp_set_comment_status', 'wpgc_post_changed', 0);
    7878        add_action('edit_user_profile_update', 'wpgc_post_changed', 100);
    7979        add_action('trash_post', 'wpgc_delete_cache_trashed', 10);         
     
    254254    function wpgc_set_defaults()
    255255    {
    256         $options = array();         
     256        $options = wpgc_get_options();
    257257        $options['cache_ttl'] = 8*60;
    258258        $options['enabled'] = false;
     
    302302        $ret = True;
    303303       
    304         echo file_get_contents( ABSPATH.'wp-content/advanced-cache.php' );
     304        $options = wpgc_get_options();
     305        if (!$options['enabled'])
     306            return $ret;
    305307       
    306308        # Check WP_CACHE define
     
    683685    }
    684686   
     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   
    685753    function wpgc_get_system_electricity_consumption(&$hw)
    686754    {
    687         include_once(dirname(__FILE__).'/lib/linfo/lib.php');
    688        
     755        # Get hardware information such as
    689756        # 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   
    692766        # calculating CPU comsumption       
    693767        # http://en.wikipedia.org/wiki/List_of_CPU_power_dissipation       
    694768        $cpu_watts = array(1=>55, 2=>70, 3=>90, 4=>100, 8=>130, 16=>200);
    695769        $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;
    697771           
    698772        # hdd using in full capacity comsupt 12 watt
     
    700774       
    701775        # mainboard using
    702         $mb_pw = $hw['main_board_devices_count'] * 1.5 * 0.075;
     776        $mb_pw = $hw['mb_dev_count'] * 1.5 * 0.075;
    703777       
    704778        # ethernet card using
     
    708782    }
    709783   
     784   
    710785    function wpgc_get_cache_gains()
    711786    {   
    712         function c($str, $color)
    713         {
     787        function c($str, $color) {
    714788            return "<font color='$color'>$str</font>";
    715789        }
     
    719793        $a_exec = sprintf("%.2f", $options['active_exec_time']);
    720794        $n_exec = sprintf("%.2f", $options['normal_exec_time']);
    721         // zero division on first install
     795       
     796        # zero division on first install
    722797        if ($options['normal_exec_time'])
    723798        $diff_exec_percent = (int) (100 - ($options['active_exec_time'] * 100 / $options['normal_exec_time']));
    724799        $diff_exec_seconds = sprintf("%.2f", $options['normal_exec_time'] - $options['active_exec_time']);
    725        
     800   
    726801        # Bandwidth values
    727802        $n_sent = $options['normal_sent_size'];
     
    730805        $c_sent = wpgc_formatBytes($c_sent, 0);
    731806       
    732         # Calculate electricity comsumption values
    733         # Info: a tree 592,39163522 gr (0,6kg US Average) gr CO2 per kWh
    734         $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        
    738807        $mes .= "Total code run time decreased to %s which was %s before plugin, ";
    739808        $mes .= 'so you saved %s (%s) of code run time. ';
    740809        $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   
    751812        $mes = sprintf($mes,
    752813                c($a_exec.' seconds', 'green'),
     
    755816                $diff_exec_seconds.' seconds',
    756817                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')
    761819                );
    762820               
     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;
    763851        $mes = _($mes);     
    764852        return $mes;
  • wp-green-cache/trunk/options.php

    r434338 r440988  
    2929            {
    3030                // Clear inbound parameters
    31                 $old_options = wpgc_get_options();
     31                $old_options = wpgc_get_options();                         
    3232                $options = stripslashes_deep($_POST['options']);
    33 
     33               
    3434                // Clean cache switching on compressed/uncompressed modes
    3535                if ( $options['compress'] != $old_options['compress'] )
    3636                    wpgc_clean_cache();
     37                   
     38                wpgc_update_options($options); 
    3739               
    38                 wpgc_update_options($options);             
    39                
    40                 // Activate/deactivate cache mechanism of wordpress
     40                // Activate/deactivate cache mechanism
    4141                if ( $options['enabled'] != $old_options['enabled'] )
    4242                if ( $options['enabled'] )
     
    105105                    </tr>
    106106                    <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>
    108116                    </tr>               
    109117                    <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':''; ?>>                           
    114120                        </td>
    115121                    </tr>
     
    129135                <td>
    130136                    <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'>
    131138                    <?php _e('Minutes a cached page is valid and served to users. A zero value means a cached page is valid forever.', 'wpgc'); ?>
    132139                    <?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'); ?>
    133140                    <?php _e('720 minutes is half a day, 1440 is a full day and so on.', 'wpgc'); ?>
     141                    </font>
    134142                </td>
    135143            </tr>
     
    139147                    <input type="hidden" name="options[last_cleaning]" value="<?php echo $options['last_cleaning']; ?>">
    140148                    <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'>
    141150                    <?php _e('Frequency of the autoclean process which removes to expired cached pages to free disk space.', 'wpgc'); ?>
    142151                    <?php _e('If Cache autoclean is set to zero, autoclean never runs.', 'wpgc'); ?>
     152                    </font>
    143153                </td>
    144154            </tr>
     
    151161                    <input type="hidden" name="options[compress]" value="0">
    152162                    <input type="checkbox" name="options[compress]" value="<?php echo wpgc_check_gz_funcs(); ?>" <?php echo $options['compress']?'checked':''; ?> /> <br />
     163                    <font color='gray'>
    153164                    <?php _e('If possible the page will be sent and stored as compressed to save bandwidth and storege quate.', 'wpgc'); ?>
    154165                    <?php _e('If you switch this option then the cache will be cleaned.', 'wpgc'); ?>
     166                    </font>
    155167                <?php } ?>     
    156168                </td>
     
    161173                    <input type="hidden" name="options[perf_footer]" value="0">
    162174                    <input type="checkbox" name="options[perf_footer]" value="1" <?php echo $options['perf_footer']?'checked':''; ?>/> <br />
     175                    <font color='gray'>
    163176                    <?php _e('When activated the performance box it will be attached to top-right of every page.', 'wpgc'); ?>
    164177                    <?php _e('Performance box views SQL query count and page generation time that you inform about blog performance.', 'hyper-cache'); ?>
    165178                    <?php _e('I suggest you to see advantage of wpgc compare the values when wpgc is enabled and disabled.', 'wpgc'); ?>
     179                    </font>
    166180                </td>
    167181            </tr>
     
    186200                    <td>
    187201                        <input type="text" size="70" name="options[include_php]" value="<?php echo htmlspecialchars($options['include_php']); ?>"/><br>
     202                        <font color='gray'>
    188203                        <?php _e('When wpgc is active if you run any php script write the path of script starting from server root.', 'wpgc'); ?><br>
    189204                        <?php _e('Example: ', 'wpgc'); ?>
    190205                        <?php echo '<i>'.dirname(__FILE__).'/example.php'.'</i>'; ?>
     206                        </font>
    191207                    </td>
    192208                </tr>
     
    198214                    </td>
    199215                </tr>   
    200                 </table>
     216                </table>               
    201217            </div>
    202218            </div>
     
    209225        </div>
    210226        </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>     
    211229        <?php
    212230    }
  • wp-green-cache/trunk/plugin.php

    r434349 r440988  
    33 Plugin Name: WP Green Cache
    44 Plugin URI: http://www.tankado.com/wp-green-cache/
    5  Version: 0.1.5
     5 Version: 0.1.6
    66 Description: WP Green Cache plugin is a cache system for WordPress Blogs to improve performance and save the World.
    77 Author: Özgür Koca
    8  Author URI: http://www.tankado.com/
     8 Author URI: http://www.facebook.com/zerostoheroes
    99*/
    1010
  • wp-green-cache/trunk/readme.txt

    r437104 r440988  
    4545
    4646* [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 
    4847* [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.")
    4948
     
    120119== Changelog ==
    121120
     121= 0.1.6 =
     122
     123* Fixed bugs
     124* Added more control
     125* Some cosmetic fixs
     126
    122127= 0.1.5 =
    123128
     
    151156== More Info ==
    152157
    153 For more info, please visit [WP Green Cache](http://www.tankado.com/wp-green-cache/ "WP Green Cache").
     158For 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.