<?php
$startTime = microtime(true);
$fileDir = dirname(__FILE__);
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
$dependencies = new XenForo_Dependencies_Public();
$dependencies->preLoadData();
$q = XenForo_Application::get('db')->fetchAll("
SELECT * from xengallery_media where media_type = 'video_embed' and media_state = 'visible' and media_embed_url like '%youtube.com%'");
$x = 0;
foreach ($q as $v)
{
$raw = parse_url($v['media_embed_url']);
parse_str($raw['query'], $query);
if (array_key_exists('v', $query))
{
$video_url = @file_get_contents('https://www.youtube.com/oembed?format=json&url=' . $v['media_embed_url']);
if(!$video_url) {
echo('video DOES NOT exist' . "<br />\n");
$w = XenForo_Application::get('db')->query("UPDATE xengallery_media set media_state = 'moderated' where media_id = " . $v['media_id']);
$x++;
}
else
{
echo "Does exist!<br />\n";
}
}
}
echo "<br /><br />Done and moderated $x videos";