function create_media_using_plugin($main_media, $configs, $aheight, $awidth, $vheight, $vwidth, $layout_id = "") { if ($main_media->type == 'video') { if ($main_media->source == 'code') { $media = $main_media->code; } if ($main_media->source == 'url') { //$position_watch = strpos($main_media->url, 'www.youtube.com/watch'); if (strpos($main_media->url, 'www.youtube.com/watch') !== false) { // youtube link - begin $link_array = explode('=', $main_media->url); $link_ = $link_array[1]; $media = '{youtube}' . $link_ . '{/youtube}'; } elseif (strpos($main_media->url, 'www.123video.nl') !== false) { // 123video.nl link - begin $link_array = explode('=', $main_media->url); $link_ = $link_array[1]; $media = '{123video}' . $link_ . '{/123video}'; } elseif (strpos($main_media->url, 'www.aniboom.com') !== false) { // aniboom.com link - begin $begin_tag = strpos($main_media->url, 'video'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '/'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{aniboom}' . $link_ . '{/aniboom}'; } elseif (strpos($main_media->url, 'www.badjojo.com') !== false) { // badjojo.com [adult] link - begin $link_array = explode('=', $main_media->url); $link_ = $link_array[1]; $media = '{badjojo}' . $link_ . '{/badjojo}'; echo $media; } elseif (strpos($main_media->url, 'www.brightcove.tv') !== false) { // brightcove.tv link - begin $begin_tag = strpos($main_media->url, 'title='); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '&'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{brightcove}' . $link_ . '{/brightcove}'; } elseif (strpos($main_media->url, 'www.collegehumor.com') !== false) { // collegehumor.com link - begin $link_array = explode(':', $main_media->url); $link_ = $link_array[2]; $media = '{collegehumor}' . $link_ . '{/collegehumor}'; } elseif (strpos($main_media->url, 'current.com') !== false) { // current.com link - begin $begin_tag = strpos($main_media->url, 'items/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '_'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{current}' . $link_ . '{/current}'; } elseif (strpos($main_media->url, 'dailymotion.com') !== false) { // dailymotion.com link - begin $begin_tag = strpos($main_media->url, 'video/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '_'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{dailymotion}' . $link_ . '{/dailymotion}'; } elseif (strpos($main_media->url, 'espn') !== false) { // video.espn.com link - begin $begin_tag = strpos($main_media->url, 'videoId='); $remaining_link = substr($main_media->url, $begin_tag + 8, strlen($main_media->url)); $end_tag = strpos($remaining_link, '&'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{espn}' . $link_ . '{/espn}'; } elseif (strpos($main_media->url, 'eyespot.com') !== false) { // eyespot.com link - begin $link_array = explode('r=', $main_media->url); $link_ = $link_array[1]; $media = '{eyespot}' . $link_ . '{/eyespot}'; } elseif (strpos($main_media->url, 'flurl.com') !== false) { // flurl.com link - begin $begin_tag = strpos($main_media->url, 'video/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '_'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{flurl}' . $link_ . '{/flurl}'; } elseif (strpos($main_media->url, 'funnyordie.com') !== false) { // funnyordie.com link - begin $link_array = explode('videos/', $main_media->url); $link_ = $link_array[1]; $media = '{funnyordie}' . $link_ . '{/funnyordie}'; } elseif (strpos($main_media->url, 'gametrailers.com') !== false) { // gametrailers.com link - begin $begin_tag = strpos($main_media->url, 'player/'); $remaining_link = substr($main_media->url, $begin_tag + 7, strlen($main_media->url)); $end_tag = strpos($remaining_link, '.'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{gametrailers}' . $link_ . '{/gametrailers}'; } elseif (strpos($main_media->url, 'godtube.com') !== false) { // godtube.com link - begin $link_array = explode('viewkey=', $main_media->url); $link_ = $link_array[1]; $media = '{godtube}' . $link_ . '{/godtube}'; } elseif (strpos($main_media->url, 'gofish.com') !== false) { // gofish.com link - begin $link_array = explode('gfid=', $main_media->url); $link_ = $link_array[1]; $media = '{gofish}' . $link_ . '{/gofish}'; } elseif (strpos($main_media->url, 'google.com') !== false) { // Google Video link - begin $link_array = explode('docid=', $main_media->url); $link_ = $link_array[1]; $media = '{google}' . $link_ . '{/google}'; } elseif (strpos($main_media->url, 'guba.com') !== false) { // guba.com link - begin $link_array = explode('watch/', $main_media->url); $link_ = $link_array[1]; $media = '{guba}' . $link_ . '{/guba}'; } elseif (strpos($main_media->url, 'hook.tv') !== false) { // hook.tv link - begin $link_array = explode('key=', $main_media->url); $link_ = $link_array[1]; $media = '{hook}' . $link_ . '{/hook}'; } elseif (strpos($main_media->url, 'jumpcut.com') !== false) { // jumpcut.com link - begin $link_array = explode('id=', $main_media->url); $link_ = $link_array[1]; $media = '{jumpcut}' . $link_ . '{/jumpcut}'; } elseif (strpos($main_media->url, 'kewego.com') !== false) { // kewego.com link - begin $begin_tag = strpos($main_media->url, 'video/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '.'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{kewego}' . $link_ . '{/kewego}'; } elseif (strpos($main_media->url, 'krazyshow.com') !== false) { // krazyshow.com [adult] link - begin $link_array = explode('cid=', $main_media->url); $link_ = $link_array[1]; $media = '{krazyshow}' . $link_ . '{/krazyshow}'; } elseif (strpos($main_media->url, 'ku6.com') !== false) { // ku6.com link - begin $begin_tag = strpos($main_media->url, 'show/'); $remaining_link = substr($main_media->url, $begin_tag + 5, strlen($main_media->url)); $end_tag = strpos($remaining_link, '.'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{ku6}' . $link_ . '{/ku6}'; } elseif (strpos($main_media->url, 'liveleak.com') !== false) { // liveleak.com link - begin $link_array = explode('i=', $main_media->url); $link_ = $link_array[1]; $media = '{liveleak}' . $link_ . '{/liveleak}'; } elseif (strpos($main_media->url, 'metacafe.com') !== false) { // metacafe.com link - begin $begin_tag = strpos($main_media->url, 'watch/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strlen($remaining_link); $link_ = substr($remaining_link, 0, $end_tag); $media = '{metacafe}' . $link_ . '{/metacafe}'; } elseif (strpos($main_media->url, 'mofile.com') !== false) { // mofile.com link - begin $begin_tag = strpos($main_media->url, 'com/'); $remaining_link = substr($main_media->url, $begin_tag + 4, strlen($main_media->url)); $end_tag = strpos($remaining_link, '/'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{mofile}' . $link_ . '{/mofile}'; } elseif (strpos($main_media->url, 'myspace.com') !== false) { // myspace.com link - begin $link_array = explode('VideoID=', $main_media->url); $link_ = $link_array[1]; $media = '{myspace}' . $link_ . '{/myspace}'; } elseif (strpos($main_media->url, 'myvideo.de') !== false) { // myvideo.de link - begin $begin_tag = strpos($main_media->url, 'watch/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '/'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{myvideo}' . $link_ . '{/myvideo}'; } elseif (strpos($main_media->url, 'redtube.com') !== false) { // redtube.com [adult] link - begin $link_array = explode('/', $main_media->url); $link_ = $link_array[1]; $media = '{redtube}' . $link_ . '{/redtube}'; } elseif (strpos($main_media->url, 'revver.com') !== false) { // revver.com link - begin $begin_tag = strpos($main_media->url, 'video/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '/'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{revver}' . $link_ . '{/revver}'; } elseif (strpos($main_media->url, 'sapo.pt') !== false) { // sapo.pt link - begin $link_array = explode('pt/', $main_media->url); $link_ = $link_array[1]; $media = '{sapo}' . $link_ . '{/sapo}'; } elseif (strpos($main_media->url, 'sevenload.com') !== false) { // sevenload.com link - begin $begin_tag = strpos($main_media->url, 'videos/'); $remaining_link = substr($main_media->url, $begin_tag + 7, strlen($main_media->url)); $end_tag = strpos($remaining_link, '-'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{sevenload}' . $link_ . '{/sevenload}'; } elseif (strpos($main_media->url, 'sohu.com') !== false) { // sohu.com link - begin $link_array = explode('/', $main_media->url); $link_ = $link_array[count($link_array) - 1]; $media = '{sohu}' . $link_ . '{/sohu}'; } elseif (strpos($main_media->url, 'southparkstudios.com') !== false) { // southparkstudios.com link - begin $begin_tag = strpos($main_media->url, 'clips/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '/'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{southpark}' . $link_ . '{/southpark}'; } elseif (strpos($main_media->url, 'spike.com') !== false) { // spike.com link - begin $link_array = explode('video/', $main_media->url); $link_ = $link_array[1]; $media = '{spike}' . $link_ . '{/spike}'; } elseif (strpos($main_media->url, 'stickam.com') !== false) { // stickam.com link - begin $link_array = explode('mId=', $main_media->url); $link_ = $link_array[1]; $media = '{stickam}' . $link_ . '{/stickam}'; } elseif (strpos($main_media->url, 'stupidvideos.com') !== false) { // stupidvideos.com link - begin $link_array = explode('#', $main_media->url); $link_ = $link_array[1]; $media = '{stupidvideos}' . $link_ . '{/stupidvideos}'; } elseif (strpos($main_media->url, 'tudou.com') !== false) { // tudou.com link - begin $begin_tag = strpos($main_media->url, 'view/'); $remaining_link = substr($main_media->url, $begin_tag + 5, strlen($main_media->url)); $end_tag = strpos($remaining_link, '/'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{tudou}' . $link_ . '{/tudou}'; } elseif (strpos($main_media->url, 'ustream.tv') !== false) { // ustream.tv link - begin $link_array = explode('recorded/', $main_media->url); $link_ = $link_array[1]; $media = '{ustream}' . $link_ . '{/ustream}'; } elseif (strpos($main_media->url, 'veoh.com') !== false) { // veoh.com link - begin $link_array = explode('videos/', $main_media->url); $link_ = $link_array[1]; $media = '{veoh}' . $link_ . '{/veoh}'; } elseif (strpos($main_media->url, 'videotube.de') !== false) { // videotube.de link - begin $link_array = explode('watch/', $main_media->url); $link_ = $link_array[1]; $media = '{videotube}' . $link_ . '{/videotube}'; } elseif (strpos($main_media->url, 'vidiac.com') !== false) { // vidiac.com link - begin $begin_tag = strpos($main_media->url, 'video/'); $remaining_link = substr($main_media->url, $begin_tag + 6, strlen($main_media->url)); $end_tag = strpos($remaining_link, '.'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{vidiac}' . $link_ . '{/vidiac}'; } elseif (strpos($main_media->url, 'vimeo.com') !== false) { // vimeo.com link - begin $link_array = explode('.com/', $main_media->url); $link_ = $link_array[1]; $media = '{vimeo}' . $link_ . '{/vimeo}'; } elseif (strpos($main_media->url, 'yahoo.com') !== false) { // video.yahoo.com link - begin $link_array = explode('watch/', $main_media->url); $link_ = $link_array[1]; $media = '{yahoo}' . $link_ . '{/yahoo}'; } elseif (strpos($main_media->url, 'youare.tv') !== false) { // youare.tv link - begin $link_array = explode('id=', $main_media->url); $link_ = $link_array[1]; $media = '{youare}' . $link_ . '{/youare}'; } elseif (strpos($main_media->url, 'youku.com') !== false) { // youku.com link - begin $begin_tag = strpos($main_media->url, 'v_show/'); $remaining_link = substr($main_media->url, $begin_tag + 7, strlen($main_media->url)); $end_tag = strpos($remaining_link, '.'); if ($end_tag === false) { $end_tag = strlen($remaining_link); } $link_ = substr($remaining_link, 0, $end_tag); $media = '{youku}' . $link_ . '{/youku}'; } elseif (strpos($main_media->url, 'youmaker.com') !== false) { // youmaker.com link - begin $link_array = explode('id=', $main_media->url); $link_ = $link_array[1]; $media = '{youmaker}' . $link_ . '{/youmaker}'; } else { //----------- not special link - begin $extension_array = explode('.', $main_media->url); $extension = $extension_array[count($extension_array) - 1]; if (strtolower($extension) == 'flv' || strtolower($extension) == 'swf' || strtolower($extension) == 'mov' || strtolower($extension) == 'wmv' || strtolower($extension) == 'mp4' || strtolower($extension) == 'divx') { $tag_begin = '{' . strtolower($extension) . 'remote}'; $tag_end = '{/' . strtolower($extension) . 'remote}'; } if (!isset($tag_begin)) { $tag_begin = NULL; } if (!isset($tag_end)) { $tag_end = NULL; } $media = $tag_begin . $main_media->url . $tag_end; //----------- not special link - begin } $media = guruAdminHelper::jwAllVideos($media, $aheight, $awidth, $vheight, $vwidth, $layout_id, $main_media->auto_play); } //$media = '<a target="_blank" href="'.$main_media->url.'">'.$main_media->name.'</a>'; if ($main_media->source == 'local') { $extension_array = explode('.', $main_media->local); $extension = $extension_array[count($extension_array) - 1]; //echo $extension; if (strtolower($extension) == 'flv' || strtolower($extension) == 'swf' || strtolower($extension) == 'mov' || strtolower($extension) == 'wmv' || strtolower($extension) == 'mp4' || strtolower($extension) == 'divx') { $tag_begin = '{' . strtolower($extension) . 'remote}'; $tag_end = '{/' . strtolower($extension) . 'remote}'; } if (!isset($tag_begin)) { $tag_begin = NULL; } if (!isset($tag_end)) { $tag_end = NULL; } $media = $tag_begin . str_replace("/administrator", "", JURI::base()) . $configs->videoin . '/' . $main_media->local . $tag_end; $media = guruAdminHelper::jwAllVideos($media, $aheight, $awidth, $vheight, $vwidth, $layout_id, $main_media->auto_play); } } if ($main_media->type == 'audio') { if ($main_media->source == 'code') { $media = $main_media->code; } if ($main_media->source == 'url') { $extension_array = explode('.', $main_media->url); $extension = $extension_array[count($extension_array) - 1]; if (strtolower($extension) == 'mp3' || strtolower($extension) == 'wma' || strtolower($extension) == 'm4a') { $tag_begin = '{' . strtolower($extension) . 'remote}'; $tag_end = '{/' . strtolower($extension) . 'remote}'; } $media = $tag_begin . $main_media->url . $tag_end; $media = guruAdminHelper::jwAllVideos($media, $aheight, $awidth, $vheight, $vwidth, $layout_id, $main_media->auto_play); //$media = '<a target="_blank" href="'.$main_media->url.'">'.$main_media->name.'</a>'; } if ($main_media->source == 'local') { $extension_array = explode('.', $main_media->local); $extension = $extension_array[count($extension_array) - 1]; if (strtolower($extension) == 'mp3' || strtolower($extension) == 'wma' || strtolower($extension) == 'm4a') { $tag_begin = '{' . strtolower($extension) . 'remote}'; $tag_end = '{/' . strtolower($extension) . 'remote}'; } //$params = ''; $media = $tag_begin . str_replace("/administrator", "", JURI::base()) . $configs->audioin . '/' . $main_media->local . $tag_end; $media = guruAdminHelper::jwAllVideos($media, $aheight, $awidth, $vheight, $vwidth, $layout_id, $main_media->auto_play); } } if ($main_media->type == 'url') { $media = '<a target="_blank" href="' . $main_media->url . '">' . $main_media->name . '</a>'; } if ($main_media->type == 'docs') { if ($main_media->source == 'url') { $media = '<a target="_blank" href="' . $main_media->url . '">' . $main_media->name . '</a>'; } if ($main_media->source == 'local') { $media = '<a target="_blank" href="' . str_replace("/administrator", "", JURI::base()) . '/' . $configs->docsin . '/' . $main_media->local . '">' . $main_media->name . '</a>'; } } if (isset($media)) { return $media; } else { return NULL; } }
$the_image = $_row->local; } // generating thumb image - start $img_size = @getimagesize(JPATH_SITE . DS . $configuration->imagesin . '/' . $the_image); $img_width = $img_size[0]; $img_height = $img_size[1]; if ($img_width > 0 && $img_height > 0) { if ($media_prop == 'w') { $thumb_width = $media_fullpx; $thumb_height = $img_height / ($img_width / $media_fullpx); } elseif ($media_prop == 'h') { $thumb_height = $media_fullpx; $thumb_width = $img_width / ($img_height / $media_fullpx); } $image_to_thumb = JPATH_SITE . DS . $configuration->imagesin . '/' . $the_image; $image_full_thumb = guruAdminHelper::create_thumbnails($image_to_thumb, $thumb_width, $thumb_height, $img_width, $img_height, 'full_'); //echo JPATH_SITE.DS.'images'.DS.'stories'.DS.$image_full_thumb; $media_image = '<img style="margin:5px;" border="0" alt="" src="' . JURI::root() . $configuration->imagesin . DS . $image_full_thumb . '" />'; } else { $media_image = 'none'; } // generating thumb image - stop ?> <?php echo $media_image; /* <img src="<?php echo str_replace('/administrator','/',JURI::base()); echo $configuration->imagesin.'/';?><?php if(isset($_POST['image'])) echo $_POST['image']; else echo $categ->image;?>" alt="" />*/ ?> </td> </tr> </table> </td>
function parse_audio($id) { $db = JFactory::getDBO(); $helperclass = new guruAdminHelper(); $sql = "SELECT * FROM #__guru_config LIMIT 1"; $db->setQuery($sql); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } $configs = $db->loadObject(); $sql = "SELECT * FROM #__guru_media\r\n\t\t\t\t\tWHERE id = " . $id; $db->setQuery($sql); $the_media = $db->loadObject(); $the_media->code = stripslashes($the_media->code); $no_plugin_for_code = 0; $aheight = 0; $awidth = 0; $vheight = 0; $vwidth = 0; if ($the_media->type == 'audio') { if ($the_media->source == 'url' || $the_media->source == 'local') { if ($the_media->width == 0 || $the_media->height == 0) { $aheight = 20; $awidth = 300; } else { $aheight = $the_media->height; $awidth = $the_media->width; } } elseif ($the_media->source == 'code') { if ($the_media->width == 0 || $the_media->height == 0) { $begin_tag = strpos($the_media->code, 'width="'); if ($begin_tag !== false) { $remaining_code = substr($the_media->code, $begin_tag + 7, strlen($the_media->code)); $end_tag = strpos($remaining_code, '"'); $awidth = substr($remaining_code, 0, $end_tag); $begin_tag = strpos($the_media->code, 'height="'); if ($begin_tag !== false) { $remaining_code = substr($the_media->code, $begin_tag + 8, strlen($the_media->code)); $end_tag = strpos($remaining_code, '"'); $aheight = substr($remaining_code, 0, $end_tag); $no_plugin_for_code = 1; } else { $aheight = 20; $awidth = 300; } } else { $aheight = 20; $awidth = 300; } } else { $replace_with = 'width="' . $the_media->width . '"'; $the_media->code = preg_replace('#width="[0-9]+"#', $replace_with, $the_media->code); $replace_with = 'height="' . $the_media->height . '"'; $the_media->code = preg_replace('#height="[0-9]+"#', $replace_with, $the_media->code); $aheight = $the_media->height; $awidth = $the_media->width; } } } $awidth = "200"; $aheight = "20"; if ($the_media->type == 'audio') { if (!isset($layout_id)) { $layout_id = ""; } if ($no_plugin_for_code == 0) { $media = $helperclass->create_media_using_plugin($the_media, $configs, $awidth, $aheight, $vwidth, $vheight, $layout_id); } else { $media = $the_media->code; } } if (!isset($media)) { $media = NULL; } return stripslashes($media); }
div.modal-body{ height:700px; max-height:700px; } </style> <?php $k = 0; $n = count($this->ads); $quiz_id = intval(JRequest::getVar("quiz_id", "")); $user_id = intval(JRequest::getVar("cid", "")); $course_id = JRequest::getVar("pid", "0"); $id = JRequest::getVar("id", "0"); $quiz_name = guruAdminModelguruQuiz::getQuizName($quiz_id); $database = JFactory::getDBO(); $db = JFactory::getDBO(); $helperclass = new guruAdminHelper(); $configs = guruAdminModelguruTask::getConfigs(); $quiz_form_content = ""; $sql = "SELECT show_countdown, max_score, questions_per_page, time_quiz_taken, is_final FROM #__guru_quiz WHERE id=" . intval($quiz_id); $database->setQuery($sql); $result = $database->loadObject(); $sql = "SELECT `score_quiz` FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($quiz_id) . " and pid=" . intval($course_id) . " and id=" . intval($id) . " ORDER BY id DESC LIMIT 0,1"; $database->setQuery($sql); $result_calc = $database->loadObject(); $sql = "SELECT `question_ids` FROM #__guru_quiz_question_taken_v3 WHERE user_id=" . intval($user_id) . " and quiz_id=" . intval($quiz_id) . " and pid=" . intval($course_id) . " ORDER BY id DESC LIMIT 0,1 "; $database->setQuery($sql); $question_ids_taken_by_user = $database->loadColumn(); $question_ids_taken_by_user = $question_ids_taken_by_user["0"]; $number_of_questions = count(explode(",", $question_ids_taken_by_user)); $q = "SELECT * FROM #__guru_questions_v3 WHERE id IN (" . $question_ids_taken_by_user . ")"; $database->setQuery($q);
function parse_media($media) { $db = JFactory::getDBO(); $configs = $this->getConfig(); $no_plugin_for_code = 0; $aheight = 0; $awidth = 0; $vheight = 0; $vwidth = 0; //start video if ($media->type == 'video') { if ($media->source == 'url' || $media->source == 'local') { if ($media->width == 0 || $media->height == 0) { $media->width = 300; $media->height = 400; } } elseif ($media->source == 'code') { if ($media->width == 0 || $media->height == 0) { //parse the code to get the width and height $begin_tag = strpos($media->code, 'width="'); if ($begin_tag !== false) { $remaining_code = substr($media->code, $begin_tag + 7, strlen($media->code)); $end_tag = strpos($remaining_code, '"'); $media->width = substr($remaining_code, 0, $end_tag); $begin_tag = strpos($media->code, 'height="'); if ($begin_tag !== false) { $remaining_code = substr($media->code, $begin_tag + 8, strlen($media->code)); $end_tag = strpos($remaining_code, '"'); $media->height = substr($remaining_code, 0, $end_tag); $no_plugin_for_code = 1; } else { $media->height = 300; $media->width = 400; } } else { $media->height = 300; $media->width = 400; } } else { $replace_with = 'width="' . $media->width . '"'; $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code); $replace_with = 'height="' . $media->height . '"'; $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code); $replace_with = 'name="width" value="' . $media->width . '"'; $media->code = preg_replace('#name="width" value="[0-9]+"#', $replace_with, $media->code); $replace_with = 'name="height" value="' . $media->height . '"'; $media->code = preg_replace('#name="height" value="[0-9]+"#', $replace_with, $media->code); } } $vwidth = $media->width; $vheight = $media->height; } elseif ($media->type == 'audio') { if ($media->source == 'url' || $media->source == 'local') { if ($media->width == 0 || $media->height == 0) { $media->width = 20; $media->height = 300; } } elseif ($media->source == 'code') { if ($media->width == 0 || $media->height == 0) { $begin_tag = strpos($media->code, 'width="'); if ($begin_tag !== false) { $remaining_code = substr($media->code, $begin_tag + 7, strlen($media->code)); $end_tag = strpos($remaining_code, '"'); $media->width = substr($remaining_code, 0, $end_tag); $begin_tag = strpos($media->code, 'height="'); if ($begin_tag !== false) { $remaining_code = substr($media->code, $begin_tag + 8, strlen($media->code)); $end_tag = strpos($remaining_code, '"'); $media->height = substr($remaining_code, 0, $end_tag); $no_plugin_for_code = 1; } else { $media->height = 20; $media->width = 300; } } else { $media->height = 20; $media->width = 300; } } else { $replace_with = 'width="' . $media->width . '"'; $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code); $replace_with = 'height="' . $media->height . '"'; $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code); } } $awidth = $media->width; $aheight = $media->height; } $parts = explode(".", $media->local); $extension = strtolower($parts[count($parts) - 1]); if ($media->type == 'video' || $media->type == 'audio') { if ($media->type == 'video' && $extension == "avi") { $media->code = '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="' . $media->width . '" height="' . $media->height . '"> <param name="fileName" value="' . JURI::root() . $configs->videoin . "/" . $media->local . '"> <param name="animationatStart" value="true"> <param name="transparentatStart" value="true"> <param name="autoStart" value="true"> <param name="showControls" value="true"> <param name="Volume" value="10"> <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="' . JURI::root() . $configs->videoin . "/" . $media->local . '" name="MediaPlayer1" width="' . $media->width . '" height="' . $media->height . '" autostart="1" showcontrols="1" volume="10"> </object>'; } elseif ($no_plugin_for_code == 0) { if ($media->type == 'video' && $media->source == "url") { require_once JPATH_ROOT . '/components/com_guru/helpers/videos/helper.php'; $parsedVideoLink = parse_url($media->url); preg_match('/(?P<domain>[a-z0-9][a-z0-9\\-]{1,63}\\.[a-z\\.]{2,6})$/i', $parsedVideoLink['host'], $matches); $domain = $matches['domain']; if (!empty($domain)) { $provider = explode('.', $domain); $providerName = JString::strtolower($provider[0]); if ($providerName == "youtu") { $providerName = "youtube"; } $libraryPath = JPATH_ROOT . '/components/com_guru/helpers/videos' . '/' . $providerName . '.php'; require_once $libraryPath; $className = 'PTableVideo' . JString::ucfirst($providerName); $videoObj = new $className(); $videoObj->init($media->url); $video_id = $videoObj->getId(); $videoPlayer = $videoObj->getViewHTML($video_id, $media->width, $media->height); $media->code = $videoPlayer; } } else { $helper = new guruAdminHelper(); $media->code = $helper->create_media_using_plugin($media, $configs, $awidth, $aheight, $vwidth, $vheight); } } } //end audio //start docs type if ($media->type == 'docs') { $media->code = 'The selected element is a text file that can\'t have a preview'; if ($media->source == 'local' && (substr($media->local, strlen($media->local) - 3, 3) == 'txt' || substr($media->local, strlen($media->local) - 3, 3) == 'pdf') && $media->width > 1) { $media->code = '<div class="contentpane"> <iframe id="blockrandom" name="iframe" src="' . JURI::root() . $configs->docsin . '/' . $media->local . '" width="' . $media->width . '" height="' . $media->height . '" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe> </div>'; if ($media->show_instruction == 2) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } elseif ($media->show_instruction == 1) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br /><div style="text-align:center"><i>' . $media->instructions . '</i></div>'; } elseif ($media->show_instruction == 0) { $media->code = '<div style="text-align:center"><i>' . $media->instructions . '</i></div>' . stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } return $media->code; } elseif ($media->source == 'local' && $media->width == 1) { $media->code = '<br /><a href="' . JURI::root() . $configs->docsin . '/' . $media->local . '" target="_blank">' . $media->name . '</a>'; if ($media->show_instruction == 2) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } elseif ($media->show_instruction == 1) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br /><div style="text-align:center"><i>' . $media->instructions . '</i></div>'; } elseif ($media->show_instruction == 0) { $media->code = '<div style="text-align:center"><i>' . $media->instructions . '</i></div>' . stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } return $media->code; } elseif ($media->source == 'url' && $media->width == 0) { $media->code = '<div class="contentpane"> <iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="100%" height="600" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe> </div>'; } else { if ($media->source == 'url' && $media->width == 1) { $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->name . '</a>'; } } } //end doc //start url if ($media->type == 'url') { if ($media->width > 1) { $media->code = '<div class="contentpane"> <iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="800px" height="600px" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe> </div>'; if ($media->show_instruction == 2) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } elseif ($media->show_instruction == 1) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br /><div style="text-align:center"><i>' . $media->instructions . '</i></div>'; } elseif ($media->show_instruction == 0) { $media->code = '<div style="text-align:center"><i>' . $media->instructions . '</i></div>' . stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } return $media->code; } else { $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->url . '</a>'; } } //end url //start image if ($media->type == 'image') { $media->code = '<img width="' . $media->width . '" height="' . $media->height . '" src="' . JURI::root() . $configs->imagesin . '/media/thumbs/' . $media->local . '" />'; } //end image //start text if ($media->type == 'text') { $media->code = $media->code; } //end text //start docs type if ($media->type == 'file') { //var_dump($media); $media->code = JText::_('GURU_NO_PREVIEW'); $x = filesize(JPATH_SITE . DS . $configs->filesin . '/' . $media->local) / (1024 * 1024); $x = number_format($x, 2, '.', ''); if ($media->source == 'local' && (substr($media->local, strlen($media->local) - 3, 3) == 'zip' || substr($media->local, strlen($media->local) - 3, 3) == 'exe')) { $media->code = '<br /><a href="' . JURI::root() . $configs->filesin . '/' . $media->local . '" target="_blank">' . $media->local . " (" . $x . " Ko)" . '</a>'; //return stripslashes($media->code); if ($media->show_instruction == 2) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } elseif ($media->show_instruction == 1) { $media->code = stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br /><div style="text-align:center"><i>' . $media->instructions . '</i></div>'; } elseif ($media->show_instruction == 0) { $media->code = '<div style="text-align:center"><i>' . $media->instructions . '</i></div>' . stripslashes($media->code) . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } return $media->code; } else { if ($media->source == 'url') { $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->name . '</a>'; } } } //end doc if ($media->type == 'text') { $media->code = $media->code; } else { if ($media->show_instruction == 2) { $media->code = $media->code . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } elseif ($media->show_instruction == 1) { $media->code = $media->code . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br /><div style="text-align:center"><i>' . $media->instructions . '</i></div>'; } elseif ($media->show_instruction == 0) { $media->code = '<div style="text-align:center"><i>' . $media->instructions . '</i></div>' . $media->code . '<br /><br /><div style="text-align:center"><i>' . $media->name . '</i></div><br />'; } } return stripslashes($media->code); }