Esempio n. 1
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function recent()
	{
	global $Itemid;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$jconfig = new jconfig();
		$my = & JFactory::getUser();

        // sql search filters
        $where = ' WHERE a.published = 1';
        $where .= ' AND a.approved = "yes"';
        if (!$my->id) {
        $where .= ' AND a.public_private = "public"';
        }

        // get videos
        $query = 'SELECT a.*'
                . ' FROM #__hwdvidsvideos AS a'
                . $where
                . ' ORDER BY a.date_uploaded DESC'
                . ' LIMIT 0, 50'
                ;
        $db->SetQuery($query);
        $rows = $db->loadObjectList();

		$link_rss = JURI::root().'index.php?option=com_hwdvideoshare&task=rss&feed=recent';
		$link_rss = str_replace("&", "&", $link_rss);

echo '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>

    <title>'.$jconfig->sitename.'</title>
    <link>'.JURI::root().'</link>
    <description>Recent Videos</description>
    <category>Video</category>
    <atom:link href="'.$link_rss.'" rel="self" type="application/rss+xml" />
    ';

	for ($i=0, $n=count($rows); $i < $n; $i++) {
		$row = $rows[$i];
		$title = stripslashes($row->title);
		$description = stripslashes($row->description);
		$category = html_entity_decode(hwd_vs_tools::generateCategory($row->category_id));

		$link_video = JURI::root()."index.php?option=com_hwdvideoshare&task=viewvideo&Itemid=".$Itemid."&video_id=".$row->id;
		$link_video = 'http://'.$_SERVER['HTTP_HOST'].JRoute::_("index.php?option=com_hwdvideoshare&task=viewvideo&Itemid=$Itemid&video_id=$row->id");

		$thumbnailURL = hwd_vs_tools::generateThumbnailURL( $row->id, $row->video_id, $row->video_type, $row->thumbnail );

		if ($row->video_type == 'local') {

		    $thumbnailURL = 'http://'.$_SERVER['HTTP_HOST'].$thumbnailURL;

		} else {

			$pos = strpos($thumbnailURL, "http");
			if ($pos === false) {
				$thumbnailURL = 'http://'.$_SERVER['HTTP_HOST'].$thumbnailURL;
			} else {
				$thumbnailURL = $thumbnailURL;
			}

	    }

		$thumbnailURL = str_replace("&", "&amp;", $thumbnailURL);
		$downloadURL = $thumbnailURL;

		$downloadSIZE = "999";

		date_default_timezone_set('GMT');

echo '<item>
      <title><![CDATA['.stripslashes($title).']]></title>
      <link><![CDATA['.$link_video.']]></link>
      <description><![CDATA[<img src="'.$thumbnailURL.'" style="float:right;padding:10px;" width="120" height="90" />&#160;'.stripslashes($description).']]></description>
      <category><![CDATA['.stripslashes($category).']]></category>
      <pubDate>'.date('D, d M Y H:i:s e', strtotime($row->date_uploaded)).'</pubDate>
      <guid>'.$link_video.'</guid>
      <enclosure url="'.$downloadURL.'" length="'.$downloadSIZE.'" type="image/jpeg" />
    </item>
    ';

	}
echo '
  </channel>
</rss>';
		exit;
        // <enclosure url="'.$downloadURL.'" length="'.$downloadSIZE.'" type="image/jpeg" />
		// <enclosure url="'.$downloadURL.'" length="'.$downloadSIZE.'" type="video/x-flv" />
	}
Esempio n. 2
0
   /**
	* system cleanup
	*/
	function ajax_WarpHdSync()
	{
		global $smartyvs;
		$db = & JFactory::getDBO();
		$c = hwd_vs_Config::get_instance();

		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'warp'.DS.'infin-lib.php');
		$accountKey = $c->warpAccountKey;
		$secretKey = $c->warpSecretKey;

		$query = 'SELECT * FROM #__hwdvidsvideos WHERE video_type = "warphd"';
		$db->SetQuery($query);
		$rows = $db->loadObjectList();

		for ($i=0, $n=count($rows); $i < $n; $i++)
		{
			$row = $rows[$i];

			$infinVideo = new InfinovationVideo($accountKey, $secretKey);
			$videoInfo = $infinVideo->getVideoInfo($row->video_id);

			$duration = hwd_vs_tools::sec2hms($videoInfo->duration);

			$db->SetQuery("UPDATE #__hwdvidsvideos SET video_length = \"$duration\" WHERE id = $row->id");
			if ( !$db->query() )
			{
				echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
				exit();
			}
		}

		echo "Synchronised ".count($rows)." WarpHD videos";
		exit;
	}
    /**
     * Outputs frontpage HTML
     *
     * @param string $option  the joomla component name
     * @param array  $rows  array of video data
     * @param array  $rowsfeatured  array of featured video data
     * @param object $pageNav  page navigation object
     * @param int    $total  the total video count
     * @return       Nothing
     */
	function fixVideoDataFormat($videoid=null) {
		$db = & JFactory::getDBO();

        if (isset($videoid)) {

			$query = 'SELECT id, title, description, tags'
					. ' FROM #__hwdvidsvideos'
					. ' WHERE id = '.$videoid
					;
			$db->SetQuery($query);
			$rows = $db->loadObjectList();

        } else {

			$query = 'SELECT *'
					. ' FROM #__hwdvidsvideos'
					;
			$db->SetQuery($query);
			$rows = $db->loadObjectList();

		}

		for ($i=0, $n=count($rows); $i < $n; $i++) {

			$row = $rows[$i];

			$title 				= hwd_vs_tools::generatePostTitle($row->title);
			$description 		= hwd_vs_tools::generatePostDescription($row->description);
			$tags 				= hwd_vs_tools::generatePostTags($row->tags);

			$thumb_snap = $row->thumb_snap;
			if ($row->thumb_snap == "0:00:00") {
				$sec = intval(hwd_vs_tools::hms2sec($row->video_length));
				if ($sec < 2) {
					$thumb_snap = "0:00:02";
				} else {
					$thumb_snap = hwd_vs_tools::sec2hms($sec/2);
				}
			}

			// update sql
			$db->SetQuery("UPDATE #__hwdvidsvideos SET title = \"$title\", description = \"$description\", tags = \"$tags\", thumb_snap = \"$thumb_snap\"  WHERE id = $row->id");
			$db->Query();
			if ( !$db->query() ) {
				echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
				exit();
			}
		}

		return true;
    }
Esempio n. 4
0
	function frontpage()
	{
		global $mainframe, $limitstart, $Itemid;
		$db =& JFactory::getDBO();

		$stats = array();

        $db->setQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE approved = \"pending\"" );
		$stats['approvals'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE approved = \"queuedforconversion\" AND approved = \"queuedforthumbnail\"" );
		$stats['conversion'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidsflagged_videos WHERE status = \"UNREAD\"" );
		$stats['reportedvideos'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidsflagged_groups WHERE status = \"UNREAD\"" );
		$stats['reportedgroups'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos" );
		$stats['totalvideos'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidscategories" );
		$stats['totalcategories'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__users" );
		$stats['totalusers'] = $db->loadResult();

		$db->SetQuery( "SELECT id FROM #__users ORDER BY registerDate DESC" );
		$stats['latestuser'] = hwd_vs_tools::generateBEUserFromID($db->loadResult());

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidsgroups" );
		$stats['totalgroups'] = $db->loadResult();

		$db->SetQuery( "SELECT id, group_name FROM #__hwdvidsgroups ORDER BY date DESC" );
		$latestgroup = $db->loadObject();
		if (!empty($latestgroup->id)) { $stats['latestgroup'] = "<a href=\"index.php?option=com_hwdvideoshare&task=editgrpA&hidemainmenu=1&cid=".$latestgroup->id."\">$latestgroup->group_name</a>"; } else { $stats['latestgroup']=null; }

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE date_uploaded >= DATE_SUB(NOW(),INTERVAL 1 DAY)" );
		$stats['totalvideostoday'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidsvideos WHERE date_uploaded >= DATE_SUB(NOW(),INTERVAL 7 DAY)" );
		$stats['totalvideosweek'] = $db->loadResult();

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidslogs_views" );
		$views_30 = $db->loadResult();
		$db->SetQuery( "SELECT SUM(views) FROM #__hwdvidslogs_archive" );
		$views_all = $db->loadResult();
		$stats['totalviews'] = $views_30 + $views_all;

		$db->SetQuery( "SELECT count(*) FROM #__hwdvidslogs_favours" );
		$favours_30 = $db->loadResult();
		$db->SetQuery( "SELECT SUM(favours) FROM #__hwdvidslogs_archive" );
		$favours_all = $db->loadResult();
		$stats['totalfavours'] = $favours_30 + $favours_all;

		$db->SetQuery( "SELECT * FROM #__hwdvidsvideos ORDER BY updated_rating DESC, rating_number_votes DESC LIMIT 0, 10" );
		$mostpopular = $db->loadObjectList();
		$db->SetQuery( "SELECT * FROM #__hwdvidsvideos ORDER BY number_of_views DESC LIMIT 0, 10" );
		$mostviewed = $db->loadObjectList();
		$db->SetQuery( "SELECT * FROM #__hwdvidsvideos ORDER BY date_uploaded DESC LIMIT 0, 10" );
		$mostrecent = $db->loadObjectList();
		$db->SetQuery( "SELECT * FROM #__hwdvidsgroups ORDER BY date DESC LIMIT 0, 10" );
		$recentgroups = $db->loadObjectList();

		hwdvids_HTML::frontpage($stats, $mostpopular, $mostviewed, $mostrecent, $recentgroups);
	}
Esempio n. 5
0
	/**
	* Import Data
	*/
	function thirdPartyImport()
	{
		global $option;
		$db = & JFactory::getDBO();
		$app = & JFactory::getApplication();
		$c = hwd_vs_Config::get_instance();

		$video_type	= Jrequest::getVar( 'videotype', '5' );
		$intCount = 0;
		$admin_import = true;
		require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'models'.DS.'uploads.php');

		if ($video_type == 1 || $video_type == 5)
		{
			$requestarray = JRequest::get( 'default', 2 );
			$data = explode("\n", $requestarray['embeddump']);
			$counter = 0;

			for ($i=0, $n=count($data); $i < $n; $i++)
			{
				unset ($_REQUEST['embeddump']);
				$_REQUEST['embeddump'] = trim($data[$i]);

				if (hwd_vs_uploads::addConfirm($option, $admin_import))
				{
					$counter++;
				}
				else
				{
					// error
				}
			}
			$app->enqueueMessage($counter." video(s) successfully imported");
		}
		else if ($video_type == 2)
		{

			// youtube playlist

			$requestarray = JRequest::get( 'default', 2 );
			$data = explode("\n", $requestarray['embeddump']);
			$embeddump_original = $data[0];
			$embeddump = $data[0];

			$pos = strpos($embeddump, "p=");

			if ($pos === false) {

				$app->enqueueMessage("This is not a Youtube Playlist URL. Check if the URL is for a User list or an RSS feed, then use the correct import tool.");
				$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=import' );

			} else if ($pos) {

				$pos_srt = $pos + 2;
				$pos_end = strpos($embeddump, '&', $pos_srt);
				if ($pos_end === false) {

					$playlist_no =  substr($embeddump, $pos_srt);

				} else {

					$length = $pos_end - $pos_srt;
					$playlist_no =  substr($embeddump, $pos_srt, $length);

				}

				$playlist_no = strip_tags($playlist_no);
				$playlist_no = preg_replace("/[^a-zA-Z0-9s_-]/", "", $playlist_no);

			}

			for ($i = 0; $i <= 4; $i++) {

				$playlist_url = "http://www.youtube.com/view_play_list?p=".$playlist_no."&page=".$i;
				$playlist_url = hwd_vs_tools::get_final_url( $playlist_url );

				$msg = 'Searching page: '.$playlist_url;
				$app->enqueueMessage($msg);

				$curl_handle=curl_init();
				curl_setopt($curl_handle,CURLOPT_URL,$playlist_url);
				curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
				curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
				$buffer = curl_exec($curl_handle);
				curl_close($curl_handle);

				if (empty($buffer))	{

					return null;

				} else {

					hwdvids_BE_imports::scanYoutubePage($buffer);

				}

			}

		} else if ($video_type == 3) {

			// youtube userlist

			$requestarray = JRequest::get( 'default', 2 );
			$data = explode("\n", $requestarray['embeddump']);
			$embeddump_original = $data[0];
			$embeddump = $data[0];

			$pos = strpos($embeddump, "user=");

			if ($pos === false) {

				$pos = strpos($embeddump, "user/");

				if ($pos === false) {

					$app->enqueueMessage("This is not a Youtube User URL. Check if the URL is for a Playlist or an RSS feed, then use the correct import tool.");
					$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=import' );

				} else if ($pos) {

					$pos_srt = $pos + 5;
					$pos_end = strpos($embeddump, '&', $pos_srt);
					if ($pos_end === false) {

						$pos_end = strpos($embeddump, '#', $pos_srt);
						if ($pos_end === false) {

							$username =  substr($embeddump, $pos_srt);

						} else {

							$length = $pos_end - $pos_srt;
							$username =  substr($embeddump, $pos_srt, $length);

						}

					} else {

						$length = $pos_end - $pos_srt;
						$username =  substr($embeddump, $pos_srt, $length);

					}

					$username = strip_tags($username);
					$username = preg_replace("/[^a-zA-Z0-9s_-]/", "", $username);

				}

			} else if ($pos) {

				$pos_srt = $pos + 5;

				$pos_end = strpos($embeddump, '&', $pos_srt);

				if ($pos_end === false) {

					$pos_end = strpos($embeddump, '#', $pos_srt);

					if ($pos_end === false) {

						$username =  substr($embeddump, $pos_srt);

					} else {

						$length = $pos_end - $pos_srt;
						$username =  substr($embeddump, $pos_srt, $length);

					}

				} else {

					$length = $pos_end - $pos_srt;
					$username =  substr($embeddump, $pos_srt, $length);

				}

				$username = strip_tags($username);
				$username = preg_replace("/[^a-zA-Z0-9s_-]/", "", $username);

			}

			//$username_url = "http://www.youtube.com/profile?user=".$username."#g/u";
			$username_url = "http://gdata.youtube.com/feeds/videos?author=".$username."&start-index=1&max-results=50";
			$username_url = hwd_vs_tools::get_final_url( $username_url );

			$msg = 'Searching page: '.$username_url;
			$app->enqueueMessage($msg);

			$curl_handle=curl_init();
			curl_setopt($curl_handle,CURLOPT_URL,$username_url);
			curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
			curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
			$buffer = curl_exec($curl_handle);
			curl_close($curl_handle);

			if (empty($buffer))	{

				return null;

			} else {

				hwdvids_BE_imports::scanYoutubePage($buffer);

			}

		} else if ($video_type == 4) {

			// youtube rss

			$requestarray = JRequest::get( 'default', 2 );
			$data = explode("\n", $requestarray['embeddump']);
			$embeddump_original = $data[0];
			$embeddump = $data[0];

			$pos = strpos($embeddump, "http");

			if ($pos === false) {
				$embeddump = 'http://'.$embeddump;
			}

			$pos = strpos($embeddump, "gdata");

			if ($pos === false) {
				$feedurl = "http://www.youtube.com".parse_url($embeddump, PHP_URL_PATH)."?".parse_url($embeddump, PHP_URL_QUERY);
			} else {
				$feedurl = "http://gdata.youtube.com".parse_url($embeddump, PHP_URL_PATH)."?".parse_url($embeddump, PHP_URL_QUERY);
			}

			$curl_handle=curl_init();
			curl_setopt($curl_handle,CURLOPT_URL,$feedurl);
			curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
			curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
			$buffer = curl_exec($curl_handle);
			curl_close($curl_handle);

			if (empty($buffer))	{

				return null;

			} else {

				hwdvids_BE_imports::scanYoutubePage($buffer);

			}

		}


		if ($video_type == 1 || $video_type == 5) {

			$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=import' );

		} else {

			$embeddump 			= urlencode($embeddump_original);
			$videotype 			= JRequest::getInt( 'videotype', 0 );
			$category_id 		= JRequest::getInt( 'category_id', 0 );
			$public_private 	= JRequest::getWord( 'public_private', 'public' );
			$allow_comments 	= JRequest::getInt( 'allow_comments', 0 );
			$allow_embedding 	= JRequest::getInt( 'allow_embedding', 0 );
			$allow_ratings 		= JRequest::getInt( 'allow_ratings', 0 );

			$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=redoListImport&embeddump='.$embeddump.'&videotype='.$videotype.'&category_id='.$category_id.'&public_private='.$public_private.'&allow_comments='.$allow_comments.'&allow_embedding='.$allow_embedding.'&allow_ratings='.$allow_ratings );

		}

	}
Esempio n. 6
0
    /**
     * Make xml playlist file
     *
     * @return       True
     */
    function XMLPlaylistFile($rows, $filename)
    {
		$db =& JFactory::getDBO();
		$c = hwd_vs_Config::get_instance();
    	jimport('joomla.filesystem.file');

		$config = null;
		$config .= "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n";
		$config .= "<title>hwdVideoShare Playlist</title>\n";
		$config .= "<info>http:/xspf.org/xspf-v1.html</info>\n";
		$config .= "<date>".date('Y-m-d H:i:s')."</date>\n";
		$config .= "<trackList>\n";
		$config .= "\n";

		// print out playlist
		for ($i=0, $n=count($rows); $i < $n; $i++)
		{
			$row = $rows[$i];

			$type = "video";

			if (($row->video_type == "youtube.com" || ($row->video_type == "seyret" && substr($row->video_id, 0, 7) == "youtube")) && ($c->hwdvids_videoplayer_file == "jwflv" || $c->hwdvids_videoplayer_file == "jwflv_v5"))
			{
				$data = @explode(",", $row->video_id);
				if ($row->video_type == "seyret")
				{
					$YTID = $data[1];
				}
				else
				{
					$YTID = $data[0];
				}

				$location = "http://www.youtube.com/watch?v=".$YTID;
				$image = hwd_vs_tools::generatePlayerThumbnail($row);
				$type = "youtube";
			}
			else
			{
				$locations = hwd_vs_tools::generateVideoLocations($row);
				$location = $locations['url'];
				$image = hwd_vs_tools::generatePlayerThumbnail($row);
			}

			if (empty($location)) continue;

			//$title      = hwd_vs_tools::truncateText(strip_tags(hwdEncoding::UNXMLEntities($row->title)), 50);
			//$annotation = hwd_vs_tools::truncateText(strip_tags(hwdEncoding::UNXMLEntities($row->description)), 50);

			$title      = strip_tags(hwdEncoding::UNXMLEntities($row->title));
			$annotation = strip_tags(hwdEncoding::UNXMLEntities($row->description));
			$image = urldecode($image);

		    $config .= "  <track>\n";
		    $config .= "    <location><![CDATA[".$location."]]></location>\n";
		    $config .= "    <image><![CDATA[".$image."]]></image>\n";
		    $config .= "    <title><![CDATA[".$title."]]></title>\n";
		    $config .= "    <annotation><![CDATA[".$annotation."]]></annotation>\n";
			$config .= "	<meta rel='type'>".$type."</meta>\n";
		    $config .= "  </track>\n";
		    $config .= "\n";
		}

		$config .= "</trackList>\n";
		$config .= "</playlist>\n";

		$configFile = JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'xml'.DS.'xspf'.DS.$filename.'.xml';
		if (!JFile::write($configFile, $config)) {
			return false;
		}

		return true;
    }
Esempio n. 7
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function grabAjaxPlayer()
	{
		global $Itemid, $smartyvs, $hwdvs_selectv, $hwdvs_joinv, $mainframe, $hwdvsAjaxPlayer;

		header('Content-type: text/html; charset=utf-8');

		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = &JComponentHelper::getParams( 'com_users' );

		$video_id = JRequest::getInt( 'video_id', 0 );
		$template = JRequest::getVar( 'template', '' );
		$showdetails = JRequest::getInt( 'showdetails', '1' );
		$width = JRequest::getInt( 'width', null );
		$height = JRequest::getInt( 'height', null );
		$quality = JRequest::getWord( 'quality', 'hd' );
		$autostart = JRequest::getInt( 'autostart', null );
		$hwdvsAjaxPlayer = true;

		if (!hwd_vs_access::allowAccess( $c->gtree_plyr, $c->gtree_plyr_child, hwd_vs_access::userGID( $my->id ))) {
			if ( ($my->id < 1) && (!$usersConfig->get( 'allowUserRegistration' ) == '0' && hwd_vs_access::allowAccess( $c->gtree_upld, 'RECURSE', $acl->get_group_id('Registered','ARO') ) ) ) {
				hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORPLYR, "exclamation.png", 0, 0);
				exit;
			} else {
				hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_PLYR_NOT_AUTHORIZED, "exclamation.png", 0, 0);
				exit;
			}
		}

        $where = ' WHERE video.id = '.$video_id;

		$query = "SELECT".$hwdvs_selectv." FROM #__hwdvidsvideos AS video ".$hwdvs_joinv." ".$where;
        $db->SetQuery($query);
        $row = $db->loadObject();

		if (!hwd_vs_tools::validateVideoAccess($row))
		{
			exit;
		}

		hwd_vs_tools::logViewing($row->id);
		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');

		if ($showdetails == 1) {
			$smartyvs->assign("showdetails", 1);
		}

		$videoplayer = hwd_vs_tools::generateVideoDetails($row, $width, $height, null, $Itemid, null, null, $autostart);
		$smartyvs->assign("videoplayer", $videoplayer);
		hwd_vs_javascript::ajaxRate($row);

		if (empty($template) || $template == '') {
			$html = $smartyvs->fetch('plug_jomsocial_ajax.tpl');
		} else if ($template == 'playeronly') {
			$html = $videoplayer->player;
		} else {
			$html = $smartyvs->fetch($template.'.tpl');
		}

		print $html;
		exit;
	}
Esempio n. 8
0
	/**
	 * save categories
	 */
	function savecategories()
	{
		global $option;
		$db = & JFactory::getDBO();
		$app = & JFactory::getApplication();
		$c = hwd_vs_Config::get_instance();

		$access_lev_u = Jrequest::getVar( 'access_lev_u', '0' );
		$access_lev_v = Jrequest::getVar( 'access_lev_v', '0' );

		$row = new hwdvids_cats($db);

		if (isset($_FILES['thumbnail_file']['error'])) {

			$file_name_org   = $_FILES['thumbnail_file']['name'];
			$file_ext        = substr($file_name_org, strrpos($file_name_org, '.') + 1);

			$thumbnail_url = JURI::root( true ).'/hwdvideos/thumbs/category'.$_POST['id'].'.'.$file_ext;
			$base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS;
			$thumbnail_name = 'category'.$_POST['id'];

			$upload_result = hwd_vs_tools::uploadFile("thumbnail_file", $thumbnail_name, $base_Dir, 2, "jpg,jpeg", 1);

			if ($upload_result[0] == "0") {

				$msg = $upload_result[1];
				$app->enqueueMessage($msg);

			} else {

				include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'thumbnail.inc.php');
				$thumb_path_s = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.$thumbnail_name.'.'.$file_ext;
				$twidth_s = round($c->con_thumb_n);
				$theight_s = round($c->con_thumb_n*$c->tar_fb);

				list($width, $height, $type, $attr) = @getimagesize($thumb_path_s);
				$ratio = $height/$width;

				if ($ratio < $c->tar_fb) {

					$resized_s = new Thumbnail($thumb_path_s);
					$resized_s->resize(1000, $theight_s);
					$resized_s->cropFromCenter($twidth_s, $theight_s);
					$resized_s->save($thumb_path_s);
					$resized_s->destruct();

				} else {

					$resized_s = new Thumbnail($thumb_path_s);
					$resized_s->resize($twidth_s,1000);
					$resized_s->cropFromCenter($twidth_s, $theight_s);
					$resized_s->save($thumb_path_s);
					$resized_s->destruct();

				}
			}

			// update db with new thumbnail
			$db->SetQuery("UPDATE #__hwdvidscategories SET thumbnail = '$thumbnail_url' WHERE id = ".intval($_POST['id']));
			$db->Query();
			if ( !$db->query() ) {
				echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
				exit();
			}

			$msg = "Thumbnail was successfully uploaded";
			$app->enqueueMessage($msg);
			$app->redirect( 'index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editcatA&hidemainmenu=1&cid='.$_POST['id'] );

		} else {

			if (intval($_POST['id']) !== 0 && (intval($_POST['id']) == intval($_POST['parent']))) {
				$app->enqueueMessage(_HWDVIDS_ALERT_PARENTNOTSELF);
				$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=categories' );
			}

			$_POST['category_name'] = Jrequest::getVar( 'category_name', 'no name supplied' );
			$_POST['category_description'] = Jrequest::getVar( 'category_description', 'no name supplied' );
			$_POST['access_lev_u'] = @implode(",", $access_lev_u);
			$_POST['access_lev_v'] = @implode(",", $access_lev_v);

		}

		// bind it to the table
		if (!$row -> bind($_POST)) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		if(empty($row->category_name)) {
			$app->enqueueMessage(_HWDVIDS_NOTITLE);
			$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=categories' );
		}

		// store it in the db
		if (!$row -> store()) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		$row->checkin();

		// perform maintenance
		include(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
		hwd_vs_recount::recountSubcatsInCategory();

		$app->enqueueMessage(_HWDVIDS_ALERT_CATSAVED);
		$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=categories' );
	}
Esempio n. 9
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function savePlaylist()
	{
		global $mainframe, $params, $Itemid, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $mosConfig_sitename;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();

		if ($c->disablecaptcha == "0") {
			$sessid = session_id();
			if (empty($sessid)) {
				session_start();
			}
			if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {
				// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
   		    	hwd_vs_playlists::bindNewPlaylist();
				unset($_SESSION['security_code']);
			} else {
				// Insert your code for showing an error message here
        		hwd_vs_tools::infomessage(3, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ERRSC, "exclamation.png", 0);
				return;
			}

   		} else {
   		    hwd_vs_playlists::bindNewPlaylist();
		}
	}
Esempio n. 10
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function addConfirm($admin_import=false)
	{
		global $Itemid, $j15, $j16;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();

		$security_code = JRequest::getCmd( 'security_code', '' );
		if ($c->disablecaptcha == "1")
		{
			$checksecurity = "0";
		}
		else
		{
			$checksecurity = "1";
		}
		if ($checksecurity == "1" && !$admin_import)
		{
			if(($_SESSION['security_code'] == $security_code) && (!empty($_SESSION['security_code'])) )
			{
				unset($_SESSION['security_code']);
			}
			else
			{
        		hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ERRSC, "exclamation.png", 0);
				return;
			}
		}

		$requestarray = JRequest::get( 'default', 2 );
		$embeddump = $requestarray['embeddump'];
		$remote_verified = null;

		$parsedurl = parse_url($embeddump);
		if (empty($parsedurl['host'])) { $parsedurl['host'] = ''; }
		preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $parsedurl['host'], $regs);
		if (empty($regs['domain'])) { $regs['domain'] = ''; }

		if ($j15)
		{
			if ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php'))
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php');
			}
			else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google.php'))
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google.php');
			}
			else if (file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.$regs['domain'].'.php'))
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.$regs['domain'].'.php');
			}
			else
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php');
				$regs['domain'] = 'remote';
			}
		}
		if ($j16)
		{
			if ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube'.DS.'youtube.php'))
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube'.DS.'youtube.php');
			}
			else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google'.DS.'google.php'))
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google'.DS.'google.php');
			}
			else if (file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'thirdpartysupportpack'.DS.$regs['domain'].'.php'))
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'thirdpartysupportpack'.DS.$regs['domain'].'.php');
			}
			else
			{
				require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'remote'.DS.'remote.php');
				$regs['domain'] = 'remote';
			}
		}

		$failures = "";
		if (!isset($remote_verified)) {

			$cn = 'hwd_vs_tp_'.preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']);
			$f_processc = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processCode';
			$f_processi = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processThumbnail';
			$f_processt = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processTitle';
			$f_processd = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDescription';
			$f_processk = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processKeywords';
			$f_processl = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDuration';

			$tp = new $cn();

			$ext_v_code  = $tp->$f_processc($embeddump);

			//check if already exists
			$db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' );
			$duplicatecount = $db->loadResult();

			if ($duplicatecount > 0 && $admin_import == false) {
				hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0);
				return;
			} else if ($duplicatecount > 0 && $admin_import == true) {
				return false;
			}

			$ext_v_title = $tp->$f_processt($embeddump, @$ext_v_code[1]);
			$ext_v_descr = $tp->$f_processd($embeddump, @$ext_v_code[1]);
			$ext_v_keywo = $tp->$f_processk($embeddump, @$ext_v_code[1]);
			$ext_v_durat = $tp->$f_processl($embeddump, @$ext_v_code[1]);

			if ($ext_v_code[0] == "0") {

				require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/remote.php');
				$regs['domain'] = 'remote';

				$tp = new hwd_vs_tp_remote();
				$ext_v_code  = $tp->remoteProcessCode($embeddump);
				$ext_v_title = $tp->remoteProcessTitle($embeddump, @$ext_v_code[1]);
				$ext_v_descr = $tp->remoteProcessDescription($embeddump, @$ext_v_code[1]);
				$ext_v_keywo = $tp->remoteProcessKeywords($embeddump, @$ext_v_code[1]);
				$ext_v_durat = $tp->remoteProcessDuration($embeddump, @$ext_v_code[1]);

				if ($ext_v_code[0] == "0") {
					hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_INFO_TPPROCESSFAIL, "exclamation.png", 0);
					return;
				}

				//check if already exists
				$db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' );
				$duplicatecount = $db->loadResult();

				if ($duplicatecount > 0 && $admin_import == false) {
					hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0);
					return;
				} else if ($duplicatecount > 0 && $admin_import == true) {
					return false;
				}
			}

			if ($ext_v_title[0] == 0) {$failures.=_HWDVIDS_INFO_TPTITLEFAIL."<br />";}
			if ($ext_v_descr[0] == 0) {$failures.=_HWDVIDS_INFO_TPDESCFAIL."<br />";}
			if ($ext_v_keywo[0] == 0) {$failures.=_HWDVIDS_INFO_TPKWFAIL."<br />";}
			if ($ext_v_durat[0] == 0) {$failures.=_HWDVIDS_INFO_TPDRFAIL."<br />";}

		} else if ($remote_verified == 0) {

			$error_msg = _HWDVIDS_ERROR_UPLDERR11."<br /><br />"._HWDVIDS_INFO_SUPPTPW."<br />".hwd_vs_tools::generateSupportedWebsiteList();
			hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, $error_msg, "exclamation.png", 1);
			return;

		}

		$title 				= hwd_vs_tools::generatePostTitle($ext_v_title[1]);
		$description 		= hwd_vs_tools::generatePostDescription($ext_v_descr[1]);
		$tags 				= hwd_vs_tools::generatePostTags($ext_v_keywo[1]);
		$category_id 		= JRequest::getInt( 'category_id', 0, 'post' );
		$public_private 	= JRequest::getWord( 'public_private' );
		$allow_comments 	= JRequest::getInt( 'allow_comments', 0, 'post' );
		$allow_embedding 	= JRequest::getInt( 'allow_embedding', 0, 'post' );
		$allow_ratings 		= JRequest::getInt( 'allow_ratings', 0, 'post' );

		$checkform = hwd_vs_tools::checkFormComplete($title, $description, $category_id, $tags, $public_private, $allow_comments, $allow_embedding, $allow_ratings);
		if (!$checkform) { return; }

		$row = new hwdvids_video($db);

		$password = Jrequest::getVar( 'hwdvspassword', '' );
		if (!empty($password))
		{
			$password = md5($password);
			$_POST['password'] 		= $password;
		}

		$_POST['video_type'] 		= $regs['domain'];
		$_POST['video_id'] 			= $ext_v_code[1];
		$_POST['title'] 			= $title;
		$_POST['description'] 		= $description;
		$_POST['category_id'] 		= $category_id;
		$_POST['tags'] 				= $tags;
		$_POST['public_private'] 	= $public_private;
		$_POST['allow_comments'] 	= $allow_comments;
		$_POST['allow_embedding'] 	= $allow_embedding;
		$_POST['allow_ratings'] 	= $allow_ratings;
		$_POST['video_length'] 		= $ext_v_durat[1];
		$_POST['date_uploaded'] 	= date('Y-m-d H:i:s');

		if ($admin_import)
		{
			$_POST['user_id'] 		= $_REQUEST['user_id'];
		}
		else
		{
			$_POST['user_id'] 		= $my->id;
		}

		if ($c->aa3v == 1) {
			$_POST['approved'] 	= "yes";
			$_POST['published'] = "1";
		} else {
			$_POST['approved'] 	= "pending";
			$_POST['published'] = "0";
		}

		// bind it to the table
		if (!$row->bind($_POST))
		{
			echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
			exit();
		}

		// store it in the db
		if (!$row->store())
		{
			echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
			exit();
		}

		include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'events.php');

		$params->title = $title;
		$params->id = $row->id;
		$params->category_id = $row->category_id;
		$params->type = $row->video_type;
		$params->user_id = $row->user_id;

		hwdvsEvent::onAfterVideoUpload($params);

		// save remote thumbnail to disk
		$data = @explode(",", $row->video_id);
		$thumburl = hwd_vs_tools::get_final_url( @$ext_v_code[2] );
		$thumbbase = "tp-".$row->id.".jpg";
		$thumbpath = JPATH_SITE.DS."hwdvideos".DS."thumbs".DS.$thumbbase;

		$ch = curl_init ($thumburl);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
		$rawdata=curl_exec($ch);
		curl_close ($ch);
		if(file_exists($thumbpath))
		{
			unlink($thumbpath);
		}
		$fp = fopen($thumbpath,'x');
		fwrite($fp, $rawdata);
		fclose($fp);

		if(file_exists($thumbpath))
		{
			$db->SetQuery( "UPDATE #__hwdvidsvideos SET `thumbnail` = \"$thumbbase\" WHERE id = $row->id" );
			$db->Query();
		}

		$video = new hwdvids_video($db);
		$video->load( $row->id );

		if (!$admin_import) {
			hwd_vs_html::addConfirm($title, $failures, $video);
		} else {
			return true;
		}
	}
Esempio n. 11
0
	/**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function bindNewGroup()
	{
		global $mainframe, $params, $Itemid, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $mosConfig_sitename;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();

		if (!hwd_vs_access::checkAccess($c->gtree_grup, $c->gtree_grup_child, 4, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORGRUP, _HWDVIDS_ALERT_GRUP_NOT_AUTHORIZED, "exclamation.png", 0, "core.frontend.group")) {return;}

			$group_name 		= Jrequest::getVar( 'group_name', _HWDVIDS_UNKNOWN );
			$public_private 	= JRequest::getWord( 'public_private' );
			$date 				= date('Y-m-d H:i:s');
			$allow_comments		= JRequest::getInt( 'allow_comments', 0, 'request' );
			$require_approval   = JRequest::getInt( 'require_approval', 0, 'request' );
			$group_description  = Jrequest::getVar( 'group_description', _HWDVIDS_UNKNOWN );
			$featured			= 0;
			$adminid            = $my->id;
			if ($c->aag == 1) {
				$published = 1;
			} else {
				$published = 0;
			}

			$checkform = hwd_vs_tools::checkGroupFormComplete( $group_name, $public_private, $allow_comments, $group_description );
			if (!$checkform) { return; }

			$row = new hwdvids_group($db);

			$_POST['group_name'] 		= $group_name;
			$_POST['public_private'] 	= $public_private;
			$_POST['date'] 				= $date;
			$_POST['allow_comments'] 	= $allow_comments;
			$_POST['require_approval'] 	= $require_approval;
			$_POST['group_description'] = $group_description;
			$_POST['featured'] 			= $featured;
			$_POST['adminid'] 			= $adminid;
			$_POST['published'] 		= $published;

			// bind it to the table
			if (!$row -> bind($_POST)) {
				echo "<script> alert('"
					.$row -> getError()
					."'); window.history.go(-1); </script>\n";
				exit();
			}

			// store it in the db
			if (!$row -> store()) {
				echo "<script> alert('"
					.$row -> getError()
					."'); window.history.go(-1); </script>\n";
				exit();
			}

			// mail admin notification
			if ($c->mailgroupnotification == 1) {
				$jconfig = new jconfig();

				$mailbody = ""._HWDVIDS_MAIL_BODY3.$jconfig->sitename.".\n";
				$mailbody .= ""._HWDVIDS_MAIL_BODY4."\"".stripslashes($group_name)."\".\n";
				if (isset($row->id)) {
					$mailbody .= "".JURI::root()."index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=viewgroup&group_id=".$row->id."\n\n";
				}
				$mailbody .= ""._HWDVIDS_MAIL_BODY5."\n";
				$mailbody .= JURI::root()."administrator";

				JUtility::sendMail( $jconfig->mailfrom, $jconfig->fromname, $c->mailnotifyaddress, _HWDVIDS_MAIL_SUBJECT2.$jconfig->sitename.' ', $mailbody );
			}

			// automatically add admin to group
			$autoa2g = @$_POST['add2group'];
			if (isset($autoa2g)) {
				if ($autoa2g == "1") {

					$date = date('Y-m-d H:i:s');
					$published = 1;

					$_POST['memberid'] = $my->id;
					$_POST['date'] = $date;
					$_POST['groupid'] = $row->id;
					$_POST['approved'] = 1;

					$row = new hwdvids_groupmember($db);

					// bind it to the table
					if (!$row -> bind($_POST)) {
						echo "<script> alert('"
							.$row -> getError()
							."'); window.history.go(-1); </script>\n";
						exit();
					}

					// store it in the db
					if (!$row -> store()) {
						echo "<script> alert('"
							.$row -> getError()
							."'); window.history.go(-1); </script>\n";
						exit();
					}
					$row->checkin();

					require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
					hwd_vs_recount::recountMembersInGroup($row->groupid);
				}
			}

			$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
			if ( file_exists($api_AUP))
			{
				require_once ($api_AUP);
				AlphaUserPointsHelper::newpoints( 'plgaup_addVideoGroup_hwdvs' );
			}

			if ($c->aag == 1) {
				$msg = _HWDVIDS_ALERT_GSAVED;
			} else {
				$msg = _HWDVIDS_ALERT_GPENDING;
			}
			$mainframe->enqueueMessage($msg);
			$mainframe->redirect( JURI::root() . 'index.php?option=com_hwdvideoshare&task=groups&Itemid='.$Itemid );
	}
Esempio n. 12
0
    /**
     * Grants or prevents access based on group id
     *
     * @param int    $accessgroupid  the group id to check against
     * @param string $recurse  the switch for recursive access check
     * @param int    $usersgroupid  the user's group id
     * @return       True or false
     */
	function backend()
	{
		global $smartyvs, $print_ulink, $print_glink, $hwdvsTemplateOverride;

		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = &JComponentHelper::getParams( 'com_users' );

		if (file_exists(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdphotoshare'.DS.'version.php'))
		{
			$smartyvs->assign("hwdIntegrate", 1);
		}
		else
		{
			$smartyvs->assign("hwdIntegrate", 0);
		}

		$smartyvs->assign("backEndCopyright", hwd_vs_templates::copyright_BE());
		$smartyvs->assign("mosConfig_live_site", JURI::root(true));
		$smartyvs->assign("mosConfig_absolute_path", JPATH_SITE);
		$smartyvs->assign("usershare1", $c->usershare1);
		$smartyvs->assign("usershare2", $c->usershare2);
		$smartyvs->assign("usershare3", $c->usershare3);
		$smartyvs->assign("usershare4", $c->usershare4);


		$hidemainmenu = JRequest::getInt( 'hidemainmenu', 0, 'request' );


		if ($hidemainmenu == 1) {
			$smartyvs->assign("hidemainmenu", 1);
		} else {
			$smartyvs->assign("hidemainmenu", 0);
		}





		$categoryselectlist = hwd_vs_tools::categoryList(_HWDVIDS_INFO_CHOOSECAT, 0, _HWDVIDS_INFO_NOCATS, 1);
		$smartyvs->assign("categoryselect", $categoryselectlist);

		if ($c->usershare1 == 1 || $c->usershare2 == 1 || $c->usershare3 == 1 || $c->usershare4 == 1) {
			$smartyvs->assign("print_sharing", 1);
		}

		if ($c->shareoption1 == 0)
		{
			$smartyvs->assign("so1p", "");
			$smartyvs->assign("so1r", " selected=\"selected\"");
			$smartyvs->assign("so1m", "");
			$smartyvs->assign("so1w", "");
			$smartyvs->assign("so1value", "registered");
		}
		else if ($c->shareoption1 == 1)
		{
			$smartyvs->assign("so1p", " selected=\"selected\"");
			$smartyvs->assign("so1r", "");
			$smartyvs->assign("so1m", "");
			$smartyvs->assign("so1w", "");
			$smartyvs->assign("so1value", "public");
		}
		else if ($c->shareoption1 == 2)
		{
			$smartyvs->assign("so1p", "");
			$smartyvs->assign("so1r", "");
			$smartyvs->assign("so1m", " selected=\"selected\"");
			$smartyvs->assign("so1w", "");
			$smartyvs->assign("so1value", "me");
		}
		else if ($c->shareoption1 == 3)
		{
			$smartyvs->assign("so1p", "");
			$smartyvs->assign("so1r", "");
			$smartyvs->assign("so1m", "");
			$smartyvs->assign("so1w", " selected=\"selected\"");
			$smartyvs->assign("so1value", "password");
		}

		if ($c->shareoption2 == 0)
		{
			$smartyvs->assign("so21", "");
			$smartyvs->assign("so20", " selected=\"selected\"");
			$smartyvs->assign("so2value", "0");
		}
		else if ($c->shareoption2 == 1)
		{
			$smartyvs->assign("so21", " selected=\"selected\"");
			$smartyvs->assign("so20", "");
			$smartyvs->assign("so2value", "1");
		}

		if ($c->shareoption3 == 0)
		{
			$smartyvs->assign("so31", "");
			$smartyvs->assign("so30", " selected=\"selected\"");
			$smartyvs->assign("so3value", "0");
		}
		else if ($c->shareoption3 == 1)
		{
			$smartyvs->assign("so31", " selected=\"selected\"");
			$smartyvs->assign("so30", "");
			$smartyvs->assign("so3value", "1");
		}

		if ($c->shareoption4 == 0)
		{
			$smartyvs->assign("so41", "");
			$smartyvs->assign("so40", " selected=\"selected\"");
			$smartyvs->assign("so4value", "0");
		}
		else if ($c->shareoption4 == 1)
		{
			$smartyvs->assign("so41", " selected=\"selected\"");
			$smartyvs->assign("so40", "");
			$smartyvs->assign("so4value", "1");
		}
	}
Esempio n. 13
0
	/**
	 * get_final_url()
	 * Gets the address that the URL ultimately leads to.
	 * Returns $url itself if it isn't a redirect.
	 *
	 * @param string $url
	 * @return string
	 */
	function getSelfURL(){
		$s = empty($_SERVER["HTTPS"]) ? ''
			: ($_SERVER["HTTPS"] == "on") ? "s"
			: "";
		$protocol = hwd_vs_tools::strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
		$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
			: (":".$_SERVER["SERVER_PORT"]);
		return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
	}
Esempio n. 14
0
	/**
	 *
	 *
	 *
	 */
	function checkAccess($gtree, $gtree_child, $nav, $usernav, $title, $message_register, $message_denied, $icon, $backlink, $action="core.frontend.access", $noMessage=0)
	{
		global $j15, $j16, $smartyvs;
        $c = hwd_vs_Config::get_instance();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = & JComponentHelper::getParams( 'com_users' );

		if ($j16)
		{
			// Access check.
			if (!JFactory::getUser()->authorise($action, 'com_hwdvideoshare'))
			{
				if ($noMessage == 1)
				{
					return false;
				}
				else
				{
					JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
					if ($my->id == 0)
					{
						$smartyvs->assign("showconnectionbox", 1);
					}
					hwd_vs_tools::infomessage($nav, $usernav, $title, $message_register, $icon, $backlink);
					return false;
				}
			}
		}
		else
		{
			if (!hwd_vs_access::allowAccess( $gtree, $gtree_child, hwd_vs_access::userGID( $my->id )))
			{
				if ( ($my->id < 1) && (!$usersConfig->get( 'allowUserRegistration' ) == '0' && hwd_vs_access::allowAccess( $c->gtree_upld, 'RECURSE', $acl->get_group_id('Registered','ARO') ) ) )
				{
					if ($noMessage == 1)
					{
						return false;
					}
					else
					{
						if ($my->id == 0)
						{
							$smartyvs->assign("showconnectionbox", 1);
						}
						hwd_vs_tools::infomessage($nav, $usernav, $title, $message_register, $icon, $backlink);
						return false;
					}
				}
				else
				{
					if ($noMessage == 1)
					{
						return false;
					}
					else
					{
						if ($my->id == 0)
						{
							$smartyvs->assign("showconnectionbox", 1);
						}
						hwd_vs_tools::infomessage($nav, $usernav, $title, $message_denied, $icon, $backlink);
						return false;
					}
				}
			}
		}
		return true;
	}
Esempio n. 15
0
    /**
     * Query SQL for all accessible category data
     *
     * @return       Nothing
     */
    function downloadFile()
    {
        global $mainframe, $limitstart;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = &JComponentHelper::getParams( 'com_users' );

		//$currentSession = JSession::getInstance('none',array());
		//$currentSession->destroy();

		$evp = JRequest::getCmd( 'evp', 0 );
		$file = JRequest::getCmd( 'file', 0 );
		$deliver = JRequest::getCmd( 'deliver', 0 );
		$media = JRequest::getCmd( 'media', 0 );
		$fix = JRequest::getCmd( 'fix', 0 );
		$streamer = JRequest::getCmd( 'streamer', 'off' );
		$quality = JRequest::getCmd( 'quality', 'hd' );
		$pushDownload = false;
		$showError = false;

		// get video details
		$db->SetQuery( 'SELECT * FROM #__hwdvidsvideos WHERE id = '.(int)$file );
		$db->Query();
		$row = $db->loadObject();

        $db->SetQuery( 'SELECT count(*) FROM #__hwdvidsantileech WHERE expiration = "'.$evp.'"' );
        $result = $db->loadResult();
		if ($result > 0 || $c->use_protection == 0 || $row->allow_embedding == "1")
		{
			$location = hwd_vs_tools::generateVideoLocations( $row, $quality );
			$location['ext'] = "flv";

			$db->SetQuery( 'SELECT `count` FROM #__hwdvidsantileech WHERE expiration = "'.$evp.'"' );
			$count = $db->loadResult();

			if ($row->allow_embedding == 1 && $c->showvebc == 1)
			{
				$pushDownload = true;
			}
			else if ($count < $c->protection_level)
			{
				$newCount = $count+1;
				$db->SetQuery( "UPDATE #__hwdvidsantileech SET `count` = $newCount WHERE expiration = \"".$evp."\"" );
				$db->Query();

				if ($deliver !== "player")
				{
					if (!hwd_vs_access::allowAccess( $c->gtree_dnld, $c->gtree_dnld_child, hwd_vs_access::userGID( $my->id )))
					{
						$pushDownload = false;
					}
					else
					{
						$pushDownload = true;
					}
				}
				else if ($deliver == "player")
				{
					$pushDownload = true;
				}
			}
			else
			{
				$showError = true;
			}

			if ($deliver == "downloadoriginal" || $deliver == "original")
			{
				if ($handle = opendir(JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS.'originals'))
				{
					$url = '';

					while (false !== ($file = readdir($handle)))
					{
						list($filename_noext, $filename_ext) = @split('\.', basename($file));

						if ($filename_noext == $row->video_id)
						{
							$location['url']  = JURI::root().'hwdvideos/uploads/originals/'.$file;
							$location['path'] = JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS.'originals'.DS.$file;
							$location['ext'] = $filename_ext;
						}
					}

					closedir($handle);
				}
			}
			else if ($deliver == "flv")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".flv"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".flv";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".flv";
					$location['ext'] = "flv";
				}
			}
			else if ($deliver == "h264")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".mp4"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".mp4";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".mp4";
					$location['ext'] = "mp4";
				}
			}
			else if ($deliver == "ipod340")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod320.mp4"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".ipod320.mp4";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod320.mp4";
					$location['ext'] = "ipod320.mp4";
				}
			}
			else if ($deliver == "ipod640")
			{
				if (file_exists(JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod640.mp4"))
				{
					$location['url']  = JURI::root()."hwdvideos/uploads/".$row->video_id.".ipod640.mp4";
					$location['path'] = JPATH_SITE.DS."hwdvideos".DS."uploads".DS.$row->video_id.".ipod320.mp4";
					$location['ext'] = "ipod640.mp4";
				}
			}

			if ($pushDownload)
			{
				if (headers_sent($filename, $linenum) || $row->video_type == "seyret" || $row->video_type == "remote")
				{
					$mainframe->redirect( $location['url'] );
				}
				else if ($deliver == "player")
				{
					header('Location: '.$location['url']);
					exit;
				}
				else
				{
					// Transfer file in chunks to preserve memory on the server
					$fn = basename($location['path']);

					$title = str_replace(" ", "-", $row->title);
					$title = preg_replace("/[^a-zA-Z0-9s-]/", "", $title);

					if (!empty($title)) {
						$ftitle = $title.".".$location['ext'];
					} else {
						$ftitle = $fn;
					}

					header('Content-Type: application/octet-stream');
					header("Content-Disposition: attachment; filename=\"$ftitle\"");
					header('Content-Length: '.filesize($location['path']));
					@hwd_vs_tools::readfile_chunked($location['path'], true);
					exit;
				}
			}
		}

		if ($count > $c->protection_level)
		{
			$db->SetQuery("DELETE FROM #__hwdvidsantileech WHERE expiration = \"$evp\"");
			$db->Query();
		}

		$showError = true;

		$hwdvsItemid = hwd_vs_tools::generateValidItemid();

		$msg = "You do not have access to this file using the requested method.";
		$mainframe->enqueueMessage($msg);
		$mainframe->redirect( JURI::root()."index.php?option=com_hwdvideoshare&Itemid=".$hwdvsItemid."&task=viewvideo&video_id=".$row->id );

    }
Esempio n. 16
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function addVideoToGroup()
	{
	global $database, $my, $acl, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $Itemid, $mosConfig_sitename;
		$db = & JFactory::getDBO();
		$c = hwd_vs_Config::get_instance();
		$url = $db->getEscaped( strip_tags( trim( strtolower( mosGetParam( $_POST, 'url' ) ) ) ) );

		if (!$my->id) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_LOG2AV2G, "exclamation.png", 1);
			return;
		}

		$userid = $my->id;
		$videoid = intval ( mosGetParam($_POST, 'videoid') );
		$groupid = intval ( mosGetParam($_POST, 'groupid') );
		$date = date('Y-m-d H:i:s');
		$published = 1;

		if ($groupid == 0) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERTSELGROUP, "exclamation.png", 1);
			return;
		}

		$where = ' WHERE a.videoid = '.$videoid;
		$where .= ' AND a.groupid = '.$groupid;

		$db->SetQuery( 'SELECT count(*)'
							. ' FROM #__hwdvidsgroup_videos AS a'
							. $where
							);
  		$total = $db->loadResult();

		if ( $total>0 ) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ALREADYAV2G, "exclamation.png", 1);
			return;
		}

		$row = new hwdvids_groupvideo($database);

		$_POST['videoid'] = $videoid;
		$_POST['groupid'] = $groupid;
		$_POST['memberid'] = $userid;
		$_POST['date'] = $date;

		// bind it to the table
		if (!$row -> bind($_POST)) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// store it in the db
		if (!$row -> store()) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// perform maintenance
		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
		hwd_vs_recount::recountVideosInGroup($groupid);

		hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_SUCAV2G, "exclamation.png", 1);
		return;
	}
Esempio n. 17
0
   /**
	* edit videos
	*/
	function updateVideoSource()
	{
		global $option;
  		$db =& JFactory::getDBO();
		$my = & JFactory::getUser();
		$app = & JFactory::getApplication();
		$c = hwd_vs_Config::get_instance();

		$video_type	= Jrequest::getVar( 'videotype', '0' );
		$video_id	= Jrequest::getVar( 'id', '0' );
		$updatedetails	= Jrequest::getVar( 'updatedetails', '0' );

		$admin_import = true;
		require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'models'.DS.'uploads.php');

		$row = new hwdvids_video($db);
		$row->load( $video_id );

		if ($video_type == 1)
		{
			$requestarray = JRequest::get( 'default', 2 );
			$embeddump = $requestarray['embeddump'];
			$remote_verified = null;

			$parsedurl = parse_url($embeddump);
			if (empty($parsedurl['host'])) { $parsedurl['host'] = ''; }
			preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $parsedurl['host'], $regs);
			if (empty($regs['domain'])) { $regs['domain'] = ''; }

			if ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/youtube.php')) {
				require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/youtube.php');
			} else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/google.php')) {
				require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/google.php');
			} else if (file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/'.$regs['domain'].'.php')) {
				require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/'.$regs['domain'].'.php');
			} else {

				$pos_flv = strpos($embeddump, ".flv");

				if ($pos_flv === false) {
					$remote_verified = 0;
				} else {
					$pos_flv = $pos_flv+4;
					$datadump = substr($embeddump, 0, $pos_flv);
					$pos_http = mb_strrpos($datadump, "http://");
					if ($pos_http === false) {
						$error_msg = _HWDVIDS_ERROR_UPLDERR11."<br /><br />"._HWDVIDS_INFO_SUPPTPW."<br />".hwd_vs_tools::generateSupportedWebsiteList();
						hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, $error_msg, "exclamation.png", 1);
						return;
					} else {
						$url = substr($datadump, $pos_http);
					}

					$pru = parse_url($url);
					$remoteurl = $pru['scheme']."://".$pru['host'].$pru['path'];

					if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",$remoteurl)) {
						$remote_verified = 0;
					} else {
						$filegrab = @file_get_contents($remoteurl, null, null, 0, 16);
						$filecheck = @strpos($remoteurl, "flv");
						if (isset($remoteurl) && !empty($remoteurl) && $filecheck !== false) {
							$remote_verified = 1;
						} else {
							$remote_verified = 0;
						}
					}
				}

			}

			$failures = "";
			if (!isset($remote_verified)) {
				$cn = 'hwd_vs_tp_'.preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']);
				$f_processc = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processCode';
				$f_processt = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processTitle';
				$f_processd = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDescription';
				$f_processk = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processKeywords';
				$f_processl = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDuration';

				$tp = new $cn();

				$ext_v_code  = $tp->$f_processc($embeddump);
				$ext_v_title = $tp->$f_processt($embeddump, @$ext_v_code[2]);
				$ext_v_descr = $tp->$f_processd($embeddump, @$ext_v_code[2]);
				$ext_v_keywo = $tp->$f_processk($embeddump, @$ext_v_code[2]);
				$ext_v_durat = $tp->$f_processl($embeddump, @$ext_v_code[2]);

				if ($ext_v_code[0] == "0") {
					hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_INFO_TPPROCESSFAIL, "exclamation.png", 0);
					return;
				}

				if ($ext_v_title[0] == 0) {$failures.=_HWDVIDS_INFO_TPTITLEFAIL."<br />";}
				if ($ext_v_descr[0] == 0) {$failures.=_HWDVIDS_INFO_TPDESCFAIL."<br />";}
				if ($ext_v_keywo[0] == 0) {$failures.=_HWDVIDS_INFO_TPKWFAIL."<br />";}
				if ($ext_v_durat[0] == 0) {$failures.=_HWDVIDS_INFO_TPDRFAIL."<br />";}
			} else if ($remote_verified == 0) {
				$error_msg = _HWDVIDS_ERROR_UPLDERR11."<br /><br />"._HWDVIDS_INFO_SUPPTPW."<br />".hwd_vs_tools::generateSupportedWebsiteList();
				hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, $error_msg, "exclamation.png", 1);
				return;
			} else if ($remote_verified == 1) {
				$ext_v_code[1] = $remoteurl.",";
				$ext_v_title[1] = _HWDVIDS_UNKNOWN;
				$ext_v_descr[1] = _HWDVIDS_UNKNOWN;
				$ext_v_keywo[1] = _HWDVIDS_UNKNOWN;
				$ext_v_durat[1] = "0:00:00";
				$regs['domain'] = "remote";
			}

			//check if already exists
			$db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' );
			$duplicatecount = $db->loadResult();

			$admin_import = false;

			if ($duplicatecount > 0 && $admin_import == false) {
				hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0);
				return;
			} else if ($duplicatecount > 0 && $admin_import == true) {
				return false;
			}

			$title = $ext_v_title[1];
			$title = stripslashes($title);
			$title = stripslashes($title);
			$title = hwdEncoding::charset_decode_utf_8($title);
			$title = hwdEncoding::charset_encode_utf_8($title);
			$title = htmlspecialchars_decode($title);
			$title = addslashes($title);

			$description = $ext_v_descr[1];
			$description = stripslashes($description);
			$description = stripslashes($description);
			$description = hwdEncoding::charset_decode_utf_8($description);
			$description = hwdEncoding::charset_encode_utf_8($description);
			$description = htmlspecialchars_decode($description);
			$description = addslashes($description);

			$raw_tags = $ext_v_keywo[1];
			$tags = '';
			$tag_arr_co = explode(",", $raw_tags);

			for ($j=0, $m=count($tag_arr_co); $j < $m; $j++) {

				$row_co = $tag_arr_co[$j];
				$tag_arr_sp = explode(" ", $row_co);

				for ($k=0, $p=count($tag_arr_sp); $k < $p; $k++) {

					$row_sp = $tag_arr_sp[$k];
					$row_sp = hwdEncoding::charset_decode_utf_8($row_sp);
					$row_sp = preg_replace("/[^a-zA-Z0-9s_&#;-]/", "", $row_sp);
					$row_sp = hwdEncoding::charset_encode_utf_8($row_sp);

					if (!empty($row_sp)) {
						$tags.= $row_sp.",";
					}

				}
			}
			if (substr($tags, -2) == ", ") {$tags = substr($tags, 0, -2);}

			if (empty($title)) { $title = _HWDVIDS_UNKNOWN;}
			if (empty($description)) { $description = _HWDVIDS_UNKNOWN;}
			if (empty($tags)) { $tags = _HWDVIDS_UNKNOWN;}

			$_POST['video_type'] 		= $regs['domain'];
			$_POST['video_id'] 			= $ext_v_code[1];

			if ($updatedetails == "on") {
				$_POST['title'] 			= $ext_v_title[1];
				$_POST['description'] 		= $ext_v_descr[1];
				$_POST['tags'] 				= $ext_v_keywo[1];
			}

			// bind it to the table
			if (!$row -> bind($_POST)) {
				echo "<script> alert('"
					.$row -> getError()
					."'); window.history.go(-1); </script>\n";
				exit();
			}

			// store it in the db
			if (!$row -> store()) {
				echo "<script> alert('"
					.$row -> getError()
					."'); window.history.go(-1); </script>\n";
				exit();
			}

			$row->checkin();

		}
		else if ($video_type == 2)
		{
			$data = explode(",", $row->video_id);
			$thumbnail = @$data[1];

			$requestarray = JRequest::get( 'default', 2 );
			$videourl = $requestarray['embeddump'];

			$validated_video_url = hwd_vs_tools::validateUrl($videourl);

			if (empty($validated_video_url))
			{
				$msg = _HWDVIDS_ALERT_VURLWRONG;
				$app->enqueueMessage($msg);
				$app->redirect(JURI::root( true )."/administrator/index.php?option=com_hwdvideoshare&task=editvidsA&hidemainmenu=1&cid=".$row->id);
			}

			$new_video_id = $validated_video_url.",".$thumbnail;

			$_POST['video_type'] 		= "remote";
			$_POST['video_id'] 			= $new_video_id;
			if (empty($row->thumbnail) && !empty($thumbnail))
			{
				$_POST['thumbnail'] 	= $thumbnail;
			}

			// bind it to the table
			if (!$row->bind($_POST))
			{
				echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
				exit();
			}

			// store it in the db
			if (!$row->store())
			{
				echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
				exit();
			}
			$row->checkin();
		}
		else if ($video_type == 3)
		{
			$data = explode(",", $row->video_id);
			$thumbnail = @$data[1];

			$requestarray = JRequest::get( 'default', 2 );
			$rtmpurl = $requestarray['embeddump'];
			$validated_rtmpurl = hwd_vs_tools::validateUrl($rtmpurl);

			if (empty($validated_rtmpurl))
			{
				$msg = _HWDVIDS_ALERT_VURLWRONG;
				$app->enqueueMessage($msg);
				$app->redirect(JURI::root( true )."/administrator/index.php?option=com_hwdvideoshare&task=editvidsA&hidemainmenu=1&cid=".$row->id);
			}

			$new_video_id = $validated_rtmpurl;

			$_POST['video_type'] 		= "rtmp";
			$_POST['video_id'] 			= $new_video_id;
			if (empty($row->thumbnail) && !empty($thumbnail))
			{
				$_POST['thumbnail'] 	= $thumbnail;
			}

			// bind it to the table
			if (!$row->bind($_POST))
			{
				echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
				exit();
			}

			// store it in the db
			if (!$row->store())
			{
				echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
				exit();
			}
			$row->checkin();
		}

		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
		hwd_vs_recount::recountVideosInCategory($row->category_id);

		$app->enqueueMessage(_HWDVIDS_ALERT_VIDSAVED);
		$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=editvidsA&hidemainmenu=1&cid='.$row->id );
	}
Esempio n. 18
0
   /**
	* view the plugin page
	*/
	function insertVideo()
	{
		global $limitstart;
		$eName	= JRequest::getVar('e_name');
		$eName	= preg_replace( '#[^A-Z0-9\-\_\[\]]#i', '', $eName );

		$db =& JFactory::getDBO();
		$my = & JFactory::getUser();
		$doc = & JFactory::getDocument();
		$doc->addStyleSheet( JURI::root().'plugins/editors-xtd/plug_hwd_vs_insertvideo.css', 'text/css', null, array() );

		$query = 'SELECT count(*) FROM #__hwdvidsvideos';
		$db->SetQuery($query);
		$total = $db->loadResult();

		$limit = 10;
		jimport('joomla.html.pagination');
		$pageNav = new JPagination( $total, $limitstart, $limit );

		// get matching video data
		$query = 'SELECT * FROM #__hwdvidsvideos ORDER BY date_uploaded DESC';
        $db->SetQuery($query, $pageNav->limitstart, $pageNav->limit);
		$rows = $db->loadObjectList();

		?>
		<script type="text/javascript">
			function insertVideo()
			{
				var video_style = document.getElementById("style").value;
				var video_id = document.getElementById("video_id").value;
				var video_width = document.getElementById("video_width").value;
				var video_height = document.getElementById("video_height").value;

				if (video_style == "videoPlayerWithDetails")
				  {
				  var tag = "\{hwdvs-player\}id="+video_id+"|width="+video_width+"|height="+video_height+"\{/hwdvs-player\}";
				  }
				else if (video_style == "videoPlayerOnly")
				  {
				  var tag = "\{hwdvs-player\}id="+video_id+"|width="+video_width+"|height="+video_height+"|tpl=playeronly\{/hwdvs-player\}";
				  }
				else if (video_style == "videoThumbnailLightbox")
				  {
				  var tag = "\{hwdvs-player\}id="+video_id+"|width="+video_width+"|height="+video_height+"|tpl=lightbox\{/hwdvs-player\}";
				  }
				window.parent.jInsertEditorText(tag, '<?php echo $eName; ?>');
				window.parent.document.getElementById('sbox-window').close();
				return false;
			}
			function insertVideoID(id)
			{
				document.getElementById('videoId').innerHTML = '<input type="text" id="video_id" value="'+id+'" name="video_id" />';
				return false;
			}
		</script>

		<table width="100%" cellpadding="2" cellspacing="2" border="0">
			<tr>
				<td width="150" style="vertical-align:top;width:150px;">
					<form>
					<table cellpadding="2" cellspacing="2" border="0">
						<tr>
							<td class="key">
								<label for="title">
									<?php echo JText::_( 'Style' ); ?>
								</label>
								<br />
								<select name="style" id="style">
									<option value="videoPlayerWithDetails">Video player (with details)</option>
									<option value="videoPlayerOnly">Video player (player only)</option>
									<option value="videoThumbnailLightbox">Video thumbnail (lightbox)</option>
								</select>
							</td>
						</tr>
						<tr>
							<td class="key">
								<label for="title">
									<?php echo JText::_( 'Video ID' ); ?>
								</label>
								<br />
								<div id="videoId"><input type="text" id="video_id" name="video_id" /></div>
							</td>
						</tr>
						<tr>
							<td class="key">
								<label for="alias">
									<?php echo JText::_( 'Video Width' ); ?>
								</label>
								<br />
								<input type="text" id="video_width" name="video_width" value="560" />
							</td>
						</tr>
						<tr>
							<td class="key">
								<label for="alias">
									<?php echo JText::_( 'Video Height' ); ?>
								</label>
								<br />
								<input type="text" id="video_height" name="video_height" value="340" />
							</td>
						</tr>
						<tr>
							<td>
								<button onclick="insertVideo();return false;"><?php echo JText::_( 'Insert Video' ); ?></button>
							</td>
						</tr>
					</table>
					</form>
				</td>
				<td>
				<div style="height:270px;overflow-y:scroll;">
				<?php
					for ($i=0, $n=count($rows); $i < $n; $i++)
					{
						$row = $rows[$i];

						$title     = hwd_vs_tools::generateVideoLink( $row->id, $row->title, null, "insertVideoID", 1000);
						$thumbnail = hwd_vs_tools::generateVideoThumbnailLink($row->id, $row->video_id, $row->video_type, $row->thumbnail, 0, "70", null, null, null, null, "insertVideoID", null, null, $row->video_length);

						echo "<div style=\"float:left;padding:0 5px 5px 0;\">$thumbnail</div>";
						echo "<div>$title</div>";
						echo "<div style=\"clear:both;\"></div>";
					}
				?>
				</div>
				</td>
			</tr>
		</table>
		<?php
	}
Esempio n. 19
0
    /**
     *
     */
    function pending($rows, $pageNav, $total)
    {
		global $smartyvs, $Itemid, $mainframe;
		$c = hwd_vs_Config::get_instance();

		// load the menu name
		jimport( 'joomla.application.menu' );
		$menu   = &JMenu::getInstance('site');
		$mparams = &$menu->getParams($Itemid);
		$mparams_pt	= $mparams->get( 'page_title', '');

		jimport( 'joomla.document.document' );
		$doc = & JFactory::getDocument();

		$active = &$menu->getActive();

		if (!empty($mparams_pt)) {
			$metatitle = $mparams_pt;
		} else if (!empty($active->name)) {
			$metatitle = $active->name;
		} else {
			$metatitle = _HWDVIDS_META_DEFAULT;
		}

		// set the page/meta title
		$doc->setTitle( $metatitle." - "._HWDVIDS_META_YVIDS );
		$doc->setMetaData( 'title' , $metatitle." - "._HWDVIDS_META_YVIDS );
		hwd_vs_tools::generateActiveLink(1);
		hwd_vs_tools::generateBreadcrumbs();

		if (count($rows) > 0) {
			$smartyvs->assign("print_videolist", 1);
			$list = hwd_vs_tools::generateVideoListFromSql($rows);
			$smartyvs->assign("list", $list);
		}

		$page = $total - $c->vpp;
		$pageNavigation = null;
		if ( $page > 0 ) {
			$link = "index.php?option=com_hwdvideoshare&task=yourvids&Itemid=".$Itemid;
			$pageNavigation.= $pageNav->getPagesLinks($link)."<br />";
			$pageNavigation.= $pageNav->getPagesCounter();
		}
		$smartyvs->assign("pageNavigation", $pageNavigation);

		$smartyvs->display('video_pending.tpl');
		return;
    }
Esempio n. 20
0
   /**
    * Save editted video details
    */
	function saveVideoInfo()
	{
		global $Itemid, $mainframe;
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$c = hwd_vs_Config::get_instance();
		$app = & JFactory::getApplication();

		$row = new hwdvids_video($db);

		$uid = JRequest::getInt( 'owner', 0, 'post' );
		$rowid = JRequest::getInt( 'id', 0, 'post' );
		$referrer = JRequest::getVar( 'referrer', JURI::root( true ) . '/index.php?option=com_hwdvideoshare&Itemid='.$Itemid );

		// check component access settings and deny those without privileges
		if (!hwd_vs_access::allowAccess( $c->gtree_mdrt, $c->gtree_mdrt_child, hwd_vs_access::userGID( $my->id ))) {
			if ($my->id == $uid) {
				if ($my->id == "0") {
					$app->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
					$app->redirect( $referrer );
				}
				if ($c->allowvidedit == "0") {
					$app->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
					$app->redirect( $referrer );
				}
				// continue
			} else {
				$app->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
				$app->redirect( $referrer );
			}
		}

		$row->load( $rowid );
		$old_category = $row->category_id;

		$file_name_org   = $_FILES['thumbnail_file']['name'];
		$file_ext        = substr($file_name_org, strrpos($file_name_org, '.') + 1);

		$thumbnail = '';
		if ($_FILES['thumbnail_file']['tmp_name'] !== "") {

			if ($row->video_type == "local" || $row->video_type == "swf" || $row->video_type == "mp4")
			{
				$videocode = $row->video_id;
				$thumbnail = $file_ext;
			}
			else
			{
				$videocode = "tp-".$row->id;
				$thumbnail = "tp-".$row->id.".".$file_ext;
			}

			$base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS;
			$upload_result = hwd_vs_tools::uploadFile("thumbnail_file", $videocode, $base_Dir, 2, "jpg,jpeg", 1);

			if ($upload_result[0] == "0")
			{
				$msg = $upload_result[1];
				$app->enqueueMessage($msg);
				$app->redirect( JURI::root( true ) . '/index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editvideo&video_id='.$row->id );
			}
			else
			{
				require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'thumbnail.inc.php');

				$thumb_path_s = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.$videocode.'.'.$file_ext;
				$thumb_path_l = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.'l_'.$videocode.'.'.$file_ext;

				$twidth_s = round($c->con_thumb_n);
				$theight_s = round($c->con_thumb_n*$c->tar_fb);
				$twidth_l = round($c->con_thumb_l);
				$theight_l = round($c->con_thumb_l*$c->tar_fb);

				list($width, $height, $type, $attr) = @getimagesize($thumb_path_s);
				$ratio = $width/$height;

				//echo $thumb_path_s."<br />".$ratio."<br />".$width."<br />".$height."<br />".$c->tar_fb."<br />".$twidth_s."<br />".$theight_s;

				if ($ratio > 1)
				{
					$resized_l = new Thumbnail($thumb_path_s);
					$resized_l->resize($twidth_l,$twidth_l);
					$resized_l->cropFromCenter($twidth_l, $theight_l);
					$resized_l->save($thumb_path_l);
					$resized_l->destruct();

					$resized_s = new Thumbnail($thumb_path_s);
					$resized_s->resize($twidth_s,$twidth_s);
					$resized_s->cropFromCenter($twidth_s, $theight_s);
					$resized_s->save($thumb_path_s);
					$resized_s->destruct();
				}
				else
				{
					$resized_l = new Thumbnail($thumb_path_s);
					$resized_l->resize($twidth_l,2000);
					$resized_l->cropFromCenter($twidth_l, $theight_l);
					$resized_l->save($thumb_path_l);
					$resized_l->destruct();

					$resized_s = new Thumbnail($thumb_path_s);
					$resized_s->resize($twidth_s,1000);
					$resized_s->cropFromCenter($twidth_s, $theight_s);
					$resized_s->save($thumb_path_s);
					$resized_s->destruct();
				}
			}
		}
		else
		{
			//echo "No thumbnail uploaded";
		}

		$title = hwd_vs_tools::generatePostTitle();
		$description = hwd_vs_tools::generatePostDescription();
		$tags = hwd_vs_tools::generatePostTags();

		$password = Jrequest::getVar( 'hwdvspassword', '' );
		if (!empty($password))
		{
			$password = md5($password);
			$_POST['password'] 		= $password;
		}

		$_POST['id'] 				= $rowid;
		$_POST['title'] 			= $title;
		$_POST['description'] 		= $description;
		$_POST['category_id'] 		= JRequest::getInt( 'category_id', 0 );
		$_POST['tags'] 				= $tags;
		if (!empty($thumbnail))
		{
			$_POST['thumbnail'] 	= $thumbnail;
		}

		// bind it to the table
		if (!$row->bind($_POST))
		{
			echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
			exit();
		}

		// Make sure the record is valid
   		if (!$row->check())
   		{
        	$this->setError($this->_db->getErrorMsg());
			echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
			exit();
    	}

		// store it in the db
		if (!$row->store())
		{
			echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n";
			exit();
		}

		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
		hwd_vs_recount::recountVideosInCategory($row->category_id);
		hwd_vs_recount::recountVideosInCategory($old_category_id);

		$msg = _HWDVIDS_ALERT_VIDEDITSAVED;
		$app->enqueueMessage($msg);
		$app->redirect( $referrer );
	}
    /**
     * Outputs frontpage HTML
     *
     * @param string $option  the joomla component name
     * @param array  $rows  array of video data
     * @param array  $rowsfeatured  array of featured video data
     * @param object $pageNav  page navigation object
     * @param int    $total  the total video count
     * @return       Nothing
     */
	function recountVideosInCategory($catid=null) {
		$db = & JFactory::getDBO();
		$c = hwd_vs_Config::get_instance();

        if (isset($catid)) {
			$rows[0]->id = $catid;
        } else {
        	// get all categories
			$query = 'SELECT id'
					. ' FROM #__hwdvidscategories'
					;
			$db->SetQuery($query);
			$rows = $db->loadObjectList();
		}

		for ($i=0, $n=count($rows); $i < $n; $i++) {
			$row = $rows[$i];

			if ($c->countcvids == 1) {
				$cids = hwd_vs_tools::getChildCategories($row->id);
				$where = ' WHERE category_id IN ('.$cids.')';
			} else {
				$where = ' WHERE category_id = '.$row->id;
			}

			// count videos in category
			$query = 'SELECT count(*)'
					. ' FROM #__hwdvidsvideos'
					. $where
					. ' AND published = 1'
					. ' AND approved = "yes"'
					;
			$db->SetQuery($query);
			$total = $db->loadResult();

			// update category
			$db->SetQuery("UPDATE #__hwdvidscategories SET num_vids = $total WHERE id = $row->id");
			$db->Query();
			if ( !$db->query() ) {
				echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
				exit();
			}
		}

		return true;
    }
   /**
	* export
	*/
	function importdata()
	{
		global $smartyvs;
		$db = & JFactory::getDBO();

		$hidden_inputs = '<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="option" value="com_hwdvideoshare" />
		<input type="hidden" name="task" value="botJombackup" />
		<input type="hidden" name="hidemainmenu" value="0">';
		jimport('joomla.html.pane');
		$pane =& JPane::getInstance('tabs');
		$startpane = $pane->startPane( 'video-pane' );
		$endtab = $pane->endPanel();
		$endpane = $pane->endPane();
		$starttab1 = $pane->startPanel( _HWDVIDS_TAB_FTP, 'panel1' );
		$starttab2 = $pane->startPanel( _HWDVIDS_TAB_REMOTE, 'panel2' );
		$starttab3 = $pane->startPanel( _HWDVIDS_TAB_SQL, 'panel3' );
		$starttab4 = $pane->startPanel( _HWDVIDS_TAB_CSV, 'panel4' );
		$starttab5 = $pane->startPanel( _HWDVIDS_TAB_SEYRET, 'panel5' );
		$starttab6 = $pane->startPanel( _HWDVIDS_TAB_TPV, 'panel6' );
		$starttab7 = $pane->startPanel( _HWDVIDS_TAB_PHPM, 'panel7' );
		$starttab8 = $pane->startPanel( _HWDVIDS_TAB_SCAN, 'panel8' );
		$starttab9 = $pane->startPanel( _HWDVIDS_TAB_RTMP, 'panel9' );
		$starttab10= $pane->startPanel( "JomSocial", 'panel10' );

		/** assign template variables **/
		$smartyvs->assign( "hidden_inputs", $hidden_inputs );
		$smartyvs->assign( "header_title", _HWDVIDS_SECTIONHEAD_IMPORT );
		$smartyvs->assign( "startpane", $startpane );
		$smartyvs->assign( "endtab", $endtab );
		$smartyvs->assign( "endpane", $endpane );
		$smartyvs->assign( "starttab1", $starttab1 );
		$smartyvs->assign( "starttab2", $starttab2 );
		$smartyvs->assign( "starttab3", $starttab3 );
		$smartyvs->assign( "starttab4", $starttab4 );
		$smartyvs->assign( "starttab5", $starttab5 );
		$smartyvs->assign( "starttab6", $starttab6 );
		$smartyvs->assign( "starttab7", $starttab7 );
		$smartyvs->assign( "starttab8", $starttab8 );
		$smartyvs->assign( "starttab9", $starttab9 );
		$smartyvs->assign( "starttab10",$starttab10 );
		$smartyvs->assign( "newvideoid", hwd_vs_tools::generateNewVideoid() );

		if (file_exists(JPATH_SITE.DS.'components'.DS.'com_seyret'.DS))
		{
			$smartyvs->assign( "seyretinstalled", 1 );

			$db->SetQuery( 'SELECT count(*) FROM #__seyret_items' );
			$seyretitems1 = $db->loadResult();

			if ($seyretitems1 == 0)
			{
				$db->SetQuery( 'SELECT count(*) FROM #__seyret_video' );
				$seyretitems2 = $db->loadResult();
			}

			if ($seyretitems1 == 0 && $seyretitems2 == 0)
			{
				$smartyvs->assign( "seyretinstalled", 0 );
			}
			else if ($seyretitems1 > 0)
			{
				$smartyvs->assign( "seyretitems", $seyretitems1 );
				//get seyret categories
				$db->setQuery( "SELECT `id` AS `key`, `categoryname` AS `text` FROM #__seyret_categories ORDER BY categoryname" );
				$rows_seyret = $db->loadObjectList();
			}
			else if ($seyretitems2 > 0)
			{
				$smartyvs->assign( "seyretitems", $seyretitems2 );
				//get seyret categories
				$db->setQuery( "SELECT `id` AS `key`, `categoryname` AS `text` FROM #__seyret_category ORDER BY categoryname" );
				$rows_seyret = $db->loadObjectList();
			}

			$n = count($rows_seyret);
			$rows_seyret[$n]->key = "-1";
			$rows_seyret[$n]->text = "All Categories";

			$seyretcatsel = JHTML::_('select.genericlist', $rows_seyret, 'seyretcid', 'class="inputbox" size="1"', 'key', 'text', -1);

			$smartyvs->assign( "seyretcatsel", $seyretcatsel );
		}
		if (file_exists(JPATH_SITE.DS.'components'.DS.'com_community'.DS))
		{
			$smartyvs->assign( "jomsocialinstalled", 1 );

			$db->SetQuery( 'SELECT count(*) FROM #__community_videos' );
			$jomsocialitems = $db->loadResult();

			$smartyvs->assign( "jomsocialitems", $jomsocialitems );

			$db->setQuery( "SELECT `id` AS `key`, `name` AS `text` FROM #__community_videos_category ORDER BY name" );
			$rows_jsvc = $db->loadObjectList();

			$n = count($rows_seyret);
			$rows_jsvc[$n]->key = "-1";
			$rows_jsvc[$n]->text = "All Categories";

			$jsvcSelect = JHTML::_('select.genericlist', $rows_jsvc, 'jsvcid', 'class="inputbox" size="1"', 'key', 'text', -1);

			$smartyvs->assign( "jsvcSelect", $jsvcSelect );
		}
		if (file_exists(JPATH_SITE.DS.'components'.DS.'com_achtube'.DS))
		{
			$smartyvs->assign( "achtubeinstalled", 1 );
		}

		$smartyvs->display('admin_import.tpl');
		return;
	}
Esempio n. 23
0
    /**
     * Outputs frontpage HTML
     *
     * @param string $option  the joomla component name
     * @param array  $rows  array of video data
     * @param array  $rowsfeatured  array of featured video data
     * @param object $pageNav  page navigation object
     * @param int    $total  the total video count
     * @return       Nothing
     */
    function updateChannel()
	{
		global $Itemid, $mainframe;
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$c = hwd_vs_Config::get_instance();

		$id = JRequest::getInt( 'id', 0 );
		$row = new hwdvids_channel($db);
		$row->load( $id );

		if ($row->user_id != $my->id)
		{
			$mainframe->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
			$mainframe->redirect( JRoute::_("index.php?option=com_hwdvideoshare&Itemid=$Itemid&task=channels") );
		}

		$channel_description  = Jrequest::getVar( 'channel_description', _HWDVS_UNKNOWN );

		$_POST['channel_description'] = $channel_description;

		$file_name_org   = $_FILES['thumbnail_file']['name'];
		$file_ext        = substr($file_name_org, strrpos($file_name_org, '.') + 1);

		$thumbnail = '';
		if ($_FILES['thumbnail_file']['tmp_name'] !== "")
		{
			$videocode = "ch-".$row->id;

			$base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS;
			$upload_result = hwd_vs_tools::uploadFile("thumbnail_file", $videocode, $base_Dir, 2, "jpg,jpeg,png,gif", 1);

			if ($upload_result[0] == "0")
			{
				$msg = $upload_result[1];
				$mainframe->enqueueMessage($msg);
				$mainframe->redirect( JURI::root( true ) . '/index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editvideo&video_id='.$row->id );
			}
			else
			{
				require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'thumbnail.inc.php');

				$thumb_path = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.$videocode.'.'.$file_ext;

				$twidth_s = round($c->con_thumb_n);
				$theight_s = round($c->con_thumb_n*$c->tar_fb);

				list($width, $height, $type, $attr) = @getimagesize($thumb_path);
				$ratio = $width/$height;

				//echo $thumb_path."<br />".$ratio."<br />".$width."<br />".$height."<br />".$c->tar_fb."<br />".$twidth_s."<br />".$theight_s;

				if ($ratio > 1)
				{
					$resized = new Thumbnail($thumb_path);
					$resized->resize($twidth_s,$twidth_s);
					$resized->cropFromCenter($twidth_s, $theight_s);
					$resized->save($thumb_path);
					$resized->destruct();
				}
				else
				{
					$resized = new Thumbnail($thumb_path);
					$resized->resize($twidth_s,1000);
					$resized->cropFromCenter($twidth_s, $theight_s);
					$resized->save($thumb_path);
					$resized->destruct();
				}
			}
			$_POST['channel_thumbnail'] = $videocode.'.'.$file_ext;
		}
		else
		{
			//echo "No thumbnail uploaded";
		}

		// bind it to the table
		if (!$row -> bind($_POST)) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// store it in the db
		if (!$row -> store()) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		$msg = "Channel saved";
		$mainframe->enqueueMessage($msg);
		$mainframe->redirect( JRoute::_("index.php?option=com_hwdvideoshare&Itemid=$Itemid&task=viewchannel&user_id=$my->id") );
	}