Ignore:
Timestamp:
Jan 1, 2011, 11:16:52 AM (13 years ago)
Author:
rub
Message:

Facebook_Integration plugin is inactivated when FacebookPlug is activating
Get representative image for category or random picture (and not only first picture)
Allow Facebook to access private index page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/FacebookPlug/Plugin/include/header.inc.php

    r8402 r8420  
    119119  ;
    120120}
    121 add_event_handler('fbp_do_facebook_init', 'fbp_do_facebook_init');
     121
     122function fbp_is_facebook_ip()
     123{
     124  foreach (array(
     125    FBP_IP_FB,
     126    //~ '127.0',
     127      ) as $ip_fb)
     128  {
     129    if (preg_match('/'.$ip_fb. '/', $_SERVER["REMOTE_ADDR"]))
     130    {
     131      return true;
     132    }
     133  }
     134  return false;
     135}
     136
     137function ftp_loc_end_section_init()
     138{
     139  global $conf, $page, $user;
     140
     141  // No restristion for facebook user
     142  if (
     143      $page['fbp']['do_facebook_init']
     144      and
     145      is_a_guest()
     146      and
     147      $conf['fbp']['allow_fb_access_private_page']
     148      and
     149      fbp_is_facebook_ip()
     150    )
     151  {
     152    global $user, $header_notes;
     153
     154    // Notes
     155    $header_notes[] = 'Facebook robot detected, guest can access private page';
     156    // Allow guest access
     157    $conf['guest_access'] = true;
     158    // No forbidden categorie
     159    $user['forbidden_categories'] = '';
     160    $user['level'] = max($conf['available_permission_levels']);
     161    switch (script_basename())
     162    {
     163      case 'picture':
     164        if (isset($page['image_id']))
     165        {
     166          $page['rank_of'][$page['image_id']] = 0;
     167          $page['items'] = array_flip($page['rank_of']);
     168        }
     169        break;
     170      case 'index':
     171        if (isset($page['category']['representative_picture_id']))
     172        {
     173          fbp_loc_begin_index_category_thumbnails(array($page['category']));
     174        }
     175      break;
     176    }
     177    //~ else if $page['category']['id']
     178  }
     179}
    122180
    123181add_event_handler('init', 'fbp_init');
    124182add_event_handler('loc_end_page_header', 'fbp_loc_end_page_header');
     183add_event_handler('fbp_do_facebook_init', 'fbp_do_facebook_init');
     184add_event_handler('loc_end_section_init', 'ftp_loc_end_section_init');
    125185
    126186?>
Note: See TracChangeset for help on using the changeset viewer.