Changeset 8420
- Timestamp:
- Jan 1, 2011, 11:16:52 AM (14 years ago)
- Location:
- extensions/FacebookPlug/Plugin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/FacebookPlug/Plugin/include/header.inc.php
r8402 r8420 119 119 ; 120 120 } 121 add_event_handler('fbp_do_facebook_init', 'fbp_do_facebook_init'); 121 122 function 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 137 function 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 } 122 180 123 181 add_event_handler('init', 'fbp_init'); 124 182 add_event_handler('loc_end_page_header', 'fbp_loc_end_page_header'); 183 add_event_handler('fbp_do_facebook_init', 'fbp_do_facebook_init'); 184 add_event_handler('loc_end_section_init', 'ftp_loc_end_section_init'); 125 185 126 186 ?> -
extensions/FacebookPlug/Plugin/include/index.inc.php
r8402 r8420 82 82 global $page; 83 83 84 if (count($categories) > 0) 84 $C = count($categories); 85 if ($C > 0) 85 86 { 86 87 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 87 $category = reset($categories); 88 $query = ' 88 //~ $category = reset($categories); 89 $category = $categories[rand(0, $C-1)]; 90 if (is_numeric($category['representative_picture_id'])) 91 { 92 $query = ' 89 93 SELECT id, path, tn_ext 90 94 FROM '.IMAGES_TABLE.' 91 95 WHERE id = '.$category['representative_picture_id'].' 92 96 ;'; 93 $result = pwg_query($query); 94 if($row = pwg_db_fetch_assoc($result)) 95 { 96 set_make_full_url(); 97 $page['fbp']['url_image'] = get_thumbnail_url($row); 98 unset_make_full_url(); 97 $result = pwg_query($query); 98 if($row = pwg_db_fetch_assoc($result)) 99 { 100 set_make_full_url(); 101 $page['fbp']['url_image'] = get_thumbnail_url($row); 102 unset_make_full_url(); 103 } 99 104 } 100 105 } … … 105 110 global $page; 106 111 107 if ( count($pictures) > 0)112 if (isset($page['category']['representative_picture_id'])) 108 113 { 109 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 110 $picture = reset($pictures); 111 set_make_full_url(); 112 $page['fbp']['url_image'] = get_thumbnail_url($picture); 113 unset_make_full_url(); 114 fbp_loc_begin_index_category_thumbnails(array($page['category'])); 115 } 116 else 117 { 118 $C = count($pictures); 119 if ($C > 0) 120 { 121 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 122 $picture = reset($pictures); 123 $picture = $pictures[rand(0, $C-1)]; 124 set_make_full_url(); 125 $page['fbp']['url_image'] = get_thumbnail_url($picture); 126 unset_make_full_url(); 127 } 114 128 } 115 129 } -
extensions/FacebookPlug/Plugin/include/picture.inc.php
r8402 r8420 90 90 } 91 91 92 function ftp_loc_end_section_init()93 {94 global $conf, $page;95 96 //~ if ($conf['fbp']['social_plugin_like_button']['enabled'] or $conf['fbp']['social_plugin_comments']['enabled'])97 if ($page['fbp']['do_facebook_init'])98 {99 if ($conf['fbp']['allow_fb_access_private_page'])100 {101 global $user, $page;102 103 // No restristion for facebook user104 if (preg_match('/'.FBP_IP_FB. '/', $_SERVER["REMOTE_ADDR"]))105 {106 //Allow guest access107 $conf['guest_access'] = true;108 // No forbidden categorie109 $user['forbidden_categories'] = '';110 $user['level'] = max($conf['available_permission_levels']);111 $page['rank_of'][$page['image_id']] = 0;112 $page['items'] = array_flip($page['rank_of']);113 }114 }115 }116 }117 118 92 add_event_handler('render_element_content', 'fbp_render_element_content', EVENT_HANDLER_PRIORITY_NEUTRAL+1 /*in order to have picture content*/, 2); 119 add_event_handler('loc_end_section_init', 'ftp_loc_end_section_init');120 93 121 94 ?> -
extensions/FacebookPlug/Plugin/maintain.inc.php
r8241 r8420 26 26 function plugin_install() 27 27 { 28 // Update configuration 28 29 $query = ' 29 30 replace into '.CONFIG_TABLE.' … … 40 41 } 41 42 43 function plugin_activate() 44 { 45 // Inactivate plugins 46 $plugins = array('Facebook_Integration'); 47 $query = ' 48 update '.PLUGINS_TABLE.' 49 set STATE=\'inactive\' 50 where ID in (\'' . implode('\',\'', $plugins) . '\') 51 ;'; 52 pwg_query($query); 53 54 } 55 42 56 function plugin_uninstall() 43 57 { 58 // Delete configuration 44 59 $query = ' 45 60 delete from '.CONFIG_TABLE.'
Note: See TracChangeset
for help on using the changeset viewer.