public function tearDown()
 {
     $this->builders = null;
     parent::tearDown();
     $this->logger->close();
     $this->DAO = null;
 }
 public function tearDown()
 {
     $this->builders = null;
     $this->logger->close();
     $this->instance = null;
     $this->api = null;
     parent::tearDown();
 }
Exemple #3
0
function flickrthumbnails_crawl()
{
    global $THINKTANK_CFG;
    global $db;
    global $conn;
    if (isset($THINKTANK_CFG['flickr_api_key']) && $THINKTANK_CFG['flickr_api_key'] != '') {
        $logger = new Logger($THINKTANK_CFG['log_location']);
        $fa = new FlickrAPIAccessor($THINKTANK_CFG['flickr_api_key'], $logger);
        $ldao = new LinkDAO($db, $logger);
        $flickrlinkstoexpand = $ldao->getLinksToExpandByURL('http://flic.kr/');
        if (count($flickrlinkstoexpand > 0)) {
            $logger->logStatus(count($flickrlinkstoexpand) . " Flickr links to expand", "Flickr Plugin");
        } else {
            $logger->logStatus("No Flickr links to expand", "Flickr Plugin");
        }
        foreach ($flickrlinkstoexpand as $fl) {
            $eurl = $fa->getFlickrPhotoSource($fl);
            if ($eurl["expanded_url"] != '') {
                $ldao->saveExpandedUrl($fl, $eurl["expanded_url"], '', 1);
            } elseif ($eurl["error"] != '') {
                $ldao->saveExpansionError($fl, $eurl["error"]);
            }
        }
        $logger->close();
        # Close logging
    }
}
 function testGetFlickrPhotoSourceSuccess()
 {
     global $THINKUP_CFG;
     $logger = new Logger($THINKUP_CFG['log_location']);
     $fa = new FlickrAPIAccessor('dummykey', $logger);
     $this->assertTrue(isset($fa));
     $eurl = $fa->getFlickrPhotoSource('http://flic.kr/p/7QAWC7');
     $this->assertEqual($eurl["expanded_url"], 'http://farm3.static.flickr.com/2755/4488149974_04d9558212_m.jpg');
     $logger->close();
 }
Exemple #5
0
 function testCreatingNewLogger()
 {
     global $THINKTANK_CFG;
     $logger = new Logger($THINKTANK_CFG['log_location']);
     $logger->logStatus('Should write this to the log', get_class($this));
     $this->assertTrue(file_exists($THINKTANK_CFG['log_location']), 'File created');
     $messages = file($THINKTANK_CFG['log_location']);
     $this->assertWantedPattern('/Should write this to the log/', $messages[sizeof($messages) - 1]);
     $logger->setUsername('ginatrapani');
     $logger->logStatus('Should write this to the log with a username', get_class($this));
     $this->assertWantedPattern('/ginatrapani | TestOfLogging:Should write this to the log/', $messages[sizeof($messages) - 1]);
     $logger->close();
 }
Exemple #6
0
 function testGetFlickrPhotoSource()
 {
     global $THINKTANK_CFG;
     $logger = new Logger($THINKTANK_CFG['log_location']);
     $fa = new FlickrAPIAccessor($THINKTANK_CFG['flickr_api_key'], $logger);
     $this->assertTrue(isset($fa));
     $eurl = $fa->getFlickrPhotoSource('http://flic.kr/p/7QAWC7');
     $this->assertEqual($eurl["expanded_url"], 'http://farm3.static.flickr.com/2755/4488149974_04d9558212_m.jpg');
     $eurl = $fa->getFlickrPhotoSource('http://flic.kr/p/6YS7AE');
     $this->assertEqual($eurl["expanded_url"], '');
     $this->assertEqual($eurl["error"], 'Photo not found');
     $logger->close();
 }
 function testSetLogFile()
 {
     $l = new Logger();
     $file = '/tmp/' . rand() . '.log';
     if (file_exists($file)) {
         unlink($file);
     }
     $l->setLogFile($file);
     $l->log('test');
     $l->close();
     $this->assertEquals($file, $l->getLogFile());
     $this->assert(!file_exists($file), "File was created");
     if (file_exists($file)) {
         unlink($file);
     }
 }
 public function tearDown() {
     $this->logger->close();
     parent::tearDown();
 }
Exemple #9
0
        $data->setBranch($_GET['ref']);
    }
    if (isset($_GET['repo'])) {
        $data->setRepoName($_GET['repo']);
    }
    $config = new Config($conf);
    $config->setBranch($data->getBranch())->setName($data->getRepoName());
    $log->append('origin user: '******'repo: ' . $data->getRepoName());
    $log->append('branch: ' . $data->getBranch());
    $total_added = 0;
    if (!($jobs = $conf['jobber']->getJobsFileHandle('a'))) {
        $log->append('Invalid log configuration.');
    } elseif ($jobs && ($commands = $config->getJobs())) {
        foreach ($commands as $cmd) {
            fwrite($jobs, $cmd . PHP_EOL);
            $log->header();
            ++$total_added;
        }
    }
    fclose($jobs);
    if ($total_added) {
        $log->append('jobs added: ' . $total_added);
    }
} else {
    header("HTTP/1.0 401 Access Denied");
    $log->append('401: Access Denied');
}
$log->close();
header("Content Type: text/html");
print '<p>' . $log->view("</p>\n</p>") . '</p>' . PHP_EOL;
Exemple #10
0
            throw new Exception(__METHOD__ . " - cPanel installation failed: {$message}");
        }
        $logger->progress($message);
        array_push($responseArray['content'], $message);
        $responseArray['status'] = 1;
        return $responseArray;
    } else {
        $instructions = "You have disabled the function \"{$func}\" in your PHP configuration.\n\n\t\tTherefore, the installation cannot be finished.\n\n\t\tTake the following steps to complete the cPanel installation:\n\n\t\t\t1.) Run \"\$ /usr/local/nimbusec/nimbusec/hooks/install.sh\" to ensure that necessary internal script hooks are being included by WHM.\n\n\t\t\t2.) Run \"\$ /usr/local/nimbusec/nimbusec/cpanel_plugin/install.sh\" to install the Nimbusec plugin on cPanel side.\n\n\t\t\t3.) Only when the script were executed successfully, add the following line to /var/cpanel/whm/nvdata/root.yaml which contains all environmental variables\n\n\t\t\t- \"NIMBUSEC_INSTALLED: 1\" - or change the value to 1 if the field already exists.\n\t\t\t4.) Afterwards, refresh the WHM plugin page to continue.\n\t\tAlternatively, you may want to re-enable the affected function in your configuration and try it again.";
        $logger->error($instructions);
        array_push($responseArray['content'], "Nimbusec installation aborted...");
        return $responseArray;
    }
} catch (CUrlException $exp) {
    $logger->error("[CURL SPECIFIC ERROR] in {$exp->getFile()}: {$exp->getMessage()} at line {$exp->getLine()}");
    $logger->info("Nimbusec installation aborted...");
    $logger->close();
    array_push($responseArray['content'], "Nimbusec installation aborted...");
    return $responseArray;
} catch (NimbusecException $exp) {
    $logger->error("[Nimbusec SPECIFIC ERROR] in {$exp->getFile()}: {$exp->getMessage()} at line {$exp->getLine()}");
    $logger->info("Nimbusec installation aborted...");
    $logger->close();
    array_push($responseArray['content'], "Nimbusec installation aborted...");
    return $responseArray;
} catch (WHMException $exp) {
    $logger->error("[WHM SPECIFIC ERROR] in {$exp->getFile()}: {$exp->getMessage()} at line {$exp->getLine()}");
    $logger->info("Nimbusec installation aborted...");
    $logger->close();
    array_push($responseArray['content'], "Nimbusec installation aborted...");
    return $responseArray;
} catch (Exception $exp) {