-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgarefspam
executable file
·57 lines (53 loc) · 2.02 KB
/
garefspam
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
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
use GeneralRedneck\GaReferrerSpamFilters\Command\ListAccountsCommand;
use GeneralRedneck\GaReferrerSpamFilters\Command\ListPropertiesCommand;
use GeneralRedneck\GaReferrerSpamFilters\Command\ListViewsCommand;
use GeneralRedneck\GaReferrerSpamFilters\Command\UpdateGaFiltersCommand;
use GeneralRedneck\GaReferrerSpamFilters\Command\UpdateSpamListCommand;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Yaml\Yaml;
$application = new Application('GA Referrer Spam Filters', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'version'));
$configValues = array(
'service-email' => '',
'key-location' => __DIR__ . DIRECTORY_SEPARATOR . 'client_secrets.p12',
'domain-list-location' => __DIR__ . DIRECTORY_SEPARATOR . 'spammers.txt',
);
$configDirectories = array(__DIR__);
try {
$locator = new FileLocator($configDirectories);
$configFile = $locator->locate('config.yml', null, true);
$configFileValues = Yaml::parse(file_get_contents($configFile));
// This may not be reached if the file doesn't exist.
$configValues = $configFileValues + $configValues;
}
catch(\InvalidArgumentException $e) {
// File was not found.
}
$application->config = $configValues;
// Add global Options to the Application
$application->getDefinition()->addOptions(array(
new InputOption(
'--service-email',
'-e',
InputOption::VALUE_OPTIONAL,
'The service email to use to connect to Google Analytics',
$configValues['service-email']
),
new InputOption(
'--key-location',
'-k',
InputOption::VALUE_OPTIONAL,
'The p12 key file used to connect to Google Analytics',
$configValues['key-location']
)
));
$application->add(new ListAccountsCommand());
$application->add(new UpdateSpamListCommand());
$application->add(new UpdateGaFiltersCommand());
$application->add(new ListPropertiesCommand());
$application->add(new ListViewsCommand());
$application->run();