SHOW:
|
|
- or go back to the newest paste.
| 1 | A hacker found a way to expose the PHP source code on www.facebook.com. | |
| 2 | ||
| 3 | The two files are index.php (the homepage) and search.php (the search page) | |
| 4 | ||
| 5 | This are the source code of it. | |
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | * INDEX (index.php) : | |
| 10 | ---------------------- | |
| 11 | ||
| 12 | ||
| 13 | <? php | |
| 14 | ||
| 15 | include_once $_SERVER['PHP_ROOT'].'/html/init.php'; | |
| 16 | include_once $_SERVER['PHP_ROOT'].'/lib/home.php'; | |
| 17 | include_once $_SERVER['PHP_ROOT'].'/lib/requests.php'; | |
| 18 | include_once $_SERVER['PHP_ROOT'].'/lib/feed/newsfeed.php'; | |
| 19 | include_once $_SERVER['PHP_ROOT'].'/lib/poke.php'; | |
| 20 | include_once $_SERVER['PHP_ROOT'].'/lib/share.php'; | |
| 21 | include_once $_SERVER['PHP_ROOT'].'/lib/orientation.php'; | |
| 22 | include_once $_SERVER['PHP_ROOT'].'/lib/feed/newsfeed.php'; | |
| 23 | include_once $_SERVER['PHP_ROOT'].'/lib/mobile/register.php'; | |
| 24 | include_once $_SERVER['PHP_ROOT'].'/lib/forms_lib.php'; | |
| 25 | include_once $_SERVER['PHP_ROOT'].'/lib/contact_importer/contact_importer.php'; | |
| 26 | include_once $_SERVER['PHP_ROOT'].'/lib/feed/util.php'; | |
| 27 | include_once $_SERVER['PHP_ROOT'].'/lib/hiding_prefs.php'; | |
| 28 | include_once $_SERVER['PHP_ROOT'].'/lib/abtesting.php'; | |
| 29 | include_once $_SERVER['PHP_ROOT'].'/lib/friends.php'; | |
| 30 | include_once $_SERVER['PHP_ROOT'].'/lib/statusupdates.php'; | |
| 31 | ||
| 32 | // lib/display/feed.php has to be declared here for scope issues. | |
| 33 | // This keeps display/feed.php cleaner and easier to understand. | |
| 34 | include_once $_SERVER['PHP_ROOT'].'/lib/display/feed.php'; | |
| 35 | include_once $_SERVER['PHP_ROOT'].'/lib/monetization_box.php'; | |
| 36 | ||
| 37 | // require login | |
| 38 | $user = require_login(); | |
| 39 | print_time('require_login');
| |
| 40 | param_request(array('react' = > $PARAM_EXISTS));
| |
| 41 | ||
| 42 | // Check and fix broken emails | |
| 43 | // LN - disabling due to excessive can_see dirties and sets when enabled. | |
| 44 | //check_and_fix_broken_emails($user); | |
| 45 | // migrate AIM screenname from profile to screenname table if needed | |
| 46 | migrate_screenname($user); | |
| 47 | ||
| 48 | // homepage announcement variables | |
| 49 | $HIDE_ANNOUNCEMENT_BIT = get_site_variable('HIDE_ANNOUNCEMENT_BIT');
| |
| 50 | $HIDE_INTRO_BITMASK = get_site_variable('HIDE_INTRO_BITMASK');
| |
| 51 | ||
| 52 | // redirects | |
| 53 | if (is_sponsor_user()) {
| |
| 54 | redirect('bizhome.php', 'www');
| |
| 55 | } | |
| 56 | ||
| 57 | include_once $_SERVER['PHP_ROOT'].'/lib/mesg.php'; | |
| 58 | include_once $_SERVER['PHP_ROOT'].'/lib/invitetool.php'; | |
| 59 | include_once $_SERVER['PHP_ROOT'].'/lib/grammar.php'; | |
| 60 | include_once $_SERVER['PHP_ROOT'].'/lib/securityq.php'; | |
| 61 | include_once $_SERVER['PHP_ROOT'].'/lib/events.php'; | |
| 62 | include_once $_SERVER['PHP_ROOT'].'/lib/rooster/stories.php'; | |
| 63 | ||
| 64 | // todo: password confirmation redirects here (from html/reset.php), | |
| 65 | // do we want a confirmation message? | |
| 66 | param_get_slashed(array( | |
| 67 | 'feeduser' = > $PARAM_INT, //debug: gets feed for user here | |
| 68 | 'err' = > $PARAM_STRING, // returning from a failed entry on an orientation form | |
| 69 | 'error' = > $PARAM_STRING, // an error can also be here because the profile photo upload code is crazy | |
| 70 | 'ret' = > $PARAM_INT, 'success' = > $PARAM_INT, // successful profile picture upload | |
| 71 | 'jn' = > $PARAM_INT, // joined a network for orientation | |
| 72 | 'np' = > $PARAM_INT, // network pending (for work/address network) | |
| 73 | 'me' = > $PARAM_STRING, // mobile error | |
| 74 | 'mr' = > $PARAM_EXISTS, // force mobile reg view | |
| 75 | 'mobile' = > $PARAM_EXISTS, // mobile confirmation code sent | |
| 76 | 'jif' = > $PARAM_EXISTS, // just imported friends | |
| 77 | 'ied' = > $PARAM_STRING, // import email domain | |
| 78 | 'o' = > $PARAM_EXISTS, // first time orientation, passed on confirm | |
| 79 | 'verified' = > $PARAM_EXISTS)); // verified mobile phone | |
| 80 | ||
| 81 | param_post(array( | |
| 82 | 'leave_orientation' = > $PARAM_EXISTS, | |
| 83 | 'show_orientation' = > $PARAM_INT, // show an orientation step | |
| 84 | 'hide_orientation' = > $PARAM_INT)); // skip an orientation step | |
| 85 | ||
| 86 | // homepage actions | |
| 87 | if ($req_react && validate_expiring_hash($req_react, $GLOBALS['url_md5key'])) {
| |
| 88 | $show_reactivated_message = true; | |
| 89 | } else {
| |
| 90 | $show_reactivated_message = false; | |
| 91 | } | |
| 92 | tpl_set('show_reactivated_message', $show_reactivated_message);
| |
| 93 | ||
| 94 | ||
| 95 | // upcoming events | |
| 96 | events_check_future_events($user); // make sure big tunas haven't moved around | |
| 97 | $upcoming_events = events_get_imminent_for_user($user); | |
| 98 | ||
| 99 | // this is all stuff that can be fetched together! | |
| 100 | $upcoming_events_short = array(); | |
| 101 | obj_multiget_short(array_keys($upcoming_events), true, $upcoming_events_short); | |
| 102 | $new_pokes = 0; | |
| 103 | ||
| 104 | //only get the next N pokes for display | |
| 105 | //where N is set in the dbget to avoid caching issues | |
| 106 | $poke_stats = get_num_pokes($user); | |
| 107 | get_next_pokes($user, true, $new_pokes); | |
| 108 | $poke_count = $poke_stats['unseen']; | |
| 109 | ||
| 110 | $targeted_data = array(); | |
| 111 | home_get_cache_targeted_data($user, true, $targeted_data); | |
| 112 | $announcement_data = array(); | |
| 113 | home_get_cache_announcement_data($user, true, $announcement_data); | |
| 114 | $orientation = 0; | |
| 115 | orientation_get_status($user, true, $orientation); | |
| 116 | $short_profile = array(); | |
| 117 | profile_get_short($user, true, $short_profile); | |
| 118 | ||
| 119 | // pure priming stuff | |
| 120 | privacy_get_network_settings($user, true); | |
| 121 | $presence = array(); | |
| 122 | mobile_get_presence_data($user, true, $presence); | |
| 123 | feedback_get_event_weights($user, true); | |
| 124 | ||
| 125 | // Determine if we want to display the feed intro message | |
| 126 | $intro_settings = 0; | |
| 127 | user_get_hide_intro_bitmask($user, true, $intro_settings); | |
| 128 | $user_friend_finder = true; | |
| 129 | contact_importer_get_used_friend_finder($user, true, $used_friend_finder); | |
| 130 | $all_requests = requests_get_cache_data($user); | |
| 131 | ||
| 132 | // FIXME?: is it sub-optimal to call this both in requests_get_cache_data and here? | |
| 133 | $friends_status = statusupdates_get_recent($user, null, 3); | |
| 134 | memcache_dispatch(); // populate cache data | |
| 135 | ||
| 136 | // Merman's Admin profile always links to the Merman's home | |
| 137 | if (user_has_obj_attached($user)) {
| |
| 138 | redirect('mhome.php', 'www');
| |
| 139 | } | |
| 140 | ||
| 141 | if (is_array($upcoming_events)) {
| |
| 142 | foreach($upcoming_events as $event_id = > $data) {
| |
| 143 | $upcoming_events[$event_id]['name'] = txt_set($upcoming_events_short[$event_id]['name']); | |
| 144 | } | |
| 145 | } | |
| 146 | ||
| 147 | tpl_set('upcoming_events', $upcoming_events);
| |
| 148 | ||
| 149 | // disabled account actions | |
| 150 | $disabled_warning = ((IS_DEV_SITE || IS_QA_SITE) && is_disabled_user($user)); | |
| 151 | tpl_set('disabled_warning', $disabled_warning);
| |
| 152 | ||
| 153 | // new pokes (no more messages here, they are in the top nav!) | |
| 154 | if (!user_is_guest($user)) {
| |
| 155 | tpl_set('poke_count', $poke_count);
| |
| 156 | tpl_set('pokes', $new_pokes);
| |
| 157 | } | |
| 158 | ||
| 159 | // get announcement computations | |
| 160 | tpl_set('targeted_data', $targeted_data);
| |
| 161 | tpl_set('announcement_data', $announcement_data);
| |
| 162 | ||
| 163 | ||
| 164 | // birthday notifications | |
| 165 | tpl_set('birthdays', $birthdays = user_get_birthday_notifications($user, $short_profile));
| |
| 166 | tpl_set('show_birthdays', $show_birthdays = (count($birthdays) || !$orientation));
| |
| 167 | ||
| 168 | // user info | |
| 169 | tpl_set('first_name', user_get_first_name(txt_set($short_profile['id'])));
| |
| 170 | tpl_set('user', $user);
| |
| 171 | ||
| 172 | // decide if there are now any requests to show | |
| 173 | $show_requests = false; | |
| 174 | foreach($all_requests as $request_category) {
| |
| 175 | if ($request_category) {
| |
| 176 | $show_requests = true; | |
| 177 | break; | |
| 178 | } | |
| 179 | } | |
| 180 | tpl_set('all_requests', $show_requests ? $all_requests : null);
| |
| 181 | ||
| 182 | $permissions = privacy_get_reduced_network_permissions($user, $user); | |
| 183 | ||
| 184 | // status | |
| 185 | $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'));
| |
| 186 | ||
| 187 | if (!empty($presence) && $presence['status_time'] > (time() - 60 * 60 * 24 * 7)) {
| |
| 188 | $status = array('message' = > txt_set($presence['status']), 'time' = > $presence['status_time'], 'source' = > $presence['status_source']);
| |
| 189 | } else {
| |
| 190 | $status = array('message' = > null, 'time' = > null, 'source' = > null);
| |
| 191 | } | |
| 192 | tpl_set('user_info', $user_info);
| |
| 193 | ||
| 194 | ||
| 195 | ||
| 196 | ||
| 197 | ||
| 198 | ||
| 199 | ||
| 200 | ||
| 201 | ||
| 202 | tpl_set('show_status', $show_status = !$orientation);
| |
| 203 | tpl_set('status', $status);
| |
| 204 | tpl_set('status_custom', $status_custom = mobile_get_status_custom($user));
| |
| 205 | tpl_set('friends_status', $friends_status);
| |
| 206 | ||
| 207 | // orientation | |
| 208 | if ($orientation) {
| |
| 209 | if ($post_leave_orientation) {
| |
| 210 | orientation_update_status($user, $orientation, 2); | |
| 211 | notification_notify_exit_orientation($user); | |
| 212 | dirty_user($user); | |
| 213 | redirect('home.php');
| |
| 214 | } else if (orientation_eligible_exit(array('uid' = > $user)) == 2) {
| |
| 215 | orientation_update_status($user, $orientation, 1); | |
| 216 | notification_notify_exit_orientation($user); | |
| 217 | dirty_user($user); | |
| 218 | redirect('home.php');
| |
| 219 | } | |
| 220 | } | |
| 221 | ||
| 222 | // timezone - outside of stealth, update user's timezone if necessary | |
| 223 | $set_time = !user_is_alpha($user, 'stealth'); | |
| 224 | tpl_set('timezone_autoset', $set_time);
| |
| 225 | if ($set_time) {
| |
| 226 | $daylight_savings = get_site_variable('DAYLIGHT_SAVINGS_ON');
| |
| 227 | tpl_set('timezone', $short_profile['timezone'] - ($daylight_savings ? 4 : 5));
| |
| 228 | } | |
| 229 | ||
| 230 | // set next step if we can | |
| 231 | if (!$orientation) {
| |
| 232 | user_set_next_step($user, $short_profile); | |
| 233 | } | |
| 234 | ||
| 235 | // 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 | |
| 236 | if ($orientation) {
| |
| 237 | extract(orientation_get_const()); | |
| 238 | ||
| 239 | require_js('js/dynamic_dialog.js');
| |
| 240 | require_js('js/suggest.js');
| |
| 241 | require_js('js/typeahead_ns.js');
| |
| 242 | require_js('js/suggest.js');
| |
| 243 | require_js('js/editregion.js');
| |
| 244 | require_js('js/orientation.js');
| |
| 245 | require_css('css/typeahead.css');
| |
| 246 | require_css('css/editor.css');
| |
| 247 | ||
| 248 | if ($post_hide_orientation && $post_hide_orientation <= $ORIENTATION_MAX) {
| |
| 249 | $orientation['orientation_bitmask'] |= ($post_hide_orientation * $ORIENTATION_SKIPPED_MODIFIER); | |
| 250 | orientation_update_status($user, $orientation); | |
| 251 | } else if ($post_show_orientation && $post_show_orientation <= $ORIENTATION_MAX) {
| |
| 252 | $orientation['orientation_bitmask'] &= ~ ($post_show_orientation * $ORIENTATION_SKIPPED_MODIFIER); | |
| 253 | orientation_update_status($user, $orientation); | |
| 254 | } | |
| 255 | ||
| 256 | $stories = orientation_get_stories($user, $orientation); | |
| 257 | switch ($get_err) {
| |
| 258 | case $ORIENTATION_ERR_COLLEGE: | |
| 259 | $temp = array(); // the affil_retval_msg needs some parameters won't be used | |
| 260 | $stories[$ORIENTATION_NETWORK]['failed_college'] = affil_retval_msg($get_ret, $temp, $temp); | |
| 261 | break; | |
| 262 | case $ORIENTATION_ERR_CORP: | |
| 263 | $temp = array(); | |
| 264 | // We special case the network not recognized error here, because affil_retval_msg is retarded. | |
| 265 | $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); | |
| 266 | break; | |
| 267 | } | |
| 268 | ||
| 269 | // photo upload error | |
| 270 | if ($get_error) {
| |
| 271 | $stories[$ORIENTATION_ORDER[$ORIENTATION_PROFILE]]['upload_error'] = pic_get_error_text($get_error); | |
| 272 | } | |
| 273 | // photo upload success | |
| 274 | else if ($get_success == 1) {
| |
| 275 | $stories[$ORIENTATION_ORDER[$ORIENTATION_PROFILE]]['uploaded_pic'] = true; | |
| 276 | // join network success | |
| 277 | } else if ($get_jn) {
| |
| 278 | $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['joined'] = array('id' = > $get_jn, 'name' = > network_get_name($get_jn));
| |
| 279 | // network join pending | |
| 280 | } else if ($get_np) {
| |
| 281 | ||
| 282 | $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));
| |
| 283 | // just imported friend confirmation | |
| 284 | } else if ($get_jif) {
| |
| 285 | $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['just_imported_friends'] = true; | |
| 286 | $stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['domain'] = $get_ied; | |
| 287 | } | |
| 288 | ||
| 289 | // Mobile web API params | |
| 290 | if ($get_mobile) {
| |
| 291 | $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['sent_code'] = true; | |
| 292 | $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['view'] = 'confirm'; | |
| 293 | } | |
| 294 | if ($get_verified) {
| |
| 295 | $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['verified'] = true; | |
| 296 | } | |
| 297 | if ($get_me) {
| |
| 298 | $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['error'] = $get_me; | |
| 299 | } | |
| 300 | if ($get_mr) {
| |
| 301 | $stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['view'] = 'register'; | |
| 302 | } | |
| 303 | ||
| 304 | if (orientation_eligible_exit($orientation)) {
| |
| 305 | tpl_set('orientation_show_exit', true);
| |
| 306 | } | |
| 307 | tpl_set('orientation_stories', $stories);
| |
| 308 | ||
| 309 | //if in orientation, we hide all feed intros (all 1's in bitmask) | |
| 310 | $intro_settings = -1; | |
| 311 | ||
| 312 | } | |
| 313 | tpl_set('orientation', $orientation);
| |
| 314 | ||
| 315 | // Rooster Stories | |
| 316 | if (!$orientation && ((get_site_variable('ROOSTER_ENABLED') == 2) || (get_site_variable('ROOSTER_DEV_ENABLED') == 2))) {
| |
| 317 | $rooster_story_count = get_site_variable('ROOSTER_STORY_COUNT');
| |
| 318 | if (!isset($rooster_story_count)) {
| |
| 319 | // Set default if something is wrong with the sitevar | |
| 320 | $rooster_story_count = 2; | |
| 321 | } | |
| 322 | $rooster_stories = rooster_get_stories($user, $rooster_story_count, $log_omissions = true); | |
| 323 | if (!empty($rooster_stories) && !empty($rooster_stories['stories'])) {
| |
| 324 | // Do page-view level logging here | |
| 325 | foreach($rooster_stories['stories'] as $story) {
| |
| 326 | rooster_log_action($user, $story, ROOSTER_LOG_ACTION_VIEW); | |
| 327 | } | |
| 328 | tpl_set('rooster_stories', $rooster_stories);
| |
| 329 | } | |
| 330 | } | |
| 331 | ||
| 332 | // set the variables for the home announcement code | |
| 333 | $hide_announcement_tpl = ($intro_settings | $HIDE_INTRO_BITMASK) & $HIDE_ANNOUNCEMENT_BIT; | |
| 334 | // if on qa/dev site, special rules | |
| 335 | $HIDE_INTRO_ON_DEV = get_site_variable('HIDE_INTRO_ON_DEV');
| |
| 336 | if ((IS_QA_SITE || IS_DEV_SITE) && !$HIDE_INTRO_ON_DEV) {
| |
| 337 | $hide_announcement_tpl = 0; | |
| 338 | } | |
| 339 | ||
| 340 | tpl_set('hide_announcement', $hide_announcement_tpl);
| |
| 341 | if ($is_candidate = is_candidate_user($user)) {
| |
| 342 | tpl_set('hide_announcement', false);
| |
| 343 | } | |
| 344 | $home_announcement_tpl = !$hide_announcement_tpl || $is_candidate ? home_get_announcement_info($user) : 0; | |
| 345 | tpl_set('home_announcement', $home_announcement_tpl);
| |
| 346 | tpl_set('hide_announcement_bit', $HIDE_ANNOUNCEMENT_BIT);
| |
| 347 | ||
| 348 | $show_friend_finder = !$orientation && contact_importer_enabled($user) && !user_get_hiding_pref($user, 'home_friend_finder'); | |
| 349 | tpl_set('show_friend_finder', $show_friend_finder);
| |
| 350 | if ($show_friend_finder && (user_get_friend_count($user) > 20)) {
| |
| 351 | tpl_set('friend_finder_hide_options', array('text' = > 'close', 'onclick' = > "return clearFriendFinder()"));
| |
| 352 | } else {
| |
| 353 | tpl_set('friend_finder_hide_options', null);
| |
| 354 | } | |
| 355 | ||
| 356 | $account_info = user_get_account_info($user); | |
| 357 | $account_create_time = $account_info['time']; | |
| 358 | ||
| 359 | tpl_set('show_friend_finder_top', !$used_friend_finder);
| |
| 360 | ||
| 361 | tpl_set('user', $user);
| |
| 362 | ||
| 363 | ||
| 364 | // MONETIZATION BOX | |
| 365 | $minimize_monetization_box = user_get_hiding_pref($user, 'home_monetization'); | |
| 366 | $show_monetization_box = (!$orientation && get_site_variable('HOMEPAGE_MONETIZATION_BOX'));
| |
| 367 | tpl_set('show_monetization_box', $show_monetization_box);
| |
| 368 | tpl_set('minimize_monetization_box', $minimize_monetization_box);
| |
| 369 | ||
| 370 | if ($show_monetization_box) {
| |
| 371 | $monetization_box_data = monetization_box_user_get_data($user); | |
| 372 | txt_set('monetization_box_data', $monetization_box_data);
| |
| 373 | } | |
| 374 | ||
| 375 | ||
| 376 | // ORIENTATION | |
| 377 | if ($orientation) {
| |
| 378 | $network_ids = id_get_networks($user); | |
| 379 | $network_names = multiget_network_name($network_ids); | |
| 380 | $in_corp_network = in_array($GLOBALS['TYPE_CORP'], array_map('extract_network_type', $network_ids));
| |
| 381 | $show_corp_search = $in_corp_network || get_age(user_get_basic_info_attr($user, 'birthday')) >= 21; | |
| 382 | $pending_hs = is_hs_pending_user($user); | |
| 383 | $hs_id = null; | |
| 384 | $hs_name = null; | |
| 385 | if ($pending_hs) {
| |
| 386 | foreach(id_get_pending_networks($user) as $network) {
| |
| 387 | if (extract_network_type($network['network_key']) == $GLOBALS['TYPE_HS']) {
| |
| 388 | $hs_id = $network['network_key']; | |
| 389 | $hs_name = network_get_name($hs_id); | |
| 390 | break; | |
| 391 | } | |
| 392 | } | |
| 393 | } | |
| 394 | //$orientation_people = orientation_get_friend_and_inviter_ids($user); | |
| 395 | $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
| |
| 396 | ); | |
| 397 | $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, ));
| |
| 398 | tpl_set('orientation_info', $orientation_info);
| |
| 399 | ||
| 400 | tpl_set('simple_orientation_first_login', $get_o); // unused right now
| |
| 401 | } | |
| 402 | ||
| 403 | ||
| 404 | // Roughly determine page length for ads | |
| 405 | // first, try page length using right-hand panel | |
| 406 | $ads_page_length_data = 3 + // 3 for profile pic + next step | |
| 407 | ($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); | |
| 408 | ||
| 409 | // page length using feed stories | |
| 410 | if ($orientation) {
| |
| 411 | $ads_page_length_data = max($ads_page_length_data, count($stories) * 5); | |
| 412 | } | |
| 413 | tpl_set('ads_page_length_data', $ads_page_length_data);
| |
| 414 | ||
| 415 | $feed_stories = null; | |
| 416 | if (!$orientation) { // if they're not in orientation they get other cool stuff
| |
| 417 | // ad_insert: the ad type to try to insert for the user | |
| 418 | // (0 if we don't want to try an insert) | |
| 419 | $ad_insert = get_site_variable('FEED_ADS_ENABLE_INSERTS');
| |
| 420 | ||
| 421 | $feed_off = false; | |
| 422 | ||
| 423 | if (check_super($user) && $get_feeduser) {
| |
| 424 | $feed_stories = user_get_displayable_stories($get_feeduser, 0, null, $ad_insert); | |
| 425 | } else if (can_see($user, $user, 'feed')) {
| |
| 426 | $feed_stories = user_get_displayable_stories($user, 0, null, $ad_insert); | |
| 427 | } else {
| |
| 428 | $feed_off = true; | |
| 429 | } | |
| 430 | ||
| 431 | // Friend's Feed Selector - Requires dev.php constant | |
| 432 | if (is_friendfeed_user($user)) {
| |
| 433 | $friendfeed = array(); | |
| 434 | $friendfeed['feeduser'] = $get_feeduser; | |
| 435 | $friendfeed['feeduser_name'] = user_get_name($get_feeduser); | |
| 436 | $friendfeed['friends'] = user_get_all_friends($user); | |
| 437 | tpl_set('friendfeed', $friendfeed);
| |
| 438 | } | |
| 439 | ||
| 440 | $feed_stories = feed_adjust_timezone($user, $feed_stories); | |
| 441 | ||
| 442 | tpl_set('feed_off', $feed_off ? redirect('privacy.php?view=feeds', null, false) : false);
| |
| 443 | } | |
| 444 | tpl_set('feed_stories', $feed_stories);
| |
| 445 | ||
| 446 | render_template($_SERVER['PHP_ROOT'].'/html/home.phpt'); | |
| 447 | ||
| 448 | ||
| 449 | ||
| 450 | ||
| 451 | * SEARCH (search.php) : | |
| 452 | ------------------------- | |
| 453 | ||
| 454 | ||
| 455 | <?php | |
| 456 | /* | |
| 457 | * @author Mark Slee | |
| 458 | * | |
| 459 | * @package ubersearch | |
| 460 | */ | |
| 461 | ||
| 462 | ini_set('memory_limit', '100M'); // to be safe we are increasing the memory limit for search
| |
| 463 | ||
| 464 | include_once $_SERVER['PHP_ROOT'].'/html/init.php'; // final lib include | |
| 465 | include_once $_SERVER['PHP_ROOT'].'/lib/s.php'; | |
| 466 | include_once $_SERVER['PHP_ROOT'].'/lib/browse.php'; | |
| 467 | include_once $_SERVER['PHP_ROOT'].'/lib/events.php'; | |
| 468 | include_once $_SERVER['PHP_ROOT'].'/lib/websearch_classifier/websearch_classifier.php'; | |
| 469 | ||
| 470 | flag_allow_guest(); | |
| 471 | $user = search_require_login(); | |
| 472 | ||
| 473 | if ($_POST) {
| |
| 474 | $arr = us_flatten_checkboxes($_POST, array('ii'));
| |
| 475 | $qs = '?'; | |
| 476 | foreach($arr as $key = > $val) {
| |
| 477 | $qs. = $key.'='.urlencode($val).'&'; | |
| 478 | } | |
| 479 | $qs = substr($qs, 0, (strlen($qs) - 1)); | |
| 480 | redirect($_SERVER['PHP_SELF'].$qs); | |
| 481 | } | |
| 482 | ||
| 483 | // If they performed a classmates search, these values are | |
| 484 | // needed to pre-populate dropdowns | |
| 485 | param_get_slashed(array('hy' = > $PARAM_STRING, 'hs' = > $PARAM_INT, 'adv' = > $PARAM_EXISTS, 'events' = > $PARAM_EXISTS, 'groups' = > $PARAM_EXISTS, 'classmate' = > $PARAM_EXISTS, 'coworker' = > $PARAM_EXISTS));
| |
| 486 | $pos = strpos($get_hy, ':'); | |
| 487 | if ($pos !== false) {
| |
| 488 | $hsid = intval(substr($get_hy, 0, $pos)); | |
| 489 | $hsyear = intval(substr($get_hy, $pos + 1)); | |
| 490 | } else {
| |
| 491 | $hsid = intval($get_hs); | |
| 492 | $hsyear = null; | |
| 493 | } | |
| 494 | ||
| 495 | tpl_set('hs_id', $hsid);
| |
| 496 | tpl_set('hs_name', get_high_school($hsid));
| |
| 497 | tpl_set('hs_year', $hsyear);
| |
| 498 | tpl_set('is_advanced_search', $get_adv);
| |
| 499 | tpl_set('user', $user);
| |
| 500 | tpl_set('count_total', 0); // pre-set count_total for the sake of ads page length
| |
| 501 | ||
| 502 | // Events search calendar data | |
| 503 | param_get(array('k' = > $PARAM_HEX, 'n' = > $PARAM_SINT));
| |
| 504 | ||
| 505 | if (($get_k == search_module::get_key(SEARCH_MOD_EVENT, SEARCH_TYPE_AS))) {
| |
| 506 | ||
| 507 | $EVENTS_CAL_DAYS_AHEAD = 60; | |
| 508 | $events_begin = strftime("%Y%m01"); // first of the month
| |
| 509 | $events_end = strftime("%Y%m%d", strtotime(strftime("%m/01/%Y")) + (86400 * $EVENTS_CAL_DAYS_AHEAD));
| |
| 510 | $events_params = array('dy1' = > $events_begin, 'dy2' = > $events_end);
| |
| 511 | ||
| 512 | param_get(array('c1' = > $PARAM_INT, 'c2' = > $PARAM_INT), 'evt_');
| |
| 513 | if (isset($evt_c1)) {
| |
| 514 | $events_params['c1'] = $evt_c1; | |
| 515 | } | |
| 516 | if (isset($evt_c2)) {
| |
| 517 | $events_params['c2'] = $evt_c2; | |
| 518 | } | |
| 519 | $results = events_get_calendar($user, $get_n, $events_params); | |
| 520 | tpl_set('events_date', $results['events_date']);
| |
| 521 | } | |
| 522 | ||
| 523 | ||
| 524 | ||
| 525 | ||
| 526 | // Holy shit, is this the cleanest fucking frontend file you've ever seen?! | |
| 527 | ubersearch($_GET, $embedded = false, $template = true); | |
| 528 | ||
| 529 | // Render it | |
| 530 | render_template($_SERVER['PHP_ROOT'].'/html/s.phpt'); | |
| 531 | ||
| 532 | /** | |
| 533 | * login function for s.php | |
| 534 | * | |
| 535 | * @author Philip Fung | |
| 536 | */ | |
| 537 | ||
| 538 | function search_require_login() {
| |
| 539 | ||
| 540 | //check if user is logged in | |
| 541 | $user = require_login(true); | |
| 542 | ||
| 543 | if($user 0 && !is_unregistered($user)) { return $user; }
| |
| 544 | ||
| 545 | // this is an unregistered user | |
| 546 | param_get( | |
| 547 | array('k' = > $GLOBALS['PARAM_HEX'], // search key (used by rest of ubersearch code)
| |
| 548 | )); | |
| 549 | ||
| 550 | global $get_k; | |
| 551 | $search_key = $get_k; | |
| 552 | ||
| 553 | //Let user see event or group search if criteria are obeyed | |
| 554 | if ($search_key && (search_module::get_key_type($search_key) == SEARCH_MOD_EVENT || search_module::get_key_type($search_key) == SEARCH_MOD_GROUP) //event or group search | |
| 555 | ) {
| |
| 556 | return $user; | |
| 557 | } else {
| |
| 558 | go_home(); | |
| 559 | } | |
| 560 | } |