Changeset 503658
- Timestamp:
- 02/11/2012 02:33:53 PM (14 years ago)
- Location:
- wp-livephp/trunk
- Files:
-
- 4 edited
-
readme.txt (modified) (1 diff)
-
wp-live-monitor.php (modified) (7 diffs)
-
wp-live.js (modified) (4 diffs)
-
wp-live.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-livephp/trunk/readme.txt
r485727 r503658 40 40 41 41 == 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). 42 44 = 1.3.1 = 43 45 * No new features, only some refactoring and code cleaning -
wp-livephp/trunk/wp-live-monitor.php
r485727 r503658 2 2 /** 3 3 * 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 7 8 */ 8 9 … … 18 19 /** ignore these files or directories */ 19 20 protected $ignore = array(); 21 22 /** default time limit in seconds */ 23 protected $timeLimit = 125; 24 25 /** the time to die */ 26 protected $deadLine; 20 27 21 28 /** … … 31 38 32 39 $this->headers(); 40 $this->setDeadLine(); 33 41 $this->main($start); 34 42 } … … 39 47 } 40 48 } 41 49 42 50 /** 43 51 * Output the no-cache headers … … 50 58 51 59 /** 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 /** 52 82 * Main function 53 83 * @param int $start start date in unix timestamp … … 55 85 protected function main($start) 56 86 { 57 foreach ($this->dirs as $root) 87 // long polling loop 88 do 58 89 { 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) 60 92 { 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'; 63 97 64 die; 98 die; 99 } 65 100 } 101 102 sleep(1); 66 103 } 104 while (time() < $this->deadLine); 67 105 } 68 106 … … 115 153 116 154 new LiveMonitor(); 155 117 156 118 } // end if157 } // end class check if -
wp-livephp/trunk/wp-live.js
r485727 r503658 1 1 /** 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 */ 6 8 7 9 var LivePhp = { … … 18 20 if (0 == LivePhp.start) { 19 21 LivePhp.start = new Date() * 1; 20 LivePhp.heartbeat();22 setTimeout(LivePhp.heartbeat, LivePhp.interval); 21 23 } 22 24 }, … … 38 40 LivePhp.ask(LivePhp.start); 39 41 } 40 41 setTimeout(LivePhp.heartbeat, LivePhp.interval);42 42 }, 43 43 … … 50 50 location.reload(); 51 51 } 52 else { 53 setTimeout(LivePhp.heartbeat, LivePhp.interval); 54 } 52 55 } 53 56 } -
wp-livephp/trunk/wp-live.php
r485735 r503658 3 3 /* 4 4 Plugin Name: WP-Live.php 5 Plugin URI: http://wordpress.org/extend/plugins/wp-livephp/6 5 Description: Automatically refresh your browser if you change any files in your theme or plugins directory 7 Version: 1.3.18 6 Author: Bence Meszaros 9 7 Author URI: http://bencemeszaros.com 8 Plugin URI: http://wordpress.org/extend/plugins/wp-livephp/ 9 Version: 1.4 10 10 License: GPL2 11 11 */
Note: See TracChangeset
for help on using the changeset viewer.