mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 02:39:46 +02:00
update
This commit is contained in:
parent
706b0bbbf3
commit
9b1a78c352
2 changed files with 93 additions and 3 deletions
|
@ -591,6 +591,98 @@ class API extends PluginAbstract {
|
|||
return new ApiObject('plans_id is empty');
|
||||
}
|
||||
|
||||
$obj->plan = PPV_Plans::getFromDb($obj->plans_id);
|
||||
if(empty($obj->plan)){
|
||||
return new ApiObject('PPV plan does not exists');
|
||||
}
|
||||
$error = false;
|
||||
$obj->plans = PayPerView::getActivePlan($obj->users_id, $obj->videos_id);
|
||||
if(empty($obj->plans)){
|
||||
$obj->plans = PayPerView::buyPPV(User::getId(), $obj->plans_id, $obj->videos_id);
|
||||
$error = $obj->plans->error;
|
||||
$msg = $obj->plans->msg;
|
||||
}else{
|
||||
$error = false;
|
||||
}
|
||||
return new ApiObject($msg, $error, $obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* videos_id
|
||||
* Returns the payperview plans
|
||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
||||
* @return \ApiObject
|
||||
*/
|
||||
public function get_api_subscription_plans($parameters) {
|
||||
global $global;
|
||||
$obj = new stdClass();
|
||||
$error = true;
|
||||
$msg = '';
|
||||
|
||||
$objPPV = AVideoPlugin::getObjectDataIfEnabled('Subscription');
|
||||
if(empty($objPPV)){
|
||||
return new ApiObject('Subscription is disabled');
|
||||
}
|
||||
|
||||
$objWallet = AVideoPlugin::getObjectDataIfEnabled('YPTWallet');
|
||||
if(empty($objWallet)){
|
||||
return new ApiObject('YPTWallet is disabled');
|
||||
}
|
||||
|
||||
$obj->videos_id = intval($parameters['videos_id']);
|
||||
if(empty($obj->videos_id)){
|
||||
return new ApiObject('videos_id is empty');
|
||||
}
|
||||
|
||||
$sub = new Subscription();
|
||||
$obj->plans = $sub->getPlansFromVideo($obj->videos_id);
|
||||
if(!empty($obj->plans)){
|
||||
$error = false;
|
||||
}
|
||||
return new ApiObject($msg, $error, $obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* reduces the wallet balance of a user by the cost of a pay-per-view (PPV) video and returns the updated balance. It checks if the user has sufficient funds to make the purchase
|
||||
* plans_id
|
||||
* videos_id
|
||||
* 'user' username of the user
|
||||
* 'pass' password of the user
|
||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
||||
* @return \ApiObject
|
||||
*/
|
||||
public function set_api_subscription_buy($parameters) {
|
||||
global $global;
|
||||
$obj = new stdClass();
|
||||
$error = true;
|
||||
$msg = '';
|
||||
$obj->users_id = User::getId();
|
||||
if(empty($obj->users_id)){
|
||||
return new ApiObject('You must login');
|
||||
}
|
||||
|
||||
$objPPV = AVideoPlugin::getObjectDataIfEnabled('PayPerView');
|
||||
if(empty($objPPV)){
|
||||
return new ApiObject('PayPerView is disabled');
|
||||
}
|
||||
|
||||
$objWallet = AVideoPlugin::getObjectDataIfEnabled('YPTWallet');
|
||||
if(empty($objWallet)){
|
||||
return new ApiObject('YPTWallet is disabled');
|
||||
}
|
||||
|
||||
$obj->videos_id = intval($parameters['videos_id']);
|
||||
if(empty($obj->videos_id)){
|
||||
return new ApiObject('videos_id is empty');
|
||||
}
|
||||
|
||||
$obj->plans_id = intval($parameters['plans_id']);
|
||||
if(empty($obj->plans_id)){
|
||||
return new ApiObject('plans_id is empty');
|
||||
}
|
||||
|
||||
$obj->plan = PPV_Plans::getFromDb($obj->plans_id);
|
||||
if(empty($obj->plan)){
|
||||
return new ApiObject('PPV plan does not exists');
|
||||
|
|
|
@ -111,8 +111,6 @@ class Live_restreams extends ObjectYPT {
|
|||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
} else {
|
||||
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue