Beispiel #1
0
 function __construct($json)
 {
     if (!($json = json_decode($json))) {
         $spider = new CableSpider();
         $json = $spider->getJson($input);
         unset($spider);
     }
     $this->originalJson = $json;
     $cable = json_decode($json);
     if (!is_array($cable->tags)) {
         $cable->tags = explode(';', $cable->tags);
     } else {
         if (strstr($cable->tags[0], ';')) {
             $cable->tags = explode(';', $cable->tags[0]);
         }
     }
     $this->attributes = array('identifier' => $cable->identifier, 'id' => $cable->identifier, 'released' => $cable->released, 'date_sent' => $cable->date_sent, 'date' => $cable->date_sent, 'created' => $cable->date_sent, 'origin' => $cable->office, 'from' => $cable->office, 'office' => $cable->office, 'tags' => $cable->tags, 'subject' => $cable->subject, 'header' => self::parseHeader($cable->header), 'head' => self::parseHeader($cable->header), 'body' => self::parseBodyContent($cable->body), 'content' => self::parseBodyContent($cable->body), 'bodyheader' => self::parseBodyHeader($cable->body), 'classification' => self::parseClassification($cable->classification), 'taglist' => self::parseTags($cable->tags), 'author' => self::parseAuthor($cable->body), 'urgency' => self::parseUrgency($cable->header), 'destination' => self::parseDestination($cable->header), 'info' => self::parseInfo($cable->header));
     $this->attributes['categories'] = self::parseCategories($this);
 }
Beispiel #2
0
<?php

if (!function_exists('php_sapi_name')) {
    die("Sorry this won't work on your server because your PHP install doesn't have the php_sapi_name function built in");
}
include 'globals.php';
// Init our main classes
$spider = new CableSpider();
$saver = new CableSaver();
// Init our cables array
$cables = array();
// Get cables from command line or get args
if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
    // running from command line
    $args = $_SERVER['argv'];
    if (count($args) == 1 && file_exists($args[0])) {
        $cables = explode("\n", file_get_contents($args[0]));
    } else {
        $cables = $args;
    }
} else {
    // running from browser
    if (isset($_GET['id'])) {
        // id is given
        if (strstr($_GET['id'], '|')) {
            // multiple ids
            foreach (explode('|', $_GET['id']) as $id) {
                $cables[] = $id;
            }
        } else {
            // single id