Código PHP:
public static function getUrlContent($Url){
// USAMOS CURL O FILE
if(function_exists('curl_int')){
// User agent
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9) Gecko/2008052906 Firefox/3.0";
//Abrir conexion
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch,CURLOPT_URL,$Url);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
curl_close($ch);
} else {
$result = @file_get_contents($Url);
}
return $result;
}
Código PHP:
public function Verific($return = false, $urlin = null)
{
$type = Input::get('type');
$url = empty($urlin) ? Input::post('url') : $urlin;
// VALIDAR
if(empty($url)){
return '0: El campo <b>url</b> es obligatorio.';
}
//
switch($type){
case 'enlace':
// VALIDAR
if(strlen($url) > 400){
return '0: La url es demasiado larga.';
}
$data = Url::getUrlContent($url);
// VALIDAR #1
if(!$data){
return '0: El enlace ingresado no es válido, no esta disponible o no existe.';
}
// OBTENER META TITULO
$title = explode('<title>',$data);
$title = explode('</title>',$title[1]);
$title = empty($title[0]) ? $url : $title[0];
// VALIDAR #2
if(!$title){
return '0: La url ingresada no es una página web válida.';
}
// RETORNAMOS HTML/VALOR
if($return == false){
return '1: <center><a href="'.$url.'" target="_blank" class="big a_blue">'.$title.'</a><br/><span class="desc">'.$url.'</span></center>';
}else{
return array('title' => Security::antiSQL ($title), 'url' => Security::antiSQL($url));
}
break;
}
}
Código PHP:
private function enlaceMuro($pid,$data,$adj,$type) {
$date = time();
$enlace = $this->ajaxCheck(true, $adj);
$insermuroEnlace[] = array('p_user' => $pid,'p_user_pub' => $this->User->uid,'p_body' => $data,'p_date' => $date,'p_type'=> 3);
foreach($insermuroEnlace as $insert) {
$this->db->insert_array('muro', $insert);
$pub_id = $this->db->insert_id();
$insermuroAdjuntos[] = array('pub_id' => $pub_id,'a_title' => $enlace['title'],'a_url' => $enlace['url']);
foreach($insermuroAdjuntos as $insertadj) {
$this->db->insert_array('muro_adjuntos', $insertadj);
$type = 'mlink';
// RETORNAMOS DATOS PARA EL TEMPLATE
$return = array('pub_id' => $pub_id, 'p_user' => $pid, 'p_user_pub' => $this->User->uid, 'p_body' => $this->Core->setMenciones($data), 'p_date' => $date, 'p_likes' => 0, 'p_type' => 3, 'likes' => array('link' => 'Me gusta'), 'a_title' => $enlace['title'], 'a_url' => $enlace['url']);
}
}
return $return;
}
me devuelve un valor de 0 en las filas de la db con son a_url y a_title pero cuando la url es asi
http://www.youtube.com/watch?v=5yZQ7hdySno tranquilamente no pasa eso todo lo inserta normalmente