Facebook PHP Source Code from August 2007


SUBMITTED BY: Guest

DATE: Nov. 29, 2013, 9:39 p.m.

FORMAT: Text only

SIZE: 18.9 kB

HITS: 988

  1. <? php
  2. include_once $_SERVER['PHP_ROOT'].'/html/init.php';
  3. include_once $_SERVER['PHP_ROOT'].'/lib/home.php';
  4. include_once $_SERVER['PHP_ROOT'].'/lib/requests.php';
  5. include_once $_SERVER['PHP_ROOT'].'/lib/feed/newsfeed.php';
  6. include_once $_SERVER['PHP_ROOT'].'/lib/poke.php';
  7. include_once $_SERVER['PHP_ROOT'].'/lib/share.php';
  8. include_once $_SERVER['PHP_ROOT'].'/lib/orientation.php';
  9. include_once $_SERVER['PHP_ROOT'].'/lib/feed/newsfeed.php';
  10. include_once $_SERVER['PHP_ROOT'].'/lib/mobile/register.php';
  11. include_once $_SERVER['PHP_ROOT'].'/lib/forms_lib.php';
  12. include_once $_SERVER['PHP_ROOT'].'/lib/contact_importer/contact_importer.php';
  13. include_once $_SERVER['PHP_ROOT'].'/lib/feed/util.php';
  14. include_once $_SERVER['PHP_ROOT'].'/lib/hiding_prefs.php';
  15. include_once $_SERVER['PHP_ROOT'].'/lib/abtesting.php';
  16. include_once $_SERVER['PHP_ROOT'].'/lib/friends.php';
  17. include_once $_SERVER['PHP_ROOT'].'/lib/statusupdates.php';
  18. // lib/display/feed.php has to be declared here for scope issues.
  19. // This keeps display/feed.php cleaner and easier to understand.
  20. include_once $_SERVER['PHP_ROOT'].'/lib/display/feed.php';
  21. include_once $_SERVER['PHP_ROOT'].'/lib/monetization_box.php';
  22. // require login
  23. $user = require_login();
  24. print_time('require_login');
  25. param_request(array('react' = > $PARAM_EXISTS));
  26. // Check and fix broken emails
  27. // LN - disabling due to excessive can_see dirties and sets when enabled.
  28. //check_and_fix_broken_emails($user);
  29. // migrate AIM screenname from profile to screenname table if needed
  30. migrate_screenname($user);
  31. // homepage announcement variables
  32. $HIDE_ANNOUNCEMENT_BIT = get_site_variable('HIDE_ANNOUNCEMENT_BIT');
  33. $HIDE_INTRO_BITMASK = get_site_variable('HIDE_INTRO_BITMASK');
  34. // redirects
  35. if (is_sponsor_user()) {
  36. redirect('bizhome.php', 'www');
  37. }
  38. include_once $_SERVER['PHP_ROOT'].'/lib/mesg.php';
  39. include_once $_SERVER['PHP_ROOT'].'/lib/invitetool.php';
  40. include_once $_SERVER['PHP_ROOT'].'/lib/grammar.php';
  41. include_once $_SERVER['PHP_ROOT'].'/lib/securityq.php';
  42. include_once $_SERVER['PHP_ROOT'].'/lib/events.php';
  43. include_once $_SERVER['PHP_ROOT'].'/lib/rooster/stories.php';
  44. // todo: password confirmation redirects here (from html/reset.php),
  45. // do we want a confirmation message?
  46. param_get_slashed(array(
  47. 'feeduser' = > $PARAM_INT, //debug: gets feed for user here
  48. 'err' = > $PARAM_STRING, // returning from a failed entry on an orientation form
  49. 'error' = > $PARAM_STRING, // an error can also be here because the profile photo upload code is crazy
  50. 'ret' = > $PARAM_INT, 'success' = > $PARAM_INT, // successful profile picture upload
  51. 'jn' = > $PARAM_INT, // joined a network for orientation
  52. 'np' = > $PARAM_INT, // network pending (for work/address network)
  53. 'me' = > $PARAM_STRING, // mobile error
  54. 'mr' = > $PARAM_EXISTS, // force mobile reg view
  55. 'mobile' = > $PARAM_EXISTS, // mobile confirmation code sent
  56. 'jif' = > $PARAM_EXISTS, // just imported friends
  57. 'ied' = > $PARAM_STRING, // import email domain
  58. 'o' = > $PARAM_EXISTS, // first time orientation, passed on confirm
  59. 'verified' = > $PARAM_EXISTS)); // verified mobile phone
  60. param_post(array(
  61. 'leave_orientation' = > $PARAM_EXISTS,
  62. 'show_orientation' = > $PARAM_INT, // show an orientation step
  63. 'hide_orientation' = > $PARAM_INT)); // skip an orientation step
  64. // homepage actions
  65. if ($req_react && validate_expiring_hash($req_react, $GLOBALS['url_md5key'])) {
  66. $show_reactivated_message = true;
  67. } else {
  68. $show_reactivated_message = false;
  69. }
  70. tpl_set('show_reactivated_message', $show_reactivated_message);
  71. // upcoming events
  72. events_check_future_events($user); // make sure big tunas haven't moved around
  73. $upcoming_events = events_get_imminent_for_user($user);
  74. // this is all stuff that can be fetched together!
  75. $upcoming_events_short = array();
  76. obj_multiget_short(array_keys($upcoming_events), true, $upcoming_events_short);
  77. $new_pokes = 0;
  78. //only get the next N pokes for display
  79. //where N is set in the dbget to avoid caching issues
  80. $poke_stats = get_num_pokes($user);
  81. get_next_pokes($user, true, $new_pokes);
  82. $poke_count = $poke_stats['unseen'];
  83. $targeted_data = array();
  84. home_get_cache_targeted_data($user, true, $targeted_data);
  85. $announcement_data = array();
  86. home_get_cache_announcement_data($user, true, $announcement_data);
  87. $orientation = 0;
  88. orientation_get_status($user, true, $orientation);
  89. $short_profile = array();
  90. profile_get_short($user, true, $short_profile);
  91. // pure priming stuff
  92. privacy_get_network_settings($user, true);
  93. $presence = array();
  94. mobile_get_presence_data($user, true, $presence);
  95. feedback_get_event_weights($user, true);
  96. // Determine if we want to display the feed intro message
  97. $intro_settings = 0;
  98. user_get_hide_intro_bitmask($user, true, $intro_settings);
  99. $user_friend_finder = true;
  100. contact_importer_get_used_friend_finder($user, true, $used_friend_finder);
  101. $all_requests = requests_get_cache_data($user);
  102. // FIXME?: is it sub-optimal to call this both in requests_get_cache_data and here?
  103. $friends_status = statusupdates_get_recent($user, null, 3);
  104. memcache_dispatch(); // populate cache data
  105. // Merman's Admin profile always links to the Merman's home
  106. if (user_has_obj_attached($user)) {
  107. redirect('mhome.php', 'www');
  108. }
  109. if (is_array($upcoming_events)) {
  110. foreach($upcoming_events as $event_id = > $data) {
  111. $upcoming_events[$event_id]['name'] = txt_set($upcoming_events_short[$event_id]['name']);
  112. }
  113. }
  114. tpl_set('upcoming_events', $upcoming_events);
  115. // disabled account actions
  116. $disabled_warning = ((IS_DEV_SITE || IS_QA_SITE) && is_disabled_user($user));
  117. tpl_set('disabled_warning', $disabled_warning);
  118. // new pokes (no more messages here, they are in the top nav!)
  119. if (!user_is_guest($user)) {
  120. tpl_set('poke_count', $poke_count);
  121. tpl_set('pokes', $new_pokes);
  122. }
  123. // get announcement computations
  124. tpl_set('targeted_data', $targeted_data);
  125. tpl_set('announcement_data', $announcement_data);
  126. // birthday notifications
  127. tpl_set('birthdays', $birthdays = user_get_birthday_notifications($user, $short_profile));
  128. tpl_set('show_birthdays', $show_birthdays = (count($birthdays) || !$orientation));
  129. // user info
  130. tpl_set('first_name', user_get_first_name(txt_set($short_profile['id'])));
  131. tpl_set('user', $user);
  132. // decide if there are now any requests to show
  133. $show_requests = false;
  134. foreach($all_requests as $request_category) {
  135. if ($request_category) {
  136. $show_requests = true;
  137. break;
  138. }
  139. }
  140. tpl_set('all_requests', $show_requests ? $all_requests : null);
  141. $permissions = privacy_get_reduced_network_permissions($user, $user);
  142. // status
  143. $user_info = array('user' = > $user, 'firstname' = > user_get_first_name($user), 'see_all' = > '/statusupdates/?ref=hp', 'profile_pic' = > make_profile_image_src_direct($user, 'thumb'), 'square_pic' = > make_profile_image_src_direct($user, 'square'));
  144. if (!empty($presence) && $presence['status_time'] > (time() - 60 * 60 * 24 * 7)) {
  145. $status = array('message' = > txt_set($presence['status']), 'time' = > $presence['status_time'], 'source' = > $presence['status_source']);
  146. } else {
  147. $status = array('message' = > null, 'time' = > null, 'source' = > null);
  148. }
  149. tpl_set('user_info', $user_info);
  150. tpl_set('show_status', $show_status = !$orientation);
  151. tpl_set('status', $status);
  152. tpl_set('status_custom', $status_custom = mobile_get_status_custom($user));
  153. tpl_set('friends_status', $friends_status);
  154. // orientation
  155. if ($orientation) {
  156. if ($post_leave_orientation) {
  157. orientation_update_status($user, $orientation, 2);
  158. notification_notify_exit_orientation($user);
  159. dirty_user($user);
  160. redirect('home.php');
  161. } else if (orientation_eligible_exit(array('uid' = > $user)) == 2) {
  162. orientation_update_status($user, $orientation, 1);
  163. notification_notify_exit_orientation($user);
  164. dirty_user($user);
  165. redirect('home.php');
  166. }
  167. }
  168. // timezone - outside of stealth, update user's timezone if necessary
  169. $set_time = !user_is_alpha($user, 'stealth');
  170. tpl_set('timezone_autoset', $set_time);
  171. if ($set_time) {
  172. $daylight_savings = get_site_variable('DAYLIGHT_SAVINGS_ON');
  173. tpl_set('timezone', $short_profile['timezone'] - ($daylight_savings ? 4 : 5));
  174. }
  175. // set next step if we can
  176. if (!$orientation) {
  177. user_set_next_step($user, $short_profile);
  178. }
  179. // note: don't make this an else with the above statement, because then no news feed stories will be fetched if they're exiting orientation
  180. if ($orientation) {
  181. extract(orientation_get_const());
  182. require_js('js/dynamic_dialog.js');
  183. require_js('js/suggest.js');
  184. require_js('js/typeahead_ns.js');
  185. require_js('js/suggest.js');
  186. require_js('js/editregion.js');
  187. require_js('js/orientation.js');
  188. require_css('css/typeahead.css');
  189. require_css('css/editor.css');
  190. if ($post_hide_orientation && $post_hide_orientation <= $ORIENTATION_MAX) {
  191. $orientation['orientation_bitmask'] |= ($post_hide_orientation * $ORIENTATION_SKIPPED_MODIFIER);
  192. orientation_update_status($user, $orientation);
  193. } else if ($post_show_orientation && $post_show_orientation <= $ORIENTATION_MAX) {
  194. $orientation['orientation_bitmask'] &= ~ ($post_show_orientation * $ORIENTATION_SKIPPED_MODIFIER);
  195. orientation_update_status($user, $orientation);
  196. }
  197. $stories = orientation_get_stories($user, $orientation);
  198. switch ($get_err) {
  199. case $ORIENTATION_ERR_COLLEGE:
  200. $temp = array(); // the affil_retval_msg needs some parameters won't be used
  201. $stories[$ORIENTATION_NETWORK]['failed_college'] = affil_retval_msg($get_ret, $temp, $temp);
  202. break;
  203. case $ORIENTATION_ERR_CORP:
  204. $temp = array();
  205. // We special case the network not recognized error here, because affil_retval_msg is retarded.
  206. $stories[$ORIENTATION_NETWORK]['failed_corp'] = ($get_ret == 70) ? 'The email you entered did not match any of our supported networks. '.'Click here to see our supported list. '.'Go here to suggest your network for the future.' : affil_retval_msg($get_ret, $temp, $temp);
  207. break;
  208. }
  209. // photo upload error
  210. if ($get_error) {
  211. $stories[$ORIENTATION_ORDER[$ORIENTATION_PROFILE]]['upload_error'] = pic_get_error_text($get_error);
  212. }
  213. // photo upload success
  214. else if ($get_success == 1) {
  215. $stories[$ORIENTATION_ORDER[$ORIENTATION_PROFILE]]['uploaded_pic'] = true;
  216. // join network success
  217. } else if ($get_jn) {
  218. $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['joined'] = array('id' = > $get_jn, 'name' = > network_get_name($get_jn));
  219. // network join pending
  220. } else if ($get_np) {
  221. $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['join_pending'] = array('id' = > $get_np, 'email' = > get_affil_email_conf($user, $get_np), 'network' = > network_get_name($get_np));
  222. // just imported friend confirmation
  223. } else if ($get_jif) {
  224. $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['just_imported_friends'] = true;
  225. $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['domain'] = $get_ied;
  226. }
  227. // Mobile web API params
  228. if ($get_mobile) {
  229. $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['sent_code'] = true;
  230. $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['view'] = 'confirm';
  231. }
  232. if ($get_verified) {
  233. $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['verified'] = true;
  234. }
  235. if ($get_me) {
  236. $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['error'] = $get_me;
  237. }
  238. if ($get_mr) {
  239. $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['view'] = 'register';
  240. }
  241. if (orientation_eligible_exit($orientation)) {
  242. tpl_set('orientation_show_exit', true);
  243. }
  244. tpl_set('orientation_stories', $stories);
  245. //if in orientation, we hide all feed intros (all 1's in bitmask)
  246. $intro_settings = -1;
  247. }
  248. tpl_set('orientation', $orientation);
  249. // Rooster Stories
  250. if (!$orientation && ((get_site_variable('ROOSTER_ENABLED') == 2) || (get_site_variable('ROOSTER_DEV_ENABLED') == 2))) {
  251. $rooster_story_count = get_site_variable('ROOSTER_STORY_COUNT');
  252. if (!isset($rooster_story_count)) {
  253. // Set default if something is wrong with the sitevar
  254. $rooster_story_count = 2;
  255. }
  256. $rooster_stories = rooster_get_stories($user, $rooster_story_count, $log_omissions = true);
  257. if (!empty($rooster_stories) && !empty($rooster_stories['stories'])) {
  258. // Do page-view level logging here
  259. foreach($rooster_stories['stories'] as $story) {
  260. rooster_log_action($user, $story, ROOSTER_LOG_ACTION_VIEW);
  261. }
  262. tpl_set('rooster_stories', $rooster_stories);
  263. }
  264. }
  265. // set the variables for the home announcement code
  266. $hide_announcement_tpl = ($intro_settings | $HIDE_INTRO_BITMASK) & $HIDE_ANNOUNCEMENT_BIT;
  267. // if on qa/dev site, special rules
  268. $HIDE_INTRO_ON_DEV = get_site_variable('HIDE_INTRO_ON_DEV');
  269. if ((IS_QA_SITE || IS_DEV_SITE) && !$HIDE_INTRO_ON_DEV) {
  270. $hide_announcement_tpl = 0;
  271. }
  272. tpl_set('hide_announcement', $hide_announcement_tpl);
  273. if ($is_candidate = is_candidate_user($user)) {
  274. tpl_set('hide_announcement', false);
  275. }
  276. $home_announcement_tpl = !$hide_announcement_tpl || $is_candidate ? home_get_announcement_info($user) : 0;
  277. tpl_set('home_announcement', $home_announcement_tpl);
  278. tpl_set('hide_announcement_bit', $HIDE_ANNOUNCEMENT_BIT);
  279. $show_friend_finder = !$orientation && contact_importer_enabled($user) && !user_get_hiding_pref($user, 'home_friend_finder');
  280. tpl_set('show_friend_finder', $show_friend_finder);
  281. if ($show_friend_finder && (user_get_friend_count($user) > 20)) {
  282. tpl_set('friend_finder_hide_options', array('text' = > 'close', 'onclick' = > "return clearFriendFinder()"));
  283. } else {
  284. tpl_set('friend_finder_hide_options', null);
  285. }
  286. $account_info = user_get_account_info($user);
  287. $account_create_time = $account_info['time'];
  288. tpl_set('show_friend_finder_top', !$used_friend_finder);
  289. tpl_set('user', $user);
  290. // MONETIZATION BOX
  291. $minimize_monetization_box = user_get_hiding_pref($user, 'home_monetization');
  292. $show_monetization_box = (!$orientation && get_site_variable('HOMEPAGE_MONETIZATION_BOX'));
  293. tpl_set('show_monetization_box', $show_monetization_box);
  294. tpl_set('minimize_monetization_box', $minimize_monetization_box);
  295. if ($show_monetization_box) {
  296. $monetization_box_data = monetization_box_user_get_data($user);
  297. txt_set('monetization_box_data', $monetization_box_data);
  298. }
  299. // ORIENTATION
  300. if ($orientation) {
  301. $network_ids = id_get_networks($user);
  302. $network_names = multiget_network_name($network_ids);
  303. $in_corp_network = in_array($GLOBALS['TYPE_CORP'], array_map('extract_network_type', $network_ids));
  304. $show_corp_search = $in_corp_network || get_age(user_get_basic_info_attr($user, 'birthday')) >= 21;
  305. $pending_hs = is_hs_pending_user($user);
  306. $hs_id = null;
  307. $hs_name = null;
  308. if ($pending_hs) {
  309. foreach(id_get_pending_networks($user) as $network) {
  310. if (extract_network_type($network['network_key']) == $GLOBALS['TYPE_HS']) {
  311. $hs_id = $network['network_key'];
  312. $hs_name = network_get_name($hs_id);
  313. break;
  314. }
  315. }
  316. }
  317. //$orientation_people = orientation_get_friend_and_inviter_ids($user);
  318. $orientation_people = array('friends' = > user_get_all_friends($user), 'pending' = > array_keys(user_get_friend_requests($user)), 'inviters' = > array(), // wc: don't show inviters for now
  319. );
  320. $orientation_info = array_merge($orientation_people, array('network_names' = > $network_names, 'show_corp_search' = > $show_corp_search, 'pending_hs' = > array('hs_id' = > $hs_id, 'hs_name' = > $hs_name), 'user' = > $user, ));
  321. tpl_set('orientation_info', $orientation_info);
  322. tpl_set('simple_orientation_first_login', $get_o); // unused right now
  323. }
  324. // Roughly determine page length for ads
  325. // first, try page length using right-hand panel
  326. $ads_page_length_data = 3 + // 3 for profile pic + next step
  327. ($show_friend_finder ? 1 : 0) + ($show_status ? ($status_custom ? count($friends_status) : 0) : 0) + ($show_monetization_box ? 1 : 0) + ($show_birthdays ? count($birthdays) : 0) + count($new_pokes);
  328. // page length using feed stories
  329. if ($orientation) {
  330. $ads_page_length_data = max($ads_page_length_data, count($stories) * 5);
  331. }
  332. tpl_set('ads_page_length_data', $ads_page_length_data);
  333. $feed_stories = null;
  334. if (!$orientation) { // if they're not in orientation they get other cool stuff
  335. // ad_insert: the ad type to try to insert for the user
  336. // (0 if we don't want to try an insert)
  337. $ad_insert = get_site_variable('FEED_ADS_ENABLE_INSERTS');
  338. $feed_off = false;
  339. if (check_super($user) && $get_feeduser) {
  340. $feed_stories = user_get_displayable_stories($get_feeduser, 0, null, $ad_insert);
  341. } else if (can_see($user, $user, 'feed')) {
  342. $feed_stories = user_get_displayable_stories($user, 0, null, $ad_insert);
  343. } else {
  344. $feed_off = true;
  345. }
  346. // Friend's Feed Selector - Requires dev.php constant
  347. if (is_friendfeed_user($user)) {
  348. $friendfeed = array();
  349. $friendfeed['feeduser'] = $get_feeduser;
  350. $friendfeed['feeduser_name'] = user_get_name($get_feeduser);
  351. $friendfeed['friends'] = user_get_all_friends($user);
  352. tpl_set('friendfeed', $friendfeed);
  353. }
  354. $feed_stories = feed_adjust_timezone($user, $feed_stories);
  355. tpl_set('feed_off', $feed_off ? redirect('privacy.php?view=feeds', null, false) : false);
  356. }
  357. tpl_set('feed_stories', $feed_stories);
  358. render_template($_SERVER['PHP_ROOT'].'/html/home.phpt');

comments powered by Disqus