-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
79 lines (49 loc) · 1.73 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('memory_limit', "8M");
require dirname(__FILE__).'/DealsStatsEnv.php';
require dirname(__FILE__).'/conf/__init_conf__.php';
$conf = dealstats_read_config_file('default');
DealsStatsEnv::setEnvConfig($conf);
require dirname(__FILE__).'/parser/__init__.php';
require dirname(__FILE__).'/WebPageHarvester.php';
require 'phpQuery.php';
// Cykl zycia
// ----------
// 1. pobieramy grupy ofert dla portalu (np. miasta)
$site = 'citeam.pl';
$ct = new CiteamParser();
$groups = $ct->getDealsGroups();
// 2. z bazy wyciagamy oferty, ktore w danej grupie powinny byc jeszcze aktywne
$dbRoot = dirname(__FILE__).'/db/';
$db = new SQLite3($dbRoot.$site.'.sqlite3');
$offers = array();
foreach($groups as $groupName => $groupData)
{
echo $groupName.PHP_EOL;
$offers += $ct->getGroupOffers($groupName);
}
// 3. ze strony pobieramy dostepna liste ofert dla danej grupy
// 4. weryfikujemy, czy pojawily sie nowe oferty
// 4.1. jesli tak pobieramy o nich informacje
// 5. aktualizujemy informacje o trwajacych ofertach:
// - ilosc sprzedanych kuponow
// - status (aktywna/wyprzedana)
die();
$offers = isort($offers, 'sold');
foreach($offers as $offer)
{
$end_time = $offer['endingTime'] - time();
$timeLeft = time_difference($end_time);
$offer = (object)$offer;
echo "[$offer->group]\t$offer->title}\n"
."[$offer->id][$offer->status]\t"
."[Price: $offer->priceRegular -> $offer->pricePromo]\t"
."[Sold: $offer->sold]\t"
."[Ending: ".date("Y-m-d H:i:s", $offer->endingTime)."]\t"
."[Left: ${timeLeft['days']}d ${timeLeft['hours']}h "
."${timeLeft['mins']}m ${timeLeft['secs']}s]\n"
// ."=================================================================\n"
.str_repeat("=", 90)."\n"
."\n";
}