function makePost($mode) { require_once PATH_CORE . '/classes/log.class.php'; $logObj = new log($this->db); switch ($mode) { case 'wall': if (isset($_GET['self'])) { $idName = 'tbId_publishSelf'; } else { $idName = 'tbId_publish'; } require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus($this->db); $templateId = $ssObj->getState($idName); if (isset($_POST['app_params']['selId']) || $_POST['app_params']['pubType'] == 'invite') { if (isset($_POST['app_params']) && trim($_POST['app_params']['comment_text']) != '') { $msg = $_POST['app_params']['comment_text']; } $feedElements = $this->fetchFeedElements($_POST['app_params']['pubType'], $_POST['app_params']['selId'], $_POST['fb_sig_user']); $fbmlArray = array("content" => array("feed" => array("template_id" => $templateId, "template_data" => array("title" => $feedElements['title'], "headline" => $feedElements['title'], "storyLink" => $feedElements['storyLink'] . '?&referfbid=' . $_POST['fb_sig_user'], "url" => URL_CANVAS . '/?referfbid=' . $_POST['fb_sig_user'], "story" => $feedElements['story'] . '<br><br>' . $msg, "pubType" => $feedElements['pubType'], "appName" => SITE_TITLE, "refId" => $_POST['fb_sig_user'], "storyImage" => $feedElements['image'], "images" => array(array('src' => $feedElements['image'], 'href' => $feedElements['storyLink']))))), "method" => "publisher_getFeedStory"); $logObj->updateFromPublisher($logObj->serialize(0, $this->fetchUseridFromFbid($_POST['fb_sig_user']), 'publisherPost', $_POST['app_params']['selId'])); } else { $fbmlArray = array("errorCode" => 1, "errorTitle" => 'Wait!', "errorMessage" => 'You must select a story to post. Post cancelled.'); } $fbml = json_encode($fbmlArray); break; case 'email': if (isset($_POST['selId']) || $_POST['pubType'] == 'invite') { //fb_sig_user if ($_POST['pubType'] == 'invite') { $idForLog = 0; } else { $idForLog = $_POST['selId']; } $logObj->updateFromPublisher($logObj->serialize(0, $this->fetchUseridFromFbid($_POST['fb_sig_user']), 'messageAttach', $idForLog)); $feedElements = $this->fetchFeedElements($_POST['pubType'], $_POST['selId'], $_POST['fb_sig_user']); $fbml .= $feedElements['story']; if ($feedElements['storyLink'] != '') { $fbml .= '<br /><a href="' . $feedElements['storyLink'] . '?&referfbid=' . $_POST['fb_sig_user'] . '">Read More</a>'; } } else { $fbml = 'No content selected'; } break; } return $fbml; }
public function sitestatus() { global $init; require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus(); $siteStatus = $ssObj->getState('siteStatus'); if ($siteStatus == 'offline') { $siteStatus = 'online'; } else { $siteStatus = 'offline'; } $ssObj->setState('siteStatus', $siteStatus); $q = $ssObj->db->query("select email from User where isAdmin=1;"); while ($data = $ssObj->db->readQ($q)) { // Notify the admins mail($data->email, SITE_TITLE . ' Site Status: ' . $siteStatus, 'Someone just toggled ' . SITE_TITLE . ' site status. The site is now ' . $siteStatus, 'From: support@newscloud.com' . "\r\n"); } set_flash(array('notice' => "Site Status Toggled! New site status is {$siteStatus}")); redirect(url_for($this->name, 'index')); }
function runJob($job, $force = false) { $stopAfterJob = false; $startTime = microtime(true); $this->log($job->task . ', started ' . date('g:i a \\a\\t D M n, Y', $startTime)); if (!isset($_GET['test']) && !$force) { if ($job->isRunning == 1) { $this->db->log('Cron race condition: ' . $job->task . ' last start= ' . $job->lastStart); echo 'Warning: Cron Race condition<br />'; return; } else { $this->db->update("cronJobs", "isRunning=1,failureNoticeSent=0", "id={$job->id}"); } } //echo 'Task: '.$job->task."\n"; switch ($job->task) { default: // do nothing break; case 'updateUserLevels': require_once 'teamBackend.class.php'; $teamObj = new teamBackend($this->db); $teamObj->updateUserLevels(); break; case 'updateSiteChallenges': require_once 'teamBackend.class.php'; $teamObj = new teamBackend($this->db); $teamObj->updateSiteChallenges(); break; case 'updateCachedPointsAndChallenges': require_once 'teamBackend.class.php'; $teamObj = new teamBackend($this->db); $teamObj->updateCachedPointsAndChallenges(); break; case 'calcWeeklyLeaders': require_once 'teamBackend.class.php'; $teamObj = new teamBackend($this->db); $teamObj->calcWeeklyLeaders(); break; case 'updateUserLevels': require_once 'teamBackend.class.php'; $teamObj = new teamBackend($this->db); $teamObj->updateUserLevels(); case 'updateTwitter': // post top stories to twitter if (USE_TWITTER) { require_once 'twitter.class.php'; $twitterObj = new twitter_old($this->db); $twitterObj->postFeaturedStories(); $twitterObj->postNextTopStory(); } break; case 'microAccountsSync': // sync twitter service accounts for micro blog room - done daily if (defined('ENABLE_MICRO')) { require_once PATH_FACEBOOK . "/classes/micro.class.php"; $mObj = new micro(); $mObj->cleanRoom(); try { $mObj->resetFriends(false); } catch (Exception $e) { $this->log('Failed running ' . $job->task . ', Error: ' . $e); // reset this cron task manually because of twitter class trown exceptions $execTime = microtime(true) - $startTime; $this->db->update("cronJobs", "nextRun=date_sub(NOW(), INTERVAL (0-{$job->freqMinutes}) MINUTE),lastExecTime={$execTime},lastStart='" . date('Y-m-d H:i:s', $startTime) . "',isRunning=0", "id={$job->id}"); } } break; case 'microBlog': // post top stories to micro blog room if (defined('ENABLE_MICRO')) { require_once PATH_FACEBOOK . "/classes/micro.class.php"; $mObj = new micro(); try { $mObj->updateRoom(); } catch (Exception $e) { $this->log('Failed running ' . $job->task . ', Error: ' . $e); // reset this cron task manually because of twitter class trown exceptions $execTime = microtime(true) - $startTime; $this->db->update("cronJobs", "nextRun=date_sub(NOW(), INTERVAL (0-{$job->freqMinutes}) MINUTE),lastExecTime={$execTime},lastStart='" . date('Y-m-d H:i:s', $startTime) . "',isRunning=0", "id={$job->id}"); } } break; case 'updateCache': // build cached content for cover page layout require_once 'cache.class.php'; $cacheObj = new cache($this->db); $cacheObj->update(); break; case 'syncProperties': // sync Cloud properties with NewsCloud services require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); $props = $apiObj->syncProperties($this->cloudid); require_once 'systemStatus.class.php'; $ssObj = new systemStatus($this->db); $ssObj->setProperties($props['items'][0]); break; case 'syncAnnouncements': require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); $resp = $apiObj->syncAnnouncements($this->cloudid); if ($resp[result] !== false) { $itemlist = $resp[items]; require_once 'systemStatus.class.php'; $ssObj = new systemStatus($this->db); $ssObj->resetAnnouncements(); if (count($itemlist) > 0) { foreach ($itemlist as $data) { $ssObj->insertState('announcement', html_entity_decode($data['announce'])); } } } break; case 'syncNewswire': /* deprecated require_once ('apiCloud.class.php'); $apiObj=new apiCloud($this->db,$this->apiKey); $resp=$apiObj->syncNewswire($this->cloudid,$this->timeStrToUnixModB($job->lastItemTime)); $itemlist=$resp[items]; echo 'count: '.count($itemlist).'<br />'; if (count($itemlist)>0) { require_once('newswire.class.php'); $nwObj=new newswire($this->db); $lastItemTime=date('Y-m-d H:i:s',(time()-(6*30*24*3600))); // set to six months earlier foreach ($itemlist as $data) { $wire=$nwObj->serialize($data[title],$data[caption],$data[blogtitle],$data[webpage],$data[date],$data[blogid]); $id=$nwObj->add($wire); if ($data[date]>$lastItemTime) $lastItemTime=$data[date]; if ($id===false) echo 'skip '.$data[title].'<br />'; else echo 'adding '.$data[title].' id->'.$id.'<br />'; } $this->db->update("cronJobs","lastItemTime='$lastItemTime'","id=$job->id"); } */ break; case 'syncLog': require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); // request server ask for log $resp = $apiObj->requestSyncLog($this->cloudid, URL_HOME, $this->timeStrToUnixModB($job->lastStart)); // get result of log sync $logResult = $resp[items][0][log]; require_once PATH_CORE . "/classes/log.class.php"; $logObj = new log($this->db); // process results from sync operation $result = $logObj->receive($logResult); echo $result; break; case 'syncContent': // bring content from NewsCloud for this cloud to the remote site require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); $resp = $apiObj->syncContent($this->cloudid, $this->timeStrToUnixModB($job->lastItemTime)); $itemlist = $resp[items]; if (count($itemlist) > 0) { require_once 'content.class.php'; $cObj = new content($this->db); // to do : set this to actual time $lastItemTime = date('Y-m-d H:i:s', time() - 6 * 30 * 24 * 3600); // set to six months earlier foreach ($itemlist as $data) { echo 'Contentid' . $data[contentid] . '<br />'; // to do: before we can do this below, we need to be syncing ncuid when new users register // to do: get userid from ncUid // lookup userid in user table where ncuid=submitbyid // if not found make it 0 // to do: if external story, then check for local userid and set here $story = $cObj->serialize($data[contentid], $data[title], $data[description], '', $data[webpage], $data[permalink], $data[submitbyid], $data[submit_member], $data[userid], $data[date], $data[avgrank], 0, $data[imageid]); $id = $cObj->add($story); // update comments table with new contentids $cObj->updateCommentsTable($data[contentid], $id); if ($data[date] > $lastItemTime) { $lastItemTime = $data[date]; } echo 'story added' . $id . '<br><br/>'; } $this->db->update("cronJobs", "lastItemTime='{$lastItemTime}'", "id={$job->id}"); } break; case 'syncComments': // bring comments from stories in this cloud from NewsCloud over to remote site require_once 'content.class.php'; $cObj = new content($this->db); $idList = $cObj->fetchRecentStoryList(14, 99, true); $this->db->log('syncComments - stories to check for.', PATH_SYNCLOGFILE); $this->db->log($idList, PATH_SYNCLOGFILE); if ($idList != '') { require_once 'comments.class.php'; $commentsObj = new comments($this->db); require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); $result = $apiObj->syncComments($this->cloudid, $idList, $this->timeStrToUnixModB($job->lastItemTime)); $itemlist = $result[items]; $this->db->log($itemlist, PATH_SYNCLOGFILE); // update comment thread for each story if (count($itemlist) > 0) { $lastItemTime = date('Y-m-d H:i:s', time() - 6 * 30 * 24 * 3600); // set to six months earlier foreach ($itemlist as $data) { $temp = 'Bring over contentid' . $data[contentid] . ' Commentid' . $data[commentid] . '<br />'; // to do: if external story, then check for local userid and set here $comment = $commentsObj->remoteSerialize($data); if ($data[date] > $lastItemTime) { $lastItemTime = $data[date]; } $id = $commentsObj->add($comment); echo $temp . '<br />'; var_dump($comment); $this->db->log($temp, PATH_SYNCLOGFILE); $this->db->log($comment, PATH_SYNCLOGFILE); } } $this->db->update("cronJobs", "lastItemTime='{$lastItemTime}'", "id={$job->id}"); } break; case 'syncScores': require_once 'content.class.php'; $cObj = new content($this->db); $idList = $cObj->fetchRecentStoryList(14, 99, true); if ($idList != '') { require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); $resp = $apiObj->syncScores($this->cloudid, $idList, $this->timeStrToUnixModB($job->lastStart)); $itemlist = $resp[items]; //var_dump($resp); if (count($itemlist) > 0) { // update the score for each story with new votes foreach ($itemlist as $data) { $this->db->update("Content", "score={$data['score']}", "contentid={$data['contentid']}"); $temp = 'Set score of contentid:' . $data[contentid] . 'to ' . $data[score]; echo $temp . '<br />'; $this->db->log($temp, PATH_SYNCLOGFILE); } } } break; case 'syncResources': require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); require_once 'resources.class.php'; $resObj = new resources($this->db); $result = $apiObj->syncResources($this->cloudid); $resObj->sync(html_entity_decode($result[items][0][resources])); break; case 'updateSiteMap': $currentHour = date('G'); // 0 - 24 $currentDayOfWeek = date('w'); // day of week 0-6 $currentDayOfMonth = date('j'); // day of month 1-31 require_once 'siteMap.class.php'; $smObj = new siteMap($this->db); // do always - build the map for content from the last hour $smObj->buildMap('hourly'); // only do this as midnight if ($currentHour == 0) { // map to all the content from the last day $smObj->buildMap('daily'); } // only do this at 3 am on first day of week if ($currentDayOfWeek = 0 and $currentHour == 3) { // map to all the content from the last week, etc. $smObj->buildMap('weekly'); } // only do this at 2 am on first day of month if ($currentDayOfMonth == 1 and $currentHour == 2) { $smObj->buildMap('monthly'); } // call buildIndexMap after updating any individual child maps above // just the time stamps from each individual map file are updated in the indexmap // warning: if a individual map hasn't been built - the index map won't include a reference to it $smObj->buildIndexMap(); break; case 'fetchFeeds': // import stories from feeds require_once 'feed.class.php'; $feedObj = new feed($this->db); $feedObj->fetchBookmarks(); $feedObj->fetchFeeds(); $feedObj->fetchImages(); if ($feedObj->newStoryLoaded) { // update features } break; case 'logHourlyStats': require_once 'statistics.class.php'; $statsObj = new statistics($this->db); $statsObj->logHourlyStats(); break; case 'facebookMinifeed': require_once PATH_FACEBOOK . "/classes/app.class.php"; $app = new app(NULL, true); $facebook =& $app->loadFacebookLibrary(); require_once PATH_FACEBOOK . '/classes/miniFeeds.class.php'; $feedObj = new miniFeeds($this->db); $feedObj->loadFacebook($facebook); $feedObj->updateMiniFeeds(); break; case 'facebookProfileBoxes': require_once PATH_FACEBOOK . "/classes/app.class.php"; $app = new app(NULL, true); $facebook =& $app->loadFacebookLibrary(); require_once PATH_FACEBOOK . '/classes/profileBoxes.class.php'; $proObj = new profileBoxes($this->db); $proObj->loadFacebook($facebook); $proObj->updateProfileBoxes(); break; case 'facebookEmailEngine': // tbd break; case 'facebookAllocations': // check nightly facebook allocations $ssObj = new systemStatus($this->db); /* initialize the SMT Facebook appliation class, NO Facebook library */ require_once PATH_FACEBOOK . "/classes/app.class.php"; $app = new app(NULL, true); $facebook =& $app->loadFacebookLibrary(); $npd = $facebook->api_client->admin_getAllocation('notifications_per_day'); $ssObj->setState('notifications_per_day', $npd); $ssObj->setState('announcement_notifications_per_week', $facebook->api_client->admin_getAllocation('announcement_notifications_per_week')); $ssObj->setState('requests_per_day', $facebook->api_client->admin_getAllocation('requests_per_day')); $ssObj->setState('emails_per_day', $facebook->api_client->admin_getAllocation('emails_per_day')); break; case 'facebookSendNotifications': require_once PATH_FACEBOOK . "/classes/app.class.php"; $app = new app(NULL, true); $facebook =& $app->loadFacebookLibrary(); require_once PATH_FACEBOOK . "/classes/shareStories.class.php"; $ssObj = new shareStories($app); $ssObj->processNotifications(); break; case 'facebookSendPromos': /* not needed for now if (date('G')==0) { require_once PATH_FACEBOOK."/classes/promos.class.php"; $promoObj=new promos($this->db); $promoObj->send(); } */ break; case 'insertNewResearchData': require_once PATH_CORE . "/classes/researchRawSession.class.php"; require_once PATH_CORE . "/classes/researchRawExtLink.class.php"; require_once PATH_CORE . "/classes/researchSessionLength.class.php"; require_once PATH_CORE . "/classes/researchLogDump.class.php"; require_once PATH_CORE . "/classes/researchUserCollective.class.php"; $rawExtLinkTable = new RawExtLinkTable($this->db); $rawExtLinkTable->insertNewestData(); $rawSessionTable = new RawSessionTable($this->db); $rawSessionTable->insertNewestData(); $sessionLengthTable = new SessionLengthTable($this->db); $sessionLengthTable->insertNewestData(); $logDumpTable = new LogDumpTable($this->db); $logDumpTable->insertNewestData(); $userCollectiveTable = new UserCollectiveTable($this->db); $userCollectiveTable->assimilateUsers(); $stopAfterJob = true; break; case 'autoFeature': require_once PATH_CORE . '/classes/content.class.php'; $cObj = new content($this->db); $cObj->autoFeature(); break; case 'cleanup': require_once 'cleanup.class.php'; $cleanObj = new cleanup($this->db, 'daily'); break; // deprecated // deprecated case 'syncFeedList': require_once 'apiCloud.class.php'; $apiObj = new apiCloud($this->db, $this->apiKey); $result = $apiObj->syncFeedList($this->cloudid); require_once 'feed.class.php'; $feedObj = new feed($this->db); $feedObj->syncFeedList($result[items]); break; } $execTime = microtime(true) - $startTime; $this->log('...completed in ' . $execTime . ' seconds.'); $this->history[$this->cntJobs]['task'] = $job->task; $this->history[$this->cntJobs]['time'] = $execTime; $this->cntJobs += 1; $this->db->update("cronJobs", "nextRun=date_sub(NOW(), INTERVAL (0-{$job->freqMinutes}) MINUTE),lastExecTime={$execTime},lastStart='" . date('Y-m-d H:i:s', $startTime) . "',isRunning=0", "id={$job->id}"); if ($stopAfterJob) { exit; } }
function transmit($timestamp = 0, $limit = 25) { require_once 'utilities.class.php'; $utilObj = new utilities($this->db); // return serialized log info for synchronization $log = array(); /*** Transmit votes - req. ncUid and contentid ***/ $votes = array(); $x = 0; $page = 0; $q = $this->db->query("SELECT Log.*,User.ncUid,Content.contentid FROM Log,User,Content WHERE Log.itemid=Content.siteContentId AND contentid>0 AND User.ncUid<>0 AND Log.userid1=User.userid AND action='vote' AND status='pending' AND Content.isBlocked=0 AND User.isBlocked=0 ORDER BY Log.id DESC"); while ($data = $this->db->readQ($q)) { $votes[$x][contentid] = $data->contentid; $votes[$x][logid] = $data->id; // fetch newscloud id from userid1 $votes[$x][uid] = $data->ncUid; // $this->lookupUid($data->userid1); $x += 1; } $this->narrate('Transmitting votes'); $this->narrate($votes); $log['votes'] = $votes; /*** Transmit new users - req isVerifiedEmail=1 ***/ $newUsers = array(); $x = 0; require_once 'userRemoteSync.class.php'; $rsObj = new userRemoteSync($this->db); require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus($this->db); $partnerid = $ssObj->getState('partnerid'); $q = $rsObj->findUnlinkedAccounts(); while ($data = $this->db->readQ($q)) { $newUsers[$x][partnerid] = $partnerid; $newUsers[$x][userid] = $data->userid; $newUsers[$x][name] = $data->name; $newUsers[$x][email] = $data->email; $newUsers[$x][fbId] = $data->fbId; $newUsers[$x][city] = $data->city; $x += 1; } $log['newUsers'] = $newUsers; $this->narrate('New users to sync with NewsCloud'); $this->narrate($newUsers); // build for users to synchronize - changed bio, changed user level - to do : facebook image /*** Transmit users who change their user level ***/ $levelChanges = array(); $x = 0; require_once 'userRemoteSync.class.php'; $rsObj = new userRemoteSync($this->db); $q = $rsObj->findUserLevelIncreases($timestamp); while ($data = $this->db->readQ($q)) { $levelChanges[$x][logid] = $data->id; $levelChanges[$x][userid] = $data->userid; $levelChanges[$x][uid] = $data->ncUid; $levelChanges[$x][userlevel] = $data->itemid; $x += 1; } $log['levelChanges'] = $levelChanges; $this->narrate('User Level Increases'); $this->narrate($levelChanges); /*** Transmit read story records - req. ncUid and contentid ***/ $q = $this->db->query("SELECT Log.id,Content.contentid,User.ncUid FROM Log,Content,User WHERE action='readStory' AND status='pending' AND User.userid=Log.userid1 AND Log.itemid=Content.siteContentId AND User.ncUid>0 AND Content.contentid>0 AND Content.isBlocked=0 AND User.isBlocked=0 ORDER BY id DESC LIMIT {$limit};"); $readStory = array(); $x = 0; while ($data = $this->db->readQ($q)) { $readStory[$x][contentid] = $data->contentid; $readStory[$x][logid] = $data->id; $readStory[$x][uid] = $data->ncUid; $x += 1; } $log['readStory'] = $readStory; /*** Transmit published story to journal - req. ncUid and contentid ***/ $q = $this->db->query("SELECT Log.id,Content.contentid,User.ncUid FROM Log,Content,User WHERE action='publishStory' AND status='pending' AND User.userid=Log.userid1 AND Log.itemid=Content.siteContentId AND User.ncUid>0 AND Content.contentid>0 AND Content.isBlocked=0 AND User.isBlocked=0 ORDER BY id DESC LIMIT {$limit};"); $pubStory = array(); $x = 0; while ($data = $this->db->readQ($q)) { $pubStory[$x][contentid] = $data->contentid; $pubStory[$x][logid] = $data->id; $pubStory[$x][uid] = $data->ncUid; $x += 1; } $log['pubStory'] = $pubStory; /*** Transmit posted raw stories - req ncUid ***/ $q = $this->db->queryC("SELECT Log.id,Log.itemid,User.ncUid FROM Log,User WHERE action='publishWire' AND status='pending' AND User.userid=Log.userid1 AND User.ncUid>0 AND User.isBlocked=0 ORDER BY id DESC LIMIT {$limit};"); $pubWire = array(); $x = 0; while ($data = $this->db->readQ($q)) { $wireQuery = $this->db->queryC("SELECT * FROM Newswire WHERE id={$data->itemid};"); if ($wireQuery !== false) { $wi = $this->db->readQ($wireQuery); $pubWire[$x][logid] = $data->id; $pubWire[$x][uid] = $data->ncUid; // fetch wire story url $pubWire[$x][url] = $wi->url; $pubWire[$x][siteContentId] = $data->itemid2; $pubWire[$x][wireid] = $wi->wireid; switch ($wi->feedType) { default: // wire $pubWire[$x][feedType] = 'wire'; break; case 'blog': $pubWire[$x][feedType] = 'blog'; $pubWire[$x][title] = $wi->title; $pubWire[$x][date] = $wi->date; $pubWire[$x][caption] = $utilObj->shorten($wi->caption, 500); break; } $x += 1; } else { // story deleted from newswire $this->db->update("Log", "status='error'", "id={$data->id}"); } } $log['pubWire'] = $pubWire; /*** Transmit posted stories, a new user posted story - req ncUid ***/ $q = $this->db->queryC("SELECT Log.id,Log.itemid,User.ncUid FROM Log,User WHERE action='postStory' AND status='pending' AND User.userid=Log.userid1 AND User.ncUid>0 AND User.isBlocked=0 ORDER BY id DESC LIMIT {$limit};"); if ($q !== false) { //$this->db->log('inside poststory'); require_once PATH_CORE . '/classes/content.class.php'; $cObj = new content($this->db); $postStory = array(); $x = 0; while ($data = $this->db->readQ($q)) { $this->db->log($data->id); // fetch contentid from siteContentid $si = $cObj->getById($data->itemid); if ($si !== false) { $postStory[$x][logid] = $data->id; $postStory[$x][siteContentId] = $data->itemid; $postStory[$x][uid] = $data->ncUid; $postStory[$x][title] = $si->title; $postStory[$x][url] = $si->url; $postStory[$x][date] = $si->date; $postStory[$x][caption] = htmlentities($utilObj->shorten(strip_tags($si->caption), 500), ENT_QUOTES); $imageProps = $cObj->getImage($data->itemid); if ($imageProps !== false) { $postStory[$x][imageurl] = $imageProps->url; } $x += 1; } } $log['postStory'] = $postStory; } $this->narrate('Posting stories to NewsCloud'); $this->narrate($postStory); /*** Transmit comments - req. ncUid and contentid ***/ $comments = array(); $q = $this->db->query("SELECT Log.id,Comments.comments,Comments.siteCommentId,Content.contentid,User.ncUid FROM Log,Comments,Content,User WHERE Log.itemid=Comments.siteCommentId AND Comments.siteContentId=Log.itemid2 AND Content.siteContentId=Log.itemid2 AND Content.contentid>0 AND Log.userid1=User.userid AND User.ncUid>0 AND action='comment' AND status='pending' AND Content.isBlocked=0 AND User.isBlocked=0 AND Comments.videoid=0 ORDER BY id DESC LIMIT {$limit};"); $x = 0; while ($data = $this->db->readQ($q)) { $comments[$x][uid] = $data->ncUid; $comments[$x][contentid] = $data->contentid; $comments[$x][logid] = $data->id; $comments[$x][comments] = htmlentities($data->comments, ENT_QUOTES); $comments[$x][siteCommentId] = $data->siteCommentId; $x += 1; // fetch contentid from siteContentid //$contentid=$this->lookupContentId($data->itemid); //if ($contentid!==false AND $contentid<>0) { // fetch newscloud id from userid1 //$ncUid=$this->lookupUid($data->userid1); //if ($ncUid<>0) { //} //} } $log['comments'] = $comments; $this->narrate('Transmitting comments'); $this->narrate($comments); // send serialized array out return serialize($log); }
function authorizeFbIdForEditing($fbId) { require_once PATH_CORE . '/classes/systemStatus.class.php'; // check system status field for $ssObj = new systemStatus($this->db); $authorizedEditors = explode(',', $ssObj->getState('template_editor_fbIds')); $authorizedEditors[] = $fbId; $ssObj->setState('template_editor_fbIds', implode(',', $authorizedEditors)); return implode(',', $authorizedEditors); }
function registerFeedTemplates() { require_once PATH_CORE . '/classes/db.class.php'; $this->db = new cloudDatabase(); require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus($this->db); require_once PATH_CORE . '/classes/dynamicTemplate.class.php'; $dynTemp = dynamicTemplate::getInstance($this->db); require_once PATH_TEMPLATES . '/feeds.php'; $ids = array(); foreach ($feeds as $k => $v) { $idName = 'tbId_' . $k; echo $idName . '<br />'; /* if ($ssObj->getState($idName)!=''){ $this->facebook->api_client->feed_deactivateTemplateBundleByID($ssObj->getState($idName)); $this->db->query("DELETE FROM SystemStatus WHERE name='".$idName."' LIMIT 1;"); } */ try { $id = $this->facebook->api_client->feed_registerTemplateBundle($v['oneLine'], $v['shortStory']); echo $id . ' registered<br><br>'; } catch (Exception $e) { echo $id . ' not able to register<br><br>'; var_dump($v); $this->db->log($e, PATH_LOG_FB); $this->db->log($errs, PATH_LOG_FB); } echo '<br><br>'; $ssObj->insertState($idName, $id); $ids[] = $ssObj->getState($idName); } $idList = implode(', ', $ids); $code .= 'Template Bundle IDs registered: ' . $idList . '<br /><br />'; $code .= 'If you are a developer for this application, you can see the templates registered for this app <a href="http://developers.facebook.com/tools.php?templates" target="_blank">here</a>.'; echo $code; }
} else { $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; if ($pass1 != $pass2) { $failure = true; $failureMsg = 'Your passwords do not match.'; } } // set up refer page if (isset($_POST['referPage'])) { $referPage = $_POST['referPage']; $extraLinks .= '<li><a href="' . $referPage . '">Return to the previous page</a></li>'; } // look up site partnerid require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus($db); $partnerid = $ssObj->getState('partnerid'); if ($partnerid == 0) { $failure = true; $failureMsg = 'The site administrator hasn\'t properly configured this site with NewsCloud - missing partner registration.'; } if (USE_RECAPTCHA) { // check captcha require_once PATH_CORE . '/utilities/recaptchalib.php'; $publickey = KEY_PUB_RECAPTCHA; $privatekey = KEY_PRI_RECAPTCHA; $db->log('Pub:' . $publickey); $db->log('Pri:' . $privatekey); $db->log($_SERVER["REMOTE_ADDR"]); $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) {
include_once PATH_CORE . "utilities/initDatabase.php"; require_once PATH_CORE . '/classes/cron.class.php'; $cObj = new cron($init['apiKey']); $cObj->initJobs(); $cObj->resetJobs(); break; case 'addTestData': include_once PATH_CORE . "utilities/populateTestData.php"; break; case 'removeTestData': include_once PATH_CORE . "utilities/removeTestData.php"; break; case 'uploadSettings': echo 'Uploading settings in SystemStatus table up to Facebook Developer application<br />'; require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus(); $propList = $ssObj->loadFacebookProperties(); echo 'These settings will be uploaded:<br />'; print_r($propList); echo '<br />'; require_once PATH_FACEBOOK . "/classes/app.class.php"; $app = new app(NULL, true); $facebook =& $app->loadFacebookLibrary(); $props = $facebook->api_client->admin_setAppProperties($propList); echo 'Completed settings upload. Visit the <a href="http://www.facebook.com/developers/apps.php?app_id=' . $init['fbAppId'] . '">Facebook Developer app</a> to review them.<br />'; break; case 'populateSubscriptions': require_once PATH_CORE . '/classes/subscriptions.class.php'; $subObj = new SubscriptionsManager($db); $subObj->populateSubscriptions(); break;
} if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'feed.class.php')) { // create feed tables require_once PATH_CORE . '/classes/feed.class.php'; FeedsTable::createTable($manageObj); FeedMediaTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'notifications.class.php')) { // create Notifications and NotificationMessages Tables require_once PATH_CORE . '/classes/notifications.class.php'; NotificationsTable::createTable($manageObj); NotificationMessagesTable::createTable($manageObj); } // Set up some default SystemStatus variables require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus($manageObj->db); $ssObj->setState('cloudid', SITE_CLOUDID); //$ssObj->name=$this->getState('name'); //$ssObj->permalink=$this->getState('permalink'); $ssObj->setState('max_sessions', MAX_SESSIONS_ACTIVE); if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'userBlogs.class.php')) { // create UserBlogs require_once PATH_CORE . '/classes/userBlogs.class.php'; UserBlogsTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'widgets.class.php')) { // create Widgets require_once PATH_CORE . '/classes/widgets.class.php'; WidgetsTable::createTable($manageObj); FeaturedWidgetsTable::createTable($manageObj); }
function sendEmailVerification($email = '') { // to do - code duplicated in ajax, move to account class, verify global init global $init; // ask NewsCloud to send an email verification request require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus($this->db); $partnerid = $ssObj->getState('partnerid'); $this->db->log('partnerid ' . $partnerid); if ($partnerid == 0) { $this->db->log('ERROR: The site administrator hasn\'t properly configured this site with NewsCloud - missing partner registration.'); } else { require_once PATH_CORE . '/classes/apiCloud.class.php'; $apiObj = new apiCloud($this->db, $init[apiKey]); //$this->db->log($email); $resp = $apiObj->sendVerifyEmailRequest(SITE_CLOUDID, $email, $partnerid); //$this->db->log(print_r($resp,true)); } }