Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
* release/1.6.0:
  Bumped version to 1.6.0
  Add page reload on page becomes visible/active
  Fix handling of quotes in auction titles
  Add end time to auction group header
  Fix edit rename
  • Loading branch information
K-Ko committed Oct 15, 2018
2 parents bf99f83 + 0692e60 commit b281cf3
Show file tree
Hide file tree
Showing 19 changed files with 376 additions and 96 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ release.sh
/.d*
design/custom/*
design_cpl/*
.esniper/

**/css/bootstrap*.css
**/js/bootstrap*.js
Expand Down
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.6.0
45 changes: 20 additions & 25 deletions HOOKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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') |
+--------------------------------+------+-----------------------------------------------+
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
21 changes: 14 additions & 7 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

$result = '';

if ($snipe = $snipes->find($GET['token'])) {
if (isset($snipes) && $snipe = $snipes->find($GET['token'])) {
switch ($GET['api']) {
// ---------------
case 'edit':
Expand Down Expand Up @@ -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
));
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions app/console → app/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -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> [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] <command> [options]", PHP_EOL, PHP_EOL;
echo " $argv[0] start <ebay user name> <password> Start missing esniper processes", PHP_EOL;
echo " $argv[0] start <ebay user name> <password> <group> Start esniper for group", PHP_EOL;
echo " $argv[0] restart <ebay user name> <password> Restart all esniper processes", PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion app/mef/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
31 changes: 30 additions & 1 deletion app/mef/Snipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Snipe
*/
public $data;

/**
* End time(s)
*
* @var string
*/
public $end;

/**
* esniper log
*
Expand Down Expand Up @@ -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)
)
);
Expand Down Expand Up @@ -324,6 +331,7 @@ protected function reset()
{
$this->name = '';
$this->data = '';
$this->end = '';
$this->log = '';
$this->won = false;
$this->pid = 0;
Expand Down Expand Up @@ -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;
}
}
Expand Down
7 changes: 1 addition & 6 deletions config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,5 @@
/**
* Inital language
*/
'language' => 'en',

/**
* Only for development
*/
'debug' => false,
'language' => 'en'
];
7 changes: 4 additions & 3 deletions design/default/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ form {
display: inline;
}

a, .btn-link {
a,
.btn-link {
text-decoration: none !important;
color: maroon;
}
Expand All @@ -41,8 +42,8 @@ a, .btn-link {
}

textarea,
input[type=text] {
padding: .25em .5em;
input[type='text'] {
padding: 0.25em 0.5em;
}

.pre {
Expand Down
Loading

0 comments on commit b281cf3

Please sign in to comment.