// load admin
$q = $db->queryC("SELECT * FROM User,UserInfo WHERE User.userid=UserInfo.userid AND isAdmin=1 LIMIT 1;");
if ($q !== false) {
    $ui = $db->readQ($q);
    $ui->u->name = $ui->name;
    $fData = new stdClass();
    $fData->body = '';
    $fData->tags = '';
    $fData->videoEmbed = '';
    $fData->isFeatureCandidate = 0;
    $fData->mediatype = 'text';
    $fData->url = mysql_real_escape_string('http://www.wired.com/vanish/2009/09/how-evan-ratliff-was-caught/');
    $fData->imageUrl = mysql_real_escape_string('http://www.wired.com/vanish/wp-content/uploads/2009/09/evanbald.jpg');
    $fData->title = mysql_real_escape_string('How Evan Ratliff Was Caught');
    $fData->caption = mysql_real_escape_string('Naked Pizza snagged Evan. But the legwork was done by Jeff Reifman, who was using twitter under @vanishteam. He has just put up an <a href="http://blog.newscloud.com/2009/09/how-we-caught-evan-ratliff.html">amazing post</a> detailing exactly what he did and how he did it. The post should be read in full.');
    $siteContentId = $cObj->createStoryContent($ui, $fData);
    // Add featured story
    $q = $db->delete("FeaturedTemplate");
    $sql = sprintf("REPLACE INTO FeaturedTemplate SET id = 1, template = '%s', story_1_id = %s", 'template_1', $siteContentId);
    $q = $db->query($sql);
    $db->query("UPDATE Content set isFeatured = 0 WHERE isFeatured = 1");
    $db->query("UPDATE Content set isFeatured = 1 WHERE siteContentId = {$siteContentId}");
    // clear out the cache of the home top stories
    require_once PATH_CORE . '/classes/template.class.php';
    $templateObj = new template($db);
    $templateObj->resetCache('home_feature');
    $fData->url = mysql_real_escape_string('http://blog.newscloud.com/2009/09/research-findings-released-engaging-youth-in-social-media-is-facebook-the-new-media-frontier-.html');
    $fData->imageUrl = mysql_real_escape_string('http://farm4.static.flickr.com/3619/3571720938_e30c9d4ab3.jpg');
    $fData->title = mysql_real_escape_string('Research Findings Released: Engaging Youth in Social Media - Is Facebook the New Media Frontier?');
    $fData->caption = mysql_real_escape_string('Counter to the decline in young people’s (print‐based) reading for pleasure and traditional media consumption is a noted increase in out‐of‐school online reading and writing through online fan fiction and social network sites. Yet, according to the Pew research institute, over one third of people under 25 get no news on a daily basis. However, teens spend many hours a week online (a recent British study said 31), particularly on Facebook ‐‐ the most‐trafficked social media site in the world. Facebook has more than 250 million active members.');
    $siteContentId = $cObj->createStoryContent($ui, $fData);
 function addStory($fData)
 {
     $this->setupLibraries();
     $status = array();
     $status['result'] = false;
     // now done through log -- can I assume the bookmarklet is being used on this page or what?
     $this->logObj->update($this->logObj->serialize(0, $this->session->userid, 'addBookmarkTool', 0, 0));
     // Clean up data
     //$fData->title = mysql_real_escape_string(stripslashes($fData->title));
     //$fData->caption = mysql_real_escape_string(stripslashes($fData->caption));
     // Check for duplicate item
     $duplicateStory = false;
     $dups = $this->db->queryC("SELECT siteContentId FROM Content WHERE url = '" . $fData->url . "' AND title = '" . $fData->title . "'");
     if ($dups) {
         $duplicateStory = true;
         $dupResult = $this->db->readQ($dups);
     } else {
         // create temporary content item, temp permalink
         require_once PATH_CORE . '/classes/content.class.php';
         $cObj = new content($this->db);
         $siteContentId = $cObj->createStoryContent($this->session, $fData);
     }
     // add to user's journal
     if ($siteContentId !== false && !$duplicateStory) {
         $status[siteContentId] = $siteContentId;
         // add to journal
         $logItem = $this->logObj->serialize(0, $this->session->userid, 'postStory', $siteContentId);
         $inLog = $this->logObj->update($logItem);
         if ($inLog) {
             $status['result'] = true;
             $status['msg'] = '';
             $logItem = $this->logObj->serialize(0, $this->session->userid, 'vote', $siteContentId);
             $inLog = $this->logObj->update($logItem);
         } else {
             $status['result'] = true;
             $status['msg'] = 'Story previously published';
         }
     } else {
         if ($duplicateStory) {
             $status['result'] = false;
             $status['msg'] = 'That story already exists. You can view it <a href="?p=read&cid=' . $dupResult->siteContentId . '">here</a>';
         } else {
             $status['result'] = false;
             $status['msg'] = 'We encountered a problem adding your story.';
         }
     }
     return $status;
 }