Exemple #1
0
function HTML2Text($text)
{
    # strip HTML, and turn links into the full URL
    $text = preg_replace("/\r/", "", $text);
    #$text = preg_replace("/\n/","###NL###",$text);
    $text = preg_replace("/<script[^>]*>(.*?)<\\/script\\s*>/is", "", $text);
    $text = preg_replace("/<style[^>]*>(.*?)<\\/style\\s*>/is", "", $text);
    # would prefer to use < and > but the strip tags below would erase that.
    #  $text = preg_replace("/<a href=\"(.*?)\"[^>]*>(.*?)<\/a>/is","\\2\n{\\1}",$text,100);
    #  $text = preg_replace("/<a href=\"(.*?)\"[^>]*>(.*?)<\/a>/is","[URLTEXT]\\2[/URLTEXT][LINK]\\1[/LINK]",$text,100);
    $text = preg_replace("/<a[^>]*href=[\"\\'](.*)[\"\\'][^>]*>(.*)<\\/a>/Umis", "[URLTEXT]\\2[ENDURLTEXT][LINK]\\1[ENDLINK]\n", $text);
    $text = preg_replace("/<b>(.*?)<\\/b\\s*>/is", "*\\1*", $text);
    $text = preg_replace("/<h[\\d]>(.*?)<\\/h[\\d]\\s*>/is", "**\\1**\n", $text);
    #  $text = preg_replace("/\s+/"," ",$text);
    $text = preg_replace("/<i>(.*?)<\\/i\\s*>/is", "/\\1/", $text);
    $text = preg_replace("/<\\/tr\\s*?>/i", "<\\/tr>\n\n", $text);
    $text = preg_replace("/<\\/p\\s*?>/i", "<\\/p>\n\n", $text);
    $text = preg_replace("/<br[^>]*?>/i", "<br>\n", $text);
    $text = preg_replace("/<br[^>]*?\\/>/i", "<br\\/>\n", $text);
    $text = preg_replace("/<table/i", "\n\n<table", $text);
    $text = strip_tags($text);
    # find all URLs and replace them back
    preg_match_all('~\\[URLTEXT\\](.*)\\[ENDURLTEXT\\]\\[LINK\\](.*)\\[ENDLINK\\]~Umis', $text, $links);
    foreach ($links[0] as $matchindex => $fullmatch) {
        $linktext = $links[1][$matchindex];
        $linkurl = $links[2][$matchindex];
        # check if the text linked is a repetition of the URL
        if (trim($linktext) == trim($linkurl) || 'http://' . trim($linktext) == trim($linkurl)) {
            $linkreplace = $linkurl;
        } else {
            ## if link is an anchor only, take it out
            if (strpos($linkurl, '#') !== false) {
                $linkreplace = $linktext;
            } else {
                $linkreplace = $linktext . ' <' . $linkurl . '>';
            }
        }
        #  $text = preg_replace('~'.preg_quote($fullmatch).'~',$linkreplace,$text);
        $text = str_replace($fullmatch, $linkreplace, $text);
    }
    $text = preg_replace("/<a href=[\"\\'](.*?)[\"\\'][^>]*>(.*?)<\\/a>/is", "[URLTEXT]\\2[ENDURLTEXT][LINK]\\1[ENDLINK]", $text, 500);
    $text = replaceChars($text);
    $text = preg_replace("/###NL###/", "\n", $text);
    $text = preg_replace("/\n /", "\n", $text);
    $text = preg_replace("/\t/", " ", $text);
    # reduce whitespace
    while (preg_match("/  /", $text)) {
        $text = preg_replace("/  /", " ", $text);
    }
    while (preg_match("/\n\\s*\n\\s*\n/", $text)) {
        $text = preg_replace("/\n\\s*\n\\s*\n/", "\n\n", $text);
    }
    $ww = (int) getConfig("wordwrap");
    if (!$ww) {
        $ww = 70;
    }
    $text = wordwrap($text, $ww);
    return $text;
}
Exemple #2
0
function validaCidade($cidade, $arr)
{
    $boo = false;
    for ($i = 0; $i < count($arr); $i++) {
        if ($cidade == replaceChars($arr[$i]['nome'])) {
            $boo = true;
            break;
        }
    }
    return $boo;
}
$toleranceK = 1000 * $factor;
/******* verbandsgemeinde *********************/
$bufferV = 100 * $factor;
$arrayV = array();
$toleranceV = 1000 * $factor;
/******* strasse *********************/
$bufferSTR = 100 * $factor;
$arraySTR = array();
$toleranceSTR = 100 * $factor;
/******* Strasse / Hsnr ****************/
$bufferSH = 100 * $factor;
$arraySH = array();
$toleranceSH = 1000 * $factor;
/****** Workflow *********************************/
/**/
$astr = split(",", replaceChars($sstr));
if (count($astr) == 1) {
    $astr[0] = trim($astr[0]);
    $plz = getPlz($astr[0]);
    $hsnr = getNr($astr[0]);
    if ($plz != false) {
        //checkSize($astr[0]);
        checkWP($plz, strtoupper(getCity($astr[0])));
        checkGfromWP();
    } else {
        if ($hsnr != false) {
        } else {
            if ($hsnr == false && $plz == false) {
                checkWP(false, strtoupper($astr[0]));
                checkG(strtoupper($astr[0]));
                checkGfromWP();
 }
 function reverseReplaceChars($string, $charset)
 {
     $string = str_replace($charset["replacing"], $charset["replaced"], $string);
     /* nahradime znaky */
     return $string;
 }
 /* úprava šifry */
 $cipherChars = readAlphabet($cipher_alphabet, $cipher_alphabet_size);
 /* nacteni do poli */
 $cipher = replaceChars($cipher, $cipherChars);
 //echo "Nová šifra:<br/>" . $cipher . "<br/><br/>";
 /* úprava vstupního souboru */
 $inputChars = readAlphabet($input_alphabet, $input_alphabet_size);
 /* nacteni do poli */
 $input = replaceChars($input, $inputChars);
 //echo "Nový vstup:<br/>" . $input . "<br/><br/>";
 /* natahneme sifru */
 $iterator = 0;
 while (strlen($cipher) <= strlen($input)) {
     $iterator++;
     $cipher .= $cipher;
 }
 /* vypis infa o kopirovani sifry */
 //echo "Počet kopírování šifry: " . $iterator . "<br/>";
 //echo "Velikost šifry: " . strlen($cipher) . "<br/>";
 //echo "Velikost vstupu: " . strlen($input) . "<br/><br/>";
 function encode($a, $b, $alphabet)
 {
     $max = strlen($alphabet);
     /* delka abecedy */
Exemple #5
0
function stripHTML($text)
{
    # strip HTML, and turn links into the full URL
    $text = preg_replace("/\r/", "", $text);
    #$text = preg_replace("/\n/","###NL###",$text);
    $text = preg_replace("/<script[^>]*>(.*?)<\\/script\\s*>/is", "", $text);
    $text = preg_replace("/<style[^>]*>(.*?)<\\/style\\s*>/is", "", $text);
    # would prefer to use < and > but the strip tags below would erase that.
    #  $text = preg_replace("/<a href=\"(.*?)\"[^>]*>(.*?)<\/a>/is","\\2\n{\\1}",$text,100);
    $text = preg_replace("/<a href=\"(.*?)\"[^>]*>(.*?)<\\/a>/is", "[URLTEXT]\\2[/URLTEXT][LINK]\\1[/LINK]", $text, 100);
    $text = preg_replace("/<b>(.*?)<\\/b\\s*>/is", "*\\1*", $text);
    $text = preg_replace("/<h[\\d]>(.*?)<\\/h[\\d]\\s*>/is", "**\\1**\n", $text);
    $text = preg_replace("/\\s+/", " ", $text);
    $text = preg_replace("/<i>(.*?)<\\/i\\s*>/is", "/\\1/", $text);
    $text = preg_replace("/<\\/tr\\s*?>/i", "<\\/tr>\n\n", $text);
    $text = preg_replace("/<\\/p\\s*?>/i", "<\\/p>\n\n", $text);
    $text = preg_replace("/<br\\s*?>/i", "<br>\n", $text);
    $text = preg_replace("/<br\\s*?\\/>/i", "<br\\/>\n", $text);
    $text = preg_replace("/<table/i", "\n\n<table", $text);
    $text = strip_tags($text);
    # find all URLs and replace them back
    preg_match_all('~\\[URLTEXT\\](.*)\\[/URLTEXT\\]\\[LINK\\](.*)\\[/LINK\\]~Ui', $text, $links);
    foreach ($links[0] as $matchindex => $fullmatch) {
        $linktext = $links[1][$matchindex];
        $linkurl = $links[2][$matchindex];
        # check if the text linked is a repetition of the URL
        if (strtolower(trim($linktext)) == strtolower(trim($linkurl)) || 'http://' . strtolower(trim($linktext)) == strtolower(trim($linkurl))) {
            $linkreplace = $linkurl;
        } else {
            $linkreplace = $linktext . ' <' . $linkurl . '>';
        }
        $text = preg_replace('~' . preg_quote($fullmatch) . '~', $linkreplace, $text);
    }
    $text = preg_replace("/<a href=\"(.*?)\"[^>]*>(.*?)<\\/a>/is", "[URLTEXT]\\2[/URLTEXT][LINK]\\1[/LINK]", $text, 100);
    $text = replaceChars($text);
    $text = preg_replace("/###NL###/", "\n", $text);
    # reduce whitespace
    while (preg_match("/  /", $text)) {
        $text = preg_replace("/  /", " ", $text);
    }
    while (preg_match("/\n\\s*\n\\s*\n/", $text)) {
        $text = preg_replace("/\n\\s*\n\\s*\n/", "\n\n", $text);
    }
    $text = wordwrap($text, 70);
    return $text;
}