Skip to content

Commit

Permalink
* Spacinazi. (NoPrintForGuests, facebook)
Browse files Browse the repository at this point in the history
Signed-off-by: Nao <nao@wedge>
  • Loading branch information
Nao committed Jul 19, 2015
1 parent 1dd082d commit d502d45
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 90 deletions.
20 changes: 11 additions & 9 deletions NoPrintForGuests/noprintforguests/NoPrintForGuests.php
@@ -1,19 +1,21 @@
<?php

function npfg_display_main(){

function npfg_display_main()
{
global $context;
if(we::$is_guest){ // If user is guest, delete print button
unset($context['nav_buttons']['normal']['print']);
}

// If user is guest, delete print button
if (we::$is_guest)
unset($context['nav_buttons']['normal']['print']);
}

function npfg_load_theme(){
function npfg_load_theme()
{
global $context;

log_error(print_r($context, true));
if(we::$is_guest && $context['action'] == 'printpage'){ // If user is guest, and action is printpage, abort it

// If user is guest, and action is printpage, abort it
if (we::$is_guest && $context['action'] == 'printpage')
redirectexit();
}

}
131 changes: 65 additions & 66 deletions facebook/base_facebook.php
Expand Up @@ -795,15 +795,14 @@ protected function makeRequest($url, $params, $ch=null) {
$existing_headers = $opts[CURLOPT_HTTPHEADER];
$existing_headers[] = 'Expect:';
$opts[CURLOPT_HTTPHEADER] = $existing_headers;
} else {
} else
$opts[CURLOPT_HTTPHEADER] = array('Expect:');
}
$opts[CURLOPT_SSL_VERIFYPEER] = false;

$opts[CURLOPT_SSL_VERIFYPEER] = false;

curl_setopt_array($ch, $opts);
$result = curl_exec($ch);

if (curl_errno($ch) == 60 || curl_errno($ch) == 77) { // CURLE_SSL_CACERT
if (curl_errno($ch) == 60 || curl_errno($ch) == 77) { // CURLE_SSL_CACERT
self::errorLog('Invalid or no certificate authority found, '.
'using bundled information');
curl_setopt($ch, CURLOPT_CAINFO,
Expand Down Expand Up @@ -845,8 +844,7 @@ protected function parseSignedRequest($signed_request) {
}

// check sig
$expected_sig = hash_hmac('sha256', $payload,
$this->getApiSecret(), $raw = true);
$expected_sig = hash_hmac('sha256', $payload, $this->getApiSecret(), $raw = true);
if ($sig !== $expected_sig) {
self::errorLog('Bad Signed JSON signature!');
return null;
Expand All @@ -864,65 +862,66 @@ protected function parseSignedRequest($signed_request) {
protected function getApiUrl($method) {
static $READ_ONLY_CALLS =
array('admin.getallocation' => 1,
'admin.getappproperties' => 1,
'admin.getbannedusers' => 1,
'admin.getlivestreamvialink' => 1,
'admin.getmetrics' => 1,
'admin.getrestrictioninfo' => 1,
'application.getpublicinfo' => 1,
'auth.getapppublickey' => 1,
'auth.getsession' => 1,
'auth.getsignedpublicsessiondata' => 1,
'comments.get' => 1,
'connect.getunconnectedfriendscount' => 1,
'dashboard.getactivity' => 1,
'dashboard.getcount' => 1,
'dashboard.getglobalnews' => 1,
'dashboard.getnews' => 1,
'dashboard.multigetcount' => 1,
'dashboard.multigetnews' => 1,
'data.getcookies' => 1,
'events.get' => 1,
'events.getmembers' => 1,
'fbml.getcustomtags' => 1,
'feed.getappfriendstories' => 1,
'feed.getregisteredtemplatebundlebyid' => 1,
'feed.getregisteredtemplatebundles' => 1,
'fql.multiquery' => 1,
'fql.query' => 1,
'friends.arefriends' => 1,
'friends.get' => 1,
'friends.getappusers' => 1,
'friends.getlists' => 1,
'friends.getmutualfriends' => 1,
'gifts.get' => 1,
'groups.get' => 1,
'groups.getmembers' => 1,
'intl.gettranslations' => 1,
'links.get' => 1,
'notes.get' => 1,
'notifications.get' => 1,
'pages.getinfo' => 1,
'pages.isadmin' => 1,
'pages.isappadded' => 1,
'pages.isfan' => 1,
'permissions.checkavailableapiaccess' => 1,
'permissions.checkgrantedapiaccess' => 1,
'photos.get' => 1,
'photos.getalbums' => 1,
'photos.gettags' => 1,
'profile.getinfo' => 1,
'profile.getinfooptions' => 1,
'stream.get' => 1,
'stream.getcomments' => 1,
'stream.getfilters' => 1,
'users.getinfo' => 1,
'users.getloggedinuser' => 1,
'users.getstandardinfo' => 1,
'users.hasapppermission' => 1,
'users.isappuser' => 1,
'users.isverified' => 1,
'video.getuploadlimits' => 1);
'admin.getappproperties' => 1,
'admin.getbannedusers' => 1,
'admin.getlivestreamvialink' => 1,
'admin.getmetrics' => 1,
'admin.getrestrictioninfo' => 1,
'application.getpublicinfo' => 1,
'auth.getapppublickey' => 1,
'auth.getsession' => 1,
'auth.getsignedpublicsessiondata' => 1,
'comments.get' => 1,
'connect.getunconnectedfriendscount' => 1,
'dashboard.getactivity' => 1,
'dashboard.getcount' => 1,
'dashboard.getglobalnews' => 1,
'dashboard.getnews' => 1,
'dashboard.multigetcount' => 1,
'dashboard.multigetnews' => 1,
'data.getcookies' => 1,
'events.get' => 1,
'events.getmembers' => 1,
'fbml.getcustomtags' => 1,
'feed.getappfriendstories' => 1,
'feed.getregisteredtemplatebundlebyid' => 1,
'feed.getregisteredtemplatebundles' => 1,
'fql.multiquery' => 1,
'fql.query' => 1,
'friends.arefriends' => 1,
'friends.get' => 1,
'friends.getappusers' => 1,
'friends.getlists' => 1,
'friends.getmutualfriends' => 1,
'gifts.get' => 1,
'groups.get' => 1,
'groups.getmembers' => 1,
'intl.gettranslations' => 1,
'links.get' => 1,
'notes.get' => 1,
'notifications.get' => 1,
'pages.getinfo' => 1,
'pages.isadmin' => 1,
'pages.isappadded' => 1,
'pages.isfan' => 1,
'permissions.checkavailableapiaccess' => 1,
'permissions.checkgrantedapiaccess' => 1,
'photos.get' => 1,
'photos.getalbums' => 1,
'photos.gettags' => 1,
'profile.getinfo' => 1,
'profile.getinfooptions' => 1,
'stream.get' => 1,
'stream.getcomments' => 1,
'stream.getfilters' => 1,
'users.getinfo' => 1,
'users.getloggedinuser' => 1,
'users.getstandardinfo' => 1,
'users.hasapppermission' => 1,
'users.isappuser' => 1,
'users.isverified' => 1,
'video.getuploadlimits' => 1
);
$name = 'api';
if (isset($READ_ONLY_CALLS[strtolower($method)])) {
$name = 'api_read';
Expand Down
30 changes: 15 additions & 15 deletions facebook/plugin.php
Expand Up @@ -27,7 +27,7 @@ function facebook_hook_load_theme()
loadPluginSource('Wedge:Facebook', array('facebook', 'Subs-Plugin'));
loadPluginTemplate('Wedge:Facebook', 'templates/plugin');
loadPluginLanguage('Wedge:Facebook', 'languages/plugin');

if (!facebook_enabled())
return false;

Expand Down Expand Up @@ -68,14 +68,14 @@ function facebook_hook_create_post_after($msgOptions, $topicOptions, $posterOpti
// Not a new topic? Facebook not enabled? Forget about it
if (!facebook_enabled() || !$new_topic || empty($posterOptions['id']))
return true;

// Get this member's information
list ($id_member, $id_facebook, $fields) = array_values(facebook_get_members($posterOptions['id']));

// Not allowed to post the topic?
if (empty($id_facebook) || !in_array('topictofeed', $fields))
return true;

// Post the topic to facebook
$facebook = facebook_instance();
$facebook->api('/' . $id_facebook . '/feed', 'POST', array(
Expand Down Expand Up @@ -125,12 +125,12 @@ function facebook_hook_thought_add($privacy, $text, $id_parent, $id_master, $id_
// !! @todo: fix privacy setting (it's the old system.)
if ($id_parent != 0 || $id_master != 0 || $privacy != '-3')
return;

// Get the member's info and make sure we should post this thought to his/her feed
list ($id_member, $id_facebook, $fields) = array_values(facebook_get_members(MID));
if (empty($id_facebook) || !in_array('thoughttofeed', $fields))
return;

$text = html_entity_decode($text, ENT_QUOTES);

// Cache it to prevent facebook updating our own thought...
Expand Down Expand Up @@ -196,16 +196,16 @@ function Facebook()
{
if (!facebook_enabled())
return false;

$areas = array(
'login' => 'Facebook_login_redirect',
'login_return' => 'Facebook_login_return',
'register' => 'Facebook_register',
);

if (isset($_REQUEST['area']) && isset($areas[$_REQUEST['area']]))
return $areas[$_REQUEST['area']]();

redirectexit();
}

Expand Down Expand Up @@ -233,10 +233,10 @@ function Facebook_login_redirect()
function Facebook_login_return()
{
global $context, $user_settings, $txt;

if (!facebook_enabled())
fatal_lang_error('facebook_disabled');

loadSource(array('Subs-Auth', 'Subs-Login', 'Subs-Members', 'Subs-Graphics'));

$facebook = facebook_instance();
Expand Down Expand Up @@ -271,7 +271,7 @@ function Facebook_login_return()
{
if (empty($me['email']))
fatal_lang_error('facebook_no_email');

$_SESSION['facebook_info'] = $me;
$context['page_title'] = $txt['facebook_create_password'];
$context['facebook_info'] = $me;
Expand Down Expand Up @@ -303,13 +303,13 @@ function Facebook_register()

loadSource(array('Subs-Auth', 'Subs-Login', 'Subs-Members', 'Subs-Graphics'));
loadLanguage('Login');

if (!facebook_enabled())
fatal_lang_error('facebook_disabled');

if (empty($_SESSION['facebook_info']) || empty($_SESSION['facebook_info']['email']))
redirectexit();

// Check to make sure this user doesn't already exist
$request = wesql::query('
SELECT id_member
Expand All @@ -322,7 +322,7 @@ function Facebook_register()
);
if (wesql::num_rows($request) > 0)
redirectexit('action=facebook;area=login');

// We don't need to do much validating, we'll let registerMember handle those
$regOptions = array(
'password' => $_POST['passwd'],
Expand Down

0 comments on commit d502d45

Please sign in to comment.