function is_junkblog($url, $strict = false) { $url = normalize_url($url); $query = XN_Query::create('Content')->filter('owner->relativeUrl', '=', 'someblogs')->filter('type', 'eic', 'Website')->filter('my.url', '=', $url); $items = $query->execute(); if (count($items)) { if ($strict === true && !$items[0]->my->verify) { return false; } return $items[0]; } //end if count items if ($strict) { return false; } $page = strip_tags(file_get_contents($url)); $stoplist = array('drunk', 'free links', 'sex', 'c**k', 'pussy', 'p**n', 'pr0n', 'pron', 'I went', 'I slept', 'slept with', 'my boss', 'loser', 'my cat', 'I love you', 'this update is'); foreach ($stoplist as $stop) { if (stristr($page, ' ' . $stop . ' ')) { $dummy = file_get_contents('http://someblogs.ning.com/add.php?xn_auth=no&url=' . urlencode($url)); return $strict ? false : true; } //end if stop } //end foreach stoplist return false; }
function pollpage($url) { $XMLdata = getTidy($url); $obj = new OutlineFromXOXO($XMLdata, array('classes' => array('xoxo', 'posts'))); $struct = $obj->toArray(); if (!count($struct)) { $obj = new OutlineFromHATOM($XMLdata); $struct = $obj->toArray(); } if (!count($struct)) { $obj = new OutlineFromXOXO($XMLdata, array('classes' => array())); $struct = $obj->toArray(); } //header('Content-Type: text/plain'); //var_dump($struct);exit; foreach ($struct as $structid => $node) { if (!is_numeric($structid)) { continue; } $postTitle = $node['text']; $postURL = $node['href']; foreach ($node as $id => $comment) { if (!is_numeric($id)) { continue; } $comment = array_change_key_case($comment); $url = $comment['href']; if ($url[0] == '#') { $url = $postURL . $url; } $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Comment')->filter('my.url', '=', $url); $items = $query->execute(); if (count($items) > 0) { continue; } if ($comment['author']) { $theParser = xml_parser_create(); xml_parse_into_struct($theParser, $comment['author'], $tmp); xml_parser_free($theParser); $authorname = $tmp[0]['value']; $authorurl = $tmp[0]['attributes']['HREF']; } else { $authorname = $comment['text#1']; $authorurl = $comment['href#1']; } //end if-else comment[author] $time = (int) ($comment['title'] / 1000000000) < 100 ? (int) $comment['title'] : (int) ($comment['title'] / 1000000000); $obj = XN_Content::create('Comment')->my->add('content', $comment['body'])->my->add('url', $url)->my->add('authorname', $authorname)->my->add('authorurl', $authorurl)->my->add('time', $time)->my->add('posturl', $postURL)->my->add('posturl2', str_replace('-', '', str_replace('/', ' ', $postURL)))->my->add('posttitle', $postTitle); $obj->saveAnonymous(); } //end foreach node } //end foreach struct }
function fetchTagsWithCount($content) { try { $results = XN_Query::create('Tag')->filter('content', '=', $content)->order('count(value)', 'desc')->order('value', 'asc'); $results = $results->execute(); // Put all the tags into an array $tagcounts = getTagCount(); $tagArray = array(); foreach ($results as $tag) { $tagArray[$tag->value] = $tagcounts[$tag->value]; } } catch (XN_Exception $e) { echo 'Whoops! Something\'s Gone Wrong'; echo 'There was an error in this page and I can\'t fetch the list of tags. The error is: ' . $e->getMessage(); } return $tagArray; }
function getSweeties($id) { $file = XN_Content::load(intval($id)); $bag = XN_Query::create('Content')->filter('owner', '=', XN_Application::load('sweeties'))->filter('type', 'eic', 'SweetieBag')->filter('contributorName', 'eic', $file->contributorName); $bag = $bag->execute(); $bag = $bag[0]; $rtrn = array(); $sweeties = unserialize($bag->my->rec_trans); if ($sweeties) { foreach ($sweeties as $sweetie) { if ($sweetie['recip_obj'] == $id) { $rtrn[] = $sweetie; } } //end foreach sweeties } //end if sweeties return array_reverse($rtrn); }
<?php $pathvars = array_reverse(explode('/', $_SERVER['SCRIPT_URI'])); if (!$pathvars[0]) { $pathvars[0] = $pathvars[1]; $pathvars[1] = $pathvars[2]; } $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'TagGroup')->alwaysReturnTotalCount(true); if ($pathvars[1] == 'tag' || $pathvars[0] == 'tag') { if (!$pathvars[0] || $pathvars[0] == 'tag') { require_once 'tagFunctions.php'; require_once 'XNC/HTML.php'; echo '<xn:head><title>tagging / tag</title></xn:head>'; echo '<h2>Tags</h2>'; echo XNC_HTML::buildMap(getTagCount(), 'index.php/tag/%s', '', true, 60, 300); exit; } //end if ! pathvars[0] if (!isset($_REQUEST['auto']) && !$_REQUEST['format']) { echo '<xn:head><title>tagging / tag / ' . htmlspecialchars($pathvars[0]) . '</title></xn:head>'; echo '<h2>Tag Groups With Related Tag of ' . htmlspecialchars($pathvars[0]) . '</h2>'; } //end if ! isset auto $_REQUEST['tag'] = $pathvars[0]; } //end if pathvars[1] == tag if ($pathvars[1] == 'tags') { if (!isset($_REQUEST['auto']) && !$_REQUEST['format']) { echo '<xn:head><title>tagging / tags / ' . htmlspecialchars($pathvars[0]) . '</title></xn:head>'; echo '<h2>Tag Groups With GroupTag of ' . htmlspecialchars($pathvars[0]) . '</h2>'; }
require_once 'tagFunctions.php'; require_once 'XNC/HTML.php'; $setup = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Setup'); $setup = $setup->execute(); if (count($setup)) { $setup = $setup[0]; } else { $setup = false; } if (!$setup) { header('Content-Type: text/plain;'); header('Location: http://' . $_SERVER['HTTP_HOST'] . '/setup.php', true, 303); exit; } //end if ! setup $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', $setup->my->single)->alwaysReturnTotalCount(true); //sort by time $query->order('createdDate', 'desc', XN_Attribute::NUMBER); if ($_REQUEST['user']) { $query->filter('contributorName', '=', $_REQUEST['user']); } if ($_REQUEST['tag']) { $_REQUEST['tag'] = str_replace(' ', '+', $_REQUEST['tag']); foreach (explode('+', $_REQUEST['tag']) as $tag) { $query->filter('tag.value', 'eic', $tag); } } //end if tag if ($_REQUEST['q']) { $query->filter('description', 'likeic', $_REQUEST['q']); }
<h2>Get Setup Feed</h2> <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?> "><div> del.icio.us username: <input type="text" name="usr" /><br /> tag filter (optional): <input type="text" name="tag" /><br /> <input type="hidden" name="xn_auth" value="no" /> <input type="submit" value="Go" /> </div></form> </div> <?php exit; } //end if ! usr $item = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'delusr')->filter('title', 'eic', $_REQUEST['usr']); $item = $item->execute(); if ($item && count($item)) { $item = $item[0]; } else { $item = XN_Content::create('delusr', $_REQUEST['usr']); } $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
<?php if (!$_REQUEST['content-type']) { $_REQUEST['content-type'] = 'text/html'; } header('Content-Type: ' . $_REQUEST['content-type'] . ';charset=utf-8'); $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'var')->filter('title', 'eic', $_REQUEST['var']); $items = $query->execute(); if ($items && count($items)) { $item = $items[0]; } else { $item = XN_Content::create('var', $_REQUEST['var']); } $_REQUEST['txt'] = str_replace('@var@', $item->description, $_REQUEST['txt']); echo $_REQUEST['txt'];
if (!$_REQUEST['url']) { header('Content-type: text/plain'); header('Location: http://xoxotools.ning.com/proxy/', true, 302); exit; } //end if ! url require 'normalize_url.php'; $_REQUEST['url'] = normalize_url(trim($_REQUEST['url'])); $domain = explode('/', $_REQUEST['url']); $domain = strtolower(str_replace('*', '', $domain[2])); $domain = explode('.', $domain); if (count($domain) > 2) { unset($domain[0]); } $domain = implode('.', $domain); $related = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'PageSetup')->filter('description', 'eic', $domain); $related = $related->execute(); $globs = array(); $unique = array(); $itself = array(); foreach ($related as $item) { if (strstr($item->title, '*')) { $globs[$item->title] = unserialize($item->my->microformats); } else { $unique[$item->title] = unserialize($item->my->microformats); } } //end foreach related if (in_array($_REQUEST['url'], array_keys($unique))) { $itself = $unique[$_REQUEST['url']]; } else {
<?php if (!XN_Profile::current()->isLoggedIn()) { die('<b>Please log in</b>'); } if ($_REQUEST['grouptags']) { if (!isset($_REQUEST['confirm'])) { $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'TagGroup')->filter('my.grouptags', 'likeic', strtolower($_REQUEST['grouptags'])); $items = $query->execute(); if (count($items)) { echo '<h2>Confirm Creation</h2> <p>The following items contain tags that appear to intersect with those of the group you are trying to create, please ensure that none of these groups is in any way synonymous with that which you are trying to create (See <a href="about.php#group-creation">About Group Creation</a> for more details).</p><br />'; echo '<ul>'; foreach ($items as $item) { echo '<li><a href="view.php?id=' . $item->id . '">' . $item->h('title') . '</a><br />' . substr($item->h('description'), 0, 90) . '...<br /><b>Group Tags:</b> ' . substr($item->my->h('grouptags'), 0, 60) . '...</li>'; } echo '</ul>'; echo '<form method="get" action="' . $_SERVER['PHP_SELF'] . '"> <input type="hidden" name="title" value="' . $_REQUEST['title'] . '" /> <input type="hidden" name="description" value="' . $_REQUEST['description'] . '" /> <input type="hidden" name="grouptags" value="' . strtolower($_REQUEST['grouptags']) . '" /> <input type="submit" name="confirm" value="Confirm Creation" /></form>'; exit; } //end if count items } //end if ! isset confirm $group = XN_Content::create('TagGroup', $_REQUEST['title'], $_REQUEST['description']); $group->my->set('grouptags', strtolower($_REQUEST['grouptags'])); $group->save(); $group->focus(); echo '<h2>Group ' . $_REQUEST['title'] . ' Added</h2>'; exit; } //end if grouptags ?>
<?php if (!$_REQUEST['id']) { die('<b>No ID Specified</b>'); } $content = XN_Content::load($_REQUEST['id']); if (XN_Profile::current()->screenName != $content->contributorName) { die('You do not have permission to delete this item'); } XN_Content::delete($content); $setup = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Setup'); $setup = $setup->execute(); $setup = $setup[0]; echo '<p>' . $setup->my->single . ' #' . $_REQUEST['id'] . ' Deleted</p>';
<?php require_once 'xn-app://someblogs/normalize_url.php'; $_REQUEST['url'] = normalize_url($_REQUEST['url']); $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Website')->filter('my.url', '=', $_REQUEST['url']); $items = $query->execute(); if (!count($items)) { $site = XN_Content::create('Website'); $site->my->set('url', $_REQUEST['url']); $site->my->set('verify', false); $site->saveAnonymous(); } //end if ! count items ?> <h2>Blog Added for Consideration</h2>
<?php require_once 'tagFunctions.php'; $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Website')->alwaysReturnTotalCount(true)->order('title'); if ($_REQUEST['user']) { $query->filter('contributorName', '=', $_REQUEST['user']); } if ($_REQUEST['tag']) { $query->filter('tag.value', 'eic', $_REQUEST['tag']); } // handle pagination $_REQUEST['maxitems'] = $_REQUEST['maxitems'] ? $_REQUEST['maxitems'] : 20; $start = isset($_GET['start']) && ctype_digit($_GET['start']) ? $_GET['start'] : 0; $end = $start + $_REQUEST['maxitems']; $query->begin($start)->end($end); $items = $query->execute(); // prepare pagination numbers for displaying result set info $total = $query->getTotalCount(); $from = $query->getResultFrom() != 0 ? 1 + $query->getResultFrom() : 1; $to = $query->getResultTo(); $title = 'Sites '; if ($_REQUEST['tag']) { $title .= ' in ' . $_REQUEST['tag']; } if ($_REQUEST['user']) { $title .= ' from ' . $_REQUEST['user']; } echo '<xn:head><title>Wrinks - ' . $title . '</title></xn:head>'; echo '<h2 class="pagetitle">'; echo $title; echo ' (' . $from . ' - ' . $to . ' of ' . $total . ')</h2>' . "\n";
<option value="xhtml">Output XHTML</option> <option value="rss20">Output RSS 2.0</option> <option value="js">Output JavaScript</option> <option value="json">Output JSON</option> </select><br /> If JSON output, output raw object? <input type="checkbox" name="raw" /><br /> Optional JSON callback function: <input type="text" name="callback" /><br /> <input type="submit" value="Syndicate" /> </div></form> <?php } else { pollpage($_GET['url']); if ($_GET['post']) { $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Comment')->filter('my.posturl', '=', $_GET['url'])->order('my.time', 'desc', XN_Attribute::NUMBER); } else { $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Comment')->filter('my.posturl2', 'likeic', str_replace('-', '', str_replace('/', ' ', $_GET['url'])))->order('my.time', 'desc', XN_Attribute::NUMBER); } //end if-else ! post $items = $query->execute(); $items = array_reverse(bytime_sort($items)); if ($_GET['max']) { $items = array_slice($items, 0, $_GET['max']); } $_GET['chars'] = $_GET['chars'] ? $_GET['chars'] : 25; if ($_GET['format'] == 'rss20') { header("Content-Type: application/xml"); ?> <rss version="2.0"> <channel> <title>Recent Comments @ <?php
exit; } //end if ! url if (!XN_Profile::current()->isLoggedIn()) { die('<h2>Please log in</h2>'); } require 'normalize_url.php'; $_REQUEST['url'] = normalize_url(trim($_REQUEST['url'])); $domain = explode('/', $_REQUEST['url']); $domain = strtolower(str_replace('*', '', $domain[2])); $domain = explode('.', $domain); if (count($domain) > 2) { unset($domain[0]); } $domain = implode('.', $domain); $itself = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'PageSetup')->filter('title', '=', $_REQUEST['url']); $itself = $itself->execute(); if (!$itself || !count($itself) || !$itself[0]) { $itself = XN_Content::create('PageSetup', $_REQUEST['url'], $domain); } else { $itself = $itself[0]; } $records = unserialize($itself->my->microformats); if (!$records || !is_array($records)) { $records = array(); } if ($_REQUEST['id']) { $record = $records[$_REQUEST['id']]; } else { $tmp = array_reverse(array_keys($records)); $_REQUEST['id'] = $tmp[0] + 1;
<?php $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Comment')->filter('id', '=', $_GET['id']); $items = $query->execute(); $item = $items[0]; XN_Content::delete($item); ?> Sucessfully deleted comment ID#<?php echo $_GET['id'];
<?php $_REQUEST['titledesc'] = $_REQUEST['titledesc'] ? urldecode($_REQUEST['titledesc']) : ' - '; $_REQUEST['as'] = $_REQUEST['as'] ? $_REQUEST['as'] : 'text'; $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'var')->order('title', 'asc'); if ($_REQUEST['match']) { $query->filter('title', 'likeic', $_REQUEST['match']); } $items = $query->execute(); $echoed = array(); foreach ($items as $item) { if ($_REQUEST['removematch']) { $item->title = str_replace($_REQUEST['match'], '', $item->title); } if ($_REQUEST['removecolon']) { $item->title = str_replace(':', '', $item->title); } $item->title = urldecode($_REQUEST['prefix']) . $item->title; if ($_REQUEST['content']) { $item->title .= $_REQUEST['titledesc'] . $item->description; } if (in_array($item->title, $echoed)) { XN_Content::delete($item); continue; } $echoed[] = $item->title; } //end foreach require 'php2yubnubarray.php'; echo php2yubnubarray($echoed, $_REQUEST['as'], $_REQUEST['callback']);
<?php if (!$_REQUEST['wrinkid']) { die('<b>ERROR : No Wrink specified</b>'); } $wrink = XN_Content::load(intval($_REQUEST['wrinkid'])); $wrink->my->traffic += 1; if ($wrink->my->traffictime < time() - 604800) { $wrink->my->traffic = 0; $wrink->my->traffictime = time(); } //end if traffictime over $wrink->save(); $sites = explode(' ', $wrink->my->sites); if (!$_REQUEST['siteid']) { $_REQUEST['siteid'] = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Website')->filter('my.url', '=', $_SERVER['HTTP_REFERER']); $_REQUEST['siteid'] = $_REQUEST['siteid']->execute(); $_REQUEST['siteid'] = $_REQUEST['siteid'][0]->id; } //end if ! siteid $key = array_search($_REQUEST['siteid'], $sites); $_REQUEST['move'] = $_REQUEST['move'] ? $_REQUEST['move'] : 1; if ($_REQUEST['move'] == 'random') { $key = 0; shuffle($sites); } else { $key += $_REQUEST['move']; if ($key > count($sites)) { $key -= count($sites); } if ($key < 0) {
<?php require_once 'tagFunctions.php'; $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Wrink')->alwaysReturnTotalCount(true)->order('my.traffic', 'desc', XN_Attribute::NUMBER); if ($_REQUEST['user']) { $query->filter('contributorName', '=', $_REQUEST['user']); } if ($_REQUEST['tag']) { $query->filter('tag.value', 'eic', $_REQUEST['tag']); } // handle pagination $_REQUEST['maxitems'] = $_REQUEST['maxitems'] ? $_REQUEST['maxitems'] : 20; $start = isset($_REQUEST['start']) && ctype_digit($_REQUEST['start']) ? $_REQUEST['start'] : 0; $end = $start + $_REQUEST['maxitems']; $query->begin($start)->end($end); $items = $query->execute(); // prepare pagination numbers for displaying result set info $total = $query->getTotalCount(); $from = $query->getResultFrom() != 0 ? 1 + $query->getResultFrom() : 1; $to = $query->getResultTo(); $title = 'Most Trafficked Wrinks'; if ($_REQUEST['tag']) { $title .= ' in ' . $_REQUEST['tag']; } if ($_REQUEST['user']) { $title .= ' from ' . $_REQUEST['user']; } if ($_REQUEST['format'] == 'rss20') { header('Content-Type: application/xml;charset=utf-8'); echo '<?xml version="1.0"?>' . "\n"; echo '<rss version="2.0">' . "\n";
echo ' <item>' . "\n"; echo ' <dc:identifier>' . htmlspecialchars($user) . '</dc:identifier>' . "\n"; echo ' <link>' . htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . '/user/' . urlencode($user)) . '</link>' . "\n"; echo ' <title>' . htmlspecialchars($user) . '</title>' . "\n"; echo ' <dc:created>2007-04-19T16:47:11+00:00</dc:created>' . "\n"; echo ' <mime>inode/directory</mime>' . "\n"; echo ' <permissions>444</permissions>' . "\n"; echo ' </item>' . "\n"; } //end foreach inode echo '</rdf:RDF>'; exit; } //end if ! count pathvars if (!is_numeric($pathvars[0])) { $query = XN_Query::create('Content')->filter('owner')->filter('type', 'eic', $setup->my->single)->filter('contributorName', 'eic', $pathvars[0]); $items = $query->execute(); header('Content-type: application/xml;'); header('X-Moz-Is-Feed: 1'); echo '<?xml version="1.0" ?>' . "\n"; echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n"; echo ' <channel/> <!-- may be removed, just forces firefox to render as feed -->' . "\n"; foreach ($items as $item) { echo ' <item>' . "\n"; echo ' <dc:identifier>' . $item->id . '</dc:identifier>' . "\n"; echo ' <link>' . htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . '/id/' . $item->id) . '</link>' . "\n"; echo ' <title>' . htmlspecialchars($item->title) . '</title>' . "\n"; echo ' <dc:created>' . $item->createdDate . '</dc:created>' . "\n"; echo ' <dc:modified>' . $item->updatedDate . '</dc:modified>' . "\n"; echo ' <mime>' . htmlspecialchars($setup->my->mime) . '</mime>' . "\n"; echo ' <size>' . strlen(base64_decode($item->my->data)) . '</size>' . "\n";
<dl> <dt>'Junk' Blog URL</dt> <dd><input type="text" name="url" /></dd> <dt></dt> <dd><input type="submit" value="Suggest" /></dd> </dl> </form> </fieldset> <fieldset> <form method="get" action="search.php"> <h2>Search 'Junk' Blogs</h2> <dl> <dt>'Junk' Blog URL</dt> <dd><input type="text" name="url" /></dd> <dt></dt> <dd><input type="submit" value="Search" /></dd> </dl> </form> </fieldset> <?php $query = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Website')->filter('my.verify', '=', false)->order('createdDate', 'desc', XN_Attribute::NUMBER); $items = $query->execute(); if (count($items)) { echo '<h2>Recently Suggested Blogs</h2>' . "\n"; echo '<ul>' . "\n"; foreach ($items as $item) { echo ' <li>' . $item->my->h('url') . ' - <a href="/verify.php?id=' . $item->id . '">Verify</a> - <a href="/unlist.php?id=' . $item->id . '">Unlist</a></li>' . "\n"; } //end foreach echo '</ul>' . "\n"; } //end if count items