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; }
/// 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); }
Respond::NotFoundPage(); } if (!($attachment = getAttachmentByOnlyName($blogid, $suri['value']))) { Respond::NotFoundPage(); } $fp = fopen(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$attachment['name']}", 'rb'); if (!$fp) { Respond::NotFoundPage(); } $fstat = fstat($fp); if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); if ($modifiedSince && $modifiedSince >= $fstat['mtime']) { fclose($fp); header('HTTP/1.1 304 Not Modified'); header('Connection: close'); exit; } } ini_set('zlib.output_compression', 'off'); header('Content-Disposition: attachment; filename="' . rawurlencode(Utils_Unicode::bring($attachment['label'])) . '"'); header('Content-Transfer-Encoding: binary'); header('Last-Modified: ' . Timestamp::getRFC1123GMT($fstat['mtime'])); header('Content-Length: ' . $fstat['size']); header('Content-Type: ' . $attachment['mime']); header('Cache-Control: private'); header('Pragma: no-cache'); header('Connection: close'); fpassthru($fp); fclose($fp); downloadAttachment($attachment['name']);
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); }