Example #1
0
 public function set($item, $from, $delay = false, $node = false)
 {
     if ($item->item) {
         $entry = $item->item;
     } else {
         $entry = $item;
     }
     if ($from != '') {
         $this->__set('origin', $from);
     }
     if ($node) {
         $this->__set('node', $node);
     } else {
         $this->__set('node', (string) $item->attributes()->node);
     }
     $this->__set('nodeid', (string) $entry->attributes()->id);
     if ($entry->entry->id) {
         $this->__set('nodeid', (string) $entry->entry->id);
     }
     // Get some informations on the author
     if ($entry->entry->author->name) {
         $this->__set('aname', (string) $entry->entry->author->name);
     }
     if ($entry->entry->author->uri) {
         $this->__set('aid', substr((string) $entry->entry->author->uri, 5));
     }
     if ($entry->entry->author->email) {
         $this->__set('aemail', (string) $entry->entry->author->email);
     }
     // Non standard support
     if ($entry->entry->source && $entry->entry->source->author->name) {
         $this->__set('aname', (string) $entry->entry->source->author->name);
     }
     if ($entry->entry->source && $entry->entry->source->author->uri) {
         $this->__set('aid', substr((string) $entry->entry->source->author->uri, 5));
     }
     $this->__set('title', $this->getTitle($entry->entry->title));
     // Content
     if ($entry->entry->summary && (string) $entry->entry->summary != '') {
         $summary = '<p class="summary">' . (string) $entry->entry->summary . '</p>';
     } else {
         $summary = '';
     }
     if ($entry->entry && $entry->entry->content) {
         $content = $this->getContent($entry->entry->content);
     } elseif ($summary == '') {
         $content = __('');
     } else {
         $content = '';
     }
     $content = $summary . $content;
     if ($entry->entry->updated) {
         $this->__set('updated', (string) $entry->entry->updated);
     } else {
         $this->__set('updated', gmdate(DATE_ISO8601));
     }
     if ($entry->entry->published) {
         $this->__set('published', (string) $entry->entry->published);
     } elseif ($entry->entry->updated) {
         $this->__set('published', (string) $entry->entry->updated);
     } else {
         $this->__set('published', gmdate(DATE_ISO8601));
     }
     if ($delay) {
         $this->__set('delay', $delay);
     }
     // Tags parsing
     if ($entry->entry->category) {
         $td = new \Modl\TagDAO();
         $td->delete($this->__get('nodeid'));
         if ($entry->entry->category->count() == 1 && isset($entry->entry->category->attributes()->term)) {
             $tag = new \Modl\Tag();
             $tag->nodeid = $this->__get('nodeid');
             $tag->tag = strtolower((string) $entry->entry->category->attributes()->term);
             $td->set($tag);
         } else {
             foreach ($entry->entry->category as $cat) {
                 $tag = new \Modl\Tag();
                 $tag->nodeid = $this->__get('nodeid');
                 $tag->tag = strtolower((string) $cat->attributes()->term);
                 $td->set($tag);
             }
         }
     }
     if (!isset($this->commentorigin)) {
         $this->__set('commentorigin', $this->origin);
     }
     $this->__set('content', trim($content));
     $this->contentcleaned = purifyHTML(html_entity_decode($this->content));
     $extra = false;
     // We try to extract a picture
     $xml = \simplexml_load_string('<div>' . $this->contentcleaned . '</div>');
     if ($xml) {
         $results = $xml->xpath('//img/@src');
         if (is_array($results) && !empty($results)) {
             $extra = (string) $results[0];
             if (isSmallPicture($extra)) {
                 $this->picture = $extra;
             }
         }
         $results = $xml->xpath('//video/@poster');
         if (is_array($results) && !empty($results)) {
             $extra = (string) $results[0];
             if (isSmallPicture($extra)) {
                 $this->picture = $extra;
             }
         }
     }
     $this->setAttachments($entry->entry->link, $extra);
     if ($entry->entry->geoloc) {
         if ($entry->entry->geoloc->lat != 0) {
             $this->__set('lat', (string) $entry->entry->geoloc->lat);
         }
         if ($entry->entry->geoloc->lon != 0) {
             $this->__set('lon', (string) $entry->entry->geoloc->lon);
         }
     }
     // We fill empty aid
     if ($this->isMicroblog() && empty($this->aid)) {
         $this->__set('aid', $this->origin);
     }
     // We check if this is a reply
     if ($entry->entry->{'in-reply-to'}) {
         $href = (string) $entry->entry->{'in-reply-to'}->attributes()->href;
         $arr = explode(';', $href);
         $reply = ['origin' => substr($arr[0], 5, -1), 'node' => substr($arr[1], 5), 'nodeid' => substr($arr[2], 5)];
         $this->__set('reply', serialize($reply));
     }
 }
Example #2
0
 protected function clean()
 {
     $method = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' ? $_POST : $_GET;
     $this->original = new stdClass();
     $this->clean = new stdClass();
     $this->db_clean = new stdClass();
     $this->html_clean = new stdClass();
     if (!empty($method)) {
         foreach ($method as $k => $v) {
             $this->original->{$k} = $v;
             $v = trim(decodeValue($v));
             $this->clean->{$k} = strip_tags($v);
             $this->db_clean->{$k} = $this->db->escape_str($this->clean->{$k});
             $this->html_clean->{$k} = $this->db->escape_str(purifyHTML($v));
         }
     }
 }
Example #3
0
 public function set($item, $from, $delay = false, $node = false)
 {
     if ($item->item) {
         $entry = $item->item;
     } else {
         $entry = $item;
     }
     $this->__set('origin', $from);
     if ($node) {
         $this->__set('node', $node);
     } else {
         $this->__set('node', (string) $item->attributes()->node);
     }
     $this->__set('nodeid', (string) $entry->attributes()->id);
     if ($entry->entry->id) {
         $this->__set('nodeid', (string) $entry->entry->id);
     }
     // Get some informations on the author
     if ($entry->entry->author->name) {
         $this->__set('aname', (string) $entry->entry->author->name);
     }
     if ($entry->entry->author->uri) {
         $this->__set('aid', substr((string) $entry->entry->author->uri, 5));
     }
     if ($entry->entry->author->email) {
         $this->__set('aemail', (string) $entry->entry->author->email);
     }
     // Non standard support
     if ($entry->entry->source && $entry->entry->source->author->name) {
         $this->__set('aname', (string) $entry->entry->source->author->name);
     }
     if ($entry->entry->source && $entry->entry->source->author->uri) {
         $this->__set('aid', substr((string) $entry->entry->source->author->uri, 5));
     }
     $this->__set('title', (string) $entry->entry->title);
     // Content
     if ($entry->entry->summary && (string) $entry->entry->summary != '') {
         $summary = '<p class="summary">' . (string) $entry->entry->summary . '</p>';
     } else {
         $summary = '';
     }
     if ($entry->entry && $entry->entry->content) {
         $content = $this->getContent($entry->entry->content);
     } elseif ($summary == '') {
         $content = __('');
     } else {
         $content = '';
     }
     $content = $summary . $content;
     if ($entry->entry->updated) {
         $this->__set('updated', (string) $entry->entry->updated);
     } else {
         $this->__set('updated', gmdate(DATE_ISO8601));
     }
     if ($entry->entry->published) {
         $this->__set('published', (string) $entry->entry->published);
     } elseif ($entry->entry->updated) {
         $this->__set('published', (string) $entry->entry->updated);
     } else {
         $this->__set('published', gmdate(DATE_ISO8601));
     }
     if ($delay) {
         $this->__set('delay', $delay);
     }
     $contentimg = $this->setAttachements($entry->entry->link);
     // Tags parsing
     if ($entry->entry->category) {
         $td = new \Modl\TagDAO();
         if ($entry->entry->category->count() == 1 && isset($entry->entry->category->attributes()->term)) {
             $tag = new \Modl\Tag();
             $tag->nodeid = $this->__get('nodeid');
             $tag->tag = (string) $entry->entry->category->attributes()->term;
             $td->set($tag);
         } else {
             foreach ($entry->entry->category as $cat) {
                 $tag = new \Modl\Tag();
                 $tag->nodeid = $this->__get('nodeid');
                 $tag->tag = (string) $cat->attributes()->term;
                 $td->set($tag);
             }
         }
     }
     if ($contentimg != '') {
         $content .= '<br />' . $contentimg;
     }
     if (!isset($this->commentplace)) {
         $this->__set('commentplace', $this->origin);
     }
     $this->__set('content', trim($content));
     $this->contentcleaned = purifyHTML(html_entity_decode($this->content));
     if ($entry->entry->geoloc) {
         if ($entry->entry->geoloc->lat != 0) {
             $this->__set('lat', (string) $entry->entry->geoloc->lat);
         }
         if ($entry->entry->geoloc->lon != 0) {
             $this->__set('lon', (string) $entry->entry->geoloc->lon);
         }
     }
 }
Example #4
0
function feedEventObject($event, $event_data)
{
    global $query;
    //clean up html in the data
    $event_data = purifyHTML($event_data);
    //first grab all the properties that match up well
    foreach (get_object_vars($event) as $k => $v) {
        if ($event_data["{$k}"]) {
            $event->{$k} = $event_data["{$k}"];
        }
    }
    //want to append time to dates, and convert to nice format
    foreach (array('start', 'end') as $boundary) {
        $prop = $boundary . '_date';
        $event->{$prop} = date('Y-m-d G:i:s', strtotime($event->{$prop} . ' ' . $event_data[$boundary . '_time']));
    }
    //now add devices, buildings, and groups affected
    foreach (array('devices', 'buildings', 'groups') as $unit) {
        $selections = $event_data['bubbles']["{$unit}"];
        $unitobj = buildAffectedObject($unit);
        $unitobj->setItems($selections);
        $unitprop = $unit . '_affected';
        $event->{$unitprop} = $unitobj;
    }
    //add pushpin data
    $event->pushpins = $event_data['pushpins'];
    //add custdb data
    $event->user_huid = $query['custdb']['huid'];
    $event->user_name = $query['custdb']['last_name'] . ', ' . $query['custdb']['first_name'];
    //copy over the public version of the event id
    $event->id = $event_data->id;
    return $event;
}