curl_setopt($ch, CURLOPT_POSTFIELDS, $vars); curl_setopt($ch, CURLOPT_HEADER, TRUE); $page = curl_exec($ch); } if ($_REQUEST['url']) { $xanga_username = $_REQUEST['user']; $xanga_password = $_REQUEST['pass']; $_REQUEST['data'] = file_get_contents($_REQUEST['url']); if (stristr($_REQUEST['data'], '<rss')) { $struct = new OutlineFromXML($_REQUEST['data'], array('rootel' => 'rss', 'itemel' => 'channel>item', 'collapsels' => array('title', 'description'))); } if (!$struct && stristr($_REQUEST['data'], '<rdf')) { $struct = new OutlineFromXML($_REQUEST['data'], array('rootel' => 'rdf:RDF', 'itemel' => 'item', 'collapsels' => array('title', 'description'))); } if (!$struct && stristr($_REQUEST['data'], '<feed')) { $struct = new OutlineFromXML($_REQUEST['data'], array('rootel' => 'feed', 'itemel' => 'entry', 'collapsels' => array('title', 'content', 'summary'))); } if (is_a($struct->getField('channel'), 'Outline')) { $channel = $struct->getField('channel'); foreach ($channel->getFields() as $name => $val) { $struct->addField($name, $val); } $struct->unsetField('channel'); } //end if channel $tmp = $struct->getNode(0); if (!$tmp->getField('link')) { foreach ($struct->getNodes() as $id => $nodes) { foreach ($nodes->getNodes() as $node) { if ($node->getField('rel') == 'alternate') { $struct->_subnodes[$id]->setField('link', $node->getField('href'));
$item->isPrivate = true; //ensure privacy if ($_REQUEST['p']) { $item->description = str_rot13($_REQUEST['p']); $item->save(); echo '<h2>Setup Successful!</h2>'; exit; } //end if p require_once 'xn-app://xoxotools/std_rss_out.php'; require_once 'xn-app://xoxotools/OutlineClasses/OutlineFromXML.php'; $_REQUEST['usr'] = $item->title; $_REQUEST['p'] = str_rot13($item->description); $_REQUEST['tag'] = $_REQUEST['tag'] ? '?tag=' . $_REQUEST['tag'] : ''; $apiget = file_get_contents('https://' . $_REQUEST['usr'] . ':' . $_REQUEST['p'] . '@api.del.icio.us/v1/posts/all' . $_REQUEST['tag']); $apiget = new OutlineFromXML($apiget); $out = array(); $out['title'] = 'del.icio.us / ' . $apiget->getField('user'); $out['description'] = 'RSS feed of ALL posts.'; $out['link'] = 'http://del.icio.us/' . $apiget->getField('user'); $out['dc:creator'] = $apiget->getField('user'); $out['pubDate'] = strtotime($apiget->getField('update')); $out['items'] = array(); foreach ($apiget->getNodes() as $item) { $outi = array(); $outi['title'] = $item->getField('description'); $outi['description'] = $item->getField('extended'); $outi['link'] = $item->getField('href'); $outi['guid'] = $item->getField('hash'); $outi['dc:creator'] = $out['dc:creator']; $outi['comments'] = 'http://del.icio.us/url/' . $item->getField('hash');
function __construct($data = '', $options = array()) { $theParser = xml_parser_create(); if (!xml_parse_into_struct($theParser, $data, $vals)) { $errorcode = xml_get_error_code($theParser); if ($errorcode != XML_ERROR_NONE && $errorcode != 27) { $this->_errorcode = $errorcode; } } //end if ! parse xml_parser_free($theParser); $flattento = ''; $flattendat = ''; $flattentag = ''; $flattenattr = array(); $subflatten = 0; $options['rootel'] = $options['rootel'] ? strtoupper($options['rootel']) : ''; $options['itemel'] = $options['itemel'] ? strtolower($options['itemel']) : ''; $options['collapsels'] = $options['collapsels'] ? $options['collapsels'] : array(); foreach ($vals as $el) { if (!$options['rootel']) { $options['rootel'] = $el['tag']; } $isopen = $el['type'] == 'open' || $el['type'] == 'complete'; //for readability $isclose = $el['type'] == 'close' || $el['type'] == 'complete'; if ($options['rootel'] == $el['tag'] && $isclose) { continue; } if ($flattento) { //if flattening tags if ($isopen && $flattentag == $el['tag']) { $subflatten++; } if ($isclose && $flattentag == $el['tag']) { if ($subflatten) { $subflatten--; } else { if (!in_array($flattento, $options['collapsels'])) { $flattendat = '<OutlineFromXML>' . $flattendat . '</OutlineFromXML>'; $tmp = explode('>', $options['itemel']); if ($tmp[1]) { $flattendat = new OutlineFromXML($flattendat, array('rootel' => 'OutlineFromXML', 'itemel' => $tmp[1], 'collapsels' => $options['collapsels'])); } else { $flattendat = new OutlineFromXML($flattendat, array('rootel' => 'OutlineFromXML', 'itemel' => $options['itemel'], 'collapsels' => $options['collapsels'])); } foreach ($flattenattr as $name => $val) { $flattendat->addField($name, $val); } } //end if ! in_array if (!$this->getField($flattento)) { $this->addField($flattento, $flattendat); } else { $oldfield = $this->getField(strtolower($el['tag'])); if (!is_a($oldfield, 'Outline')) { $oldfield = new Outline(array(array('text' => $oldfield))); } if (count($oldfield->getFields())) { $oldfield = new Outline(array($oldfield)); } if (!is_a($flattendat, 'Outline')) { $flattendat = new Outline(array(array('text' => $flattendat))); } $oldfield->addNode($flattendat); $this->setField(strtolower($el['tag']), $oldfield); } //end if-else ! getField $flattendat = ''; $flattentag = ''; $subflatten = 0; $flattento = ''; $flattenattr = array(); continue; } //end if-else subflatten } //end if isclose && $emptytag = false; //assume not an empty tag if ($isopen) { //if opening tag $flattendat .= '<' . strtolower($el['tag']); //add open tag if ($el['attributes']) { //if attributes foreach ($el['attributes'] as $id => $val) { //loop through and add $flattendat .= ' ' . strtolower($id) . '="' . htmlspecialchars($val) . '"'; } //end foreach } //end if attributes $emptytag = $el['type'] == 'complete' && !$el['value']; //is emptytag? $flattendat .= $emptytag ? ' />' : '>'; //end tag if ($el['value']) { $flattendat .= htmlspecialchars($el['value']); } //add contents, if any } //end if isopen if ($el['type'] == 'cdata') { //if cdata $flattendat .= htmlspecialchars($el['value']); //add data } //end if cdata if ($isclose) { //if closing tag if (!$emptytag) { $flattendat .= '</' . strtolower($el['tag']) . '>'; } //if not emptytag, write out end tag } //end if isclose continue; } //end if flattento if ($el['type'] == 'complete') { if (!in_array(strtolower($el['tag']), $options['collapsels'])) { if ($el['attributes']) { if ($el['value']) { $el['value'] = new Outline(array('text' => $el['value'])); } else { $el['value'] = new Outline(); } foreach ($el['attributes'] as $id => $val) { $el['value']->addField(strtolower($id), $val); } //end foreach attributes } //end if attributes } //end if ! collapsels if (!$this->getField(strtolower($el['tag']))) { $this->addField(strtolower($el['tag']), $el['value']); } else { $oldfield = $this->getField(strtolower($el['tag'])); if (!is_a($oldfield, 'Outline')) { $oldfield = new Outline(array(array('text' => $oldfield))); } if (count($oldfield->getFields())) { $oldfield = new Outline(array($oldfield)); } if (!is_a($el['value'], 'Outline')) { $el['value'] = new Outline(array('text' => $el['value'])); } $oldfield->addNode($el['value']); $this->setField(strtolower($el['tag']), $oldfield); } //end if-else getField continue; } //end if type == complete if ($el['type'] == 'cdata') { if ($options['rootel'] == 'OUTLINEFROMXML') { $el['tag'] = 'TEXT'; } if (!$this->getField(strtolower($el['tag']))) { if (trim($el['value'])) { $this->addField(strtolower($el['tag']), $el['value']); } } else { $this->setField(strtolower($el['tag']), $this->getField(strtolower($el['tag'])) . $el['value']); } continue; } //end if type == complete if ($el['type'] == 'open') { if ($options['rootel'] == $el['tag']) { if ($options['rootel'] == 'OUTLINEFROMXML') { $el['tag'] = 'TEXT'; } if ($el['attributes']) { foreach ($el['attributes'] as $id => $val) { $this->addField(strtolower($id), $val); } } //end if attributes if (trim($el['value'])) { $this->addField(strtolower($el['tag']), $el['value']); } continue; } //end if rootel if ($el['attributes']) { foreach ($el['attributes'] as $id => $val) { $flattenattr[strtolower($id)] = $val; } } //end if attributes $flattento = strtolower($el['tag']); $flattentag = $el['tag']; $flattendat = $el['value']; continue; } //end if open } //end foreach vals $tmp = explode('>', $options['itemel']); if ($options['itemel'] !== false) { $this->nodesFromField($tmp[0]); } }
</select><br /> Max Items: <input type="text" name="max" /><br /> <?php exit; } //end if ! url $_REQUEST['format'] = $_REQUEST['format'] ? $_REQUEST['format'] : 'xhtml'; $_REQUEST['max'] = $_REQUEST['max'] ? $_REQUEST['max'] : 5; if (substr($_REQUEST['url'], -5, 5) == 'basic') { $_REQUEST['url'] = substr($_REQUEST['url'], 0, strlen($_REQUEST['url']) - 5) . 'full'; } //end if basic $xmldata = file_get_contents($_REQUEST['url']); preg_match('/\\/feeds\\/(.*?)\\//', $_REQUEST['url'], $theid); $theid = $theid[1]; $obj = new OutlineFromXML($xmldata); $feed = array(); $feed['title'] = $obj->getField('title')->getField('text'); $feed['description'] = $obj->getField('subtitle')->getField('text'); $feed['link'] = 'http://www.google.com/calendar/embed?src=' . urlencode($theid); $feed['items'] = array(); $nodes = $obj->getField('entry')->getNodes(); foreach ($nodes as $event) { $starttime = false; if ($event->getField('gd:when')) { $starttime = $event->getField('gd:when')->getField('starttime'); } if (!$starttime) { continue; } if (strtotime($starttime) < time()) {