Olá, ao adicionar um video na pagina videos.php pelo painel do adm ele me volta o seguinte erro:
Linha com erro
$info = new SimpleXMLElement(file_get_contents("http://gdata.youtube.com/feeds/api/videos/$link"));
Citar
Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/_uYFR1_EyZM) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found inC:\xampp\htdocs\03 - Genesis Nok\pages\videos.phpon line264
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\xampp\htdocs\03 - Genesis Nok\pages\videos.php:264 Stack trace: #0 C:\xampp\htdocs\03 - Genesis Nok\pages\videos.php(264): SimpleXMLElement->__construct('') #1 C:\xampp\htdocs\03 - Genesis Nok\system\load.page.php(7): include('C:\xampp\htdocs...') #2 C:\xampp\htdocs\03 - Genesis Nok\index.php(37): include_once('C:\xampp\htdocs...') #3 {main} thrown inC:\xampp\htdocs\03 - Genesis Nok\pages\videos.phpon line264
Codigo da pagina
<?php
# Variaveis globais.
$action = $_GET["action"];
$act = $_GET["act"];
$db = $SQL;
$accessLevel =($logged && $account_logged->getPageAccess()>0)? TRUE : FALSE;# Checa se as tabelas existem.
$res = $db->query("SHOW TABLES");if($res){foreach($res as $tabela){if($tabela[0]=="videos"){
$videos = TRUE;}if($tabela[0]=="videos_categorias"){
$videos_categorias = TRUE;}if($tabela[0]=="videos_comentarios"){
$videos_comentarios = TRUE;}}if(!$videos){try{
$db->exec("
CREATE TABLE `videos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`titulo` varchar(255) NOT NULL,
`descricao` text NOT NULL,
`categoria` int(11) NOT NULL,
`link` varchar(11) NOT NULL,
`ativo` int(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
");}catch(PDOException $e){
$main_content ="Erro:<br />".$e->getMessage();}}if(!$videos_categorias){try{
$db->exec("
CREATE TABLE `videos_categorias` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
");}catch(PDOException $e){
$main_content ="Erro:<br />".$e->getMessage();}}if(!$videos_comentarios){try{
$db->exec("
CREATE TABLE `videos_comentarios` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mensagem` text NOT NULL,
`character` varchar(255) NOT NULL,
`ip` varchar(15) NOT NULL,
`topico` int(11) NOT NULL,
`data` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ativo` int(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
");}catch(PDOException $e){
$main_content ="Erro:<br />".$e->getMessage();}}}else{
$main_content ="Erro ao adicionar tabelas ao banco de dados!";}# Se as tabelas existirem.if($videos && $videos_categorias && $videos_comentarios){# Se nao existir nenhuma acao.if(empty($action)&&!isset($action)){
$catFilter =(isset($_GET["cat"])&&!empty($_GET["cat"])&& is_numeric($_GET["cat"]))?" AND `categoria` = ".$_GET["cat"]."":"";
$resul = $db->query("SELECT `id`,`titulo`,`link` FROM `videos` WHERE `ativo` = 1".$catFilter.";");
$main_content ="<div class=\"conteudo\" style=\"background-image:url(layouts/tibiacom/images/content/scroll.gif);\">";
$main_content .="<center><a href=\"?subtopic=videos\"><img src=\"images/youtube.png\"></a></center>";
$main_content .=($accessLevel)?"<center><a href=\"?subtopic=videos&action=adminpanel\">Painel de Administração</a></center>":"";if($resul->rowCount()<=0){
$mc ="<br /><center><table cellpadding=\"5\" cellspacing=\"1\"><tr><td width=\"560px\" bgcolor=\"#F1E0C6\"><center>Nenhum vídeo cadastrado!<br /></center></td></tr>";
$div2 ="</div>";}
$categorias = $db->query("SELECT `id`, `nome` FROM `videos_categorias` ORDER BY nome ASC;");if($categorias->rowCount()<=0){
$mcs ="Nenhuma categoria cadastrada!";}
$tudos ="";
$t ="";
$i =0;foreach($categorias as $categoria){
$barra =($i !=0)?"|":"";
$space =($i = count($categorias)-1)?"":" ";
$adm =($accessLevel)?"<a href=\"?subtopic=videos&action=adminpanel&act=editcat&id=".$categoria["id"]."\"><img src=\"images/edit.png\" height=\"15\" weight=\"15\" /></a><a href=\"?subtopic=videos&action=adminpanel&act=delcat&id=".$categoria["id"]."\"><img src=\"images/del.png\" height=\"15\" weight=\"15\" /></a>":"";
$tudos .="$barra $adm<a href=\"?subtopic=videos&cat=".$categoria["id"]."\">".html_entity_decode($categoria["nome"])."</a>$space";
$t .="$barra ".html_entity_decode($categoria["nome"])."$space";
$i++;}
$tx =(strlen($t)>0)?"<a href=\"?subtopic=videos\">Todas</a> |":"";
$tam =(strlen($t)*8<560)?"560": strlen($t)*8;
$add =($accessLevel)?"<a href=\"?subtopic=videos&action=adminpanel&act=addcat\"><img src=\"images/add.png\" weight=\"15\" height=\"15\" /></a>":"";
$main_content .="<center><table cellpadding=\"5\" cellspacing=\"1\"><tr><td width=\"".$tam ."px\" colspan=\"3\" bgcolor=\"#555555\"><font color=\"white\" size=\"3\"><b><center>Categorias</center></b></font></td></tr>";
$main_content .="<tr><td width=\"".$tam ."px\" bgcolor=\"#F1E0C6\"><b><center>$mcs$tx$tudos$add</center></b></td></tr>";# Loop para os resultados que vem da database com os videos.foreach($resul as $res){
$id =(int)$res["id"];
$titulo = html_entity_decode($res["titulo"]);if($accessLevel){
$editar ="<a href=\"?subtopic=videos&action=adminpanel&act=edit&id=$id\">Editar Vídeo</a> ⇔";
$deletar ='<a href="?subtopic=videos&action=adminpanel&act=del&id='.$id.'"> Deletar Vídeo</a>';}
$embed ='<iframe width="560" height="349" src="http://www.youtube.com/embed/'.$res["link"].'" frameborder="0" allowfullscreen></iframe>';
$main_content .="<br /><center><table cellpadding=\"5\" cellspacing=\"1\"><tr><td width=\"550px\" bgcolor=\"#D4C0A1\"><center><b><a href=\"?subtopic=videos&id=$id\">$titulo</a></b></center></td></tr>";
$main_content .="<br /><tr><td width=\"550px\" bgcolor=\"#F1E0C6\"><center>$embed $editar $deletar<br /></center></td></tr>";
$div ="</div>";}
$main_content .="$mc</div>$div</table>".$div2."$div</center>";if(isset($_GET["id"])){
$id =(int)$_GET['id'];
$res = $db->query("SELECT `titulo`,`link`, `descricao` FROM `videos` WHERE `ativo` = 1 AND `id` = $id LIMIT 1;")->fetch();if(!$res){
$main_content ="Vídeo inexistente!<br /><a href=\"?subtopic=videos\">⇐ Voltar</a>";}else{
$resul = $db->query("SELECT `id`, `mensagem`, `character`, `data`, `ativo` FROM `videos_comentarios` WHERE `topico` = $id");
$resuls = $db->query("SELECT `id` FROM `videos_comentarios` WHERE `topico` = $id AND `ativo` = 1")->fetchAll();
$numM = $db->query("SELECT COUNT(`id`) FROM `videos_comentarios` WHERE `topico` = $id AND `ativo` = 1")->fetch();
$numM =($numM[0]>0)? $numM[0]." ":"";
$s =($numM >1|| $numM ==0)?"s":"";
$main_content ="<div class=\"conteudo\" style=\"background-image:url(layouts/tibiacom/images/content/scroll.gif);\">";
$main_content .="<center><table cellpadding=\"5\" cellspacing=\"1\"><tr><td width=\"200px\" colspan=\"3\" bgcolor=\"#505050\"><font color=\"white\" size=\"2\"><center><b>".$res["titulo"]."</b></center></font></td></tr>";
$main_content .="<tr><td width=\"500px\" bgcolor=\"#F1E0C6\"><center><iframe width=\"560\" height=\"349\" src=\"http://www.youtube.com/embed/".$res['link']."\" frameborder=\"0\" allowfullscreen></center></iframe></td></tr>";if($res["descricao"]){
$main_content .="<tr><td width=\"200px\" colspan=\"3\" bgcolor=\"#505050\"><font color=\"white\" size=\"2\"><center><b>Descrição</b></font></td></tr>";
$main_content .="<tr><td width=\"200px\" colspan=\"3\" bgcolor=\"#F1E0C6\"><center>".html_entity_decode($res["descricao"])."</center></td></tr>";}
$main_content .="<tr><td width=\"500px\" bgcolor=\"#505050\"><center><span style=\"color:white; font-weight:bold;\">".$numM."Comentário$s</span></center></td></tr>";foreach($resul as $resz){
preg_match_all("/(\d{4})-(\d{2})-(\d{2})\ (\d{2}):(\d{2}):(\d{2})/", $resz["data"], $matches);
$ifAccess =($accessLevel && $resz["ativo"])?" <a href=\"?subtopic=videos&action=adminpanel&act=delcom&id=".$resz["id"]."\"><img src=\"images/del.png\" height=\"15\" weight=\"15\" /></a>":"";
$msg = preg_replace("/(.{100})/i","$1<br />", html_entity_decode($resz["mensagem"]));if($resz["ativo"]){
$main_content .="<tr><td width=\"200px\" colspan=\"3\" bgcolor=\"#D4C0A5\"><center><b>[".$matches[3][0]."/".$matches[2][0]."] [<a href=\"?subtopic=characters&name=".urlencode($resz["character"])."\">".$resz["character"]."</a>] [".$matches[4][0].":".$matches[5][0]."]</b></center></td></tr>";
$main_content .="<tr><td width=\"200px\" colspan=\"3\" bgcolor=\"#F1E0C6\"><font color=\"black\" size=\"2\"></span><center>".$msg."$ifAccess</center></font></td></tr>";}elseif(!$resz["ativo"]&& $accessLevel){
$existe = TRUE;
$main_content .="<tr><td width=\"200px\" colspan=\"3\" bgcolor=\"#D4C0A5\"><center><b>[".$matches[3][0]."/".$matches[2][0]."] [<a href=\"?subtopic=characters&name=".urlencode($resz["character"])."\">".$resz["character"]."</a>] [".$matches[4][0].":".$matches[5][0]."]</b></center></td></tr>";
$main_content .="<tr><td width=\"200px\" colspan=\"3\" bgcolor=\"#F1E0C6\"><font color=\"black\" size=\"2\"></span><center><strike>".$msg."</strike> <a href=\"?subtopic=videos&action=adminpanel&act=ativarcom&id=".$resz["id"]."\"><img src=\"images/ativar.png\" height=\"15\" weight=\"15\" /></a></center></font></td></tr>";}}if(!count($resuls)){if($accessLevel && $existe){}else{
$main_content .="<tr><td width=\"500px\" bgcolor=\"#D4C0A5\"><center>Nenhum comentário foi feito!</center></td></tr>";}}
$todosChars ="";if($account_logged){
$accountPlayers = $account_logged->getPlayersList();
$accountPlayers->orderBy('name');foreach($accountPlayers as $char){
$todosChars .="<option value=\"".$char->getName()."\">".$char->getName()."</option>";}
$temChar =(!$accountPlayers)? TRUE : FALSE;}
$ifLogged ="
<tr><td width=\"500px\" bgcolor=\"#505050\"><span style=\"color:white; font-weight:bold;\">
<form action=\"?subtopic=videos&id=$id\" method=\"post\">
<fieldset>
<legend>Deixe um comentário</legend><br />
<select style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" name=\"character\">
$todosChars
</select> Character *<br />
<input type=\"hidden\" name=\"topico\" value=\"$id\" />
<textarea style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" cols=\"70\" rows=\"13\" name=\"mensagem\"></textarea>
<input type=\"submit\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" name=\"comment\" id=\"comment\" value=\"Comentar\" />
</fieldset>
</form>
</span></td></tr>
";
$main_content .=($logged &&!$temChar)? $ifLogged :"<tr><td width=\"500px\" bgcolor=\"#505050\"><center><span style=\"color:white; font-weight:bold;\">Você deve estar logado e ter um character para comentar!</span></center></td></tr>";
$main_content .="</div></div></table></div></center>";if(isset($_POST["comment"])&&!empty($_POST["comment"])){
$accountPlayers = $account_logged->getPlayersList();foreach($accountPlayers as $char){if($char->getName()== $_POST["character"]){
$character = TRUE;}}if(strlen($_POST["mensagem"])<1){
$main_content ="Você deve escrever uma mensagem para comentar!<br /><a href='?subtopic=videos&id=".$_POST["topico"]."'>⇐ Voltar</a>";}else{if(!$character){
$main_content ="Você deve escolher um character para comentar!<br /><a href='?subtopic=videos&id=".$_POST["topico"]."'>⇐ Voltar</a>";}else{try{
$reszs = $db->exec("INSERT INTO `videos_comentarios` (`mensagem`, `character`, `ip`, `topico`) VALUES (".$db->quote(htmlentities(strip_tags($_POST["mensagem"]))).", ".$db->quote(htmlentities($_POST["character"])).", ".$db->quote($_SERVER["REMOTE_ADDR"]).",".(int)$_POST["topico"].")");}catch(PDOException $e){
$main_content ="Erro:<br />".$e->getMessage();}if($reszs){
$main_content ="Comentário adicionado com sucesso!<br /><a href='?subtopic=videos&id=".$_POST["topico"]."'>⇐ Voltar</a>";}}}}}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& $accessLevel){
$main_content ="<br /><div class=\"conteudo\" style=\"background-image:url(layouts/tibiacom/images/content/scroll.gif);\">";
$main_content .="<center><table cellpadding=\"5\" cellspacing=\"1\"><tr><td width=\"500px\" colspan=\"3\" bgcolor=\"#555555\"><font color=\"white\" size=\"3\"><b>Painel de Controle</b></font></td></tr><tr><td width=\"250px\" bgcolor=\"#F1E0C6\"><b>Opções</b></td></tr>";
$main_content .="<tr><td width=\"250px\" bgcolor=\"#D4C0A1\"><a href=\"?subtopic=videos&action=adminpanel&act=addcat\">Adicionar Categoria</a></td></tr>";
$main_content .="<tr><td width=\"250px\" bgcolor=\"#D4C0A1\"><a href=\"?subtopic=videos&action=adminpanel&act=add\">Adicionar Vídeo</a></td></tr>";
$main_content .="<tr><td width=\"250px\" bgcolor=\"#D4C0A1\"><a href=\"?subtopic=videos\">Editar Vídeos</a></td></tr>";
$main_content .="<tr><td width=\"250px\" bgcolor=\"#D4C0A1\"><a href=\"?subtopic=videos\">Deletar Vídeos</a></td></tr>";
$main_content .="</div></div></table></div></center>";}elseif(isset($action)&&!empty($action)&& $action =="adminpanel"&&!$accessLevel){
$main_content ="Você não pode acessar esta área!";}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& $accessLevel && $act =="add"){
$main_content ="<fieldset>";
$main_content .="<legend>Adicionar Vídeo</legend>";
$main_content .="<form id=\"add\" name=\"add\" method=\"post\" action=\"?subtopic=videos&action=adminpanel&act=add\">";
$main_content .="<p style=\"font-size: 1.8em;\">";
$main_content .="<label for=\"link\">Link do Vídeo</label>";
$main_content .="<br /><input name=\"link\" type='text' id=\"link\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" />";
$main_content .="</p>";
$main_content .="<p>";
$main_content .="<input type=\"submit\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" name=\"button\" id=\"button\" value=\"Adicionar\" />";
$main_content .="</p>";
$main_content .="</form></fieldset>";if(isset($_POST["button"])&&!empty($_POST["button"])&& $accessLevel){
$link = $_POST["link"];
$res = $db->query("SELECT `id`,`nome` FROM `videos_categorias`;");
$tudo ="";foreach($res as $cat_info){
$cat_tudo .="<option name='".$cat_info["id"]."' value='".$cat_info["id"]."'>".html_entity_decode($cat_info["nome"])."</option>";}if(strlen($link)!=11){
preg_match_all("/([[:alnum:]|\_|\-]{11}?)/", $link, $matches);if(count($matches[0])>1){
$link ="Alexx Pirado lol";}else{
$link = $matches[0][0];}}if(strlen($link)!=11){
$erro ="O link do vídeo está errado ou incompleto.<br />Por favor, coloque a parte do link como o exemplo abaixo:<br />http://www.youtube.com/watch?v=<b><i>5abamRO41fE</i></b><br /><a href='?subtopic=videos&action=adminpanel&act=add'>⇐ Voltar</a>";}if(empty($erro)&&!isset($erro)){
$info =newSimpleXMLElement(file_get_contents("http://gdata.youtube.com/feeds/api/videos/$link"));
$titulo = $info->title;
$main_content ="<br /><div class=\"conteudo\" style=\"background-image:url(layouts/tibiacom/images/content/scroll.gif);\">";
$main_content .="<form action='?subtopic=videos&action=adminpanel&act=add' method='post'><input type='hidden' name='link' value='$link'>";
$main_content .="<center><table cellpadding=\"5\" cellspacing=\"1\"><tr><td width=\"800px\" colspan=\"3\" bgcolor=\"#555555\"><font color=\"white\" size=\"3\"><b>Informações do Vídeo</b></font></td></tr><tr><td width=\"250px\" bgcolor=\"#F1E0C6\"><b>Informação</b></td><td width=\"250px\" bgcolor=\"#F1E0C6\"><b>Valor</b></td></tr>";
$main_content .="<tr><td width=\"300px\" bgcolor=\"#D4C0A1\"><b>Link</b><span style='color:red;'>*</span></td><td width=\"300px\" bgcolor=\"#D4C0A1\"><a href='http://www.youtube.com/watch?v=$link'>http://www.youtube.com/watch?v=$link</a></td></tr>";
$main_content .="<tr><td width=\"250px\" bgcolor=\"#D4C0A1\"><b>Título</b><span style='color:red;'>*</span></td><td width=\"250px\" bgcolor=\"#D4C0A1\"><input type='text' name='titulo' value='$titulo' size='".strlen($titulo)."'></td></tr>";
$main_content .="<tr><td width=\"250px\" bgcolor=\"#D4C0A1\"><b>Descrição</b></td><td width=\"250px\" bgcolor=\"#D4C0A1\"><textarea id=\"descricao\" name=\"descricao\" cols=\"40\" rows=\"10\" onfocus=\"if(this.innerHTML == 'Coloque uma descrição no vídeo!') this.innerHTML = '';\" onblur=\"if(this.innerHTML == '') this.innerHTML = 'Coloque uma descrição no vídeo!';\">Coloque uma descrição no vídeo!</textarea></td></tr>";
$main_content .="<tr><td width=\"250px\" bgcolor=\"#D4C0A1\"><b>Categoria</b><span style='color:red;'>*</span></td><td width=\"250px\" bgcolor=\"#D4C0A1\"><select name='categoria'><option value=\"0\">Nenhuma</option>$cat_tudo</select></td></tr>";
$main_content .="</div></div></table>Os campos com <span style='color:red;margin:left;'>*</span> são obrigatórios!<br /><input type='submit' style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" name='avancar' value='Avançar'></center></div>";}else{
$main_content = $erro;}}if(isset($_POST["avancar"])&&!empty($_POST["avancar"])&& $accessLevel){
$link = $_POST["link"];
$titulo = $_POST["titulo"];
$categoria = htmlentities($_POST["categoria"]);
$descricao =($_POST["descricao"]!="Coloque uma descrição no vídeo!"&& $_POST["descricao"]!="Coloque uma descrição no vídeo!")? nl2br($_POST["descricao"]): NULL;if(!empty($link)&& isset($link)& $link !=11){if(!empty($titulo)&& isset($titulo)){try{
$res = $db->query("INSERT INTO `videos` (`titulo`, `descricao`, `categoria`, `link`) VALUES (".$db->quote(htmlentities($titulo)).", ".$db->quote(htmlentities($descricao)).", $categoria, ".$db->quote($link).")");}catch(PDOException $e){
$main_content ="Erro ao adicionar o vídeo!<br />".$e->getMessage()."<br /><a href='?subtopic=videos&action=adminpanel&act=add'>⇐ Voltar</a>";}if($res){
$main_content ="Vídeo adicionado com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}else{
$main_content ="O título não pode ficar em branco!<br /><a href='?subtopic=videos&action=adminpanel&act=add'>⇐ Voltar</a>";}}else{
$main_content ="Você deve fornecer um link para adicionar um vídeo!<br /><a href='?subtopic=videos&action=adminpanel&act=add'>⇐ Voltar</a>";}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& isset($act)&&!empty($act)&& $act =="del"&& $accessLevel){
$id =(int)$_GET["id"];
$main_content ="Você realmente deseja excluir o vídeo #$id?<br />
<form action=\"?subtopic=videos&action=adminpanel&act=del\" method=\"post\">
<input type=\"hidden\" name=\"id\" value=\"$id\">
<input type=\"submit\" name=\"botao\" value=\"Concluir\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\">
</form>
";if(isset($_POST["botao"])&&!empty($_POST["botao"])){
$id =(int)$_POST["id"];if(!empty($id)&& isset($id)&& is_numeric($id)){
$id =(int)$id;try{
$res = $db->exec("DELETE FROM `videos` WHERE `id` = $id");}catch(PDOException $e){
$main_content ="Houve um erro ao deletar o vídeo número $id.<br />".$e->getMessage()."<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}if($res){
$main_content ="Vídeo #$id deletado com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}else{
$main_content ="Vídeo não encontrado!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& isset($act)&&!empty($act)&& $act =="edit"&& $accessLevel){
$res = $db->query("SELECT `id`,`titulo`,`link`,`descricao` FROM `videos` WHERE `ativo` = 1 AND `id` = ".$_GET["id"]." LIMIT 1;")->fetch();
$resul = $db->query("SELECT `id`,`nome` FROM `videos_categorias`;");
$resz = $db->query("SELECT `categoria` as `id` FROM `videos` WHERE `id` = ".$_GET["id"]." LIMIT 1;")->fetch();
$cat_tudo ="";foreach($resul as $cat_info){if($cat_info["id"]== $resz["id"]){
$c =" selected=\"selected\"";}
$cat_tudo .="<option name='".$cat_info["id"]."' $c value='".$cat_info["id"]."'>".html_entity_decode($cat_info["nome"])."</option>";}
$main_content ="<fieldset>";
$main_content .="<legend>Editar Vídeo</legend>";
$main_content .="
<center>
<span style=\"font-size:1.8em; font-color:black;\"><strong>".html_entity_decode($res['titulo'])."</span></strong><hr>
<iframe width=\"560\" height=\"349\" src=\"http://www.youtube.com/embed/".$res["link"]."\" frameborder=\"0\" allowfullscreen></iframe><hr />
<br /><br />
</center>
";
$main_content .="<form id=\"add\" name=\"add\" method=\"POST\" action=\"\">";
$main_content .="<p style=\"font-size: 1.8em;\">";
$main_content .="<label for=\"titulo\">Título do Vídeo</label>";
$main_content .="<br /><input name=\"titulo\" type=\"text\" id=\"titulo\" size=\"".strlen($res["link"])*3."\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" value=\"".$res['titulo']."\"/>";
$main_content .="</p>";
$main_content .="<p style=\"font-size: 1.8em;\">";
$main_content .="<label for=\"link\">Link do Vídeo</label>";
$main_content .="<br /><input name=\"link\" type='text' id=\"link\" size=\"25\" maxlength=\"11\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" value=\"".$res['link']."\"/>";
$main_content .="<br /><br /><label for=\"descricao\">Descrição do Vídeo</label>";
$main_content .="<br /><textarea id=\"descricao\" name=\"descricao\" cols=\"40\" rows=\"10\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\">".html_entity_decode($res["descricao"])."</textarea>";
$main_content .="</p>";
$main_content .="<p style=\"font-size: 1.8em;\">";
$main_content .="Categoria<br /><select name='categoria'><option value=\"0\">Nenhuma</option>$cat_tudo</select>";
$main_content .="</p>";
$main_content .="<p>";
$main_content .="<input type=\"hidden\" name=\"id\" value=\"".$res["id"]."\"><input type=\"submit\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" name=\"button\" id=\"button\" value=\"Editar\" />";
$main_content .="</p>";
$main_content .="</form></div></fieldset>";if(isset($_POST['button'])&&!empty($_POST["button"])){if(($_POST["link"]!= $res["link"])||($_POST["titulo"]!= $res["titulo"])||($_POST["descricao"]!= $res["descricao"])||($_POST["categoria"]!= $resz["id"])){try{
$res = $db->exec("UPDATE `videos` SET `link` = '".$_POST["link"]."', `titulo` = ".$db->quote(htmlentities($_POST["titulo"])).", `descricao` = ".$db->quote(htmlentities($_POST["descricao"])).", `categoria` = ".(int)$_POST["categoria"]." WHERE `id` = ".$_POST["id"].";");}catch(PDOException $e){
$main_content ="Houve um erro ao tentar editar o vídeo #".$_POST["id"]."!<br />".$e->getMessage();}if($res){
$main_content ="Vídeo #".$_POST["id"]." editado com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}else{
$main_content ="Vídeo #".$_POST["id"]." editado com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& isset($act)&&!empty($act)&& $act =="addcat"&& $accessLevel){
$main_content ="
<form action=\"?subtopic=videos&action=adminpanel&act=addcat\" method=\"post\">
<fieldset>
<legend>Adicionar Categoria</legend><br />
<label for=\"catNome\" style=\"margin-left:3px;\">Nome da Categoria</label><br />
<input type=\"text\" name=\"catNome\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" /><br />
<input type=\"submit\" name=\"botao\" value=\"Adicionar\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" />
</fieldset>
</form>
";if(isset($_POST["botao"])&&!empty($_POST["botao"])&& $accessLevel){if(isset($_POST["catNome"])&&!empty($_POST["catNome"])&& strlen($_POST["catNome"])>0){try{
$res = $db->exec("INSERT INTO `videos_categorias` (`nome`) VALUES (".$db->quote(htmlentities($_POST["catNome"])).");");}catch(PDOException $e){
$main_content ="Houve um erro ao adicionar a categoria!<br />".$e->getMessage()."<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}if($res) $main_content ="Categoria adicionada com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}else{
$main_content ="O campo <b>Nome da Categoria</b> é obrigatório!<br /><a href='?subtopic=videos&action=adminpanel&act=addcat'>⇐ Voltar</a>";}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& isset($act)&&!empty($act)&& $act =="delcat"&& $accessLevel){if(!isset($_GET["id"])&& empty($_GET["id"])& $accessLevel){
$main_content ="Você deve definir uma categoria para deletar!";}else{
$res = $db->query("SELECT `id`, `nome` FROM `videos_categorias` WHERE `id` = ".$_GET["id"]." LIMIT 1;")->fetch();
$main_content ="
<form action=\"?subtopic=videos&action=adminpanel&act=delcat&id=".$res["id"]."\" method=\"post\">
<fieldset>
<legend>Deletar Categoria</legend><br />
<span style=\"margin-left:3px;\">Você realmente deseja deletar a categoria <b>".$res["nome"]."</b>?</span><br />
<input type=\"hidden\" name=\"catId\" value=\"".$res["id"]."\" />
<input type=\"hidden\" name=\"catNome\" value=\"".$res["nome"]."\" />
<input type=\"submit\" name=\"botao\" value=\"Deletar Categoria\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" />
<input type=\"submit\" name=\"botao2\" value=\"Deletar categoria e vídeos desta categoria\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" />
</fieldset>
</form>
";if(isset($_POST["botao"])&&!empty($_POST["botao"])&& $accessLevel){try{
$res = $db->exec("DELETE FROM `videos_categorias` WHERE `id` = ".$_POST["catId"].";");
$res = $db->exec("UPDATE `videos` SET `categoria` = 0 WHERE `categoria` = ".$_POST["catId"].";");}catch(PDOException $e){
$main_content ="Houve um erro ao deletar a categoria ".$_POST["catNome"]."!<br />".$e->getMessage();}if($res){
$main_content ="Categoria deletada com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}if(isset($_POST["botao2"])&&!empty($_POST["botao2"])&& $accessLevel){try{
$res = $db->exec("DELETE FROM `videos_categorias` WHERE `id` = ".$_POST["catId"].";");
$resul = $db->exec("DELETE FROM `videos` WHERE `categoria` = ".$_POST["catId"].";");}catch(PDOException $e){
$main_content ="Houve um erro ao deletar a categoria ".$_POST["catNome"]."!<br />".$e->getMessage();}if($res && $resul){
$main_content ="Categoria deletada com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& isset($act)&&!empty($act)&& $act =="editcat"&& $accessLevel){if(!isset($_GET["id"])&& empty($_GET["id"])& $accessLevel){
$main_content ="Você deve definir uma categoria para deletar!";}else{
$res = $db->query("SELECT `id`, `nome` FROM `videos_categorias` WHERE `id` = ".$_GET["id"]." LIMIT 1;")->fetch();
$main_content ="
<form action=\"?subtopic=videos&action=adminpanel&act=editcat&id=".$res["id"]."\" method=\"post\">
<fieldset>
<legend>Editar Categoria</legend><br />
<p style=\"font-size: 1.8em;\">
<label for=\"catNome\" style=\"margin-left:3px;\">Nome da Categoria</label><br /></p>
<input type=\"hidden\" name=\"nome\" value=\"".$res["nome"]."\" />
<input type=\"hidden\" name=\"id\" value=\"".$res["id"]."\" />
<input type=\"text\" name=\"catNome\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" value=\"".$res["nome"]."\" /><br />
<br /><input type=\"submit\" name=\"botao\" value=\"Editar Categoria\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" />
</fieldset>
</form>
";if(isset($_POST["botao"])&&!empty($_POST["botao"])&& $accessLevel){try{
$res = $db->exec("UPDATE `videos_categorias` SET `nome` = ".$db->quote(htmlentities($_POST["catNome"]))." WHERE `id` = ".$_POST["id"].";");}catch(PDOException $e){
$main_content ="Houve um erro ao editar a categoria ".$_POST["nome"]."!<br />".$e->getMessage();}if($res){
$main_content ="Categoria editada com sucesso!<br /><a href='?subtopic=videos'>⇐ Voltar</a>";}}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& isset($act)&&!empty($act)&& $act =="delcom"&& $accessLevel){if(!isset($_GET["id"])&& empty($_GET["id"])& $accessLevel){
$main_content ="Você deve escolher um comentário para deletar!";}else{
$res = $db->query("SELECT `id`, `mensagem`, `topico` FROM `videos_comentarios` WHERE `id` = ".(int)$_GET["id"]." LIMIT 1;")->fetch();
$main_content ="
<form action=\"?subtopic=videos&action=adminpanel&act=delcom&id=".$res["id"]."\" method=\"post\">
<fieldset>
<legend>Deletar Comentário</legend><br />
<span style=\"margin-left:3px;\">Você realmente deseja deletar o comentário <b>".html_entity_decode($res["mensagem"])."</b>?</span><br />
<input type=\"hidden\" name=\"comId\" value=\"".$res["id"]."\" />
<input type=\"hidden\" name=\"comTopico\" value=\"".$res["topico"]."\" />
<input type=\"hidden\" name=\"comCom\" value=\"".html_entity_decode($res["mensagem"])."\" />
<input type=\"submit\" name=\"botao\" value=\"Deletar Comentário\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" />
</fieldset>
</form>
";if(isset($_POST["botao"])&&!empty($_POST["botao"])&& $accessLevel){try{
$res = $db->exec("UPDATE `videos_comentarios` SET `ativo` = 0 WHERE `id` = ".(int)$_POST["comId"]." AND `ativo` = 1;");}catch(PDOException $e){
$main_content ="Houve um erro ao deletar o comentário ".$_POST["comCom"]."!<br />".$e->getMessage();}if($res){
$main_content ="Comentário deletado com sucesso!<br /><a href='?subtopic=videos&id=".(int)$_POST["comTopico"]."'>⇐ Voltar</a>";}}}}if(isset($action)&&!empty($action)&& $action =="adminpanel"&& isset($act)&&!empty($act)&& $act =="ativarcom"&& $accessLevel){if(!isset($_GET["id"])&& empty($_GET["id"])& $accessLevel){
$main_content ="Você deve escolher um comentário para restaurar!";}else{
$res = $db->query("SELECT `id`, `mensagem`, `topico` FROM `videos_comentarios` WHERE `id` = ".(int)$_GET["id"]." LIMIT 1;")->fetch();
$main_content ="
<form action=\"?subtopic=videos&action=adminpanel&act=ativarcom&id=".$res["id"]."\" method=\"post\">
<fieldset>
<legend>Restaurar Comentário</legend><br />
<span style=\"margin-left:3px;\">Você realmente deseja restaurar o comentário <b>".html_entity_decode($res["mensagem"])."</b>?</span><br />
<input type=\"hidden\" name=\"comId\" value=\"".$res["id"]."\" />
<input type=\"hidden\" name=\"comTopico\" value=\"".$res["topico"]."\" />
<input type=\"hidden\" name=\"comCom\" value=\"".html_entity_decode($res["mensagem"])."\" />
<input type=\"submit\" name=\"botao\" value=\"Restaurar Comentário\" style=\"border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;-khtml-border-radius:3px;padding: 4px 2px; border: 1px solid #b2babe; background: #fff;\" />
</fieldset>
</form>
";if(isset($_POST["botao"])&&!empty($_POST["botao"])&& $accessLevel){try{
$res = $db->exec("UPDATE `videos_comentarios` SET `ativo` = 1 WHERE `id` = ".(int)$_POST["comId"]." AND `ativo` = 0;");}catch(PDOException $e){
$main_content ="Houve um erro ao restaurar o comentário ".$_POST["comCom"]."!<br />".$e->getMessage();}if($res){
$main_content ="Comentário restaurado com sucesso!<br /><a href='?subtopic=videos&id=".(int)$_POST["comTopico"]."'>⇐ Voltar</a>";}}}}}?>
Pergunta
brunonyyu 0
Olá, ao adicionar um video na pagina videos.php pelo painel do adm ele me volta o seguinte erro:
Linha com erro
$info = new SimpleXMLElement(file_get_contents("http://gdata.youtube.com/feeds/api/videos/$link"));
Codigo da pagina
Link para o comentário
Compartilhar em outros sites
3 respostass a esta questão
Posts Recomendados