* Adds video to database. */ function addVideo() { $id = checkVideoExists(); $addVideo = new addVideo(); $playlistClass = new Playlist(); $playlist = $playlistClass->getMatchedPlaylist($id); $addVideo->addVideoByID($id, $playlist); } /** * Exits if latest video is already in database. */ function checkVideoExists() { $videoData = new videoData(); $youtube = new youtube(); $id = $youtube->getLatestVideoID(); if ($videoData->checkVideoExists($id)) { exit; } return $id; } if (isset($argv[1]) && $argv[1] == "cron") { addVideo(); } else { /* PASSWORD PROTECT */ require_once dirname(__FILE__) . '/../inc/class.passwordProtect.php'; /* PASSWORD PROTECT */ addVideo(); }
if (empty($_POST['description'])) { $errors[] = "description"; } else { $description = mysqli_real_escape_string($dbc, strip_tags($_POST['description'])); } $url_video = "https://www.youtube.com/watch?v={$vid}"; $url_thumbnail = "http://img.youtube.com/vi/{$vid}/sddefault.jpg"; // validate status if (isset($_POST['status'])) { $status = $_POST['status']; } else { $errors[] = 'status'; } $thumbnail = save_thumbnail_from_url($url_thumbnail, $vid); if (empty($errors)) { $result = addVideo($uid, $type_id, $title, $description, $thumbnail, $url_video, $status); if (mysqli_affected_rows($dbc) == 1) { echo "<script type='text/javascript'>\n alert('{$lang['AD_VIDEO_SUCCESS']}');\n window.location = 'list_videos.php';\n </script>\n "; } else { echo "<script type='text/javascript'>\n alert('{$lang['AD_FAIL']}');\n window.location = 'list_videos.php';\n </script>\n "; } } else { $error = $lang['AD_REQUIRED']; } } } include '../includes/backend/header-admin.php'; ?> <div class="content-wrapper"> <div class="container"> <div class="row">
/** * Handle parameter --add * * Add videos to the video_info table that are already on the wiki */ if ($addVideos) { // get embedded videos (premium) $excludeList = array('png', 'gif', 'bmp', 'jpg', 'jpeg', 'ogg', 'ico', 'svg', 'mp3', 'wav', 'midi'); $sqlWhere = implode("','", $excludeList); $sql = <<<SQL \t\tSELECT il_to as name \t\tFROM `imagelinks` \t\tWHERE NOT EXISTS ( SELECT 1 FROM image WHERE img_media_type = 'VIDEO' AND img_name = il_to ) \t\t\tAND LOWER(il_to) != 'placeholder' \t\t\tAND LOWER(SUBSTRING_INDEX(il_to, '.', -1)) NOT IN ( '{$sqlWhere}' ) SQL; $result = $db->query($sql, __METHOD__); while ($row = $db->fetchObject($result)) { printText("Embedded Video: "); addVideo($videoList, $row->name); $total++; } // get local videos $result = $db->select(array('image'), array('img_name as name'), array('img_media_type' => 'VIDEO'), __METHOD__); while ($row = $db->fetchObject($result)) { printText("Local Video: "); addVideo($videoList, $row->name); $total++; } echo "Wiki {$wgCityId}: TOTAL: {$total}, ADDED: {$added}, DUPLICATE: {$duplicate}, DUPLICATE IN DB: {$dupInDb}, INVALID: {$invalid}\n"; }
while ($row = $db->fetchObject($result)) { printText("Local Video: "); addVideo($videoList, $row->name); $total++; } // get related videos - RelatedVideos Articles $result = $db->select(array('page'), array('page_title'), array('page_namespace' => NS_RELATED_VIDEOS), __METHOD__); while ($row = $db->fetchObject($result)) { printText("RelatedVideos Article: {$row->page_title}\n"); $title = Title::newFromText($row->page_title, NS_RELATED_VIDEOS); $relatedVideosNSData = RelatedVideosNamespaceData::newFromTitle($title); $data = $relatedVideosNSData->getData(); foreach ($data['lists']['WHITELIST'] as $v) { printText('NS' . NS_RELATED_VIDEOS . ": "); addVideo($videoList, $v['title']); $total++; } } // get related videos - Global list $relatedVideosNSData = RelatedVideosNamespaceData::newFromGeneralMessage(); printText("MediaWiki:RelatedVideosGlobalList\n"); if (!empty($relatedVideosNSData)) { $data = $relatedVideosNSData->getData(); foreach ($data['lists']['WHITELIST'] as $v) { printText("GlobalList: "); addVideo($videoList, $v['title']); $total++; } } echo "Wiki {$wgCityId}: TOTAL: {$total}, ADDED: {$added}, DUPLICATE: {$duplicate}, DUPLICATE IN DB: {$dupInDb}, INVALID: {$invalid}\n"; echo "Total removed deleted videos: {$removed}\n";