Esempio n. 1
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;
	}
Esempio n. 2
0
	/**
	* Import Data
	*/
	function jomsocialImport()
	{
		global $Itemid, $option;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$app = & JFactory::getApplication();

		$jsvcid = JRequest::getInt( 'jsvcid', -1 );
		$category_id = JRequest::getInt( 'category_id', 0 );
		$counter = 0;
		$admin_import = true;
		require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'models'.DS.'uploads.php');

		$where = " WHERE type = \"youtube\"";
		if (!empty($jsvcid) && ($jsvcid !== -1))
		{
			$where.= " AND category_id = $jsvcid";
		}

		$db->setQuery( "SELECT * FROM #__community_videos".$where );
		if ( !$db->query() )
		{
			echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
			exit();
		}
		$rows_js = $db->loadObjectList();

		$_REQUEST['category_id'] 	 = $category_id;
		$_REQUEST['public_private']  = "public";
		$_REQUEST['allow_comments']  = $_POST['allow_comments'] = $c->shareoption2;
		$_REQUEST['allow_embedding'] = $_POST['allow_embedding'] = $c->shareoption3;
		$_REQUEST['allow_ratings'] 	 = $_POST['allow_ratings'] = $c->shareoption4;
		$_REQUEST['allow_ratings'] 	 = $_POST['allow_ratings'] = $c->shareoption4;

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

			$_REQUEST['video_length'] = hwd_vs_tools::sec2hms($row_js->duration);
			$_REQUEST['user_id'] = intval($row_js->creator);

			unset ($_REQUEST['embeddump']);
			$_REQUEST['embeddump'] = "http://www.youtube.com/watch?v=".$row_js->video_id;

			if (hwd_vs_uploads::addConfirm($option, $admin_import))
			{
				$counter++;
			}
		}

		$msg = "Successully imported ".$counter." videos";
		$app->enqueueMessage($msg);
		$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=import' );
	}
    /**
     * 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;
    }