Exemple #1
0
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
}
 public function processForm()
 {
     $comment = $this->comment;
     if ($_REQUEST['Comment:_parent_id'] && $_REQUEST['Comment:_parent_id'] != $this->parent->id) {
         $comment = new XNC_Comment(XN_Content::load(intval($_REQUEST['Comment:_parent_id'])));
     }
     if ($comment->willProcessForm()) {
         $comment->processForm();
         $cnt = XN_Content::load($comment->id);
         if ($this->storeparent) {
             $cnt->my->set('parentid', $this->parent->id);
         }
         $cnt->isPrivate = $this->private;
         $cnt->save();
     } elseif ($comment->lastError() != XNC_Comment::ERROR_FORM_ABSENT) {
         print $comment->lastError();
     }
 }
Exemple #3
0
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);
}
Exemple #4
0
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) {
        $key += count($sites);
    }
}
//end if-else random
$site = XN_Content::load(intval($sites[$key]));
header('Content-Type: text/plain;');
header('Location: ' . $site->my->url, TRUE, 303);
<?php

$dummy = XN_Content::create('Dummy', $_REQUEST['title'], $_REQUEST['description']);
$dummy->save();
echo 'Dummy ID# ' . $dummy->id . ' Created!';
Exemple #6
0
    echo '<input type="submit" name="submit" value="Update" />' . "\n";
    echo '</div></form>' . "\n";
}
//end if owner
if ($item->my->wrinks) {
    echo '<h3>In Wrinks</h3>' . "\n";
    echo '<ul>' . "\n";
    $wrinks = array_unique(explode(' ', $item->my->wrinks));
    foreach ($wrinks as $wrink) {
        $wrinkdata = XN_Content::load(intval($wrink));
        echo '<li>';
        echo '<a href="/wrink.php?id=' . $wrink . '" title="' . $wrinkdata->description . '">' . $wrinkdata->title . '</a>';
        echo '</li>' . "\n";
    }
    //end foreach sites
    echo '</ul>' . "\n";
}
//end if isset wrinks
if ($item->my->rejectedwrinks && XN_Profile::current()->screenName == $item->contributorName) {
    echo '<h3>Rejected From Wrinks</h3>' . "\n";
    echo '<ul>' . "\n";
    $reject = array_unique(explode(' ', $item->my->rejectedwrinks));
    foreach ($reject as $wrink) {
        $wrinkdata = XN_Content::load(intval($wrink));
        echo '<li><a href="/wrink.php?id=' . $wrink . '" title="' . $wrinkdata->description . '">' . $wrinkdata->title . '</a>';
        echo '</li>' . "\n";
    }
    //end foreach sites
    echo '</ul>' . "\n";
}
//end if rejectedwrinks
Exemple #7
0
 //if processing form
 if ($_POST['data']) {
     //if files was uploaded
     $data = XN_Request::uploadedFileContents($_POST['data']);
     //get uploaded file
 } else {
     $data = false;
 }
 //no uploaded file == no data (or do not change data)
 if (!$file && !$data) {
     //if no data and no original, die
     die('<b>You must upload a ' . $setup->my->single . '!</b>');
 }
 if (!$file) {
     //if no existing file, create new object
     $file = XN_Content::create($setup->my->single);
 }
 $file->title = $_REQUEST['title'];
 //set title
 $file->description = $_REQUEST['description'];
 //set description
 if ($data) {
     //if editing data
     $file->my->set('data', base64_encode($data));
 }
 //set data
 if ($_POST['data']) {
     //if uploading file
     $file->my->set('filename', $_POST['data']);
 }
 //set filename
Exemple #8
0
<?php

$site = XN_Content::load(intval($_REQUEST['id']));
XN_Content::delete($site);
?>
<h2>Blog Unlisted!</h2>
Exemple #9
0
   <?php 
} else {
    header('Content-Type: text/plain;');
    $item = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Website')->filter('my.url', '=', $_REQUEST['url']);
    $item = $item->execute();
    if (count($item)) {
        $item = $item[0];
    } else {
        $item = XN_Content::create('Website', $_REQUEST['title'], $_REQUEST['description'])->my->add('url', $_REQUEST['url'])->my->add('feedurl', $_REQUEST['feedurl']);
        $item->save();
        XN_Tag::checkTags($_REQUEST['tags']);
        XN_Tag::addTags($item, $_REQUEST['tags']);
    }
    //end if-else count item
    if ($_REQUEST['towrink']) {
        $wrink = XN_Content::load(intval($_REQUEST['towrink']));
        if (XN_Profile::current()->screenName == $wrink->contributorName) {
            if ($wrink->my->sites) {
                $wrink->my->sites .= ' ' . $item->id;
            } else {
                $wrink->my->add('sites', $item->id);
            }
            if ($item->my->wrinks) {
                $item->my->wrinks .= ' ' . $_REQUEST['towrink'];
            } else {
                $item->my->add('wrinks', $_REQUEST['towrink']);
            }
            $item->save();
        } else {
            if ($wrink->my->requestedsites) {
                $wrink->my->requestedsites .= ' ' . $item->id;
<?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'];
Exemple #11
0
<?php

if (!XN_Profile::current()->isLoggedIn()) {
    //Check if user is logged in and fail if they are not
    die('<b>Please log in</b>');
}
if (!$_REQUEST['id']) {
    die('<b>No ID Specified</b>');
}
$file = XN_Content::load(intval($_REQUEST['id']));
//load file by id from Content Store
if (XN_Profile::current()->screenName != $file->contributorName) {
    //if this user is not the object owner, die
    die('You do not have permission to edit this item');
}
if ($_REQUEST['_content']) {
    //save
    $file->my->set('data', base64_encode($_REQUEST['_content']));
    $file->save();
    echo '<h2>Saved</h2>';
}
//end if _content
?>
<h2>Edit File</h2>
<fieldset>
<form method="post" action="?id=<?php 
echo $_REQUEST['id'];
?>
" style="width:auto;"><dl>
   <dt style="float:none;clear:both;text-align:left;width:auto;">File Contents</dt>
   <dd style="clear:both;padding:0px;float:none;margin:0px;"><textarea name="_content" cols="100" rows="25"><?php 
Exemple #12
0
<?php

if (!XN_Profile::current()->isLoggedIn()) {
    die('<b>Please log in</b>');
}
if (!isset($_REQUEST['submit'])) {
    ?>
   <h2 class="pagetitle">Add Wrink</h2>
   <form method="get" action="addWrink.php"><div>
      <label for="title">Wrink title:</label> <input type="text" name="title" value="" /><br />
      <label for="description">Wrink description:</label> <input type="text" name="description" value="" /><br />
      <label for="tags">Wrink tags:</label> <input type="text" name="tags" value="" /><br />
      <input type="submit" name="submit" value="Add" />
   </div></form>
   <?php 
} else {
    header('Content-Type: text/plain;');
    $item = XN_Content::create('Wrink', $_REQUEST['title'], $_REQUEST['description'])->my->add('traffic', 0);
    $item->save();
    XN_Tag::checkTags($_REQUEST['tags']);
    XN_Tag::addTags($item, $_REQUEST['tags']);
    header('Location: http://' . $_SERVER['HTTP_HOST'] . '/wrink.php?id=' . $item->id, TRUE, 303);
}
//end if-else ! isset submit
Exemple #13
0
<?php

echo '<xn:head><title>' . XN_Application::load()->name . ' - Setup</title></xn:head>';
if (!XN_Profile::current()->isOwner()) {
    die('<b>Only Owner can do this</b>');
}
$setup = XN_Query::create('Content')->filter('owner', '=')->filter('type', 'eic', 'Setup');
$setup = $setup->execute();
if (count($setup)) {
    $setup = $setup[0];
} else {
    $setup = false;
}
if (isset($_REQUEST['submit'])) {
    if (!$setup) {
        $setup = XN_Content::create('Setup');
    }
    //update header
    $header = file_get_contents('xn_header.view');
    if ($setup->my->plural) {
        $header = str_replace('My ' . $setup->my->plural, 'My ' . $_REQUEST['plural'], $header);
        $header = str_replace('Get Multiple ' . $setup->my->plural, 'Get Multiple ' . $_REQUEST['plural'], $header);
    }
    //end if plural
    $header = str_replace('My Files', 'My ' . $_REQUEST['plural'], $header);
    if ($setup->my->single) {
        $header = str_replace('Add ' . $setup->my->single, 'Add ' . $_REQUEST['single'], $header);
    }
    $header = str_replace('Add File', 'Add ' . $_REQUEST['single'], $header);
    if ($setup->my->single && file_exists('xn_pivot.' . $setup->my->single . '.view')) {
        rename('xn_pivot.' . $setup->my->single . '.view', 'xn_pivot.' . $_REQUEST['single'] . '.view');
Exemple #14
0
<?php

require_once 'XNC/Ajax.php';
XNC_Ajax::startAjaxPage();
if (!$_REQUEST['id']) {
    die;
}
$group = XN_Content::load(intval($_REQUEST['id']));
$grouptags = explode(' ', $group->my->grouptags);
$_REQUEST['grouptag'] = str_replace(' ', '+', $_REQUEST['grouptag']);
if (isset($_REQUEST['edit-title'])) {
    $group->set('title', $_REQUEST['title']);
    $group->save();
    header('Content-Type: text/plain');
    if (isset($_REQUEST['form'])) {
        exit($_REQUEST['title']);
    }
    header('Location: ' . $_REQUEST['return_to'], TRUE, 303);
    exit;
}
//end if edit-title
if (isset($_REQUEST['edit-desc'])) {
    $group->set('description', $_REQUEST['desc']);
    $group->save();
    header('Content-Type: text/plain');
    if (isset($_REQUEST['form'])) {
        exit(nl2br($_REQUEST['desc']));
    }
    header('Location: ' . $_REQUEST['return_to'], TRUE, 303);
    exit;
}
Exemple #15
0
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;
    $record = array();
}
//end if-else id
Exemple #16
0
<?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'];
Exemple #17
0
<?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();
header('Content-Type: text/plain;');
header('Location: ' . $_REQUEST['url'], TRUE, 303);
Exemple #18
0
        echo '</li>' . "\n";
    }
    //end foreach sweeties
    echo '</ul>' . "\n";
}
//end if count sweeties
echo '<h3 id="comments" style="display:inline;margin:0px;padding:0px;">Comments</h3>' . "\n";
echo ' <a href="http://' . $_SERVER['HTTP_HOST'] . '/view.php?id=' . $file->id . '#comments" rel="comments">&raquo;</a> ' . "\n";
echo '<a href="http://' . $_SERVER['HTTP_HOST'] . '/commentRSS.php?xn_auth=no&amp;id=' . $file->id . '" rel="comments alternate"><img src="http://wrinks.ning.com/feedicon12x12.png" alt="[feed]" /></a><br />' . "\n";
require_once 'XNC/Comment.php';
require_once 'removeEvils.php';
$newComment = new XNC_Comment($file);
// Handle any form submission of adding a new comment
if ($newComment->willProcessForm()) {
    $newComment->processForm();
    $cnt = XN_Content::load($newComment->id);
    $cnt->my->set('parentid', $file->id);
    $cnt->isPrivate = false;
    $cnt->save();
} elseif ($newComment->lastError() != XNC_Comment::ERROR_FORM_ABSENT) {
    print $newComment->lastError();
}
// Display a list of comments belonging to a parent object
if ($file->my->content($newComment->referenceAttribute, true)) {
    echo '<ul class="xoxo comments">';
    foreach ($file->my->content($newComment->referenceAttribute, true) as $comment) {
        $data = new XNC_Comment($comment);
        ?>
<li id="<?php 
        echo 'c' . $data->id;
        ?>
Exemple #19
0
<?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>
Exemple #20
0
<?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>';
Exemple #21
0
     }
 } else {
     echo '{"wrinks":[';
 }
 foreach ($items as $id => $item) {
     if ($id > 0) {
         echo ',';
     }
     echo '{';
     echo '"title":"' . $item->title . '",';
     echo '"description":"' . $item->description . '",';
     echo '"user":"******",';
     echo '"traffic":"' . $item->my->traffic . '",';
     echo '"sites":[';
     foreach (explode(' ', $item->my->sites) as $id => $site) {
         $sitedata = XN_Content::load(intval($site));
         if ($id > 0) {
             echo ',';
         }
         echo '{';
         echo '"title":"' . $sitedata->title . '",';
         echo '"description":"' . $sitedata->description . '",';
         echo '"url":"' . $sitedata->my->url . '",';
         echo '"feedurl":"' . $sitedata->my->feedurl . '",';
         $tags = fetchTags($sitedata);
         if (count($tags)) {
             echo '"tags":["' . implode('","', $tags) . '"]';
         } else {
             echo '"tags":[]';
         }
         echo '}';
Exemple #22
0
        $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
?>
<h2>New Tag Group</h2>
<form method="get" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
"><dl>
<dt>Title</dt> <dd><input type="text" name="title" style="width:250px;" /></dd>
<dt>Description</dt> <dd><textarea style="width:250px;height:100px;" name="description">Describe and define this group of tags.</textarea></dd>
      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
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'] : '';
Exemple #24
0
//update wrink
$wrink = XN_Content::load(intval($_REQUEST['wrinkid']));
if (XN_Profile::current()->screenName != $wrink->contributorName) {
    die("<b>Only Wrink owner can reject sites!</b>");
}
$requestedsites = explode(' ', $wrink->my->requestedsites);
foreach ($requestedsites as $id => $site) {
    if ($site == $_REQUEST['siteid'] || !$site) {
        unset($requestedsites[$id]);
    }
}
//end foreach
$wrink->my->requestedsites = implode(' ', $requestedsites);
$wrink->save();
//update site
$site = XN_Content::load(intval($_REQUEST['siteid']));
if ($site->my->rejectedwrinks) {
    $site->my->rejectedwrinks .= ' ' . $_REQUEST['wrinkid'];
} else {
    $site->my->add('rejectedwrinks', $_REQUEST['wrinkid']);
}
if ($site->my->wrinks) {
    $wrinks = array_unique(explode(' ', $site->my->wrinks));
    foreach ($wrinks as $id => $wrink) {
        if ($wrink == $_REQUEST['wrinkid'] || !$wrink) {
            unset($wrinks[$id]);
        }
    }
    //end foreach
    $site->my->wrinks = implode(' ', $wrinks);
}
Exemple #25
0
function extComments($file)
{
    ?>

<xn:head>
<style type="text/css">
/* Comment Styles */
   .comments {
      list-style-type: none;
      margin-left: 0px;
      margin-top: 0.5em;
   }
   .comments li {
      display: block;
      margin-left: 0px;
      margin-bottom: 1em;
   }
   .comments dl {
      display: inline;
   }
   .comments dd {
      margin-left: 0px;
   }
   .comments dt {
      display: none;
   }
   .comments dd.author {
      display: inline;
      font-size: 1em;
   }
   .comments dd.content {
      display: block;
      margin-top: 0.5em;
   }
</style>
</xn:head>

<?php 
    $newComment = new XNC_Comment($file);
    // Handle any form submission of adding a new comment
    if ($newComment->willProcessForm()) {
        $newComment->processForm();
        $cnt = XN_Content::load($newComment->id);
        $cnt->my->set('parentid', $file->id);
        $cnt->isPrivate = false;
        $cnt->save();
    } elseif ($newComment->lastError() != XNC_Comment::ERROR_FORM_ABSENT) {
        print $newComment->lastError();
    }
    // Display a list of comments belonging to a parent object
    if ($file->my->content($newComment->referenceAttribute, true)) {
        echo '<ul class="xoxo comments">';
        foreach ($file->my->content($newComment->referenceAttribute, true) as $comment) {
            $data = new XNC_Comment($comment);
            ?>
<li id="<?php 
            echo 'c' . $data->id;
            ?>
">
   Posted on <a href="<?php 
            echo $_SERVER['SCRIPT_URI'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
            ?>
#<?php 
            echo 'c' . $data->id;
            ?>
" title="<?php 
            echo strtotime($data->createdDate);
            ?>
"><?php 
            echo date('Y-m-d H:i', strtotime($data->createdDate));
            ?>
</a>
   by <a href="http://<?php 
            echo $_SERVER['HTTP_HOST'];
            ?>
/?user=<?php 
            echo $data->contributorName;
            ?>
" class="author user"><?php 
            echo $data->contributorName;
            ?>
</a>
<dl>
   <dt>body</dt>
      <dd class="content"><?php 
            echo removeEvilTags(nl2br($data->description));
            ?>
</dd>
</dl>
</li>
      <?php 
        }
        //end foreach
        echo '</ul>';
    }
    //end if
    // Display the add a comment form
    if (XN_Profile::current()->isLoggedIn()) {
        ?>
<form id="commentForm" method="post" action="<?php 
        echo $_SERVER['SCRIPT_URI'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
        ?>
">
<input type="hidden" name="xnc_comment" value="xnc_comment" /><input type="hidden" name="Comment:_parent_id" value="<?php 
        echo $file->id;
        ?>
" />Comment: <br />
<textarea name="Comment:description" rows="5" cols="50"></textarea><br />
<input type="submit" name="submit" value="Save Comment" class="button"/><br />
</form>
<a href="http://cocomment.com/"><img src="http://cocomment.com/images/cocomment-integrated.gif" alt="coComment Integrated" /></a>
<script type="text/javascript">
  var blogTool              = "Ning App";
  var blogURL               = "http://<?php 
        echo $_SERVER['HTTP_HOST'];
        ?>
/";
  var blogTitle             = "<?php 
        echo addslashes(XN_Application::load()->name);
        ?>
";
  var postURL               = "<?php 
        echo $_SERVER['SCRIPT_URI'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
        ?>
";
  var postTitle             = "<?php 
        echo addslashes($file->title);
        ?>
";
  var commentTextFieldName  = "Comment:description";
  var commentButtonName     = "submit";
  var commentAuthorLoggedIn = true;
  var commentAuthor         = "<?php 
        echo XN_Profile::current()->screenName;
        ?>
";
  var commentFormID         = "commentForm";
  var cocomment_force       = false;

var cocoscript = document.createElement('script');
cocoscript.setAttribute('id', 'cocomment-fetchlet');
cocoscript.setAttribute('trackAllComments', 'true');
cocoscript.setAttribute('src', 'http://www.cocomment.com/js/enabler.js');
document.getElementsByTagName('head')[0].appendChild(cocoscript);

</script>
<?php 
    }
    ?>
</div>

<?php 
}