Ejemplo n.º 1
0
 function prepareContent($content, $title = false)
 {
     if ($title) {
         return cleanHTMLTags($content);
     } else {
         return trim(cleanHTMLTags(prepareString($content)));
     }
 }
Ejemplo n.º 2
0
 public function set($stanza, $parent = false)
 {
     if ($stanza->body || $stanza->subject) {
         $jid = explode('/', (string) $stanza->attributes()->from);
         $to = current(explode('/', (string) $stanza->attributes()->to));
         // This is not very beautiful
         $user = new \User();
         $this->session = $user->getLogin();
         $this->jidto = $to;
         $this->jidfrom = $jid[0];
         if (isset($jid[1])) {
             $this->resource = $jid[1];
         }
         $this->type = 'chat';
         if ($stanza->attributes()->type) {
             $this->type = (string) $stanza->attributes()->type;
         }
         $this->body = (string) $stanza->body;
         $this->subject = (string) $stanza->subject;
         $images = (bool) ($this->type == 'chat');
         /*if($stanza->html) {
               $this->html = \cleanHTMLTags($stanza->html->body->asXML());
               $this->html = \fixSelfClosing($this->html);
               $this->html = \prepareString($this->html, false, $images);
           } else {*/
         $this->html = \prepareString($this->body, false, $images);
         //}
         if ($stanza->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($stanza->delay->attributes()->stamp));
         } elseif ($parent && $parent->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($parent->delay->attributes()->stamp));
         } else {
             $this->published = gmdate('Y-m-d H:i:s');
         }
         $this->delivered = gmdate('Y-m-d H:i:s');
     }
 }
Ejemplo n.º 3
0
Archivo: Chat.php Proyecto: Trim/movim
 function prepareMessage(&$message)
 {
     if (isset($message->html)) {
         $message->body = $message->html;
     } else {
         $message->body = prepareString(htmlentities($message->body, ENT_COMPAT, 'UTF-8'));
     }
     if ($message->type == 'groupchat') {
         $message->color = stringToColor($message->session . $message->resource . $message->jidfrom . $message->type);
     }
     $message->published = prepareDate(strtotime($message->published));
     return $message;
 }
Ejemplo n.º 4
0
 function prepareChat($jid, $muc = false)
 {
     $view = $this->tpl();
     $view->assign('jid', $jid);
     $jid = echapJS($jid);
     $view->assign('composing', $this->call('ajaxSendComposing', "'" . $jid . "'"));
     $view->assign('paused', $this->call('ajaxSendPaused', "'" . $jid . "'"));
     $view->assign('smiley', $this->call('ajaxSmiley'));
     $view->assign('emoji', prepareString('😀'));
     $view->assign('muc', $muc);
     $view->assign('anon', false);
     if ($muc) {
         $md = new \Modl\MessageDAO();
         $s = $md->getRoomSubject($jid);
         $cd = new \Modl\ConferenceDAO();
         $c = $cd->get($jid);
         $pd = new \Modl\PresenceDAO();
         $p = $pd->getMyPresenceRoom($jid);
         $view->assign('room', $jid);
         $view->assign('subject', $s);
         $view->assign('presence', $p);
         $view->assign('conference', $c);
     } else {
         $cd = new \Modl\ContactDAO();
         $cr = $cd->getRosterItem($jid);
         if (isset($cr)) {
             $contact = $cr;
         } else {
             $contact = $cd->get($jid);
         }
         $view->assign('contact', $contact);
         $view->assign('jid', $jid);
     }
     return $view->draw('_chat', true);
 }
Ejemplo n.º 5
0
 /**
  * @brief Get the path of a emoji
  */
 function ajaxSmileyGet($string)
 {
     return prepareString($string, true);
 }
Ejemplo n.º 6
0
 function prepareChat($jid, $muc = false)
 {
     $view = $this->tpl();
     $view->assign('jid', $jid);
     $jid = echapJS($jid);
     $view->assign('composing', $this->call('ajaxSendComposing', "'" . $jid . "'"));
     $view->assign('paused', $this->call('ajaxSendPaused', "'" . $jid . "'"));
     $view->assign('smiley', $this->call('ajaxSmiley'));
     $view->assign('emoji', prepareString('😀'));
     $view->assign('muc', $muc);
     return $view->draw('_chat', true);
 }
Ejemplo n.º 7
0
function createPOContent($strings_template)
{
    $out = '';
    $has_strings = false;
    foreach ($strings_template as $string => $data) {
        if (!is_string($string)) {
            $string = $string . '';
        }
        $is_meta = strlen(trim($string)) == 0;
        if (!$is_meta) {
            //this is not the meta-data string
            $has_strings = true;
        }
        if (is_string($data)) {
            $data = array('comments' => array('' => explode("\n", $data)), 'msgstr' => '');
        } else {
            if (is_bool($data)) {
                $data = array('comments' => array(), 'msgstr' => '');
            }
        }
        if (!is_array($data['comments'])) {
            $data['comments'] = array();
        }
        if (!array_key_exists(',', $data['comments']) || !is_array($data['comments'][',']) || count($data['comments'][',']) == 0) {
            if ($is_meta) {
                $data['comments'][','] = array('fuzzy');
            } else {
                $data['comments'][','] = array('no-c-format');
            }
        }
        //'.' comments are "extracted comments"
        //''  comments are tranlator comments
        //':' comnets are refeernce comments
        //',' comments are format/flag comments
        foreach (array('', '.', ':', ',') as $prefix) {
            if (!array_key_exists($prefix, $data['comments'])) {
                continue;
            }
            $comments = $data['comments'][$prefix];
            if (is_string($comments)) {
                $comments = explode("\n", trim($comments));
            }
            if (!is_array($comments)) {
                $comments = array();
            }
            foreach ($comments as $comment) {
                if (strlen($comment) > 0 && $comment[0] != ' ') {
                    $comment = ' ' . $comment;
                }
                $out .= '#' . $prefix . $comment . "\n";
            }
        }
        $out .= prepareString('msgid', $string);
        if (array_key_exists('msgid_plural', $data) && $data['msgid_plural']) {
            $out .= prepareString('msgid_plural', $data['msgid_plural']);
        }
        if (array_key_exists('msgstr', $data) && $data['msgstr']) {
            $msgstr = $data['msgstr'];
        } else {
            $msgstr = '';
        }
        $out .= prepareString('msgstr', $msgstr);
        $out .= "\n";
    }
    if (!$has_strings) {
        return false;
    }
    return $out;
}
Ejemplo n.º 8
0
Archivo: Postn.php Proyecto: Trim/movim
 public function set($item, $from, $delay = false, $node = false)
 {
     if ($item->item) {
         $entry = $item->item;
     } else {
         $entry = $item;
     }
     $this->origin = $from;
     if ($node) {
         $this->node = $node;
     } else {
         $this->node = (string) $item->attributes()->node;
     }
     $this->nodeid = (string) $entry->attributes()->id;
     if ($entry->entry->id) {
         $this->nodeid = (string) $entry->entry->id;
     }
     // Get some informations on the author
     if ($entry->entry->author->name) {
         $this->aname = (string) $entry->entry->author->name;
     }
     if ($entry->entry->author->uri) {
         $this->aid = substr((string) $entry->entry->author->uri, 5);
     }
     if ($entry->entry->author->email) {
         $this->aemail = (string) $entry->entry->author->email;
     }
     // Non standard support
     if ($entry->entry->source && $entry->entry->source->author->name) {
         $this->aname = (string) $entry->entry->source->author->name;
     }
     if ($entry->entry->source && $entry->entry->source->author->uri) {
         $this->aid = substr((string) $entry->entry->source->author->uri, 5);
     }
     $this->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->updated = (string) $entry->entry->updated;
     } else {
         $this->updated = gmdate(DATE_ISO8601);
     }
     if ($entry->entry->published) {
         $this->published = (string) $entry->entry->published;
     } elseif ($entry->entry->updated) {
         $this->published = (string) $entry->entry->updated;
     } else {
         $this->published = gmdate(DATE_ISO8601);
     }
     if ($delay) {
         $this->delay = $delay;
     }
     $contentimg = $this->setAttachements($entry->entry->link);
     // Tags parsing
     if ($entry->entry->category) {
         $this->tags = array();
         if ($entry->entry->category->count() == 1 && isset($entry->entry->category->attributes()->term)) {
             array_push($this->tags, (string) $entry->entry->category->attributes()->term);
         } else {
             foreach ($entry->entry->category as $cat) {
                 array_push($this->tags, (string) $cat->attributes()->term);
             }
         }
     }
     if (!empty($this->tags)) {
         $this->tags = serialize($this->tags);
     }
     if ($contentimg != '') {
         $content .= '<br />' . $contentimg;
     }
     if (!isset($this->commentplace)) {
         $this->commentplace = $this->origin;
     }
     $this->content = trim($content);
     $this->contentcleaned = prepareString(html_entity_decode($this->content));
     if ($entry->entry->geoloc) {
         if ($entry->entry->geoloc->lat != 0) {
             $this->lat = (string) $entry->entry->geoloc->lat;
         }
         if ($entry->entry->geoloc->lon != 0) {
             $this->lon = (string) $entry->entry->geoloc->lon;
         }
     }
 }
Ejemplo n.º 9
0
<?php

function prepareString($string = '', $maxLength = 0)
{
    if (!isset($string) || strlen($string) == 0) {
        return '';
    }
    return $maxLength > 0 ? substr(trim($string), 0, $maxLength) : $string;
}
//prepare attributes
$attributes['id'] = isset($attributes['id']) ? intval($attributes['id']) : 0;
$attributes['url'] = prepareString($attributes['url'], 1000);
$attributes['last_modified'] = prepareString($attributes['last_modified'], 10);
$attributes['change_freq'] = prepareString($attributes['change_freq'], 10);
$attributes['priority'] = prepareString($attributes['priority'], 255);
$attributes['priority'] = str_replace(',', '.', $attributes['priority']);
//validate
if ($attributes['id'] > 0) {
    $oldItem = $oSitemap->getItemByID($attributes['id']);
    if (empty($oldItem)) {
        _warning("WItemNotFound", "Item not found, probably deleted");
    }
}
if (strlen($attributes['url']) == 0) {
    _warning("WEmptyLocation", $oContentManager->getCleanTitle("MessageEmptyLocation"));
} else {
    if (!preg_match("/^http(s)?:\\/\\/.*/", $attributes['url'])) {
        $attributes['url'] = 'http://' . $attributes['url'];
    }
}
if (strlen($attributes['last_modified']) == 0) {
Ejemplo n.º 10
0
        $category = strtolower($category_name);
        if (!isset($categories[$category])) {
            $query = "\n                    INSERT INTO `jmla_wcatalog_categories` (`title`, `parent_id`, `ordering`, `level`, `published`, `created`, `created_by`, `modified`, `modified_by`) VALUES\n                    ('" . $category_name . "', 7, " . $cat_ordering . ", 2, 1, '2016-02-01 02:13:43', 948, '0000-00-00 00:00:00', 0);\n                ";
            $result = mysqli_query($mysqli, $query);
            if (!$result) {
                print $query . "\n\n" . mysqli_error($mysqli) . "\n";
                die;
            }
            $categories[$category] = $mysqli->insert_id;
            $cat_ordering++;
        }
    } else {
        //insert product
        $article_arr = explode('.', $data[3]);
        if (!empty(trim($data[2])) || $article_arr[0] == '444') {
            $query = "INSERT INTO `comcar`.`jmla_wcatalog_products` (`title`, `make`, `model`, `year`, `article`, `description`, `price`, `image`, `category_id`, `published`, `created`, `created_by`, `modified`, `modified_by`) VALUES\n                (\n                    '" . prepareString($data[0], $mysqli) . "',\n                    '" . prepareString($category_name, $mysqli) . "',\n                    '" . prepareString($data[1], $mysqli) . "',\n                    '" . prepareString($data[2], $mysqli) . "',\n                    '" . prepareString($data[3], $mysqli) . "',\n                    NULL,\n                    " . prepareInt($data[7]) . ",\n                    '" . prepareString($data[3] . '.jpg', $mysqli) . "',\n                    " . $categories[$category] . ",\n                    1,\n                    '2016-02-01 00:00:00',\n                    948,\n                    '0000-00-00 00:00:00',\n                    0\n                );";
            $result = mysqli_query($mysqli, $query);
            if (!$result) {
                print $query . "\n\n" . mysqli_error($mysqli) . "\n";
                die;
            }
        }
    }
}
fclose($file);
print "Success!\n";
function fupper($string)
{
    $string = strtolower($string);
    $string = strtoupper(substr($string, 0, 1)) . substr($string, 1);
    return $string;