[PHP] facebook首页PHP源代码 2007年 →→→→→进入此内容的聊天室

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

回复 "facebook首页PHP源代码 2007年"

这儿你可以回复上面这条便签

captcha