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 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; }
$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) { $failure = true;
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)); } }