Add simplepie
|
@ -0,0 +1,26 @@
|
||||||
|
Copyright (c) 2004-2007, Ryan Parman and Geoffrey Sneddon.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the SimplePie Team nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without specific prior
|
||||||
|
written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
||||||
|
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
|
||||||
|
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,53 @@
|
||||||
|
# SimplePie
|
||||||
|
|
||||||
|
## Authors and contributors
|
||||||
|
|
||||||
|
* [Ryan Parman](http://ryanparman.com)
|
||||||
|
* [Geoffrey Sneddon](http://gsnedders.com)
|
||||||
|
* [Ryan McCue](http://ryanmccue.info)
|
||||||
|
* [Michael Shipley](http://michaelpshipley.com)
|
||||||
|
* [Steve Minutillo](http://minutillo.com/steve/)
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[New BSD license](http://www.opensource.org/licenses/bsd-license.php)
|
||||||
|
|
||||||
|
|
||||||
|
## Project status
|
||||||
|
|
||||||
|
SimplePie is currently maintained by Ryan McCue.
|
||||||
|
|
||||||
|
At the moment, there isn't a lot of active development happening. If the community decides that SimplePie is a valuable tool, then the community will come together to maintain it into the future.
|
||||||
|
|
||||||
|
If you're interested in getting involved with SimplePie, please get in touch with Ryan McCue.
|
||||||
|
|
||||||
|
|
||||||
|
## What comes in the package?
|
||||||
|
|
||||||
|
1. `simplepie.inc` - The SimplePie library. This is all that's required for your pages.
|
||||||
|
2. `README.markdown` - This document.
|
||||||
|
3. `LICENSE.txt` - A copy of the BSD license.
|
||||||
|
4. `compatibility_test/` - The SimplePie compatibility test that checks your server for required settings.
|
||||||
|
5. `demo/` - A basic feed reader demo that shows off some of SimplePie's more noticable features.
|
||||||
|
6. `idn/` - A third-party library that SimplePie can optionally use to understand Internationalized Domain Names (IDNs).
|
||||||
|
7. `test/` - SimplePie's unit test suite.
|
||||||
|
|
||||||
|
|
||||||
|
## To start the demo
|
||||||
|
|
||||||
|
1. Upload this package to your webserver.
|
||||||
|
2. Make sure that the cache folder inside of the demo folder is server-writable.
|
||||||
|
3. Navigate your browser to the demo folder.
|
||||||
|
|
||||||
|
|
||||||
|
## Need support?
|
||||||
|
|
||||||
|
For further setup and install documentation, function references, etc., visit:
|
||||||
|
[http://simplepie.org/wiki/](http://simplepie.org/wiki/)
|
||||||
|
|
||||||
|
For bug reports and feature requests, visit:
|
||||||
|
[http://github.com/rmccue/simplepie/issues](http://github.com/rmccue/simplepie/issues)
|
||||||
|
|
||||||
|
Support mailing list -- powered by users, for users.
|
||||||
|
[http://tech.groups.yahoo.com/group/simplepie-support/](http://tech.groups.yahoo.com/group/simplepie-support/)
|
|
@ -0,0 +1,7 @@
|
||||||
|
SIMPLEPIE COMPATIBILITY TEST
|
||||||
|
|
||||||
|
1) Upload sp_compatibility_test.php to the web-accessible root of your website.
|
||||||
|
For example, if your website is www.example.com, upload it so that you can get
|
||||||
|
to it at www.example.com/sp_compatibility_test.php
|
||||||
|
|
||||||
|
2) Open your web browser and go to the page you just uploaded.
|
|
@ -0,0 +1,178 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'simplepie.inc';
|
||||||
|
|
||||||
|
function normalize_character_set($charset)
|
||||||
|
{
|
||||||
|
return strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset));
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_character_set_list()
|
||||||
|
{
|
||||||
|
$file = new SimplePie_File('http://www.iana.org/assignments/character-sets');
|
||||||
|
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data = explode("\n", $file->body);
|
||||||
|
unset($file);
|
||||||
|
|
||||||
|
foreach ($data as $line)
|
||||||
|
{
|
||||||
|
// New character set
|
||||||
|
if (substr($line, 0, 5) === 'Name:')
|
||||||
|
{
|
||||||
|
// If we already have one, push it on to the array
|
||||||
|
if (isset($aliases))
|
||||||
|
{
|
||||||
|
for ($i = 0, $count = count($aliases); $i < $count; $i++)
|
||||||
|
{
|
||||||
|
$aliases[$i] = normalize_character_set($aliases[$i]);
|
||||||
|
}
|
||||||
|
$charsets[$preferred] = array_unique($aliases);
|
||||||
|
natsort($charsets[$preferred]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = 5 + strspn($line, "\x09\x0A\x0B\xC\x0D\x20", 5);
|
||||||
|
$chars = strcspn($line, "\x09\x0A\x0B\xC\x0D\x20", $start);
|
||||||
|
$aliases = array(substr($line, $start, $chars));
|
||||||
|
$preferred = end($aliases);
|
||||||
|
}
|
||||||
|
// Another alias
|
||||||
|
elseif(substr($line, 0, 6) === 'Alias:')
|
||||||
|
{
|
||||||
|
$start = 7 + strspn($line, "\x09\x0A\x0B\xC\x0D\x20", 7);
|
||||||
|
$chars = strcspn($line, "\x09\x0A\x0B\xC\x0D\x20", $start);
|
||||||
|
$aliases[] = substr($line, $start, $chars);
|
||||||
|
|
||||||
|
if (end($aliases) === 'None')
|
||||||
|
{
|
||||||
|
array_pop($aliases);
|
||||||
|
}
|
||||||
|
elseif (substr($line, 7 + $chars + 1, 21) === '(preferred MIME name)')
|
||||||
|
{
|
||||||
|
$preferred = end($aliases);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compatibility replacements
|
||||||
|
$compat = array(
|
||||||
|
'EUC-KR' => 'windows-949',
|
||||||
|
'GB2312' => 'GBK',
|
||||||
|
'GB_2312-80' => 'GBK',
|
||||||
|
'ISO-8859-1' => 'windows-1252',
|
||||||
|
'ISO-8859-9' => 'windows-1254',
|
||||||
|
'ISO-8859-11' => 'windows-874',
|
||||||
|
'KS_C_5601-1987' => 'windows-949',
|
||||||
|
'TIS-620' => 'windows-874',
|
||||||
|
//'US-ASCII' => 'windows-1252',
|
||||||
|
'x-x-big5' => 'Big5',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($compat as $real => $replace)
|
||||||
|
{
|
||||||
|
if (isset($charsets[$real]) && isset($charsets[$replace]))
|
||||||
|
{
|
||||||
|
$charsets[$replace] = array_merge($charsets[$replace], $charsets[$real]);
|
||||||
|
unset($charsets[$real]);
|
||||||
|
}
|
||||||
|
elseif (isset($charsets[$real]))
|
||||||
|
{
|
||||||
|
$charsets[$replace] = $charsets[$real];
|
||||||
|
$charsets[$replace][] = normalize_character_set($replace);
|
||||||
|
unset($charsets[$real]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$charsets[$replace][] = normalize_character_set($real);
|
||||||
|
}
|
||||||
|
$charsets[$replace] = array_unique($charsets[$replace]);
|
||||||
|
natsort($charsets[$replace]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort it
|
||||||
|
uksort($charsets, 'strnatcasecmp');
|
||||||
|
|
||||||
|
// Check that nothing matches more than one
|
||||||
|
$all = call_user_func_array('array_merge', $charsets);
|
||||||
|
$all_count = array_count_values($all);
|
||||||
|
if (max($all_count) > 1)
|
||||||
|
{
|
||||||
|
echo "Duplicated charsets:\n";
|
||||||
|
foreach ($all_count as $charset => $count)
|
||||||
|
{
|
||||||
|
if ($count > 1)
|
||||||
|
{
|
||||||
|
echo "$charset\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// And we're done!
|
||||||
|
return $charsets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function charset($charset)
|
||||||
|
{
|
||||||
|
$normalized_charset = normalize_character_set($charset);
|
||||||
|
if ($charsets = build_character_set_list())
|
||||||
|
{
|
||||||
|
foreach ($charsets as $preferred => $aliases)
|
||||||
|
{
|
||||||
|
if (in_array($normalized_charset, $aliases))
|
||||||
|
{
|
||||||
|
return $preferred;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $charset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_function()
|
||||||
|
{
|
||||||
|
if ($charsets = build_character_set_list())
|
||||||
|
{
|
||||||
|
$return = <<<EOF
|
||||||
|
function charset(\$charset)
|
||||||
|
{
|
||||||
|
// Normalization from UTS #22
|
||||||
|
switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\\1', \$charset)))
|
||||||
|
{
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
foreach ($charsets as $preferred => $aliases)
|
||||||
|
{
|
||||||
|
foreach ($aliases as $alias)
|
||||||
|
{
|
||||||
|
$return .= "\t\tcase " . var_export($alias, true) . ":\n";
|
||||||
|
}
|
||||||
|
$return .= "\t\t\treturn " . var_export($preferred, true) . ";\n\n";
|
||||||
|
}
|
||||||
|
$return .= <<<EOF
|
||||||
|
default:
|
||||||
|
return \$charset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF;
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (php_sapi_name() === 'cli' && realpath($_SERVER['argv'][0]) === __FILE__)
|
||||||
|
{
|
||||||
|
echo build_function();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,38 @@
|
||||||
|
/* SQLite */
|
||||||
|
CREATE TABLE cache_data (
|
||||||
|
id TEXT NOT NULL,
|
||||||
|
items SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
data BLOB NOT NULL,
|
||||||
|
mtime INTEGER UNSIGNED NOT NULL
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX id ON cache_data(id);
|
||||||
|
|
||||||
|
CREATE TABLE items (
|
||||||
|
feed_id TEXT NOT NULL,
|
||||||
|
id TEXT NOT NULL,
|
||||||
|
data TEXT NOT NULL,
|
||||||
|
posted INTEGER UNSIGNED NOT NULL
|
||||||
|
);
|
||||||
|
CREATE INDEX feed_id ON items(feed_id);
|
||||||
|
|
||||||
|
|
||||||
|
/* MySQL */
|
||||||
|
CREATE TABLE `cache_data` (
|
||||||
|
`id` TEXT CHARACTER SET utf8 NOT NULL,
|
||||||
|
`items` SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
`data` BLOB NOT NULL,
|
||||||
|
`mtime` INT UNSIGNED NOT NULL,
|
||||||
|
UNIQUE (
|
||||||
|
`id`(125)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `items` (
|
||||||
|
`feed_id` TEXT CHARACTER SET utf8 NOT NULL,
|
||||||
|
`id` TEXT CHARACTER SET utf8 NOT NULL,
|
||||||
|
`data` TEXT CHARACTER SET utf8 NOT NULL,
|
||||||
|
`posted` INT UNSIGNED NOT NULL,
|
||||||
|
INDEX `feed_id` (
|
||||||
|
`feed_id`(125)
|
||||||
|
)
|
||||||
|
);
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
include_once('../simplepie.inc');
|
||||||
|
|
||||||
|
// Parse it
|
||||||
|
$feed = new SimplePie();
|
||||||
|
if (isset($argv[1]) && $argv[1] !== '')
|
||||||
|
{
|
||||||
|
$feed->set_feed_url($argv[1]);
|
||||||
|
$feed->enable_cache(false);
|
||||||
|
$feed->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $feed->get_items();
|
||||||
|
|
||||||
|
foreach ($items as $item)
|
||||||
|
{
|
||||||
|
echo $item->get_title() . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
var_dump($feed->get_item_quantity());
|
||||||
|
|
||||||
|
?>
|
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 250 B |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 715 B |
After Width: | Height: | Size: 3.0 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="refresh" content="0;url=http://www.jeroenwijering.com/extras/readme.html">
|
||||||
|
</head>
|
||||||
|
</html>
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 851 B |
After Width: | Height: | Size: 36 KiB |
|
@ -0,0 +1,35 @@
|
||||||
|
/*=:project
|
||||||
|
scalable Inman Flash Replacement (sIFR) version 3.
|
||||||
|
|
||||||
|
=:file
|
||||||
|
Copyright: 2006 Mark Wubben.
|
||||||
|
Author: Mark Wubben, <http://novemberborn.net/>
|
||||||
|
|
||||||
|
=:history
|
||||||
|
* IFR: Shaun Inman
|
||||||
|
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
|
||||||
|
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
|
||||||
|
|
||||||
|
=:license
|
||||||
|
This software is licensed and provided under the CC-GNU LGPL.
|
||||||
|
See <http://creativecommons.org/licenses/LGPL/2.1/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* This is the print stylesheet to hide the Flash headlines from the browser... regular browser text headlines will now print as normal */
|
||||||
|
|
||||||
|
.sIFR-flash {
|
||||||
|
display: none !important;
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
position: absolute;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sIFR-alternate {
|
||||||
|
visibility: visible !important;
|
||||||
|
display: block !important;
|
||||||
|
position: static !important;
|
||||||
|
left: auto !important;
|
||||||
|
top: auto !important;
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*=:project
|
||||||
|
scalable Inman Flash Replacement (sIFR) version 3.
|
||||||
|
|
||||||
|
=:file
|
||||||
|
Copyright: 2006 Mark Wubben.
|
||||||
|
Author: Mark Wubben, <http://novemberborn.net/>
|
||||||
|
|
||||||
|
=:history
|
||||||
|
* IFR: Shaun Inman
|
||||||
|
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
|
||||||
|
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
|
||||||
|
|
||||||
|
=:license
|
||||||
|
This software is licensed and provided under the CC-GNU LGPL.
|
||||||
|
See <http://creativecommons.org/licenses/LGPL/2.1/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*---- sIFR ---*/
|
||||||
|
.sIFR-flash {
|
||||||
|
visibility: visible !important;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sIFR-replaced {
|
||||||
|
visibility: visible !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sIFR-alternate {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---- Header styling ---*/
|
|
@ -0,0 +1,40 @@
|
||||||
|
var yanone_kaffeesatz = {
|
||||||
|
src: './for_the_demo/yanone-kaffeesatz-bold.swf'
|
||||||
|
};
|
||||||
|
|
||||||
|
var lucida_grande = {
|
||||||
|
src: './for_the_demo/lucida-grande-bold.swf'
|
||||||
|
};
|
||||||
|
|
||||||
|
sIFR.activate(yanone_kaffeesatz);
|
||||||
|
//sIFR.activate(lucida_grande);
|
||||||
|
|
||||||
|
sIFR.replace(yanone_kaffeesatz, {
|
||||||
|
//sIFR.replace(lucida_grande, {
|
||||||
|
|
||||||
|
selector: 'h3.header',
|
||||||
|
wmode: 'transparent',
|
||||||
|
css: {
|
||||||
|
'.sIFR-root': {
|
||||||
|
'text-align': 'center',
|
||||||
|
'color': '#000000',
|
||||||
|
'font-weight': 'bold',
|
||||||
|
'background-color': '#EEFFEE',
|
||||||
|
|
||||||
|
'font-size': '50px', // For Yanone Kaffeesatz
|
||||||
|
//'font-size': '40px', // For Lucida Grande
|
||||||
|
|
||||||
|
'letter-spacing': '0' // For Yanone Kaffeesatz
|
||||||
|
//'letter-spacing': '-4' // For Lucida Grande
|
||||||
|
|
||||||
|
},
|
||||||
|
'a': {
|
||||||
|
'text-decoration': 'none',
|
||||||
|
'color': '#000000'
|
||||||
|
},
|
||||||
|
'a:hover': {
|
||||||
|
'text-decoration': 'none',
|
||||||
|
'color': '#666666'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,397 @@
|
||||||
|
/*
|
||||||
|
Theme Name: SimplePie
|
||||||
|
Theme URI: http://simplepie.org
|
||||||
|
Description: A simple, yet beautiful theme inspired by several cleanly designed websites.
|
||||||
|
Version: 1.4
|
||||||
|
Author: Ryan Parman
|
||||||
|
Author URI: http://skyzyx.com
|
||||||
|
Updated: 21 June 2007
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************
|
||||||
|
HYPERLINK STYLES
|
||||||
|
*********************************************/
|
||||||
|
a {
|
||||||
|
color:#369;
|
||||||
|
text-decoration:underline;
|
||||||
|
padding:0 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color:#fff !important;
|
||||||
|
background-color:#333;
|
||||||
|
text-decoration:none;
|
||||||
|
padding:0 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.nohover {
|
||||||
|
text-decoration:none;
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.nohover:hover {
|
||||||
|
background-color:transparent;
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.namelink {
|
||||||
|
padding:0;
|
||||||
|
margin:0;
|
||||||
|
overflow:hidden;
|
||||||
|
height:1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 a,
|
||||||
|
.sample_feeds a {
|
||||||
|
color:#000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************
|
||||||
|
GENERAL STYLES
|
||||||
|
*********************************************/
|
||||||
|
body {
|
||||||
|
/*font:12px/18px Verdana, sans-serif;*/
|
||||||
|
font:14px/1.5em "Lucida Grande", Tahoma, sans-serif;
|
||||||
|
letter-spacing:0px;
|
||||||
|
color:#333;
|
||||||
|
background-color:#fff;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#site {
|
||||||
|
width:600px;
|
||||||
|
margin:50px auto 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1#logo {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1#logo a,
|
||||||
|
h1#logo a:hover {
|
||||||
|
background-color:transparent;
|
||||||
|
text-decoration:none;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2.image {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
margin:20px 0 0 0;
|
||||||
|
padding:0;
|
||||||
|
font-size:1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
margin:20px 0 0 0;
|
||||||
|
padding:0;
|
||||||
|
font-size:1.2em;
|
||||||
|
letter-spacing:-1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h5 {
|
||||||
|
margin:10px 0 0 0;
|
||||||
|
padding:0;
|
||||||
|
font-size:1em;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
em {
|
||||||
|
font-style:normal;
|
||||||
|
background-color:#ffc;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin:0;
|
||||||
|
padding:5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul, ol {
|
||||||
|
margin:10px 0 10px 20px;
|
||||||
|
padding:0 0 0 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li, ol li {
|
||||||
|
margin:0 0 7px 0;
|
||||||
|
padding:0 0 0 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-size:1em;
|
||||||
|
background-color:#f3f3ff;
|
||||||
|
color:#000;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#site pre {
|
||||||
|
background-color:#f3f3ff;
|
||||||
|
color:#000080;
|
||||||
|
border:1px dotted #000080;
|
||||||
|
overflow:auto;
|
||||||
|
padding:3px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
font-size:1em;
|
||||||
|
color:#666;
|
||||||
|
border-left:4px solid #666;
|
||||||
|
margin:10px 0 10px 30px;
|
||||||
|
padding:0 5px 0 10px;
|
||||||
|
background:#f3f3f3 url(background_blockquote.png) repeat top left;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, select, textarea {
|
||||||
|
font-size:12px;
|
||||||
|
line-height:1.2em;
|
||||||
|
padding:2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text], select, textarea {
|
||||||
|
background-color:#e9f5ff;
|
||||||
|
border:1px solid #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text]:focus, select:focus, textarea:focus {
|
||||||
|
background-color:#ffe;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clearLeft {clear:left;}
|
||||||
|
.clearRight {clear:right;}
|
||||||
|
.clearBoth {clear:both;}
|
||||||
|
.hide {display:none;}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************
|
||||||
|
NAVIGATION STYLES
|
||||||
|
*********************************************/
|
||||||
|
div#header {
|
||||||
|
background:#fff url(top_gradient.gif) repeat-x top left;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header form {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#logoContainer {}
|
||||||
|
|
||||||
|
div#header div#headerInner div#logoContainerInner {
|
||||||
|
width:550px;
|
||||||
|
margin:0 auto;
|
||||||
|
padding:20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#logoContainer div#logo {
|
||||||
|
float:left;
|
||||||
|
width:200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#logoContainer div#logo a,
|
||||||
|
div#header div#headerInner div#logoContainer div#logo a:hover {
|
||||||
|
border:none;
|
||||||
|
background:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#logoContainer div#feed {
|
||||||
|
float:right;
|
||||||
|
width:300px;
|
||||||
|
text-align:right;
|
||||||
|
padding:10px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#logoContainer div#feed input.text {
|
||||||
|
width:60%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#menu {
|
||||||
|
background:#eee url(background_menuitem_shadow.gif) repeat-x top left;
|
||||||
|
border-top:2px solid #ccc;
|
||||||
|
border-bottom:1px solid #ddd;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#menu table {
|
||||||
|
width:auto;
|
||||||
|
margin:0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#menu ul {
|
||||||
|
display:block;
|
||||||
|
width:100%;
|
||||||
|
margin:0 auto;
|
||||||
|
padding:0;
|
||||||
|
font-size:12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#menu ul li {
|
||||||
|
display:block;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#menu ul li a {
|
||||||
|
display:block;
|
||||||
|
margin:-2px 0 0 0;
|
||||||
|
padding:5px 7px 8px 7px;
|
||||||
|
text-decoration:none;
|
||||||
|
color:#666 !important;
|
||||||
|
background-color:transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#header div#headerInner div#menu ul li a:hover {
|
||||||
|
display:block;
|
||||||
|
margin:-2px 0 0 0;
|
||||||
|
padding:5px 7px 8px 7px;
|
||||||
|
text-decoration:none;
|
||||||
|
color:#666;
|
||||||
|
background:#fff url(background_menuitem_off.gif) no-repeat bottom right;
|
||||||
|
}
|
||||||
|
|
||||||
|
body#bodydemo div#header div#headerInner div#menu ul li#demo a {
|
||||||
|
display:block;
|
||||||
|
margin:-2px 0 0 0;
|
||||||
|
padding:5px 7px 8px 7px;
|
||||||
|
text-decoration:none;
|
||||||
|
color:#333;
|
||||||
|
font-weight:bold;
|
||||||
|
background:#fff url(background_menuitem.gif) no-repeat bottom right;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************
|
||||||
|
CONTENT STYLES
|
||||||
|
*********************************************/
|
||||||
|
div.chunk {
|
||||||
|
margin:20px 0 0 0;
|
||||||
|
padding:0 0 10px 0;
|
||||||
|
border-bottom:1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.topchunk {
|
||||||
|
margin:0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footnote,
|
||||||
|
.footnote a {
|
||||||
|
font-size:12px;
|
||||||
|
line-height:1.3em;
|
||||||
|
color:#aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footnote em {
|
||||||
|
background-color:transparent;
|
||||||
|
font-style:italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footnote code {
|
||||||
|
background-color:transparent;
|
||||||
|
font:11px/14px monospace;
|
||||||
|
color:#aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.subscribe {
|
||||||
|
background-color:#f3f3f3;
|
||||||
|
font-size:12px;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.highlight {
|
||||||
|
background-color:#ffc;
|
||||||
|
font-size:12px;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.sample_feeds {
|
||||||
|
font-size:12px;
|
||||||
|
line-height:1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.sp_errors {
|
||||||
|
background-color:#eee;
|
||||||
|
padding:5px;
|
||||||
|
text-align:center;
|
||||||
|
font-size:12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noborder {
|
||||||
|
border:none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
img.favicon {
|
||||||
|
margin:0 4px -2px 0;
|
||||||
|
width:16px;
|
||||||
|
height:16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.favicons a,
|
||||||
|
p.favicons a:hover {
|
||||||
|
border:none;
|
||||||
|
background-color:transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.favicons img {
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************
|
||||||
|
DEMO STYLES
|
||||||
|
*********************************************/
|
||||||
|
div#sp_input {
|
||||||
|
background-color:#ffc;
|
||||||
|
border:2px solid #f90;
|
||||||
|
padding:5px;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#sp_input input.text {
|
||||||
|
border:1px solid #999;
|
||||||
|
background:#e9f5ff url(feed.png) no-repeat 4px 50%;
|
||||||
|
width:75%;
|
||||||
|
padding:2px 2px 2px 28px;
|
||||||
|
font:18px/22px "Lucida Grande", Verdana, sans-serif;
|
||||||
|
font-weight:bold;
|
||||||
|
letter-spacing:-1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form#sp_form {
|
||||||
|
margin:15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.focus {
|
||||||
|
margin:0;
|
||||||
|
padding:10px 20px;
|
||||||
|
background-color:#efe;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.sample_feeds {
|
||||||
|
text-align:justify;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************
|
||||||
|
SIFR STYLES
|
||||||
|
*********************************************/
|
||||||
|
.sIFR-active h3.header {
|
||||||
|
visibility:hidden;
|
||||||
|
line-height:1em;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**********************************************************
|
||||||
|
Sleight
|
||||||
|
(c) 2001, Aaron Boodman
|
||||||
|
http://www.youngpup.net
|
||||||
|
**********************************************************/
|
||||||
|
|
||||||
|
if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent)
|
||||||
|
{
|
||||||
|
document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
|
||||||
|
window.attachEvent("onload", fnLoadPngs);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fnLoadPngs()
|
||||||
|
{
|
||||||
|
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
|
||||||
|
var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
|
||||||
|
|
||||||
|
for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--)
|
||||||
|
{
|
||||||
|
if (itsAllGood && img.src.match(/\.png$/i) != null)
|
||||||
|
{
|
||||||
|
var src = img.src;
|
||||||
|
var div = document.createElement("DIV");
|
||||||
|
div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')"
|
||||||
|
div.style.width = img.width + "px";
|
||||||
|
div.style.height = img.height + "px";
|
||||||
|
img.replaceNode(div);
|
||||||
|
}
|
||||||
|
img.style.visibility = "visible";
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 113 KiB |
|
@ -0,0 +1,71 @@
|
||||||
|
/*=:project
|
||||||
|
scalable Inman Flash Replacement (sIFR) version 3.
|
||||||
|
|
||||||
|
=:file
|
||||||
|
Copyright: 2006 Mark Wubben.
|
||||||
|
Author: Mark Wubben, <http://novemberborn.net/>
|
||||||
|
|
||||||
|
=:history
|
||||||
|
* IFR: Shaun Inman
|
||||||
|
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
|
||||||
|
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
|
||||||
|
|
||||||
|
=:license
|
||||||
|
This software is licensed and provided under the CC-GNU LGPL.
|
||||||
|
See <http://creativecommons.org/licenses/LGPL/2.1/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
import TextField.StyleSheet;
|
||||||
|
|
||||||
|
class SifrStyleSheet extends TextField.StyleSheet {
|
||||||
|
public var fontSize;
|
||||||
|
public var latestLeading = 0;
|
||||||
|
|
||||||
|
public function parseCSS(cssText:String) {
|
||||||
|
var native = new TextField.StyleSheet();
|
||||||
|
var parsed = native.parseCSS(cssText);
|
||||||
|
|
||||||
|
if(!parsed) return false;
|
||||||
|
|
||||||
|
var selectors = native.getStyleNames();
|
||||||
|
for(var i = selectors.length - 1; i >= 0; i--) {
|
||||||
|
var selector = selectors[i];
|
||||||
|
var nativeStyle = native.getStyle(selector);
|
||||||
|
var style = this.getStyle(selector) || nativeStyle;
|
||||||
|
if(style != nativeStyle) {
|
||||||
|
for(var property in nativeStyle) style[property] = nativeStyle[property];
|
||||||
|
}
|
||||||
|
this.setStyle(selector, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply leading to the textFormat. Much thanks to <http://www.blog.lessrain.com/?p=98>.
|
||||||
|
private function applyLeading(format, leading) {
|
||||||
|
this.latestLeading = leading;
|
||||||
|
|
||||||
|
if(leading >= 0) {
|
||||||
|
format.leading = leading;
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for negative leading, which is ignored otherwise.
|
||||||
|
var newFormat = new TextFormat(null, null, null, null, null, null, null, null, null, null, null, null, leading);
|
||||||
|
for(var property in format) if(property != 'leading') newFormat[property] = format[property];
|
||||||
|
|
||||||
|
return newFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transform(style) {
|
||||||
|
var format = super.transform(style);
|
||||||
|
if(style.leading) format = applyLeading(format, style.leading);
|
||||||
|
if(style.letterSpacing) format.letterSpacing = style.letterSpacing;
|
||||||
|
// Support font sizes relative to the size of .sIFR-root.
|
||||||
|
if(this.fontSize && style.fontSize && style.fontSize.indexOf('%')) {
|
||||||
|
format.size = this.fontSize * parseInt(style.fontSize) / 100;
|
||||||
|
}
|
||||||
|
format.kerning = _root.kerning == 'true' || !(_root.kerning == 'false') || sIFR.defaultKerning;
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
This is a pre-release nightly of sIFR 3 (r245 to be exact). We (the SimplePie team) will be updating the
|
||||||
|
sIFR code and font files from time to time as new releases of sIFR 3 are made available.
|
||||||
|
|
||||||
|
In this folder you'll find a few Flash 8 files. The only one of you might want to mess with is sifr.fla.
|
||||||
|
* Open it up
|
||||||
|
* Double-click the rectangle in the middle
|
||||||
|
* Select all
|
||||||
|
* Change the font
|
||||||
|
|
||||||
|
More information about sIFR 3 can be found here:
|
||||||
|
* http://dev.novemberborn.net/sifr3/
|
||||||
|
* http://wiki.novemberborn.net/sifr3/
|
|
@ -0,0 +1,12 @@
|
||||||
|
// MTASC only parses as-files with class definitions, so here goes...
|
||||||
|
class Options {
|
||||||
|
public static function apply() {
|
||||||
|
sIFR.fromLocal = true;
|
||||||
|
sIFR.domains = ['*'];
|
||||||
|
|
||||||
|
// Parsing `p.foo` might not work, see: <http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001766.html>
|
||||||
|
// Appearantly you have to use hex color codes as well, names are not supported!
|
||||||
|
|
||||||
|
sIFR.styles.parseCSS('.foo { text-decoration: underline; }');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,359 @@
|
||||||
|
/*=:project
|
||||||
|
scalable Inman Flash Replacement (sIFR) version 3.
|
||||||
|
|
||||||
|
=:file
|
||||||
|
Copyright: 2006 Mark Wubben.
|
||||||
|
Author: Mark Wubben, <http://novemberborn.net/>
|
||||||
|
|
||||||
|
=:history
|
||||||
|
* IFR: Shaun Inman
|
||||||
|
* sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
|
||||||
|
* sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben
|
||||||
|
|
||||||
|
=:license
|
||||||
|
This software is licensed and provided under the CC-GNU LGPL.
|
||||||
|
See <http://creativecommons.org/licenses/LGPL/2.1/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
import SifrStyleSheet;
|
||||||
|
|
||||||
|
class sIFR {
|
||||||
|
public static var DEFAULT_TEXT = 'Rendered with sIFR 3, revision 245';
|
||||||
|
public static var CSS_ROOT_CLASS = 'sIFR-root';
|
||||||
|
public static var DEFAULT_WIDTH = 300;
|
||||||
|
public static var DEFAULT_HEIGHT = 100;
|
||||||
|
public static var DEFAULT_ANTI_ALIAS_TYPE = 'advanced';
|
||||||
|
public static var MARGIN_LEFT = -3;
|
||||||
|
public static var PADDING_BOTTOM = 5; // Extra padding to make sure the movie is high enough in most cases.
|
||||||
|
public static var LEADING_REMAINDER = 2; // Flash uses the specified leading minus 2 as the applied leading.
|
||||||
|
|
||||||
|
public static var MAX_FONT_SIZE = 126;
|
||||||
|
public static var ALIASING_MAX_FONT_SIZE = 48;
|
||||||
|
|
||||||
|
//= Holds CSS properties and other rendering properties for the Flash movie.
|
||||||
|
// *Don't overwrite!*
|
||||||
|
public static var styles:SifrStyleSheet = new SifrStyleSheet();
|
||||||
|
//= Allow sIFR to be run from localhost
|
||||||
|
public static var fromLocal:Boolean = true;
|
||||||
|
//= Array containing domains for which sIFR may render text. Used to prevent
|
||||||
|
// hotlinking. Use `*` to allow all domains.
|
||||||
|
public static var domains:Array = [];
|
||||||
|
//= Whether kerning is enabled by default. This can be overriden from the client side.
|
||||||
|
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002811.html>.
|
||||||
|
public static var defaultKerning:Boolean = true;
|
||||||
|
//= Default value which can be overriden from the client side.
|
||||||
|
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002788.html>.
|
||||||
|
public static var defaultSharpness:Number = 0;
|
||||||
|
//= Default value which can be overriden from the client side.
|
||||||
|
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002787.html>.
|
||||||
|
public static var defaultThickness:Number = 0;
|
||||||
|
//= Default value which can be overriden from the client side.
|
||||||
|
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002732.html>.
|
||||||
|
public static var defaultOpacity:Number = -1; // Use client settings
|
||||||
|
//= Default value which can be overriden from the client side.
|
||||||
|
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002788.html>.
|
||||||
|
public static var defaultBlendMode:Number = -1; // Use cliest settings
|
||||||
|
//= Overrides the grid fit type as defined on the client side.
|
||||||
|
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002444.html>.
|
||||||
|
public static var enforcedGridFitType:String = null;
|
||||||
|
//= If `true` sIFR won't override the anti aliasing set in the Flash IDE when exporting.
|
||||||
|
// Thickness and sharpness won't be affected either.
|
||||||
|
public static var preserveAntiAlias:Boolean = false;
|
||||||
|
//= If `true` sIFR will disable anti-aliasing if the font size is larger than `ALIASING_MAX_FONT_SIZE`.
|
||||||
|
// This setting is *independent* from `preserveAntiAlias`.
|
||||||
|
public static var conditionalAntiAlias:Boolean = true;
|
||||||
|
//= Sets the anti alias type. By default it's `DEFAULT_ANTI_ALIAS_TYPE`.
|
||||||
|
// See also <http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002733.html>.
|
||||||
|
public static var antiAliasType:String = null;
|
||||||
|
//= Flash filters can be added to this array and will be applied to the text field.
|
||||||
|
public static var filters:Array = [];
|
||||||
|
//= A mapping from the names of the filters to their actual objecs, used when transforming
|
||||||
|
// filters defined on the client. You can add additional filters here so they'll be supported
|
||||||
|
// when defined on the client.
|
||||||
|
public static var filterMap:Object = {
|
||||||
|
DisplacementMapFilter : flash.filters.DisplacementMapFilter,
|
||||||
|
ColorMatrixFilter : flash.filters.ColorMatrixFilter,
|
||||||
|
ConvolutionFilter : flash.filters.ConvolutionFilter,
|
||||||
|
GradientBevelFilter : flash.filters.GradientBevelFilter,
|
||||||
|
GradientGlowFilter : flash.filters.GradientGlowFilter,
|
||||||
|
BevelFilter : flash.filters.BevelFilter,
|
||||||
|
GlowFilter : flash.filters.GlowFilter,
|
||||||
|
BlurFilter : flash.filters.BlurFilter,
|
||||||
|
DropShadowFilter : flash.filters.DropShadowFilter
|
||||||
|
};
|
||||||
|
|
||||||
|
private static var instance;
|
||||||
|
|
||||||
|
private var textField;
|
||||||
|
private var content;
|
||||||
|
private var realHeight;
|
||||||
|
private var originalHeight;
|
||||||
|
private var currentHeight;
|
||||||
|
private var fontSize;
|
||||||
|
private var tuneWidth;
|
||||||
|
private var tuneHeight;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//= Sets the default styles for `sIFR.styles`. This method is called
|
||||||
|
// directly in `sifr.fla`, before options are applied.
|
||||||
|
public static function setDefaultStyles() {
|
||||||
|
sIFR.styles.parseCSS([
|
||||||
|
'.', CSS_ROOT_CLASS, ' { color: #000000; }',
|
||||||
|
'strong { display: inline; font-weight: bold; } ',
|
||||||
|
'em { display: inline; font-style: italic; }',
|
||||||
|
'a { color: #0000FF; text-decoration: underline; }',
|
||||||
|
'a:hover { color: #0000FF; text-decoration: none; }'
|
||||||
|
].join(''));
|
||||||
|
}
|
||||||
|
|
||||||
|
//= Validates the domain sIFR is being used on.
|
||||||
|
// Returns `true` if the domain is valid, `false` otherwise.
|
||||||
|
public static function checkDomain():Boolean {
|
||||||
|
if(sIFR.domains.length == 0) return true;
|
||||||
|
|
||||||
|
var domain = (new LocalConnection()).domain();
|
||||||
|
if(sIFR.fromLocal) sIFR.domains.push('localhost');
|
||||||
|
|
||||||
|
for(var i = 0; i < sIFR.domains.length; i++) {
|
||||||
|
var match = sIFR.domains[i];
|
||||||
|
if(match == '*' || match == domain) return true;
|
||||||
|
|
||||||
|
var wildcard = match.lastIndexOf('*');
|
||||||
|
if(wildcard > -1) {
|
||||||
|
match = match.substr(wildcard + 1);
|
||||||
|
var matchPosition = domain.lastIndexOf(match);
|
||||||
|
if(matchPosition > -1 && (matchPosition + match.length) == domain.length) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//= Runs sIFR. Called automatically.
|
||||||
|
public static function run() {
|
||||||
|
var holder = _root.holder;
|
||||||
|
var content = checkDomain() ? unescape(_root.content) : DEFAULT_TEXT
|
||||||
|
if(content == 'undefined' || content == '') {
|
||||||
|
content = DEFAULT_TEXT;
|
||||||
|
fscommand('resetmovie', '');
|
||||||
|
} else fscommand('ping', '');
|
||||||
|
|
||||||
|
// Sets stage parameters
|
||||||
|
Stage.scaleMode = 'noscale';
|
||||||
|
Stage.align = 'TL';
|
||||||
|
Stage.showMenu = false;
|
||||||
|
|
||||||
|
// Other parameters
|
||||||
|
var opacity = parseInt(_root.opacity);
|
||||||
|
if(!isNaN(opacity)) holder._alpha = sIFR.defaultOpacity == -1 ? opacity : sIFR.defaultOpacity;
|
||||||
|
else holder._alpha = 100;
|
||||||
|
_root.blendMode = sIFR.defaultBlendMode == -1 ? _root.blendmode : sIFR.defaultBlendMode;
|
||||||
|
|
||||||
|
sIFR.instance = new sIFR(holder.txtF, content);
|
||||||
|
// This should ignore resizes from the callback. Disabled for now.
|
||||||
|
/* if(_root.zoomsupport == 'true') Stage.addListener({onResize: function() { sIFR.instance.scale() }});*/
|
||||||
|
|
||||||
|
// Setup callbacks
|
||||||
|
_root.watch('callbackTrigger', function() {
|
||||||
|
sIFR.callback();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function eval(str) {
|
||||||
|
var as;
|
||||||
|
|
||||||
|
if(str.charAt(0) == '{') { // Ah, we need to create an object
|
||||||
|
as = {};
|
||||||
|
str = str.substring(1, str.length - 1);
|
||||||
|
var $ = str.split(',');
|
||||||
|
for(var i = 0; i < $.length; i++) {
|
||||||
|
var $1 = $[i].split(':');
|
||||||
|
as[$1[0]] = sIFR.eval($1[1]);
|
||||||
|
}
|
||||||
|
} else if(str.charAt(0) == '"') { // String
|
||||||
|
as = str.substring(1, str.length - 1);
|
||||||
|
} else if(str == 'true' || str == 'false') { // Boolean
|
||||||
|
as = str == 'true';
|
||||||
|
} else { // Float
|
||||||
|
as = parseFloat(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return as;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applyFilters() {
|
||||||
|
var $filters = this.textField.filters;
|
||||||
|
$filters = $filters.concat(sIFR.filters);
|
||||||
|
|
||||||
|
var $ = _root.flashfilters.split(';'); // name,prop:value,...;
|
||||||
|
for(var i = 0; i < $.length; i++) {
|
||||||
|
var $1 = $[i].split(',');
|
||||||
|
|
||||||
|
var newFilter = new sIFR.filterMap[$1[0]]();
|
||||||
|
for(var j = 1; j < $1.length; j++) {
|
||||||
|
var $2 = $1[j].split(':');
|
||||||
|
newFilter[$2[0]] = sIFR.eval(unescape($2[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$filters.push(newFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.textField.filters = $filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sIFR(textField, content) {
|
||||||
|
this.textField = textField;
|
||||||
|
this.content = content;
|
||||||
|
|
||||||
|
var offsetLeft = parseInt(_root.offsetleft);
|
||||||
|
textField._x = MARGIN_LEFT + (isNaN(offsetLeft) ? 0 : offsetLeft);
|
||||||
|
var offsetTop = parseInt(_root.offsettop);
|
||||||
|
if(!isNaN(offsetTop)) textField._y += offsetTop;
|
||||||
|
|
||||||
|
tuneWidth = parseInt(_root.tunewidth);
|
||||||
|
if(isNaN(tuneWidth)) tuneWidth = 0;
|
||||||
|
tuneHeight = parseInt(_root.tuneheight);
|
||||||
|
if(isNaN(tuneHeight)) tuneHeight = 0;
|
||||||
|
|
||||||
|
textField._width = tuneWidth + (isNaN(parseInt(_root.width)) ? DEFAULT_WIDTH : parseInt(_root.width));
|
||||||
|
textField._height = tuneHeight + (isNaN(parseInt(_root.height)) ? DEFAULT_HEIGHT : parseInt(_root.height));
|
||||||
|
textField.wordWrap = true;
|
||||||
|
textField.selectable = _root.selectable == 'true';
|
||||||
|
textField.gridFitType = sIFR.enforcedGridFitType || _root.gridfittype;
|
||||||
|
this.applyFilters();
|
||||||
|
|
||||||
|
// Determine font-size and the number of lines
|
||||||
|
this.fontSize = parseInt(_root.size);
|
||||||
|
if(isNaN(this.fontSize)) this.fontSize = 26;
|
||||||
|
styles.fontSize = this.fontSize;
|
||||||
|
|
||||||
|
if(!sIFR.preserveAntiAlias && (sIFR.conditionalAntiAlias && this.fontSize < ALIASING_MAX_FONT_SIZE
|
||||||
|
|| !sIFR.conditionalAntiAlias)) {
|
||||||
|
textField.antiAliasType = sIFR.antiAliasType || DEFAULT_ANTI_ALIAS_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!sIFR.preserveAntiAlias || !isNaN(parseInt(_root.sharpness))) {
|
||||||
|
textField.sharpness = parseInt(_root.sharpness);
|
||||||
|
}
|
||||||
|
if(isNaN(textField.sharpness)) textField.sharpness = sIFR.defaultSharpness;
|
||||||
|
|
||||||
|
if(!sIFR.preserveAntiAlias || !isNaN(parseInt(_root.thickness))) {
|
||||||
|
textField.thickness = parseInt(_root.thickness);
|
||||||
|
}
|
||||||
|
if(isNaN(textField.thickness)) textField.thickness = sIFR.defaultThickness;
|
||||||
|
|
||||||
|
// Set font-size and other styles
|
||||||
|
sIFR.styles.parseCSS(unescape(_root.css));
|
||||||
|
|
||||||
|
var rootStyle = styles.getStyle('.sIFR-root') || {};
|
||||||
|
rootStyle.fontSize = this.fontSize; // won't go higher than 126!
|
||||||
|
styles.setStyle('.sIFR-root', rootStyle);
|
||||||
|
textField.styleSheet = styles;
|
||||||
|
|
||||||
|
this.write(content);
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function repaint() {
|
||||||
|
var leadingFix = this.isSingleLine() ? sIFR.styles.latestLeading : 0;
|
||||||
|
if(leadingFix > 0) leadingFix -= LEADING_REMAINDER;
|
||||||
|
|
||||||
|
// Flash wants to scroll the movie by one line, by adding the fontSize to the
|
||||||
|
// textField height this is no longer happens. We also add the absolute tuneHeight,
|
||||||
|
// to prevent a negative value from triggering the bug. We won't send the fake
|
||||||
|
// value to the JavaScript side, though.
|
||||||
|
textField._height = textField.textHeight + PADDING_BOTTOM + this.fontSize + Math.abs(tuneHeight) + tuneHeight - leadingFix;
|
||||||
|
this.realHeight = textField._height - this.fontSize - Math.abs(tuneHeight);
|
||||||
|
var arg = 'height:' + this.realHeight;
|
||||||
|
if(_root.fitexactly == 'true') arg += ',width:' + (textField.textWidth + tuneWidth);
|
||||||
|
fscommand('resize', arg);
|
||||||
|
|
||||||
|
this.originalHeight = textField._height;
|
||||||
|
this.currentHeight = Stage.height;
|
||||||
|
|
||||||
|
textField._xscale = textField._yscale = parseInt(_root.zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function write(content) {
|
||||||
|
this.textField.htmlText = ['<p class="', CSS_ROOT_CLASS, '">',
|
||||||
|
content, '</p>'
|
||||||
|
].join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isSingleLine() {
|
||||||
|
return Math.round((this.textField.textHeight - sIFR.styles.latestLeading) / this.fontSize) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//= Scales the text field to the new scale of the Flash movie itself.
|
||||||
|
public function scale() {
|
||||||
|
this.currentHeight = Stage.height;
|
||||||
|
var scale = 100 * Math.round(this.currentHeight / this.originalHeight);
|
||||||
|
textField._xscale = textField._yscale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function calculateRatios() {
|
||||||
|
var strings = ['X', 'X<br>X', 'X<br>X<br>X', 'X<br>X<br>X<br>X'];
|
||||||
|
var results = {};
|
||||||
|
|
||||||
|
for(var i = 1; i <= strings.length; i++) {
|
||||||
|
var size = 6;
|
||||||
|
|
||||||
|
this.write(strings[i - 1]);
|
||||||
|
while(size < MAX_FONT_SIZE) {
|
||||||
|
var rootStyle = sIFR.styles.getStyle('.sIFR-root') || {};
|
||||||
|
rootStyle.fontSize = size;
|
||||||
|
sIFR.styles.setStyle('.sIFR-root', rootStyle);
|
||||||
|
this.textField.styleSheet = sIFR.styles;
|
||||||
|
this.repaint();
|
||||||
|
var ratio = (this.realHeight - PADDING_BOTTOM) / i / size;
|
||||||
|
if(!results[size]) results[size] = ratio;
|
||||||
|
else results[size] = ((i - 1) * results[size] + ratio) / i;
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var sizes = [], ratios = [];
|
||||||
|
var ratiosToSizes = {}, sizesToRatios = {};
|
||||||
|
|
||||||
|
for(var size in results) {
|
||||||
|
if(results[size] == Object.prototype[size]) continue;
|
||||||
|
var ratio = results[size];
|
||||||
|
ratiosToSizes[ratio] = Math.max(ratio, parseInt(size));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var ratio in ratiosToSizes) {
|
||||||
|
if(ratiosToSizes[ratio] == Object.prototype[ratio]) continue;
|
||||||
|
sizesToRatios[ratiosToSizes[ratio]] = roundDecimals(ratio, 2);
|
||||||
|
sizes.push(ratiosToSizes[ratio]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sizes.sort(function(a, b) { return a - b; });
|
||||||
|
for(var j = 0; j < sizes.length - 1; j++) ratios.push(sizes[j], sizesToRatios[sizes[j]]);
|
||||||
|
ratios.push(sizesToRatios[sizes[sizes.length - 1]]);
|
||||||
|
|
||||||
|
fscommand('debug:ratios', '[' + ratios.join(',') + ']');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function roundDecimals(value, decimals) {
|
||||||
|
return Math.round(value * Math.pow(10, decimals)) / Math.pow(10, decimals);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function callback() {
|
||||||
|
switch(_root.callbackType) {
|
||||||
|
case 'replacetext':
|
||||||
|
sIFR.instance.content = _root.callbackValue;
|
||||||
|
sIFR.instance.write(_root.callbackValue);
|
||||||
|
sIFR.instance.repaint();
|
||||||
|
break;
|
||||||
|
case 'resettext':
|
||||||
|
sIFR.instance.write('');
|
||||||
|
sIFR.instance.write(sIFR.instance.content);
|
||||||
|
break;
|
||||||
|
case 'ratios':
|
||||||
|
sIFR.instance.calculateRatios();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
// This should be modifed as your own use warrants.
|
||||||
|
|
||||||
|
require_once('../simplepie.inc');
|
||||||
|
SimplePie_Misc::display_cached_file($_GET['i'], './cache', 'spi');
|
||||||
|
?>
|
|
@ -0,0 +1,295 @@
|
||||||
|
<?php
|
||||||
|
// Start counting time for the page load
|
||||||
|
$starttime = explode(' ', microtime());
|
||||||
|
$starttime = $starttime[1] + $starttime[0];
|
||||||
|
|
||||||
|
// Include SimplePie
|
||||||
|
// Located in the parent directory
|
||||||
|
include_once('../simplepie.inc');
|
||||||
|
include_once('../idn/idna_convert.class.php');
|
||||||
|
|
||||||
|
// Create a new instance of the SimplePie object
|
||||||
|
$feed = new SimplePie();
|
||||||
|
|
||||||
|
//$feed->force_fsockopen(true);
|
||||||
|
|
||||||
|
// Make sure that page is getting passed a URL
|
||||||
|
if (isset($_GET['feed']) && $_GET['feed'] !== '')
|
||||||
|
{
|
||||||
|
// Strip slashes if magic quotes is enabled (which automatically escapes certain characters)
|
||||||
|
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
|
||||||
|
{
|
||||||
|
$_GET['feed'] = stripslashes($_GET['feed']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the URL that was passed to the page in SimplePie
|
||||||
|
$feed->set_feed_url($_GET['feed']);
|
||||||
|
|
||||||
|
// XML dump
|
||||||
|
$feed->enable_xml_dump(isset($_GET['xmldump']) ? true : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow us to change the input encoding from the URL string if we want to. (optional)
|
||||||
|
if (!empty($_GET['input']))
|
||||||
|
{
|
||||||
|
$feed->set_input_encoding($_GET['input']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow us to choose to not re-order the items by date. (optional)
|
||||||
|
if (!empty($_GET['orderbydate']) && $_GET['orderbydate'] == 'false')
|
||||||
|
{
|
||||||
|
$feed->enable_order_by_date(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow us to cache images in feeds. This will also bypass any hotlink blocking put in place by the website.
|
||||||
|
if (!empty($_GET['image']) && $_GET['image'] == 'true')
|
||||||
|
{
|
||||||
|
$feed->set_image_handler('./handler_image.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// We'll enable the discovering and caching of favicons.
|
||||||
|
$feed->set_favicon_handler('./handler_image.php');
|
||||||
|
|
||||||
|
// Initialize the whole SimplePie object. Read the feed, process it, parse it, cache it, and
|
||||||
|
// all that other good stuff. The feed's information will not be available to SimplePie before
|
||||||
|
// this is called.
|
||||||
|
$success = $feed->init();
|
||||||
|
|
||||||
|
// We'll make sure that the right content type and character encoding gets set automatically.
|
||||||
|
// This function will grab the proper character encoding, as well as set the content type to text/html.
|
||||||
|
$feed->handle_content_type();
|
||||||
|
|
||||||
|
// When we end our PHP block, we want to make sure our DOCTYPE is on the top line to make
|
||||||
|
// sure that the browser snaps into Standards Mode.
|
||||||
|
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
|
||||||
|
<head>
|
||||||
|
<title>SimplePie: Demo</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="./for_the_demo/sIFR-screen.css" type="text/css" media="screen">
|
||||||
|
<link rel="stylesheet" href="./for_the_demo/sIFR-print.css" type="text/css" media="print">
|
||||||
|
<link rel="stylesheet" href="./for_the_demo/simplepie.css" type="text/css" media="screen, projector" />
|
||||||
|
|
||||||
|
<script type="text/javascript" src="./for_the_demo/sifr.js"></script>
|
||||||
|
<script type="text/javascript" src="./for_the_demo/sifr-config.js"></script>
|
||||||
|
<script type="text/javascript" src="./for_the_demo/sleight.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body id="bodydemo">
|
||||||
|
|
||||||
|
<div id="header">
|
||||||
|
<div id="headerInner">
|
||||||
|
<div id="logoContainer">
|
||||||
|
<div id="logoContainerInner">
|
||||||
|
<div align="center"><a href="http://simplepie.org"><img src="./for_the_demo/logo_simplepie_demo.png" alt="SimplePie Demo: PHP-based RSS and Atom feed handling" title="SimplePie Demo: PHP-based RSS and Atom feed handling" border="0" /></a></div>
|
||||||
|
<div class="clearLeft"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="menu">
|
||||||
|
<!-- I know, I know, I know... tables for layout, I know. If a web standards evangelist (like me) has to resort
|
||||||
|
to using tables for something, it's because no other possible solution could be found. This issue? No way to
|
||||||
|
do centered floats purely with CSS. The table box model allows for a dynamic width while centered, while the
|
||||||
|
CSS box model for DIVs doesn't allow for it. :( -->
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0"><tbody><tr><td>
|
||||||
|
<ul><li id="demo"><a href="./">SimplePie Demo</a></li><li><a href="http://simplepie.org/wiki/faq/start">FAQ/Troubleshooting</a></li><li><a href="http://simplepie.org/support/">Support Forums</a></li><li><a href="http://simplepie.org/wiki/reference/start">API Reference</a></li><li><a href="http://simplepie.org/blog/">Weblog</a></li><li><a href="../test/test.php">Unit Tests</a></li></ul>
|
||||||
|
|
||||||
|
<div class="clearLeft"></div>
|
||||||
|
</td></tr></tbody></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="site">
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<div class="chunk">
|
||||||
|
<form action="" method="get" name="sp_form" id="sp_form">
|
||||||
|
<div id="sp_input">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- If a feed has already been passed through the form, then make sure that the URL remains in the form field. -->
|
||||||
|
<p><input type="text" name="feed" value="<?php if ($feed->subscribe_url()) echo $feed->subscribe_url(); ?>" class="text" id="feed_input" /> <input type="submit" value="Read" class="button" /></p>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Check to see if there are more than zero errors (i.e. if there are any errors at all)
|
||||||
|
if ($feed->error())
|
||||||
|
{
|
||||||
|
// If so, start a <div> element with a classname so we can style it.
|
||||||
|
echo '<div class="sp_errors">' . "\r\n";
|
||||||
|
|
||||||
|
// ... and display it.
|
||||||
|
echo '<p>' . htmlspecialchars($feed->error()) . "</p>\r\n";
|
||||||
|
|
||||||
|
// Close the <div> element we opened.
|
||||||
|
echo '</div>' . "\r\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!-- Here are some sample feeds. -->
|
||||||
|
<p class="sample_feeds"><strong>Or try one of the following:</strong>
|
||||||
|
<a href="?feed=http://www.詹姆斯.com/atomtests/iri/everything.atom" title="Test: International Domain Name support">詹姆斯.com</a>,
|
||||||
|
<a href="?feed=http://www.adultswim.com/williams/podcast/tools/xml/video_rss.xml" title="Humor from the people who make [adult swim] cartoons.">adult swim</a>,
|
||||||
|
<a href="?feed=http://afterdawn.com/news/afterdawn_rss.xml" title="Ripping, Burning, DRM, and the Dark Side of Consumer Electronics Media">Afterdawn</a>,
|
||||||
|
<a href="?feed=http://feeds.feedburner.com/ajaxian" title="AJAX and Scripting News">Ajaxian</a>,
|
||||||
|
<a href="?feed=http://www.andybudd.com/index.rdf&image=true" title="Test: Bypass Image Hotlink Blocking">Andy Budd</a>,
|
||||||
|
<a href="?feed=http://feeds.feedburner.com/AskANinja" title="Test: Embedded Enclosures">Ask a Ninja</a>,
|
||||||
|
<a href="?feed=http://www.atomenabled.org/atom.xml" title="Test: Atom 1.0 Support">AtomEnabled.org</a>,
|
||||||
|
<a href="?feed=http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml" title="World News">BBC News</a>,
|
||||||
|
<a href="?feed=http://newsrss.bbc.co.uk/rss/arabic/news/rss.xml" title="Test: Windows-1256 Encoding">BBC Arabic</a>,
|
||||||
|
<a href="?feed=http://newsrss.bbc.co.uk/rss/chinese/simp/news/rss.xml" title="Test: GB2312 Encoding">BBC China</a>,
|
||||||
|
<a href="?feed=http://newsrss.bbc.co.uk/rss/russian/news/rss.xml" title="Test: Windows-1251 Encoding">BBC Russia</a>,
|
||||||
|
<a href="?feed=http://inessential.com/xml/rss.xml" title="Developer of NetNewsWire">Brent Simmons</a>,
|
||||||
|
<a href="?feed=http://www.channelfrederator.com/rss" title="Test: Embedded Enclosures">Channel Frederator</a>,
|
||||||
|
<a href="?feed=http://rss.cnn.com/rss/cnn_topstories.rss" title="World News">CNN</a>,
|
||||||
|
<a href="?feed=http://digg.com/rss/index.xml" title="Tech news. Better than Slashdot.">Digg</a>,
|
||||||
|
<a href="?feed=http://revision3.com/diggnation/feed/quicktime-large" title="Tech and industry videocast.">Diggnation</a>,
|
||||||
|
<a href="?feed=http://www.flickr.com/services/feeds/photos_public.gne?format=rss2" title="Flickr Photos">Flickr</a>,
|
||||||
|
<a href="?feed=http://news.google.com/?output=rss" title="World News">Google News</a>,
|
||||||
|
<a href="?feed=http://video.google.com/videofeed?type=top100new&num=20&output=rss" title="Test: Media RSS Support">Google Video</a>,
|
||||||
|
<a href="?feed=http://blogs.law.harvard.edu/home/feed/rdf/" title="Test: Tag Stripping">Harvard Law</a>,
|
||||||
|
<a href="?feed=http://hagada.org.il/hagada/html/backend.php" title="Test: Window-1255 Encoding">Hebrew Language</a>,
|
||||||
|
<a href="?feed=http://www.infoworld.com/rss/news.xml" title="Test: Ad Stripping">InfoWorld</a>,
|
||||||
|
<a href="?feed=http://phobos.apple.com/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/rss.xml&orderbydate=false" title="Test: Tag Stripping">iTunes</a>,
|
||||||
|
<a href="?feed=http://blog.japan.cnet.com/lessig/index.rdf" title="Test: EUC-JP Encoding">Japanese Language</a>,
|
||||||
|
<a href="?feed=http://nurapt.kaist.ac.kr/~jamaica/htmls/blog/rss.php&input=EUC-KR" title="Test: EUC-KR Encoding">Korean Language</a>,
|
||||||
|
<a href="?feed=http://mir.aculo.us/xml/rss/feed.xml" title="Weblog for the developer of Scriptaculous">mir.aculo.us</a>,
|
||||||
|
<a href="?feed=http://images.apple.com/trailers/rss/newtrailers.rss" title="Apple's QuickTime movie trailer site">Movie Trailers</a>,
|
||||||
|
<a href="?feed=http://www.newspond.com/rss/main.xml" title="Tech and Science News">Newspond</a>,
|
||||||
|
<a href="?feed=http://nick.typepad.com/blog/index.rss" title="Developer of TopStyle and FeedDemon">Nick Bradbury</a>,
|
||||||
|
<a href="?feed=http://feeds.feedburner.com/ok-cancel" title="Usability comics and commentary">OK/Cancel</a>,
|
||||||
|
<a href="?feed=http://osnews.com/files/recent.rdf" title="News about every OS ever">OS News</a>,
|
||||||
|
<a href="?feed=http://weblog.philringnalda.com/feed/" title="Test: Atom 1.0 Support">Phil Ringnalda</a>,
|
||||||
|
<a href="?feed=http://kabili.libsyn.com/rss" title="Test: Improved enclosure type sniffing">Photoshop Videocast</a>,
|
||||||
|
<a href="?feed=http://www.pariurisportive.com/blog/xmlsrv/rss2.php?blog=2" title="Test: ISO-8859-1 Encoding">Romanian Language</a>,
|
||||||
|
<a href="?feed=http://www.erased.info/rss2.php" title="Test: KOI8-R Encoding">Russian Language</a>,
|
||||||
|
<a href="?feed=http://www.upsaid.com/isis/index.rdf" title="Test: BIG5 Encoding">Traditional Chinese Language</a>,
|
||||||
|
<a href="?feed=http://technorati.com/watchlists/rss.html?wid=29290" title="Technorati watch for SimplePie">Technorati</a>,
|
||||||
|
<a href="?feed=http://www.tbray.org/ongoing/ongoing.atom" title="Test: Atom 1.0 Support">Tim Bray</a>,
|
||||||
|
<a href="?feed=http://tuaw.com/rss.xml" title="Apple News">TUAW</a>,
|
||||||
|
<a href="?feed=http://www.tvgasm.com/atom.xml&image=true" title="Test: Bypass Image Hotlink Blocking">TVgasm</a>,
|
||||||
|
<a href="?feed=http://uneasysilence.com/feed/" title="Interesting tech randomness">UNEASYsilence</a>,
|
||||||
|
<a href="?feed=http://feeds.feedburner.com/web20Show" title="Test: Embedded Enclosures">Web 2.0 Show</a>,
|
||||||
|
<a href="?feed=http://windowsvistablog.com/blogs/MainFeed.aspx" title="Test: Tag Stripping">Windows Vista Blog</a>,
|
||||||
|
<a href="?feed=http://xkcd.com/rss.xml" title="Test: LightHTTPd and GZipping">XKCD</a>,
|
||||||
|
<a href="?feed=http://rss.news.yahoo.com/rss/topstories" title="World News">Yahoo! News</a>,
|
||||||
|
<a href="?feed=http://youtube.com/rss/global/top_favorites.rss" title="Funny user-submitted videos">You Tube</a>,
|
||||||
|
<a href="?feed=http://zeldman.com/rss/" title="The father of the web standards movement">Zeldman</a></p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="sp_results">
|
||||||
|
|
||||||
|
<!-- As long as the feed has data to work with... -->
|
||||||
|
<?php if ($success): ?>
|
||||||
|
<div class="chunk focus" align="center">
|
||||||
|
|
||||||
|
<!-- If the feed has a link back to the site that publishes it (which 99% of them do), link the feed's title to it. -->
|
||||||
|
<h3 class="header"><?php if ($feed->get_link()) echo '<a href="' . $feed->get_link() . '">'; echo $feed->get_title(); if ($feed->get_link()) echo '</a>'; ?></h3>
|
||||||
|
|
||||||
|
<!-- If the feed has a description, display it. -->
|
||||||
|
<?php echo $feed->get_description(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Add subscribe links for several different aggregation services -->
|
||||||
|
<p class="subscribe"><strong>Subscribe:</strong> <a href="<?php echo $feed->subscribe_bloglines(); ?>">Bloglines</a>, <a href="<?php echo $feed->subscribe_google(); ?>">Google Reader</a>, <a href="<?php echo $feed->subscribe_msn(); ?>">My MSN</a>, <a href="<?php echo $feed->subscribe_netvibes(); ?>">Netvibes</a>, <a href="<?php echo $feed->subscribe_newsburst(); ?>">Newsburst</a><br /><a href="<?php echo $feed->subscribe_newsgator(); ?>">Newsgator</a>, <a href="<?php echo $feed->subscribe_odeo(); ?>">Odeo</a>, <a href="<?php echo $feed->subscribe_podnova(); ?>">Podnova</a>, <a href="<?php echo $feed->subscribe_rojo(); ?>">Rojo</a>, <a href="<?php echo $feed->subscribe_yahoo(); ?>">My Yahoo!</a>, <a href="<?php echo $feed->subscribe_feed(); ?>">Desktop Reader</a></p>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Let's begin looping through each individual news item in the feed. -->
|
||||||
|
<?php foreach($feed->get_items() as $item): ?>
|
||||||
|
<div class="chunk">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Let's add a favicon for each item. If one doesn't exist, we'll use an alternate one.
|
||||||
|
if (!$favicon = $feed->get_favicon())
|
||||||
|
{
|
||||||
|
$favicon = './for_the_demo/favicons/alternate.png';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!-- If the item has a permalink back to the original post (which 99% of them do), link the item's title to it. -->
|
||||||
|
<h4><img src="<?php echo $favicon; ?>" alt="Favicon" class="favicon" /><?php if ($item->get_permalink()) echo '<a href="' . $item->get_permalink() . '">'; echo $item->get_title(); if ($item->get_permalink()) echo '</a>'; ?> <span class="footnote"><?php echo $item->get_date('j M Y, g:i a'); ?></span></h4>
|
||||||
|
|
||||||
|
<!-- Display the item's primary content. -->
|
||||||
|
<?php echo $item->get_content(); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Check for enclosures. If an item has any, set the first one to the $enclosure variable.
|
||||||
|
if ($enclosure = $item->get_enclosure(0))
|
||||||
|
{
|
||||||
|
// Use the embed() method to embed the enclosure into the page inline.
|
||||||
|
echo '<div align="center">';
|
||||||
|
echo '<p>' . $enclosure->embed(array(
|
||||||
|
'audio' => './for_the_demo/place_audio.png',
|
||||||
|
'video' => './for_the_demo/place_video.png',
|
||||||
|
'mediaplayer' => './for_the_demo/mediaplayer.swf',
|
||||||
|
'altclass' => 'download'
|
||||||
|
)) . '</p>';
|
||||||
|
|
||||||
|
if ($enclosure->get_link() && $enclosure->get_type())
|
||||||
|
{
|
||||||
|
echo '<p class="footnote" align="center">(' . $enclosure->get_type();
|
||||||
|
if ($enclosure->get_size())
|
||||||
|
{
|
||||||
|
echo '; ' . $enclosure->get_size() . ' MB';
|
||||||
|
}
|
||||||
|
echo ')</p>';
|
||||||
|
}
|
||||||
|
if ($enclosure->get_thumbnail())
|
||||||
|
{
|
||||||
|
echo '<div><img src="' . $enclosure->get_thumbnail() . '" alt="" /></div>';
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!-- Add links to add this post to one of a handful of services. -->
|
||||||
|
<p class="footnote favicons" align="center">
|
||||||
|
<a href="<?php echo $item->add_to_blinklist(); ?>" title="Add post to Blinklist"><img src="./for_the_demo/favicons/blinklist.png" alt="Blinklist" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_blogmarks(); ?>" title="Add post to Blogmarks"><img src="./for_the_demo/favicons/blogmarks.png" alt="Blogmarks" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_delicious(); ?>" title="Add post to del.icio.us"><img src="./for_the_demo/favicons/delicious.png" alt="del.icio.us" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_digg(); ?>" title="Digg this!"><img src="./for_the_demo/favicons/digg.png" alt="Digg" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_magnolia(); ?>" title="Add post to Ma.gnolia"><img src="./for_the_demo/favicons/magnolia.png" alt="Ma.gnolia" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_myweb20(); ?>" title="Add post to My Web 2.0"><img src="./for_the_demo/favicons/myweb2.png" alt="My Web 2.0" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_newsvine(); ?>" title="Add post to Newsvine"><img src="./for_the_demo/favicons/newsvine.png" alt="Newsvine" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_reddit(); ?>" title="Add post to Reddit"><img src="./for_the_demo/favicons/reddit.png" alt="Reddit" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_segnalo(); ?>" title="Add post to Segnalo"><img src="./for_the_demo/favicons/segnalo.png" alt="Segnalo" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_simpy(); ?>" title="Add post to Simpy"><img src="./for_the_demo/favicons/simpy.png" alt="Simpy" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_spurl(); ?>" title="Add post to Spurl"><img src="./for_the_demo/favicons/spurl.png" alt="Spurl" /></a>
|
||||||
|
<a href="<?php echo $item->add_to_wists(); ?>" title="Add post to Wists"><img src="./for_the_demo/favicons/wists.png" alt="Wists" /></a>
|
||||||
|
<a href="<?php echo $item->search_technorati(); ?>" title="Who's linking to this post?"><img src="./for_the_demo/favicons/technorati.png" alt="Technorati" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Stop looping through each item once we've gone through all of them. -->
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<!-- From here on, we're no longer using data from the feed. -->
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<!-- Display how fast the page was rendered. -->
|
||||||
|
<p class="footnote">Page processed in <?php $mtime = explode(' ', microtime()); echo round($mtime[0] + $mtime[1] - $starttime, 3); ?> seconds.</p>
|
||||||
|
|
||||||
|
<!-- Display the version of SimplePie being loaded. -->
|
||||||
|
<p class="footnote">Powered by <a href="<?php echo SIMPLEPIE_URL; ?>"><?php echo SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . ', Build ' . SIMPLEPIE_BUILD; ?></a>. Run the <a href="../compatibility_test/sp_compatibility_test.php">SimplePie Compatibility Test</a>. SimplePie is © 2004–<?php echo date('Y'); ?>, Ryan Parman and Geoffrey Sneddon, and licensed under the <a href="http://www.opensource.org/licenses/bsd-license.php">BSD License</a>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,137 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function microtime_float()
|
||||||
|
{
|
||||||
|
if (version_compare(phpversion(), '5.0.0', '>='))
|
||||||
|
{
|
||||||
|
return microtime(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list($usec, $sec) = explode(' ', microtime());
|
||||||
|
return ((float) $usec + (float) $sec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = microtime_float();
|
||||||
|
|
||||||
|
include('../simplepie.inc');
|
||||||
|
|
||||||
|
// Parse it
|
||||||
|
$feed = new SimplePie();
|
||||||
|
if (!empty($_GET['feed']))
|
||||||
|
{
|
||||||
|
if (get_magic_quotes_gpc())
|
||||||
|
{
|
||||||
|
$_GET['feed'] = stripslashes($_GET['feed']);
|
||||||
|
}
|
||||||
|
$feed->set_feed_url($_GET['feed']);
|
||||||
|
$feed->init();
|
||||||
|
}
|
||||||
|
$feed->handle_content_type();
|
||||||
|
|
||||||
|
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title><?php echo (empty($_GET['feed'])) ? 'SimplePie' : 'SimplePie: ' . $feed->get_title(); ?></title>
|
||||||
|
|
||||||
|
<!-- META HTTP-EQUIV -->
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=<?php echo ($feed->get_encoding()) ? $feed->get_encoding() : 'UTF-8'; ?>" />
|
||||||
|
<meta http-equiv="imagetoolbar" content="false" />
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
html, body {
|
||||||
|
height:100%;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
background-color:#333;
|
||||||
|
color:#fff;
|
||||||
|
font-size:3em;
|
||||||
|
margin:0;
|
||||||
|
padding:5px 15px;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer {
|
||||||
|
padding:5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer,
|
||||||
|
div#footer a {
|
||||||
|
text-align:center;
|
||||||
|
font-size:0.7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#footer a {
|
||||||
|
text-decoration:underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
background-color:#f3f3ff;
|
||||||
|
color:#000;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
background-color:#f3f3ff;
|
||||||
|
color:#000080;
|
||||||
|
border:1px dotted #000080;
|
||||||
|
padding:3px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.chunk {
|
||||||
|
border-bottom:1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
form#sp_form {
|
||||||
|
text-align:center;
|
||||||
|
margin:0;
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
form#sp_form input.text {
|
||||||
|
width:85%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1><?php echo (empty($_GET['feed'])) ? 'SimplePie' : 'SimplePie: ' . $feed->get_title(); ?></h1>
|
||||||
|
|
||||||
|
<form action="" method="get" name="sp_form" id="sp_form">
|
||||||
|
<p><input type="text" name="feed" value="<?php echo ($feed->subscribe_url()) ? htmlspecialchars($feed->subscribe_url()) : 'http://'; ?>" class="text" id="feed_input" /> <input type="submit" value="Read" class="button" /></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div id="sp_results">
|
||||||
|
<?php if ($feed->data): ?>
|
||||||
|
<?php $items = $feed->get_items(); ?>
|
||||||
|
<p align="center"><span style="background-color:#ffc;">Displaying <?php echo $feed->get_item_quantity(); ?> most recent entries.</span></p>
|
||||||
|
<?php foreach($items as $item): ?>
|
||||||
|
<div class="chunk" style="padding:0 5px;">
|
||||||
|
<h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a> <?php echo $item->get_date('j M Y'); ?></h4>
|
||||||
|
<?php echo $item->get_content(); ?>
|
||||||
|
<?php
|
||||||
|
if ($enclosure = $item->get_enclosure(0))
|
||||||
|
echo '<p><a href="' . $enclosure->get_link() . '" class="download"><img src="./for_the_demo/mini_podcast.png" alt="Podcast" title="Download the Podcast" border="0" /></a></p>';
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
Powered by <?php echo SIMPLEPIE_LINKBACK; ?>, a product of <a href="http://www.skyzyx.com">Skyzyx Technologies</a>.<br />
|
||||||
|
Page created in <?php echo round(microtime_float()-$start, 3); ?> seconds.
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?php
|
||||||
|
/********************************************************************
|
||||||
|
MULTIFEEDS TEST PAGE
|
||||||
|
|
||||||
|
Nothing too exciting here. Just a sample page that demos integrated
|
||||||
|
Multifeeds support as well as cached favicons and perhaps a few other
|
||||||
|
things.
|
||||||
|
|
||||||
|
Lots of this code is commented to help explain some of the new stuff.
|
||||||
|
Code was tested in PHP 5.2.2, but *should* also work with earlier
|
||||||
|
versions of PHP, as supported by SimplePie (PHP 4.1).
|
||||||
|
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
// Include the SimplePie library, and the one that handles internationalized domain names.
|
||||||
|
require_once('../simplepie.inc');
|
||||||
|
require_once('../idn/idna_convert.class.php');
|
||||||
|
|
||||||
|
// Initialize some feeds for use.
|
||||||
|
$feed = new SimplePie();
|
||||||
|
$feed->set_feed_url(array(
|
||||||
|
'http://rss.news.yahoo.com/rss/topstories',
|
||||||
|
'http://news.google.com/?output=atom',
|
||||||
|
'http://rss.cnn.com/rss/cnn_topstories.rss'
|
||||||
|
));
|
||||||
|
|
||||||
|
// When we set these, we need to make sure that the handler_image.php file is also trying to read from the same cache directory that we are.
|
||||||
|
$feed->set_favicon_handler('./handler_image.php');
|
||||||
|
$feed->set_image_handler('./handler_image.php');
|
||||||
|
|
||||||
|
// Initialize the feed.
|
||||||
|
$feed->init();
|
||||||
|
|
||||||
|
// Make sure the page is being served with the UTF-8 headers.
|
||||||
|
$feed->handle_content_type();
|
||||||
|
|
||||||
|
// Begin the (X)HTML page.
|
||||||
|
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Multifeeds Test page</title>
|
||||||
|
<link rel="stylesheet" href="../demo/for_the_demo/simplepie.css" type="text/css" media="screen" title="SimplePie Styles" charset="utf-8" />
|
||||||
|
<style type="text/css">
|
||||||
|
div#site {
|
||||||
|
width:600px;
|
||||||
|
}
|
||||||
|
span.footnote {
|
||||||
|
white-space:nowrap;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
line-height:1.4em;
|
||||||
|
}
|
||||||
|
h4 {
|
||||||
|
padding-left:20px;
|
||||||
|
background-color:transparent;
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
background-position:0 1px;
|
||||||
|
}
|
||||||
|
.clearBoth {
|
||||||
|
clear:both;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="site">
|
||||||
|
|
||||||
|
<?php if ($feed->error): ?>
|
||||||
|
<p><?=$feed->error()?></p>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<div class="chunk">
|
||||||
|
<h1>Quick-n-Dirty Multifeeds Demo</a></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Let's loop through each item in the feed.
|
||||||
|
foreach($feed->get_items() as $item):
|
||||||
|
|
||||||
|
// Let's give ourselves a reference to the parent $feed object for this particular item.
|
||||||
|
$feed = $item->get_feed();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="chunk">
|
||||||
|
<h4 style="background-image:url(<?php echo $feed->get_favicon(); ?>);"><a href="<?php echo $item->get_permalink(); ?>"><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'); ?></a></h4>
|
||||||
|
|
||||||
|
<!-- get_content() prefers full content over summaries -->
|
||||||
|
<?php echo $item->get_content(); ?>
|
||||||
|
|
||||||
|
<?php if ($enclosure = $item->get_enclosure()): ?>
|
||||||
|
<div>
|
||||||
|
<?php echo $enclosure->native_embed(array(
|
||||||
|
// New 'mediaplayer' attribute shows off Flash-based MP3 and FLV playback.
|
||||||
|
'mediaplayer' => '../demo/for_the_demo/mediaplayer.swf'
|
||||||
|
)); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<p class="footnote">Source: <a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a'); ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<p class="footnote">This is a test of the emergency broadcast system. This is only a test… beeeeeeeeeeeeeeeeeeeeeeeeeep!</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
include_once('../simplepie.inc');
|
||||||
|
include_once('../idn/idna_convert.class.php');
|
||||||
|
|
||||||
|
// Parse it
|
||||||
|
$feed = new SimplePie();
|
||||||
|
if (isset($_GET['feed']) && $_GET['feed'] !== '')
|
||||||
|
{
|
||||||
|
if (get_magic_quotes_gpc())
|
||||||
|
{
|
||||||
|
$_GET['feed'] = stripslashes($_GET['feed']);
|
||||||
|
}
|
||||||
|
$feed->set_feed_url($_GET['feed']);
|
||||||
|
$feed->enable_cache(false);
|
||||||
|
$starttime = explode(' ', microtime());
|
||||||
|
$starttime = $starttime[1] + $starttime[0];
|
||||||
|
$feed->init();
|
||||||
|
$endtime = explode(' ', microtime());
|
||||||
|
$endtime = $endtime[1] + $endtime[0];
|
||||||
|
$time = $endtime - $starttime;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$time = 'null';
|
||||||
|
}
|
||||||
|
|
||||||
|
$feed->handle_content_type();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
|
<title>SimplePie Test</title>
|
||||||
|
<pre>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// memory_get_peak_usage() only exists on PHP 5.2 and higher if PHP is compiled with the --enable-memory-limit configuration option or on PHP 5.2.1 and higher (which runs as if --enable-memory-limit was on, with no option)
|
||||||
|
if (function_exists('memory_get_peak_usage'))
|
||||||
|
{
|
||||||
|
var_dump($time, memory_get_usage(), memory_get_peak_usage());
|
||||||
|
}
|
||||||
|
// memory_get_usage() only exists if PHP is compiled with the --enable-memory-limit configuration option or on PHP 5.2.1 and higher (which runs as if --enable-memory-limit was on, with no option)
|
||||||
|
else if (function_exists('memory_get_usage'))
|
||||||
|
{
|
||||||
|
var_dump($time, memory_get_usage());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var_dump($time);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output buffer
|
||||||
|
function callable_htmlspecialchars($string)
|
||||||
|
{
|
||||||
|
return htmlspecialchars($string);
|
||||||
|
}
|
||||||
|
ob_start('callable_htmlspecialchars');
|
||||||
|
|
||||||
|
// Output
|
||||||
|
print_r($feed);
|
||||||
|
ob_end_flush();
|
||||||
|
|
||||||
|
?>
|
||||||
|
</pre>
|
|
@ -0,0 +1,502 @@
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 2.1, February 1999
|
||||||
|
|
||||||
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
[This is the first released version of the Lesser GPL. It also counts
|
||||||
|
as the successor of the GNU Library Public License, version 2, hence
|
||||||
|
the version number 2.1.]
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
Licenses are intended to guarantee your freedom to share and change
|
||||||
|
free software--to make sure the software is free for all its users.
|
||||||
|
|
||||||
|
This license, the Lesser General Public License, applies to some
|
||||||
|
specially designated software packages--typically libraries--of the
|
||||||
|
Free Software Foundation and other authors who decide to use it. You
|
||||||
|
can use it too, but we suggest you first think carefully about whether
|
||||||
|
this license or the ordinary General Public License is the better
|
||||||
|
strategy to use in any particular case, based on the explanations below.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom of use,
|
||||||
|
not price. Our General Public Licenses are designed to make sure that
|
||||||
|
you have the freedom to distribute copies of free software (and charge
|
||||||
|
for this service if you wish); that you receive source code or can get
|
||||||
|
it if you want it; that you can change the software and use pieces of
|
||||||
|
it in new free programs; and that you are informed that you can do
|
||||||
|
these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
distributors to deny you these rights or to ask you to surrender these
|
||||||
|
rights. These restrictions translate to certain responsibilities for
|
||||||
|
you if you distribute copies of the library or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of the library, whether gratis
|
||||||
|
or for a fee, you must give the recipients all the rights that we gave
|
||||||
|
you. You must make sure that they, too, receive or can get the source
|
||||||
|
code. If you link other code with the library, you must provide
|
||||||
|
complete object files to the recipients, so that they can relink them
|
||||||
|
with the library after making changes to the library and recompiling
|
||||||
|
it. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
We protect your rights with a two-step method: (1) we copyright the
|
||||||
|
library, and (2) we offer you this license, which gives you legal
|
||||||
|
permission to copy, distribute and/or modify the library.
|
||||||
|
|
||||||
|
To protect each distributor, we want to make it very clear that
|
||||||
|
there is no warranty for the free library. Also, if the library is
|
||||||
|
modified by someone else and passed on, the recipients should know
|
||||||
|
that what they have is not the original version, so that the original
|
||||||
|
author's reputation will not be affected by problems that might be
|
||||||
|
introduced by others.
|
||||||
|
|
||||||
|
Finally, software patents pose a constant threat to the existence of
|
||||||
|
any free program. We wish to make sure that a company cannot
|
||||||
|
effectively restrict the users of a free program by obtaining a
|
||||||
|
restrictive license from a patent holder. Therefore, we insist that
|
||||||
|
any patent license obtained for a version of the library must be
|
||||||
|
consistent with the full freedom of use specified in this license.
|
||||||
|
|
||||||
|
Most GNU software, including some libraries, is covered by the
|
||||||
|
ordinary GNU General Public License. This license, the GNU Lesser
|
||||||
|
General Public License, applies to certain designated libraries, and
|
||||||
|
is quite different from the ordinary General Public License. We use
|
||||||
|
this license for certain libraries in order to permit linking those
|
||||||
|
libraries into non-free programs.
|
||||||
|
|
||||||
|
When a program is linked with a library, whether statically or using
|
||||||
|
a shared library, the combination of the two is legally speaking a
|
||||||
|
combined work, a derivative of the original library. The ordinary
|
||||||
|
General Public License therefore permits such linking only if the
|
||||||
|
entire combination fits its criteria of freedom. The Lesser General
|
||||||
|
Public License permits more lax criteria for linking other code with
|
||||||
|
the library.
|
||||||
|
|
||||||
|
We call this license the "Lesser" General Public License because it
|
||||||
|
does Less to protect the user's freedom than the ordinary General
|
||||||
|
Public License. It also provides other free software developers Less
|
||||||
|
of an advantage over competing non-free programs. These disadvantages
|
||||||
|
are the reason we use the ordinary General Public License for many
|
||||||
|
libraries. However, the Lesser license provides advantages in certain
|
||||||
|
special circumstances.
|
||||||
|
|
||||||
|
For example, on rare occasions, there may be a special need to
|
||||||
|
encourage the widest possible use of a certain library, so that it becomes
|
||||||
|
a de-facto standard. To achieve this, non-free programs must be
|
||||||
|
allowed to use the library. A more frequent case is that a free
|
||||||
|
library does the same job as widely used non-free libraries. In this
|
||||||
|
case, there is little to gain by limiting the free library to free
|
||||||
|
software only, so we use the Lesser General Public License.
|
||||||
|
|
||||||
|
In other cases, permission to use a particular library in non-free
|
||||||
|
programs enables a greater number of people to use a large body of
|
||||||
|
free software. For example, permission to use the GNU C Library in
|
||||||
|
non-free programs enables many more people to use the whole GNU
|
||||||
|
operating system, as well as its variant, the GNU/Linux operating
|
||||||
|
system.
|
||||||
|
|
||||||
|
Although the Lesser General Public License is Less protective of the
|
||||||
|
users' freedom, it does ensure that the user of a program that is
|
||||||
|
linked with the Library has the freedom and the wherewithal to run
|
||||||
|
that program using a modified version of the Library.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow. Pay close attention to the difference between a
|
||||||
|
"work based on the library" and a "work that uses the library". The
|
||||||
|
former contains code derived from the library, whereas the latter must
|
||||||
|
be combined with the library in order to run.
|
||||||
|
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License Agreement applies to any software library or other
|
||||||
|
program which contains a notice placed by the copyright holder or
|
||||||
|
other authorized party saying it may be distributed under the terms of
|
||||||
|
this Lesser General Public License (also called "this License").
|
||||||
|
Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
A "library" means a collection of software functions and/or data
|
||||||
|
prepared so as to be conveniently linked with application programs
|
||||||
|
(which use some of those functions and data) to form executables.
|
||||||
|
|
||||||
|
The "Library", below, refers to any such software library or work
|
||||||
|
which has been distributed under these terms. A "work based on the
|
||||||
|
Library" means either the Library or any derivative work under
|
||||||
|
copyright law: that is to say, a work containing the Library or a
|
||||||
|
portion of it, either verbatim or with modifications and/or translated
|
||||||
|
straightforwardly into another language. (Hereinafter, translation is
|
||||||
|
included without limitation in the term "modification".)
|
||||||
|
|
||||||
|
"Source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For a library, complete source code means
|
||||||
|
all the source code for all modules it contains, plus any associated
|
||||||
|
interface definition files, plus the scripts used to control compilation
|
||||||
|
and installation of the library.
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running a program using the Library is not restricted, and output from
|
||||||
|
such a program is covered only if its contents constitute a work based
|
||||||
|
on the Library (independent of the use of the Library in a tool for
|
||||||
|
writing it). Whether that is true depends on what the Library does
|
||||||
|
and what the program that uses the Library does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Library's
|
||||||
|
complete source code as you receive it, in any medium, provided that
|
||||||
|
you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||||
|
all the notices that refer to this License and to the absence of any
|
||||||
|
warranty; and distribute a copy of this License along with the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy,
|
||||||
|
and you may at your option offer warranty protection in exchange for a
|
||||||
|
fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Library or any portion
|
||||||
|
of it, thus forming a work based on the Library, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The modified work must itself be a software library.
|
||||||
|
|
||||||
|
b) You must cause the files modified to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
c) You must cause the whole of the work to be licensed at no
|
||||||
|
charge to all third parties under the terms of this License.
|
||||||
|
|
||||||
|
d) If a facility in the modified Library refers to a function or a
|
||||||
|
table of data to be supplied by an application program that uses
|
||||||
|
the facility, other than as an argument passed when the facility
|
||||||
|
is invoked, then you must make a good faith effort to ensure that,
|
||||||
|
in the event an application does not supply such function or
|
||||||
|
table, the facility still operates, and performs whatever part of
|
||||||
|
its purpose remains meaningful.
|
||||||
|
|
||||||
|
(For example, a function in a library to compute square roots has
|
||||||
|
a purpose that is entirely well-defined independent of the
|
||||||
|
application. Therefore, Subsection 2d requires that any
|
||||||
|
application-supplied function or table used by this function must
|
||||||
|
be optional: if the application does not supply it, the square
|
||||||
|
root function must still compute square roots.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Library,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Library, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote
|
||||||
|
it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Library.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Library
|
||||||
|
with the Library (or with a work based on the Library) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||||
|
License instead of this License to a given copy of the Library. To do
|
||||||
|
this, you must alter all the notices that refer to this License, so
|
||||||
|
that they refer to the ordinary GNU General Public License, version 2,
|
||||||
|
instead of to this License. (If a newer version than version 2 of the
|
||||||
|
ordinary GNU General Public License has appeared, then you can specify
|
||||||
|
that version instead if you wish.) Do not make any other change in
|
||||||
|
these notices.
|
||||||
|
|
||||||
|
Once this change is made in a given copy, it is irreversible for
|
||||||
|
that copy, so the ordinary GNU General Public License applies to all
|
||||||
|
subsequent copies and derivative works made from that copy.
|
||||||
|
|
||||||
|
This option is useful when you wish to copy part of the code of
|
||||||
|
the Library into a program that is not a library.
|
||||||
|
|
||||||
|
4. You may copy and distribute the Library (or a portion or
|
||||||
|
derivative of it, under Section 2) in object code or executable form
|
||||||
|
under the terms of Sections 1 and 2 above provided that you accompany
|
||||||
|
it with the complete corresponding machine-readable source code, which
|
||||||
|
must be distributed under the terms of Sections 1 and 2 above on a
|
||||||
|
medium customarily used for software interchange.
|
||||||
|
|
||||||
|
If distribution of object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the
|
||||||
|
source code from the same place satisfies the requirement to
|
||||||
|
distribute the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
5. A program that contains no derivative of any portion of the
|
||||||
|
Library, but is designed to work with the Library by being compiled or
|
||||||
|
linked with it, is called a "work that uses the Library". Such a
|
||||||
|
work, in isolation, is not a derivative work of the Library, and
|
||||||
|
therefore falls outside the scope of this License.
|
||||||
|
|
||||||
|
However, linking a "work that uses the Library" with the Library
|
||||||
|
creates an executable that is a derivative of the Library (because it
|
||||||
|
contains portions of the Library), rather than a "work that uses the
|
||||||
|
library". The executable is therefore covered by this License.
|
||||||
|
Section 6 states terms for distribution of such executables.
|
||||||
|
|
||||||
|
When a "work that uses the Library" uses material from a header file
|
||||||
|
that is part of the Library, the object code for the work may be a
|
||||||
|
derivative work of the Library even though the source code is not.
|
||||||
|
Whether this is true is especially significant if the work can be
|
||||||
|
linked without the Library, or if the work is itself a library. The
|
||||||
|
threshold for this to be true is not precisely defined by law.
|
||||||
|
|
||||||
|
If such an object file uses only numerical parameters, data
|
||||||
|
structure layouts and accessors, and small macros and small inline
|
||||||
|
functions (ten lines or less in length), then the use of the object
|
||||||
|
file is unrestricted, regardless of whether it is legally a derivative
|
||||||
|
work. (Executables containing this object code plus portions of the
|
||||||
|
Library will still fall under Section 6.)
|
||||||
|
|
||||||
|
Otherwise, if the work is a derivative of the Library, you may
|
||||||
|
distribute the object code for the work under the terms of Section 6.
|
||||||
|
Any executables containing that work also fall under Section 6,
|
||||||
|
whether or not they are linked directly with the Library itself.
|
||||||
|
|
||||||
|
6. As an exception to the Sections above, you may also combine or
|
||||||
|
link a "work that uses the Library" with the Library to produce a
|
||||||
|
work containing portions of the Library, and distribute that work
|
||||||
|
under terms of your choice, provided that the terms permit
|
||||||
|
modification of the work for the customer's own use and reverse
|
||||||
|
engineering for debugging such modifications.
|
||||||
|
|
||||||
|
You must give prominent notice with each copy of the work that the
|
||||||
|
Library is used in it and that the Library and its use are covered by
|
||||||
|
this License. You must supply a copy of this License. If the work
|
||||||
|
during execution displays copyright notices, you must include the
|
||||||
|
copyright notice for the Library among them, as well as a reference
|
||||||
|
directing the user to the copy of this License. Also, you must do one
|
||||||
|
of these things:
|
||||||
|
|
||||||
|
a) Accompany the work with the complete corresponding
|
||||||
|
machine-readable source code for the Library including whatever
|
||||||
|
changes were used in the work (which must be distributed under
|
||||||
|
Sections 1 and 2 above); and, if the work is an executable linked
|
||||||
|
with the Library, with the complete machine-readable "work that
|
||||||
|
uses the Library", as object code and/or source code, so that the
|
||||||
|
user can modify the Library and then relink to produce a modified
|
||||||
|
executable containing the modified Library. (It is understood
|
||||||
|
that the user who changes the contents of definitions files in the
|
||||||
|
Library will not necessarily be able to recompile the application
|
||||||
|
to use the modified definitions.)
|
||||||
|
|
||||||
|
b) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (1) uses at run time a
|
||||||
|
copy of the library already present on the user's computer system,
|
||||||
|
rather than copying library functions into the executable, and (2)
|
||||||
|
will operate properly with a modified version of the library, if
|
||||||
|
the user installs one, as long as the modified version is
|
||||||
|
interface-compatible with the version that the work was made with.
|
||||||
|
|
||||||
|
c) Accompany the work with a written offer, valid for at
|
||||||
|
least three years, to give the same user the materials
|
||||||
|
specified in Subsection 6a, above, for a charge no more
|
||||||
|
than the cost of performing this distribution.
|
||||||
|
|
||||||
|
d) If distribution of the work is made by offering access to copy
|
||||||
|
from a designated place, offer equivalent access to copy the above
|
||||||
|
specified materials from the same place.
|
||||||
|
|
||||||
|
e) Verify that the user has already received a copy of these
|
||||||
|
materials or that you have already sent this user a copy.
|
||||||
|
|
||||||
|
For an executable, the required form of the "work that uses the
|
||||||
|
Library" must include any data and utility programs needed for
|
||||||
|
reproducing the executable from it. However, as a special exception,
|
||||||
|
the materials to be distributed need not include anything that is
|
||||||
|
normally distributed (in either source or binary form) with the major
|
||||||
|
components (compiler, kernel, and so on) of the operating system on
|
||||||
|
which the executable runs, unless that component itself accompanies
|
||||||
|
the executable.
|
||||||
|
|
||||||
|
It may happen that this requirement contradicts the license
|
||||||
|
restrictions of other proprietary libraries that do not normally
|
||||||
|
accompany the operating system. Such a contradiction means you cannot
|
||||||
|
use both them and the Library together in an executable that you
|
||||||
|
distribute.
|
||||||
|
|
||||||
|
7. You may place library facilities that are a work based on the
|
||||||
|
Library side-by-side in a single library together with other library
|
||||||
|
facilities not covered by this License, and distribute such a combined
|
||||||
|
library, provided that the separate distribution of the work based on
|
||||||
|
the Library and of the other library facilities is otherwise
|
||||||
|
permitted, and provided that you do these two things:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work
|
||||||
|
based on the Library, uncombined with any other library
|
||||||
|
facilities. This must be distributed under the terms of the
|
||||||
|
Sections above.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library of the fact
|
||||||
|
that part of it is a work based on the Library, and explaining
|
||||||
|
where to find the accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
8. You may not copy, modify, sublicense, link with, or distribute
|
||||||
|
the Library except as expressly provided under this License. Any
|
||||||
|
attempt otherwise to copy, modify, sublicense, link with, or
|
||||||
|
distribute the Library is void, and will automatically terminate your
|
||||||
|
rights under this License. However, parties who have received copies,
|
||||||
|
or rights, from you under this License will not have their licenses
|
||||||
|
terminated so long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
9. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Library or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Library (or any work based on the
|
||||||
|
Library), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Library or works based on it.
|
||||||
|
|
||||||
|
10. Each time you redistribute the Library (or any work based on the
|
||||||
|
Library), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute, link with or modify the Library
|
||||||
|
subject to these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties with
|
||||||
|
this License.
|
||||||
|
|
||||||
|
11. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Library at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Library by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Library.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply,
|
||||||
|
and the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
12. If the distribution and/or use of the Library is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Library under this License may add
|
||||||
|
an explicit geographical distribution limitation excluding those countries,
|
||||||
|
so that distribution is permitted only in or among countries not thus
|
||||||
|
excluded. In such case, this License incorporates the limitation as if
|
||||||
|
written in the body of this License.
|
||||||
|
|
||||||
|
13. The Free Software Foundation may publish revised and/or new
|
||||||
|
versions of the Lesser General Public License from time to time.
|
||||||
|
Such new versions will be similar in spirit to the present version,
|
||||||
|
but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Library
|
||||||
|
specifies a version number of this License which applies to it and
|
||||||
|
"any later version", you have the option of following the terms and
|
||||||
|
conditions either of that version or of any later version published by
|
||||||
|
the Free Software Foundation. If the Library does not specify a
|
||||||
|
license version number, you may choose any version ever published by
|
||||||
|
the Free Software Foundation.
|
||||||
|
|
||||||
|
14. If you wish to incorporate parts of the Library into other free
|
||||||
|
programs whose distribution conditions are incompatible with these,
|
||||||
|
write to the author to ask for permission. For software which is
|
||||||
|
copyrighted by the Free Software Foundation, write to the Free
|
||||||
|
Software Foundation; we sometimes make exceptions for this. Our
|
||||||
|
decision will be guided by the two goals of preserving the free status
|
||||||
|
of all derivatives of our free software and of promoting the sharing
|
||||||
|
and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||||
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||||
|
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||||
|
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||||
|
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||||
|
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||||
|
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||||
|
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||||
|
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||||
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||||
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Libraries
|
||||||
|
|
||||||
|
If you develop a new library, and you want it to be of the greatest
|
||||||
|
possible use to the public, we recommend making it free software that
|
||||||
|
everyone can redistribute and change. You can do so by permitting
|
||||||
|
redistribution under these terms (or, alternatively, under the terms of the
|
||||||
|
ordinary General Public License).
|
||||||
|
|
||||||
|
To apply these terms, attach the following notices to the library. It is
|
||||||
|
safest to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the library's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||||
|
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1990
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
That's all there is to it!
|
|
@ -0,0 +1,123 @@
|
||||||
|
*******************************************************************************
|
||||||
|
* *
|
||||||
|
* IDNA Convert (idna_convert.class.php) *
|
||||||
|
* *
|
||||||
|
* http://idnaconv.phlymail.de mailto:phlymail@phlylabs.de *
|
||||||
|
*******************************************************************************
|
||||||
|
* (c) 2004-2007 phlyLabs, Berlin *
|
||||||
|
* This file is encoded in UTF-8 *
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
------------
|
||||||
|
|
||||||
|
The class idna_convert allows to convert internationalized domain names
|
||||||
|
(see RFC 3490, 3491, 3492 and 3454 for detials) as they can be used with various
|
||||||
|
registries worldwide to be translated between their original (localized) form
|
||||||
|
and their encoded form as it will be used in the DNS (Domain Name System).
|
||||||
|
|
||||||
|
The class provides two public methods, encode() and decode(), which do exactly
|
||||||
|
what you would expect them to do. You are allowed to use complete domain names,
|
||||||
|
simple strings and complete email addresses as well. That means, that you might
|
||||||
|
use any of the following notations:
|
||||||
|
|
||||||
|
- www.nörgler.com
|
||||||
|
- xn--nrgler-wxa
|
||||||
|
- xn--brse-5qa.xn--knrz-1ra.info
|
||||||
|
|
||||||
|
Errors, incorrectly encoded or invalid strings will lead to either a FALSE
|
||||||
|
response (when in strict mode) or to only partially converted strings.
|
||||||
|
You can query the occured error by calling the method get_last_error().
|
||||||
|
|
||||||
|
Unicode strings are expected to be either UTF-8 strings, UCS-4 strings or UCS-4
|
||||||
|
arrays. The default format is UTF-8. For setting different encodings, you can
|
||||||
|
call the method setParams() - please see the inline documentation for details.
|
||||||
|
ACE strings (the Punycode form) are always 7bit ASCII strings.
|
||||||
|
|
||||||
|
ATTENTION: We no longer supply the PHP5 version of the class. It is not
|
||||||
|
necessary for achieving a successfull conversion, since the supplied PHP code is
|
||||||
|
compatible with both PHP4 and PHP5. We expect to see no compatibility issues
|
||||||
|
with the upcoming PHP6, too.
|
||||||
|
|
||||||
|
|
||||||
|
Files
|
||||||
|
-----
|
||||||
|
|
||||||
|
idna_convert.class.php - The actual class
|
||||||
|
idna_convert.create.npdata.php - Useful for (re)creating the NPData file
|
||||||
|
npdata.ser - Serialized data for NamePrep
|
||||||
|
example.php - An example web page for converting
|
||||||
|
ReadMe.txt - This file
|
||||||
|
LICENCE - The LGPL licence file
|
||||||
|
|
||||||
|
The class is contained in idna_convert.class.php.
|
||||||
|
MAKE SURE to copy the npdata.ser file into the same folder as the class file
|
||||||
|
itself!
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
1. Say we wish to encode the domain name nörgler.com:
|
||||||
|
|
||||||
|
// Include the class
|
||||||
|
include_once('idna_convert.class.php');
|
||||||
|
// Instantiate it *
|
||||||
|
$IDN = new idna_convert();
|
||||||
|
// The input string, if input is not UTF-8 or UCS-4, it must be converted before
|
||||||
|
$input = utf8_encode('nörgler.com');
|
||||||
|
// Encode it to its punycode presentation
|
||||||
|
$output = $IDN->encode($input);
|
||||||
|
// Output, what we got now
|
||||||
|
echo $output; // This will read: xn--nrgler-wxa.com
|
||||||
|
|
||||||
|
|
||||||
|
2. We received an email from a punycoded domain and are willing to learn, how
|
||||||
|
the domain name reads originally
|
||||||
|
|
||||||
|
// Include the class
|
||||||
|
include_once('idna_convert.class.php');
|
||||||
|
// Instantiate it (depending on the version you are using) with
|
||||||
|
$IDN = new idna_convert();
|
||||||
|
// The input string
|
||||||
|
$input = 'andre@xn--brse-5qa.xn--knrz-1ra.info';
|
||||||
|
// Encode it to its punycode presentation
|
||||||
|
$output = $IDN->decode($input);
|
||||||
|
// Output, what we got now, if output should be in a format different to UTF-8
|
||||||
|
// or UCS-4, you will have to convert it before outputting it
|
||||||
|
echo utf8_decode($output); // This will read: andre@börse.knörz.info
|
||||||
|
|
||||||
|
|
||||||
|
3. The input is read from a UCS-4 coded file and encoded line by line. By
|
||||||
|
appending the optional second parameter we tell enode() about the input
|
||||||
|
format to be used
|
||||||
|
|
||||||
|
// Include the class
|
||||||
|
include_once('idna_convert.class.php');
|
||||||
|
// Instantiate it
|
||||||
|
$IDN = new dinca_convert();
|
||||||
|
// Iterate through the input file line by line
|
||||||
|
foreach (file('ucs4-domains.txt') as $line) {
|
||||||
|
echo $IDN->encode(trim($line), 'ucs4_string');
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NPData
|
||||||
|
------
|
||||||
|
|
||||||
|
Should you need to recreate the npdata.ser file, which holds all necessary translation
|
||||||
|
tables in a serialized format, you can run the file idna_convert.create.npdata.php, which
|
||||||
|
creates the file for you and stores it in the same folder, where it is placed.
|
||||||
|
Should you need to do changes to the tables you can do so, but beware of the consequences.
|
||||||
|
|
||||||
|
|
||||||
|
Contact us
|
||||||
|
----------
|
||||||
|
|
||||||
|
In case of errors, bugs, questions, wishes, please don't hesitate to contact us
|
||||||
|
under the email address above.
|
||||||
|
|
||||||
|
The team of phlyLabs
|
||||||
|
http://phlylabs.de
|
||||||
|
mailto:phlymail@phlylabs.de
|
|
@ -0,0 +1,969 @@
|
||||||
|
<?php
|
||||||
|
// {{{ license
|
||||||
|
|
||||||
|
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
||||||
|
//
|
||||||
|
// +----------------------------------------------------------------------+
|
||||||
|
// | This library is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU Lesser General Public License as |
|
||||||
|
// | published by the Free Software Foundation; either version 2.1 of the |
|
||||||
|
// | License, or (at your option) any later version. |
|
||||||
|
// | |
|
||||||
|
// | This library is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | Lesser General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU Lesser General Public |
|
||||||
|
// | License along with this library; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
||||||
|
// | USA. |
|
||||||
|
// +----------------------------------------------------------------------+
|
||||||
|
//
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode/decode Internationalized Domain Names.
|
||||||
|
*
|
||||||
|
* The class allows to convert internationalized domain names
|
||||||
|
* (see RFC 3490 for details) as they can be used with various registries worldwide
|
||||||
|
* to be translated between their original (localized) form and their encoded form
|
||||||
|
* as it will be used in the DNS (Domain Name System).
|
||||||
|
*
|
||||||
|
* The class provides two public methods, encode() and decode(), which do exactly
|
||||||
|
* what you would expect them to do. You are allowed to use complete domain names,
|
||||||
|
* simple strings and complete email addresses as well. That means, that you might
|
||||||
|
* use any of the following notations:
|
||||||
|
*
|
||||||
|
* - www.nörgler.com
|
||||||
|
* - xn--nrgler-wxa
|
||||||
|
* - xn--brse-5qa.xn--knrz-1ra.info
|
||||||
|
*
|
||||||
|
* Unicode input might be given as either UTF-8 string, UCS-4 string or UCS-4
|
||||||
|
* array. Unicode output is available in the same formats.
|
||||||
|
* You can select your preferred format via {@link set_paramter()}.
|
||||||
|
*
|
||||||
|
* ACE input and output is always expected to be ASCII.
|
||||||
|
*
|
||||||
|
* @author Matthias Sommerfeld <mso@phlylabs.de>
|
||||||
|
* @copyright 2004-2007 phlyLabs Berlin, http://phlylabs.de
|
||||||
|
* @version 0.5.1
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class idna_convert
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Holds all relevant mapping tables, loaded from a seperate file on construct
|
||||||
|
* See RFC3454 for details
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $NP = array();
|
||||||
|
|
||||||
|
// Internal settings, do not mess with them
|
||||||
|
var $_punycode_prefix = 'xn--';
|
||||||
|
var $_invalid_ucs = 0x80000000;
|
||||||
|
var $_max_ucs = 0x10FFFF;
|
||||||
|
var $_base = 36;
|
||||||
|
var $_tmin = 1;
|
||||||
|
var $_tmax = 26;
|
||||||
|
var $_skew = 38;
|
||||||
|
var $_damp = 700;
|
||||||
|
var $_initial_bias = 72;
|
||||||
|
var $_initial_n = 0x80;
|
||||||
|
var $_sbase = 0xAC00;
|
||||||
|
var $_lbase = 0x1100;
|
||||||
|
var $_vbase = 0x1161;
|
||||||
|
var $_tbase = 0x11A7;
|
||||||
|
var $_lcount = 19;
|
||||||
|
var $_vcount = 21;
|
||||||
|
var $_tcount = 28;
|
||||||
|
var $_ncount = 588; // _vcount * _tcount
|
||||||
|
var $_scount = 11172; // _lcount * _tcount * _vcount
|
||||||
|
var $_error = false;
|
||||||
|
|
||||||
|
// See {@link set_paramter()} for details of how to change the following
|
||||||
|
// settings from within your script / application
|
||||||
|
var $_api_encoding = 'utf8'; // Default input charset is UTF-8
|
||||||
|
var $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden
|
||||||
|
var $_strict_mode = false; // Behave strict or not
|
||||||
|
|
||||||
|
// The constructor
|
||||||
|
function idna_convert($options = false)
|
||||||
|
{
|
||||||
|
$this->slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount;
|
||||||
|
if (function_exists('file_get_contents')) {
|
||||||
|
$this->NP = unserialize(file_get_contents(dirname(__FILE__).'/npdata.ser'));
|
||||||
|
} else {
|
||||||
|
$this->NP = unserialize(join('', file(dirname(__FILE__).'/npdata.ser')));
|
||||||
|
}
|
||||||
|
// If parameters are given, pass these to the respective method
|
||||||
|
if (is_array($options)) {
|
||||||
|
return $this->set_parameter($options);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new option value. Available options and values:
|
||||||
|
* [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8,
|
||||||
|
* 'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8]
|
||||||
|
* [overlong - Unicode does not allow unnecessarily long encodings of chars,
|
||||||
|
* to allow this, set this parameter to true, else to false;
|
||||||
|
* default is false.]
|
||||||
|
* [strict - true: strict mode, good for registration purposes - Causes errors
|
||||||
|
* on failures; false: loose mode, ideal for "wildlife" applications
|
||||||
|
* by silently ignoring errors and returning the original input instead
|
||||||
|
*
|
||||||
|
* @param mixed Parameter to set (string: single parameter; array of Parameter => Value pairs)
|
||||||
|
* @param string Value to use (if parameter 1 is a string)
|
||||||
|
* @return boolean true on success, false otherwise
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function set_parameter($option, $value = false)
|
||||||
|
{
|
||||||
|
if (!is_array($option)) {
|
||||||
|
$option = array($option => $value);
|
||||||
|
}
|
||||||
|
foreach ($option as $k => $v) {
|
||||||
|
switch ($k) {
|
||||||
|
case 'encoding':
|
||||||
|
switch ($v) {
|
||||||
|
case 'utf8':
|
||||||
|
case 'ucs4_string':
|
||||||
|
case 'ucs4_array':
|
||||||
|
$this->_api_encoding = $v;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'overlong':
|
||||||
|
$this->_allow_overlong = ($v) ? true : false;
|
||||||
|
break;
|
||||||
|
case 'strict':
|
||||||
|
$this->_strict_mode = ($v) ? true : false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->_error('Set Parameter: Unknown option '.$k);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode a given ACE domain name
|
||||||
|
* @param string Domain name (ACE string)
|
||||||
|
* [@param string Desired output encoding, see {@link set_parameter}]
|
||||||
|
* @return string Decoded Domain name (UTF-8 or UCS-4)
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function decode($input, $one_time_encoding = false)
|
||||||
|
{
|
||||||
|
// Optionally set
|
||||||
|
if ($one_time_encoding) {
|
||||||
|
switch ($one_time_encoding) {
|
||||||
|
case 'utf8':
|
||||||
|
case 'ucs4_string':
|
||||||
|
case 'ucs4_array':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->_error('Unknown encoding '.$one_time_encoding);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Make sure to drop any newline characters around
|
||||||
|
$input = trim($input);
|
||||||
|
|
||||||
|
// Negotiate input and try to determine, whether it is a plain string,
|
||||||
|
// an email address or something like a complete URL
|
||||||
|
if (strpos($input, '@')) { // Maybe it is an email address
|
||||||
|
// No no in strict mode
|
||||||
|
if ($this->_strict_mode) {
|
||||||
|
$this->_error('Only simple domain name parts can be handled in strict mode');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
list ($email_pref, $input) = explode('@', $input, 2);
|
||||||
|
$arr = explode('.', $input);
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
|
||||||
|
$conv = $this->_decode($v);
|
||||||
|
if ($conv) $arr[$k] = $conv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$input = join('.', $arr);
|
||||||
|
$arr = explode('.', $email_pref);
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
|
||||||
|
$conv = $this->_decode($v);
|
||||||
|
if ($conv) $arr[$k] = $conv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$email_pref = join('.', $arr);
|
||||||
|
$return = $email_pref . '@' . $input;
|
||||||
|
} elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
|
||||||
|
// No no in strict mode
|
||||||
|
if ($this->_strict_mode) {
|
||||||
|
$this->_error('Only simple domain name parts can be handled in strict mode');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$parsed = parse_url($input);
|
||||||
|
if (isset($parsed['host'])) {
|
||||||
|
$arr = explode('.', $parsed['host']);
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
$conv = $this->_decode($v);
|
||||||
|
if ($conv) $arr[$k] = $conv;
|
||||||
|
}
|
||||||
|
$parsed['host'] = join('.', $arr);
|
||||||
|
$return =
|
||||||
|
(empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://'))
|
||||||
|
.(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@')
|
||||||
|
.$parsed['host']
|
||||||
|
.(empty($parsed['port']) ? '' : ':'.$parsed['port'])
|
||||||
|
.(empty($parsed['path']) ? '' : $parsed['path'])
|
||||||
|
.(empty($parsed['query']) ? '' : '?'.$parsed['query'])
|
||||||
|
.(empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
|
||||||
|
} else { // parse_url seems to have failed, try without it
|
||||||
|
$arr = explode('.', $input);
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
$conv = $this->_decode($v);
|
||||||
|
$arr[$k] = ($conv) ? $conv : $v;
|
||||||
|
}
|
||||||
|
$return = join('.', $arr);
|
||||||
|
}
|
||||||
|
} else { // Otherwise we consider it being a pure domain name string
|
||||||
|
$return = $this->_decode($input);
|
||||||
|
if (!$return) $return = $input;
|
||||||
|
}
|
||||||
|
// The output is UTF-8 by default, other output formats need conversion here
|
||||||
|
// If one time encoding is given, use this, else the objects property
|
||||||
|
switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
|
||||||
|
case 'utf8':
|
||||||
|
return $return;
|
||||||
|
break;
|
||||||
|
case 'ucs4_string':
|
||||||
|
return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));
|
||||||
|
break;
|
||||||
|
case 'ucs4_array':
|
||||||
|
return $this->_utf8_to_ucs4($return);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->_error('Unsupported output format');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a given UTF-8 domain name
|
||||||
|
* @param string Domain name (UTF-8 or UCS-4)
|
||||||
|
* [@param string Desired input encoding, see {@link set_parameter}]
|
||||||
|
* @return string Encoded Domain name (ACE string)
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function encode($decoded, $one_time_encoding = false)
|
||||||
|
{
|
||||||
|
// Forcing conversion of input to UCS4 array
|
||||||
|
// If one time encoding is given, use this, else the objects property
|
||||||
|
switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) {
|
||||||
|
case 'utf8':
|
||||||
|
$decoded = $this->_utf8_to_ucs4($decoded);
|
||||||
|
break;
|
||||||
|
case 'ucs4_string':
|
||||||
|
$decoded = $this->_ucs4_string_to_ucs4($decoded);
|
||||||
|
case 'ucs4_array':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No input, no output, what else did you expect?
|
||||||
|
if (empty($decoded)) return '';
|
||||||
|
|
||||||
|
// Anchors for iteration
|
||||||
|
$last_begin = 0;
|
||||||
|
// Output string
|
||||||
|
$output = '';
|
||||||
|
foreach ($decoded as $k => $v) {
|
||||||
|
// Make sure to use just the plain dot
|
||||||
|
switch($v) {
|
||||||
|
case 0x3002:
|
||||||
|
case 0xFF0E:
|
||||||
|
case 0xFF61:
|
||||||
|
$decoded[$k] = 0x2E;
|
||||||
|
// Right, no break here, the above are converted to dots anyway
|
||||||
|
// Stumbling across an anchoring character
|
||||||
|
case 0x2E:
|
||||||
|
case 0x2F:
|
||||||
|
case 0x3A:
|
||||||
|
case 0x3F:
|
||||||
|
case 0x40:
|
||||||
|
// Neither email addresses nor URLs allowed in strict mode
|
||||||
|
if ($this->_strict_mode) {
|
||||||
|
$this->_error('Neither email addresses nor URLs are allowed in strict mode.');
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// Skip first char
|
||||||
|
if ($k) {
|
||||||
|
$encoded = '';
|
||||||
|
$encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin)));
|
||||||
|
if ($encoded) {
|
||||||
|
$output .= $encoded;
|
||||||
|
} else {
|
||||||
|
$output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin)));
|
||||||
|
}
|
||||||
|
$output .= chr($decoded[$k]);
|
||||||
|
}
|
||||||
|
$last_begin = $k + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Catch the rest of the string
|
||||||
|
if ($last_begin) {
|
||||||
|
$inp_len = sizeof($decoded);
|
||||||
|
$encoded = '';
|
||||||
|
$encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
|
||||||
|
if ($encoded) {
|
||||||
|
$output .= $encoded;
|
||||||
|
} else {
|
||||||
|
$output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
} else {
|
||||||
|
if ($output = $this->_encode($decoded)) {
|
||||||
|
return $output;
|
||||||
|
} else {
|
||||||
|
return $this->_ucs4_to_utf8($decoded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to get the last error ocurred
|
||||||
|
* @param void
|
||||||
|
* @return string The last error, that occured
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function get_last_error()
|
||||||
|
{
|
||||||
|
return $this->_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual decoding algorithm
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _decode($encoded)
|
||||||
|
{
|
||||||
|
// We do need to find the Punycode prefix
|
||||||
|
if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) {
|
||||||
|
$this->_error('This is not a punycode string');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded);
|
||||||
|
// If nothing left after removing the prefix, it is hopeless
|
||||||
|
if (!$encode_test) {
|
||||||
|
$this->_error('The given encoded string was empty');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Find last occurence of the delimiter
|
||||||
|
$delim_pos = strrpos($encoded, '-');
|
||||||
|
if ($delim_pos > strlen($this->_punycode_prefix)) {
|
||||||
|
for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
|
||||||
|
$decoded[] = ord($encoded{$k});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$decoded = array();
|
||||||
|
}
|
||||||
|
$deco_len = count($decoded);
|
||||||
|
$enco_len = strlen($encoded);
|
||||||
|
|
||||||
|
// Wandering through the strings; init
|
||||||
|
$is_first = true;
|
||||||
|
$bias = $this->_initial_bias;
|
||||||
|
$idx = 0;
|
||||||
|
$char = $this->_initial_n;
|
||||||
|
|
||||||
|
for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
|
||||||
|
for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
|
||||||
|
$digit = $this->_decode_digit($encoded{$enco_idx++});
|
||||||
|
$idx += $digit * $w;
|
||||||
|
$t = ($k <= $bias) ? $this->_tmin :
|
||||||
|
(($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
|
||||||
|
if ($digit < $t) break;
|
||||||
|
$w = (int) ($w * ($this->_base - $t));
|
||||||
|
}
|
||||||
|
$bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
|
||||||
|
$is_first = false;
|
||||||
|
$char += (int) ($idx / ($deco_len + 1));
|
||||||
|
$idx %= ($deco_len + 1);
|
||||||
|
if ($deco_len > 0) {
|
||||||
|
// Make room for the decoded char
|
||||||
|
for ($i = $deco_len; $i > $idx; $i--) {
|
||||||
|
$decoded[$i] = $decoded[($i - 1)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$decoded[$idx++] = $char;
|
||||||
|
}
|
||||||
|
return $this->_ucs4_to_utf8($decoded);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual encoding algorithm
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _encode($decoded)
|
||||||
|
{
|
||||||
|
// We cannot encode a domain name containing the Punycode prefix
|
||||||
|
$extract = strlen($this->_punycode_prefix);
|
||||||
|
$check_pref = $this->_utf8_to_ucs4($this->_punycode_prefix);
|
||||||
|
$check_deco = array_slice($decoded, 0, $extract);
|
||||||
|
|
||||||
|
if ($check_pref == $check_deco) {
|
||||||
|
$this->_error('This is already a punycode string');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// We will not try to encode strings consisting of basic code points only
|
||||||
|
$encodable = false;
|
||||||
|
foreach ($decoded as $k => $v) {
|
||||||
|
if ($v > 0x7a) {
|
||||||
|
$encodable = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$encodable) {
|
||||||
|
$this->_error('The given string does not contain encodable chars');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do NAMEPREP
|
||||||
|
$decoded = $this->_nameprep($decoded);
|
||||||
|
if (!$decoded || !is_array($decoded)) return false; // NAMEPREP failed
|
||||||
|
|
||||||
|
$deco_len = count($decoded);
|
||||||
|
if (!$deco_len) return false; // Empty array
|
||||||
|
|
||||||
|
$codecount = 0; // How many chars have been consumed
|
||||||
|
|
||||||
|
$encoded = '';
|
||||||
|
// Copy all basic code points to output
|
||||||
|
for ($i = 0; $i < $deco_len; ++$i) {
|
||||||
|
$test = $decoded[$i];
|
||||||
|
// Will match [-0-9a-zA-Z]
|
||||||
|
if ((0x2F < $test && $test < 0x40) || (0x40 < $test && $test < 0x5B)
|
||||||
|
|| (0x60 < $test && $test <= 0x7B) || (0x2D == $test)) {
|
||||||
|
$encoded .= chr($decoded[$i]);
|
||||||
|
$codecount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($codecount == $deco_len) return $encoded; // All codepoints were basic ones
|
||||||
|
|
||||||
|
// Start with the prefix; copy it to output
|
||||||
|
$encoded = $this->_punycode_prefix.$encoded;
|
||||||
|
|
||||||
|
// If we have basic code points in output, add an hyphen to the end
|
||||||
|
if ($codecount) $encoded .= '-';
|
||||||
|
|
||||||
|
// Now find and encode all non-basic code points
|
||||||
|
$is_first = true;
|
||||||
|
$cur_code = $this->_initial_n;
|
||||||
|
$bias = $this->_initial_bias;
|
||||||
|
$delta = 0;
|
||||||
|
while ($codecount < $deco_len) {
|
||||||
|
// Find the smallest code point >= the current code point and
|
||||||
|
// remember the last ouccrence of it in the input
|
||||||
|
for ($i = 0, $next_code = $this->_max_ucs; $i < $deco_len; $i++) {
|
||||||
|
if ($decoded[$i] >= $cur_code && $decoded[$i] <= $next_code) {
|
||||||
|
$next_code = $decoded[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$delta += ($next_code - $cur_code) * ($codecount + 1);
|
||||||
|
$cur_code = $next_code;
|
||||||
|
|
||||||
|
// Scan input again and encode all characters whose code point is $cur_code
|
||||||
|
for ($i = 0; $i < $deco_len; $i++) {
|
||||||
|
if ($decoded[$i] < $cur_code) {
|
||||||
|
$delta++;
|
||||||
|
} elseif ($decoded[$i] == $cur_code) {
|
||||||
|
for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
|
||||||
|
$t = ($k <= $bias) ? $this->_tmin :
|
||||||
|
(($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
|
||||||
|
if ($q < $t) break;
|
||||||
|
$encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval()
|
||||||
|
$q = (int) (($q - $t) / ($this->_base - $t));
|
||||||
|
}
|
||||||
|
$encoded .= $this->_encode_digit($q);
|
||||||
|
$bias = $this->_adapt($delta, $codecount+1, $is_first);
|
||||||
|
$codecount++;
|
||||||
|
$delta = 0;
|
||||||
|
$is_first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$delta++;
|
||||||
|
$cur_code++;
|
||||||
|
}
|
||||||
|
return $encoded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapt the bias according to the current code point and position
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _adapt($delta, $npoints, $is_first)
|
||||||
|
{
|
||||||
|
$delta = intval($is_first ? ($delta / $this->_damp) : ($delta / 2));
|
||||||
|
$delta += intval($delta / $npoints);
|
||||||
|
for ($k = 0; $delta > (($this->_base - $this->_tmin) * $this->_tmax) / 2; $k += $this->_base) {
|
||||||
|
$delta = intval($delta / ($this->_base - $this->_tmin));
|
||||||
|
}
|
||||||
|
return intval($k + ($this->_base - $this->_tmin + 1) * $delta / ($delta + $this->_skew));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encoding a certain digit
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _encode_digit($d)
|
||||||
|
{
|
||||||
|
return chr($d + 22 + 75 * ($d < 26));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode a certain digit
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _decode_digit($cp)
|
||||||
|
{
|
||||||
|
$cp = ord($cp);
|
||||||
|
return ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $this->_base));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal error handling method
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _error($error = '')
|
||||||
|
{
|
||||||
|
$this->_error = $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do Nameprep according to RFC3491 and RFC3454
|
||||||
|
* @param array Unicode Characters
|
||||||
|
* @return string Unicode Characters, Nameprep'd
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _nameprep($input)
|
||||||
|
{
|
||||||
|
$output = array();
|
||||||
|
$error = false;
|
||||||
|
//
|
||||||
|
// Mapping
|
||||||
|
// Walking through the input array, performing the required steps on each of
|
||||||
|
// the input chars and putting the result into the output array
|
||||||
|
// While mapping required chars we apply the cannonical ordering
|
||||||
|
foreach ($input as $v) {
|
||||||
|
// Map to nothing == skip that code point
|
||||||
|
if (in_array($v, $this->NP['map_nothing'])) continue;
|
||||||
|
|
||||||
|
// Try to find prohibited input
|
||||||
|
if (in_array($v, $this->NP['prohibit']) || in_array($v, $this->NP['general_prohibited'])) {
|
||||||
|
$this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach ($this->NP['prohibit_ranges'] as $range) {
|
||||||
|
if ($range[0] <= $v && $v <= $range[1]) {
|
||||||
|
$this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Hangul syllable decomposition
|
||||||
|
if (0xAC00 <= $v && $v <= 0xD7AF) {
|
||||||
|
foreach ($this->_hangul_decompose($v) as $out) {
|
||||||
|
$output[] = (int) $out;
|
||||||
|
}
|
||||||
|
// There's a decomposition mapping for that code point
|
||||||
|
} elseif (isset($this->NP['replacemaps'][$v])) {
|
||||||
|
foreach ($this->_apply_cannonical_ordering($this->NP['replacemaps'][$v]) as $out) {
|
||||||
|
$output[] = (int) $out;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$output[] = (int) $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Before applying any Combining, try to rearrange any Hangul syllables
|
||||||
|
$output = $this->_hangul_compose($output);
|
||||||
|
//
|
||||||
|
// Combine code points
|
||||||
|
//
|
||||||
|
$last_class = 0;
|
||||||
|
$last_starter = 0;
|
||||||
|
$out_len = count($output);
|
||||||
|
for ($i = 0; $i < $out_len; ++$i) {
|
||||||
|
$class = $this->_get_combining_class($output[$i]);
|
||||||
|
if ((!$last_class || $last_class > $class) && $class) {
|
||||||
|
// Try to match
|
||||||
|
$seq_len = $i - $last_starter;
|
||||||
|
$out = $this->_combine(array_slice($output, $last_starter, $seq_len));
|
||||||
|
// On match: Replace the last starter with the composed character and remove
|
||||||
|
// the now redundant non-starter(s)
|
||||||
|
if ($out) {
|
||||||
|
$output[$last_starter] = $out;
|
||||||
|
if (count($out) != $seq_len) {
|
||||||
|
for ($j = $i+1; $j < $out_len; ++$j) {
|
||||||
|
$output[$j-1] = $output[$j];
|
||||||
|
}
|
||||||
|
unset($output[$out_len]);
|
||||||
|
}
|
||||||
|
// Rewind the for loop by one, since there can be more possible compositions
|
||||||
|
$i--;
|
||||||
|
$out_len--;
|
||||||
|
$last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i-1]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The current class is 0
|
||||||
|
if (!$class) $last_starter = $i;
|
||||||
|
$last_class = $class;
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decomposes a Hangul syllable
|
||||||
|
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul
|
||||||
|
* @param integer 32bit UCS4 code point
|
||||||
|
* @return array Either Hangul Syllable decomposed or original 32bit value as one value array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _hangul_decompose($char)
|
||||||
|
{
|
||||||
|
$sindex = (int) $char - $this->_sbase;
|
||||||
|
if ($sindex < 0 || $sindex >= $this->_scount) {
|
||||||
|
return array($char);
|
||||||
|
}
|
||||||
|
$result = array();
|
||||||
|
$result[] = (int) $this->_lbase + $sindex / $this->_ncount;
|
||||||
|
$result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount;
|
||||||
|
$T = intval($this->_tbase + $sindex % $this->_tcount);
|
||||||
|
if ($T != $this->_tbase) $result[] = $T;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Ccomposes a Hangul syllable
|
||||||
|
* (see http://www.unicode.org/unicode/reports/tr15/#Hangul
|
||||||
|
* @param array Decomposed UCS4 sequence
|
||||||
|
* @return array UCS4 sequence with syllables composed
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _hangul_compose($input)
|
||||||
|
{
|
||||||
|
$inp_len = count($input);
|
||||||
|
if (!$inp_len) return array();
|
||||||
|
$result = array();
|
||||||
|
$last = (int) $input[0];
|
||||||
|
$result[] = $last; // copy first char from input to output
|
||||||
|
|
||||||
|
for ($i = 1; $i < $inp_len; ++$i) {
|
||||||
|
$char = (int) $input[$i];
|
||||||
|
$sindex = $last - $this->_sbase;
|
||||||
|
$lindex = $last - $this->_lbase;
|
||||||
|
$vindex = $char - $this->_vbase;
|
||||||
|
$tindex = $char - $this->_tbase;
|
||||||
|
// Find out, whether two current characters are LV and T
|
||||||
|
if (0 <= $sindex && $sindex < $this->_scount && ($sindex % $this->_tcount == 0)
|
||||||
|
&& 0 <= $tindex && $tindex <= $this->_tcount) {
|
||||||
|
// create syllable of form LVT
|
||||||
|
$last += $tindex;
|
||||||
|
$result[(count($result) - 1)] = $last; // reset last
|
||||||
|
continue; // discard char
|
||||||
|
}
|
||||||
|
// Find out, whether two current characters form L and V
|
||||||
|
if (0 <= $lindex && $lindex < $this->_lcount && 0 <= $vindex && $vindex < $this->_vcount) {
|
||||||
|
// create syllable of form LV
|
||||||
|
$last = (int) $this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount;
|
||||||
|
$result[(count($result) - 1)] = $last; // reset last
|
||||||
|
continue; // discard char
|
||||||
|
}
|
||||||
|
// if neither case was true, just add the character
|
||||||
|
$last = $char;
|
||||||
|
$result[] = $char;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the combining class of a certain wide char
|
||||||
|
* @param integer Wide char to check (32bit integer)
|
||||||
|
* @return integer Combining class if found, else 0
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _get_combining_class($char)
|
||||||
|
{
|
||||||
|
return isset($this->NP['norm_combcls'][$char]) ? $this->NP['norm_combcls'][$char] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apllies the cannonical ordering of a decomposed UCS4 sequence
|
||||||
|
* @param array Decomposed UCS4 sequence
|
||||||
|
* @return array Ordered USC4 sequence
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _apply_cannonical_ordering($input)
|
||||||
|
{
|
||||||
|
$swap = true;
|
||||||
|
$size = count($input);
|
||||||
|
while ($swap) {
|
||||||
|
$swap = false;
|
||||||
|
$last = $this->_get_combining_class(intval($input[0]));
|
||||||
|
for ($i = 0; $i < $size-1; ++$i) {
|
||||||
|
$next = $this->_get_combining_class(intval($input[$i+1]));
|
||||||
|
if ($next != 0 && $last > $next) {
|
||||||
|
// Move item leftward until it fits
|
||||||
|
for ($j = $i + 1; $j > 0; --$j) {
|
||||||
|
if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break;
|
||||||
|
$t = intval($input[$j]);
|
||||||
|
$input[$j] = intval($input[$j-1]);
|
||||||
|
$input[$j-1] = $t;
|
||||||
|
$swap = true;
|
||||||
|
}
|
||||||
|
// Reentering the loop looking at the old character again
|
||||||
|
$next = $last;
|
||||||
|
}
|
||||||
|
$last = $next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do composition of a sequence of starter and non-starter
|
||||||
|
* @param array UCS4 Decomposed sequence
|
||||||
|
* @return array Ordered USC4 sequence
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _combine($input)
|
||||||
|
{
|
||||||
|
$inp_len = count($input);
|
||||||
|
foreach ($this->NP['replacemaps'] as $np_src => $np_target) {
|
||||||
|
if ($np_target[0] != $input[0]) continue;
|
||||||
|
if (count($np_target) != $inp_len) continue;
|
||||||
|
$hit = false;
|
||||||
|
foreach ($input as $k2 => $v2) {
|
||||||
|
if ($v2 == $np_target[$k2]) {
|
||||||
|
$hit = true;
|
||||||
|
} else {
|
||||||
|
$hit = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($hit) return $np_src;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This converts an UTF-8 encoded string to its UCS-4 representation
|
||||||
|
* By talking about UCS-4 "strings" we mean arrays of 32bit integers representing
|
||||||
|
* each of the "chars". This is due to PHP not being able to handle strings with
|
||||||
|
* bit depth different from 8. This apllies to the reverse method _ucs4_to_utf8(), too.
|
||||||
|
* The following UTF-8 encodings are supported:
|
||||||
|
* bytes bits representation
|
||||||
|
* 1 7 0xxxxxxx
|
||||||
|
* 2 11 110xxxxx 10xxxxxx
|
||||||
|
* 3 16 1110xxxx 10xxxxxx 10xxxxxx
|
||||||
|
* 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
|
* 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
|
* 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
|
* Each x represents a bit that can be used to store character data.
|
||||||
|
* The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _utf8_to_ucs4($input)
|
||||||
|
{
|
||||||
|
$output = array();
|
||||||
|
$out_len = 0;
|
||||||
|
$inp_len = strlen($input);
|
||||||
|
$mode = 'next';
|
||||||
|
$test = 'none';
|
||||||
|
for ($k = 0; $k < $inp_len; ++$k) {
|
||||||
|
$v = ord($input{$k}); // Extract byte from input string
|
||||||
|
|
||||||
|
if ($v < 128) { // We found an ASCII char - put into stirng as is
|
||||||
|
$output[$out_len] = $v;
|
||||||
|
++$out_len;
|
||||||
|
if ('add' == $mode) {
|
||||||
|
$this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char
|
||||||
|
$start_byte = $v;
|
||||||
|
$mode = 'add';
|
||||||
|
$test = 'range';
|
||||||
|
if ($v >> 5 == 6) { // &110xxxxx 10xxxxx
|
||||||
|
$next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left
|
||||||
|
$v = ($v - 192) << 6;
|
||||||
|
} elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx
|
||||||
|
$next_byte = 1;
|
||||||
|
$v = ($v - 224) << 12;
|
||||||
|
} elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
|
$next_byte = 2;
|
||||||
|
$v = ($v - 240) << 18;
|
||||||
|
} elseif ($v >> 2 == 62) { // &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
|
$next_byte = 3;
|
||||||
|
$v = ($v - 248) << 24;
|
||||||
|
} elseif ($v >> 1 == 126) { // &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
|
$next_byte = 4;
|
||||||
|
$v = ($v - 252) << 30;
|
||||||
|
} else {
|
||||||
|
$this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ('add' == $mode) {
|
||||||
|
$output[$out_len] = (int) $v;
|
||||||
|
++$out_len;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ('add' == $mode) {
|
||||||
|
if (!$this->_allow_overlong && $test == 'range') {
|
||||||
|
$test = 'none';
|
||||||
|
if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
|
||||||
|
$this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx
|
||||||
|
$v = ($v - 128) << ($next_byte * 6);
|
||||||
|
$output[($out_len - 1)] += $v;
|
||||||
|
--$next_byte;
|
||||||
|
} else {
|
||||||
|
$this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($next_byte < 0) {
|
||||||
|
$mode = 'next';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // for
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert UCS-4 string into UTF-8 string
|
||||||
|
* See _utf8_to_ucs4() for details
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _ucs4_to_utf8($input)
|
||||||
|
{
|
||||||
|
$output = '';
|
||||||
|
$k = 0;
|
||||||
|
foreach ($input as $v) {
|
||||||
|
++$k;
|
||||||
|
// $v = ord($v);
|
||||||
|
if ($v < 128) { // 7bit are transferred literally
|
||||||
|
$output .= chr($v);
|
||||||
|
} elseif ($v < (1 << 11)) { // 2 bytes
|
||||||
|
$output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
|
||||||
|
} elseif ($v < (1 << 16)) { // 3 bytes
|
||||||
|
$output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
|
||||||
|
} elseif ($v < (1 << 21)) { // 4 bytes
|
||||||
|
$output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63))
|
||||||
|
. chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
|
||||||
|
} elseif ($v < (1 << 26)) { // 5 bytes
|
||||||
|
$output .= chr(248 + ($v >> 24)) . chr(128 + (($v >> 18) & 63))
|
||||||
|
. chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63))
|
||||||
|
. chr(128 + ($v & 63));
|
||||||
|
} elseif ($v < (1 << 31)) { // 6 bytes
|
||||||
|
$output .= chr(252 + ($v >> 30)) . chr(128 + (($v >> 24) & 63))
|
||||||
|
. chr(128 + (($v >> 18) & 63)) . chr(128 + (($v >> 12) & 63))
|
||||||
|
. chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
|
||||||
|
} else {
|
||||||
|
$this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert UCS-4 array into UCS-4 string
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _ucs4_to_ucs4_string($input)
|
||||||
|
{
|
||||||
|
$output = '';
|
||||||
|
// Take array values and split output to 4 bytes per value
|
||||||
|
// The bit mask is 255, which reads &11111111
|
||||||
|
foreach ($input as $v) {
|
||||||
|
$output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255);
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert UCS-4 strin into UCS-4 garray
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function _ucs4_string_to_ucs4($input)
|
||||||
|
{
|
||||||
|
$output = array();
|
||||||
|
$inp_len = strlen($input);
|
||||||
|
// Input length must be dividable by 4
|
||||||
|
if ($inp_len % 4) {
|
||||||
|
$this->_error('Input UCS4 string is broken');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Empty input - return empty output
|
||||||
|
if (!$inp_len) return $output;
|
||||||
|
for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
|
||||||
|
// Increment output position every 4 input bytes
|
||||||
|
if (!($i % 4)) {
|
||||||
|
$out_len++;
|
||||||
|
$output[$out_len] = 0;
|
||||||
|
}
|
||||||
|
$output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter class for aligning the API of idna_convert with that of Net_IDNA
|
||||||
|
* @author Matthias Sommerfeld <mso@phlylabs.de>
|
||||||
|
*/
|
||||||
|
class Net_IDNA_php4 extends idna_convert
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Sets a new option value. Available options and values:
|
||||||
|
* [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8,
|
||||||
|
* 'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8]
|
||||||
|
* [overlong - Unicode does not allow unnecessarily long encodings of chars,
|
||||||
|
* to allow this, set this parameter to true, else to false;
|
||||||
|
* default is false.]
|
||||||
|
* [strict - true: strict mode, good for registration purposes - Causes errors
|
||||||
|
* on failures; false: loose mode, ideal for "wildlife" applications
|
||||||
|
* by silently ignoring errors and returning the original input instead
|
||||||
|
*
|
||||||
|
* @param mixed Parameter to set (string: single parameter; array of Parameter => Value pairs)
|
||||||
|
* @param string Value to use (if parameter 1 is a string)
|
||||||
|
* @return boolean true on success, false otherwise
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function setParams($option, $param = false)
|
||||||
|
{
|
||||||
|
return $this->IC->set_parameters($option, $param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1 @@
|
||||||
|
The tests enclosed within come from RFC 3986 section 5.4 and all share the same base URL
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_1 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '../../../g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_10 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = './g/.';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_11 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g/./h';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g/h';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_12 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g/../h';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/h';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_13 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g;x=1/./y';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g;x=1/y';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_14 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g;x=1/../y';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/y';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_15 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g?y/./x';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g?y/./x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_16 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g?y/../x';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g?y/../x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_17 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g#s/./x';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g#s/./x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_18 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g#s/../x';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g#s/../x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_19 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'http:g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http:g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_2 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '../../../../g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_3 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '/./g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_4 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '/../g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_5 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g.';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_6 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '.g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/.g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_7 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g..';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g..';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_8 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '..g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/..g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Abnormal_9 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = './../g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986 extends SimplePie_Absolutize_Test
|
||||||
|
{
|
||||||
|
function SimplePie_Absolutize_Test_RFC3986()
|
||||||
|
{
|
||||||
|
// Ugly hack so it only applies to this and none of its children
|
||||||
|
if (!is_subclass_of($this, 'SimplePie_Absolutize_Test_RFC3986'))
|
||||||
|
{
|
||||||
|
$this->test = false;
|
||||||
|
}
|
||||||
|
// Only call the parent constructor if it exists
|
||||||
|
if (is_callable(array('parent', 'SimplePie_Absolutize_Test')))
|
||||||
|
{
|
||||||
|
parent::SimplePie_Absolutize_Test();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init()
|
||||||
|
{
|
||||||
|
$this->data['base'] = 'http://a/b/c/d;p?q';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_1 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g:h';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'g:h';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_10 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g#s';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g#s';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_11 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g?y#s';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g?y#s';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_12 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = ';x';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/;x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_13 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g;x';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g;x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_14 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g;x?y#s';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g;x?y#s';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_15 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/d;p?q';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_16 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_17 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = './';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_18 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '..';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_19 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '../';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_2 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_20 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '../g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_21 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '../..';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_22 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '../../';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_23 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '../../g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_3 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = './g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_4 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = 'g/';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/b/c/g/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class SimplePie_Absolutize_Test_RFC3986_Normal_5 extends SimplePie_Absolutize_Test_RFC3986
|
||||||
|
{
|
||||||
|
function data()
|
||||||
|
{
|
||||||
|
$this->data['relative'] = '/g';
|
||||||
|
}
|
||||||
|
|
||||||
|
function expected()
|
||||||
|
{
|
||||||
|
$this->expected = 'http://a/g';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|