Plugin Directory

Changeset 503658


Ignore:
Timestamp:
02/11/2012 02:33:53 PM (14 years ago)
Author:
mbence
Message:

v1.4

Location:
wp-livephp/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-livephp/trunk/readme.txt

    r485727 r503658  
    4040
    4141== Changelog ==
     42= 1.4 =
     43* Switched to long polling. Now the js will open only one long ajax request every 2 minutes (or as long as the php script is allowed to run).
    4244= 1.3.1 =
    4345* No new features, only some refactoring and code cleaning
  • wp-livephp/trunk/wp-live-monitor.php

    r485727 r503658  
    22/**
    33 * Wp-Live.php file monitor
    4  * Author: Bence Meszaros
    5  * Author URI: http://bencemeszaros.com
    6  * Plugin URI: http://wordpress.org/extend/plugins/wp-livephp/
     4 * @author Bence Meszaros
     5 * @link http://bencemeszaros.com
     6 * @link http://wordpress.org/extend/plugins/wp-livephp/
     7 * @version 1.4
    78 */
    89
     
    1819        /** ignore these files or directories */
    1920        protected $ignore = array();
     21       
     22        /** default time limit in seconds */
     23        protected $timeLimit = 125;
     24       
     25        /** the time to die */
     26        protected $deadLine;
    2027
    2128        /**
     
    3138
    3239                $this->headers();
     40                $this->setDeadLine();               
    3341                $this->main($start);
    3442            }
     
    3947            }
    4048        }
    41 
     49       
    4250        /**
    4351         * Output the no-cache headers
     
    5058
    5159        /**
     60         * Sets the time limit if possible
     61         */
     62        protected function setDeadLine()
     63        {
     64            // in safe mode there is no way to set the time limit
     65            if (!ini_get('safe_mode'))
     66            {
     67                set_time_limit($this->timeLimit);
     68            }       
     69            // lets check what the actual limit is
     70            $limit = ini_get('max_execution_time');
     71           
     72            if (empty($limit) || $limit < 1)
     73            {
     74                // in case of unsuccesful ini_get, (or unlimited execution), we fall back to the default 30 sec
     75                $limit = 30;
     76            }
     77            // we stop the loop 5 sec befor the time limit, just for sure
     78            $this->deadLine = time() + $limit - 5;
     79        }
     80
     81        /**
    5282         * Main function
    5383         * @param int $start start date in unix timestamp
     
    5585        protected function main($start)
    5686        {
    57             foreach ($this->dirs as $root)
     87            // long polling loop
     88            do
    5889            {
    59                 if ($this->checkDir(realpath($root), $start))
     90                // look for the changes every second until the execution time allows it.
     91                foreach ($this->dirs as $root)
    6092                {
    61                     // if we find modified files in any of the directories, we can skip the rest
    62                     echo '1';
     93                    if ($this->checkDir(realpath($root), $start))
     94                    {
     95                        // if we find modified files in any of the directories, we can skip the rest
     96                        echo '1';
    6397
    64                     die;
     98                        die;
     99                    }
    65100                }
     101               
     102                sleep(1);
    66103            }
     104            while (time() < $this->deadLine);
    67105        }
    68106
     
    115153
    116154    new LiveMonitor();
     155   
    117156
    118 } // end if
     157} // end class check if
  • wp-livephp/trunk/wp-live.js

    r485727 r503658  
    11/**
    2  Live.php
    3  @author    Bence Meszaros
    4  @version   1.0
    5 */
     2 * Live.php
     3 * @author Bence Meszaros
     4 * @link http://bencemeszaros.com
     5 * @link http://wordpress.org/extend/plugins/wp-livephp/
     6 * @version 1.4
     7 */
    68
    79var LivePhp = {
     
    1820        if (0 == LivePhp.start) {
    1921            LivePhp.start = new Date() * 1;
    20             LivePhp.heartbeat();
     22            setTimeout(LivePhp.heartbeat, LivePhp.interval);
    2123        }
    2224    },
     
    3840            LivePhp.ask(LivePhp.start);
    3941        }
    40 
    41         setTimeout(LivePhp.heartbeat, LivePhp.interval);
    4242    },
    4343
     
    5050                    location.reload();
    5151                }
     52                else {
     53                    setTimeout(LivePhp.heartbeat, LivePhp.interval);
     54                }
    5255            }
    5356        }
  • wp-livephp/trunk/wp-live.php

    r485735 r503658  
    33/*
    44  Plugin Name: WP-Live.php
    5   Plugin URI: http://wordpress.org/extend/plugins/wp-livephp/
    65  Description: Automatically refresh your browser if you change any files in your theme or plugins directory
    7   Version: 1.3.1
    86  Author: Bence Meszaros
    97  Author URI: http://bencemeszaros.com
     8  Plugin URI: http://wordpress.org/extend/plugins/wp-livephp/
     9  Version: 1.4
    1010  License: GPL2
    1111 */
Note: See TracChangeset for help on using the changeset viewer.