{"id":574,"date":"2007-08-14T11:34:27","date_gmt":"2007-08-14T18:34:27","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/2007\/08\/14\/facebook-php-source-code\/"},"modified":"2007-08-14T11:34:27","modified_gmt":"2007-08-14T18:34:27","slug":"facebook-php-source-code","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/facebook-php-source-code\/","title":{"rendered":"Facebook PHP Source Code"},"content":{"rendered":"<p>Ok, so one guy got to see Facebook&#8217;s source code on his screen, probably due to some bad upgrade, lord knows why, the code appeared on his screen, he then copied and pasted it to some forums, and then Facebook lawyers were threatening him.<\/p>\n<p>Too late!, it&#8217;s all over the place. Look for it no more, see how these noobs code, its horrible&#8230; Home Page code included.<\/p>\n<p>How embarrasing man, let&#8217;s look at this line by line and make jokes or try to learn from them. Wonder what all the people that are doing Facebook apps are going to think about the style of where their code is running on top of.<\/p>\n<p><strong>HOME PAGE CODE<\/strong><\/p>\n<pre>\ninclude_once $_SERVER['PHP_ROOT'].'\/html\/init.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/home.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/requests.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/feed\/newsfeed.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/poke.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/share.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/orientation.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/feed\/newsfeed.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/mobile\/register.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/forms_lib.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/contact_importer\/contact_importer.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/feed\/util.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/hiding_prefs.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/abtesting.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/friends.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/statusupdates.php';\n\n\/\/ lib\/display\/feed.php has to be declared here for scope issues.\n\/\/ This keeps display\/feed.php cleaner and easier to understand.\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/display\/feed.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/monetization_box.php';\n\n\/\/ require login\n$user = require_login();\nprint_time('require_login');\nparam_request(array( 'react' => $PARAM_EXISTS));\n\n\/\/ Check and fix broken emails\n\/\/ LN - disabling due to excessive can_see dirties and sets when enabled.\n\/\/check_and_fix_broken_emails($user);\n\n\/\/ migrate AIM screenname from profile to screenname table if needed\nmigrate_screenname ($user);\n\n\/\/ homepage announcement variables\n$HIDE_ANNOUNCEMENT_BIT = get_site_variable('HIDE_ANNOUNCEMENT_BIT');\n$HIDE_INTRO_BITMASK = get_site_variable('HIDE_INTRO_BITMASK');\n\n\/\/ redirects\nif (is_sponsor_user()) {\nredirect('bizhome.php', 'www');\n}\n\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/mesg.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/invitetool.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/grammar.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/securityq.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/events.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/rooster\/stories.php';\n\n\/\/ todo: password confirmation redirects here (from html\/reset.php),\n\/\/ do we want a confirmation message?\n\nparam_get_slashed(array(\n'feeduser' => $PARAM_INT, \/\/debug: gets feed for user here\n'err' => $PARAM_STRING, \/\/ returning from a failed entry on an orientation form\n'error' => $PARAM_STRING, \/\/ an error can also be here because the profile photo upload code is crazy\n'ret' => $PARAM_INT,\n'success' => $PARAM_INT, \/\/ successful profile picture upload\n'jn' => $PARAM_INT, \/\/ joined a network for orientation\n'np' => $PARAM_INT, \/\/ network pending (for work\/address network)\n'me' => $PARAM_STRING, \/\/ mobile error\n'mr' => $PARAM_EXISTS, \/\/ force mobile reg view\n'mobile' => $PARAM_EXISTS, \/\/ mobile confirmation code sent\n'jif' => $PARAM_EXISTS, \/\/ just imported friends\n'ied' => $PARAM_STRING, \/\/ import email domain\n'o' => $PARAM_EXISTS, \/\/ first time orientation, passed on confirm\n'verified' => $PARAM_EXISTS)); \/\/ verified mobile phone\n\nparam_post(array(\n'leave_orientation' => $PARAM_EXISTS,\n'show_orientation' => $PARAM_INT, \/\/ show an orientation step\n'hide_orientation' => $PARAM_INT)); \/\/ skip an orientation step\n\n\/\/ homepage actions\nif ($req_react && validate_expiring_hash($req_react, $GLOBALS['url_md5key'])) {\n$show_reactivated_message = true;\n} else {\n$show_reactivated_message = false;\n}\ntpl_set('show_reactivated_message', $show_reactivated_message);\n\n\n\/\/ upcoming events\nevents_check_future_events($user); \/\/ make sure big tunas haven't moved around\n$upcoming_events = events_get_imminent_for_user($user);\n\n\/\/ this is all stuff that can be fetched together!\n$upcoming_events_short = array();\nobj_multiget_short(array_keys($upcoming_events), true, $upcoming_events_short);\n$new_pokes = 0;\n\/\/only get the next N pokes for display\n\/\/where N is set in the dbget to avoid caching issues\n$poke_stats = get_num_pokes($user);\nget_next_pokes($user, true, $new_pokes);\n$poke_count = $poke_stats['unseen'];\n\n$targeted_data = array();\nhome_get_cache_targeted_data($user, true, $targeted_data);\n$announcement_data = array();\nhome_get_cache_announcement_data($user, true, $announcement_data);\n$orientation = 0;\norientation_get_status($user, true, $orientation);\n$short_profile = array();\nprofile_get_short($user, true, $short_profile);\n\/\/ pure priming stuff\nprivacy_get_network_settings($user, true);\n$presence = array();\nmobile_get_presence_data($user, true, $presence);\nfeedback_get_event_weights($user, true);\n\/\/ Determine if we want to display the feed intro message\n$intro_settings = 0;\nuser_get_hide_intro_bitmask($user, true, $intro_settings);\n$user_friend_finder = true;\ncontact_importer_get_used_friend_finder($user, true, $used_friend_finder);\n$all_requests = requests_get_cache_data($user);\n\/\/ FIXME?: is it sub-optimal to call this both in requests_get_cache_data and here?\n$friends_status = statusupdates_get_recent($user, null, 3);\nmemcache_dispatch(); \/\/ populate cache data\n\n\/\/ Merman's Admin profile always links to the Merman's home\nif (user_has_obj_attached($user)) {\nredirect('mhome.php', 'www');\n}\n\nif (is_array($upcoming_events)) {\nforeach ($upcoming_events as $event_id => $data) {\n$upcoming_events[$event_id]['name'] = txt_set($upcoming_events_short[$event_id]['name']);\n}\n}\n\ntpl_set('upcoming_events' , $upcoming_events);\n\n\/\/ disabled account actions\n$disabled_warning = ((IS_DEV_SITE || IS_QA_SITE) && is_disabled_user($user));\ntpl_set('disabled_warning', $disabled_warning);\n\n\/\/ new pokes (no more messages here, they are in the top nav!)\nif (!user_is_guest($user)) {\ntpl_set('poke_count' , $poke_count);\ntpl_set('pokes' , $new_pokes);\n}\n\n\/\/ get announcement computations\ntpl_set('targeted_data' , $targeted_data);\ntpl_set('announcement_data' , $announcement_data);\n\n\n\/\/ birthday notifications\ntpl_set('birthdays' , $birthdays = user_get_birthday_notifications($user, $short_profile));\ntpl_set('show_birthdays' , $show_birthdays = (count($birthdays) || !$orientation));\n\n\/\/ user info\ntpl_set('first_name' , user_get_first_name(txt_set($short_profile['id'])));\ntpl_set('user' , $user);\n\n\/\/ decide if there are now any requests to show\n$show_requests = false;\nforeach ($all_requests as $request_category) {\nif ($request_category) {\n$show_requests = true;\nbreak;\n}\n}\ntpl_set('all_requests', $show_requests ? $all_requests : null);\n\n$permissions = privacy_get_reduced_network_permissions($user, $user);\n\n\/\/ status\n$user_info = array('user' => $user,\n'firstname' => user_get_first_name($user),\n'see_all' => '\/statusupdates\/?ref=hp',\n'profile_pic' => make_profile_image_src_direct($user, 'thumb'),\n'square_pic' => make_profile_image_src_direct($user, 'square'));\n\nif (!empty($presence) && $presence['status_time'] > (time() - 60*60*24*7)) {\n$status = array('message' => txt_set($presence['status']),\n'time' => $presence['status_time'],\n'source' => $presence['status_source']);\n} else {\n$status = array('message' => null, 'time' => null, 'source' => null);\n}\ntpl_set('user_info', $user_info);\n\ntpl_set('show_status', $show_status = !$orientation);\ntpl_set('status', $status);\ntpl_set('status_custom', $status_custom = mobile_get_status_custom($user));\ntpl_set('friends_status', $friends_status);\n\n\/\/ orientation\nif ($orientation) {\nif ($post_leave_orientation) {\norientation_update_status($user, $orientation, 2);\nnotification_notify_exit_orientation($user);\ndirty_user($user);\nredirect('home.php');\n} else if (orientation_eligible_exit(array('uid'=>$user)) == 2) {\norientation_update_status($user, $orientation, 1);\nnotification_notify_exit_orientation($user);\ndirty_user($user);\nredirect('home.php');\n}\n}\n\n\/\/ timezone - outside of stealth, update user's timezone if necessary\n$set_time = !user_is_alpha($user, 'stealth');\ntpl_set('timezone_autoset', $set_time );\nif ($set_time) {\n$daylight_savings = get_site_variable('DAYLIGHT_SAVINGS_ON');\ntpl_set('timezone', $short_profile['timezone'] - ($daylight_savings ? 4 : 5) );\n}\n\n\/\/ set next step if we can\nif (!$orientation) {\nuser_set_next_step($user, $short_profile);\n}\n\n\/\/ 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\nif ($orientation) {\nextract(orientation_get_const());\n\nrequire_js('js\/dynamic_dialog.js');\nrequire_js('js\/suggest.js');\nrequire_js('js\/typeahead_ns.js');\nrequire_js('js\/suggest.js');\nrequire_js('js\/editregion.js');\nrequire_js('js\/orientation.js');\nrequire_css('css\/typeahead.css');\nrequire_css('css\/editor.css');\n\nif ($post_hide_orientation && $post_hide_orientation <= $ORIENTATION_MAX) {\n$orientation['orientation_bitmask'] |= ($post_hide_orientation * $ORIENTATION_SKIPPED_MODIFIER);\norientation_update_status($user, $orientation);\n} else if ($post_show_orientation &#038;&#038; $post_show_orientation <= $ORIENTATION_MAX) {\n$orientation['orientation_bitmask'] &#038;= ~($post_show_orientation * $ORIENTATION_SKIPPED_MODIFIER);\norientation_update_status($user, $orientation);\n}\n\n$stories = orientation_get_stories($user, $orientation);\nswitch ($get_err) {\ncase $ORIENTATION_ERR_COLLEGE:\n$temp = array(); \/\/ the affil_retval_msg needs some parameters won't be used\n$stories[$ORIENTATION_NETWORK]['failed_college']=affil_retval_msg($get_ret, $temp, $temp);\nbreak;\ncase $ORIENTATION_ERR_CORP:\n$temp = array();\n\/\/ We special case the network not recognized error here, because affil_retval_msg is retarded.\n$stories[$ORIENTATION_NETWORK]['failed_corp'] = ($get_ret == 70) ? 'The email you entered did not match any of our supported networks. ' .\n'Click here to see our supported list. ' .\n'Go here to suggest your network for the future.'\n: affil_retval_msg($get_ret, $temp, $temp);\nbreak;\n}\n\n\/\/ photo upload error\nif ($get_error) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_PROFILE]]['upload_error'] = pic_get_error_text($get_error);\n}\n\/\/ photo upload success\nelse if ($get_success == 1) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_PROFILE]]['uploaded_pic'] = true;\n\/\/ join network success\n} else if ($get_jn) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['joined'] = array(\n'id' => $get_jn,\n'name' => network_get_name($get_jn));\n\/\/ network join pending\n} else if ($get_np) {\n\n$stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['join_pending'] = array(\n'id' => $get_np,\n'email' => get_affil_email_conf($user, $get_np),\n'network' => network_get_name($get_np));\n\/\/ just imported friend confirmation\n} else if ($get_jif) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['just_imported_friends'] = true;\n$stories[$ORIENTATION_ORDER[$ORIENTATION_NETWORK]]['domain'] = $get_ied;\n}\n\n\/\/ Mobile web API params\nif ($get_mobile) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['sent_code'] = true;\n$stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['view'] = 'confirm';\n}\nif ($get_verified) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['verified'] = true;\n}\nif ($get_me) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['error'] = $get_me;\n}\nif ($get_mr) {\n$stories[$ORIENTATION_ORDER[$ORIENTATION_MOBILE]]['view'] = 'register';\n}\n\nif (orientation_eligible_exit($orientation)) {\ntpl_set('orientation_show_exit', true);\n}\ntpl_set('orientation_stories', $stories);\n\n\/\/if in orientation, we hide all feed intros (all 1's in bitmask)\n$intro_settings = -1;\n\n}\ntpl_set('orientation', $orientation);\n\n\/\/ Rooster Stories\nif (!$orientation &&\n((get_site_variable('ROOSTER_ENABLED') == 2) ||\n(get_site_variable('ROOSTER_DEV_ENABLED') == 2))) {\n$rooster_story_count = get_site_variable('ROOSTER_STORY_COUNT');\nif (!isset($rooster_story_count)) {\n\/\/ Set default if something is wrong with the sitevar\n$rooster_story_count = 2;\n}\n$rooster_stories = rooster_get_stories($user, $rooster_story_count, $log_omissions = true);\nif (!empty($rooster_stories) && !empty($rooster_stories['stories'])) {\n\/\/ Do page-view level logging here\nforeach($rooster_stories['stories'] as $story) {\nrooster_log_action($user, $story, ROOSTER_LOG_ACTION_VIEW);\n}\ntpl_set('rooster_stories', $rooster_stories);\n}\n}\n\n\/\/ set the variables for the home announcement code\n$hide_announcement_tpl = ($intro_settings | $HIDE_INTRO_BITMASK) & $HIDE_ANNOUNCEMENT_BIT;\n\/\/ if on qa\/dev site, special rules\n$HIDE_INTRO_ON_DEV = get_site_variable('HIDE_INTRO_ON_DEV');\nif ((IS_QA_SITE || IS_DEV_SITE) && !$HIDE_INTRO_ON_DEV) {\n$hide_announcement_tpl = 0;\n}\n\ntpl_set('hide_announcement', $hide_announcement_tpl);\nif($is_candidate = is_candidate_user($user)) {\ntpl_set('hide_announcement', false);\n}\n$home_announcement_tpl = !$hide_announcement_tpl || $is_candidate ? home_get_announcement_info($user) : 0;\ntpl_set('home_announcement', $home_announcement_tpl);\ntpl_set('hide_announcement_bit', $HIDE_ANNOUNCEMENT_BIT);\n\n$show_friend_finder = !$orientation && contact_importer_enabled($user) && !user_get_hiding_pref($user, 'home_friend_finder');\ntpl_set('show_friend_finder', $show_friend_finder);\nif ($show_friend_finder && (user_get_friend_count($user) > 20)) {\ntpl_set('friend_finder_hide_options', array('text'=>'close',\n'onclick'=>\"return clearFriendFinder()\"));\n} else {\ntpl_set('friend_finder_hide_options', null);\n}\n\n$account_info = user_get_account_info($user);\n$account_create_time = $account_info['time'];\n\ntpl_set('show_friend_finder_top',\n!$used_friend_finder);\n\ntpl_set('user', $user);\n\n\n\/\/ MONETIZATION BOX\n$minimize_monetization_box = user_get_hiding_pref($user, 'home_monetization');\n$show_monetization_box = (!$orientation &&\nget_site_variable('HOMEPAGE_MONETIZATION_BOX'));\ntpl_set('show_monetization_box', $show_monetization_box);\ntpl_set('minimize_monetization_box', $minimize_monetization_box);\n\nif ($show_monetization_box) {\n$monetization_box_data = monetization_box_user_get_data($user);\ntxt_set('monetization_box_data', $monetization_box_data);\n}\n\n\n\/\/ ORIENTATION\nif ($orientation) {\n$network_ids = id_get_networks($user);\n$network_names = multiget_network_name($network_ids);\n$in_corp_network = in_array($GLOBALS['TYPE_CORP'], array_map('extract_network_type', $network_ids));\n$show_corp_search = $in_corp_network ||\nget_age(user_get_basic_info_attr($user, 'birthday')) >= 21;\n$pending_hs = is_hs_pending_user($user);\n$hs_id = null;\n$hs_name = null;\nif ($pending_hs) {\nforeach (id_get_pending_networks($user) as $network) {\nif (extract_network_type($network['network_key']) == $GLOBALS['TYPE_HS']) {\n$hs_id = $network['network_key'];\n$hs_name = network_get_name($hs_id);\nbreak;\n}\n}\n}\n\/\/$orientation_people = orientation_get_friend_and_inviter_ids($user);\n$orientation_people = array('friends' => user_get_all_friends($user),\n'pending' => array_keys(user_get_friend_requests($user)),\n'inviters'=> array(), \/\/ wc: don't show inviters for now\n);\n$orientation_info = array_merge($orientation_people,\narray('network_names' => $network_names,\n'show_corp_search' => $show_corp_search,\n'pending_hs' => array('hs_id'=>$hs_id,\n'hs_name'=>$hs_name),\n'user' => $user,\n));\ntpl_set('orientation_info', $orientation_info);\n\ntpl_set('simple_orientation_first_login', $get_o); \/\/ unused right now\n}\n\n\n\/\/ Roughly determine page length for ads\n\/\/ first, try page length using right-hand panel\n$ads_page_length_data = 3 + \/\/ 3 for profile pic + next step\n($show_friend_finder ? 1 : 0) +\n($show_status ? ($status_custom ? count($friends_status) : 0) : 0) +\n($show_monetization_box ? 1 : 0) +\n($show_birthdays ? count($birthdays) : 0) +\ncount($new_pokes);\n\n\/\/ page length using feed stories\nif ($orientation) {\n$ads_page_length_data = max($ads_page_length_data, count($stories) * 5);\n}\ntpl_set('ads_page_length_data', $ads_page_length_data);\n\n$feed_stories = null;\nif (!$orientation) { \/\/ if they're not in orientation they get other cool stuff\n\/\/ ad_insert: the ad type to try to insert for the user\n\/\/ (0 if we don't want to try an insert)\n$ad_insert = get_site_variable('FEED_ADS_ENABLE_INSERTS');\n\n$feed_off = false;\n\nif (check_super($user) && $get_feeduser){\n$feed_stories = user_get_displayable_stories($get_feeduser, 0, null, $ad_insert);\n} else if (can_see($user, $user, 'feed')) {\n$feed_stories = user_get_displayable_stories($user, 0, null, $ad_insert);\n} else {\n$feed_off = true;\n}\n\n\/\/ Friend's Feed Selector - Requires dev.php constant\nif (is_friendfeed_user($user)) {\n$friendfeed = array();\n$friendfeed['feeduser'] = $get_feeduser;\n$friendfeed['feeduser_name'] = user_get_name($get_feeduser);\n$friendfeed['friends'] = user_get_all_friends($user);\ntpl_set('friendfeed', $friendfeed);\n}\n\n$feed_stories = feed_adjust_timezone($user, $feed_stories);\n\ntpl_set('feed_off', $feed_off ? redirect('privacy.php?view=feeds', null, false) : false);\n}\ntpl_set('feed_stories', $feed_stories);\n\nrender_template($_SERVER['PHP_ROOT'].'\/html\/home.phpt');\n<\/pre>\n<p><strong>SEARCH CODE<\/strong><\/p>\n<pre>\n\/* @author Mark Slee\n*\n* @package ubersearch\n*\/\n\nini_set('memory_limit', '100M'); \/\/ to be\nsafe we are increasing the memory limit for search\n\ninclude_once $_SERVER['PHP_ROOT'].'\/html\n\/init.php'; \/\/ final\nlib include\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/s.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/browse.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/events.php';\ninclude_once $_SERVER['PHP_ROOT'].'\/lib\/websearch_classifier\/websearch_classifier.php';\n\nflag_allow_guest();\n$user = search_require_login();\n\nif($_POST) {\n$arr = us_flatten_checkboxes($_POST, array('ii'));\n$qs = '?';\nforeach($arr as $key=>$val) {\n$qs .= $key.'='.urlencode($val).'&';\n}\n$qs = substr($qs, 0, (strlen($qs)-1));\nredirect($_SERVER['PHP_SELF'].$qs);\n}\n\n\/\/ If they performed a classmates search, these values are\n\/\/ needed to pre-populate dropdowns\nparam_get_slashed(array('hy'=>$PARAM_STRING,\n'hs'=>$PARAM_INT,\n'adv'=>$PARAM_EXISTS,\n'events'=>$PARAM_EXISTS,\n'groups'=>$PARAM_EXISTS,\n'classmate'=>$PARAM_EXISTS,\n'coworker'=>$PARAM_EXISTS));\n$pos = strpos($get_hy, ':');\nif($pos !== false) {\n$hsid = intval(substr($get_hy, 0, $pos));\n$hsyear = intval(substr($get_hy, $pos+1));\n} else {\n$hsid = intval($get_hs);\n$hsyear = null;\n}\n\ntpl_set('hs_id', $hsid);\ntpl_set('hs_name', get_high_school($hsid));\ntpl_set('hs_year', $hsyear);\ntpl_set('is_advanced_search', $get_adv);\ntpl_set('user', $user);\ntpl_set('count_total', 0); \/\/ pre-set count_total for the sake of ads\npage length\n\n\/\/ Events search calendar data\nparam_get(array('k' => $PARAM_HEX,\n'n' => $PARAM_SINT));\nif (($get_k == search_module::get_key(SEARCH_MOD_EVENT, SEARCH_TYPE_AS))) {\n\n$EVENTS_CAL_DAYS_AHEAD = 60;\n$events_begin = strftime(\"%Y%m01\"); \/\/ first of the month\n$events_end = strftime(\"%Y%m%d\", strtotime(strftime(\"%m\/01\/%Y\")) +\n(86400 * $EVENTS_CAL_DAYS_AHEAD));\n$events_params = array('dy1' => $events_begin,\n'dy2' => $events_end);\n\nparam_get(array('c1' => $PARAM_INT, 'c2' => $PARAM_INT), 'evt_');\nif (isset($evt_c1)) { $events_params['c1'] = $evt_c1; }\nif (isset($evt_c2)) { $events_params['c2'] = $evt_c2; }\n$results = events_get_calendar($user, $get_n, $events_params);\ntpl_set('events_date', $results['events_date']);\n}\n\n\n\n\n\/\/ Holy shit, is this the cleanest fucking frontend file you've ever seen?!\nubersearch($_GET, $embedded=false, $template=true);\n\n\/\/ Render it\nrender_template($_SERVER['PHP_ROOT'].'\/html\/s.phpt');\n\n\/**\n* login function for s.php\n*\n* @author Philip Fung\n*\/\nfunction search_require_login() {\n\n\/\/check if user is logged in\n$user = require_login(true);\n\nif($user 0 && !is_unregistered($user)) { return $user; }\n\n\/\/ this is an unregistered user\nparam_get(array('k' => $GLOBALS['PARAM_HEX'], \/\/ search key\n(used by rest of ubersearch code)\n));\n\nglobal $get_k;\n$search_key = $get_k;\n\n\/\/Let user see event or group search if criteria are obeyed\nif ($search_key\n&& (search_module::get_key_type($search_key) ==\nSEARCH_MOD_EVENT || search_module::get_key_type($search_key) ==\nSEARCH_MOD_GROUP) \/\/event or group search\n) {\n\nreturn $user;\n\n} else {\ngo_home();\n}\n}\n<\/pre>\n<p>It&#8217;s all procedural and looks very nasty to mantain. Procedural for speed maybe? I don&#8217;t think so.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ok, so one guy got to see Facebook&#8217;s source code on his screen, probably due to some bad upgrade, lord knows why, the code appeared on his screen, he then copied and pasted it to some forums, and then Facebook lawyers were threatening him. Too late!, it&#8217;s all over the place. Look for it no [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15,30],"tags":[],"class_list":["post-574","post","type-post","status-publish","format-standard","hentry","category-code","category-geeklife"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-9g","jetpack-related-posts":[{"id":4135,"url":"https:\/\/www.gubatron.com\/blog\/the-curious-case-of-inconsistent-cargo-fmt-formatting-and-how-to-fix-it\/","url_meta":{"origin":574,"position":0},"title":"The Curious Case of Inconsistent cargo fmt Formatting (and How to Fix It)","author":"gubatron","date":"February 17, 2025","format":false,"excerpt":"Have you ever run into a situation where\u00a0cargo fmt, Rust's code formatter, produces different output on different machines, even though you're working on the same project? This can be incredibly frustrating, especially when you're trying to maintain consistent code style across a team or between your own development environments. I\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/02\/gubatron_Abstract_digital_art_fragmented_code_snippets_floati_e3f2c486-78ad-4b2a-b86a-e792a1970064_2.png?fit=1024%2C1024&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":470,"url":"https:\/\/www.gubatron.com\/blog\/how-to-build-pyqt4-for-windows\/","url_meta":{"origin":574,"position":1},"title":"How to build PyQt4 for Windows","author":"gubatron","date":"February 23, 2007","format":false,"excerpt":"- Make sure you don't have cygwin or C:devkitPromsysbin in your path, or else your make files can end up trying to run the Makefile using 'sh' and all the makefile we're about to use are meant to run from the windows command line. If for some odd reason you\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":584,"url":"https:\/\/www.gubatron.com\/blog\/svn-gotchas-importing-a-folder-in-one-step\/","url_meta":{"origin":574,"position":2},"title":"svn gotchas: Importing a Folder in one step","author":"gubatron","date":"September 6, 2007","format":false,"excerpt":"Up until this day when my friend Gabe told me how, I didn't know how to import a folder, without doing this first: svn mkdir svn+ssh:\/\/server.com\/path\/to\/repo\/myfolder svn import myFolder svn+ssh:\/\/server.com\/path\/to\/repo\/myfolder If I didn't do that, If I just imported the local \"myFolder\", it would end up adding all the files\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3236,"url":"https:\/\/www.gubatron.com\/blog\/how-to-actually-build-bitcoin-on-mac-osx-10-9-1\/","url_meta":{"origin":574,"position":3},"title":"How to actually build bitcoin on Mac OSX 10.9.1","author":"gubatron","date":"February 3, 2014","format":false,"excerpt":"First of all, if you have Macports, do yourself a favor and get rid of it. Then make sure you have Homebrew installed and all the packages installed by it up to date. 1. Let's install all the dependencies for Bitcoin hacking. brew install autoconf automake berkeley-db4 boost miniupnpc openssl\u2026","rel":"","context":"In &quot;BitCoin&quot;","block_context":{"text":"BitCoin","link":"https:\/\/www.gubatron.com\/blog\/category\/bitcoin-2\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3383,"url":"https:\/\/www.gubatron.com\/blog\/things-to-remember-when-compilinglinking-cc-software\/","url_meta":{"origin":574,"position":4},"title":"# Things to remember when compiling\/linking C\/C++ software","author":"gubatron","date":"March 18, 2015","format":false,"excerpt":"by Angel Leon. March 17, 2015. Include Paths On the compilation phase, you will usually need to specify the different include paths so that the interfaces (.h, .hpp) which define structs, classes, constans, and functions can be found. With gcc and llvm include paths are passed with -I\/path\/to\/includes, you can\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2015\/03\/make-all-executables.png?fit=680%2C510&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2015\/03\/make-all-executables.png?fit=680%2C510&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2015\/03\/make-all-executables.png?fit=680%2C510&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2849,"url":"https:\/\/www.gubatron.com\/blog\/no-bad-code-files-included-to-print-your-own-stickers-code-streetart-wheatpaste-pasteup-streetart\/","url_meta":{"origin":574,"position":5},"title":"No Bad CODE &#8211; Files Included to Print your own stickers &#8211; #CODE #streetart #wheatpaste #pasteup #streetart","author":"gubatron","date":"November 10, 2012","format":false,"excerpt":"Enjoy and print my latest creation (links at the end) inspired in the coding philosophy of \"No Broken Windows\" of the book The Pragmatic Programmer Save the .pngs, print with Photoshop (Fit to Screen) Single Sticker PNG Multiple Sticker PNG LICENSE Share all you want, no commercial use. If you\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=574"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/574\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}