Changeset 621 for pro-violet-viettel/sourcecode/application/helpers
- Timestamp:
- Nov 25, 2014 10:33:58 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/helpers/lockfile_helper.php
r620 r621 3 3 if ( ! function_exists('createLockFile')) 4 4 { 5 function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $lockFilePath = '', $checkLockOnly = 0, $colSep = '|')5 function createLockFile ($lockFilePrefix, $maxReach, $timeToUnlock, $lockFilePath = '', $checkLockOnly = FALSE, $colSep = '|') 6 6 { 7 7 $currentTimeStamp = time(); … … 23 23 24 24 $timeDiffMin = $lastTimeLock != '' ? dateDifference(date('Y-m-d H:i:s',$currentTimeStamp), date('Y-m-d H:i:s',$lastTimeLock), '%i') : 0; 25 26 if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock && $checkLockOnly == 0) {25 26 if ($lockCount < $maxReach && $timeDiffMin < $timeToUnlock && !$checkLockOnly) { 27 27 $lockCount ++; 28 28 $isLocked = $lockCount < $maxReach ? 0:1; … … 30 30 } 31 31 else if ($timeDiffMin > $timeToUnlock) { 32 $lockCount = 0;32 $lockCount = 1; 33 33 $isLocked = 0; 34 34 $ready = 1; … … 44 44 } 45 45 46 return $isLocked;46 return (int)$isLocked; 47 47 } 48 48 } … … 52 52 function releaseLockFile ($lockFilePrefix, $lockFilePath = '') 53 53 { 54 $filePath = $lockFileP refix.'_lock';54 $filePath = $lockFilePath.$lockFilePrefix.'_lock'; 55 55 $fileExisted = file_exists($filePath); 56 56 if ($fileExisted) { … … 81 81 $datetime2 = date_create($date_2); 82 82 83 $interval = date_diff($datetime1, $datetime2); 84 85 return $interval->format($differenceFormat); 86 83 $diff = date_diff($datetime1, $datetime2); 84 $total = 0; 85 switch( $differenceFormat){ 86 case "%y": 87 $total = $diff->y + $diff->m / 12 + $diff->d / 365.25; break; 88 case "%m": 89 $total= $diff->y * 12 + $diff->m + $diff->d/30 + $diff->h / 24; 90 break; 91 case "%a": 92 $total = $diff->y * 365.25 + $diff->m * 30 + $diff->d + $diff->h/24 + $diff->i / 60; 93 break; 94 case "%h": 95 $total = ($diff->y * 365.25 + $diff->m * 30 + $diff->d) * 24 + $diff->h + $diff->i/60; 96 break; 97 case "%i": 98 $total = (($diff->y * 365.25 + $diff->m * 30 + $diff->d) * 24 + $diff->h) * 60 + $diff->i + $diff->s/60; 99 break; 100 case "%s": 101 $total = ((($diff->y * 365.25 + $diff->m * 30 + $diff->d) * 24 + $diff->h) * 60 + $diff->i)*60 + $diff->s; 102 break; 103 } 104 105 return (int)$total; 106 /* if( $diff->invert) 107 return -1 * $total; 108 else return $total; */ 87 109 } 88 110 }
Note: See TracChangeset
for help on using the changeset viewer.