-
Notifications
You must be signed in to change notification settings - Fork 0
/
chameleoncrawl.php
41 lines (33 loc) · 1.6 KB
/
chameleoncrawl.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
<?php
// Call with JSON parameter like so
//'{"installation_name":"mwilkie", "timezone":"America/Los_Angeles", "db_host":"localhost", "db_name":"thinkup_20120911", "db_socket":"/tmp/mysql.sock", "db_port":""}';
$passed_in = $argv[1];
require_once 'config.inc.php';
// Go to ThinkUp root dir
chdir(dirname(__FILE__) . "/../..");
require_once 'init.php';
$params = JSONDecoder::decode($passed_in);
$CHAM_CONFIG['timezone'] = $params->timezone;
$CHAM_CONFIG['db_host'] = $params->db_host;
$CHAM_CONFIG['db_name'] = $params->db_name;
$CHAM_CONFIG['db_socket'] = $params->db_socket;
$CHAM_CONFIG['db_port'] = $params->db_port;
$CHAM_CONFIG['source_root_path'] = getcwd();
//Commenting this out to use the single common data directory, as all the users' dirs aren't created on crawlers
//$CHAM_CONFIG['datadir_path'] = $CHAM_CONFIG['data_dir_root'] . $params->installation_name.'/';
if (strpos($CHAM_CONFIG['site_root_path'], '{user}') !== false ) {
$CHAM_CONFIG['site_root_path'] = str_replace('{user}', $params->installation_name, $CHAM_CONFIG['site_root_path']);
}
//DEBUG
//Uncomment out next section if logs should go to filesystem instead of into the database
/*
$CHAM_CONFIG['log_location'] = $CHAM_CONFIG['data_dir_path'] . 'crawler.log';
$logger = Logger::getInstance($CHAM_CONFIG['log_location']);
*/
//DEBUG
//echo Utils::varDumpToString($params);
//echo Utils::varDumpToString($CHAM_CONFIG);
$cfg = Config::getInstance($CHAM_CONFIG);
$credentials = array('crawl.php', $CHAM_CONFIG['thinkup_username'], $CHAM_CONFIG['thinkup_password']);
$controller = new CrawlerAuthController(3, $credentials);
echo $controller->go();