Joomla!ŪPlug

. XCloner - Backup and Restore Component

OOPS. Your Flash player is missing or outdated.Click here to update your player so you can see this content.
Joomla backup and restore component

XCloner for Wordpress new!

 
 
JoomlaPlug.com
Welcome, Guest
Please Login or Register.    Lost Password?
Re:JCRON works only 'every minute' (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:JCRON works only 'every minute'
#5510
kapearl (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:JCRON works only 'every minute' 3 Years, 2 Months ago  
Yeah! What is the fix for this?
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5516
GreyHead (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Gender: Male Location: Brittany
Re:JCRON works only 'every minute' 3 Years, 2 Months ago  
Hi,

Sorry, I failed to subscribe to the thread so didn't see your reply until someone pointed it out to me.

The changes I made were in the expand_ranges() function of CronParser.class.php As far as I can recall looking at the code today I added the extra loops to look for and expand step ranges of the form 1-9/n and */n

I was pretty new to cron codes when I wrote this so it may not be ideal but I recall that it worked OK on my test strings.

If there are any bugs please let me know and I'll do my best to fix them.

Bob

Code:

/** * Assumes that value is not *, and creates an array of valid numbers that * the string represents. Returns an array. */ function expand_ranges($str, $unit){ //$this->debug("Expanding $str"); // $this->debug("Expand Ranges: String: $str Unit: $unit"); if (strstr($str, ",")){ $tmp1 = explode(",", $str); $count = count($tmp1); for ( $i = 0; $i < $count; $i++ ) { //Loop through each comma-separated value if (strstr($tmp1[$i], "-")){ //If there's a range in this place, expand that too if ( strstr($tmp1[$i], "/") ) { $tmp3 = strtok($tmp1[$i], '/'); $tmp2 = explode("-", $tmp3); $step = strtok("/"); } else { $tmp2 = explode("-", $tmp1[$i]); $step = 1; } // $this->debug("tmp2: ".print_r($tmp2, true)." step: $step"); for ( $j = $tmp2[0]; $j <= $tmp2[1]; $j = $j+$step ){ $ret[] = $j; } } else {//Otherwise, just add the value $ret[] = $tmp1[$i]; } } } else if (strstr($str, "-")){ if ( strstr($str, "/") ) { $tmp = strtok($str, "/"); $range = explode("-", $tmp); $step = strtok("/"); } else { $range = explode("-", $str); $step = 1; } // $this->debug("range: ".print_r($range, true)." step: $step"); //There might only be a range, no comma sep values at all. Just loop these for ( $i = $range[0]; $i <= $range[1]; $i = $i+$step ) { $ret[] = $i; } } elseif ( strstr($str, "/") ) { // No range so this must be a */n value // we need to know the units range here: $step = substr(strrchr($str, "/"), 1); switch ($unit) { case 0 : // minutes $end = 59; break; case 1 : // hours $end = 23; break; default : // invalid entry $end = false; break; } if ( $end ) { for ( $i = 0; $i <= $end; $i = $i+$step ) { $ret[] = $i; } } } else { //Otherwise, it's a single value $ret[] = $str; } // $this->debug("return: ".print_r($ret, true)); return $ret; }
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Search JoomlaPlug.com

All rights reserved to JoomlaPlug.com ©2006-2012!

The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries.
JoomlaPlug.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.