Skip to content

Commit

Permalink
Encode pass correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Aug 12, 2017
1 parent 2e8a70e commit 6773cec
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions objects/Login.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php

require_once dirname(__FILE__) . '/../videos/configuration.php';
require_once dirname(__FILE__) .'/Streamer.php';
require_once dirname(__FILE__) . '/Streamer.php';

class Login {

static function run($user, $pass, $youPHPTubeURL, $encodedPass=false) {
static function run($user, $pass, $youPHPTubeURL, $encodedPass = false) {
global $global;
if (substr($youPHPTubeURL, -1) !== '/') {
$youPHPTubeURL .= "/";
}

$postdata = http_build_query(
array(
'user' => $user,
Expand All @@ -33,34 +34,33 @@ static function run($user, $pass, $youPHPTubeURL, $encodedPass=false) {
$context = stream_context_create($opts);

$result = @file_get_contents($youPHPTubeURL . 'login', false, $context);
if(empty($result)){
if (empty($result)) {
$object = new stdClass();
$object->streamer = false;
$object->streamers_id = 0;
$object->isLogged = false;
$object->isAdmin = false;
$object->canUpload = false;
$object->canComment = false;
}else{
} else {
$object = json_decode($result);
$object->streamer = $youPHPTubeURL;
$object->streamers_id = 0;
if(!empty($object->canUpload)){
$object->streamers_id = 0;
if (!empty($object->canUpload)) {
$object->streamers_id = Streamer::createIfNotExists($user, $pass, $youPHPTubeURL, $encodedPass);
}
if($object->streamers_id){
if ($object->streamers_id) {
$s = new Streamer($object->streamers_id);
$object->isAdmin = $s->getIsAdmin();
if(!$encodedPass){
if (!$encodedPass || $encodedPass === 'false') {
$pass = md5($pass);
}
// update pass
$s->setPass($pass);
$s->save();
}
}
$_SESSION['login'] = $object;

$_SESSION['login'] = $object;
}

static function logoff() {
Expand All @@ -82,16 +82,16 @@ static function canUpload() {
static function canComment() {
return !empty($_SESSION['login']->canComment);
}

static function getStreamerURL() {
if(!static::isLogged()){
if (!static::isLogged()) {
return false;
}
return $_SESSION['login']->streamer;
}

static function getStreamerId() {
if(!static::isLogged()){
if (!static::isLogged()) {
return false;
}
return $_SESSION['login']->streamers_id;
Expand Down

0 comments on commit 6773cec

Please sign in to comment.