summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSBeans <info@kayakporn.com>2012-11-27 17:27:00 +0000
committerSBeans <info@kayakporn.com>2012-11-27 17:27:00 +0000
commitf04073216a2bffdeb6ede3a62fdbdef0fa5c819b (patch)
treee3bffcc4bcd4437ba0f7a41d2a63816e3e3593bc
parent2ef98b6dc895007c71def6c9b41fae5e6844366e (diff)
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"
-rw-r--r--blasource.php28
1 files changed, 21 insertions, 7 deletions
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;