All pastes #181692 Raw Edit

iubito

public php v1 · immutable
#181692 ·published 2006-09-25 09:13 UTC
rendered paste body
<?php# Stream MP3 with DewPlayer little flash ;-)# http://www.estvideo.com/dew/index/2005/12/03/603-dewplayer-reloaded#  # Tag :# <mp3>uploaded filename.mp3 or external link</mp3># <mp3>uploaded filename.mp3 or external link|download</mp3> adds an icon with link to download the mp3# Requires :# dewplayer.swf at the same level of index.php# /images/download.gif : an image of your choice#  # To activate the extension :# - include it at the end of your LocalSettings.php : include("extensions/mp3.php");# - add .mp3 in the extension upload list :# $wgFileExtensions = array('png','gif',...,'mp3');#  # Enjoy !$wgExtensionFunctions[] = 'wfMp3';$wgExtensionCredits['other'][] = array( 'name' => 'mp3', 'description' => '[http://www.estvideo.com/dew/index/2005/12/03/603-dewplayer-reloaded ' . 'Flash dewplayer] is light and streams your mp3', 'author' => 'Sylvain Machefert');function wfMp3() { global $wgParser; $wgParser->setHook('mp3', 'renderMp3');}# The callback function for converting the input text to HTML outputfunction renderMp3($input) { //$input = "filename.mp3" $arr = explode('|', trim($input)); $addDLlink = isset($arr[1]) && ($arr[1] == 'download'); $input = $arr[0]; $img = Image::newFromName($input); $mp3 = ''; //The parameters for object and embed # File uploaded or external link ? if (!$img->exists()) {  //must be http://... URL  if (substr($input,0,7) == 'http://')   $mp3 = $input; } else  $mp3 = $img->getURL(); if ($mp3 == '')  return '<div class="noprint">Fichier manquant : '.$input.'<br />' .'Missing ressource: '.$input.'</div>'; unset($img); $output = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' . 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ' . 'width="150" height="20" id="dewplayer" align="middle">' . '<param name="allowScriptAccess" value="sameDomain" />' . '<param name="movie" value="dewplayer.swf?son='.$mp3.'&amp;bgcolor=FFF8DC" />' . '<param name="quality" value="high" />' . '<param name="bgcolor" value="FFF8DC" />' . '<embed src="dewplayer.swf?son='.$mp3 .'&amp;bgcolor=FFF8DC" quality="high" bgcolor="FFF8DC" width="150" height="20" ' .'name="dewplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ' .'pluginspage="http://www.macromedia.com/go/getflashplayer">' .'</embed>' .'</object>'; if ($addDLlink) {  $output .= '<a href="'.$mp3.'" title="Download">'  .'<img src="/images/download.gif" alt="Downlaod" />'  .'</a>'; } return $output;}?>