/**
  * Reademails
  * @return type
  */
 public function readmails(Emails $emails, Email $settings_email, System $system)
 {
     $path_url = $system->first()->url;
     if ($settings_email->first()->email_fetching == 1) {
         if ($settings_email->first()->all_emails == 1) {
             $helptopic = $this->TicketController->default_helptopic();
             $sla = $this->TicketController->default_sla();
             $email = $emails->get();
             foreach ($email as $e_mail) {
                 $dept = $e_mail->department;
                 $host = $e_mail->fetching_host;
                 $port = $e_mail->fetching_port;
                 $protocol = $e_mail->mailbox_protocol;
                 $imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX';
                 $password = Crypt::decrypt($e_mail->password);
                 $mailbox = new ImapMailbox($imap_config, $e_mail->user_name, $password, __DIR__);
                 $mails = array();
                 $mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime("-1 day")));
                 if (!$mailsIds) {
                     die('Mailbox is empty');
                 }
                 // dd($mailsIds);
                 foreach ($mailsIds as $mailId) {
                     $overview = $mailbox->get_overview($mailId);
                     $var = $overview[0]->seen ? 'read' : 'unread';
                     if ($var == 'unread') {
                         $mail = $mailbox->getMail($mailId);
                         if ($settings_email->email_collaborator == 1) {
                             $collaborator = $mail->cc;
                         } else {
                             $collaborator = null;
                         }
                         $body = $mail->textHtml;
                         // dd($mailId);
                         if ($body == null) {
                             $body = $mailbox->backup_getmail($mailId);
                             $body = str_replace('\\r\\n', '<br/>', $body);
                             // var_dump($body);
                         }
                         // dd($body);
                         $date = $mail->date;
                         $datetime = $overview[0]->date;
                         $date_time = explode(" ", $datetime);
                         $date = $date_time[1] . "-" . $date_time[2] . "-" . $date_time[3] . " " . $date_time[4];
                         $date = date('Y-m-d H:i:s', strtotime($date));
                         if (isset($mail->subject)) {
                             $subject = $mail->subject;
                         } else {
                             $subject = "No Subject";
                         }
                         $fromname = $mail->fromName;
                         $fromaddress = $mail->fromAddress;
                         $source = "2";
                         $phone = "";
                         $priority = '1';
                         $assign = "";
                         $form_data = null;
                         if ($this->TicketController->create_user($fromaddress, $fromname, $subject, $body, $phone, $helptopic, $sla, $priority, $source, $collaborator, $dept, $assign, $form_data) == true) {
                             $thread_id = Ticket_Thread::whereRaw('id = (select max(`id`) from ticket_thread)')->first();
                             $thread_id = $thread_id->id;
                             foreach ($mail->getAttachments() as $attachment) {
                                 $support = "support";
                                 // echo $_SERVER['DOCUMENT_ROOT'];
                                 $dir_img_paths = __DIR__;
                                 $dir_img_path = explode('/code', $dir_img_paths);
                                 $filepath = explode('../../../../../../public/', $attachment->filePath);
                                 // dd($filepath);
                                 // $path = $dir_img_path[0]."/public/".$filepath[1];
                                 $path = public_path() . '/' . $filepath[1];
                                 // dd($path);
                                 $filesize = filesize($path);
                                 $file_data = file_get_contents($path);
                                 $ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
                                 $imageid = $attachment->id;
                                 $string = str_replace('-', '', $attachment->name);
                                 $filename = explode('src', $attachment->filePath);
                                 $filename = str_replace('\\', '', $filename);
                                 $body = str_replace("cid:" . $imageid, $filepath[1], $body);
                                 $pos = strpos($body, $filepath[1]);
                                 if ($pos == false) {
                                     if ($settings_email->first()->attachment == 1) {
                                         $upload = new Ticket_attachments();
                                         $upload->file = $file_data;
                                         $upload->thread_id = $thread_id;
                                         $upload->name = $filepath[1];
                                         $upload->type = $ext;
                                         $upload->size = $filesize;
                                         $upload->poster = "ATTACHMENT";
                                         $upload->save();
                                     }
                                 } else {
                                     $upload = new Ticket_attachments();
                                     $upload->file = $file_data;
                                     $upload->thread_id = $thread_id;
                                     $upload->name = $filepath[1];
                                     $upload->type = $ext;
                                     $upload->size = $filesize;
                                     $upload->poster = "INLINE";
                                     $upload->save();
                                 }
                                 unlink($path);
                             }
                             $body = Encoding::fixUTF8($body);
                             $thread = Ticket_Thread::where('id', '=', $thread_id)->first();
                             $thread->body = $this->separate_reply($body);
                             $thread->save();
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Return entities by document
  * @param string $document
  * @return array
  * @throws OpenCalaisException
  */
 public function getEntities($document)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->api_url);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-AG-Access-Token: ' . $this->api_token, 'Content-Type: ' . $this->contentType, 'outputFormat: ' . $this->outputFormat));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $document);
     $response = curl_exec($ch);
     $response = Encoding::fixUTF8($response);
     $object = json_decode($response);
     if (empty($object)) {
         throw new OpenCalaisException('No response was received from the API.');
     } elseif (isset($object->fault)) {
         throw new OpenCalaisException('OpenCalais Error:' . $object->fault->faultstring);
     }
     foreach ($object as $item) {
         if (!empty($item->_typeGroup) && !empty($item->name)) {
             if (!empty($item->_type)) {
                 $this->entities[$item->_typeGroup][$item->_type][] = trim($item->name);
             } else {
                 $this->entities[$item->_typeGroup][] = trim($item->name);
             }
         }
     }
     return $this->entities;
 }
Exemple #3
0
 public function onMessage(Bucket $bucket)
 {
     $data = $bucket->getData();
     if ($data['isAction']) {
         $format = '* %s %s';
     } else {
         $format = '<%s> %s';
     }
     $this->log(sprintf($format, $data['from']['nick'], \ForceUTF8\Encoding::fixUTF8($data['message'])), $data['channel']);
 }
function getStoryAttributes($xpath, $story)
{
    $parsedUrl = parse_url($story["story_url"]);
    $host = explode('.', $parsedUrl['host']);
    $subdomain = $host[0];
    $cookies = "HasVisited=bypass page next time; path=/; domain={$subdomain}.adult-fanfiction.org";
    $story_author = $xpath->query("//tr[5]/td[2]");
    $story_title = $xpath->query("//html/head/title");
    $story_chapters = $xpath->query("//select[@name='chapnav']/option");
    // ========== GET STORY PROPERTIES ========== //
    foreach ($story_title as $title) {
        $story["title"] = str_replace("Story: ", '', stripAccents(trim($title->nodeValue)));
    }
    foreach ($story_author as $author) {
        $story["author"] = str_replace("Author: ", '', str_replace("\t", '', str_replace("\n", '', $author->nodeValue)));
    }
    if (!isset($story["author"]) || !isset($story["title"])) {
        throw new WrongFormatException("Data received contained invalid format. Author: {$story['author']}, Title: {$story['title']}");
    }
    $story["desc"] = "";
    $story["numChapter"] = 1;
    $story["chapters"] = array();
    $story["chapters"]["title"] = array();
    $story["chapters"]["content"] = array();
    foreach ($story_chapters as $chapter) {
        $new_url = $story["story_url"] . "&chapter=" . $story["numChapter"];
        $title = trim($chapter->nodeValue);
        if (startsWith($title, $story["numChapter"] . ".")) {
            $title = str_replace($story["numChapter"] . ". ", "", $title);
            array_push($story["chapters"]["title"], $title);
            array_push($story["chapters"]["content"], \ForceUTF8\Encoding::fixUTF8(getChapter($new_url, $story["debug"], $cookies, $story["uniqid"])));
        } else {
            break;
        }
        $story["numChapter"]++;
    }
    return $story;
}
Exemple #5
0
 /**
  *@desc Check and encode UTF-8 encoding document. Return the checked document converted to UTF-8
  *@param string $document
  *@return string
  */
 public static function fixUTF8($document)
 {
     return Encoding::fixUTF8(Encoding::removeBOM($document), Encoding::WITHOUT_ICONV);
 }
 /**
  * Get all system recordings
  * @return array Array of system recordings
  */
 public function getSystemRecordings()
 {
     $files = $this->getdir($this->path);
     $final = array();
     foreach ($files as &$file) {
         $file = str_replace($this->path . "/", "", $file);
         if (preg_match("/^(\\w{2}_\\w{2}|\\w{2})\\/(.*)\\.([a-z0-9]{2,})/i", $file, $matches)) {
             $lang = $matches[1];
             $name = \ForceUTF8\Encoding::fixUTF8($matches[2]);
             if (substr($name, 0, 1) == "." || preg_match("/^(?:CHANGES|CREDITS|LICENSE)-asterisk-(?:core|extra)-(?:\\w\\w\\_\\w\\w|\\w\\w)-(?:\\d|\\.)*\$/i", $name)) {
                 continue;
             }
             $format = $matches[3];
             if (!isset($final[$name])) {
                 $final[$name] = array("name" => $name, "languages" => array($lang => $lang), "formats" => array($format => $format), "paths" => array($lang => $lang . "/" . $name));
             } else {
                 $final[$name]['languages'][$lang] = $lang;
                 $final[$name]['formats'][$format] = $format;
                 $final[$name]['paths'][$lang] = $lang . "/" . $name;
             }
         }
     }
     ksort($final);
     return $final;
 }
Exemple #7
0
 /**
  * Converts a string to UTF-8
  * 
  * @param unknown $string            
  * @return Ambigous <unknown, string>
  */
 public function toUtf8($string)
 {
     return ForceUtf8::fixUTF8($string);
 }
Exemple #8
0
 /**
  * @param $document
  * @return array|string
  */
 public static function fixUTF8($document)
 {
     return Encoding::fixUTF8(Encoding::removeBOM($document), Encoding::ICONV_TRANSLIT);
 }
 /**
  * Check to see if the given key exists in the array, and trim excess white space before returning it
  *
  * @author Daniel Melzter
  * @since 3.0
  * @param $array array
  * @param $key string
  * @param $default string
  * @return string
  */
 public function array_smart_fetch(array $array, $key, $default = '')
 {
     return array_key_exists(trim($key), $array) ? e(Encoding::fixUTF8(trim($array[$key]))) : $default;
 }
Exemple #10
0
 /**
  * This function returns an array with key=column-name and value=data.
  */
 private function createValues($columns, $data)
 {
     $result = array();
     foreach ($columns as $column) {
         if (!empty($data[$column['index']]) || is_numeric(@$data[$column['index']])) {
             $result[$column['column_name_alias']] = \ForceUTF8\Encoding::fixUTF8(@$data[$column['index']]);
         } else {
             $index = $column['index'];
             $result[$column['column_name_alias']] = '';
         }
     }
     return $result;
 }
 public function fixUtf8($content)
 {
     $content = Encoding::fixUTF8($content);
     $content = str_replace('Â', '', $content);
     return $content;
 }
 /**
  * generate doc
  * @var array $params
  */
 public function generateDoc($params)
 {
     Yii::$app->user->identity = \app\models\User::findIdentityByAccessToken($params['template']['key']);
     header("Content-Description: File Transfer");
     header('Content-Transfer-Encoding: binary');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Expires: 0');
     switch ($params['template']['format']) {
         case 'PDF':
             $file = Yii::$app->user->id . '_temp.pdf';
             $writeFormat = 'PDF';
             PhpWordSettings::setPdfRendererPath(dirname(__DIR__) . '/../../../vendor/tecnickcom/tcpdf');
             PhpWordSettings::setPdfRendererName('TCPDF');
             header('Content-Type: application/pdf');
             break;
         case 'Word2013':
             $file = Yii::$app->user->id . '_temp.docx';
             $writeFormat = 'Word2013';
             header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
             break;
         default:
             $file = Yii::$app->user->id . '_temp.doc';
             $writeFormat = 'Word2007';
             header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
             break;
     }
     header('Content-Disposition: attachment; filename="' . $file . '"');
     $document = new TemplateProcessor(dirname(__DIR__) . '/../../../files/' . $this->id . '/' . $this->template_file);
     /**
      * process the fields, that have been send through the rest interface
      */
     foreach ($params['template']['fields'] as $field) {
         foreach ($field as $key => $value) {
             $document->setValue($key, UTF8encoding::fixUTF8($value));
         }
     }
     /**
      * process the tables, that have been send through the rest interface
      */
     foreach ($params['template']['tables'] as $tables) {
         foreach ($tables as $name => $rows) {
             //first we create a clone for the master row
             $document->cloneRow($name, count($rows));
             //our walking variable for the table
             $ii = 1;
             foreach ($rows as $row) {
                 foreach ($row as $cell) {
                     $document->setValue(key($cell) . '#' . $ii, current($cell));
                 }
                 $ii++;
             }
         }
     }
     // save as a random file in temp file
     $temp_file = tempnam(sys_get_temp_dir(), $file);
     $document->saveAs($temp_file);
     switch ($params['template']['format']) {
         case 'PDF':
             $phpWord = IOFactory::load($temp_file);
             $xmlWriter = IOFactory::createWriter($phpWord, $writeFormat);
             $xmlWriter->save("php://output");
             break;
         case 'Word2007':
             $phpWord = IOFactory::load($temp_file);
             $xmlWriter = IOFactory::createWriter($phpWord, $writeFormat);
             $xmlWriter->save("php://output");
             break;
         default:
             readfile($temp_file);
             break;
     }
     unlink($temp_file);
     $LogEvent = new TemplateEvent();
     $LogEvent->aTemplateCreated(Yii::$app->user->identity->username, $this->id);
     \Yii::$app->end();
 }
Exemple #13
0
            }
        }
        $i++;
    }
    $IdAlumnibiris = mysql_result($Alumnos, $j, 'id_estu');
    $Observacion = $Querys->Select('*', 'oboletin', "WHERE id_estu='{$IdAlumnibiris}' AND id_peri='{$IdPeriodo}'");
    $Observacion = mysql_result($Observacion, 0, 'obol_obol');
    $PuestoFinal = $Querys->Select('pues_pues', 'puestos', "WHERE id_estu='" . $IdAlumnibiris . "' AND peri_pues='" . $IdPeriodo . "'");
    $PuestoFinal = mysql_result($PuestoFinal, 0, 'pues_pues');
    ?>

			<div id="observacion"><?php 
    echo Encoding::fixUTF8($Observacion);
    ?>
<br /><b>Puesto en el curso:</b> <?php 
    echo Encoding::fixUTF8($PuestoFinal);
    ?>
</div>
			<div id="firma"><img src="firma.png"></div></div>
	</div>
<?php 
    $j++;
}
?>
		<!--<div id="pagina2">
			<div id="materia">
				<div id="nombremateria9" class="absoluto">Matemáticas</div>
				<div id="ih9" class="absoluto">2</div>
				<div id="f9" class="absoluto">2</div>
				<div id="d9" class="absoluto">Superior</div>
				<div id="v19" class="absoluto">9.3</div>
Exemple #14
0
 /**
  * Clean a UTF-8 string. Sometimes the encoding might be UTF-8
  * but contains contaminated characters e.g. when the encoding
  * is not know of a file, there's no way to address that.
  *
  *
  * @param string $value
  *
  * @return string
  */
 public function fixUtf8($value)
 {
     return \ForceUTF8\Encoding::fixUTF8($value);
 }
 public function readmails()
 {
     $emails = Emails::get();
     // fetch each mails by mails
     foreach ($emails as $email) {
         $email_id = $email->email_address;
         $password = Crypt::decrypt($email->password);
         $protocol = '/' . $email->fetching_protocol;
         $host = $email->fetching_host;
         $port = $email->fetching_port;
         $encryption = '/' . $email->fetching_encryption;
         if ($email->mailbox_protocol) {
             $protocol_value = $e_mail->mailbox_protocol;
             $get_mailboxprotocol = MailboxProtocol::where('id', '=', $protocol_value)->first();
             $protocol = $get_mailboxprotocol->value;
         } elseif ($email->fetching_encryption == '/none') {
             $fetching_encryption2 = '/novalidate-cert';
             $protocol = $fetching_encryption2;
         } else {
             if ($email->fetching_protocol) {
                 $fetching_protocol = '/' . $email->fetching_protocol;
             } else {
                 $fetching_protocol = '';
             }
             if ($email->fetching_encryption) {
                 $fetching_encryption = $email->fetching_encryption;
             } else {
                 $fetching_encryption = '';
             }
             $protocol = $fetching_protocol . $fetching_encryption;
         }
         // dd('{' . $host . ':' . $port . $protocol . '}INBOX');
         $mailbox = new ImapMailbox('{' . $host . ':' . $port . $protocol . '}INBOX', $email_id, $password, __DIR__);
         //dd($mailbox);
         // fetch mail by one day previous
         $mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime('-1 day')));
         if (!$mailsIds) {
             die('Mailbox is empty');
         }
         foreach ($mailsIds as $mailId) {
             // get overview of mails
             $overview = $mailbox->get_overview($mailId);
             // check if mails are unread
             $var = $overview[0]->seen ? 'read' : 'unread';
             // load only unread mails
             if ($var == 'unread') {
                 $mail = $mailbox->getMail($mailId);
                 //dd($mail);
                 $body = $mail->textHtml;
                 if ($body != null) {
                     $body = self::trimTableTag($body);
                 }
                 // if mail body has no messages fetch backup mail
                 if ($body == null) {
                     $body = $mail->textPlain;
                 }
                 if ($body == null) {
                     $attach = $mail->getAttachments();
                     $path = $attach['html-body']->filePath;
                     if ($path == null) {
                         $path = $attach['text-body']->filePath;
                     }
                     $body = file_get_contents($path);
                     //dd($body);
                     $body = self::trimTableTag($body);
                 }
                 // check if mail has subject
                 if (isset($mail->subject)) {
                     $subject = $mail->subject;
                 } else {
                     $subject = 'No Subject';
                 }
                 // fetch mail from details
                 $fromname = $mail->fromName;
                 $fromaddress = $mail->fromAddress;
                 // store mail details id thread tables
                 $thread = new Thread();
                 $thread->name = $fromname;
                 $thread->email = $fromaddress;
                 $thread->title = $subject;
                 $thread->body = $body;
                 $thread->save();
                 // fetch mail attachments
                 foreach ($mail->getAttachments() as $attachment) {
                     $support = 'support';
                     $dir_img_paths = __DIR__;
                     $dir_img_path = explode('/code', $dir_img_paths);
                     $filepath = explode('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'public', $attachment->filePath);
                     $path = public_path() . $filepath[1];
                     $filesize = filesize($path);
                     $file_data = file_get_contents($path);
                     $ext = pathinfo($attachment->filePath, PATHINFO_EXTENSION);
                     $imageid = $attachment->id;
                     $string = str_replace('-', '', $attachment->name);
                     $filename = explode('src', $attachment->filePath);
                     $filename = str_replace('\\', '', $filename);
                     $body = str_replace('cid:' . $imageid, $filepath[1], $body);
                     $pos = strpos($body, $filepath[1]);
                     if ($pos == false) {
                         $upload = new Attachment();
                         $upload->file = $file_data;
                         $upload->thread_id = $thread->id;
                         $upload->name = $filepath[1];
                         $upload->type = $ext;
                         $upload->size = $filesize;
                         $upload->poster = 'ATTACHMENT';
                         $upload->save();
                     } else {
                         $upload = new Attachment();
                         $upload->file = $file_data;
                         $upload->thread_id = $thread->id;
                         $upload->name = $filepath[1];
                         $upload->type = $ext;
                         $upload->size = $filesize;
                         $upload->poster = 'INLINE';
                         $upload->save();
                     }
                     unlink($path);
                 }
                 // run an encoding fix before saving mail details
                 $body = Encoding::fixUTF8($body);
                 $thread->body = $body;
                 $thread->save();
             } else {
             }
         }
     }
     return redirect()->route('home');
 }
 private function cleanup_text($text)
 {
     $text = trim(preg_replace('/(\\s\\s+|\\t|\\n)/', ' ', $text));
     return Encoding::fixUTF8($text);
 }
function createShittalkRow($text)
{
    if (strlen($text) > 128) {
        $text = substr($text, 0, 128);
        //shorten to source game default length
    }
    $text_to_utf8 = Encoding::toUTF8($text);
    $text = Encoding::fixUTF8($text_to_utf8);
    $text_escaped = mysql_escape_mimic(strip_double_quotes($text));
    $today = mysql_escape_mimic(date("Y-m-d H:i:s"));
    $sql = "INSERT INTO `shittalkDB`\n            (`text`, `date_created`, `custom`)\n            VALUES ('{$text_escaped}', '{$today}', 1);";
    $result = mySqlQuery($sql);
    return $result;
}
 $enc = mb_detect_encoding($text, mb_list_encodings(), true);
 //overwrite ASCII
 if ($enc === false) {
     $enc = "UNKWN";
     $textToSend = $text;
     $saveToOpen = false;
 } elseif ($enc !== "UTF-8") {
     //$text = mb_convert_encoding($text, 'UTF-8', $enc);
     /*  
                    if(function_exists('incov'))
                    {
     $text = incov($enc,'UTF-8',$text);       
                    }
                    else {
     */
     $textToSend = \ForceUTF8\Encoding::fixUTF8(\ForceUTF8\Encoding::toUTF8($text));
     $test = mb_convert_encoding($textToSend, $enc, 'UTF-8');
     if ($test != $text) {
         $saveToOpen = false;
     } else {
         $saveToOpen = true;
     }
     //}
 } else {
     $textToSend = $text;
     $saveToOpen = true;
 }
 if ($enc === 'ASCII' && mb_check_encoding($text, 'UTF-8')) {
     $enc = 'UTF-8';
 }
 $json = new \stdClass();
 /**
  * SchemaPropertyElementHistory::getContent()
  *
  * @return string
  */
 public function getFeedContent()
 {
     $uriPrefix = sfContext::getInstance()->getRequest()->getUriPrefix();
     $language = $this->getLanguage() ? " (" . $this->getLanguage() . ")" : "";
     $content = "On " . $this->getCreatedAt("D M j Y") . " at " . $this->getCreatedAt("G:i:s T") . ",  " . '<a href="' . $this->getFeedAuthorLink() . '">' . $this->getFeedAuthorName() . '</a>, <br />working on the Element: <a href="' . $uriPrefix . "/schemaprop/show/id/" . $this->getSchemaPropertyId() . '.html">' . $this->getSchemaPropertyRelatedBySchemaPropertyId()->getLabel() . '</a>, <br />' . $this->getAction() . ' the <a href="' . $uriPrefix . "/schemapropel/show/id/" . $this->getSchemaPropertyElementId() . '.html">' . $this->getProfileProperty()->getLabel() . $language . '</a> Property';
     $content .= 'updated' == $this->getAction() ? '<br /> To: ' : ':';
     $content .= '<div style="background-color:#eeffee; padding:3px" >';
     $content .= Encoding::fixUTF8($this->getObject());
     $content .= '</div>';
     if ('updated' == $this->getAction()) {
         $content .= ' From: ';
         $content .= '<div style="background-color:#ffffee; padding:3px" >';
         $previous = $this->getPrevious();
         if ($previous) {
             $content .= $previous->getObject();
         }
         $content .= '</div>';
     }
     return $content;
 }
function test_double_encoded_arrays_fix()
{
    $arr1 = array(utf8_encode(file_get_contents(dirname(__FILE__) . "/data/test1Latin.txt")), utf8_encode(file_get_contents(dirname(__FILE__) . "/data/test1.txt")), utf8_encode(file_get_contents(dirname(__FILE__) . "/data/test1Latin.txt")));
    $arr2 = array(file_get_contents(dirname(__FILE__) . "/data/test1.txt"), file_get_contents(dirname(__FILE__) . "/data/test1.txt"), file_get_contents(dirname(__FILE__) . "/data/test1.txt"));
    return Encoding::fixUTF8($arr1) == $arr2;
}
 /**
  * Converts BB-Code
  *
  * @param string WoWBB-BB-Code
  * @return string MyBB-BB-Code
  */
 public function bb2my($input)
 {
     /**
      * Force UTF-8
      * @see Encoding.php
      */
     $input = \ForceUTF8\Encoding::fixUTF8($input);
     /**
      * HTML to Specialchar
      */
     $input = html_entity_decode($input, ENT_QUOTES | ENT_HTML5, 'UTF-8');
     /**
      * Regexes from WowBB
      */
     $input = preg_replace('/\\[\\s*(\\/*)\\s*(\\S*)\\s*(=*)\\s*("?)(.*)("?)\\s*\\]/isU', '[\\1\\2\\3\\4\\5\\6]', $input);
     $input = preg_replace('/\\[([\\/=*a-z0-9]+):[a-z0-9]*(=".+")?\\]/iU', '[\\1\\2]', $input);
     $input = preg_replace('/(?<!http:\\/\\/|\\/)(www\\.\\S+)\\b/isU', 'http://\\1', $input);
     $input = preg_replace('/(?<!\\]|=|")http(s?):\\/\\/([^\\s<\\[]+)/is', '[url]http\\1://\\2[/url]', $input);
     /**
      * Own Replace
      */
     $input = str_replace("&nbsp;", " ", $input);
     $input = str_replace("[line]", '[hr]', $input);
     $input = str_replace("[/*]", "", $input);
     $input = preg_replace('/\\[([^\\]"]+)="([^\\]]+)"\\]/is', '[\\1=\\2]', $input);
     $input = preg_replace('/\\[(\\/?)indent\\]/i', '[\\1quote]', $input);
     $input = preg_replace('/\\[(\\/?)php\\]/i', '[\\1code]', $input);
     /**
      * [user=...]...[/user]-Convert
      */
     $input = preg_replace_callback('/\\[user="******"?\\](.*?)\\[\\/user\\]/si', function ($matches) {
         $my_uid = $this->uid2my($matches[1], 0);
         if (!$my_uid) {
             return $matches[2];
         } else {
             return "[user="******"]" . $matches[2] . "[/user]";
         }
     }, $input);
     /**
      * Convert Sizes from HTML3-font-tag
      */
     $input = preg_replace_callback('/\\[size="?([+-]?[0-9]+)"?\\]/is', function ($matches) {
         $ret = "[size=";
         switch ($matches[1]) {
             case "-9":
             case "-8":
             case "-7":
             case "-6":
             case "-5":
             case "-4":
             case "-3":
             case "-2":
                 $ret .= "62.5%";
                 break;
             case "-1":
                 $ret .= "smaller";
                 break;
             case "-0":
             case "+0":
                 $ret .= "100%";
                 break;
             case "0":
                 $ret .= "xx-small";
                 break;
             case "1":
                 $ret .= "x-small";
                 break;
             case "2":
                 $ret .= "small";
                 break;
             case "3":
                 $ret .= "medium";
                 break;
             case "4":
                 $ret .= "large";
                 break;
             case "5":
                 $ret .= "x-large";
                 break;
             case "6":
                 $ret .= "xx-large";
                 break;
             case "7":
             case "8":
             case "9":
                 $ret .= "48px";
                 break;
             case "+1":
                 $ret .= "larger";
                 break;
             case "+2":
                 $ret .= "150%";
                 break;
             case "+3":
                 $ret .= "200%";
                 break;
             case "+4":
             case "+5":
             case "+6":
             case "+7":
             case "+8":
             case "+9":
                 $ret .= "300%";
                 break;
             default:
                 $ret .= (int) $matches[1] . "px";
         }
         $ret .= "]";
         return $ret;
     }, $input);
     /**
      * Not supported => delete
      */
     $input = preg_replace('/\\[(sound|real|quicktime|media|fl|flash)[^\\]]*\\].*?\\[\\/\\1\\]/si', "", $input);
     $input = preg_replace('/\\[\\/?(?:blur|glow)\\]/i', "", $input);
     $input = preg_replace('/\\[\\/?(?:shadow|move(?:up|[ldr])?|scroll)[^\\]]*\\]/i', "", $input);
     return $input;
 }
 public function genStatusIcon($res, $tt = null)
 {
     $glyphs = array("ok" => "glyphicon-ok text-success", "warning" => "glyphicon-warning-sign text-warning", "error" => "glyphicon-remove text-danger", "unknown" => "glyphicon-question-sign text-info", "info" => "glyphicon-info-sign text-info", "critical" => "glyphicon-fire text-danger");
     // Are we being asked for an alert we actually know about?
     if (!isset($glyphs[$res])) {
         return array('type' => 'unknown', "tooltip" => "Don't know what {$res} is", "glyph-class" => $glyphs['unknown']);
     }
     if ($tt === null) {
         // No Tooltip
         return array('type' => $res, "tooltip" => null, "glyph-class" => $glyphs[$res]);
     } else {
         // Generate a tooltip
         $html = '';
         if (is_array($tt)) {
             foreach ($tt as $line) {
                 $html .= htmlentities(\ForceUTF8\Encoding::fixUTF8($line), ENT_QUOTES, "UTF-8") . "\n";
             }
         } else {
             $html .= htmlentities(\ForceUTF8\Encoding::fixUTF8($tt), ENT_QUOTES, "UTF-8");
         }
         return array('type' => $res, "tooltip" => $html, "glyph-class" => $glyphs[$res]);
     }
     return '';
 }
 /**
  * @param $product
  * @return object
  */
 private function productFields($product)
 {
     $fields = $product->felder;
     $learningContent = [];
     $description = [];
     if ($fields) {
         foreach ($fields as $field) {
             $oField[] = $field[2];
             //2 = inhaltstype = html
             switch ($oField[0]->name) {
                 case 'S_Inhalte':
                     // Produktinhalte (S_Inhalte)
                     $learningContent = $this->removeStyle(\ForceUTF8\Encoding::fixUTF8($oField[0]->inhalt));
                     break;
                 case 'S_Beschreibung':
                     // Produktbeschreibung (S_Beschreibung)
                     $description = $oField[0]->inhalt;
                     //@todo: fixUTF8 nach Stefans Fix nicht mehr notwendig
                     $description = $this->removeStyle($description);
                     break;
                 case 'S_Teilnehmerkreis':
                     $participants = $oField[0]->inhalt;
                     $participants = $this->removeStyle($participants);
                     break;
             }
         }
     }
     $contents = ['description' => $description ? $description : '', 'learningContent' => $learningContent ? $learningContent : '', 'participants' => $participants ? $participants : ''];
     return (object) $contents;
 }