Файл: ajax/publisher/check.php
Строк: 67
<?php
/**
* check if user connected his fb|tw accounts
*
* @package Sngine
* @author Zamblek
*/
// fetch kernal
$depth = '../../';
require($depth.'kernal.php');
// check user exist
if(!$userExist) {
exit(PopupError('Please log in to continue.', 'Not Logged In'));
}
// check user verified
if($userArray['Verified'] == "N") {
VerifyError();
}
// check page parameters
if(!isset($_POST['connection']) || !isset($_POST['do'])) {
exit(PopupError(ReportError('parameters error[1] @/ajax/publisher/check')));
}
// valid inputs
$valid['connection'] = array('fb', 'tw');
$valid['do'] = array('active', 'inactive');
if(!in_array($_POST['connection'], $valid['connection']) || !in_array($_POST['do'], $valid['do'])) {
exit(PopupError(ReportError('parameters error[2] @/ajax/publisher/check')));
}
if($_POST['connection'] == "fb") {
if($_POST['do'] == "active") {
// check if facebook connected
if($userArray['fb_UserID'] !== NULL) {
$db->query(sprintf("UPDATE users SET fb_connected = 'Y' WHERE UserID = %s", Secure($userArray['UserID'], 'int'))) or die(PopupError(ReportError('sql error #1 @/ajax/publisher/check')));
}else {
exit(PopupError('You have to connect your facebook account. <a href="'.SITE_URL.'/connect/facebook/">Connect it now</a>'));
}
}else {
$db->query(sprintf("UPDATE users SET fb_connected = 'N' WHERE UserID = %s", Secure($userArray['UserID'], 'int'))) or die(PopupError(ReportError('sql error #2 @/ajax/publisher/check')));
}
}else {
if($_POST['do'] == "active") {
// check if twitter connected
if($userArray['tw_UserID'] !== NULL) {
$db->query(sprintf("UPDATE users SET tw_connected = 'Y' WHERE UserID = %s", Secure($userArray['UserID'], 'int'))) or die(PopupError(ReportError('sql error #3 @/ajax/publisher/check')));
}else {
exit(PopupError('You have to connect your twitter account. <a href="'.SITE_URL.'/connect/twitter/">Connect it now</a>'));
}
}else {
$db->query(sprintf("UPDATE users SET tw_connected = 'N' WHERE UserID = %s", Secure($userArray['UserID'], 'int'))) or die(PopupError(ReportError('sql error #4 @/ajax/publisher/check')));
}
}
?>