cmd = "[yt]0gfniCDbbzg[/yt]"; echo 'message before parse: '.$command->cmd.'
'; $command->cmd = preg_replace_callback("|\[yt\](.*?)\[\/yt\]|", 'yt', $command->cmd); //$command->cmd = preg_replace_callback("|\[yt (.*?)=(.*?) (.*?)=(.*?)\](.*?)\[\/yt\]|", 'yt', $command->cmd); function get_tiny_url($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } function getTitle($Url){ echo "parse"; $ustr = parse_url($Url); echo "file"; $ctx = stream_context_create(array( 'http' => array( 'timeout' => 10 ) ) ); $str = file_get_contents($Url, 0, $ctx); echo "rest"; if(strlen($str)>0){ if(strpos($ustr['host'],'youtu')===FALSE){ preg_match("/\(.*)\<\/title\>/",$str,$title); }else{ preg_match('/\/',$str,$title); } if($title[1]!=""){ unset($Url); unset($ustr); return $title[1]; }else{ unset($ustr); return basename($Url); } } } function url($matches) { echo getTitle($matches[0]); $url = get_tiny_url($matches[0]); return ''.$url.''; } echo 'message after parse: '.$command->cmd.'
'; function yt($matches) { global $session,$config,$db,$tpl,$log,$core; var_dump($matches); if($matches[1]=='h'){ $height=$matches[2]; $width=$matches[4]; $url=$matches[5]; }elseif($matches[1]=='w'){ $height=$matches[4]; $width=$matches[2]; $url=$matches[5]; }elseif($matches[2]==''){ $height=315; $width=560; $url=$matches[1]; }else{ return $matches[0]; } return ''; }*/ ?>