mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Update APIs
This commit is contained in:
parent
667d2fe2a3
commit
52dd39edad
4 changed files with 86 additions and 0 deletions
|
@ -234,6 +234,7 @@ if ($resp === User::REQUIRE2FA) {
|
|||
////_error_log("login.json.php setup object");
|
||||
$object->siteLogo = $global['webSiteRootURL'] . $config->getLogo();
|
||||
$object->id = User::getId();
|
||||
$object->age = User::getAge();
|
||||
$object->user = User::getUserName();
|
||||
$object->donationLink = User::donationLink();
|
||||
$object->name = User::getName();
|
||||
|
|
|
@ -1394,6 +1394,12 @@ if (typeof gtag !== \"function\") {
|
|||
|
||||
public static function getAge($users_id = 0)
|
||||
{
|
||||
if(empty($users_id)){
|
||||
$users_id = User::getId();
|
||||
}
|
||||
if(empty($users_id)){
|
||||
return 0;
|
||||
}
|
||||
$birth_date = self::getBirthIfIsSet($users_id);
|
||||
if (empty($birth_date)) {
|
||||
return 0;
|
||||
|
|
|
@ -1510,6 +1510,7 @@ if (!class_exists('Video')) {
|
|||
$sql .= AVideoPlugin::getVideoWhereClause();
|
||||
|
||||
$sql .= "ORDER BY RAND() LIMIT {$limit}";
|
||||
//var_dump($sql);exit;
|
||||
$res = sqlDAL::readSql($sql);
|
||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||
//var_dump(count($fullData), $sql);
|
||||
|
|
|
@ -2792,6 +2792,82 @@ class API extends PluginAbstract
|
|||
return new ApiObject($msg, empty($obj), $obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* 'birth_date' The birth date in Y-m-d format.
|
||||
* ['user' username of the user]
|
||||
* ['pass' password of the user]
|
||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&birth_date=1997-06-17
|
||||
* @return \ApiObject Returns an ApiObject.
|
||||
*/
|
||||
public function set_api_birth($parameters)
|
||||
{
|
||||
global $global;
|
||||
$users_id = User::getId();
|
||||
if (empty($users_id)) {
|
||||
return new ApiObject("You must login first");
|
||||
}
|
||||
$msg = '';
|
||||
$obj = new stdClass();
|
||||
|
||||
$user = new User(0);
|
||||
$user->loadSelfUser();
|
||||
$user->setBirth_date($_REQUEST['birth_date']);
|
||||
$obj->users_id = $user->save();
|
||||
$obj->error = empty($obj->users_id);
|
||||
User::updateSessionInfo();
|
||||
|
||||
return new ApiObject($msg, $obj->error, $obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* 'users_id' users id from what user you want the response.
|
||||
* 'APISecret' mandatory for security reasons - required
|
||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&users_id=1
|
||||
* @return \ApiObject Returns an ApiObject.
|
||||
*/
|
||||
public function get_api_is_verified($parameters)
|
||||
{
|
||||
global $global;
|
||||
if (!self::isAPISecretValid()) {
|
||||
return new ApiObject("APISecret is required");
|
||||
}
|
||||
$obj = new stdClass();
|
||||
$obj->users_id = intval($_REQUEST['users_id']);
|
||||
if (empty($obj->users_id)) {
|
||||
return new ApiObject("Users ID is required");
|
||||
}
|
||||
$user = new User($obj->users_id);
|
||||
$obj->email_verified = !empty($user->getEmailVerified());
|
||||
|
||||
return new ApiObject('', false, $obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* 'users_id' users id from what user you want the response.
|
||||
* 'APISecret' mandatory for security reasons - required
|
||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&users_id=1
|
||||
* @return \ApiObject Returns an ApiObject.
|
||||
*/
|
||||
public function set_api_send_verification_email($parameters)
|
||||
{
|
||||
global $global;
|
||||
if (!self::isAPISecretValid()) {
|
||||
return new ApiObject("APISecret is required");
|
||||
}
|
||||
$obj = new stdClass();
|
||||
$obj->users_id = intval($_REQUEST['users_id']);
|
||||
if (empty($obj->users_id)) {
|
||||
return new ApiObject("Users ID is required");
|
||||
}
|
||||
$user = new User($obj->users_id);
|
||||
$obj->sent = User::sendVerificationLink($obj->users_id);
|
||||
return new ApiObject('', false, $obj);
|
||||
}
|
||||
|
||||
public static function isAPISecretValid()
|
||||
{
|
||||
global $global;
|
||||
|
@ -2814,6 +2890,7 @@ class ApiObject
|
|||
public $response;
|
||||
public $msg;
|
||||
public $users_id;
|
||||
public $user_age;
|
||||
public $session_id;
|
||||
|
||||
public function __construct($message = "api not started or not found", $error = true, $response = [])
|
||||
|
@ -2825,6 +2902,7 @@ class ApiObject
|
|||
$this->message = $message;
|
||||
$this->response = $response;
|
||||
$this->users_id = User::getId();
|
||||
$this->user_age = User::getAge();
|
||||
$this->session_id = session_id();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue