isdir() should use fetch_rev_num() instead of HEAD
[viewsvn.git] / includes / svnlib.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Command line interface with the SVN commands
24 *
25 * @package ViewSVN
26 */
27
28 /**
29 * Interacts with the command line subsystem to
30 * access SVN information
31 *
32 * @package ViewSVN
33 * @version $Id$
34 */
35 class SVNLib
36 {
37 /**
38 * Path to the SVN binary
39 * @var string
40 */
41 var $svnpath;
42
43 /**
44 * Common command system
45 * @var object
46 */
47 var $common;
48
49 /**
50 * Constructor: validate SVN path
51 *
52 * @param string Path to SVN binary
53 */
54 function SVNLib($svnpath)
55 {
56 global $viewsvn;
57
58 $this->svnpath = $viewsvn->shell->cmd($svnpath);
59
60 $this->common =& new SVNCommon();
61
62 $access = $viewsvn->shell->exec($this->svnpath . ' --version');
63
64 if (!$access)
65 {
66 $viewsvn->trigger->error('svn binary could not be found');
67 }
68
69 if (!preg_match('#^svn, version (.*?)\)$#i', trim($access[0])))
70 {
71 $viewsvn->trigger->error('svn binary does not pass test');
72 }
73 }
74
75 /**
76 * Prepares data for output
77 *
78 * @access public
79 *
80 * @param string Standard data
81 *
82 * @return string Output-ready data
83 */
84 function format($string)
85 {
86 // convert entities
87 $string = htmlspecialchars($string);
88
89 // tabs to 5 spaces
90 $string = str_replace("\t", ' ', $string);
91
92 // spaces to nbsp
93 if (true)
94 {
95 $string = preg_replace('#( +)#e', '$this->format_spaces("\1")', $string);
96 }
97 // no word wrap
98 else
99 {
100 $string = str_replace(' ', '&nbsp;', $string);
101 }
102
103 // convert advanced diff
104 $string = str_replace(array('{@+' . '+}', '{@-' . '-}'), array('<span class="diff_add_bit">', '<span class="diff_del_bit">'), $string);
105 $string = str_replace(array('{/@+' . '+}', '{/@-' . '-}'), '</span>', $string);
106
107 // nl2br
108 $string = nl2br($string);
109
110 return $string;
111 }
112
113 /**
114 * Counts the spaces and replaces two or more ones
115 *
116 * @access private
117 *
118 * @param string Spaced string
119 *
120 * @return string &nbsp;'d string
121 */
122 function format_spaces($thestring)
123 {
124 if (strlen($thestring) >= 2)
125 {
126 $thestring = str_replace(' ', '&nbsp;', $thestring);
127 }
128
129 return $thestring;
130 }
131
132 /**
133 * Executes the SVN binary
134 *
135 * @access private
136 *
137 * @param string Command
138 *
139 * @return array Output
140 */
141 function svn($command)
142 {
143 global $viewsvn;
144
145 $output = $viewsvn->shell->exec($this->svnpath . ' ' . $command . ' 2>&1');
146
147 // make sure that we keep escaped chars
148 //$output = str_replace(array('\t', '\n', '\r'), array('\\\t', '\\\n', '\\\r'), $output);
149 //$output = preg_replace('#\\\(.)#', '\\\\\\\\' . '\1', $output);
150 $output = str_replace('\\', '\\\\', $output);
151
152 $temp = implode("\n", $output);
153 if (strpos($temp, '(apr' . '_err=') !== false)
154 {
155 $viewsvn->trigger->error(nl2br($temp));
156 }
157 return $output;
158 }
159
160 /**
161 * SVN Wrapper: standard command system
162 *
163 * @access private
164 *
165 * @param string SVN command
166 * @param string Repository
167 * @param string Path
168 * @param integer Revision
169 *
170 * @return array Lines of output
171 */
172 function std($command, $repos, $path, $revision)
173 {
174 global $viewsvn;
175
176 $revision = $this->rev($revision);
177 $repospath = $viewsvn->repos->fetch_path($repos, false);
178
179 return $this->svn($command . ' ' . $repospath . $path . '@' . $revision);
180 }
181
182 /**
183 * SVN Wrapper: blame
184 *
185 * @access protected
186 *
187 * @param string Repository
188 * @param string Path
189 * @param integer Revision
190 *
191 * @return array Lines of blame output
192 */
193 function blame($repos, $path, $revision)
194 {
195 return $this->std('blame', $repos, $path, $revision);
196 }
197
198 /**
199 * SVN Wrapper: cat
200 *
201 * @access protected
202 *
203 * @param string Repository
204 * @param string Path
205 * @param integer Revision
206 *
207 * @return array Lines of cat output
208 */
209 function cat($repos, $path, $revision)
210 {
211 return $this->std('cat', $repos, $path, $revision);
212 }
213
214 /**
215 * SVN Wrapper: diff
216 *
217 * @access protected
218 *
219 * @param string Repository
220 * @param string Path
221 * @param integer Lower revision
222 * @param integer Higher revision
223 *
224 * @return array Lines of diff output
225 */
226 function diff($repos, $path, $lorev, $hirev)
227 {
228 global $viewsvn;
229
230 $hirev = $this->rev($hirev);
231 $lorev = $this->rev($lorev);
232 if ($lorev == 'HEAD')
233 {
234 $lorev = 1;
235 }
236
237 if (is_integer($hirev) AND is_integer($lorev))
238 {
239 if ($lorev > $hirev)
240 {
241 $lorev = $hirev - 1;
242 }
243 if ($lorev == $hirev)
244 {
245 $lorev = 0;
246 }
247 }
248
249 $repospath = $viewsvn->repos->fetch_path($repos, false);
250
251 return $this->svn('diff -r' . $lorev . ':' . $hirev . ' ' . $repospath . $path);
252 }
253
254 /**
255 * SVN Wrapper: log
256 *
257 * @access protected
258 *
259 * @param string Repository
260 * @param string Path
261 * @param integer Lower revision
262 * @param integer Higher revision
263 *
264 * @return array Lines of log output
265 */
266 function log($repos, $path, $lorev, $hirev)
267 {
268 global $viewsvn;
269
270 $hirev = $this->rev($hirev);
271 $lorev = $this->rev($hirev);
272 if ($lorev == 'HEAD')
273 {
274 $lorev = 0;
275 }
276
277 if (is_integer($hirev) AND is_integer($lorev))
278 {
279 if ($lorev > $hirev)
280 {
281 $lorev = $hirev - 1;
282 }
283 if ($lorev == $hirev)
284 {
285 $lorev = 0;
286 }
287 }
288
289 $repospath = $viewsvn->repos->fetch_path($repos, false);
290
291 return $this->svn('log -v -r' . $hirev . ':' . $lorev . ' ' . $repospath . $path);
292 }
293
294 /**
295 * SVN Wrapper: ls (list)
296 *
297 * @access protected
298 *
299 * @param string Repository
300 * @param string Path
301 * @param integer Revision
302 *
303 * @return array Lines of list output
304 */
305 function ls($repos, $path, $revision)
306 {
307 return $this->std('list', $repos, $path, $revision);
308 }
309
310 /**
311 * Generates a clean revision number
312 *
313 * @access public
314 *
315 * @param integer Revision number
316 *
317 * @return mixed Cleaned revision or HEAD
318 */
319 function rev($revision)
320 {
321 if (($revision = intval($revision)) < 1)
322 {
323 $revision = 'HEAD';
324 }
325 return $revision;
326 }
327 }
328
329 /**
330 * Commonly executed SVN commands that return data
331 * used in many parts of the system
332 *
333 * @package ViewSVN
334 * @version $Id$
335 */
336 class SVNCommon
337 {
338 /**
339 * Registry object
340 * @var object
341 */
342 var $registry;
343
344 /**
345 * List of revisions
346 * @var array
347 */
348 var $revisions;
349
350 /**
351 * List of logs
352 * @var array
353 */
354 var $logs;
355
356 /**
357 * Constructor: bind with registry
358 */
359 function SVNCommon()
360 {
361 global $viewsvn;
362
363 $this->registry =& $viewsvn;
364 }
365
366 /**
367 * Checks to see if the given universal path is
368 * a directory
369 *
370 * @access public
371 *
372 * @param string Universal path
373 *
374 * @return bool Directory or not
375 */
376 function isdir($path)
377 {
378 $output = $this->registry->svn->std('info', $this->registry->paths->fetch_repos($path), $this->registry->paths->fetch_path($path), $this->registry->paths->fetch_rev_num());
379
380 foreach ($output AS $line)
381 {
382 if (preg_match('#^Node Kind: (.*)#', $line, $matches))
383 {
384 if (trim(strtolower($matches[1])) == 'directory')
385 {
386 return true;
387 }
388 }
389 }
390
391 return false;
392 }
393
394 /**
395 * Get a list of revisions for a path
396 *
397 * @access public
398 *
399 * @param string Universal path
400 *
401 * @return array Key revisions
402 */
403 function fetch_revs($path)
404 {
405 if (!isset($this->revisions["$path"]))
406 {
407 $log = $this->fetch_logs($path);
408
409 $revs = array_keys($log);
410
411 $this->revisions["$path"] = array(
412 'HEAD' => $revs[0],
413 'START' => $revs[ count($revs) - 1 ],
414 'revs' => $revs
415 );
416 }
417
418 return $this->revisions["$path"];
419 }
420
421 /**
422 * Gets the revision that is marked as HEAD
423 *
424 * @access public
425 *
426 * @param string Universal path
427 *
428 * @return integer Revision
429 */
430 function fetch_head_rev($path)
431 {
432 $revs = $this->fetch_revs($path);
433 return $revs['HEAD'];
434 }
435
436 /**
437 * Returns the previous revision to the one given
438 *
439 * @access public
440 *
441 * @param string Universal path
442 * @param integer Arbitrary revision
443 *
444 * @return integer Previous revision (-1 if none)
445 */
446 function fetch_prev_rev($path, $current)
447 {
448 $revs = $this->fetch_revs($path);
449
450 if ($current == 'HEAD')
451 {
452 $current = $this->fetch_head_rev($path);
453 }
454
455 $index = array_search($current, $revs['revs']);
456 if ($current === false)
457 {
458 $message->trigger->error('revision ' . $current . ' is not in ' . $path);
459 }
460
461 if (isset($revs['revs'][ $index + 1 ]))
462 {
463 return $revs['revs'][ $index + 1 ];
464 }
465 else
466 {
467 return -1;
468 }
469 }
470
471 /**
472 * Get a list of logs
473 *
474 * @access public
475 *
476 * @param string Universal path
477 *
478 * @return array Log data
479 */
480 function fetch_logs($path)
481 {
482 if (!isset($this->logs["$path"]))
483 {
484 $log = new SVNLog($this->registry->paths->fetch_repos($path), $this->registry->paths->fetch_path($path), 0, 0);
485
486 $this->logs["$path"] = $log->fetch();
487 }
488
489 return $this->logs["$path"];
490 }
491
492 /**
493 * Returns a given log entry for a path
494 * and revision
495 *
496 * @access public
497 *
498 * @param string Universal path
499 * @param integer Arbitrary revision
500 *
501 * @return array Log entry
502 */
503 function fetch_log($path, $rev)
504 {
505 $logs = $this->fetch_logs($path);
506
507 $rev = $this->registry->svn->rev($rev);
508 if ($rev == 'HEAD')
509 {
510 $rev = $this->fetch_head_rev($path);
511 }
512
513 if (isset($logs["$rev"]))
514 {
515 return $logs["$rev"];
516 }
517 else
518 {
519 $keys = array_keys($logs);
520 sort($keys);
521
522 for ($i = 0; $i < count($keys); $i++)
523 {
524 if ($rev > $keys["$i"] AND $rev < $keys[ $i + 1 ])
525 {
526 return $logs["$keys[$i]"];
527 }
528 }
529
530 return null;
531 }
532 }
533
534 /**
535 * Prints the file changed list
536 *
537 * @access public
538 *
539 * @public array List of file changes
540 * @public string The repository
541 * @public integer Current revision
542 *
543 * @return string Processed HTML
544 */
545 function construct_file_changes($changes, $repos, $revision)
546 {
547 global $viewsvn;
548
549 $files = '';
550
551 foreach ($changes AS $file)
552 {
553 switch ($file['action'])
554 {
555 case 'A':
556 $class = 'file_add';
557 $tooltip = 'Added';
558 break;
559 case 'D':
560 $class = 'file_delete';
561 $tooltip = 'Deleted';
562 break;
563 case 'M':
564 $class = 'file_modify';
565 $tooltip = 'Modified';
566 break;
567 case 'R':
568 $class = 'file_replace';
569 $tooltip = 'Replaced';
570 break;
571 }
572
573 $show['from'] = (bool)$file['from'];
574
575 if ($file['from'])
576 {
577 $class = 'file_move';
578 $tooltip = 'Moved/Copied';
579 preg_match('#(.*):([0-9]+)#', $file['from'], $matches);
580 $link['from'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $matches[2]), $repos . $matches[1]);
581 }
582
583 $link['file'] = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $revision), $repos . $file['file']);
584
585 eval('$files .= "' . $viewsvn->template->fetch('file_change') . '";');
586 }
587
588 return $files;
589 }
590 }
591
592 /**
593 * Annotation/blame system; constructs an array
594 * that is ready for output
595 *
596 * @package ViewSVN
597 * @version $Id$
598 */
599 class SVNBlame
600 {
601 /**
602 * Array of blame information
603 * @var array
604 */
605 var $blame = array();
606
607 /**
608 * Raw "svn blame" output
609 * @var array
610 */
611 var $rawoutput;
612
613 /**
614 * Constructor: create blame and store data
615 *
616 * @param string Repository
617 * @param string Path
618 * @param integer Revision
619 */
620 function SVNBlame($repos, $path, $revision)
621 {
622 global $viewsvn;
623
624 $this->rawoutput = $viewsvn->svn->blame($repos, $path, $revision);
625 $this->process();
626 }
627
628 /**
629 * Returns blame for display
630 *
631 * @access public
632 *
633 * @return array Blame data
634 */
635 function fetch()
636 {
637 return $this->blame;
638 }
639
640 /**
641 * Parses the blame data
642 *
643 * @access private
644 */
645 function process()
646 {
647 $lineno = 1;
648
649 foreach ($this->rawoutput AS $line)
650 {
651 if (preg_match('#^\s+([0-9]+)\s+([\w\.\-_]+)\s(.*)$#', $line, $matches))
652 {
653 $this->blame[] = array(
654 'rev' => $matches[1],
655 'author' => $matches[2],
656 'line' => $matches[3],
657 'lineno' => $lineno++
658 );
659 }
660 // a blank line
661 else if (preg_match('#^\s+([0-9]+)\s+([\w\.\-_]+)$#', $line, $matches))
662 {
663 $this->blame[] = array(
664 'rev' => $matches[1],
665 'author' => $matches[2],
666 'line' => '',
667 'lineno' => $lineno++
668 );
669 }
670 }
671 }
672 }
673
674 /**
675 * Log management system; creates a complex list
676 * of SVN log information
677 *
678 * @package ViewSVN
679 * @version $Id$
680 */
681 class SVNLog
682 {
683 /**
684 * Array of logs
685 * @var array
686 */
687 var $logs = array();
688
689 /**
690 * Raw "svn log" output
691 * @var array
692 */
693 var $rawoutput;
694
695 /**
696 * Constructor: create log store for the given file
697 *
698 * @param string Repository
699 * @param string Path
700 * @param integer Lower revision
701 * @param integer Higher revision
702 */
703 function SVNLog($repos, $path, $lorev, $hirev)
704 {
705 global $viewsvn;
706
707 $this->rawoutput = $viewsvn->svn->log($repos, $path, $lorev, $hirev);
708 $this->process();
709 }
710
711 /**
712 * Returns logs for display
713 *
714 * @access public
715 *
716 * @return array Log data
717 */
718 function fetch()
719 {
720 return $this->logs;
721 }
722
723 /**
724 * Splits up the raw output into a usable log
725 *
726 * @access private
727 */
728 function process()
729 {
730 $lastrev = 0;
731
732 for ($i = 1; $i <= count($this->rawoutput) - 1; $i++)
733 {
734 $line = $this->rawoutput["$i"];
735
736 if (preg_match('#^r([0-9]*) \| (.*?) \| (....-..-.. ..:..:..) ([0-9\-]*) \((.*?)\) \| ([0-9]*) lines?$#', $line, $matches))
737 {
738 if (isset($this->logs["$lastrev"]))
739 {
740 $this->logs["$lastrev"]['message'] = $this->strip_last_line($this->logs["$lastrev"]['message']);
741 }
742
743 $this->logs["$matches[1]"] = array(
744 'rev' => $matches[1],
745 'author' => $matches[2],
746 'date' => $matches[3],
747 'timezone' => $matches[4],
748 'lines' => $matches[6],
749 'message' => ''
750 );
751
752 $lastrev = $matches[1];
753 }
754 else if (preg_match('#^\s+([ADMR])\s(.*)#', $line, $matches))
755 {
756 if (preg_match('#(.*) \(from (.*?)\)$#', $matches[2], $amatches))
757 {
758 $matches[2] = $amatches[1];
759 }
760
761 $this->logs["$lastrev"]['files'][] = array(
762 'action' => $matches[1],
763 'file' => trim($matches[2]),
764 'from' => (isset($amatches[2]) ? $amatches[2] : '')
765 );
766 }
767 else
768 {
769 if (trim($line) != 'Changed paths:')
770 {
771 $this->logs["$lastrev"]['message'] .= $line . "\n";
772 }
773 }
774 }
775
776 if (isset($this->logs["$lastrev"]))
777 {
778 $this->logs["$lastrev"]['message'] = $this->strip_last_line($this->logs["$lastrev"]['message']);
779 }
780 }
781
782 /**
783 * Trims the last dash line off a message
784 *
785 * @access private
786 *
787 * @param string Message with annoying-ass line
788 *
789 * @return string Clean string
790 */
791 function strip_last_line($string)
792 {
793 return trim(preg_replace("#\n(.*?)\n$#", '', $string));
794 }
795 }
796
797 /**
798 * Diff system; constructs a diff array that
799 * is ready for output
800 *
801 * @package ViewSVN
802 */
803 class SVNDiff
804 {
805 /**
806 * Array of diff information
807 * @var array
808 */
809 var $diff = array();
810
811 /**
812 * Raw "svn diff" output
813 * @var array
814 */
815 var $rawoutput;
816
817 /**
818 * Constructor: create and store diff data
819 *
820 * @param string Repository
821 * @param string Path
822 * @param integer Lower revision
823 * @param integer Higher revision
824 */
825 function SVNDiff($repos, $path, $lorev, $hirev)
826 {
827 global $viewsvn;
828
829 $this->rawoutput = $viewsvn->svn->diff($repos, $path, $lorev, $hirev);
830 $this->process();
831 }
832
833 /**
834 * Returns diffs for display
835 *
836 * @access public
837 *
838 * @return array Diff data
839 */
840 function fetch()
841 {
842 return $this->diff;
843 }
844
845 /**
846 * Processes and prepares diff data
847 *
848 * @access private
849 */
850 function process()
851 {
852 $chunk = 0;
853 $indexcounter = null;
854
855 $delstack = array();
856
857 foreach ($this->rawoutput AS $line)
858 {
859 if (preg_match('#^@@ \-([0-9]*),([0-9]*) \+([0-9]*),([0-9]*) @@$#', $line, $bits))
860 {
861 $delstack = array();
862 $this->diff["$index"][ ++$chunk ]['hunk'] = array('old' => array('line' => $bits[1], 'count' => $bits[2]), 'new' => array('line' => $bits[3], 'count' => $bits[4]));
863 $lines['old'] = $this->diff["$index"]["$chunk"]['hunk']['old']['line'] - 1;
864 $lines['new'] = $this->diff["$index"]["$chunk"]['hunk']['new']['line'] - 1;
865 continue;
866 }
867
868 if ($indexcounter <= 3 AND $indexcounter !== null)
869 {
870 //echo $line . "\n";
871 $indexcounter++;
872 continue;
873 }
874 else if ($indexcounter == 3)
875 {
876 $indexcounter = null;
877 //echo "\n\n\n";
878 continue;
879 }
880
881 if (preg_match('#^([\+\- ])(.*)#', $line, $matches))
882 {
883 $act = $matches[1];
884 $content = $matches[2];
885
886 if ($act == ' ')
887 {
888 $this->diff["$index"]["$chunk"][] = array(
889 'line' => $content,
890 'act' => '',
891 'oldlineno' => ++$lines['old'],
892 'newlineno' => ++$lines['new']
893 );
894
895 $delstack = array();
896 }
897 else if ($act == '+')
898 {
899 // potential line delta
900 if (count($delstack) > 0)
901 {
902 $lastline = array_shift($delstack);
903
904 if ($delta = @$this->fetch_diff_extent($lastline['line'], $content))
905 {
906 // create two sets of ends for the two contents
907 $delta['endo'] = strlen($lastline['line']) - $delta['end'];
908 $delta['endn'] = strlen($content) - $delta['end'];
909
910 $diffo = $delta['endo'] - $delta['start'];
911 $diffn = $delta['endn'] - $delta['start'];
912
913 if (strlen($lastline['line']) > $delta['endo'] - $diffo)
914 {
915 $removed = substr($lastline['line'], $delta['start'], $diffo);
916 $this->diff["$index"]["$chunk"]["$lastline[INDEX]"]['line'] = substr_replace($lastline['line'], '{@-' . '-}' . $removed . '{/@-' . '-}', $delta['start'], $diffo);
917 }
918
919 if (strlen($content) > $delta['endn'] - $diffn)
920 {
921 $added = substr($content, $delta['start'], $diffn);
922 $content = substr_replace($content, '{@+' . '+}' . $added . '{/@+' . '+}', $delta['start'], $diffn);
923 }
924 }
925 }
926
927 $this->diff["$index"]["$chunk"][] = array(
928 'line' => $content,
929 'act' => '+',
930 'oldlineno' => '',
931 'newlineno' => ++$lines['new']
932 );
933 }
934 else if ($act == '-')
935 {
936 $this->diff["$index"]["$chunk"][] = $thearray = array(
937 'line' => $content,
938 'act' => '-',
939 'oldlineno' => ++$lines['old'],
940 'newlineno' => ''
941 );
942
943 $key = count($this->diff["$index"]["$chunk"]) - 2;
944 $thearray['INDEX'] = $key;
945
946 array_push($delstack, $thearray);
947 }
948 }
949 // whitespace lines
950 else
951 {
952 if (preg_match('#^Index: (.*?)$#', $line, $matches))
953 {
954 $index = $matches[1];
955 $indexcounter = 1;
956 $chunk = 0;
957 continue;
958 }
959
960 $this->diff["$index"]["$chunk"][] = array(
961 'line' => '',
962 'act' => '',
963 'oldlineno' => ++$lines['old'],
964 'newlineno' => ++$lines['new']
965 );
966
967 $delstack = array();
968 }
969 }
970 }
971
972 /**
973 * Returns the amount of change that occured
974 * between two lines
975 *
976 * @access private
977 *
978 * @param string Old line
979 * @param string New line
980 *
981 * @return array Difference of positions
982 */
983 function fetch_diff_extent($old, $new)
984 {
985 $start = 0;
986 $min = min(strlen($old), strlen($new));
987
988 for ($start = 0; $start < $min; $start++)
989 {
990 if ($old{"$start"} != $new{"$start"})
991 {
992 break;
993 }
994 }
995
996 $max = max(strlen($old), strlen($new));
997
998 for ($end = 0; $end < $min; $end++)
999 {
1000 $oldpos = strlen($old) - $end;
1001 $newpos = strlen($new) - $end;
1002
1003 if ($old{"$oldpos"} != $new{"$newpos"})
1004 {
1005 break;
1006 }
1007 }
1008
1009 $end--;
1010
1011 if ($start == 0 AND $end == $max)
1012 {
1013 return false;
1014 }
1015
1016 return array('start' => $start, 'end' => $end);
1017 }
1018 }
1019
1020 /*=====================================================================*\
1021 || ###################################################################
1022 || # $HeadURL$
1023 || # $Id$
1024 || ###################################################################
1025 \*=====================================================================*/
1026 ?>