diff --git a/.gitignore b/.gitignore index ca5166b..d20a3fc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ release.sh /.d* design/custom/* design_cpl/* +.esniper/ **/css/bootstrap*.css **/js/bootstrap*.js diff --git a/.version b/.version index 3e1ad72..ce6a70b 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.5.0 \ No newline at end of file +1.6.0 \ No newline at end of file diff --git a/HOOKS.md b/HOOKS.md index 2e9504f..707944f 100644 --- a/HOOKS.md +++ b/HOOKS.md @@ -2,28 +2,23 @@ Some hooks have a **parameter by reference**. -Please refer to source code for context. - -## index.php - - Line 28 : Hook::apply('init') - Line 58 : Hook::apply('config.loaded', $config) - Line 77 : Hook::apply('before.action', $page) - Line 93 : Hook::apply('template.compile', $html) - Line 114 : Hook::apply('template.compiled', $html) - Line 121 : Hook::apply('template.compressed', $html) - Line 128 : Hook::apply('before.render') - Line 133 : Hook::apply('after.render') - -## app/mef/Snipe.php - - Line 92 : Hook::apply('snipe.loaded', $this) - Line 115 : Hook::apply('snipe.loaded', $this) - -## design/default/index.html - - Line 36 : Hook::apply('head.style') - Line 37 : Hook::apply('head.script') - Line 43 : Hook::apply('before.content') - Line 61 : Hook::apply('after.content') - Line 66 : Hook::apply('body.script') +Please refer to the source code to find out more about the context of the hook. + + +--------------------------------+------+-----------------------------------------------+ + | File | Line | Hook call | + +--------------------------------+------+-----------------------------------------------+ + | index.php | 27 | Hook::apply('init') | + | index.php | 58 | Hook::apply('config.loaded', $config) | + | index.php | 78 | Hook::apply('before.action', $page) | + | index.php | 96 | Hook::apply('template.compile', $html) | + | index.php | 117 | Hook::apply('template.compiled', $html) | + | index.php | 124 | Hook::apply('template.compressed', $html) | + | index.php | 131 | Hook::apply('before.render') | + | index.php | 136 | Hook::apply('after.render') | + | app/mef/Snipe.php | 98 | Hook::apply('snipe.loaded', $this) | + | app/mef/Snipe.php | 121 | Hook::apply('snipe.loaded', $this) | + | design/default/index.html | 36 | Hook::apply('head.style') | + | design/default/index.html | 43 | Hook::apply('before.content') | + | design/default/index.html | 62 | Hook::apply('after.content') | + | design/default/index.html | 69 | Hook::apply('body.script') | + +--------------------------------+------+-----------------------------------------------+ diff --git a/README.md b/README.md index 6450f48..b509d83 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # A minimal esniper web frontend +![](https://img.shields.io/github/release/K-Ko/MiniEsniperWebFrontend.svg) + This repo will cover the handling of [esniper](http://esniper.sourceforge.net/), a lightweight eBay sniping tool. It works directly with the files created by esniper. diff --git a/api.php b/api.php index 51eb84b..675a44e 100644 --- a/api.php +++ b/api.php @@ -21,7 +21,7 @@ $result = ''; -if ($snipe = $snipes->find($GET['token'])) { +if (isset($snipes) && $snipe = $snipes->find($GET['token'])) { switch ($GET['api']) { // --------------- case 'edit': @@ -54,7 +54,8 @@ [ 'bug' => FILTER_SANITIZE_STRING, 'name' => FILTER_SANITIZE_STRING, - 'item' => FILTER_SANITIZE_STRING + 'item' => FILTER_SANITIZE_STRING, + 'ship' => FILTER_SANITIZE_STRING ], true )); @@ -74,15 +75,21 @@ // Need user for snipe instance to have a data path mef\User::init($GET['token'], null); + $name = urldecode($GET['name']); + // Ebay uses " as quotes in auction names + $name = str_replace('"', '"', $name); + // Trim auction title title to max. 40 chars, don't split words - $name = substr($GET['name'], 0, 40); - while (strlen($name) && substr($name, -1) != ' ') { - $name = substr($name, 0, -1); - } + // $name = substr($name, 0, 40); + // while (strlen($name) && substr($name, -1) != ' ') { + // $name = substr($name, 0, -1); + // } $snipe = new mef\Snipe( trim($name), - '# Define your price #' . PHP_EOL . $GET['item'] + '# Shipping: ' . urldecode($GET['ship']) . PHP_EOL . + '# Adjust your price!' . PHP_EOL . + $GET['item'] . ' 1.00' ); $result = $snipe->save() diff --git a/app/console b/app/console.php similarity index 95% rename from app/console rename to app/console.php index bc49920..57b46e2 100755 --- a/app/console +++ b/app/console.php @@ -12,8 +12,8 @@ function usage($rc = 0) global $argv; echo PHP_EOL; - echo 'Minimal esniper web frontend v', trim(file_get_contents('.version')), PHP_EOL, PHP_EOL; - echo "Usage: $argv[0] [command options]", PHP_EOL, PHP_EOL; + echo 'Minimal esniper web frontend console v', trim(file_get_contents('.version')), PHP_EOL, PHP_EOL; + echo "Usage: $argv[0] [options]", PHP_EOL, PHP_EOL; echo " $argv[0] start Start missing esniper processes", PHP_EOL; echo " $argv[0] start Start esniper for group", PHP_EOL; echo " $argv[0] restart Restart all esniper processes", PHP_EOL; diff --git a/app/mef/Config.php b/app/mef/Config.php index cf79afd..0333de8 100644 --- a/app/mef/Config.php +++ b/app/mef/Config.php @@ -62,7 +62,7 @@ public function get($name, $default = null) * * @param string $name * @param mixed $value - * @return Instance + * @return Instance $this for fluid interface */ public function set($name, $value) { diff --git a/app/mef/Snipe.php b/app/mef/Snipe.php index 4d3aa77..768d4c2 100644 --- a/app/mef/Snipe.php +++ b/app/mef/Snipe.php @@ -27,6 +27,13 @@ class Snipe */ public $data; + /** + * End time(s) + * + * @var string + */ + public $end; + /** * esniper log * @@ -130,7 +137,7 @@ public function save() sprintf( 'name = "%2$s"%1$s%1$sdata = "%3$s%1$s"%1$s', PHP_EOL, - $this->name, + str_replace('"', '\\"', $this->name), trim($this->data) ) ); @@ -324,6 +331,7 @@ protected function reset() { $this->name = ''; $this->data = ''; + $this->end = ''; $this->log = ''; $this->won = false; $this->pid = 0; @@ -354,6 +362,27 @@ protected function getLog() } } + // Get auction end time + if (preg_match_all('~End time: *(.*)$~m', $log, $args)) { + // Get last end time from log + $ts = strptime(array_pop($args[1]), '%d/%m/%Y %H:%M:%S'); + + // Make timestamp for reformating + $ts = mktime( + $ts['tm_hour'], + $ts['tm_min'], + $ts['tm_sec'], + $ts['tm_mon'] + 1, + $ts['tm_mday'], + $ts['tm_year'] + 1900 + ); + + // Not ended auction? + if ($ts > time()) { + $this->end = date(I18N::_('timestamp_format'), $ts); + } + } + return $log; } } diff --git a/config.default.php b/config.default.php index 771037f..13282ec 100644 --- a/config.default.php +++ b/config.default.php @@ -67,10 +67,5 @@ /** * Inital language */ - 'language' => 'en', - - /** - * Only for development - */ - 'debug' => false, + 'language' => 'en' ]; diff --git a/design/default/css/style.css b/design/default/css/style.css index cbc0a32..637023a 100644 --- a/design/default/css/style.css +++ b/design/default/css/style.css @@ -17,7 +17,8 @@ form { display: inline; } -a, .btn-link { +a, +.btn-link { text-decoration: none !important; color: maroon; } @@ -41,8 +42,8 @@ a, .btn-link { } textarea, -input[type=text] { - padding: .25em .5em; +input[type='text'] { + padding: 0.25em 0.5em; } .pre { diff --git a/design/default/home.html b/design/default/home.html index 1f8319b..9575d74 100644 --- a/design/default/home.html +++ b/design/default/home.html @@ -1,12 +1,14 @@
- +
{{echo mef\User::$name}} {{echo mef\User::$name}}
-
@@ -18,7 +20,7 @@
- +
@@ -29,7 +31,8 @@ {|group_hint|}
- + {|group_hint|}
@@ -43,7 +46,8 @@
- + {|auction_hint|}
@@ -53,10 +57,12 @@
- +
- +
@@ -72,30 +78,37 @@ {{foreach ($snipes as $snipe): $token = $snipe->getNameHash()}}
- {{$snipe->name}} - {{if ($snipe->won):}} -
+ {{$snipe->name}} + {{if ($snipe->end):}} +
+ {{$snipe->end}} + {{elseif ($snipe->won):}} +
{{$snipe->won}}
{{endif}}
-
+
- + - - - @@ -105,7 +118,9 @@
-
{{if ($snipe->log):}}{{$snipe->log}}{{else:}}No auction log{{endif}}
+
+ {{if ($snipe->log):}}{{$snipe->log}}{{else:}}No auction + log{{endif}}
{{endforeach}} @@ -121,16 +136,21 @@ {{foreach ($bugs as $bug):}} {{endforeach}} - @@ -146,11 +166,14 @@
- Minimal esniper web frontend + + Minimal esniper web frontend
- v{{$config->version}}, check on - + v{{$config->version}}, + check on + GitHub for updates @@ -158,8 +181,37 @@
diff --git a/design/default/index.html b/design/default/index.html index b769ea9..fa31d9f 100644 --- a/design/default/index.html +++ b/design/default/index.html @@ -29,24 +29,26 @@ {{$config->title}} - + - + -
+
{{echo mef\Hook::apply('before.content')}} {{if (isset($_SESSION['message'])):}}