Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F13563792
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Authored By
Unknown
Size
9 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/objects/login.json.php b/objects/login.json.php
index eb124820b..b3d73bdeb 100644
--- a/objects/login.json.php
+++ b/objects/login.json.php
@@ -1,137 +1,139 @@
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json');
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = '../';
}
require_once $global['systemRootPath'] . 'objects/functions.php';
// gettig the mobile submited value
$inputJSON = url_get_contents('php://input');
$input = json_decode($inputJSON, TRUE); //convert JSON into array
if(!empty($input) && empty($_POST)){
foreach ($input as $key => $value) {
$_POST[$key]=$value;
}
}
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/hybridauth/autoload.php';
require_once $global['systemRootPath'] . 'objects/user.php';
+require_once $global['systemRootPath'] . 'objects/category.php';
use Hybridauth\Hybridauth;
use Hybridauth\HttpClient;
if (!empty($_GET['type'])) {
$login = YouPHPTubePlugin::getLogin();
foreach ($login as $value) {
$obj = $value['loginObject']->getDataObject();
if($value['parameters']->type === $_GET['type']){
$id = $obj->id;
$key = $obj->key;
break;
}
}
if(empty($id)){
die(sprintf(__("%s ERROR: You must set a ID on config"), $_GET['type']));
}
if(empty($key)){
die(sprintf(__("%s ERROR: You must set a KEY on config"), $_GET['type']));
}
$config = [
'callback' => HttpClient\Util::getCurrentUrl()."?type={$_GET['type']}",
'providers' => [
$_GET['type'] => [
'enabled' => true,
'keys' => ['id' => $id, 'secret' => $key, 'key'=>$id],
"includeEmail" => true,
]
],
/* optional : set debug mode
'debug_mode' => true,
// Path to file writeable by the web server. Required if 'debug_mode' is not false
'debug_file' => __FILE__ . '.log', */
];
try {
$hybridauth = new Hybridauth($config);
$adapter = $hybridauth->authenticate($_GET['type']);
$tokens = $adapter->getAccessToken();
$userProfile = $adapter->getUserProfile();
//print_r($tokens);
//print_r($userProfile);
if(!empty($userProfile->email)){
$user = $userProfile->email;
}else{
$user = $userProfile->displayName;
}
$name = $userProfile->displayName;
$photoURL = $userProfile->photoURL;
$email = $userProfile->email;
$pass = rand();
User::createUserIfNotExists($user, $pass, $name, $email, $photoURL);
$userObject = new User(0, $user, $pass);
$userObject->login(true);
$adapter->disconnect();
header("Location: {$global['webSiteRootURL']}");
} catch (\Exception $e) {
header("Location: {$global['webSiteRootURL']}user?error=".urlencode($e->getMessage()));
//echo $e->getMessage();
}
return;
}
$object = new stdClass();
if(!empty($_GET['user'])){
$_POST['user'] = $_GET['user'];
}
if(!empty($_GET['pass'])){
$_POST['pass'] = $_GET['pass'];
}
if(!empty($_GET['encodedPass'])){
$_POST['encodedPass'] = $_GET['encodedPass'];
}
if(empty($_POST['user']) || empty($_POST['pass'])){
$object->error = __("User and Password can not be blank");
die(json_encode($object));
}
$user = new User(0, $_POST['user'], $_POST['pass']);
$resp = $user->login(false, @$_POST['encodedPass']);
if($resp === User::USER_NOT_VERIFIED){
$object->error = __("Your user is not verified, we sent you a new e-mail");
die(json_encode($object));
}
$object->id = User::getId();
$object->user = User::getUserName();
$object->pass = User::getUserPass();
$object->email = User::getMail();
$object->photo = User::getPhoto();
$object->backgroundURL = User::getBackground($object->id);
$object->isLogged = User::isLogged();
$object->isAdmin = User::isAdmin();
$object->canUpload = User::canUpload();
$object->canComment = User::canComment();
+$object->categories = Category::getAllCategories();
$object->streamServerURL = "";
$object->streamKey = "";
if($object->isLogged){
$p = YouPHPTubePlugin::loadPluginIfEnabled("Live");
if(!empty($p)){
require_once $global['systemRootPath'] . 'plugin/Live/Objects/LiveTransmition.php';
$trasnmition = LiveTransmition::createTransmitionIfNeed(User::getId());
$object->streamServerURL = $p->getServer()."?p=".User::getUserPass();
$object->streamKey = $trasnmition['key'];
}
$p = YouPHPTubePlugin::loadPluginIfEnabled("MobileManager");
if(!empty($p)){
$object->streamer = json_decode(url_get_contents($global['webSiteRootURL']."status"));
$object->plugin = $p->getDataObject();
$object->encoder = $config->getEncoderURL();
}
}
echo json_encode($object);
diff --git a/objects/youPHPTubeEncoder.json.php b/objects/youPHPTubeEncoder.json.php
index 5c6a1d6ab..b47ea15fa 100644
--- a/objects/youPHPTubeEncoder.json.php
+++ b/objects/youPHPTubeEncoder.json.php
@@ -1,117 +1,122 @@
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = "../";
}
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/video.php';
if (empty($_POST)) {
$obj->msg = __("Your POST data is empty may be your vide file is too big for the host");
error_log($obj->msg);
die(json_encode($obj));
}
if (empty($_POST['format']) || !in_array($_POST['format'], $global['allowedExtension'])) {
error_log("Extension not allowed File " . __FILE__ . ": " . print_r($_POST, true));
die();
}
// pass admin user and pass
$user = new User("", @$_POST['user'], @$_POST['password']);
$user->login(false, true);
if (!User::canUpload()) {
$obj->msg = __("Permission denied to receive a file: " . print_r($_POST, true));
error_log($obj->msg);
die(json_encode($obj));
}
if(!empty($_POST['videos_id']) && !Video::canEdit($_POST['videos_id'])){
$obj->msg = __("Permission denied to edit a video: " . print_r($_POST, true));
error_log($obj->msg);
die(json_encode($obj));
}
// check if there is en video id if yes update if is not create a new one
$video = new Video("", "", @$_POST['videos_id']);
$obj->video_id = @$_POST['videos_id'];
$title = $video->getTitle();
if (empty($title) && !empty($_POST['title'])) {
$title = $video->setTitle($_POST['title']);
} elseif (empty($title)) {
$video->setTitle("Automatic Title");
}
$video->setDuration($_POST['duration']);
$video->setDescription($_POST['description']);
$advancedCustom = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeAdvanced");
if(empty($advancedCustom->makeVideosInactiveAfterEncode)){
// set active
$video->setStatus('a');
}else{
$video->setStatus('i');
}
$video->setVideoDownloadedLink($_POST['videoDownloadedLink']);
error_log("Encoder receiving post");
error_log(print_r($_POST, true));
if (preg_match("/(mp3|wav|ogg)$/i", $_POST['format'])) {
$type = 'audio';
$video->setType($type);
} elseif (preg_match("/(mp4|webm)$/i", $_POST['format'])) {
$type = 'video';
$video->setType($type);
}
$videoFileName = $video->getFilename();
if (empty($videoFileName)) {
$mainName = preg_replace("/[^A-Za-z0-9]/", "", cleanString($title));
$videoFileName = uniqid($mainName . "_YPTuniqid_", true);
$video->setFilename($videoFileName);
}
$destination_local = "{$global['systemRootPath']}videos/{$videoFileName}";
// get video file from encoder
if (!empty($_FILES['video']['tmp_name'])) {
$resolution = "";
if (!empty($_POST['resolution'])) {
$resolution = "_{$_POST['resolution']}";
}
$filename = "{$videoFileName}{$resolution}.{$_POST['format']}";
decideMoveUploadedToVideos($_FILES['video']['tmp_name'], $filename);
} else {
// set encoding
$video->setStatus('e');
}
if (!empty($_FILES['image']['tmp_name']) && !file_exists("{$destination_local}.jpg")) {
if (!move_uploaded_file($_FILES['image']['tmp_name'], "{$destination_local}.jpg")) {
$obj->msg = print_r(sprintf(__("Could not move image file [%s.jpg]"), $destination_local), true);
error_log($obj->msg);
die(json_encode($obj));
}
}
if (!empty($_FILES['gifimage']['tmp_name']) && !file_exists("{$destination_local}.gif")) {
if (!move_uploaded_file($_FILES['gifimage']['tmp_name'], "{$destination_local}.gif")) {
$obj->msg = print_r(sprintf(__("Could not move gif image file [%s.gif]"), $destination_local), true);
error_log($obj->msg);
die(json_encode($obj));
}
}
+
+if(!empty($_POST['categories_id'])){
+ $video->setCategories_id($_POST['categories_id']);
+}
+
$video_id = $video->save();
$video->updateDurationIfNeed();
$obj->error = false;
$obj->video_id = $video_id;
error_log("Files Received for video {$video_id}: " . $video->getTitle());
die(json_encode($obj));
/*
error_log(print_r($_POST, true));
error_log(print_r($_FILES, true));
var_dump($_POST, $_FILES);
*/
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jul 16, 02:55 (20 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2001190
Default Alt Text
(9 KB)
Attached To
Mode
R58 TurboFlop
Attached
Detach File
Event Timeline