/**
     * 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 initiate($override) {

		global $mainframe;

		// set cache variables
		$cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root)
		$cachetime = 86400; // Seconds to cache files for
		$cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt)
		$page = 'http://fixerrorfile'; // Requested page
		$cachefile = $cachedir . md5($page) . '.' . $cacheext; // Cache file to either load or create

		$cachefile_created = (@file_exists($cachefile)) ? @filemtime($cachefile) : 0;
		@clearstatcache();

		if ($override == 2) {
			// Show file from cache if still valid
			if (time() - $cachetime < $cachefile_created) {
				$mainframe->enqueueMessage(_HWDVIDS_M_FIX_RUN);
				return;
			}
		}

		 // Now the script has run, generate a new cache file
		$fp = @fopen($cachefile, 'w');

		// save the contents of output buffer to the file
		@fwrite($fp, ob_get_contents());
		@fclose($fp);

		hwd_vs_fixerrors::fixVideoDataFormat();
		hwd_vs_fixerrors::cleanAntileech();

		return true;
	}
Пример #2
0
   /**
	* system cleanup
	*/
	function runmaintenance()
	{
		global $limit, $limitstart;
  		$db =& JFactory::getDBO();

		$run_permdel = JRequest::getInt( 'run_permdel', 0 );
		$run_fixerrors = JRequest::getInt( 'run_fixerrors', 0 );
		$run_recount = JRequest::getInt( 'run_recount', 0 );
		$run_archivelogs = JRequest::getInt( 'run_archivelogs', 0 );

		$permdelete_report = null;
		$fixerrors_report = null;
		$recount_report = null;
		$archivelogs_report = null;

		if ($run_permdel == 1) {
			// permenantly delete
			$query = "SELECT a.*"
					. "\nFROM #__hwdvidsvideos AS a"
					. "\nWHERE a.approved = \"deleted\""
								;
			$db->SetQuery( $query );
			$rows = $db->loadObjectList();

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

				$files   = array();
				$files[] = JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".flv";
				$files[] = JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".mp4";
				$files[] = JPATH_SITE."/hwdvideos/thumbs/".$row->video_id.".jpg";
				$files[] = JPATH_SITE."/hwdvideos/thumbs/".$row->video_id.".gif";
				$files[] = JPATH_SITE."/hwdvideos/thumbs/l_".$row->video_id.".jpg";

				for($j=0, $m=count( $files ); $j < $m; $j++)
				{
					$file = &$files[$j];

					if (@file_exists($file))
					{
						@unlink($file);
					}
				}
			}

			$db->SetQuery("DELETE FROM #__hwdvidsvideos WHERE approved = \"deleted\"");
			$db->Query();
			if ( !$db->query() ) {
				echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
				exit();
			}
			$permdelete_report = true;
		}

		if ($run_fixerrors !== 0) {
			// perform 'fix errors' maintenance
			require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_fixerrors.class.php');
			$fixerrors_report = hwd_vs_fixerrors::initiate($run_fixerrors);
		}

		if ($run_recount !== 0) {
			// perform 'recount' maintenance
			require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
			$recount_report = hwd_vs_recount::initiate($run_recount);
		}

		// set fixerror cache variables
		$cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root)
		$cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt)
		$page = 'http://fixerrorfile'; // Requested page
		$cachefile = $cachedir . md5($page) . '.' . $cacheext; // Cache file to either load or create
		$fixerror_cache = (@file_exists($cachefile)) ? @date ("F d Y H:i:s.", filemtime($cachefile)) : "Never";

		// set recount cache variables
		$cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root)
		$cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt)
		$page = 'http://recountfile'; // Requested page
		$cachefile = $cachedir . md5($page) . '.' . $cacheext; // Cache file to either load or create
		$recount_cache = (@file_exists($cachefile)) ? @date ("F d Y H:i:s.", filemtime($cachefile)) : "Never";

		// set archive cache variables
		$cachedir = JPATH_SITE.'/administrator/cache/'; // Directory to cache files in (keep outside web root)
		$cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt)
		$page = 'http://archivefile'; // Requested page
		$cachefile = $cachedir . md5($page) . '.' . $cacheext; // Cache file to either load or create
		$archive_cache = (@file_exists($cachefile)) ? @date ("F d Y H:i:s.", filemtime($cachefile)) : "Never";

		$db->SetQuery( "SELECT count(*)"
							. "\nFROM #__hwdvidsvideos AS a"
							. "\nWHERE a.approved = \"deleted\""
							);
		$total = $db->loadResult();
		echo $db->getErrorMsg();

		hwdvids_HTML::maintenance($permdelete_report, $total, $fixerrors_report, $recount_report, $archivelogs_report, $fixerror_cache, $recount_cache, $archive_cache);
	}