/**
     * 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://recountfile'; // 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_COUNT_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_recount::recountVideosInCategory();
		hwd_vs_recount::recountSubcatsInCategory();
		hwd_vs_recount::recountMembersInGroup();
		hwd_vs_recount::recountVideosInGroup();
		hwd_vs_recount::recountVideoViews();
		hwd_vs_recount::recountRatings();
		hwd_vs_recount::recountNumberOfComments();

		return true;
	}
示例#2
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' );
	}
示例#3
0
	/**
	 * save categories
	 */
	function savegroup()
	{
		global $option;
  		$db =& JFactory::getDBO();
		$app = & JFactory::getApplication();

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

		$row = new hwdvids_group($db);

		$_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();
		}

		// 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::recountVideosInCategory();
		hwd_vs_recount::recountSubcatsInCategory();

		$msg = $total ._HWDVIDS_ALERT_GRPSAVED;
		$app->enqueueMessage($msg);
		$app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=groups' );
	}