예제 #1
0
 function open($xml, $encoding = null)
 {
     if (!empty($encoding) && strtolower($encoding) != 'utf-8' && !Utils_Unicode::validate($xml)) {
         if (preg_match('/^<\\?xml[^<]*\\s+encoding=["\']?([\\w-]+)["\']?/', $xml, $matches)) {
             $encoding = $matches[1];
             $xml = preg_replace('/^(<\\?xml[^<]*\\s+encoding=)["\']?[\\w-]+["\']?/', '$1"utf-8"', $xml, 1);
         }
         if (strcasecmp($encoding, 'utf-8')) {
             $xml = Utils_Unicode::bring($xml, $encoding);
             if (is_null($xml)) {
                 $this->error = XML_ERROR_UNKNOWN_ENCODING;
                 return false;
             }
         }
     } else {
         if (substr($xml, 0, 3) == "") {
             $xml = substr($xml, 3);
         }
     }
     $p = xml_parser_create();
     xml_set_object($p, $this);
     xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($p, 'o', 'c');
     xml_set_character_data_handler($p, 'd');
     xml_set_default_handler($p, 'x');
     $this->tree = array('children' => array());
     $this->_cursor =& $this->tree;
     $this->_cdata = false;
     xml_parse($p, $xml);
     unset($this->_cursor);
     unset($this->_cdata);
     $this->error = xml_get_error_code($p);
     xml_parser_free($p);
     return $this->error == XML_ERROR_NONE;
 }
예제 #2
0
                trashCommentInOwner($blogid, $comment['id']);
            }
        }
    }
    POD::free($result);
}
if ($result = POD::query("SELECT id, url, site, subject, excerpt FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}")) {
    while ($trackback = POD::fetch($result)) {
        setProgress($item++ / $items * 100, _t('걸린 글 데이터를 교정하고 있습니다.'));
        $correction = '';
        if (!Utils_Unicode::validate($trackback['url'])) {
            $correction .= ' url = \'' . POD::escapeString(Utils_Unicode::correct($trackback['url'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['site'])) {
            $correction .= ' site = \'' . POD::escapeString(Utils_Unicode::correct($trackback['site'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['subject'])) {
            $correction .= ' subject = \'' . POD::escapeString(Utils_Unicode::correct($trackback['subject'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['excerpt'])) {
            $correction .= ' excerpt = \'' . POD::escapeString(Utils_Unicode::correct($trackback['excerpt'], '?')) . '\'';
        }
        if (strlen($correction) > 0) {
            POD::query("UPDATE {$database['prefix']}RemoteResponses SET {$correction} WHERE blogid = {$blogid} AND id = {$trackback['id']}");
            $corrected++;
        }
    }
    POD::free($result);
}
setProgress(100, _t('완료되었습니다.') . "({$corrected})");
finish();
예제 #3
0
파일: index.php 프로젝트: ragi79/Textcube
function bringSearchWord($originalURL, $originalHost)
{
    $matches = array();
    $decodedURL = '';
    $decodedKeyword = '';
    //	$originalURL = urlutfchr($originalURL);
    if (preg_match('/\\W(q|query|k|keyword|search|stext|nlia|aqa|wd)(?:=|%3D)([^&]+)/i', $originalURL, $matches)) {
        $decodedKeyword = unified_decode($matches[2]);
        $decodedURL = unified_decode($originalURL);
    } else {
        if (strpos($originalHost, 'images.google.') !== false && preg_match('/%3Fsearch%3D([^&]+)/i', $originalURL, $matches)) {
            $decodedKeyword = unified_decode($matches[1]);
            $decodedURL = unified_decode($originalURL);
        } else {
            if (strpos($originalURL, 'yahoo') !== false && preg_match('/\\Wp=([^&]+)/i', $originalURL, $matches)) {
                $decodedKeyword = unified_decode($matches[1]);
                $decodedURL = unified_decode($originalURL);
            } else {
                if (preg_match('@/search/(?:\\w+/)*([^/?]+)@i', $originalURL, $matches)) {
                    $decodedKeyword = unified_decode($matches[1]);
                    $decodedURL = unified_decode($originalURL);
                }
            }
        }
    }
    if (!Utils_Unicode::validate($decodedKeyword)) {
        $decodedKeyword = Utils_Unicode::correct(Utils_Unicode::bring($decodedKeyword));
        $decodedURL = Utils_Unicode::correct(Utils_Unicode::bring($decodedURL));
    }
    return array($decodedKeyword, $decodedURL);
}
예제 #4
0
/// Copyright (c) 2004-2015, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
$IV = array('GET' => array('rss' => array('url')));
require ROOT . '/library/preprocessor.php';
importlib('model.blog.link');
if (!empty($_GET['rss'])) {
    list($st, $header, $body, $lmdate, $rval) = @xml_parser($_GET['rss'], '');
    $result = array();
    if ($rval) {
        list($title, $link) = str_dbi_check(@get_siteinfo($rval));
        if (Utils_Unicode::validate($title, true)) {
            $result['name'] = correctTTForXmlText(Utils_Unicode::correct(htmlspecialchars(trim($title))));
        } else {
            $result['name'] = correctTTForXmlText(Utils_Unicode::bring(htmlspecialchars(trim($title))));
        }
        if (Utils_Unicode::validate($link, true)) {
            $result['url'] = correctTTForXmlText(Utils_Unicode::correct(htmlspecialchars(trim($link))));
        } else {
            $result['url'] = correctTTForXmlText(Utils_Unicode::bring(htmlspecialchars(trim($link))));
        }
        Respond::PrintResult($result);
    } else {
        $result['url'] = $_GET['rss'];
        $result['name'] = '';
        Respond::PrintResult($result);
    }
    exit;
} else {
    Respond::ResultPage(-1);
}
function isUTF8($str)
{
    return Utils_Unicode::validate($str);
}