/** * Get the ID3v2.x tag from an mp3 file. * * @param string $file * @return array * @access public */ function getid3($file) { global $mosConfig_absolute_path, $database; require_once $mosConfig_absolute_path . "/components/com_zoom/lib/getid3/getid3.php"; require_once $mosConfig_absolute_path . "/components/com_zoom/lib/getid3/extension.cache.mysql.php"; $getid3 = new getID3_cached_mysql($database); $fileInfo = $getid3->analyze($file); getid3_lib::CopyTagsToComments($fileInfo); return $fileInfo; }
/** * @param object element model * @param object element params * @param string row data for this element */ function render(&$model, &$params, $file) { $src = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); ini_set('display_errors', true); require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.php'; require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.lib.php'; getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'extension.cache.mysql.php', __FILE__, true); $config = JFactory::getConfig(); $host = $config->getValue('host'); $database = $config->getValue('db'); $username = $config->getValue('user'); $password = $config->getValue('password'); $getID3 = new getID3_cached_mysql($host, $database, $username, $password); // Analyze file and store returned data in $ThisFileInfo $relPath = JPATH_SITE . "{$file}"; $thisFileInfo = $getID3->analyze($relPath); if (array_key_exists('video', $thisFileInfo)) { if (array_key_exists('resolution_x', $thisFileInfo['video'])) { $w = $thisFileInfo['video']['resolution_x']; $h = $thisFileInfo['video']['resolution_y']; } else { $w = $thisFileInfo['video']['streams']['2']['resolution_x']; //for wmv files $h = $thisFileInfo['video']['streams']['2']['resolution_y']; } switch ($thisFileInfo['fileformat']) { //add in space for controller case 'quicktime': $h += 16; break; default: $h += 64; } } $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); switch ($thisFileInfo['fileformat']) { case 'asf': $this->output = '<object id="MediaPlayer" width=' . $w . ' height=' . $h . ' classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components�" type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"> <param name="filename" value="http://yourdomain/yourmovie.wmv"> <param name="Showcontrols" value="true"> <param name="autoStart" value="false"> <embed type="application/x-mplayer2" src="' . $src . '" name="MediaPlayer" width=' . $w . ' height=' . $h . '></embed> </object> '; break; default: $this->output = "<object width=\"{$w}\" height=\"{$h}\"\n\t\t\tclassid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\"\n\t\t\tcodebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">\n\t\t\t<param name=\"src\" value=\"{$src}\">\n\t\t\t<param name=\"autoplay\" value=\"false\">\n\t\t\t<param name=\"controller\" value=\"true\">\n\t\t\t<embed src=\"{$src}\" width=\"{$w}\" height=\"{$h}\"\n\t\t\tautoplay=\"false\" controller=\"true\"\n\t\t\tpluginspage=\"http://www.apple.com/quicktime/download/\">\n\t\t\t</embed>\n\t\t\t\n\t\t\t</object>"; break; } }
/** * Render Video in the form view * * @param object &$model Element model * @param object &$params Element params * @param string $file Row data for this element * * @return void */ public function render(&$model, &$params, $file) { $src = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); ini_set('display_errors', true); require_once COM_FABRIK_FRONTEND . '/libs/getid3/getid3/getid3.php'; require_once COM_FABRIK_FRONTEND . '/libs/getid3/getid3/getid3.lib.php'; getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND . '/libs/getid3/getid3/extension.cache.mysql.php', __FILE__, true); $config = $this->config; $host = $config->get('host'); $database = $config->get('db'); $username = $config->get('user'); $password = $config->get('password'); $getID3 = new getID3_cached_mysql($host, $database, $username, $password); // Analyse file and store returned data in $ThisFileInfo $relPath = JPATH_SITE . $file; $thisFileInfo = $getID3->analyze($relPath); if (array_key_exists('video', $thisFileInfo)) { if (array_key_exists('resolution_x', $thisFileInfo['video'])) { $w = $thisFileInfo['video']['resolution_x']; $h = $thisFileInfo['video']['resolution_y']; } else { // For wmv files $w = $thisFileInfo['video']['streams']['2']['resolution_x']; $h = $thisFileInfo['video']['streams']['2']['resolution_y']; } switch ($thisFileInfo['fileformat']) { // Add in space for controller case 'quicktime': $h += 16; break; default: $h += 64; } } $displayData = new stdClass(); $displayData->width = $w; $displayData->height = $h; $displayData->src = $src; switch ($thisFileInfo['fileformat']) { case 'asf': $layout = $model->getLayout('video-asf'); break; default: $layout = $model->getLayout('video'); break; } $this->output = $layout->render($displayData); }
<?php ///////////////////////////////////////////////////////////////// /// getID3() by James Heinrich <*****@*****.**> // // available at http://getid3.sourceforge.net // // or http://www.getid3.org // ///////////////////////////////////////////////////////////////// // // // /demo/demo.cache.mysql.php - part of getID3() // // Sample script demonstrating the use of the DBM caching // // extension for getID3() // // See readme.txt for more details // // /// ///////////////////////////////////////////////////////////////// die('Due to a security issue, this demo has been disabled. It can be enabled by removing line ' . __LINE__ . ' in ' . $_SERVER['PHP_SELF']); require_once '../getid3/getid3.php'; getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'extension.cache.mysql.php', __FILE__, true); $getID3 = new getID3_cached_mysql('localhost', 'database', 'username', 'password'); $r = $getID3->analyze('/path/to/files/filename.mp3'); echo '<pre>'; var_dump($r); echo '</pre>'; // uncomment to clear cache //$getID3->clear_cache();
/** * * @param type $dir * @param type $match search type name extentions, can be an array or csv list * @param type $cache caching extention, select one of sqlite3, mysql, dbm * @param array $opt database options, */ function scan_files($dir, $match, $cache = 'sqlite3', $opt = array('table' => 'getid3_cache', 'hide' => true)) { $Start = self::getTime(); switch ($cache) { // load the caching module case 'sqlite3': if (!class_exists('getID3_cached_sqlite3')) { require_once dirname(__FILE__) . '/extension.cache.sqlite3.php'; } $id3 = new getID3_cached_sqlite3($opt['table'], $opt['hide']); break; case 'mysql': if (!class_exists('getID3_cached_mysql')) { require_once dirname(__FILE__) . '/extension.cache.mysql.php'; } $id3 = new getID3_cached_mysql($opt['host'], $opt['database'], $opt['username'], $opt['password'], $opt['table']); break; // I'll leave this for some one else //case 'dbm': // if (!class_exists('getID3_cached_dbm')) { // require_once(dirname(__FILE__)).'/extension.cache.dbm.php'; // } // die(' This has not be implemented, sorry for the inconvenience'); // break; // I'll leave this for some one else //case 'dbm': // if (!class_exists('getID3_cached_dbm')) { // require_once(dirname(__FILE__)).'/extension.cache.dbm.php'; // } // die(' This has not be implemented, sorry for the inconvenience'); // break; default: die(' You have selected an Invalid cache type, only "sqlite3" and "mysql" are valid' . "\n"); break; } $count = array('dir' => 0, 'file' => 0); $dirs = self::getDirs($dir); if ($dirs !== null) { foreach ($dirs as $d) { echo ' Scanning: ' . $d . "\n"; $search = self::type_brace($d, $match); if ($search !== null) { $files = self::file_check($search); if ($files !== null) { foreach ($files as $f) { echo ' * Analyzing ' . $f . ' ' . "\n"; $id3->analyze($f); $count['file']++; } $count['dir']++; } else { echo 'Failed to get files ' . "\n"; } } else { echo 'Failed to create match string ' . "\n"; } } echo '**************************************' . "\n"; echo '* Finished Scanning your directories ' . "\n*\n"; echo '* Directories ' . $count['dir'] . "\n"; echo '* Files ' . $count['file'] . "\n"; $End = self::getTime(); $t = number_format(($End - $Start) / 60, 2); echo '* Time taken to scan ' . $dir . ' ' . $t . ' min ' . "\n"; echo '**************************************' . "\n"; } else { echo ' failed to get directories ' . "\n"; } }
/** * @param object element model * @param object element params * @param string row data for this element */ function render(&$model, &$params, $file) { $fbConfig =& JComponentHelper::getParams('com_fabrik'); ini_set('display_errors', true); require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.php'; require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.lib.php'; getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'extension.cache.mysql.php', __FILE__, true); $config =& JFactory::getConfig(); $host = $config->getValue('host'); $database = $config->getValue('db'); $username = $config->getValue('user'); $password = $config->getValue('password'); $getID3 = new getID3_cached_mysql($host, $database, $username, $password); // Analyze file and store returned data in $ThisFileInfo $relPath = str_replace("\\", "/", JPATH_SITE . $file); $thisFileInfo = $getID3->analyze($relPath); //var_dump($relPath, $thisFileInfo); $w = $params->get('fu_main_max_width', 0); $h = $params->get('fu_main_max_height', 0); if (is_array($thisFileInfo)) { if (array_key_exists('swf', $thisFileInfo)) { if ($thisFileInfo['swf']['header']['frame_width'] < $w || $thisFileInfo['swf']['header']['frame_height'] < $h) { $w = $thisFileInfo['swf']['header']['frame_width']; $h = $thisFileInfo['swf']['header']['frame_height']; } } } if ($w <= 0 || $h <= 0) { $w = 800; $h = 600; } // $$$ hugh - if they've enabled thumbnails, for Flash content we'll take that to mean they don't // want to play the content inline in the table, and use mediabox (if available) to open it instead. if (!$model->_inDetailedView && $fbConfig->get('use_mediabox', true) && FabrikWorker::getMooVersion() == 1 && $params->get('make_thumbnail', false)) { $element =& $model->getElement(); // @TODO - work out how to do thumbnails // $$$ hugh - thought about using thumbed-down embedded Flash as // thumbnail, but really need to avoid having to download every flash in // the table on page load! But just doesn't seem to be a way of getting // a thumbnail from a Flash. For now, just use a default "Here Be Flash" // icon for the thumb. Might be nice to add 'icon to use' option for Upload // element, so if it isn't an image type, you can point at another element on the form, // (either and Upload or an Image) and use that as the thumb for this content. /* $thumb_w = $params->get('thumb_max_width'); $thumb_h = $params->get('thumb_max_height'); $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $this->output = "<object width=\"$w\" height=\"$h\"> <param name=\"movie\" value=\"$file\"> <embed src=\"$file\" width=\"$thumb_w\" height=\"$thumb_h\"> </embed> </object>"; */ $thumb_dir = $params->get('thumb_dir'); if (!empty($thumb_dir)) { $file = str_replace("\\", "/", $file); $pathinfo = pathinfo($file); // $$$ hugh - apparently filename ocnstant only added in PHP 5.2 if (!isset($pathinfo['filename'])) { $pathinfo['filename'] = explode('.', $pathinfo['basename']); $pathinfo['filename'] = $pathinfo['filename'][0]; } $thumb_path = COM_FABRIK_BASE . DS . $thumb_dir . DS . $pathinfo['filename'] . '.png'; if (JFile::exists($thumb_path)) { $thumb_file = COM_FABRIK_LIVESITE . $thumb_dir . '/' . $pathinfo['filename'] . '.png'; } else { $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg"; } } else { $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg"; } $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $this->output .= "<a href=\"{$file}\" rel=\"lightbox[flash {$w} {$h}]\"><img src=\"{$thumb_file}\" alt=\"Full Size\" /></a>"; } else { if ($model->_inDetailedView) { $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $this->output .= "<object width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t<param name=\"movie\" value=\"{$file}\">\n\t\t\t\t<embed src=\"{$file}\" width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t</embed>\n\t\t\t\t</object>"; } else { $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $this->output .= "<object width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t<param name=\"movie\" value=\"{$file}\">\n\t\t\t\t<embed src=\"{$file}\" width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t</embed>\n\t\t\t\t</object>"; } } //} }
/** * Render flash in the form view * * @param object &$model Element model * @param object &$params Element params * @param string $file Row data for this element * * @return void */ public function render(&$model, &$params, $file) { $fbConfig = JComponentHelper::getParams('com_fabrik'); ini_set('display_errors', true); require_once COM_FABRIK_FRONTEND . '/libs/getid3/getid3/getid3.php'; require_once COM_FABRIK_FRONTEND . '/libs/getid3/getid3/getid3.lib.php'; getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND . '/libs/getid3/getid3/extension.cache.mysql.php', __FILE__, true); $config = $this->config; $host = $config->get('host'); $database = $config->get('db'); $username = $config->get('user'); $password = $config->get('password'); $getID3 = new getID3_cached_mysql($host, $database, $username, $password); // Analyse file and store returned data in $ThisFileInfo $relPath = str_replace("\\", "/", JPATH_SITE . $file); $thisFileInfo = $getID3->analyze($relPath); $w = $params->get('fu_main_max_width', 0); $h = $params->get('fu_main_max_height', 0); if ($thisFileInfo && array_key_exists('swf', $thisFileInfo)) { if ($thisFileInfo['swf']['header']['frame_width'] < $w || $thisFileInfo['swf']['header']['frame_height'] < $h) { $w = $thisFileInfo['swf']['header']['frame_width']; $h = $thisFileInfo['swf']['header']['frame_height']; } } if ($w <= 0 || $h <= 0) { $w = 800; $h = 600; } $layout = $model->getLayout('flash'); $displayData = new stdClass(); $displayData->useThumbs = !$model->inDetailedView && $fbConfig->get('use_mediabox', true) && $params->get('make_thumbnail', false); $displayData->width = $w; $displayData->height = $h; $displayData->inDetailedView = $model->inDetailedView; $displayData->file = $file; if ($displayData->useThumbs) { // @TODO - work out how to do thumbnails $thumb_dir = $params->get('thumb_dir'); if (!empty($thumb_dir)) { $file = str_replace("\\", "/", $file); $pathinfo = pathinfo($file); // $$$ hugh - apparently filename constant only added in PHP 5.2 if (!isset($pathinfo['filename'])) { $pathinfo['filename'] = explode('.', $pathinfo['basename']); $pathinfo['filename'] = $pathinfo['filename'][0]; } $thumb_path = COM_FABRIK_BASE . $thumb_dir . '/' . $pathinfo['filename'] . '.png'; if (JFile::exists($thumb_path)) { $thumb_file = COM_FABRIK_LIVESITE . $thumb_dir . '/' . $pathinfo['filename'] . '.png'; } else { $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg"; } } else { $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg"; } $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $displayData->thumb = $thumb_file; $displayData->file = $file; } $this->output = $layout->render($displayData); }
/** * Render flash in the form view * * @param object &$model Element model * @param object &$params Element params * @param string $file Row data for this element * * @return void */ public function render(&$model, &$params, $file) { $fbConfig = JComponentHelper::getParams('com_fabrik'); ini_set('display_errors', true); require_once COM_FABRIK_FRONTEND . '/libs/getid3/getid3/getid3.php'; require_once COM_FABRIK_FRONTEND . '/libs/getid3/getid3/getid3.lib.php'; getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND . '/libs/getid3/getid3/extension.cache.mysql.php', __FILE__, true); $config = JFactory::getConfig(); $host = $config->get('host'); $database = $config->get('db'); $username = $config->get('user'); $password = $config->get('password'); $getID3 = new getID3_cached_mysql($host, $database, $username, $password); // Analyse file and store returned data in $ThisFileInfo $relPath = str_replace("\\", "/", JPATH_SITE . $file); $thisFileInfo = $getID3->analyze($relPath); $w = $params->get('fu_main_max_width', 0); $h = $params->get('fu_main_max_height', 0); if ($thisFileInfo && array_key_exists('swf', $thisFileInfo)) { if ($thisFileInfo['swf']['header']['frame_width'] < $w || $thisFileInfo['swf']['header']['frame_height'] < $h) { $w = $thisFileInfo['swf']['header']['frame_width']; $h = $thisFileInfo['swf']['header']['frame_height']; } } if ($w <= 0 || $h <= 0) { $w = 800; $h = 600; } // $$$ hugh - if they've enabled thumbnails, for Flash content we'll take that to mean they don't // want to play the content inline in the table, and use mediabox (if available) to open it instead. if (!$model->inDetailedView && $fbConfig->get('use_mediabox', true) && $params->get('make_thumbnail', false)) { $element = $model->getElement(); // @TODO - work out how to do thumbnails $thumb_dir = $params->get('thumb_dir'); if (!empty($thumb_dir)) { $file = str_replace("\\", "/", $file); $pathinfo = pathinfo($file); // $$$ hugh - apparently filename constant only added in PHP 5.2 if (!isset($pathinfo['filename'])) { $pathinfo['filename'] = explode('.', $pathinfo['basename']); $pathinfo['filename'] = $pathinfo['filename'][0]; } $thumb_path = COM_FABRIK_BASE . $thumb_dir . '/' . $pathinfo['filename'] . '.png'; if (JFile::exists($thumb_path)) { $thumb_file = COM_FABRIK_LIVESITE . $thumb_dir . '/' . $pathinfo['filename'] . '.png'; } else { $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg"; } } else { $thumb_file = COM_FABRIK_LIVESITE . "media/com_fabrik/images/flash.jpg"; } $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $this->output .= "<a href='{$file}' rel='lightbox[flash {$w} {$h}]'><img src='{$thumb_file}' alt='Full Size'></a>"; } elseif ($model->inDetailedView) { $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $this->output = "<object width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t<param name=\"movie\" value=\"{$file}\">\n\t\t\t\t<embed src=\"{$file}\" width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t</embed>\n\t\t\t\t</object>"; } else { $file = str_replace("\\", "/", COM_FABRIK_LIVESITE . $file); $this->output = "<object width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t<param name=\"movie\" value=\"{$file}\">\n\t\t\t\t<embed src=\"{$file}\" width=\"{$w}\" height=\"{$h}\">\n\t\t\t\t</embed>\n\t\t\t\t</object>"; } }
function onAjax_download() { $app =& JFactory::getApplication(); $url = JRequest::getVar('HTTP_REFERER', '', 'server'); $lang =& JFactory::getLanguage(); $lang->load('com_fabrik.plg.element.fabrikfileupload', JPATH_ADMINISTRATOR); if (!$this->canView()) { $app->enqueueMessage(JText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_PERMISSION')); $app->redirect($url); exit; } $rowid = JRequest::getInt('rowid', 0); if (empty($rowid)) { $app->enqueueMessage(JText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE')); $app->redirect($url); exit; } $repeatcount = JRequest::getInt('repeatcount', 0); $listModel = $this->getListModel(); $row = $listModel->getRow($rowid, false); if (empty($row)) { $app->enqueueMessage(JText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE')); $app->redirect($url); exit; } //$element = $this->getElement(); $storage =& $this->getStorage(); $elName = $this->getFullName(true, true, false); $elName .= '_raw'; $filepath = $row->{$elName}; //$filepath = explode(GROUPSPLITTER,$filepath); $filepath = FabrikWorker::JSONtoData($filepath, true); $filepath = JArrayHelper::getValue($filepath, $repeatcount); $filepath = COM_FABRIK_BASE . $filepath; $filecontent = $storage->read($filepath); if ($filecontent !== false) { require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.php'; require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'getid3.lib.php'; getid3_lib::IncludeDependency(COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'getid3' . DS . 'getid3' . DS . 'extension.cache.mysql.php', __FILE__, true); $config =& JFactory::getConfig(); $host = $config->getValue('host'); $database = $config->getValue('db'); $username = $config->getValue('user'); $password = $config->getValue('password'); $getID3 = new getID3_cached_mysql($host, $database, $username, $password); // Analyze file and store returned data in $ThisFileInfo $thisFileInfo = $getID3->analyze($filepath); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Some time in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header('Accept-Ranges: bytes'); header('Content-Length: ' . $thisFileInfo['filesize']); header('Content-Type: ' . $thisFileInfo['mime_type']); header('Content-Disposition: attachment; filename=' . $thisFileInfo['filename']); // ... serve up the image ... echo $filecontent; $this->downloadEmail($row, $filepath); $this->downloadHit($rowid, $repeatcount); // ... and we're done. exit; } else { $app->enqueueMessage(JText::_('PLG_ELEMENT_FILEUPLOAD_DOWNLOAD_NO_SUCH_FILE')); $app->redirect($url); exit; } }