Skip to content
Browse files

preview dec 09 release

  • Loading branch information...
1 parent 6cdb8d9 commit f7650329f11f560c85ce937a22637e068441eed9 Jeff Reifman committed Dec 26, 2009
Showing with 19,743 additions and 4,001 deletions.
  1. BIN .DS_Store
  2. +0 −31 approvedClouds.txt
  3. BIN core/.DS_Store
  4. +1 −1 core/classes/adCode.class.php
  5. +1 −1 core/classes/challenges.class.php
  6. +1 −1 core/classes/comments.class.php
  7. +181 −6 core/classes/content.class.php
  8. +103 −34 core/classes/cron.class.php
  9. +26 −9 core/classes/db.class.php
  10. +16 −1 core/classes/dbManage.class.php
  11. +4 −3 core/classes/dbRowObject.class.php
  12. +13 −16 core/classes/dynamicTemplate.class.php
  13. +1 −0 core/classes/featuredTemplate.class.php
  14. +1 −1 core/classes/feed.class.php
  15. +24 −9 core/classes/forum.class.php
  16. +172 −7 core/classes/home.class.php
  17. +9 −5 core/classes/images.class.php
  18. +75 −13 core/classes/log.class.php
  19. +25 −13 core/classes/newswire.class.php
  20. +77 −14 core/classes/parseStory.class.php
  21. +49 −45 core/classes/read.class.php
  22. +113 −6 core/classes/remotefile.class.php
  23. +1 −0 core/classes/research.class.php
  24. +1 −1 core/classes/resources.class.php
  25. +1 −1 core/classes/subscriptions.class.php
  26. +9 −0 core/classes/systemStatus.class.php
  27. +197 −0 core/classes/tags.class.php
  28. +40 −36 core/classes/teamBackend.class.php
  29. +76 −10 core/classes/template.class.php
  30. +1 −1 core/classes/twitter.class.php
  31. +32 −8 core/classes/user.class.php
  32. +1 −1 core/classes/utilities.class.php
  33. +21 −2 core/classes/video.class.php
  34. +1 −1 core/engine.php
  35. BIN core/utilities/.DS_Store
  36. +768 −0 core/utilities/OAuth.php
  37. +1,250 −0 core/utilities/Snoopy.class.php
  38. +49 −0 core/utilities/browserDetectMobile.php
  39. +10 −0 core/utilities/calais/license.txt
  40. +38 −0 core/utilities/calais/octest.php
  41. +129 −0 core/utilities/calais/opencalais.php
  42. +490 −0 core/utilities/class.html2text.inc
  43. +93 −58 core/utilities/initDatabase.php
  44. +263 −0 core/utilities/populateTestData.php
  45. +58 −0 core/utilities/removeTestData.php
  46. +4,277 −2,592 core/utilities/simplepie.inc
  47. +1,936 −0 core/utilities/twitter.php
  48. +151 −0 core/utilities/twitterOAuth.php
  49. BIN docs/.DS_Store
  50. +119 −0 docs/Adding a new page feature.txt
  51. +3 −0 docs/Capfile
  52. +51 −0 docs/Enabling modules.txt
  53. +0 −31 docs/approvedClouds.txt
  54. +6 −0 docs/commit-pull-push.sh
  55. BIN docs/designkit/.DS_Store
  56. BIN docs/designkit/Home mockup.psd
  57. BIN docs/designkit/app-icon.psd
  58. BIN docs/designkit/app-splash.psd
  59. BIN docs/designkit/bg_team2.psd
  60. BIN docs/designkit/bookmarklet demo.psd
  61. BIN docs/designkit/bookmarklet-demo-ondark.png
  62. BIN docs/designkit/bookmarklet-demo-onlight.png
  63. BIN docs/designkit/favicon.psd
  64. BIN docs/designkit/guide.doc
  65. +10 −0 docs/how_to_apc.txt
  66. +6 −0 docs/pull-push.sh
  67. +64 −0 docs/readme_console.txt
  68. +18 −3 docs/setup_indexing.txt
  69. +2 −0 docs/{setup.txt → setup_may09.txt}
  70. BIN facebook/.DS_Store
  71. +0 −62 facebook/Social Media Toolkit.tmproj
  72. +373 −29 facebook/ajax.php
  73. +19 −6 facebook/cache.php
  74. BIN facebook/classes/.DS_Store
  75. +5 −2 facebook/classes/account.class.php
  76. +12 −12 facebook/classes/actionFeed.class.php
  77. +119 −32 facebook/classes/actionTeam.class.php
  78. +802 −0 facebook/classes/ask.class.php
  79. +278 −0 facebook/classes/cards.class.php
  80. +53 −0 facebook/classes/common.class.php
  81. +592 −0 facebook/classes/ideas.class.php
  82. +70 −0 facebook/classes/local.class.php
  83. +406 −0 facebook/classes/media.class.php
  84. +1,015 −0 facebook/classes/micro.class.php
  85. +207 −91 facebook/classes/pages.class.php
  86. +166 −0 facebook/classes/predict.class.php
  87. +1 −2 facebook/classes/promos.class.php
  88. +1 −1 facebook/classes/publisher.class.php
  89. +24 −15 facebook/classes/session.class.php
  90. +2 −6 facebook/classes/shareStories.class.php
  91. BIN facebook/images/.DS_Store
  92. BIN facebook/images/ads/160x600.gif
  93. BIN facebook/images/ads/180x150.gif
  94. BIN facebook/images/ads/234x60.gif
  95. BIN facebook/images/ads/300x250.gif
  96. BIN facebook/images/ads/336x280.gif
  97. BIN facebook/images/ads/468x60.gif
  98. BIN facebook/images/ads/728x90.gif
  99. BIN facebook/images/anonymous_user.jpg
  100. BIN facebook/images/end_quote_small.gif
  101. +120 −0 facebook/images/gradient.php
  102. BIN facebook/images/helperUploadPhoto.jpg
  103. BIN facebook/images/indicator_blue_small.gif
  104. BIN facebook/images/loading.gif
  105. +101 −0 facebook/images/scaleImage.php
  106. BIN facebook/images/start_quote_small.gif
  107. BIN facebook/images/tweet_button.gif
  108. +88 −21 facebook/index.php
  109. BIN facebook/lib/.DS_Store
  110. +16 −7 facebook/lib/facebook.php
  111. +1 −1 facebook/lib/facebook_desktop.php
  112. +260 −0 facebook/lib/facebook_mobile.php
  113. +379 −161 facebook/lib/facebookapi_php5_restlib.php
  114. BIN facebook/lib/jsonwrapper/.DS_Store
  115. +6 −1 facebook/pages/pageAccount.class.php
  116. +180 −0 facebook/pages/pageAsk.class.php
  117. +197 −0 facebook/pages/pageCards.class.php
  118. +0 −1 facebook/pages/pageContact.class.php
  119. +25 −3 facebook/pages/pageHome.class.php
  120. +184 −0 facebook/pages/pageIdeas.class.php
  121. +2 −2 facebook/pages/pageLeaders.class.php
  122. +5 −2 facebook/pages/pageLinks.class.php
  123. +79 −0 facebook/pages/pageMedia.class.php
  124. +88 −0 facebook/pages/pageMicro.class.php
  125. +42 −14 facebook/pages/pagePostStory.class.php
  126. +129 −0 facebook/pages/pagePredict.class.php
  127. +1 −13 facebook/pages/pageProfile.class.php
  128. +21 −2 facebook/pages/pageRead.class.php
  129. +3 −1 facebook/pages/pageRules.class.php
  130. +7 −2 facebook/pages/pageSignup.class.php
  131. +32 −1 facebook/pages/pageStatic.class.php
  132. +4 −0 facebook/pages/pageStories.class.php
  133. +177 −0 facebook/pages/pageStuff.class.php
  134. +4 −4 facebook/pages/pageTeam.class.php
  135. +20 −4 facebook/pages/pageWall.class.php
  136. +273 −0 facebook/scripts/ask.js
  137. +236 −0 facebook/scripts/ideas.js
  138. +5 −3 facebook/scripts/loadStory.js
  139. +29 −0 facebook/scripts/local.js
  140. +131 −0 facebook/scripts/media.js
  141. +18 −0 facebook/scripts/micro.js
  142. +187 −131 facebook/scripts/newsroom.js
  143. +394 −0 facebook/scripts/stuff.js
  144. +12 −10 facebook/styles/default.css
  145. +1 −1 facebook/styles/newsroom.css
  146. +214 −125 facebook/utilities/initDatabase.php
  147. +27 −0 facebook/verify.php
  148. +0 −29 open-social-media-toolkit.tmproj
  149. BIN php/.DS_Store
  150. +4 −2 php/classes/auth.class.php
  151. +1 −1 php/classes/common.class.php
  152. +4 −0 php/classes/page.class.php
  153. +182 −120 php/config.php
  154. +0 −1 php/console/console.php
  155. +10 −5 php/console/controllers/admin_controller.php
  156. +1 −2 php/console/controllers/app_controller.php
  157. +284 −1 php/console/controllers/members_controller.php
  158. +39 −0 php/console/controllers/research_controller.php
  159. +115 −8 php/console/controllers/stories_controller.php
  160. +38 −4 php/console/controllers/street_team_controller.php
  161. +1 −1 php/console/footer.php
  162. +19 −2 php/console/global.php
  163. +58 −5 php/console/header.php
  164. +0 −8 php/console/index.php
  165. +5 −5 php/console/load_stories.php
  166. +4 −6 php/console/load_story.php
  167. +18 −8 php/console/pods/ChallengeReport.php
  168. +15 −1 php/console/pods/StoryReport.php
  169. +38 −13 php/console/pods/UserReport.php
  170. +0 −35 php/console/readme.txt
  171. +0 −15 php/console/readme_indexes.txt
Sorry, we could not display the entire diff because too many files (501) changed.
View
BIN .DS_Store
Binary file not shown.
View
31 approvedClouds.txt
@@ -1,31 +0,0 @@
-CloudId - Name
-77 2008 Elections
-70 CIA Leak Case
-87 Darfur
-159 Food
-73 Global Warming
-156 Green Energy
-68 Iraq
-101 Israel Palestine
-158 Living with Cancer
-75 Media Reform
-198 Online community
-157 Open Society
-160 Reproductive Rights
-136 The Daily Show
-155 Two Americas
-388 Sarah Palin
-172 Seattle
-107 Technology
-108 Environment
-109 Health
-110 Sports
-111 Spirituality
-114 World
-115 U.S.
-116 Business
-117 Opinion
-118 Science
-119 Arts
-120 Entertainment
-121 Oddities
View
BIN core/.DS_Store
Binary file not shown.
View
2 core/classes/adCode.class.php
@@ -1 +1 @@
-<?php
+<?php
View
2 core/classes/challenges.class.php
@@ -176,7 +176,7 @@ function populateCommonChallenges()
array("submission","addAppTab","Add App Tab to profile","Add the ".SITE_TITLE." application tab to your Facebook profile so your friends can see what you've been up to. See <a href=\"".URL_CANVAS."?p=faq\">the FAQ</a> for details. Then send us a screenshot of the tab on your profile! File size must be under 2mb. (Don't know how to take a screenshot? Once again, <a href=\"".URL_CANVAS."?p=faq\">hit up the FAQ</a>.)","0","0","100","1","0","0","disabled"),
array("submission","profileBoxWall","Add profile box to your wall",'To add the profile box to your profile, visit settings -> application settings, then Edit Settings for ".SITE_TITLE.". Click the Profile tab and "add" next to Box to add the profile box to your profile. Then, move the profile box to your wall page. (If you don\'t see the button, you may have already added this.) Send us a screenshot (file size under 2mb) of the box on your profile! (Don\'t know how to take a screenshot? <a href="'.URL_CANVAS.'?p=faq">Hit up the FAQ</a>.)
- <div><fb:add-section-button section="profile" /><br clear="all" /></div>',"0","0","100","1","1","0","enabled"),
+ <div><fb:add-section-button section="profile" /><br clear="all" /></div>',"0","0","100","1","1","0","disabled"),
array("submission","blog","Blog about ".SITE_TITLE."","Forget blogging about what you had for lunch. We know you love ".SITE_TITLE." -- so why not write a post about it on your blog and send us the link?","0","0","75","25","1","0","disabled"),
);
View
2 core/classes/comments.class.php
@@ -155,7 +155,7 @@ function serialize($siteCommentId=0,$commentid=0,$siteContentId=0,$contentid=0,$
$data->contentid = $contentid;
$data->siteContentId = $siteContentId;
$data->siteCommentId=$siteCommentId;
- $data->comments=$this->db->safe($comments);
+ $data->comments=mysql_real_escape_string($comments);
$data->postedById = $postedById;
$data->userid = $userid;
$data->postedByName = $postedByName;
View
187 core/classes/content.class.php
@@ -91,7 +91,7 @@ class content {
function content(&$db=NULL) {
if (is_null($db)) {
- require_once('db.class.php');
+ require_once(PATH_CORE.'/classes/db.class.php');
$this->db=new cloudDatabase();
} else
$this->db=$db;
@@ -130,7 +130,7 @@ function getByPermalink($permalink='',$returnQuery=false) {
function createStoryContent($userinfo=NULL,$info=NULL,$mode='link') {
// post a story from the post story form
// build source from domain - to do : improve this with source objects table
- $urlParts=parse_url($fData->storyUrl);
+ $urlParts=parse_url($info->url);
$info->source=$urlParts['host'];
// create permalink
$info->permalink=$this->buildPermalink($info->title);
@@ -143,7 +143,7 @@ function createStoryContent($userinfo=NULL,$info=NULL,$mode='link') {
$isBlogEntry=1;
$story=$this->serialize(0,$info->title,$info->caption,$info->source,$info->url,$info->permalink,$userinfo->ncUid,$userinfo->u->name,$userinfo->userid,'',$userinfo->votePower,0,0,$info->imageUrl,0,$isBlogEntry,$info->isFeatureCandidate);
// post wire story to content
- $siteContentId=$this->add($story);
+ $siteContentId=$this->add($story);
if ($info->videoEmbed<>'') {
// add video if it exists
require_once(PATH_CORE .'/classes/video.class.php');
@@ -186,14 +186,16 @@ function buildPermalink($title) {
function add($story) {
// check for duplicate
- $chkDup=$this->db->queryC("SELECT siteContentId FROM Content WHERE permalink='$story->permalink';");
+ $chkDup=$this->db->queryC("SELECT siteContentId FROM Content WHERE url='$story->url';");
if (!$chkDup) {
// insert the story into the table
$this_query=$this->db->insert("Content","contentid,title,caption,source,url,permalink,postedById,PostedByName,userid,date,score,isFeatured,imageid,videoid,isBlogEntry,isFeatureCandidate",
"$story->contentid,'$story->title','$story->caption','$story->source','$story->url','$story->permalink',$story->postedById,'$story->postedByName',$story->userid,'$story->date',$story->score,$story->isFeatured,$story->imageid,$story->videoid,$story->isBlogEntry,$story->isFeatureCandidate");
$q=$this->db->query("SELECT siteContentId FROM Content WHERE url='$story->url' AND permalink='$story->permalink';");
$data=$this->db->readQ($q);
$contentImageQuery = $this->db->insert("ContentImages", "url, siteContentId, date", "'$story->imageUrl', $data->siteContentId, NOW()");
+ $imageid=$this->db->getId();
+ $this->db->update("Content","imageid=$imageid","siteContentId=$data->siteContentId");
} else {
$data=$this->db->readQ($chkDup);
}
@@ -231,8 +233,8 @@ function serialize($contentid=0,$title='',$caption='',$source='',$url='',$permal
// creates an object for an action
$data= new stdClass;
$data->contentid = $contentid;
- $data->title=$this->db->safe($title);
- $data->caption=$this->db->safe($caption);
+ $data->title=$title;
+ $data->caption=$caption;
$data->source=$source;
$data->url=$url;
$data->imageUrl=$imageUrl;
@@ -314,12 +316,185 @@ function getScore($siteContentId) {
return $info->score;
}
+
+ function ajaxBanStoryPoster(&$app=null,$cid=0,$userid=0) {
+ // to do - make sure user is admin
+ // cid - cid of user to ban
+ $contentTable = new ContentTable($this->db);
+ $c=$contentTable->getRowObject();
+ $c->load($cid);
+ if ($c->userid<>$userid) {
+ $this->db->update("Content","isBlocked=1","userid=".$c->userid); // block all stories by this user
+ $this->db->update("Comments","isBlocked=1","userid=".$c->userid); // block all comments by this user
+ require_once (PATH_CORE .'/classes/user.class.php');
+ $uit = new UserInfoTable($this->db);
+ $ut = new UserTable($this->db);
+ $u = $ut->getRowObject();
+ $ui = $uit->getRowObject();
+ $u->load($c->userid);
+ // block story
+ $c->isBlocked=1;
+ $c->update();
+ // block user
+ $u->isBlocked=1;
+ $u->update();
+ $ui->load($c->userid);
+ $facebook=$app->loadFacebookLibrary();
+ $this->db->log('To Ban '.$ui->fbId);
+ //$facebook->api_client->admin_banUsers($ui->fbId);
+ // load facebook library - call ban api
+ $code='Ban complete.';
+ } else {
+ $code='Error: Trying to ban yourself again, huh?';
+ }
+ return $code;
+ }
+
+ function autoFeature() {
+ // look up FeaturedTemplate.t to see if more than interval
+ $q=$this->db->queryC("SELECT id FROM FeaturedTemplate WHERE t<DATE_SUB(NOW(),INTERVAL ".AUTOFEATURE_INTERVAL." HOUR);");
+ if ($q===false) {
+ //return false;
+ }
+ // get admin user list
+ require_once(PATH_CORE.'/classes/user.class.php');
+ $userTable = new UserTable($this->db);
+ $adminList=$userTable->listAdmins();
+ if ($adminList=='') {
+ $this->db->log("AF Error: No admins listed");
+ return false;
+ }
+ $cnt=0;
+ $tempInterval=AUTOFEATURE_INTERVAL*2;
+ while ($cnt<6) {
+ // find 2 stories (posted by admin, in last n hours, not yet in log) - sort preference to images
+ $qStr="SELECT Content.siteContentId,title,ContentImages.url AS imageUrl FROM Content LEFT JOIN ContentImages ON Content.siteContentId=ContentImages.siteContentId LEFT JOIN Log ON Content.siteContentId=Log.itemid AND Log.action='storyFeatured' WHERE FIND_IN_SET(Content.userid,'$adminList') AND Content.date>DATE_SUB(NOW(),INTERVAL $tempInterval HOUR) ORDER BY (Log.id IS NULL) DESC,(imageUrl<>'') DESC, Content.siteContentId DESC LIMIT 2;";
+ $q1=$this->db->queryC($qStr);
+ if ($this->db->cnt==2) break;
+ $cnt+=1;
+ $tempInterval*=2;
+ }
+ if ($this->db->cnt==0) return false; // not enough stories
+ $numPrimaryStories=$this->db->cnt;
+ $primaryStories=array();
+ $excludeStoryList='';
+ // load array with results
+ while ($d=$this->db->readQ($q1)) {
+ $primaryStories[]=$d;
+ $excludeStoryList.=$d->siteContentId.',';
+ }
+ $excludeStoryList=trim($excludeStoryList,',');
+ // find secondary stories
+ $cnt=0;
+ $tempInterval=AUTOFEATURE_INTERVAL*4;
+ while ($cnt<3) {
+ // 4 stories in last n hours e.g. 12/24 excluding above selections, posted by admins - no worries if featured before
+ $qStr="SELECT Content.siteContentId,title,ContentImages.url AS imageUrl FROM Content LEFT JOIN ContentImages ON Content.siteContentId=ContentImages.siteContentId WHERE NOT FIND_IN_SET(Content.siteContentId,'$excludeStoryList') AND FIND_IN_SET(Content.userid,'$adminList') AND Content.date>DATE_SUB(NOW(),INTERVAL $tempInterval HOUR) ORDER BY Content.siteContentId DESC LIMIT 4;";
+ $q2=$this->db->queryC($qStr);
+ if ($this->db->cnt==4) break;
+ $cnt+=1;
+ $tempInterval*=2;
+ }
+ $numSecondaryStories=$this->db->cnt;
+ $secondaryStories=array();
+ // load array with results
+ while ($d=$this->db->readQ($q2)) {
+ $secondaryStories[]=$d;
+ }
+ $autoLog=PATH_SERVER_LOGS.'auto.log';
+ // log changes to auto.log
+ $this->db->log('Time: '.date('H:i').' on '.date('m-d'),$autoLog);
+ $this->db->log('Template: '.$template,$autoLog);
+ // from story arrays, determine best template e.g. images
+ // no images
+ $story_1_id=0; $story_2_id=0; $story_3_id=0; $story_4_id=0; $story_5_id=0; $story_6_id=0;
+ if ($primaryStories[0]->imageUrl=='') { // first always likeliest to have image due to sort
+ $template='template_1';
+ $story_1_id=$primaryStories[0]->siteContentId;
+ $this->db->log($primaryStories[0],$autoLog);
+ } else if ($primaryStories[0]->imageUrl<>'' AND $primaryStories[1]->imageUrl<>'') { // two images
+ // less than two secondary stories
+ $x=rand(0,1);
+ if ($x==0)
+ $template='template_3'; // two images version 1
+ else
+ $template='template_4'; // two images version 2
+ $story_1_id=$primaryStories[0]->siteContentId;
+ $story_4_id=$primaryStories[1]->siteContentId;
+ $this->db->log($primaryStories[0],$autoLog);
+ $this->db->log($primaryStories[1],$autoLog);
+ /*if ($numSecondaryStories<4) {
+ } else {
+ // 4 secondary stories
+ $template='template_5';
+ $story_1_id=$primaryStories[0]->siteContentId;
+ $story_4_id=$primaryStories[1]->siteContentId;
+ $story_2_id=$secondaryStories[0]->siteContentId;
+ $story_3_id=$secondaryStories[1]->siteContentId;
+ $story_5_id=$secondaryStories[2]->siteContentId;
+ $story_6_id=$secondaryStories[3]->siteContentId;
+ $this->db->log($primaryStories[0],$autoLog);
+ $this->db->log($primaryStories[1],$autoLog);
+ $this->db->log($secondaryStories,$autoLog);
+ }
+ */
+ } else { // one image if ($primaryStories[0]->imageUrl<>'') - first always likeliest to have image due to sort
+ if ($numSecondaryStories>=2) {
+ $template='template_2'; // one image, two story links
+ $story_1_id=$primaryStories[0]->siteContentId;
+ $story_2_id=$secondaryStories[0]->siteContentId;
+ $story_3_id=$secondaryStories[1]->siteContentId;
+ $this->db->log($primaryStories[0],$autoLog);
+ $this->db->log($secondaryStories[0],$autoLog);
+ $this->db->log($secondaryStories[1],$autoLog);
+ } else {
+ $template='template_1';
+ // less than two secondaryStories
+ $story_1_id=$primaryStories[0]->siteContentId;
+ $this->db->log($primaryStories[0],$autoLog);
+ }
+ }
+ // add top two to the log as having been featured
+ require_once(PATH_CORE.'/classes/log.class.php');
+ $logObj=new log($this->db);
+ for ($i=1;$i<=6;$i++) {
+ $str = '$story_'.$i.'_id';
+ eval("\$storyid = \"$str\";");
+ if ($storyid>0) {
+ // only log new ones
+ $q=$this->db->queryC("SELECT id FROM Log WHERE action='storyFeatured' AND itemid=$storyid LIMIT 1;");
+ if ($q===false) {
+ $logItem=$logObj->serialize(0,0,'storyFeatured',$storyid);
+ $logObj->add($logItem);
+ }
+ }
+ }
+ // taken from save_template.php in console
+ $this->db->query("UPDATE Content set isFeatured = 0 WHERE isFeatured = 1");
+ // set new features
+ $sql = sprintf("REPLACE INTO FeaturedTemplate SET id = 1, template = '%s', story_1_id = %s, story_2_id = %s, story_3_id = %s, story_4_id = %s, story_5_id = %s, story_6_id = %s", $template, $story_1_id, $story_2_id, $story_3_id, $story_4_id, $story_5_id, $story_6_id);
+ $this->db->query($sql);
+ $this->db->query("UPDATE Content set isFeatured = 1 WHERE siteContentId IN ($story_1_id, $story_2_id, $story_3_id, $story_4_id, $story_5_id, $story_6_id)");
+ // clear out the cache of the home top stories
+ require_once(PATH_CORE.'/classes/template.class.php');
+ $templateObj=new template($this->db);
+ $templateObj->resetCache('home_feature');
+ // update twitter feed
+ if (USE_TWITTER) {
+ require_once (PATH_CORE.'classes/twitter.class.php');
+ $twitterObj=new twitter_old($this->db);
+ $twitterObj->postFeaturedStories();
+ }
+ return true;
+ }
+
function cleanup() {
// delete content for deleted users
$this->db->delete("Content","NOT EXISTS (select * from User where User.userid=Content.userid)");
// delete comments for deleted stories
$this->db->delete("Comments","NOT EXISTS (SELECT * FROM Content WHERE Content.siteContentId=Comments.siteContentId)");
// to do: delete log entries related to deleted stories and content
}
+
}
?>
View
137 core/classes/cron.class.php
@@ -101,6 +101,21 @@ function fetchJobs() {
// log time of day
$entryTime=time();
$this->startTime=$entryTime;
+ // reboot dead tasks
+ $this->resetDeadTasks();
+
+ if (defined('ENABLE_MICRO')) {
+ // Always look for micro blog entries
+ require_once PATH_FACEBOOK."/classes/micro.class.php";
+ $mObj=new micro();
+ try {
+ $mObj->updateRoom();
+ $this->db->update("cronJobs","nextRun=date_sub(NOW(), INTERVAL (0-$job->freqMinutes) MINUTE),lastStart='".date('Y-m-d H:i:s')."',isRunning=0","task='microBlog'");
+ } catch (Exception $e) {
+ $this->log('Failed running '.$job->task.', Error: '.$e);
+ }
+ }
+
// FIRST - run any jobs that are set for this particular day of week and time of day
if ($this->checkTime()) {
$jobList=$this->db->query("SELECT * FROM cronJobs WHERE hourOfDay='".$this->hourOfDay."' AND dayOfWeek='".$this->dayOfWeek."' AND nextRun<=now() AND status='enabled';");
@@ -119,7 +134,7 @@ function fetchJobs() {
//$this->log(date('g:i a \a\t D M n, Y',$entryTime));
// fetch jobs that need to be run
if ($this->checkTime()) {
- $jobList=$this->db->query("SELECT * FROM cronJobs WHERE hourOfDay='' AND dayOfWeek='' AND nextRun<=now() AND status='enabled' ORDER BY nextRun ASC;");
+ $jobList=$this->db->query("SELECT * FROM cronJobs WHERE task<>'microBlog' AND hourOfDay='' AND dayOfWeek='' AND nextRun<=now() AND status='enabled' ORDER BY nextRun ASC;");
$this->runJobList($jobList);
} else
return;
@@ -129,8 +144,6 @@ function fetchJobs() {
// check for dead tasks
$this->hasDeadTasks();
- // reboot dead tasks
- $this->resetDeadTasks();
$exitTime=time();
//$this->log('Execution time total: '.(($exitTime-$entryTime)/60).' seconds');
//mail('newscloud@gmail.com', 'Job history: '.SITE_TITLE, $this->showHistory(), 'From: support@newscloud.com'."\r\n");
@@ -141,7 +154,7 @@ function runJobList($jobList) {
while ($job=$this->db->readQ($jobList)) {
if ($this->checkTime()) {
// reset next run timestamp to a later timestamp based on frequency in minutes
- echo '<b>Cron: '.$job->task.'</b><br/>';
+ echo '<b>Run task: '.$job->task.'</b><br/>';
//$this->log('Run '.$job->task);
$startTime=time();
try {
@@ -157,16 +170,19 @@ function runJobList($jobList) {
}
function resetDeadTasks() {
- $whereStr="isRunning=1 AND failureNoticeSent=1 AND status='enabled' AND lastStart<date_sub(NOW(), INTERVAL (freqMinutes+120) MINUTE)";
- $resultStr=$this->db->buildIdList("SELECT task as id FROM cronJobs WHERE ".$whereStr);
- if ($result<>'') {
- $result=$this->db->query("SELECT * FROM cronJobs WHERE ".$whereStr);
+ $whereStr="isRunning=1 AND status='enabled' AND (lastStart IS NULL OR lastStart<date_sub(NOW(), INTERVAL (freqMinutes+15) MINUTE))";
+ $result=$this->db->queryC("SELECT id,task FROM cronJobs WHERE ".$whereStr);
+ $resultStr='';
+ if ($result!==false) {
while ($data=$this->db->readQ($result)) {
- $this->db->update("UPDATE cronJobs SET isRunning=0,failureNoticeSent=0 WHERE id=".$data->id);
+ $this->db->query("UPDATE cronJobs SET isRunning=0,failureNoticeSent=0 WHERE id=".$data->id);
+ $resultStr.=$data->task.', ';
}
+ $resultStr=trim($resultStr,',');
$subject='Alert'.SITE_TITLE.' Cron Jobs Auto Reset';
- $msg='The following cronJobs have been reset: '.$resultStr.' ';
- mail('newscloud@gmail.com', $subject, $msg, 'From: support@newscloud.com'."\r\n");
+ $msg='CronJobs reset: '.$resultStr.' ';
+ $this->db->log($msg);
+ //mail('newscloud@gmail.com', $subject, $msg, 'From: support@newscloud.com'."\r\n");
}
}
@@ -272,11 +288,42 @@ function runJob($job,$force=false) {
// post top stories to twitter
if (USE_TWITTER) {
require_once ('twitter.class.php');
- $twitterObj=new twitter($this->db);
+ $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');
@@ -309,6 +356,7 @@ function runJob($job,$force=false) {
}
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));
@@ -330,6 +378,7 @@ function runJob($job,$force=false) {
}
$this->db->update("cronJobs","lastItemTime='$lastItemTime'","id=$job->id");
}
+ */
break;
case 'syncLog':
require_once ('apiCloud.class.php');
@@ -436,14 +485,6 @@ function runJob($job,$force=false) {
$result=$apiObj->syncResources($this->cloudid);
$resObj->sync(html_entity_decode($result[items][0][resources]));
break;
- 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;
case 'updateSiteMap':
$currentHour=date('G'); // 0 - 24
$currentDayOfWeek=date('w'); // day of week 0-6
@@ -475,7 +516,12 @@ function runJob($job,$force=false) {
// 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');
@@ -525,11 +571,13 @@ function runJob($job,$force=false) {
$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";
@@ -556,10 +604,25 @@ function runJob($job,$force=false) {
$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
+ 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.');
@@ -607,23 +670,20 @@ function initJobs() {
// this function adds NewsCloud's cron jobs to the database
/* please do not update the frequency of these cron calls without requesting permission from jeff@newscloud.com for your site and topic */
$this->addJob("updateCache","Update cached content",15,"disabled");
- $this->addJob("syncFeedList","Fetch blog list for this cloud",720,"enabled");
- if (USE_SIMPLEPIE)
- $this->addJob("fetchFeeds","Fetch blog feeds locally",15,"enabled"); // use simple pie to locally fetch raw feeds
- else
- $this->addJob("syncNewswire","Fetch new wire stories for this cloud",15,"enabled"); // sync raw feeds from newscloud
- $this->addJob("syncContent","Fetch new Content stories for this cloud",60,"enabled");
- $this->addJob("syncComments","Fetch new comment thread for this cloud",30,"enabled");
- $this->addJob("syncScores","Update scores for recent stories",20,"enabled");
- $this->addJob("syncProperties","Synchronize the latest Cloud properties",1440,"enabled");
- $this->addJob("syncAnnouncements","Synchronize the announcements for this Cloud",1440,"disabled");
+ //$this->addJob("updateSiteMap","Update site map for search engines",60,"enabled");
+ $this->addJob("calcTeamLeaders","Update team leaders",60,"enabled");
+ //if (USE_SIMPLEPIE)
+ $this->addJob("fetchFeeds","Fetch blog feeds locally",15,"enabled"); // use simple pie to locally fetch raw feeds
$this->addJob("cleanup","Cleanup unused tables",1440,"enabled");
- $this->addJob("syncLog","Synchronize the log with NewsCloud server",30,"enabled");
- $this->addJob("syncResources","Fetch folders and links from the cloud",4320,"enabled");
$this->addJob("updateTwitter","Update top stories in Twitter",30,"enabled");
- $this->addJob("updateSiteMap","Update site map for search engines",60,"enabled");
+ if (defined('ENABLE_MICRO')) {
+ $this->addJob("microBlog","Update microblog",10,"enabled");
+ $this->addJob("microAccountsSync","Update microblog accounts",1440,"enabled");
+ }
+ if (defined('ENABLE_AUTOFEATURE'))
+ $this->addJob("autoFeature","Update cover features",60,"enabled");
$this->addJob("calcTeamLeaders","Update team leaders",60,"enabled");
- $this->addJob("insertNewResearchData","Add in the daily research stat logs",24*60,"enabled",'','03');
+ //$this->addJob("insertNewResearchData","Add in the daily research stat logs",24*60,"enabled",'','03'); -- only for hot dish
if (MODULE_FACEBOOK) {
$this->addJob("facebookProfileBoxes","Update Facebook profile boxes",15,"enabled");
$this->addJob("facebookMinifeed","Publish facebook minifeed stories",15,"enabled");
@@ -637,6 +697,15 @@ function initJobs() {
$this->addJob("facebookSendNotifications","Deliver notifications",20,"enabled");
$this->addJob("facebookSendPromos","Send promotions to new users",24*60,"enabled",'','00');
}
+ //else - from not USE_SIMPLEPIE ABOVE $this->addJob("syncNewswire","Fetch new wire stories for this cloud",15,"enabled"); // sync raw feeds from newscloud
+ //$this->addJob("syncContent","Fetch new Content stories for this cloud",60,"enabled");
+ //$this->addJob("syncComments","Fetch new comment thread for this cloud",30,"enabled");
+ //$this->addJob("syncScores","Update scores for recent stories",20,"enabled");
+ //$this->addJob("syncProperties","Synchronize the latest Cloud properties",1440,"enabled");
+ //$this->addJob("syncAnnouncements","Synchronize the announcements for this Cloud",1440,"disabled");
+ //$this->addJob("syncLog","Synchronize the log with NewsCloud server",30,"enabled");
+ //$this->addJob("syncResources","Fetch folders and links from the cloud",4320,"enabled");
+ //$this->addJob("syncFeedList","Fetch blog list for this cloud",720,"enabled");
}
function log($str='') {
View
35 core/classes/db.class.php
@@ -13,7 +13,7 @@ class cloudDatabase {
var $init;
var $row;
var $ui; // user information
- var $debug;
+ var $debug=false;
var $logInserts=false;
// current raw database handler
@@ -39,7 +39,7 @@ function cloudDatabase()
$this->selectDB($this->database);
}
- function _connect()
+ function _connect()
{
$this->handle = mysql_pconnect($this->hostname, $this->username, $this->password) or die(mysql_error());
}
@@ -57,6 +57,7 @@ function selectDB($database_name)
function query($q_string)
{
+ if (stristr($q_string,'load_file')) exit;
if ($this->debug)
$this->log($q_string);
@@ -72,10 +73,10 @@ function query($q_string)
echo "<p><h2> Query String: </h2>$q_string</p><br />";
$error = mysql_error();
- $logMessage = '('. date('Y-m-d H:i:s', time()) .') '. "$error ... Query String: $q_string";
- $logHash = hash('md5',$logMessage);
- $this->log("[$logHash] $logMessage"); // embed unique hash (hopefully) in log message
- die("<h2>MySQL Error Encountered</h2> <p>Please notify site admins and show them this message (refence code: $logHash)</p>");
+ $logMessage = '('. date('Y-m-d H:i:s', time()) .') '. "IP:".$_SERVER['HTTP_X_FB_USER_REMOTE_ADDR']." qs:".$_SERVER['QUERY_STRING']." $error ... Query String: $q_string";
+ $logHash = hash('md5',$logMessage);
+ $this->log($logHash.' '.$logMessage);
+ die("<h2>MySQL Error Encountered</h2> <p>Please notify site admins and show them this message (reference code: $logHash)</p>");
}
return $this->result;
}
@@ -84,8 +85,7 @@ function query($q_string)
function queryC($q_string) {
// queries and counts, returns false if empty
if ($this->debug)
- $this->log($q_string);
-
+ $this->log($q_string);
$this->query($q_string);
$this->cnt=$this->count();
if ($this->cnt==0)
@@ -128,6 +128,7 @@ function readQ($result) {
function insert($table,$columns,$values) {
//echo "INSERT INTO $table ($columns) VALUES ($values);";
+ if (stristr($values,'load_file')) exit;
$error = false;
if (mysql_query("INSERT INTO $table ($columns) VALUES ($values);"))
$result = $this->getId();
@@ -141,6 +142,7 @@ function insert($table,$columns,$values) {
}
function update($table,$setList,$whereList='') {
+ if (stristr($whereList,'load_file')) exit;
if ($whereList<>'') $whereList="WHERE $whereList";
//echo "UPDATE $table SET $setList $whereList;"; // bear with me for a sec guys :)
@@ -192,6 +194,16 @@ function buildIdList($q_string) {
return $str;
}
+ function buildWhereStr($where,$joinWith='AND') {
+ // construct where str
+ if (count($where)) {
+ $whereStr = ' WHERE '.join(' '.$joinWith.' ', $where);
+ } else {
+ $whereStr = '';
+ }
+ return $whereStr;
+ }
+
function paging($pageCurrent=1,$rowLimit=10,$link='',$jscriptFunction='refreshPage',$ajaxOn=false,$nav=NULL) {
// $link is the url that the page navigation will point to - this functions add the page offset as the suffix
// e.g. $link ='/search/keyword/tag/sort/' ... pages will link to '/search/keyword/tag/sort/pagenumber/'
@@ -401,7 +413,12 @@ function safe($str) {
return $str;
}
+ function mysql_real_escape_array($t) {
+ return array_map("mysql_real_escape_string",$t);
+ }
+
function log($str='Empty log string',$filename=PATH_LOGFILE) {
+ if (defined('NO_LOGGING') AND NO_LOGGING) return false;
// write to newscloud log file for debugging
// must touch and permission file at PATH_LOGFILE for this to work
$fHandle=fopen($filename,'a');
@@ -414,7 +431,7 @@ function log($str='Empty log string',$filename=PATH_LOGFILE) {
fclose($fHandle);
}
}
-
+
function setDebug($status=true) {
$this->debug=$status;
}
View
17 core/classes/dbManage.class.php
@@ -2,12 +2,27 @@
class dbManage {
var $db;
+ var $ssObj;
var $debug;
-
+
function dbManage($debug=false) {
require_once('db.class.php');
$this->db=new cloudDatabase();
$this->debug=$debug;
+ require_once (PATH_CORE.'/classes/systemStatus.class.php');
+ $this->ssObj=new systemStatus($this->db);
+ }
+
+ function modifyLibrary($path='',$lib='') {
+ $lastModified=$this->ssObj->getState('dm_'.$lib);
+ if ($lastModified=='' OR intval($lastModified)<filemtime($path.$lib)) {
+ $this->ssObj->setState('dm_'.$lib,time()); // add or update in sysStatus
+ $this->db->log('NEED TO UPDATE:'.$lib);
+ return true; // file is out of date
+ } else {
+ $this->db->log('OK:'.$lib);
+ return false;
+ }
}
function addColumn($table,$column,$column_info) {
View
7 core/classes/dbRowObject.class.php
@@ -210,7 +210,7 @@ function insert($set_id=NULL)
if (dbRowObject::$debug) echo "\n<BR>insert string: (\"$this->table\", \"$fields\", \"$valuestring\")<BR>\n";
-
+ if (stristr($valuestring,'load_file')) exit;
$newId=$this->db->insert($this->table,$fields, $valuestring);
if ($set_id != NULL && is_numeric($newId)) // set_id usually used with non-autoincrement id columns, so $newId will always be zero
@@ -239,7 +239,7 @@ function update()
$wherestring = $this->idname. '='.$this->{$this->idname}; //"{$this->{$idname}=$this->id";
-
+ if (stristr($wherestring,'load_file')) exit;
if (dbRowObject::$debug) echo "<br>updatestring: ($this->table, $updatestring, $wherestring)<br>";
$this_query=$this->db->update($this->table,$updatestring,$wherestring);
@@ -255,6 +255,7 @@ function load($id=0, $idname=NULL) // option to override idname useful when cros
{
//echo "<p>id: $id</p>";
$idname = !$idname ? $this->idname : $idname;
+ if (stristr($id,'load_file')) exit;
if (dbRowObject::$debug) echo "<p>SELECT * FROM {$this->table} WHERE {$idname}=$id</p>";
$res=$this->db->query("SELECT * FROM {$this->table} WHERE {$idname}=$id");
@@ -278,7 +279,7 @@ function load($id=0, $idname=NULL) // option to override idname useful when cros
function loadWhere($wherestring) // lower level, more general load op can use arbitrary conditions
{
-
+ if (stristr($wherestring,'load_file')) exit;
if (dbRowObject::$debug) echo "<p>SELECT * FROM {$this->table} WHERE $wherestring</p>";
$res=$this->db->query("SELECT * FROM {$this->table} WHERE $wherestring");
View
29 core/classes/dynamicTemplate.class.php
@@ -25,7 +25,9 @@ class TemplateTable
"shortName" => "VARCHAR(255)",
"code" => "BLOB",
"category" => "VARCHAR(128)",
- "helpString" => "BLOB"
+ "helpString" => "BLOB",
+ "hasChanged" => "TINYINT(1) default 0",
+ "lastChange" => "timestamp"
);
@@ -146,7 +148,7 @@ function authEnableEditMode($session=null)
return true;
}
- if ($_POST['fb_sig_added']) {
+ if (isset($_POST['fb_sig_added']) AND $_POST['fb_sig_added']==1) {
$fbId=$_POST['fb_sig_user'];
} else {
$fbId=$_POST['fb_sig_canvas_user'];
@@ -214,27 +216,22 @@ function fetchDBTemplateHelpString($templateShortName) // just load it, no defin
}
-
function useDBTemplate($templateShortName, $templateDefaultCode, $templateHelpString = '', $refreshPage = false, $category='', $ajaxEdit=true)
{
-
if (!$this->dbtemplates)
$this->loadDBTemplates();
- if (array_key_exists($templateShortName, $this->dbtemplates))//($this->dbtemplates[$templateShortName]<>'')
- $code= $this->dbtemplates[$templateShortName]['code'];
- else
- {
+ if (array_key_exists($templateShortName, $this->dbtemplates)){ //($this->dbtemplates[$templateShortName]<>'')
+ $code= $this->dbtemplates[$templateShortName]['code'];
+ } else {
$code= $templateDefaultCode;
// add to db and update loaded templates
$this->updateAddDBTemplate($templateShortName, $templateDefaultCode, $templateHelpString, $category);
- }
-
+ }
if ($this->editEnabled && ($ajaxEdit || $this->forceAjaxEdit))
- $code = $this->wrapCodeForEditMode($code, $templateShortName, $templateHelpString, $refreshPage);
-
+ $code = $this->wrapCodeForEditMode($code, $templateShortName, $templateHelpString, $refreshPage);
return $code;
-
}
+
function loadDBTemplates()
{
$tt = new TemplateTable($this->db);
@@ -244,21 +241,21 @@ function loadDBTemplates()
function updateAddDBTemplate($shortName, $code,$helpString='', $category='')
{
- if (/*ENABLE_TEMPLATE_EDITS &&*/ $this->editEnabled) // extra auth check to make sure this isnt being invoked by an unauthorized user
+ if (/*ENABLE_TEMPLATE_EDITS &&*/ $this->editEnabled OR defined('NO_CACHE')) // extra auth check to make sure this isnt being invoked by an unauthorized user
{
$tt = new TemplateTable($this->db);
$to = $tt->getRowObject();
$to->shortName = $shortName;
$to->code = $code;
+ $to->lastChange=time();
if ($helpString <>'') $to->helpString = $helpString;
if ($category <> '') $to->category = $category;
if ($to->loadWhere("shortName='$shortName'"))
{
$to->code=$code;
$to->update();
} else
- $to->insert();
-
+ $to->insert();
}
}
View
1 core/classes/featuredTemplate.class.php
@@ -25,6 +25,7 @@ class FeaturedTemplateTable
"story_4_id" => "INT unsigned default 0",
"story_5_id" => "INT unsigned default 0",
"story_6_id" => "INT unsigned default 0",
+ "t" => "timestamp"
);
static $keydefinitions = array();
View
2 core/classes/feed.class.php
@@ -1 +1 @@
-<?php
+<?php
View
33 core/classes/forum.class.php
@@ -26,7 +26,8 @@ class ForumTopicsTable
"intro" => "TEXT default ''",
"lastChanged" => "DATETIME",
"numPostsToday" => "INT(4) default 0",
- "numViewsToday" => "INT(4) default 0"
+ "numViewsToday" => "INT(4) default 0",
+ "isHidden" => "TINYINT(1) default 0"
);
static $keydefinitions = array();
@@ -63,15 +64,29 @@ static function createTable($manageObj)
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
- function testPopulate()
+ function initialize()
{
-
- $Forum = $this->getRowObject();
- $Forum->title = 'Rescue a cute animal from a politically incorrect predicament';
- $Forum->pointValue = 100;
- $Forum->dateStart = date('Y-m-d H:i:s', time());
- if (!self::checkForumExistsByTitle($Forum->title)) $Forum->insert();
-
+ // initialize first topic if none exist
+ $chkDup=$this->db->queryC("SELECT ".self::$idname." FROM ".self::$tablename);
+ if ($chkDup===false) {
+ $Forum = $this->getRowObject();
+ $Forum->title = 'General';
+ $Forum->intro = 'Talk about anything related to '.SITE_TOPIC;
+ $Forum->numPostsToday = 0;
+ $Forum->numViewsToday = 0;
+ $Forum->lastChanged=date('Y-m-d H:i:s', time());
+ $Forum->insert();
+ }
+ $chkDup=$this->db->queryC("SELECT ".self::$idname." FROM ".self::$tablename." WHERE title='Feedback';");
+ if ($chkDup===false) {
+ $Forum = $this->getRowObject();
+ $Forum->title = 'Feedback';
+ $Forum->intro = 'Please share your feedback with us for '.SITE_TITLE;
+ $Forum->numPostsToday = 0;
+ $Forum->numViewsToday = 0;
+ $Forum->lastChanged=date('Y-m-d H:i:s', time());
+ $Forum->insert();
+ }
}
View
179 core/classes/home.class.php
@@ -33,23 +33,23 @@ function fetchHomePage($currentPage=1) {
$startRow=($currentPage-1)*ROWS_PER_PAGE;
$q = $this->templateObj->db->query("SELECT * FROM FeaturedTemplate WHERE id = 1");
$data=$this->db->readQ($q);
- $excludeStr=' AND NOT FIND_IN_SET(siteContentId,\''.$data->story_1_id.','.$data->story_2_id.','.$data->story_3_id.','.$data->story_4_id.','.$data->story_5_id.','.$data->story_6_id.'\')';
- $this->templateObj->db->result=$this->templateObj->db->query("SELECT SQL_CALC_FOUND_ROWS Content.*, UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid) WHERE date<now() AND date > date_sub(NOW(), INTERVAL ".AGE_TOP_STORY_MAX_HOUR." HOUR) AND isBlocked = 0 $excludeStr ORDER BY score DESC LIMIT $startRow,".ROWS_PER_PAGE.";");
+ $excludeStr=' AND NOT FIND_IN_SET(Content.siteContentId,\''.$data->story_1_id.','.$data->story_2_id.','.$data->story_3_id.','.$data->story_4_id.','.$data->story_5_id.','.$data->story_6_id.'\')';
+ $this->templateObj->db->result=$this->templateObj->db->query("SELECT SQL_CALC_FOUND_ROWS Content.*,ContentImages.url as imageUrl,UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid) LEFT JOIN ContentImages ON (ContentImages.siteContentId=Content.siteContentId) WHERE Content.date<now() AND Content.date > date_sub(NOW(), INTERVAL ".AGE_TOP_STORY_MAX_HOUR." HOUR) AND isBlocked = 0 $excludeStr ORDER BY score DESC LIMIT $startRow,".ROWS_PER_PAGE.";");
//$this->db->log("SELECT SQL_CALC_FOUND_ROWS Content.*, UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid) WHERE date<now() AND date > date_sub(NOW(), INTERVAL ".AGE_TOP_STORY_MAX_HOUR." HOUR) AND isBlocked = 0 $excludeStr ORDER BY score DESC LIMIT $startRow,".ROWS_PER_PAGE.";");
$this->templateObj->db->setTemplateCallback('submitBy', array($this->templateObj, 'submitBy'), 'postedByName');
$this->templateObj->db->setTemplateCallback('caption', array($this->templateObj, 'cleanString'), array('caption', 130));
- $this->templateObj->db->setTemplateCallback('storyImage', array($this->templateObj, 'getStoryImage'), 'imageid');
+ $this->templateObj->db->setTemplateCallback('storyImage', array($this->templateObj, 'getStoryImageUrl'), 'imageUrl');
$this->templateObj->db->setTemplateCallback('cmdVote', array($this->templateObj, 'commandVote'), 'siteContentId');
$this->templateObj->db->setTemplateCallback('cmdComment', array($this->templateObj, 'commandComment'), 'siteContentId');
$this->templateObj->db->setTemplateCallback('mbrLink', array($this->templateObj, 'memberLink'), 'postedById');
$this->templateObj->db->setTemplateCallback('mbrImage', array($this->templateObj, 'memberImage'), 'postedById');
$this->templateObj->db->setTemplateCallback('timeSince', array($this->utilObj, 'time_since'), 'date');
if ($this->templateObj->db->countQ($this->templateObj->db->result)<5) {
// if not enough stories, increase max hour - do this once
- $this->templateObj->db->result=$this->templateObj->db->query("SELECT SQL_CALC_FOUND_ROWS Content.*, UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid) WHERE date<now() AND date > date_sub(NOW(), INTERVAL ".(2*AGE_TOP_STORY_MAX_HOUR)." HOUR) AND isBlocked = 0 $excludeStr ORDER BY score DESC LIMIT $startRow,".ROWS_PER_PAGE.";");
+ $this->templateObj->db->result=$this->templateObj->db->query("SELECT SQL_CALC_FOUND_ROWS Content.*,ContentImages.url as imageUrl,UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid) LEFT JOIN ContentImages ON (ContentImages.siteContentId=Content.siteContentId) WHERE Content.date<now() AND Content.date > date_sub(NOW(), INTERVAL ".(2*AGE_TOP_STORY_MAX_HOUR)." HOUR) AND isBlocked = 0 $excludeStr ORDER BY score DESC LIMIT $startRow,".ROWS_PER_PAGE.";");
if ($this->templateObj->db->countQ($this->templateObj->db->result)<3) {
// if still too few, check in last week
- $this->templateObj->db->result=$this->templateObj->db->query("SELECT SQL_CALC_FOUND_ROWS Content.*, UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid) WHERE date<now() AND date > date_sub(NOW(), INTERVAL 7 DAY) AND isBlocked = 0 $excludeStr ORDER BY score DESC LIMIT $startRow,".ROWS_PER_PAGE.";");
+ $this->templateObj->db->result=$this->templateObj->db->query("SELECT SQL_CALC_FOUND_ROWS Content.*,ContentImages.url as imageUrl,UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid) LEFT JOIN ContentImages ON (ContentImages.siteContentId=Content.siteContentId) WHERE Content.date<now() AND Content.date > date_sub(NOW(), INTERVAL 7 DAY) AND isBlocked = 0 $excludeStr ORDER BY score DESC LIMIT $startRow,".ROWS_PER_PAGE.";");
}
}
//$this->templateObj->db->setTemplateCallback('cmdAdd', array($this->templateObj, 'commandAdd'), 'siteContentId');
@@ -60,12 +60,150 @@ function fetchHomePage($currentPage=1) {
return $code;
}
+ function fetchAskQuestions(&$page=NULL) {
+ $x=rand(0,100);
+ if ($x<50) {
+ $mode='recent';
+ $title='Recent Questions';
+ $cacheName='home_askRecent';
+ } else {
+ $mode='popular';
+ $title='Popular Questions';
+ $cacheName='home_askPopular';
+ }
+ if ($this->templateObj->checkCache($cacheName,30)) {
+ // still current, get from cache
+ $code=$this->templateObj->fetchCache($cacheName);
+ } else {
+ require_once(PATH_FACEBOOK.'/classes/ask.class.php');
+ $askObj=new ask($this->db,$this->templateObj);
+ $code='';
+ $code.='<div class="panel_1">';
+ $code.=$page->buildPanelBar($title,'<span class="pipe">|</span><a href="?p=ask&o=browse" onclick="switchPage(\'ask\',\'browse\');return false;">See all</a>','Questions asked by '.SITE_TITLE.' members');
+ $code.='<div id="storyList">';
+ $code.=$askObj->listQuestions($mode,0,0,0,3);
+ $code.='</div><!-- end storyList -->';
+ $code.='</div><!--end "panel_1"-->';
+ $this->templateObj->cacheContent($cacheName,$code);
+ }
+ return $code;
+ }
+
+ function fetchIdeas(&$page=NULL) {
+ $x=rand(0,100);
+ if ($x<50) {
+ $mode='recent';
+ $title='Recent Ideas';
+ $cacheName='home_ideasRecent';
+ } else {
+ $mode='popular';
+ $title='Popular Ideas';
+ $cacheName='home_ideasPopular';
+ }
+ if ($this->templateObj->checkCache($cacheName,30)) {
+ // still current, get from cache
+ $code=$this->templateObj->fetchCache($cacheName);
+ } else {
+ require_once(PATH_FACEBOOK.'/classes/ideas.class.php');
+ $iObj=new ideas($this->db,$this->templateObj);
+ $code='';
+ $code.='<div class="panel_1">';
+ $code.=$page->buildPanelBar($title,'<span class="pipe">|</span><a href="?p=ideas" onclick="switchPage(\'ideas\');return false;">See all</a>','Ideas suggested by '.SITE_TITLE.' members');
+ $code.='<div id="storyList">';
+ $code.=$iObj->listIdeas($mode,0,0,0,3);
+ $code.='</div><!-- end storyList -->';
+ $code.='</div><!--end "panel_1"-->';
+ $this->templateObj->cacheContent($cacheName,$code);
+ }
+ return $code;
+ }
+
+ function fetchMicro(&$page=NULL) {
+ $mode='recent';
+ $title='Recent Tweets about '.SITE_TOPIC;
+ $cacheName='home_microRecent';
+ if ($this->templateObj->checkCache($cacheName,10)) {
+ // still current, get from cache
+ $code=$this->templateObj->fetchCache($cacheName);
+ } else {
+ require_once(PATH_FACEBOOK.'/classes/micro.class.php');
+ $mObj=new micro($this->db,$this->templateObj);
+ $code='';
+ $code.='<div class="panel_1">';
+ $code.=$page->buildPanelBar($title,'<span class="pipe">|</span><a href="?p=tweets" onclick="switchPage(\'micro\');return false;">Visit our '.SITE_TOPIC.' tweet summary</a>');
+ $code.='<div id="storyList">';
+ $code.=$mObj->homeList();
+ $code.='</div><!-- end storyList -->';
+ $code.='</div><!--end "panel_1"-->';
+ $this->templateObj->cacheContent($cacheName,$code);
+ }
+ return $code;
+ }
+
+ function fetchStuff(&$page=NULL,$limit=7) {
+ // fetches image bar of recent items
+ $cacheName='home_recentStuff';
+ if ($this->templateObj->checkCache($cacheName,120)) {
+ // still current, get from cache
+ $code=$this->templateObj->fetchCache($cacheName);
+ } else {
+ $temp='';
+ if (defined('SITE_LOCAL')) {
+ $q=$this->db->queryC("SELECT Items.id,title,tagid,raw_tag,imageUrl FROM stuff.Items LEFT JOIN stuff.Tags ON tagid=Tags.id LEFT JOIN stuff.Access ON Access.itemid=Items.id WHERE isHidden=0 AND status='available' AND accessType='site' AND accessid=".RESEARCH_SITE_ID." AND imageUrl<>'' ORDER BY dt DESC LIMIT $limit;");
+ } else {
+ $q=$this->db->queryC("SELECT Items.id,title,tagid,raw_tag,imageUrl FROM stuff.Items LEFT JOIN stuff.Tags ON tagid=Tags.id WHERE isHidden=0 AND status='available' AND imageUrl<>'' AND isFriendsOnly=0 ORDER BY dt DESC LIMIT $limit;");
+ }
+ if ($q!==false) {
+ $temp.='<div class="imageStrip" >';
+ $temp.='<div class="imageStripPanel">';
+ while ($data=$this->db->readQ($q)) {
+ $temp.='<a href="?p=things&o=view&id='.$data->id.'"><img title="'.$data->title.'" alt="'.$data->title.' in '.$data->raw_tag.'" src="'.$data->imageUrl.'"></a>';
+ }
+ $temp.='</div><!-- end imageStripPanel --></div><!-- end imageStrip --><br clear="both" />';
+ $code='<div class="panel_1">';
+ $code.=$page->buildPanelBar('Recent '.SITE_STUFF_TITLE,'<span class="pipe">|</span><a href="?p=things" onclick="switchPage(\'things\');return false;">See all</a>','Items available at '.SITE_TITLE);
+ $code.=$temp;
+ $code.='</div><!--end "panel_1"-->';
+ $this->templateObj->cacheContent($cacheName,$code);
+ }
+ }
+ return $code;
+ }
+
+ function fetchImages(&$page=NULL,$limit=7) {
+ // fetches image bar of recent photos
+ $cacheName='home_recentImages';
+ if ($this->templateObj->checkCache($cacheName,120)) {
+ // still current, get from cache
+ $code=$this->templateObj->fetchCache($cacheName);
+ } else {
+ $temp='';
+ $q=$this->db->queryC("SELECT * FROM FeedMedia WHERE previewImageUrl<>'' AND t>date_sub(NOW(),INTERVAL ".(defined('MEDIA_INTERVAL')?MEDIA_INTERVAL:"2")." DAY) ORDER BY RAND() DESC LIMIT $limit;");
+ if ($q!==false) {
+ $temp.='<div class="imageStrip" >';
+ $temp.='<div class="imageStripPanel">';
+ while ($data=$this->db->readQ($q)) {
+ $temp.='<a href="?p=media&media=image&id='.$data->id.'"><img title="'.$data->title.' by '.$data->author.'" alt="'.$data->title.' by '.$data->author.'" src="'.$data->previewImageUrl.'"></a>';
+ }
+ $temp.='</div><!-- end imageStripPanel --></div><!-- end imageStrip --><br clear="both" />';
+ $code='<div class="panel_1">';
+ $code.=$page->buildPanelBar('Recent Photos',(defined('ENABLE_MEDIA_PROFILE')?'<span class="pipe">|</span><a href="?p=media&o=pro" onclick="switchPage(\'media\',\'pro\');return false;">Customize your profile pic</a>':'').'<span class="pipe">|</span><a href="?p=media" onclick="switchPage(\'media\',\'view\');return false;">See all</a>','Images related to '.SITE_TOPIC);
+ $code.=$temp;
+ $code.='</div><!--end "panel_1"-->';
+ $this->templateObj->cacheContent($cacheName,$code);
+ }
+ }
+ return $code;
+ }
+
function fetchFeature() {
$cacheName='home_feature';
if ($this->templateObj->checkCache($cacheName,60)) {
// still current, get from cache
$code=$this->templateObj->fetchCache($cacheName);
} else {
+ /*
+ confused - why is this function embedded here? jr
function getImageUrl($imageid = 0, $size = 'large') {
$largeImageWidth = "185";
$largeImageHeight = "130";
@@ -74,10 +212,12 @@ function getImageUrl($imageid = 0, $size = 'large') {
if ($imageid == 0 || !($size == 'large' || $size == 'small'))
return URL_CALLBACK.'?p=cache&img=watermark.jpg';
else
- return sprintf("http://www.newscloud.com/images/scaleImage.php?id=%s&x=%s&y=%s&fixed=x&crop", $imageid, ${$size.'ImageWidth'}, ${$size.'ImageHeight'});
+ return sprintf("{URL_BASE}/index.php?p=scaleImg&id=%s&x=%s&y=%s&fixed=x&crop", $imageid, ${$size.'ImageWidth'}, ${$size.'ImageHeight'});
}
+ */
require_once(PATH_CORE.'/classes/utilities.class.php');
$this->utilObj=new utilities($this->db);
+ define ("LENGTH_CAPTION",250);
include PATH_TEMPLATES.'/featuredStories.php';
//$this->templateObj->registerTemplates(MODULE_ACTIVE, 'featuredStories');
$this->templateObj->db->result = $this->templateObj->db->query("SELECT * FROM FeaturedTemplate WHERE id = 1");
@@ -90,7 +230,7 @@ function getImageUrl($imageid = 0, $size = 'large') {
if (preg_match('/^story_([0-9]+)_id$/', $field))
$story_ids[] = $value;
$stories = array();
- $story_results = $this->db->query("SELECT * FROM Content WHERE siteContentId IN (".join(',', $story_ids).") ORDER BY FIND_IN_SET(siteContentId, '".join(',', $story_ids)."')");
+ $story_results = $this->db->query("SELECT Content.*,ContentImages.url as imageUrl FROM Content LEFT JOIN ContentImages ON Content.siteContentId=ContentImages.siteContentId WHERE Content.siteContentId IN (".join(',', $story_ids).") ORDER BY FIND_IN_SET(Content.siteContentId, '".join(',', $story_ids)."')");
while ($story = mysql_fetch_assoc($story_results))
$stories[] = $story;
//$code='<div id="featurePanel"><div id="featuredStories">';
@@ -126,6 +266,31 @@ function fetchPromo() {
return $code;
}
+ function buildFeedbackBox(&$page=NULL,$isAjax=false) {
+ $code='';
+ $cacheName='home_feedback';
+ if ($this->templateObj->checkCache($cacheName,1440)) {
+ // still current, get from cache
+ $code=$this->templateObj->fetchCache($cacheName);
+ } else {
+ $code='<div class="panel_1">';
+ $q=$this->db->queryC("SELECT id FROM ForumTopics WHERE title='Feedback';");
+ if ($q===false) return false;
+ $d=$this->db->readQ($q);
+ $q=$this->db->queryC("SELECT fbId FROM User LEFT JOIN UserInfo ON User.userid=UserInfo.userid WHERE isAdmin=1 LIMIT 1;");
+ $d2=$this->db->readQ($q);
+ $code.=$page->buildPanelBar('Give us your feedback','<span class="pipe">|</span><a href="?p=wall&topic='.$d->id.'">See all</a>','');
+ $temp='<fb:comments xid="'.CACHE_PREFIX.'_wall_'.$d->id.'" canpost="true" candelete="true" numposts="1" showform="false" send_notification_uid="'.$d2->fbId.'" />';
+ $this->db->log($temp);
+ $code.=$temp;
+ $code.='</div><!--end "panel_1"-->';
+ if (!$isAjax) {
+ $code='<div id="feedbackBox">'.$code.'</div>';
+ }
+ $this->templateObj->cacheContent($cacheName,$code);
+ }
+ return $code;
+ }
}
?>
View
14 core/classes/images.class.php
@@ -3,11 +3,15 @@
class images {
var $db;
- function __construct() {
- // do nothing
- require_once (PATH_CORE.'/classes/db.class.php');
- $this->db=new cloudDatabase();
- }
+ function __construct(&$db=NULL)
+ {
+ if (is_null($db))
+ {
+ require_once (PATH_CORE.'/classes/db.class.php');
+ $this->db=new cloudDatabase();
+ } else
+ $this->db=$db;
+ }
function fetchImage() {
/* Image server for an image for the story */
View
88 core/classes/log.class.php
@@ -49,14 +49,13 @@ class LogTable
static $fields = array(
"userid1" => "BIGINT(20)default 0",
- "action" => // NOTE: see mysql docs about ALTER ... MODIFY and enums before attempting to change the spelling of any fields. you will corrupt the existing data!
+ "action" => // IMPORTANT NOTE: see mysql docs about ALTER ... MODIFY and enums before attempting to change the spelling of any fields. you will corrupt the existing data!
"ENUM('vote','comment',
'readStory','readWire','invite','postStory','publishWire',
'publishStory','shareStory','referReader','referToSite',
'postTwitter', 'signup', 'acceptedInvite',
'redeemed', 'wonPrize', 'completedChallenge', 'addedWidget', 'addedFeedHeadlines',
- 'friendSignup', 'addBookmarkTool',
- 'levelIncrease','sessionsRecent','sessionsHour','pageAdd','chatStory','postBlog'
+ 'friendSignup', 'addBookmarkTool', 'levelIncrease','sessionsRecent','sessionsHour','pageAdd','chatStory','postBlog','sendCard','askQuestion','answerQuestion','likeQuestion','likeAnswer','likeIdea','likeStuff','addStuff','storyFeatured','madePredict'
) default 'readStory'",
"itemid" => "INT(11) default 0",
"itemid2" => "INT(11) default 0",
@@ -116,6 +115,64 @@ function testPopulate()
}
+class LogExtraRow extends dbRowObject
+{
+
+}
+
+
+class LogExtraTable
+{
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////
+ // standard table fields
+ var $db;
+ static $tablename="LogExtra";
+ static $idname = "id";
+ static $idtype = "BIGINT(20) unsigned NOT NULL auto_increment";
+ static $dbRowObjectClass = "LogExtraRow";
+
+ static $fields = array(
+ "logid" => "BIGINT(20)default 0",
+ "txt" => "TEXT default ''"
+ );
+ static $keydefinitions = array();
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////
+ // standard table functions
+ function __construct(&$db=NULL)
+ {
+ if (is_null($db))
+ {
+ require_once('db.class.php');
+ $this->db=new cloudDatabase();
+ } else
+ $this->db=$db;
+ }
+ // although many functions will be duplicated between table subclasses, having a parent class gets too messy
+ function getRowObject()
+ {
+ $classname = self::$dbRowObjectClass;
+ return new $classname($this->db, self::$tablename, array_keys(self::$fields), self::$idname);
+ }
+
+ // generic table creation routine, same for all *Table classes
+ static function createTable($manageObj)
+ {
+ $manageObj->addTable(self::$tablename,self::$idname,self::$idtype,"MyISAM");
+ foreach (array_keys(self::$fields) as $key)
+ {
+ $manageObj->updateAddColumn(self::$tablename,$key,self::$fields[$key]);
+ }
+ foreach (self::$keydefinitions as $keydef)
+ {
+ $manageObj->updateAddKey(self::$tablename,$keydef[0], $keydef[1], $keydef[2], $keydef[3]);
+ }
+ }
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////
+
+}
+
class log {
@@ -140,6 +197,13 @@ function fetch($id) {
$data=$this->db->read();
return $data;
}
+
+ function fetchExtra($id) {
+ // return log item as a data object
+ $this->db->query("SELECT Log.*,LogExtra.txt FROM Log LEFT JOIN LogExtra ON Log.id=LogExtra.logid WHERE Log.id=$id;");
+ $data=$this->db->read();
+ return $data;
+ }
function transmit($timestamp=0,$limit=25) {
require_once('utilities.class.php');
@@ -331,15 +395,15 @@ function receive($rx='') {
// process log result and perform appropriate actions
// process vote results
$votes=$resp['votes'];
- if (count($votes)>0) {
+ if (count($votes)>0 AND is_array($votes)) {
foreach ($votes as $item) {
$this->processResultStatus($item[logid],$item[result]);
$msg.=$item[logid].'->'.$item[result].'<br />';
}
}
// process comment results
$comments=$resp['comments'];
- if (count($comments)>0) {
+ if (count($comments)>0 AND is_array($comments)) {
foreach ($comments as $item) {
$this->processResultStatus($item[logid],$item[result]);
// sync NC commentid
@@ -351,23 +415,23 @@ function receive($rx='') {
}
// process readStory results
$readStory=$resp['readStory'];
- if (count($readStory)>0) {
+ if (count($readStory)>0 AND is_array($readStory)) {
foreach ($readStory as $item) {
$this->processResultStatus($item[logid],$item[result]);
$msg.=$item[logid].'->'.$item[result].'<br />';
}
}
// process pubStory results
$pubStory=$resp['pubStory'];
- if (count($pubStory)>0) {
+ if (count($pubStory)>0 AND is_array($pubStory)) {
foreach ($pubStory as $item) {
$this->processResultStatus($item[logid],$item[result]);
$msg.=$item[logid].'->'.$item[result].'<br />';
}
}
// process postStory results
$postStory=$resp['postStory'];
- if (count($postStory)>0) {
+ if (count($postStory)>0 AND is_array($postStory)) {
foreach ($postStory as $item) {
$contentid=$item[contentid];
$imageid=$item[imageid];
@@ -381,7 +445,7 @@ function receive($rx='') {
}
// process pubWire results
$pubWire=$resp['pubWire'];
- if (count($pubWire)>0) {
+ if (count($pubWire)>0 AND is_array($pubWire)) {
foreach ($pubWire as $item) {
$siteContentId=$item[siteContentId];
$contentid=$item[contentid];
@@ -395,7 +459,7 @@ function receive($rx='') {
// process registered users
$newUsers=$resp['newUsers'];
- if (count($newUsers)>0) {
+ if (count($newUsers)>0 AND is_array($newUsers)) {
foreach ($newUsers as $item) {
$userid=$item[userid];
$ncUid=$item[ncUid];
@@ -409,7 +473,7 @@ function receive($rx='') {
// process level changes
$msg.='<h3>User Level Changes</h3>';
$levelChanges=$resp['levelChanges'];
- if (count($levelChanges)>0) {
+ if (count($levelChanges)>0 AND is_array($levelChanges)) {
foreach ($levelChanges as $item) {
$this->processResultStatus($item[logid],$item[result]);
$msg.=$item[logid].'->'.$item[result].'<br />';
@@ -435,7 +499,6 @@ function serialize($id=0,$userid1=0,$action='',$itemid=0,$userid2=0,$itemid2=0)
$data->itemid=$itemid;
$data->userid2=$userid2;
$data->itemid2=$itemid2;
-
return $data;
}
@@ -444,7 +507,6 @@ function add($log) {
$this->checkSubmitSiteChallenge($log);
}
-
function update($log) {
if ($debug) $this->db->log( 'loginfo: <pre>'.print_r($log, true). '</pre>');
// update Log row in db from data object
View
38 core/classes/newswire.class.php
@@ -27,10 +27,10 @@ function getWebpage($id=0) {
function add($wire) {
// check for duplicate
- $chkDup=$this->db->queryC("SELECT id FROM Newswire WHERE url='$wire->url';");
+ $chkDup=$this->db->queryC("SELECT id FROM Newswire WHERE url='$wire->url' AND feedType='$wire->feedType';");
if (!$chkDup) {
// insert the story into the table
- $this_query=$this->db->insert("Newswire","title,caption,source,url,date,wireid,feedType","'$wire->title','$wire->caption','$wire->source','$wire->url','$wire->date',$wire->wireid,'$wire->feedType'");
+ $this_query=$this->db->insert("Newswire","title,caption,source,url,date,wireid,feedType,feedid","'$wire->title','$wire->caption','$wire->source','$wire->url','$wire->date',$wire->wireid,'$wire->feedType',$wire->feedid");
$newId=$this->db->getId();
return $newId;
} else
@@ -41,26 +41,36 @@ function createTempContent($userinfo=NULL,$wireid=0) {
require_once(PATH_CORE.'/classes/content.class.php');
$cObj=new content($this->db);
$info=$this->getWireStory($wireid);
+ require_once(PATH_CORE.'/classes/parseStory.class.php');
+ $psObj = new parseStory();
+ require_once(PATH_CORE.'/classes/utilities.class.php');
+ $this->utilObj=new utilities($this->db);
+ $info->title=stripslashes($info->title);
+ $info->caption=stripslashes($this->utilObj->shorten($info->caption));
+ // to do - replace proxy feed urls with final redirect
+ $info->title=$psObj->cleanTitle($info->title);
// create permalink
$info->permalink=$cObj->buildPermalink($info->title);
- $this->db->log($info->permalink);