Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Stuff
Thursday, August 16th, 2007 at 10:30:34pm MDT 

  1. /*
  2. * Facebook Search Code
  3. * @author Mark Slee
  4. *
  5. * @package ubersearch
  6. */
  7.  
  8. ini_set('memory_limit', '100M'); // to be
  9. safe we are increasing the memory limit for search
  10.  
  11. include_once $_SERVER['PHP_ROOT'].'/html
  12. /init.php'; // final
  13. lib include
  14. include_once $_SERVER['PHP_ROOT'].'/lib/s.php';
  15. include_once $_SERVER['PHP_ROOT'].'/lib/browse.php';
  16. include_once $_SERVER['PHP_ROOT'].'/lib/events.php';
  17. include_once $_SERVER['PHP_ROOT'].'/lib/websearch_classifier/websearch_classifier.php';
  18.  
  19. flag_allow_guest();
  20. $user = search_require_login();
  21.  
  22. if($_POST) {
  23.         $arr = us_flatten_checkboxes($_POST, array('ii'));
  24.         $qs = '?';
  25.         foreach($arr as $key=>$val) {
  26.                 $qs .= $key.'='.urlencode($val).'&';
  27.         }
  28.         $qs = substr($qs, 0, (strlen($qs)-1));
  29.         redirect($_SERVER['PHP_SELF'].$qs);
  30. }
  31.  
  32. // If they performed a classmates search, these values are
  33. // needed to pre-populate dropdowns
  34. param_get_slashed(array('hy'=>$PARAM_STRING,
  35. 'hs'=>$PARAM_INT,
  36. 'adv'=>$PARAM_EXISTS,
  37. 'events'=>$PARAM_EXISTS,
  38. 'groups'=>$PARAM_EXISTS,
  39. 'classmate'=>$PARAM_EXISTS,
  40. 'coworker'=>$PARAM_EXISTS));
  41. $pos = strpos($get_hy, ':');
  42. if($pos !== false) {
  43.         $hsid = intval(substr($get_hy, 0, $pos));
  44.         $hsyear = intval(substr($get_hy, $pos+1));
  45. } else {
  46.         $hsid = intval($get_hs);
  47.         $hsyear = null;
  48. }
  49.  
  50. tpl_set('hs_id', $hsid);
  51. tpl_set('hs_name', get_high_school($hsid));
  52. tpl_set('hs_year', $hsyear);
  53. tpl_set('is_advanced_search', $get_adv);
  54. tpl_set('user', $user);
  55. tpl_set('count_total', 0); // pre-set count_total for the sake of ads
  56. page length
  57.  
  58. // Events search calendar data
  59. param_get(array('k' => $PARAM_HEX,
  60. 'n' => $PARAM_SINT));
  61. if (($get_k == search_module::get_key(SEARCH_MOD_EVENT, SEARCH_TYPE_AS))) {
  62.  
  63.         $EVENTS_CAL_DAYS_AHEAD = 60;
  64.         $events_begin = strftime("%Y%m01"); // first of the month
  65.         $events_end = strftime("%Y%m%d", strtotime(strftime("%m/01/%Y")) +
  66.         (86400 * $EVENTS_CAL_DAYS_AHEAD));
  67.         $events_params = array('dy1' => $events_begin,
  68.         'dy2' => $events_end);
  69.  
  70.         param_get(array('c1' => $PARAM_INT, 'c2' => $PARAM_INT), 'evt_');
  71.         if (isset($evt_c1)) { $events_params['c1'] = $evt_c1; }
  72.         if (isset($evt_c2)) { $events_params['c2'] = $evt_c2; }
  73.         $results = events_get_calendar($user, $get_n, $events_params);
  74.         tpl_set('events_date', $results['events_date']);
  75. }
  76.  
  77.  
  78.  
  79.  
  80. // Holy shit, is this the cleanest fucking frontend file you've ever seen?!
  81. ubersearch($_GET, $embedded=false, $template=true);
  82.  
  83. // Render it
  84. render_template($_SERVER['PHP_ROOT'].'/html/s.phpt');
  85.  
  86. /**
  87. * login function for s.php
  88. *
  89. * @author Philip Fung
  90. */
  91. function search_require_login() {
  92.  
  93.         //check if user is logged in
  94.         $user = require_login(true);
  95.  
  96.         if($user 0 && !is_unregistered($user)) { return $user; }
  97.  
  98.         // this is an unregistered user
  99.         param_get(array('k' => $GLOBALS['PARAM_HEX'], // search key
  100.         (used by rest of ubersearch code)
  101.         ));
  102.  
  103.         global $get_k;
  104.         $search_key = $get_k;
  105.  
  106.         //Let user see event or group search if criteria are obeyed
  107.         if ($search_key
  108.                         && (search_module::get_key_type($search_key) ==
  109.                                 SEARCH_MOD_EVENT || search_module::get_key_type($search_key) ==
  110.                                 SEARCH_MOD_GROUP) //event or group search
  111.                         ) {
  112.  
  113.                 return $user;
  114.  
  115.         } else {
  116.                 go_home();
  117.         }
  118. }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
worth-right