1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00

Sending files to support Android App

This commit is contained in:
daniel 2018-01-07 20:27:39 -03:00
parent 8e53aa1e26
commit ac4ae68ef3
19 changed files with 397 additions and 36 deletions

View file

@ -93,6 +93,8 @@
#manager playList
RewriteRule ^playLists.json$ objects/playlists.json.php [NC,L]
RewriteRule ^playListsVideos.json$ objects/playlistsVideos.json.php [NC,L]
RewriteRule ^playListsFromUser.json/([0-9]+)/?$ objects/playlistsFromUser.json.php?users_id=$1 [NC,L]
RewriteRule ^addNewPlayList$ objects/playlistAddNew.json.php [NC,L]
RewriteRule ^playListAddVideo.json$ objects/playListAddVideo.json.php [NC,L]
RewriteRule ^playlist/([0-9]+)/([0-9]+)/?$ view/?playlist_id=$1&playlist_index=$2 [NC,L]
@ -137,8 +139,8 @@
RewriteRule ^login$ objects/login.json.php [NC,L]
RewriteRule ^logoff$ objects/logoff.php [NC,L]
RewriteRule ^like$ objects/like.json.php?like=1 [NC,L]
RewriteRule ^dislike$ objects/like.json.php?like=-1 [NC,L]
RewriteRule ^like$ objects/like.json.php?like=1 [QSA]
RewriteRule ^dislike$ objects/like.json.php?like=-1 [QSA]
#manager configuration
@ -154,6 +156,8 @@
RewriteRule ^googleAdView$ view/googleAdView.php [NC,L]
RewriteRule ^notifications.json$ objects/notifications.json.php [NC,L]
# if image do not exists
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png|ico)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f

View file

@ -40,6 +40,11 @@ class Comment {
}
$this->comment = htmlentities($this->comment);
$this->comment = $global['mysqli']->real_escape_string($this->comment);
if(empty($this->comment)){
return false;
}
if (!empty($this->id)) {
$sql = "UPDATE comments SET comment = '{$this->comment}', modified = now() WHERE id = {$this->id}";
} else {
@ -94,6 +99,7 @@ class Comment {
$comment = array();
if ($res) {
while ($row = $res->fetch_assoc()) {
$row['commentHTML'] = nl2br($row['comment']);
$comment[] = $row;
}
//$comment = $res->fetch_all(MYSQLI_ASSOC);

View file

@ -1,10 +1,26 @@
<?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'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
// gettig the mobile submited value
$inputJSON = file_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;
}
}
if(!empty($_POST['user']) && !empty($_POST['pass'])){
$user = new User(0, $_POST['user'], $_POST['pass']);
$user->login(false, true);
}
if (!User::canComment()) {
die('{"error":"'.__("Permission denied").'"}');
}

View file

@ -2,5 +2,14 @@
require_once 'like.php';
require_once $global['systemRootPath'] . 'objects/user.php';
header('Content-Type: application/json');
if(!empty($_GET['user']) && !empty($_GET['pass'])){
$user = new User(0, $_GET['user'], $_GET['pass']);
$user->login(false, true);
}
if(empty($_POST['videos_id']) && !empty($_GET['videos_id'])){
$_POST['videos_id'] = $_GET['videos_id'];
}
$like = new Like($_GET['like'], $_POST['videos_id']);
echo json_encode(Like::getLikes($_POST['videos_id']));

View file

@ -2,6 +2,16 @@
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json');
// gettig the mobile submited value
$inputJSON = file_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;
}
}
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = '../';
}
@ -82,23 +92,40 @@ if(!empty($_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']);
$user->login(false, @$_POST['encodedPass']);
$object->id = User::getId();
$object->user = User::getUserName();
$object->pass = User::getUserPass();
$object->email = User::getMail();
$object->photo = User::getPhoto();
$object->backgroundURL = $user->getBackgroundURL();
$object->isLogged = User::isLogged();
$object->isAdmin = User::isAdmin();
$object->canUpload = User::canUpload();
$object->canComment = User::canComment();
$object->streamServerURL = "";
$object->streamKey = "";
$p = YouPHPTubePlugin::loadPluginIfEnabled("Live");
if($object->isLogged && !empty($p)){
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(file_get_contents($global['webSiteRootURL']."status"));
$object->plugin = $p->getDataObject();
$object->encoder = $config->getEncoderURL();
}
}
echo json_encode($object);

View file

@ -0,0 +1,31 @@
<?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'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
// gettig the mobile submited value
$inputJSON = file_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;
}
}
if(!empty($_POST['user']) && !empty($_POST['pass'])){
$user = new User(0, $_POST['user'], $_POST['pass']);
$user->login(false, true);
}
$obj = new stdClass();
if(YouPHPTubePlugin::loadPluginIfEnabled("Live")){
$liveStats = file_get_contents("{$global['webSiteRootURL']}plugin/Live/stats.json.php");
$obj->live = json_decode($liveStats);
}
echo json_encode($obj);

View file

@ -27,7 +27,8 @@ class PlayList extends Object {
*/
static function getAllFromUser($userId, $publicOnly = true) {
global $global;
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
$sql = "SELECT u.*, pl.* FROM " . static::getTableName() . " pl "
. " LEFT JOIN users u ON u.id = users_id WHERE 1=1 ";
if ($publicOnly) {
$sql .= " AND status = 'public' ";
}
@ -52,9 +53,11 @@ class PlayList extends Object {
static function getVideosFromPlaylist($playlists_id) {
global $global;
$sql = "SELECT * FROM playlists_has_videos p "
. "LEFT JOIN videos as v ON videos_id = v.id "
. " LEFT JOIN videos as v ON videos_id = v.id "
. " LEFT JOIN users u ON u.id = v.users_id "
. " WHERE playlists_id = {$playlists_id} ORDER BY p.`order` ASC ";
$sql .= self::getSqlFromPost();
$res = $global['mysqli']->query($sql);
$rows = array();
if ($res) {

View file

@ -0,0 +1,15 @@
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json');
if(empty($_GET['users_id'])){
die("You need a user");
}
if (empty($global['systemRootPath'])) {
$global['systemRootPath'] = '../';
}
require_once $global['systemRootPath'] . 'videos/configuration.php';
require_once './playlist.php';
header('Content-Type: application/json');
$row = PlayList::getAllFromUser($_GET['users_id'], false);
echo json_encode($row);

View file

@ -0,0 +1,73 @@
<?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'] . 'videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
require_once 'comment.php';
require_once 'subscribe.php';
// gettig the mobile submited value
$inputJSON = file_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;
}
}
if(!empty($_GET) && empty($_POST)){
$_POST = $_GET;
}
if(!empty($_POST['user']) && !empty($_POST['pass'])){
$user = new User(0, $_POST['user'], $_POST['pass']);
$user->login(false, true);
}
if(empty($_POST['playlists_id'])){
die('Play List can not be empty');
}
require_once './playlist.php';
$videos = PlayList::getVideosFromPlaylist($_POST['playlists_id']);
foreach ($videos as $key => $value) {
unset($videos[$key]['password']);
unset($videos[$key]['recoverPass']);
$videos[$key]['Poster'] = "{$global['webSiteRootURL']}videos/".$videos[$key]['filename'].".jpg";
$videos[$key]['Thumbnail'] = "{$global['webSiteRootURL']}videos/".$videos[$key]['filename']."_thumbs.jpg";
$videos[$key]['VideoUrl'] = getVideosURL($videos[$key]['filename']);
$videos[$key]['createdHumanTiming'] = humanTiming(strtotime($videos[$key]['created']));
$videos[$key]['pageUrl'] = "{$global['webSiteRootURL']}video/".$videos[$key]['clean_title'];
$videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/".$videos[$key]['clean_title'];
unset($_POST['sort']);
unset($_POST['current']);
unset($_POST['searchPhrase']);
$_POST['rowCount'] = 10;
$_POST['sort']['created'] = "desc";
$videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']);
$videos[$key]['commentsTotal'] = Comment::getTotalComments($videos[$key]['id']);
foreach ($videos[$key]['comments'] as $key2 => $value2) {
$user = new User($value2['users_id']);
$videos[$key]['comments'][$key2]['userPhotoURL'] = User::getPhoto($videos[$key]['comments'][$key2]['users_id']);
$videos[$key]['comments'][$key2]['userName'] = $user->getNameIdentificationBd();
}
$videos[$key]['subscribers'] = Subscribe::getTotalSubscribes($videos[$key]['users_id']);
$videos[$key]['firstVideo'] = "";
foreach ($videos[$key]['VideoUrl'] as $value2) {
if($value2["type"] === 'video'){
$videos[$key]['firstVideo'] = $value2["url"];
break;
}
}
if(preg_match("/^videos/", $videos[$key]['photoURL'])){
$videos[$key]['UserPhoto'] = "{$global['webSiteRootURL']}".$videos[$key]['photoURL'];
}else{
$videos[$key]['UserPhoto'] = $videos[$key]['photoURL'];
}
}
echo json_encode($videos);

View file

@ -1,4 +1,10 @@
<?php
// gettig the mobile submited value
if(empty($_POST) && !empty($_GET)){
foreach ($_GET as $key => $value) {
$_POST[$key]=$value;
}
}
require_once 'subscribe.php';
header('Content-Type: application/json');
$obj = new stdClass();

View file

@ -145,8 +145,8 @@ class Subscribe {
$total = static::getTotalSubscribes($user_id);
$subscribe = "<div class=\"btn-group\">"
. "<button class='btn btn-xs subscribeButton{$user_id}'><span class='fa'></span> <b class='text'>" . __("Subscribe") . "</b></button>"
. "<button class='btn btn-xs'><b class='textTotal'>{$total}</b></button>"
. "<button class='btn btn-xs subsB subs{$user_id} subscribeButton{$user_id}'><span class='fa'></span> <b class='text'>" . __("Subscribe") . "</b></button>"
. "<button class='btn btn-xs subsB subs{$user_id}'><b class='textTotal'>{$total}</b></button>"
. "</div>";
//show subscribe button with mail field
$popover = "<div id=\"popover-content\" class=\"hide\">
@ -194,8 +194,8 @@ trigger: 'manual',
if (!empty($subs)) {
// show unsubscribe Button
$subscribe = "<div class=\"btn-group\">"
. "<button class='btn btn-xs subscribeButton subscribed'><span class='fa'></span> <b class='text'>" . __("Subscribed") . "</b></button>"
. "<button class='btn btn-xs subscribed'><b class='text'>$total</b></button>"
. "<button class='btn btn-xs subsB subscribeButton{$user_id} subscribed subs{$user_id}'><span class='fa'></span> <b class='text'>" . __("Subscribed") . "</b></button>"
. "<button class='btn btn-xs subsB subscribed subs{$user_id}'><b class='textTotal'>$total</b></button>"
. "</div>";
}
}

View file

@ -1,5 +1,9 @@
<?php
require_once 'subscribe.php';
if(!empty($_GET['user']) && !empty($_GET['pass'])){
$user = new User(0, $_GET['user'], $_GET['pass']);
$user->login(false, true);
}
if (!User::isLogged()) {
return false;
}

View file

@ -1,6 +1,8 @@
<?php
require_once '../videos/configuration.php';
require_once 'video.php';
require_once 'comment.php';
require_once 'subscribe.php';
require_once $global['systemRootPath'] . 'objects/functions.php';
header('Content-Type: application/json');
if(empty($_POST['current']) && !empty($_GET['current'])){
@ -9,19 +11,38 @@ if(empty($_POST['current']) && !empty($_GET['current'])){
if(empty($_POST['rowCount']) && !empty($_GET['rowCount'])){
$_POST['rowCount']=$_GET['rowCount'];
}
if(empty($_POST['sort']) && !empty($_GET['sort'])){
$_POST['sort']=$_GET['sort'];
}
if(empty($_POST['searchPhrase']) && !empty($_GET['searchPhrase'])){
$_POST['searchPhrase']=$_GET['searchPhrase'];
}
$videos = Video::getAllVideos("viewableNotAd");
$total = Video::getTotalVideos("viewableNotAd");
$reversed = array_reverse($videos);
$videos = $reversed;
foreach ($videos as $key => $value) {
unset($videos[$key]['password']);
unset($videos[$key]['recoverPass']);
$videos[$key]['Poster'] = "{$global['webSiteRootURL']}videos/".$videos[$key]['filename'].".jpg";
$videos[$key]['Thumbnail'] = "{$global['webSiteRootURL']}videos/".$videos[$key]['filename']."_thumbs.jpg";
$videos[$key]['VideoUrl'] = getVideosURL($videos[$key]['filename']);
$videos[$key]['createdHumanTiming'] = humanTiming(strtotime($videos[$key]['created']));
$videos[$key]['pageUrl'] = "{$global['webSiteRootURL']}video/".$videos[$key]['clean_title'];
$videos[$key]['embedUrl'] = "{$global['webSiteRootURL']}videoEmbeded/".$videos[$key]['clean_title'];
unset($_POST['sort']);
unset($_POST['current']);
unset($_POST['searchPhrase']);
$_POST['rowCount'] = 10;
$_POST['sort']['created'] = "desc";
$videos[$key]['comments'] = Comment::getAllComments($videos[$key]['id']);
$videos[$key]['commentsTotal'] = Comment::getTotalComments($videos[$key]['id']);
foreach ($videos[$key]['comments'] as $key2 => $value2) {
$user = new User($value2['users_id']);
$videos[$key]['comments'][$key2]['userPhotoURL'] = User::getPhoto($videos[$key]['comments'][$key2]['users_id']);
$videos[$key]['comments'][$key2]['userName'] = $user->getNameIdentificationBd();
}
$videos[$key]['subscribers'] = Subscribe::getTotalSubscribes($videos[$key]['users_id']);
$videos[$key]['firstVideo'] = "";
foreach ($videos[$key]['VideoUrl'] as $value2) {
if($value2["type"] === 'video'){

View file

@ -61,7 +61,8 @@ foreach ($lifeStream as $value){
$userName = $u->getNameIdentificationBd();
$user = $u->getUser();
$photo = $u->getPhotoURL();
$obj->applications[] = array("key"=>$value->name, "users"=>$users, "name"=>$userName, "user"=>$user, "photo"=>$photo, "title"=>$row['title']);
$UserPhoto = $u->getPhoto();
$obj->applications[] = array("key"=>$value->name, "users"=>$users, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>$row['title']);
if($value->name === $_POST['name']){
$obj->error = (!empty($value->publishing))?false:true;
$obj->msg = (!$obj->error)?"ONLINE":"Waiting for Streamer";

View file

@ -0,0 +1,36 @@
<?php
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
require_once $global['systemRootPath'] . 'objects/video.php';
class MobileManager extends PluginAbstract {
public function getDescription() {
return "Manage the Mobile App";
}
public function getName() {
return "MobileManager";
}
public function getUUID() {
return "4c1f4f76-b336-4ddc-a4de-184efe715c09";
}
public function getTags() {
return array('free', 'mobile', 'android', 'ios');
}
public function getEmptyDataObject() {
global $global;
$obj = new stdClass();
$obj->aboutPage = "";
$obj->doNotAllowAnonimusAccess = false;
$obj->disableGif = false;
return $obj;
}
public function upload(){
}
}

View file

@ -0,0 +1,98 @@
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json');
require_once dirname(__FILE__) . '/../../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'plugin/LoginLDAP/LoginLDAP.php';
$object = new stdClass();
$object->error = true;
if (!User::canUpload() && (empty($_GET['user']) || empty($_GET['pass']))) {
$object->msg = "You need a user";
die(json_encode($object));
}
$user = $_GET['user'];
$password = $_GET['pass'];
$userObj = new User(0, $user, $password);
$userObj->login(false, true);
if (!User::canUpload()) {
$object->msg = "You can not upload";
die(json_encode($object));
}
// A list of permitted file extensions
$allowed = array('mp4', 'avi', 'mov', 'mkv', 'flv', 'mp3', 'wav', 'm4v', 'webm', 'wmv');
error_log("MOBILE UPLOAD: Starts");
if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
if (!in_array(strtolower($extension), $allowed)) {
$object->msg = "File extension error (" . $_FILES['upl']['name'] . "), we allow only (" . implode(",", $allowed) . ")";
error_log("MOBILE UPLOAD: {$object->msg}");
die(json_encode($object));
}
//chack if is an audio
$type = "video";
if (strcasecmp($extension, 'mp3') == 0 || strcasecmp($extension, 'wav') == 0) {
$type = 'audio';
}
require_once $global['systemRootPath'] . 'objects/video.php';
$duration = Video::getDurationFromFile($_FILES['upl']['tmp_name']);
// check if can upload video (about time limit storage)
if (!empty($global['videoStorageLimitMinutes'])) {
$maxDuration = $global['videoStorageLimitMinutes'] * 60;
$currentStorageUsage = getSecondsTotalVideosLength();
$thisFile = parseDurationToSeconds($duration);
$limitAfterThisFile = $currentStorageUsage + $thisFile;
if ($maxDuration < $limitAfterThisFile) {
$object->msg = "Sorry, your storage limit has run out."
. "<br>[Max Duration: {$maxDuration} Seconds]"
. "<br>[Current Srotage Usage: {$currentStorageUsage} Seconds]"
. "<br>[This File Duration: {$thisFile} Seconds]"
. "<br>[Limit after this file: {$limitAfterThisFile} Seconds]";
if (!empty($_FILES['upl']['videoId'])) {
$video = new Video("", "", $_FILES['upl']['videoId']);
$video->delete();
}
error_log("MOBILE UPLOAD: {$object->msg}");
die(json_encode($object));
}
}
$mainName = preg_replace("/[^A-Za-z0-9]/", "", cleanString($_FILES['upl']['name']));
$filename = uniqid($mainName . "_YPTuniqid_", true);
$video = new Video(preg_replace("/_+/", " ", $_FILES['upl']['name']), $filename, 0);
$video->setDuration($duration);
if ($type == 'audio') {
$video->setType($type);
} else {
$video->setType("video");
}
$video->setStatus('e');
if (!move_uploaded_file($_FILES['upl']['tmp_name'], "{$global['systemRootPath']}videos/original_" . $filename)) {
$object->msg = "Error on move_uploaded_file(" . $_FILES['upl']['tmp_name'] . ", " . "{$global['systemRootPath']}videos/original_" . $filename . ")";
error_log("MOBILE UPLOAD: {$object->msg}");
die($object->msg);
}
$video->queue();
$object->error = false;
$object->msg = "We sent your video to the encoder";
error_log("MOBILE SUCCESS UPLOAD: {$object->msg}");
die(json_encode($object));
} else {
error_log("MOBILE UPLOAD: File Not exists - " . print_r($_FILES, true));
}

View file

@ -448,7 +448,7 @@ img.rotate-90 {
-o-transform: rotate(270deg);
/* Opera */
}
.subscribeButton {
.subsB {
background-color: #e62117;
color: #FFF;
-webkit-transition: all 1s ease-out;
@ -456,23 +456,17 @@ img.rotate-90 {
-o-transition: all 1s ease-out;
transition: all 1s ease-out;
}
.subscribeButton:hover,
.subscribeButton:active,
.subscribeButton:focus {
background-color: #CC0000;
color: #FFF;
}
.subscribeButton span:before {
.subsB span:before {
content: "\f16a";
}
.subscribeButton.subscribed {
.subscribed {
background-color: #DDD;
color: #777;
}
.subscribeButton.subscribed span:before {
.subscribed span:before {
content: "\f00c";
}
.subscribeButton.subscribed:hover span:before {
.subscribed:hover span:before {
content: "\f057";
}
.profileBg {

View file

@ -1,12 +1,29 @@
<?php
$configFile = dirname(__FILE__).'/../../videos/configuration.php';
require_once $configFile;
$file = 'static2.gif';
$type = 'image/gif';
// if the thumb is not ready yet, try to find the default image
if(preg_match('/videos\/(.*)_thumbs.jpg$/', $_SERVER["REQUEST_URI"], $matches)){
$jpg = "{$global['systemRootPath']}videos/{$matches[1]}.jpg";
if(file_exists($jpg)){
$file = $jpg;
$type = 'image/jpg';
header("HTTP/1.0 404 Not Found");
header('Content-Type:' . $type);
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
}
if(empty($_GET['notFound'])){
header("Location: {$global['webSiteRootURL']}img/image404.php?notFound=1");
exit;
}
$file = 'static2.gif';
$type = 'image/gif';
/*
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);

View file

@ -180,13 +180,13 @@ function subscribe(email, user_id) {
if (response.subscribe == "i") {
$('.subscribeButton'+user_id).removeClass("subscribed");
$('.subscribeButton'+user_id+' b.text').text("Subscribe");
$('.subscribeButton'+user_id+' b.textTotal').text(parseInt($('.subscribeButton'+user_id+' b.textTotal').first().text())-1);
$('.subs'+user_id).removeClass("subscribed");
$('.subs'+user_id+' b.text').text("Subscribe");
$('b.textTotal').text(parseInt($('b.textTotal').first().text())-1);
} else {
$('.subscribeButton'+user_id).addClass("subscribed");
$('.subscribeButton'+user_id+' b.text').text("Subscribed");
$('.subscribeButton'+user_id+' b.textTotal').text(parseInt($('.subscribeButton'+user_id+' b.textTotal').first().text())+1);
$('.subs'+user_id).addClass("subscribed");
$('.subs'+user_id+' b.text').text("Subscribed");
$('b.textTotal').text(parseInt($('b.textTotal').first().text())+1);
}
$('#popover-content #subscribeEmail').val(email);
$('.subscribeButton'+user_id).popover('hide');