diff --git a/install/checkConfiguration.php b/install/checkConfiguration.php index a52772af6..971c689a3 100644 --- a/install/checkConfiguration.php +++ b/install/checkConfiguration.php @@ -1,174 +1,174 @@ post = $_POST; if (!file_exists($_POST['systemRootPath'] . "index.php")) { $obj->error = "Your system path to application ({$_POST['systemRootPath']}) is wrong"; echo json_encode($obj); exit; } $mysqli = @new mysqli($_POST['databaseHost'], $_POST['databaseUser'], $_POST['databasePass'], "", $_POST['databasePort']); /* * This is the "official" OO way to do it, * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0. */ if ($mysqli->connect_error) { $obj->error = ('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); echo json_encode($obj); exit; } if ($_POST['createTables'] == 2) { $sql = "CREATE DATABASE IF NOT EXISTS {$_POST['databaseName']}"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating database: " . $mysqli->error; echo json_encode($obj); exit; } } $mysqli->select_db($_POST['databaseName']); /* $cmd = "mysql -h {$_POST['databaseHost']} -u {$_POST['databaseUser']} -p {$_POST['databasePass']} {$_POST['databaseName']} < {$_POST['systemRootPath']}install/database.sql"; exec("{$cmd} 2>&1", $output, $return_val); if ($return_val !== 0) { $obj->error = "Error on command: {$cmd}"; echo json_encode($obj); exit; } */ if ($_POST['createTables'] > 0) { // Temporary variable, used to store current query $templine = ''; // Read in entire file $lines = file("{$_POST['systemRootPath']}install/database.sql"); // Loop through each line $obj->error = ""; foreach ($lines as $line) { // Skip it if it's a comment if (substr($line, 0, 2) == '--' || $line == '') continue; // Add this line to the current segment $templine .= $line; // If it has a semicolon at the end, it's the end of the query if (substr(trim($line), -1, 1) == ';') { // Perform the query if (!$mysqli->query($templine)) { $obj->error = ('Error performing query \'' . $templine . '\': ' . $mysqli->error . '

'); } // Reset temp variable to empty $templine = ''; } } } $sql = "DELETE FROM users WHERE id = 1 "; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error deleting user: " . $mysqli->error; echo json_encode($obj); exit; } $sql = "INSERT INTO users (id, user, email, password, created, modified, isAdmin) VALUES (1, 'admin', '" . $_POST['contactEmail'] . "', '" . md5($_POST['systemAdminPass']) . "', now(), now(), true)"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating admin user: " . $mysqli->error; echo json_encode($obj); exit; } $sql = "DELETE FROM categories WHERE id = 1 "; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error deleting category: " . $mysqli->error; echo json_encode($obj); exit; } $sql = "INSERT INTO categories (id, name, clean_name, description, created, modified) VALUES (1, 'Default', 'default','', now(), now())"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating category: " . $mysqli->error; echo json_encode($obj); exit; } $sql = "DELETE FROM configurations WHERE id = 1 "; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error deleting configuration: " . $mysqli->error; echo json_encode($obj); exit; } $sql = "INSERT INTO configurations (id, video_resolution, users_id, version, webSiteTitle, language, contactEmail, encoderURL, created, modified) " . " VALUES " . " (1, '858:480', 1,'{$installationVersion}', '{$_POST['webSiteTitle']}', '{$_POST['mainLanguage']}', '{$_POST['contactEmail']}', 'https://encoder.youphptube.com/', now(), now())"; if ($mysqli->query($sql) !== TRUE) { $obj->error = "Error creating configuration: " . $mysqli->error; echo json_encode($obj); exit; } $mysqli->close(); if(empty($_POST['salt'])){ $_POST['salt'] = uniqid(); } $content = "error = "Error copying the encoding progress sample files. Check whether the directory {$_POST['systemRootPath']}videos/ exists and the process have permission"; echo json_encode($obj); exit; } */ $obj->success = true; echo json_encode($obj); diff --git a/install/database.sql b/install/database.sql index 11a8f38af..9e1b510d4 100644 --- a/install/database.sql +++ b/install/database.sql @@ -1,511 +1,512 @@ -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; -- ----------------------------------------------------- -- Table `users` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `users` ( `id` INT NOT NULL AUTO_INCREMENT, `user` VARCHAR(45) NOT NULL, `name` VARCHAR(45) NULL, `email` VARCHAR(45) NULL, `password` VARCHAR(145) NOT NULL, `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, `isAdmin` TINYINT(1) NOT NULL DEFAULT 0, `status` ENUM('a', 'i') NOT NULL DEFAULT 'a', `photoURL` VARCHAR(255) NULL, `lastLogin` DATETIME NULL, `recoverPass` VARCHAR(255) NULL, `backgroundURL` VARCHAR(255) NULL, `canStream` TINYINT(1) NULL, `canUpload` TINYINT(1) NULL, `canViewChart` TINYINT(1) NOT NULL DEFAULT 0, `about` TEXT NULL, `channelName` VARCHAR(45) NULL, `emailVerified` TINYINT(1) NOT NULL DEFAULT 0, `analyticsCode` VARCHAR(45) NULL DEFAULT NULL, `externalOptions` TEXT NULL, `first_name` VARCHAR(255) NULL DEFAULT NULL, `last_name` VARCHAR(255) NULL DEFAULT NULL, `address` VARCHAR(255) NULL DEFAULT NULL, `zip_code` VARCHAR(45) NULL DEFAULT NULL, `country` VARCHAR(100) NULL DEFAULT NULL, `region` VARCHAR(100) NULL DEFAULT NULL, `city` VARCHAR(100) NULL DEFAULT NULL, `donationLink` VARCHAR(225) NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `user_UNIQUE` (`user` ASC)) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `users_blob` ( `id` INT NOT NULL AUTO_INCREMENT, `blob` LONGBLOB NULL, `users_id` INT NOT NULL, `created` DATETIME NULL, `modified` DATETIME NULL, `type` VARCHAR(45) NULL, PRIMARY KEY (`id`), INDEX `fk_users_document_image_users1_idx` (`users_id` ASC), CONSTRAINT `fk_users_document_image_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `categories` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `categories` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `clean_name` VARCHAR(45) NOT NULL, `description` TEXT NULL, `nextVideoOrder` INT(2) NOT NULL DEFAULT '0', `parentId` INT NOT NULL DEFAULT '0', `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, `iconClass` VARCHAR(45) NOT NULL DEFAULT 'fa fa-folder', `users_id` INT(11) NOT NULL DEFAULT 1, `private` TINYINT(1) NULL DEFAULT 0, + `allow_download` TINYINT(1) NULL DEFAULT 1, PRIMARY KEY (`id`), INDEX `fk_categories_users1_idx` (`users_id` ASC), UNIQUE INDEX `clean_name_UNIQUE` (`clean_name` ASC), CONSTRAINT `fk_categories_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `sites` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NULL DEFAULT NULL, `url` VARCHAR(255) NOT NULL, `created` DATETIME NULL DEFAULT NULL, `modified` DATETIME NULL DEFAULT NULL, `status` CHAR(1) NULL DEFAULT NULL, `secret` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `videos` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `videos` ( `id` INT NOT NULL AUTO_INCREMENT, `title` VARCHAR(190) NOT NULL, `clean_title` VARCHAR(190) NOT NULL, `description` TEXT NULL, `views_count` INT NOT NULL DEFAULT 0, `views_count_25` INT(11) NULL DEFAULT 0, `views_count_50` INT(11) NULL DEFAULT 0, `views_count_75` INT(11) NULL DEFAULT 0, `views_count_100` INT(11) NULL DEFAULT 0, `status` ENUM('a', 'i', 'e', 'x', 'd', 'xmp4', 'xwebm', 'xmp3', 'xogg', 'ximg', 'u', 'p', 't') NOT NULL DEFAULT 'e' COMMENT 'a = active\ni = inactive\ne = encoding\nx = encoding error\nd = downloading\nu = Unlisted\np = private\nxmp4 = encoding mp4 error \nxwebm = encoding webm error \nxmp3 = encoding mp3 error \nxogg = encoding ogg error \nximg = get image error\nt = Transfering' , `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, `users_id` INT NOT NULL, `categories_id` INT NOT NULL, `filename` VARCHAR(255) NOT NULL, `duration` VARCHAR(15) NOT NULL, `type` ENUM('audio', 'video', 'embed', 'linkVideo', 'linkAudio', 'torrent', 'pdf', 'image', 'gallery', 'article', 'serie') NOT NULL DEFAULT 'video', `videoDownloadedLink` VARCHAR(255) NULL, `order` INT UNSIGNED NOT NULL DEFAULT 1, `rotation` SMALLINT NULL DEFAULT 0, `zoom` FLOAT NULL DEFAULT 1, `youtubeId` VARCHAR(45) NULL, `videoLink` VARCHAR(255) NULL, `next_videos_id` INT NULL, `isSuggested` INT(1) NOT NULL DEFAULT 0, `trailer1` VARCHAR(255) NULL DEFAULT NULL, `trailer2` VARCHAR(255) NULL DEFAULT NULL, `trailer3` VARCHAR(255) NULL DEFAULT NULL, `rate` FLOAT(4,2) NULL DEFAULT NULL, `can_download` TINYINT(1) NULL DEFAULT NULL, `can_share` TINYINT(1) NULL DEFAULT NULL, `rrating` VARCHAR(45) NULL DEFAULT NULL, `externalOptions` TEXT NULL DEFAULT NULL, `only_for_paid` TINYINT(1) NULL DEFAULT NULL, `serie_playlists_id` INT(11) NULL DEFAULT NULL, `sites_id` INT(11) NULL, PRIMARY KEY (`id`), INDEX `fk_videos_users_idx` (`users_id` ASC), INDEX `fk_videos_categories1_idx` (`categories_id` ASC), UNIQUE INDEX `clean_title_UNIQUE` (`clean_title` ASC), INDEX `index5` (`order` ASC), INDEX `fk_videos_videos1_idx` (`next_videos_id` ASC), INDEX `fk_videos_sites1_idx` (`sites_id` ASC), CONSTRAINT `fk_videos_sites1` FOREIGN KEY (`sites_id`) REFERENCES `sites` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_videos_users` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_videos_categories1` FOREIGN KEY (`categories_id`) REFERENCES `categories` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_videos_videos1` FOREIGN KEY (`next_videos_id`) REFERENCES `videos` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_videos_playlists1` FOREIGN KEY (`serie_playlists_id`) REFERENCES `playlists` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `comments` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `comments` ( `id` INT NOT NULL AUTO_INCREMENT, `comment` TEXT NOT NULL, `videos_id` INT NOT NULL, `users_id` INT NOT NULL, `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, `comments_id_pai` INT NULL, `pin` INT(1) NOT NULL DEFAULT 0 COMMENT 'If = 1 will be on the top', PRIMARY KEY (`id`), INDEX `fk_comments_videos1_idx` (`videos_id` ASC), INDEX `fk_comments_users1_idx` (`users_id` ASC), INDEX `fk_comments_comments1_idx` (`comments_id_pai` ASC), CONSTRAINT `fk_comments_videos1` FOREIGN KEY (`videos_id`) REFERENCES `videos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_comments_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_comments_comments1` FOREIGN KEY (`comments_id_pai`) REFERENCES `comments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `configurations` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `configurations` ( `id` INT NOT NULL, `video_resolution` VARCHAR(12) NOT NULL, `users_id` INT NOT NULL, `version` VARCHAR(10) NOT NULL, `webSiteTitle` VARCHAR(45) NOT NULL DEFAULT 'YouPHPTube', `language` VARCHAR(6) NOT NULL DEFAULT 'en', `contactEmail` VARCHAR(45) NOT NULL, `modified` DATETIME NOT NULL, `created` DATETIME NOT NULL, `authGoogle_id` VARCHAR(255) NULL, `authGoogle_key` VARCHAR(255) NULL, `authGoogle_enabled` TINYINT(1) NOT NULL DEFAULT 0, `authFacebook_id` VARCHAR(255) NULL, `authFacebook_key` VARCHAR(255) NULL, `authFacebook_enabled` TINYINT(1) NOT NULL DEFAULT 0, `authCanUploadVideos` TINYINT(1) NOT NULL DEFAULT 0, `authCanViewChart` TINYINT(2) NOT NULL DEFAULT 0, `authCanComment` TINYINT(1) NOT NULL DEFAULT 1, `head` TEXT NULL, `logo` VARCHAR(255) NULL, `logo_small` VARCHAR(255) NULL, `adsense` TEXT NULL, `mode` ENUM('Youtube', 'Gallery') NULL DEFAULT 'Youtube', `disable_analytics` TINYINT(1) NULL DEFAULT 0, `disable_youtubeupload` TINYINT(1) NULL DEFAULT 0, `allow_download` TINYINT(1) NULL DEFAULT 0, `session_timeout` INT NULL DEFAULT 3600, `autoplay` TINYINT(1) NULL, `theme` VARCHAR(45) NULL DEFAULT 'default', `smtp` TINYINT(1) NULL, `smtpAuth` TINYINT(1) NULL, `smtpSecure` VARCHAR(255) NULL COMMENT '\'ssl\'; // secure transfer enabled REQUIRED for Gmail', `smtpHost` VARCHAR(255) NULL COMMENT '\"smtp.gmail.com\"', `smtpUsername` VARCHAR(255) NULL COMMENT '\"email@gmail.com\"', `smtpPassword` VARCHAR(255) NULL, `smtpPort` INT NULL, `encoderURL` VARCHAR(255) NULL, PRIMARY KEY (`id`), INDEX `fk_configurations_users1_idx` (`users_id` ASC), CONSTRAINT `fk_configurations_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `videos_statistics` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `videos_statistics` ( `id` INT NOT NULL AUTO_INCREMENT, `when` DATETIME NOT NULL, `ip` VARCHAR(45) NULL, `users_id` INT NULL, `videos_id` INT NOT NULL, `created` DATETIME NULL DEFAULT NULL, `modified` DATETIME NULL DEFAULT NULL, `lastVideoTime` INT(11) NULL DEFAULT NULL, `session_id` VARCHAR(45) NOT NULL, PRIMARY KEY (`id`), INDEX `fk_videos_statistics_users1_idx` (`users_id` ASC), INDEX `fk_videos_statistics_videos1_idx` (`videos_id` ASC), INDEX `when_statisci` (`when` ASC), INDEX `session_id_statistics` (`session_id` ASC), CONSTRAINT `fk_videos_statistics_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_videos_statistics_videos1` FOREIGN KEY (`videos_id`) REFERENCES `videos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `likes` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `likes` ( `id` INT NOT NULL AUTO_INCREMENT, `like` INT(1) NOT NULL DEFAULT 0 COMMENT '1 = Like\n0 = Does not metter\n-1 = Dislike', `created` DATETIME NULL, `modified` DATETIME NULL, `videos_id` INT NOT NULL, `users_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_likes_videos1_idx` (`videos_id` ASC), INDEX `fk_likes_users1_idx` (`users_id` ASC), CONSTRAINT `fk_likes_videos1` FOREIGN KEY (`videos_id`) REFERENCES `videos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_likes_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `users_groups` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `users_groups` ( `id` INT NOT NULL AUTO_INCREMENT, `group_name` VARCHAR(45) NULL, `created` DATETIME NULL, `modified` DATETIME NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `users_has_users_groups` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `users_has_users_groups` ( `users_id` INT NOT NULL, `users_groups_id` INT NOT NULL, PRIMARY KEY (`users_id`, `users_groups_id`), INDEX `fk_users_has_users_groups_users_groups1_idx` (`users_groups_id` ASC), INDEX `fk_users_has_users_groups_users1_idx` (`users_id` ASC), UNIQUE INDEX `index_user_groups_unique` (`users_groups_id` ASC, `users_id` ASC), CONSTRAINT `fk_users_has_users_groups_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_users_has_users_groups_users_groups1` FOREIGN KEY (`users_groups_id`) REFERENCES `users_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `videos_group_view` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `videos_group_view` ( `id` INT NOT NULL AUTO_INCREMENT, `users_groups_id` INT NOT NULL, `videos_id` INT NOT NULL, INDEX `fk_videos_group_view_users_groups1_idx` (`users_groups_id` ASC), INDEX `fk_videos_group_view_videos1_idx` (`videos_id` ASC), PRIMARY KEY (`id`), CONSTRAINT `fk_videos_group_view_users_groups1` FOREIGN KEY (`users_groups_id`) REFERENCES `users_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_videos_group_view_videos1` FOREIGN KEY (`videos_id`) REFERENCES `videos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `subscribes` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `subscribes` ( `id` INT NOT NULL AUTO_INCREMENT, `email` VARCHAR(100) NOT NULL, `status` ENUM('a', 'i') NOT NULL DEFAULT 'a', `created` DATETIME NULL, `modified` DATETIME NULL, `ip` VARCHAR(45) NULL, `users_id` INT NOT NULL DEFAULT 1 COMMENT 'subscribes to user channel', `notify` TINYINT(1) NOT NULL DEFAULT 1, `subscriber_users_id` INT(11) NOT NULL, PRIMARY KEY (`id`), INDEX `fk_subscribes_users1_idx` (`users_id` ASC), INDEX `fk_subscribes_users2_idx` (`subscriber_users_id` ASC), CONSTRAINT `fk_subscribes_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_subscribes_users2` FOREIGN KEY (`subscriber_users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `playlists` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `playlists` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NOT NULL, `created` DATETIME NULL, `modified` DATETIME NULL, `users_id` INT NOT NULL, `status` ENUM('public', 'private', 'unlisted', 'favorite', 'watch_later') NOT NULL DEFAULT 'public', PRIMARY KEY (`id`), INDEX `fk_playlists_users1_idx` (`users_id` ASC), CONSTRAINT `fk_playlists_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `playlists_has_videos` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `playlists_has_videos` ( `playlists_id` INT NOT NULL, `videos_id` INT NOT NULL, `order` INT NULL, PRIMARY KEY (`playlists_id`, `videos_id`), INDEX `fk_playlists_has_videos_videos1_idx` (`videos_id` ASC), INDEX `fk_playlists_has_videos_playlists1_idx` (`playlists_id` ASC), CONSTRAINT `fk_playlists_has_videos_playlists1` FOREIGN KEY (`playlists_id`) REFERENCES `playlists` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_playlists_has_videos_videos1` FOREIGN KEY (`videos_id`) REFERENCES `videos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `plugins` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `plugins` ( `id` INT NOT NULL AUTO_INCREMENT, `uuid` VARCHAR(45) NOT NULL, `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active', `created` DATETIME NULL, `modified` DATETIME NULL, `object_data` TEXT NULL, `name` VARCHAR(255) NOT NULL, `dirName` VARCHAR(255) NOT NULL, `pluginversion` VARCHAR(6) NULL, PRIMARY KEY (`id`), UNIQUE INDEX `uuid_UNIQUE` (`uuid` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `comments_likes` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `comments_likes` ( `id` INT NOT NULL AUTO_INCREMENT, `like` INT(1) NOT NULL, `created` DATETIME NULL, `modified` DATETIME NULL, `users_id` INT NOT NULL, `comments_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `fk_comments_likes_users1_idx` (`users_id` ASC), INDEX `fk_comments_likes_comments1_idx` (`comments_id` ASC), CONSTRAINT `fk_comments_likes_users1` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_comments_likes_comments1` FOREIGN KEY (`comments_id`) REFERENCES `comments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `category_type_cache` -- ----------------------------------------------------- CREATE TABLE `category_type_cache` ( `categoryId` int(11) NOT NULL, `type` int(2) NOT NULL COMMENT '0=both, 1=audio, 2=video' DEFAULT 0, `manualSet` int(1) NOT NULL COMMENT '0=auto, 1=manual' DEFAULT 0 ) ENGINE=InnoDB; ALTER TABLE `category_type_cache` ADD UNIQUE KEY `categoryId` (`categoryId`); ALTER TABLE `plugins` ADD INDEX `plugin_status` (`status` ASC); ALTER TABLE `videos` ADD INDEX `videos_status_index` (`status` ASC), ADD INDEX `is_suggested_index` (`isSuggested` ASC), ADD INDEX `views_count_index` (`views_count` ASC), ADD INDEX `filename_index` (`filename` ASC); COMMIT; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/objects/category.php b/objects/category.php index 4bff0c6ed..06077205e 100644 --- a/objects/category.php +++ b/objects/category.php @@ -1,531 +1,542 @@ users_id)) { $this->users_id == User::getId(); } return $this->users_id; } function getPrivate() { return $this->private; } function setUsers_id($users_id) { // only admin can change owner if (!empty($this->users_id) && !User::isAdmin()) { return false; } $this->users_id = intval($users_id); } function setPrivate($private) { $this->private = empty($private) ? 0 : 1; } function setName($name) { $this->name = xss_esc($name); } function setClean_name($clean_name) { $clean_name = preg_replace('/\W+/', '-', strtolower(cleanString($clean_name))); $this->clean_name = $clean_name; } function setNextVideoOrder($nextVideoOrder) { $this->nextVideoOrder = $nextVideoOrder; } function setParentId($parentId) { $this->parentId = $parentId; } function setType($type, $overwriteUserId = 0) { global $global; $internalId = $overwriteUserId; if (empty($internalId)) { $internalId = $this->id; } $exist = false; // require this cause of Video::autosetCategoryType - but should be moveable easy here.. require_once dirname(__FILE__) . '/../objects/video.php'; $sql = "SELECT * FROM `category_type_cache` WHERE categoryId = ?"; $res = sqlDAL::readSql($sql, "i", array($internalId)); $catTypeCache = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($catTypeCache != false) { $exist = true; } if ($type == "3") { // auto-cat-type Video::autosetCategoryType($internalId); } else { if ($exist) { $sql = "UPDATE `category_type_cache` SET `type` = ?, `manualSet` = '1' WHERE `category_type_cache`.`categoryId` = ?;"; sqlDAL::writeSql($sql, "si", array($type, $internalId)); } else { $sql = "INSERT INTO `category_type_cache` (`categoryId`, `type`, `manualSet`) VALUES (?,?,'1')"; sqlDAL::writeSql($sql, "is", array($internalId, $type)); } } } function setDescription($description) { $this->description = xss_esc($description); } function __construct($id, $name = '') { if (empty($id)) { // get the category data from category and pass $this->name = xss_esc($name); } else { $this->id = $id; // get data from id $this->load($id); } } private function load($id) { $row = self::getCategory($id); if (empty($row)) return false; foreach ($row as $key => $value) { $this->$key = $value; } return true; } function loadSelfCategory() { $this->load($this->getId()); } function save($allowOfflineUser = false) { global $global; if (!$allowOfflineUser && !self::canCreateCategory()) { return false; } if (!$allowOfflineUser && !empty($this->id) && !self::userCanEditCategory($this->id)) { return false; } if (empty($this->users_id)) { $this->users_id = User::getId(); } $this->clean_name = self::fixCleanTitle($this->clean_name, 1, $this->id); // check if clean name exists $exists = $this->getCategoryByName($this->clean_name); if (!empty($exists) && $exists['id'] != $this->id) { $this->clean_name .= uniqid(); } $this->nextVideoOrder = intval($this->nextVideoOrder); $this->parentId = intval($this->parentId); if (!empty($this->id)) { $sql = "UPDATE categories SET " . "name = ?," . "clean_name = ?," . "description = ?," . "nextVideoOrder = ?," . "parentId = ?," . "iconClass = ?," . "users_id = ?," - . "`private` = ?, modified = now() WHERE id = ?"; - $format = "sssiisiii"; - $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->id); + . "`private` = ?, allow_download = ?, modified = now() WHERE id = ?"; + $format = "sssiisiiii"; + $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download(), $this->id); } else { $sql = "INSERT INTO categories ( " . "name," . "clean_name," . "description," . "nextVideoOrder," . "parentId," . "iconClass, " . "users_id, " - . "`private`, created, modified) VALUES (?, ?,?,?,?,?,?,?,now(), now())"; - $format = "sssiisii"; - $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate()); + . "`private`, allow_download, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,now(), now())"; + $format = "sssiisiii"; + $values = array(xss_esc($this->name), xss_esc($this->clean_name), xss_esc($this->description), $this->nextVideoOrder, $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getPrivate(), $this->getAllow_download()); } $insert_row = sqlDAL::writeSql($sql, $format, $values); if ($insert_row) { if (empty($this->id)) { $id = $global['mysqli']->insert_id; } else { $id = $this->id; } return $id; } else { die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } } static function fixCleanTitle($clean_title, $count, $id, $original_title = "") { global $global; if (empty($original_title)) { $original_title = $clean_title; } $sql = "SELECT * FROM categories WHERE clean_name = '{$clean_title}' "; if (!empty($id)) { $sql .= " AND id != {$id} "; } $sql .= " LIMIT 1"; $res = sqlDAL::readSql($sql, "", array(), true); $cleanTitleExists = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($cleanTitleExists != false) { return self::fixCleanTitle($original_title . "-" . $count, $count + 1, $videoId, $original_title); } return $clean_title; } function delete() { if (!self::canCreateCategory()) { return false; } if (!self::userCanEditCategory($this->id)) { return false; } // cannot delete default category if ($this->id == 1) { return false; } global $global; if (!empty($this->id)) { $sql = "DELETE FROM categories WHERE id = ?"; } else { return false; } return sqlDAL::writeSql($sql, "i", array($this->id)); } static function getCategoryType($categoryId) { global $global; $sql = "SELECT * FROM `category_type_cache` WHERE categoryId = ?;"; $res = sqlDAL::readSql($sql, "i", array($categoryId)); $data = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($res) { if (!empty($data)) { return $data; } else { return array("categoryId" => "-1", "type" => "0", "manualSet" => "0"); } } else { return array("categoryId" => "-1", "type" => "0", "manualSet" => "0"); } } static function getCategory($id) { global $global; $id = intval($id); $sql = "SELECT * FROM categories WHERE id = ? LIMIT 1"; $res = sqlDAL::readSql($sql, "i", array($id)); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($result) { $result['name'] = xss_esc_back($result['name']); } return ($res) ? $result : false; } static function getCategoryByName($name) { global $global; $sql = "SELECT * FROM categories WHERE clean_name = ? LIMIT 1"; $res = sqlDAL::readSql($sql, "s", array($name)); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($result) { $result['name'] = xss_esc_back($result['name']); } return ($res) ? $result : false; } static function getOrCreateCategoryByName($name) { $cat = self::getCategoryByName($name); if (empty($cat)) { $obj = new Category(0); $obj->setName($name); $obj->setClean_name($name); $obj->setDescription(""); $obj->setIconClass(""); $obj->setNextVideoOrder(0); $obj->setParentId(0); $id = $obj->save(); return self::getCategoryByName($name); } return $cat; } static function getCategoryDefault() { global $global; $sql = "SELECT * FROM categories ORDER BY id ASC LIMIT 1"; $res = sqlDAL::readSql($sql); $result = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($result) { $result['name'] = xss_esc_back($result['name']); } return ($res) ? $result : false; } static function getAllCategories($filterCanAddVideoOnly = false) { global $global, $config; if ($config->currentVersionLowerThen('5.01')) { return false; } $sql = "SELECT * FROM categories WHERE 1=1 "; if ($filterCanAddVideoOnly && !User::isAdmin()) { if (is_int($filterCanAddVideoOnly)) { $users_id = $filterCanAddVideoOnly; } else { $users_id = User::getId(); } if ($config->currentVersionGreaterThen('6.1')) { $sql .= " AND (private=0 OR users_id = '{$users_id}') "; } } if (!empty($_GET['parentsOnly'])) { $sql .= "AND parentId = 0 "; } if (isset($_POST['sort']['title'])) { unset($_POST['sort']['title']); } $sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY name ASC "); $res = sqlDAL::readSql($sql); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $category = array(); if ($res) { foreach ($fullResult as $row) { $row['name'] = xss_esc_back($row['name']); $row['total'] = self::getTotalVideosFromCategory($row['id']); $row['fullTotal'] = self::getTotalVideosFromCategory($row['id'], false, true, true); $row['owner'] = User::getNameIdentificationById(@$row['users_id']); $row['canEdit'] = self::userCanEditCategory($row['id']); $row['canAddVideo'] = self::userCanAddInCategory($row['id']); $category[] = $row; } //$category = $res->fetch_all(MYSQLI_ASSOC); } else { $category = false; die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $category; } static function userCanAddInCategory($categories_id, $users_id = 0) { if (empty($categories_id)) { return false; } if (empty($users_id)) { $users_id = User::getId(); } if (empty($users_id)) { return false; } $cat = new Category($categories_id); if (empty($cat->getPrivate()) || $users_id == $cat->getUsers_id()) { return true; } return false; } static function userCanEditCategory($categories_id, $users_id = 0) { if (empty($categories_id)) { return false; } if (empty($users_id)) { $users_id = User::getId(); } if (empty($users_id)) { return false; } if (User::isAdmin()) { return true; } $cat = new Category($categories_id); if ($users_id == $cat->getUsers_id()) { return true; } return false; } static function canCreateCategory() { global $advancedCustomUser; if (User::isAdmin()) { return true; } if ($advancedCustomUser && $advancedCustomUser->usersCanCreateNewCategories && User::canUpload()) { return true; } return false; } static function getChildCategories($parentId, $filterCanAddVideoOnly = false) { global $global, $config; if ($config->currentVersionLowerThen('5.01')) { return false; } $sql = "SELECT * FROM categories WHERE parentId=? AND id!=? "; if ($filterCanAddVideoOnly && !User::isAdmin()) { if (is_int($filterCanAddVideoOnly)) { $users_id = $filterCanAddVideoOnly; } else { $users_id = User::getId(); } if ($config->currentVersionGreaterThen('6.1')) { $sql .= " AND (private=0 OR users_id = '{$users_id}') "; } } $sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY name ASC "); $res = sqlDAL::readSql($sql, "ii", array($parentId, $parentId)); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $category = array(); if ($res) { foreach ($fullResult as $row) { $row['name'] = xss_esc_back($row['name']); $row['total'] = self::getTotalVideosFromCategory($row['id']); $category[] = $row; } } else { $category = false; die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $category; } static function getChildCategoriesFromTitle($clean_title) { $row = self::getCategoryByName($clean_title); return self::getChildCategories($row['id']); } static function getTotalVideosFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew=false) { global $global, $config; if ($renew || empty($_SESSION['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)])) { $sql = "SELECT count(id) as total FROM videos v WHERE 1=1 AND categories_id = ? "; if (User::isLogged()) { $sql .= " AND (v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "') OR (v.status='u' AND v.users_id ='" . User::getId() . "'))"; } else { $sql .= " AND v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "')"; } if (!$getAllVideos) { $sql .= Video::getUserGroupsCanSeeSQL(); } //echo $categories_id, $sql;exit; $res = sqlDAL::readSql($sql, "i", array($categories_id)); $fullResult = sqlDAL::fetchAllAssoc($res); sqlDAL::close($res); $total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']); $rows = self::getChildCategories($categories_id); foreach ($rows as $value) { $total += self::getTotalVideosFromCategory($value['id']); } if (session_status() == PHP_SESSION_NONE) { session_start(); } $_SESSION['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)] = $total; } return $_SESSION['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]; } static function clearCacheCount() { // clear category count cache if (session_status() == PHP_SESSION_NONE) { session_start(); } unset($_SESSION['categoryTotal']); //session_write_close(); } static function getTotalCategories($filterCanAddVideoOnly = false) { global $global, $config; if ($config->currentVersionLowerThen('5.01')) { return false; } $sql = "SELECT id, parentId FROM categories WHERE 1=1 "; if ($filterCanAddVideoOnly && !User::isAdmin()) { if (is_int($filterCanAddVideoOnly)) { $users_id = $filterCanAddVideoOnly; } else { $users_id = User::getId(); } if ($config->currentVersionGreaterThen('6.1')) { $sql .= " AND (private=0 OR users_id = '{$users_id}') "; } } if (!empty($_GET['parentsOnly'])) { $sql .= "AND parentId = 0 OR parentId = -1 "; } $sql .= BootGrid::getSqlSearchFromPost(array('name')); $res = sqlDAL::readSql($sql); $numRows = sqlDal::num_rows($res); sqlDAL::close($res); return $numRows; } function getIconClass() { if (empty($this->iconClass)) { return "fa fa-folder"; } return $this->iconClass; } function setIconClass($iconClass) { $this->iconClass = $iconClass; } function getName() { return $this->name; } function getClean_name() { return $this->clean_name; } function getDescription() { return $this->description; } + + function getAllow_download() { + return $this->allow_download; + } + + function setAllow_download($allow_download) { + $this->allow_download = intval($allow_download); + } + + } diff --git a/objects/categoryAddNew.json.php b/objects/categoryAddNew.json.php index ee38b6931..e41018a2d 100644 --- a/objects/categoryAddNew.json.php +++ b/objects/categoryAddNew.json.php @@ -1,28 +1,29 @@ setName($_POST['name']); $obj->setClean_name($_POST['clean_name']); $obj->setDescription(nl2br ($_POST['description'])); $obj->setIconClass($_POST['iconClass']); $obj->setNextVideoOrder($_POST['nextVideoOrder']); $obj->setParentId($_POST['parentId']); $obj->setPrivate($_POST['private']); +$obj->setAllow_download($_POST['allow_download']); $id = $obj->save(); $obj->setType($_POST['type'],$id); echo '{"status":"'.$id.'"}'; diff --git a/plugin/CustomizeUser/CustomizeUser.php b/plugin/CustomizeUser/CustomizeUser.php index 90f2dcf6d..7cfa3b71b 100644 --- a/plugin/CustomizeUser/CustomizeUser.php +++ b/plugin/CustomizeUser/CustomizeUser.php @@ -1,260 +1,264 @@ userCanAllowFilesDownload = false; $obj->userCanAllowFilesShare = false; $obj->userCanAllowFilesDownloadSelectPerVideo = false; $obj->userCanAllowFilesShareSelectPerVideo = false; $obj->usersCanCreateNewCategories = !isset($advancedCustom->usersCanCreateNewCategories) ? false : $advancedCustom->usersCanCreateNewCategories; $obj->userCanNotChangeCategory = !isset($advancedCustom->userCanNotChangeCategory) ? false : $advancedCustom->userCanNotChangeCategory; $obj->userMustBeLoggedIn = !isset($advancedCustom->userMustBeLoggedIn) ? false : $advancedCustom->userMustBeLoggedIn; $obj->onlyVerifiedEmailCanUpload = !isset($advancedCustom->onlyVerifiedEmailCanUpload) ? false : $advancedCustom->onlyVerifiedEmailCanUpload; $obj->sendVerificationMailAutomaic = !isset($advancedCustom->sendVerificationMailAutomaic) ? false : $advancedCustom->sendVerificationMailAutomaic; $obj->unverifiedEmailsCanNOTLogin = !isset($advancedCustom->unverifiedEmailsCanNOTLogin) ? false : $advancedCustom->unverifiedEmailsCanNOTLogin; $obj->newUsersCanStream = !isset($advancedCustom->newUsersCanStream) ? false : $advancedCustom->newUsersCanStream; $obj->doNotIndentifyByEmail = !isset($advancedCustom->doNotIndentifyByEmail) ? false : $advancedCustom->doNotIndentifyByEmail; $obj->doNotIndentifyByName = !isset($advancedCustom->doNotIndentifyByName) ? false : $advancedCustom->doNotIndentifyByName; $obj->doNotIndentifyByUserName = !isset($advancedCustom->doNotIndentifyByUserName) ? false : $advancedCustom->doNotIndentifyByUserName; $obj->hideRemoveChannelFromModeYoutube = !isset($advancedCustom->hideRemoveChannelFromModeYoutube) ? false : $advancedCustom->hideRemoveChannelFromModeYoutube; $obj->showChannelBannerOnModeYoutube = !isset($advancedCustom->showChannelBannerOnModeYoutube) ? false : $advancedCustom->showChannelBannerOnModeYoutube; $obj->encryptPasswordsWithSalt = !isset($advancedCustom->encryptPasswordsWithSalt) ? false : $advancedCustom->encryptPasswordsWithSalt; $obj->requestCaptchaAfterLoginsAttempts = !isset($advancedCustom->requestCaptchaAfterLoginsAttempts) ? 0 : $advancedCustom->requestCaptchaAfterLoginsAttempts; $obj->disableSignOutButton = false; $obj->disableNativeSignUp = !isset($advancedCustom->disableNativeSignUp) ? false : $advancedCustom->disableNativeSignUp; $obj->disableNativeSignIn = !isset($advancedCustom->disableNativeSignIn) ? false : $advancedCustom->disableNativeSignIn; $obj->disablePersonalInfo = !isset($advancedCustom->disablePersonalInfo) ? true : $advancedCustom->disablePersonalInfo; $obj->userCanChangeUsername = true; $obj->signInOnRight = false; $obj->doNotShowRightProfile = false; $obj->doNotShowLeftProfile = false; $obj->forceLoginToBeTheEmail = false; // added on 2019-02-11 $o = new stdClass(); $o->type = "textarea"; $o->value = ""; $obj->messageToAppearBelowLoginBox = $o; $obj->doNotShowTopBannerOnChannel = false; $obj->doNotShowMyChannelNameOnBasicInfo = false; $obj->doNotShowMyAnalyticsCodeOnBasicInfo = false; $obj->doNotShowMyAboutOnBasicInfo = false; $obj->MyChannelLabel = "My Channel"; $obj->afterLoginGoToMyChannel = false; $obj->afterLogoffGoToMyChannel = false; $obj->allowDonationLink = false; $obj->showEmailVerifiedMark = true; $obj->Checkmark1Enabled = true; $obj->Checkmark1HTML = ''; $obj->Checkmark2Enabled = true; $obj->Checkmark2HTML = ''; $obj->Checkmark3Enabled = true; $obj->Checkmark3HTML = ''; return $obj; } public function getUserOptions() { $obj = $this->getDataObject(); if ($obj->Checkmark1Enabled) { $userOptions["Checkmark 1"] = "checkmark1"; } if ($obj->Checkmark2Enabled) { $userOptions["Checkmark 2"] = "checkmark2"; } if ($obj->Checkmark3Enabled) { $userOptions["Checkmark 3"] = "checkmark3"; } return $userOptions; } static function canDownloadVideosFromUser($users_id) { global $config; $obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); if (empty($obj) || empty($obj->userCanAllowFilesDownload)) { return $config->getAllow_download(); } $user = new User($users_id); return !empty($user->getExternalOption('userCanAllowFilesDownload')); } static function setCanDownloadVideosFromUser($users_id, $value = true) { $obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); if (empty($obj) || empty($obj->userCanAllowFilesDownload)) { return false; } $user = new User($users_id); return $user->addExternalOptions('userCanAllowFilesDownload', $value); } static function canShareVideosFromUser($users_id) { global $advancedCustom; if (!empty($advancedCustom->disableShareAndPlaylist)) { return false; } $obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); if (empty($obj) || empty($obj->userCanAllowFilesShare)) { return true; } $user = new User($users_id); return !empty($user->getExternalOption('userCanAllowFilesShare')); } static function setCanShareVideosFromUser($users_id, $value = true) { $obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); if (empty($obj) || empty($obj->userCanAllowFilesShare)) { return false; } $user = new User($users_id); return $user->addExternalOptions('userCanAllowFilesShare', $value); } static function getSwitchUserCanAllowFilesDownload($users_id) { global $global; include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesDownload.php'; } static function getSwitchUserCanAllowFilesShare($users_id) { global $global; include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesShare.php'; } public function getMyAccount($users_id) { $objcu = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) { echo '
'; self::getSwitchUserCanAllowFilesDownload($users_id); echo '
'; } if (!empty($objcu) && !empty($objcu->userCanAllowFilesShare)) { echo '
'; self::getSwitchUserCanAllowFilesShare($users_id); echo '
'; } } public function getTags() { return array('free', 'customization', 'users'); } public function getChannelButton() { global $global, $isMyChannel; if (!$isMyChannel) { return ""; } $objcu = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); echo "
"; if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) { echo '
'; echo '
'; self::getSwitchUserCanAllowFilesDownload(User::getId()); echo '
'; } if (!empty($objcu) && !empty($objcu->userCanAllowFilesShare)) { echo '
'; echo '
'; self::getSwitchUserCanAllowFilesShare(User::getId()); echo '
'; } echo "
"; } public function getVideoManagerButton() { global $isMyChannel; $isMyChannel = true; return self::getChannelButton(); } static function canDownloadVideosFromVideo($videos_id) { $video = new Video("", "", $videos_id); if (empty($video)) { return false; } $users_id = $video->getUsers_id(); if (!self::canDownloadVideosFromUser($users_id)) { return false; } + $category = new Category($video->getCategories_id()); + if(is_object($category) && !$category->getAllow_download()){ + return false; + } $obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) { if (empty($video->getCan_download())) { return false; } } return true; } static function canShareVideosFromVideo($videos_id) { $video = new Video("", "", $videos_id); if (empty($video)) { return false; } $users_id = $video->getUsers_id(); if (!self::canShareVideosFromUser($users_id)) { return false; } $obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser"); if (!empty($obj->userCanAllowFilesShareSelectPerVideo)) { if (empty($video->getCan_share())) { return false; } } return true; } public function onUserSignup($users_id) { $obj = $this->getDataObject(); if ($obj->sendVerificationMailAutomaic) { url_get_contents("{$global['webSiteRootURL']}objects/userVerifyEmail.php?users_id=$users_id"); } } public function getWatchActionButton($videos_id) { global $global, $video; $obj = $this->getDataObject(); include $global['systemRootPath'] . 'plugin/CustomizeUser/actionButton.php'; } } diff --git a/plugin/TheaterButton/TheaterButton.php b/plugin/TheaterButton/TheaterButton.php old mode 100755 new mode 100644 diff --git a/updatedb/updateDb.v7.8.sql b/updatedb/updateDb.v7.8.sql new file mode 100644 index 000000000..ceaa14480 --- /dev/null +++ b/updatedb/updateDb.v7.8.sql @@ -0,0 +1,14 @@ +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; + + +ALTER TABLE `categories` +ADD COLUMN `allow_download` TINYINT(1) NULL DEFAULT 1; + + +UPDATE configurations SET version = '7.8', modified = now() WHERE id = 1; + +SET SQL_MODE=@OLD_SQL_MODE; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/view/managerCategories_body.php b/view/managerCategories_body.php index 0222a9e0e..a5f69b2eb 100644 --- a/view/managerCategories_body.php +++ b/view/managerCategories_body.php @@ -1,280 +1,287 @@
+
\ No newline at end of file