Jump to content


rEd nEcK *

Member Since 06/12/2005
Offline Last Active 04/01/2010, 17:07
-----

Posts I've Made

In Topic: Migrar De Cookie Para Sessão

24/04/2007, 10:48

Bom dia,

Isso vai depender da necessidade... Na verdade dificuldade não há nenhuma, apenas trocar $_COOKIE por $_SESSION e adicionar um "session_start()" em todas as páginas...

<?php
session_start();

// escrevo um COOKIE
$_COOKIE["x"] = "foo !";

// escrevo uma SESSION
$_SESSION["y"] = "bar !";

//-------------------------------

print '<pre>';
print '<b>Olha o Cookie: </b><br/>';
print_r($_COOKIE);
print '<br/><br/>';
print '<b>Olha a Session: </b><br/>';
print_r($_SESSION);

?>


Mas o COOKIE tem as utilidades X já a SESSION tem as utilidades Y, por isso vai depender doque você precisa exatamente

Abraços !

In Topic: Selecionar Mais De Uma Linha Com Mysql

24/04/2007, 10:40

Bom dia,

Já tentou algo assim ?

<?php

$conn = mysql_connect('localhost','login','senha');
mysql_select_db('teste',$conn);

$consulta = "SELECT * FROM `clientes` ORDER BY `id` DESC";
$query = mysql_query($consulta);

$clientes = Array();
while( $row = mysql_fetch_array($query) )
$clientes[] = $row;

// exemplo de exibição
print '<pre>';
print_r($clientes);

?>


Abraços

In Topic: Sistema De Video

12/04/2007, 16:20

Boa tarde pessoal !

Estive estudando um pouquinho, e só agora fui ver que o Youtube libera as informações, então, fiz uma classe para pegar essas informações.

Quem puder melhorar, sinta-se avontade !!!

<?php

class YTVideoDetails{

private $dom = "";
private $xml = '';

function YTVideoDetails( $id_dev, $id_video ){
$this->dom = new DOMDocument("1.0", "ISO-8859-1");
$this->xml = file_get_contents("http://www.youtube.com/api2_rest?method=youtube.videos.get_details&dev_id=".$id_dev."&video_id=".$id_video);
$this->xml = str_replace("&","&amp;",$this->xml);
$this->dom->preserveWhiteSpace = false;
$this->dom->loadXML( $this->xml );
}

private function getNodeValue( $element ){
return @$this->dom->getElementsByTagName( $element )->item( 0 )->nodeValue;
}

private function getAllChildsValue( $element ){
$values = Array();
$nodes = @$this->dom->getElementsByTagName( $element );

foreach( $nodes as $node ) $values[] = $node->nodeValue;

return $values;
}

private function getAllComments( $element ){
$values = Array();
$nodes = @$this->dom->getElementsByTagName( $element );

for($i=0; $i<$nodes->length; $i++){
$values[$i]["author"] = $nodes->item($i)->getElementsByTagName("author")->item(0)->nodeValue;
$values[$i]["text"] = $nodes->item($i)->getElementsByTagName("text")->item(0)->nodeValue;
$values[$i]["time"] = $nodes->item($i)->getElementsByTagName("time")->item(0)->nodeValue;
}

return $values;
}

public function getDetails(){
$details = Array();

$details["author"] = $this->getNodeValue("author");
$details["title"] = $this->getNodeValue("title");
$details["rating_avg"] = $this->getNodeValue("rating_avg");
$details["rating_count"] = $this->getNodeValue("rating_count");
$details["tags"] = $this->getNodeValue("tags");
$details["description"] = $this->getNodeValue("description");
$details["update_time"] = $this->getNodeValue("update_time");
$details["view_count"] = $this->getNodeValue("view_count");
$details["comment_count"] = $this->getNodeValue("comment_count");
$details["upload_time"] = $this->getNodeValue("upload_time");
$details["length_seconds"] = $this->getNodeValue("length_seconds");
$details["recording_date"] = $this->getNodeValue("recording_date");
$details["recording_location"] = $this->getNodeValue("recording_location");
$details["recording_country"] = $this->getNodeValue("recording_country");

$details["comments"] = $this->getAllComments("comment");
$details["channels"] = $this->getAllChildsValue("channel");

$details["thumbnail_url"] = $this->getNodeValue("thumbnail_url");
$details["embed_status"] = $this->getNodeValue("embed_status");

return $details;
}
}

$d = new YTVideoDetails( /* youtube developer id */ 1, /* youtube video id */ "2fC99HjOExg" );
print_r( $d->getDetails() );

?>


O unico problema, é que para poder pegar essas informações, precisa ter um usúario com perfil de developer no Youtube, eu tentei criar e não consegui....

Esse script funcionará apenas, se for adicionado um Dev_ID valido... Mas vale a pena dar uma olhadinha... rsrsrs

Duvidas, é só perguntar !
Abraços,
Luiz Souza

In Topic: Ler Variáveis Passadas Pela Url (get)

06/02/2007, 10:17

Bom dia !

Aparentemente, é porque a variavel id2 não foi encontrada, você tem certeza que acessou:

simulador.php?id=FFFFFF&id2=1136

?

Luiz Souza

In Topic: Sistema De Video

04/02/2007, 21:19

Boa noite !!

Seria tipo isso?

<?php

$key = isset($_GET["key"]) ? $_GET["key"] : "2fC99HjOExg";
$content = file_get_contents("http://www.youtube.com/watch?v=".$key);

preg_match("#\<h1 id\=\"video_title\"\>(.*?)\<\/h1\>#s", $content, $return);
list(, $title) = $return;

preg_match("#\<div id\=\"vidDescDiv\"\>(.*?)\<\/div\>#s", $content, $return );
list(, $desc) = $return;

print "<b>Title:</b> ".$title . "<br/><b>Desc:</b> " . $desc;


?>


Abraços

IPB Skin By Virteq