From f04073216a2bffdeb6ede3a62fdbdef0fa5c819b Mon Sep 17 00:00:00 2001 From: SBeans Date: Tue, 27 Nov 2012 17:27:00 +0000 Subject: Fixed -l output so that it will only return a page of results if it exists, if not it will just say "no More Source found" --- blasource.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'blasource.php') diff --git a/blasource.php b/blasource.php index 5ae752b..87c0872 100644 --- a/blasource.php +++ b/blasource.php @@ -5,10 +5,11 @@ // Version History // 0.0.1 Created blasource.php - // 0.0.2 Added -l option for listing for sources. - // 0.0.3 Fixed -l option for listing for sources. + // 0.1.0 Added -l option for listing for sources. + // 0.1.1 Fixed -l option for listing for sources. + // 0.1.2 Checked -l page number to see if there are any results. - $version = "BlaSource Version: 0.0.3"; + $version = "BlaSource Version: 0.1.2"; // get the input $stdin = read_stdin(); @@ -20,16 +21,29 @@ switch ($stdin[$i]) { case "-l": + $last = str_replace(":", "",exec("grep -n \"\" blasource.txt | tail -n 1")) / 5 + 1; + $look = 0; if(!isset($stdin[$i+1])) { - $n = 1; + $look = 1; } else { - $n=$stdin[$i+1]; - $i++; + if($stdin[$i+1] > $last) + { + echo "No more source found."; + $i++; + break; + } + else + { + $look = $stdin[$i+1]; + $i++; + } } - $X = ($n*5)-5; + + + $X = ($look*5)-5; for($j=0;$j<5;$j++) { $bla = $j+$X; -- cgit v1.2.3