KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/owens.enteract/inc/libs/photocropper/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/owens.enteract/inc/libs/photocropper/js/fbjs.js
/**
	REQUIRES ARRAY PROTOTYPE FOR INDEXOF IN IE
	SET IN UTILS.JS
**/
(function(window){
	var FBUtil = {};
	FBUtil.clean = function(){
		FBUtil.firstname = "";
		FBUtil.lastname = "";
		FBUtil.fullname = "";
		FBUtil.expires = "";
		FBUtil.uid = "";
		FBUtil.loginStatus = "";
		FBUtil.access_token = "";
		FBUtil.hasSession = false;
		FBUtil.hasUserData = false;
		FBUtil.permissions = [];
		FBUtil.userObj = {};
	}
	FBUtil.init = function(initObj){
		loginStatus = initObj.status;
		if(initObj.status === "connected"){
			FBUtil.uid = initObj.authResponse.userID;
			FBUtil.access_token = initObj.authResponse.accessToken;
			FBUtil.expires = initObj.authResponse.expiresIn;
			FBUtil.hasSession = true;
			
			//Save to perma values that we're using everywhere (getting from PHP first)
			fbAccessToken = FBUtil.access_token;
			fbID = FBUtil.uid;
			
			//log(FBUtil);
		}else{
			FBUtil.clean();
		}
	}
	FBUtil.addUserData = function(userObj){
		FBUtil.firstname = userObj.first_name;
		FBUtil.lastname = userObj.last_name;
		FBUtil.fullname = userObj.name;
		FBUtil.uid = userObj.id;
		FBUtil.userObj = userObj;
		FBUtil.hasUserData = true;
		//log(FBUtil);
	}
	FBUtil.addPermissions = function(permsAr){
		for(var i=0; i < permsAr.length; i++){
			if (FBUtil.permissions.indexOf(permsAr[i]) == -1)
				FBUtil.permissions.push(permsAr[i]);
		}
		//log(FBUtil);
	}
	FBUtil.hasPermission = function(perm){
		return (FBUtil.permissions.indexOf(perm) != -1);
	}
	FBUtil.hasAllPermissions = function(permsAr){
		for(var i=0; i < permsAr.length; i++){
			if (!hasPermission(permsAr[i]))
				return false;
		}
		return true;
	}
	window.FBUtil = FBUtil;
	FBUtil.clean();
}(window));	


var api_key;
//STAGING OR PROD FB
if (document.location.href.indexOf("tedperezexternal.com/your_dev") == -1){
	api_key = "xxxx"; //DEV
}else if (document.location.href.indexOf("tedperezexternal.com/your_review") == -1){
	api_key = "xxxx"; //REVIEW
}else if (document.location.href.indexOf("__staging") == -1){
	api_key = "xxxx"; //STAGE
}else{
	api_key = "xxxx"; //LIVE
}

/*----------------------------------------------------------------------------
CORE FUNCTIONS
----------------------------------------------------------------------------*/

/**
 * Append text to fb tracer.
 */
function traceJS(msgIn){
	if (window.log){
		log(msgIn);
	}
	var fb_status = document.getElementById('fb_status');  	
	if (fb_status){
		fb_status.innerHTML += "<br />" + msgIn;
	}
}

/**
 * Attempt the callback.
 * @param fb_cb - The callback Function or String function name.
 * @param fb_params - Array of parameters to pass to the callback Function.
 */
function doCallback(fb_cb){
	if (arguments.length > 1){ var fb_params = arguments[1]; }
	var myFunc;
	if (typeof fb_cb === "function"){
		myFunc = fb_cb;
	}else if (typeof fb_cb === "string"){
		myFunc = window[fb_cb];
	}
	try{
		myFunc.apply(null, fb_params);
	}catch(err){
		traceJS('error: '+fb_cb+' is not a function!');
	}
}

/**
 * Validate one array's contents are in the second array
 */
function validatePermissions(fb_req, fb_given) {
	var i = fb_req.length;
	while(i--) {
		if (!arrayContains(fb_given, fb_req[i])){
			return false;
		}
	}
	return true;
}

/**
 * Validate an array contains an value
 */
function arrayContains(a, obj) {
    var i = a.length;
    while (i--) {
       if (a[i] === obj) {
           return true;
       }
    }
    return false;
}

/*----------------------------------------------------------------------------
FACEBOOK LOGIN METHODS
----------------------------------------------------------------------------*/
/**
 * Logs in the user and authorizes application.
 * http://developers.facebook.com/docs/reference/javascript/FB.login/
 */
function requestLogin(fb_opts, fb_cb) {
	if(!fb_opts) fb_opts = {};
	if(!fb_cb) fb_cb = "";
	
	FB.login(function(response) {
		traceJS('--login response: '+response);
		if (window.FBUtil)
			FBUtil.init(response);
		if (response.authResponse) {
			// user is logged in, collect permissions
			var session = response.authResponse;
			FB.api('/me/permissions', function(response) {
				traceJS('--me/permissions: '+response);
				//collect permissions in an array
				var perms = new Array();
				for (var i in response.data[0]) {
					perms.push(i);
				}
				if (window.FBUtil){
					FBUtil.addPermissions(perms);
				}
				traceJS('--permissions: '+perms.sort().join(","));
				setTimeout(function(){doCallback(fb_cb, [session, perms.sort().join(",")]);}, 200);
			});
	  	} else {
			// user is not logged in
			traceJS("User login failed!");
			doCallback(fb_cb);
	  	}
	},fb_opts);
}

/**
 * Logs the user out of facebook.
 * http://developers.facebook.com/docs/reference/javascript/FB.logout/
 */
function requestLogout(fb_cb) {
	if(!fb_cb) fb_cb = "";
	FB.logout(function(response) {
		// user is now logged out
		doCallback(fb_cb);
	});

}

/**
 * This determines the user's login status.  If the user is logged in, requests permissions and user data.
 * if all requested permissions have already been granted, the user's session is returned to the callback function.
 * https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
 */
function getLoginStatus(fb_opts, fb_cb) {
	traceJS("getLoginStatus");
	if(!fb_opts) fb_opts = {};
	if(!fb_cb) fb_cb = "";
	
	FB.getLoginStatus(function(response) {
		if (window.FBUtil){
			FBUtil.init(response);
		}	
		if (response.status === 'connected') {
			FB.api('/me/permissions', function(response) {
				if (!response['error']){
					var perms = new Array();
					for (var i in response.data[0]) {
						perms.push(i);
					}
					if (window.FBUtil){
						FBUtil.addPermissions(perms);
					}
				}
			});
			FB.api('me', function(response){
				if (!response['error']){
					if (window.FBUtil){
						FBUtil.addUserData(response);
						doCallback(fb_cb,["user connected and ready"]);
					}	
				}
			});
		}else{
			doCallback(fb_cb, ["not connected"]);
		}
	});
}

/*----------------------------------------------------------------------------
FACEBOOK UI METHODS - Used to prompt FB Dialogs
Example FB.ui attachment:
{
	method: 'feed',
	name: 'Facebook Dialogs',
	link: 'http://developers.facebook.com/docs/reference/dialogs/',
	picture: 'http://fbrell.com/f8.jpg',
	caption: 'Reference Documentation',
	description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
	message: 'Facebook Dialogs are easy!'
}

----------------------------------------------------------------------------*/

/**
 * Posts a message to the user's feed, or to a friend's feed if specified 
 * in the 'to' property of attachment.
 * https://developers.facebook.com/docs/reference/dialogs/feed/
 */
function feedDialog(fb_attachment, fb_cb) {
	if(!fb_cb) fb_cb = "";
	FB.ui(fb_attachment, function(response) {
		if (response && response.post_id) {
			doCallback(fb_cb, [response]);
		} else {
			doCallback(fb_cb);
		}
	});
}

/**
 * Prompts the app requests dialog.
 * https://developers.facebook.com/docs/reference/dialogs/requests/
 */
function requestDialog(fb_attachment, fb_cb) {
	if(!fb_cb) fb_cb = "";
	FB.ui(fb_attachment, function(response) {
		if (response) {
			//this should return a comma-deliniated list of request_ids
			traceJS('response.request_ids: '+response.request_ids);
			doCallback(fb_cb, [response]);
		} else {
			doCallback(fb_cb);
		}
	});
}

/**
 * Prompts the send dialog.
 * https://developers.facebook.com/docs/reference/dialogs/send/
 */
function sendDialog(fb_attachment, fb_cb) {
	if(!fb_cb) fb_cb = "";
	FB.ui(fb_attachment, function(response) {
		if (response) {
			doCallback(fb_cb, [response]);
		} else {
			doCallback(fb_cb);
		}
	});
}

/**
 * Prompts a user to add the application tab to a Page that they 
 * administer.
 * https://developers.facebook.com/docs/reference/dialogs/add_to_page/
 */
function addPageTabDialog(fb_attachment, fb_cb) {
	if(!fb_cb) fb_cb = "";
	FB.ui(fb_attachment, function(response) {
		if (response) {
			doCallback(fb_cb, [response]);
		} else {
			doCallback(fb_cb);
		}
	});
}

/**
 * Promts the user to send a friend request to the defined user.
 * https://developers.facebook.com/docs/reference/dialogs/friends/
 */
function friendDialog(fb_attachment, fb_cb) {
	if(!fb_cb) fb_cb = "";
	FB.ui(fb_attachment, function(response) {
		if (response.action) {
			doCallback(fb_cb, [response]);
		} else {
			doCallback(fb_cb);
		}
	});
}

/*----------------------------------------------------------------------------
FACEBOOK API METHODS - Used to make calls to the Graph.
http://developers.facebook.com/docs/reference/javascript/FB.api/
----------------------------------------------------------------------------*/

/**
 * Make a standard call to the Facebook graph. 
 * http://developers.facebook.com/docs/reference/javascript/FB.api/
 */
function callApi(fb_url, fb_params, fb_method, fb_cb, fb_id){
	if(!fb_params) fb_params = {};
	if (!fb_method) fb_method = "get";
	if(!fb_cb) fb_cb = "";
	if(!fb_id) fb_id = "";
	FB.api(fb_url, fb_method, fb_params, function(response) {
		if (response) {
			doCallback(fb_cb, [response, fb_id]);
		} else {
			doCallback(fb_cb, [fb_id]);
		}
	});
}

function callRestApi(fb_params, fb_cb, fb_id){
	if(!fb_cb) fb_cb = "";
	if(!fb_id) fb_id = "";
	FB.api(fb_params, function(response) {
		if (response) {
			doCallback(fb_cb, [fb_id, response]);
		} else {
			doCallback(fb_cb, [fb_id]);
		}
	});
}

/*----------------------------------------------------------------------------
FLASH CALLBACKS
----------------------------------------------------------------------------*/
/**
 * Return login results
 */
function swfHandleLogin(fb_session, fb_perms) {
	if (fb_session){
		theSwf.handleFacebookLogin(fb_session, fb_perms);
	}else{
		theSwf.handleFacebookLoginCancel();
	}
}

/**
 * Returns logout results
 */
function swfHandleLogout() {
	theSwf.handleFacebookLogout();
}

/**
 * Return UI action results.
 */
function swfHandleUIComplete() {
	if (arguments.length > 0){
		var fb_params = arguments[1]; 
		theSwf.handleUIComplete(fb_params);
	}else{
		theSwf.handleUIComplete();
	}
}

/**
 * Returns API request results
 */
function swfHandleAPIComplete(){
	if (arguments.length == 2){
		var fb_response = arguments[0];
		fb_response["callbackID"] = arguments[1];
		theSwf.handleApiComplete(fb_response);
	}else if (arguments.length == 1){
		if (typeof arguments[0] === "object"){
			theSwf.handleApiComplete(arguments[0]);
		} else {
			theSwf.handleApiComplete({callbackID:arguments[0]});
		}
	}else{
		theSwf.handleApiComplete({});
	}
}

Anon7 - 2021