Пример #1
0
 /**
  * Perfoms manipulation
  *
  * @param string $from
  * @param string $to
  * @param string $options
  * @return void
  */
 public function manipulate($from, $to, $options)
 {
     if (false === class_exists('Thumbnail')) {
         throw new Yag_Manipulator_Adapter_Exception('Class Thumbnail could not be loaded');
     }
     if (!isset($options['geometry'])) {
         throw new Yag_Manipulator_Adapter_Exception('Thumbnail requires the \'geometry\' option to be set');
     }
     $matches = array();
     preg_match('/(c)?([0-9]+)x([0-9]+)/', $options['geometry'], $matches);
     $crop = empty($matches[1]) ? false : true;
     $width = $matches[2];
     $height = $matches[3];
     if (empty($matches[2])) {
         throw new Yag_Manipulator_Adapter_Exception('Invalid geometry pattern \'' . $options['geometry'] . '\'');
     }
     if (empty($matches[3])) {
         throw new Yag_Manipulator_Adapter_Exception('Invalid geometry pattern \'' . $options['geometry'] . '\'');
     }
     $thumbnail = new Thumbnail($from);
     // TODO: Fix error handling around this...
     $quality = 80;
     if (false == $crop) {
         $thumbnail->resize($width, $height);
         $quality = 100;
     } else {
         if ($width == $height) {
             // Well works for now... the crop for ImageTransform is a bit better
             // but who cares?
             $thumbnail->cropFromCenter($width);
         } else {
             $thumbnail->crop(0, 0, $width, $height);
         }
     }
     $thumbnail->save($to, $quality);
 }
Пример #2
0
        $_GET['width'] = $size[0];
    }
}
/* End of error image */
$thumb = new Thumbnail($_GET['filename']);
$size = getimagesize($_GET['filename']);
/* width and height setting and resize width and height with respect to image width and height  */
if (!empty($_GET['width'])) {
    if ($size[0] > $_GET['width']) {
        $_GET['width'] = $_GET['width'];
    } else {
        $_GET['width'] = $size[0];
    }
}
if (!empty($_GET['height'])) {
    if ($size[1] > $_GET['height']) {
        $_GET['height'] = $_GET['height'];
    } else {
        $_GET['height'] = $size[0];
    }
}
/* end of setting */
//check to see if file exists
$thumb->resize($_GET['width'], $_GET['height']);
//$thumb->crop(110,120,$_GET['width'],$_GET['height']);
if (isset($_GET['filename'])) {
    $thumb->show();
} else {
    $thumb->destruct();
}
exit;
Пример #3
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 );
	}
Пример #4
0
	function getImages($text, $thumb_size=70) {

        $matches = array();

		preg_match("/\<img.+?src=\"(.+?)\".+?\/>/", $text, $matches);

		$images = new stdClass();
		$images->image = false;
		$images->thumb = false;

		$paths = array();

		if (isset($matches[1])) {

			$image_path = $matches[1];

			//joomla 1.5 only
			$full_url = JURI::base();

			//remove any protocol/site info from the image path
			$parsed_url = parse_url($full_url);

			$paths[] = $full_url;
			if (isset($parsed_url['path']) && $parsed_url['path'] != "/") $paths[] = $parsed_url['path'];


			foreach ($paths as $path) {
				if (strpos($image_path,$path) !== false) {
					$image_path = substr($image_path,strpos($image_path, $path)+strlen($path));
				}
			}

			// remove any / that begins the path
			if (substr($image_path, 0 , 1) == '/') $image_path = substr($image_path, 1);

			//if after removing the uri, still has protocol then the image
			//is remote and we don't support thumbs for external images
			if (strpos($image_path,'http://') !== false ||
				strpos($image_path,'https://') !== false) {
				return false;
			}

			$images->image = JURI::Root(True)."/".$image_path;

			// create a thumb filename
			$file_div = strrpos($image_path,'.');
			$thumb_ext = substr($image_path, $file_div);
			$thumb_prev = substr($image_path, 0, $file_div);
			$thumb_path = $thumb_prev . "_thumb" . $thumb_ext;

			// check to see if this file exists, if so we don't need to create it
			if (function_exists("gd_info")) {
				// file doens't exist, so create it and save it
				if (!class_exists("Thumbnail")) include_once('thumbnail.inc.php');

				if (file_exists($thumb_path)) {
				    $existing_thumb = new Thumbnail($thumb_path);
				 	$images->size = $existing_thumb->currentDimensions;
				    $current_size = $existing_thumb->getCurrentWidth();
				}

                if (!file_exists($thumb_path) || $current_size!=$thumb_size) {

				    $thumb = new Thumbnail($image_path);

    				if ($thumb->error) {
    					echo "ROKNEWSPAGER ERROR: " . $thumb->errmsg . ": " . $image_path;
    					return false;
    				}
    				$thumb->resize($thumb_size);
    				if (!is_writable(dirname($thumb_path))) {
    					$thumb->destruct();
    					return false;
    				}
					$images->size = $thumb->currentDimensions;
    				$thumb->save($thumb_path);
    				$thumb->destruct();
    			}
			}
			$images->thumb = $thumb_path;
		}
		return $images;
	}
Пример #5
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' );
	}
Пример #6
0
function uploadarticleimage()
{
	$db =& JFactory::getDBO();
	
	$itemId = AwdwallHelperUser::getComItemId();
	
	$id=$_REQUEST['id'];
	$user = &JFactory::getUser();
		$query = "SELECT image,commenter_id,user_id FROM #__awd_wall_article as ar inner join #__awd_wall as aw on ar.wall_id =aw.id  WHERE `article_id`=".$id."  limit 1";
		$db->setQuery($query);
		$articlerows = $db->loadObjectList();
		$articlerow=$articlerows[0];
		if($articlerow->commenter_id)
		{
			$wuid=$articlerow->commenter_id;
		}
		else
		{
			$wuid=$user->id;
		}	
		
		
	$config 		= &JComponentHelper::getParams('com_awdwall');
	$article_img_height 		= $config->get('article_img_height', '84');
	$article_img_width 		= $config->get('article_img_width', '112');
	$image 	= JRequest::getVar('awd_link_image', null, 'files', 'array');
	$arrExt 	= explode(',', AwdwallHelperUser::getImageExt());
	$article_image 	= JRequest::getVar('awd_article_image', null, 'files', 'array');
		if($article_image['name'] != ''){
		jimport('joomla.filesystem.file');
		jimport('joomla.filesystem.folder');
		$time = time();
		//Clean up filename to get rid of strange characters like spaces etc
		$fileName = $time . '_' . JFile::makeSafe($article_image['name']);
		$fileName = str_replace(' ', '_', $fileName);
		$src 	= $article_image['tmp_name'];
		$dest 	= 'images' . DS . 'awd_articles' . DS . $wuid . DS . 'original' . DS . $fileName; 
		if(in_array(strtolower(JFile::getExt($fileName)), $arrExt)){
			if (JFile::upload($src, $dest)){ 
				require_once(JPATH_COMPONENT . DS . 'libraries' . DS . 'thumbnail.php');
				$thumb = new Thumbnail($dest);
				$thumb->resize($article_img_width, $article_img_height);
				JFolder::create('images' . DS . 'awd_articles' . DS . $wuid . DS . 'thumb');
				$thumb->save('images' . DS . 'awd_articles' . DS . $wuid . DS . 'thumb' . DS . $fileName);
				// resize original picture to 600*400
				$thumb = new Thumbnail($dest);
				$thumb->resize(600, 400);					
				$thumb->save($dest);
				$query = "update #__awd_wall_article set image='".$fileName."' where  `article_id`=".$id;
				$db->setQuery($query);
				if (!$db->query()){	
					$this->setRedirect(JRoute::_('index.php?option=com_awdwall&&view=awdwall&layout=main&Itemid='.$itemId,false),$db->getErrorMsg());
				}
				
			}else {						
				//Redirect and throw an error message
				//$this->setRedirect(JRoute::_('index.php?option=com_awdwall&&view=awdwall&layout=mywall&wuid=' . $wuid . '&Itemid=' . $itemId, false));
			}
		}
	}
	if($articlerow->image)
	{
		unlink('images' . DS . 'awd_articles' . DS . $wuid . DS . 'original' . DS . $articlerow->image);
		unlink('images' . DS . 'awd_articles' . DS . $wuid . DS . 'thumb' . DS . $articlerow->image);
	}
	
	$imagesrc=JURI::base().'images/awd_articles/'. $wuid . '/original/'. $fileName;
	echo '{"imagesrc": "'.$imagesrc.'"}';
	//echo '<img src="'.$imagesrc.'" width="150" />';
	exit;
}	
Пример #7
0
 /**
  * create Thumbnail
  *
  * @param none
  */
 function createThumbnail()
 {
     global $leaguemanager;
     $image = $leaguemanager->getImagePath($this->image);
     $thumb = $leaguemanager->getThumbnailPath($this->image);
     $thumbnail = new Thumbnail($image);
     $thumbnail->resize(60, 60);
     $thumbnail->save($image);
     $thumbnail->resize(30, 30);
     $thumbnail->save($thumb);
     chmod($image, 0644);
     chmod($thumb, 0644);
 }
Пример #8
0
<?php

include dirname(__FILE__) . "/init.php";
require_once ISC_BASE_PATH . "/includes/classes/class.thumbnail.php";
$width = (int) $_GET['width'];
$height = (int) $_GET['height'];
$path = $_GET['path'];
$imagename = ISC_BASE_PATH . "/" . $path;
$thumb = new Thumbnail($imagename);
//$thumb->resizeToWidth(240);
$thumb->resize($width, $height);
$thumb->show();
$thumb->destruct();
Пример #9
0
   /**
	* edit videos
	*/
	function editvideos($cid)
	{
		global $option;
  		$db =& JFactory::getDBO();
		$my = & JFactory::getUser();
		$app = & JFactory::getApplication();

		$row = new hwdvids_video( $db );
		$row->load( $cid );
		$c = hwd_vs_Config::get_instance();

        // get view count
        require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
        hwd_vs_recount::recountVideoViews($row->id);

		$db->SetQuery("SELECT *"
							. "\n FROM #__hwdvidsvideos"
							. "\n WHERE id = $cid");
		$row = $db->loadObject();

		$db->SetQuery("SELECT category_name"
							. "\n FROM #__hwdvidscategories"
							. "\n WHERE id = $row->category_id");
		$cat = $db->loadObject();

		if ($row->user_id == 0) {
			$usr->username = "******";
		} else {
			$db->SetQuery("SELECT username"
								. "\n FROM #__users"
								. "\n WHERE id = $row->user_id");
			$usr = $db->loadObject();
		}

		$db->SetQuery( "SELECT count(*)"
							. "\nFROM #__hwdvidsfavorites"
							. "\nWHERE videoid = $cid"
							);
		$favs = $db->loadResult();
		echo $db->getErrorMsg();
		if (empty($favs)) {$favs = 0;}

		$db->SetQuery( "SELECT count(*)"
							. "\nFROM #__hwdvidsflagged_videos"
							. "\nWHERE videoid = $cid"
							);
		$flagged = $db->loadResult();
		echo $db->getErrorMsg();
		if (empty($flagged)) {$flagged = 0;}

		$upld_thumbnail = JRequest::getInt( 'upld_thumbnail', 0, 'post' );
		if ($upld_thumbnail == "1") {

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

			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( 'index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editvidsA&hidemainmenu=1&cid='.$row->id );
			}
			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.$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();
				}
			}

			// update db with new thumbnail
			$db->SetQuery("UPDATE #__hwdvidsvideos SET thumbnail = '$thumbnail' WHERE id = $row->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=editvidsA&hidemainmenu=1&cid='.$row->id );
		}

		hwdvids_HTML::editvideos($row, $cat, $usr, $favs, $flagged);
	}
Пример #10
0
 function scale($imagePath, $thumbnailPath, $dimensions)
 {
     $imgMaxWidth = is_numeric($this->image_size[0]) ? min($this->image_size[0], trim(intval($dimensions[0]))) : trim(intval($dimensions[0]));
     //        $imgMaxHeight = trim(intval($this->size));
     $thumb = new Thumbnail($imagePath);
     if ($thumb->error) {
         echo $imagePath . ":" . $thumb->errmsg . "<br />";
         return false;
     }
     //        $thumb->resize($imgMaxWidth,$imgMaxHeight);
     $thumb->resize($imgMaxWidth);
     $thumb->save($thumbnailPath, $this->quality);
     $thumb->destruct();
     if (file_exists($thumbnailPath)) {
         return true;
     }
     return false;
 }
Пример #11
0
 function resizewatermark()
 {
     /* $watermark = "C:/wamp/www/gallery/upload/w_mark.png";
        echo*/
     $basedir = $_SERVER['DOCUMENT_ROOT'] . "/gallery/upload/";
     $watermarkimage = "Sample-trans.png";
     $watermark = $basedir . "/" . $watermarkimage;
     $waterthumb = new Thumbnail($watermark);
     $waterthumb->resize(imagesx($this->newImage) / 2, imagesy($this->newImage) / 2);
     return $waterthumb->newImage;
 }
 private function _subirArchivo($imagen)
 {
     if (isset($imagen['name'])) {
         if ($imagen['error'] == 0) {
             $nombre_imagen = time() . $imagen['name'];
             $directorio = "img/productos/";
             if (move_uploaded_file($imagen['tmp_name'], $directorio . $nombre_imagen)) {
                 App::uses('Thumbnail', 'Vendor');
                 $thumbnail = new Thumbnail();
                 $thumbnail->loadImage($directorio . $nombre_imagen);
                 $thumbnail->resize(200, 'width');
                 $thumbnail->save($directorio . 'medianos/' . $nombre_imagen);
                 $thumbnail->resize(70, 'width');
                 $thumbnail->save($directorio . 'chicos/' . $nombre_imagen);
                 return $nombre_imagen;
             }
         }
     }
     $this->Session->setFlash(__('Problemas al subir la imagen.'));
     $this->redirect(array('action' => 'mis_productos'));
 }
Пример #13
0
 function uploadImages($listing_id, $path)
 {
     $imgMaxWidth = $this->Config->content_max_imgwidth;
     $fileKeys = $this->fileKeys;
     $images = array();
     // Load thumbnail library
     App::import('Vendor', 'thumbnail' . DS . 'thumbnail.inc');
     foreach ($fileKeys as $key) {
         $tmp_name = $_FILES['image']['tmp_name'][$key];
         $name = basename($_FILES['image']['name'][$key]);
         // Append datetime stamp to file name
         $nameArray = explode(".", $name);
         // Leave only valid characters
         $nameArray[count($nameArray) - 2] = preg_replace('/[^0-9a-z]+/i', '', $nameArray[count($nameArray) - 2]);
         $nameArray[count($nameArray) - 2] = preg_replace('/[^\\w\\d\\s]+/i', '', $nameArray[count($nameArray) - 2]);
         $nameArray[count($nameArray) - 2] = $nameArray[count($nameArray) - 2] . "_" . time();
         // Prepend contentid
         $name = $listing_id . "_" . implode(".", $nameArray);
         $uploadfile = $path . $name;
         if (move_uploaded_file($tmp_name, $uploadfile)) {
             $images[] = "jreviews/" . $name . "|||0||bottom||";
             chmod($uploadfile, 0644);
             // Begin image resizing
             if ($imgMaxWidth > 0) {
                 $thumb = new Thumbnail($uploadfile);
                 if ($thumb->getCurrentWidth() > $imgMaxWidth) {
                     $thumb->resize($imgMaxWidth, $thumb->getCurrentHeight());
                 }
                 $thumb->save($uploadfile);
                 $thumb->destruct();
             }
         }
     }
     $this->images = $images;
 }
Пример #14
0
 public static function update($values, $user)
 {
     $id = $values['id'];
     if ($id) {
         $q = new Doctrine_Query();
         $q = $q->select('t.*')->from('Theme t');
         $q = $q->addWhere('id = ?', array($id));
         if (!$user->getRole() == User::ADMIN) {
             $q = $q->addWhere('user_id = ?', array($user->getId()));
         }
         $theme = $q->fetchOne();
     } else {
         $theme = new Theme();
     }
     if ($theme) {
         $theme->setName($values['name']);
         $theme->setDescription($values['description']);
         if (!$theme->getUserId()) {
             $theme->setUserId($user->getId());
         }
         $file = $values['file'];
         if ($file) {
             $filename = $file->getOriginalName();
             $theme->setFileName($filename);
         }
         $theme->setApproved(false);
         $theme->save();
         $folderpath = $theme->getFolderPath();
         if (!is_dir($folderpath)) {
             mkdir($folderpath);
         }
         if ($file) {
             $filepath = $folderpath . $theme->getFileName();
             $file->save($filepath);
         }
         $screenshot = $values['screenshot'];
         if ($screenshot) {
             $screenshotpath = $folderpath . $theme->getId() . $screenshot->getOriginalName();
             $screenshot->save($screenshotpath);
             $smallThumb = new Thumbnail($screenshotpath);
             if ($smallThumb->getCurrentWidth() > 150 || $smallThumb->getCurrentHeight() > 150) {
                 $smallThumb->resize(150, 150);
             }
             $smallThumb->show(100, $folderpath . 'smallthumb.png');
             $bigThumb = new Thumbnail($screenshotpath);
             if ($bigThumb->getCurrentWidth() > 500 || $bigThumb->getCurrentHeight() > 500) {
                 $bigThumb->resize(500, 500);
             }
             $bigThumb->show(100, $folderpath . 'bigthumb.png');
             $screenshot = new Thumbnail($screenshotpath);
             $screenshot->show(100, $folderpath . 'screenshot.png');
             unlink($screenshotpath);
         }
         $outputs = array();
         if ($file) {
             exec(Tools::get('edje_list_path') . ' ' . $filepath, $outputs);
             $groups = array_splice($outputs, 4);
             $groups = array_keys(array_flip($groups));
             $name = substr($outputs[0], 6);
             if ($name) {
                 $theme->setName($name);
             }
             $author = substr($outputs[1], 8);
             if ($author) {
                 $theme->setAuthor($author);
             }
             $license = substr($outputs[2], 9);
             $theme->setLicense($license);
             $version = substr($outputs[3], 9);
             $theme->setVersion($version);
             $theme->save();
             $theme->clearThemeGroups();
             foreach ($groups as $group) {
                 $theme->addThemeGroup($group);
             }
         }
         return $theme;
     }
     return null;
 }
Пример #15
0
     $ruta = "../images/" . nombre() . $ext;
     //comprobamos si este archivo existe para no volverlo a copiar.
     //pero si quieren pueden obviar esto si no es necesario.
     //o pueden darle otro nombre para que no sobreescriba el actual.
     if (!file_exists($ruta)) {
         //aqui movemos el archivo desde la ruta temporal a nuestra ruta
         //usamos la variable $resultado para almacenar el resultado del proceso de mover el archivo
         //almacenara true o false
         $resultado = @move_uploaded_file($_FILES['imagen']['tmp_name'], $ruta);
         if ($resultado) {
             $temp = $_FILES['imagen']['tmp_name'];
             $thumb = new Thumbnail($temp);
             if ($thumb->error) {
                 echo $thumb->error;
             } else {
                 $thumb->resize(80);
                 $thumb->save_jpg("", "imagen");
             }
             $nombre = $_FILES['imagen']['name'];
             mysql_query("INSERT INTO voxs (id_autor, titulo, categoria, imagen, contenido, editores, fuente, fecha) VALUES ('{$id_autor}','{$titulo}', '{$categoria}','{$ruta}','{$contenido}','{$editores}','{$fuente}','{$fecha}')") or die(mysql_error());
             $dato = mysql_insert_id();
             mysql_query("INSERT INTO muro (id_perfil, id_autor, tipo, dato) VALUES ('{$id_autor}','{$id_autor}', '5','{$dato}')") or die(mysql_error());
             header("Location: ../vox.php?id={$dato}");
         } else {
             echo "ocurrio un error al mover el archivo.";
         }
     } else {
         echo $_FILES['imagen']['name'] . ", este archivo existe";
     }
 } else {
     echo "archivo no permitido, es tipo de archivo prohibido o excede el tamano de {$limite_kb} Kilobytes";
Пример #16
0
                $thumb = new Thumbnail($temp);
                if ($thumb->error) {
                    echo $thumb->error;
                } else {
                    $thumb->resize(500);
                    $thumb->save_jpg($URL_long, $nombre_archivo);
                }
            }
        } else {
            if (isset($_FILES["imagen"])) {
                $temp = $_FILES["imagen"]["tmp_name"];
                $thumb = new Thumbnail($temp);
                if ($thumb->error) {
                    echo $thumb->error;
                } else {
                    $thumb->resize(500);
                    $thumb->save_jpg($URL_long, $nombre_archivo);
                }
            }
        }
        $objConnect = new Conexion();
        //Creación de imagen
        //Inicio de rescate de variables por medio de PHP.
        $objConnect->connect();
        $SQLEditar = "UPDATE local SET ID_REGION=" . $regionLocal . ", ID_COMUNA=" . $comunaLocal . ", DIRECCION_LOCAL='" . $direccionLocal . "', LATITUD_LOCAL=" . $latitudLocal . ", LONGITUD_LOCAL=" . $longitudLocal . ", ID_CATEGORIA_LOCAL='" . $categoria . "', URL_IMAGEN_LOCAL='" . $URL_full . "', CORREO_LOCAL='" . $emailLocal . "', WEB_LOCAL='" . $webLocal . "', TELEFONO_LOCAL='" . $telefonoLocal . "', DESCRIPCION_LOCAL='" . $descripcionLocal . "' WHERE ID_CLIENTE=" . $idCliente . " AND ID_LOCAL=" . $idLocal . ";";
        $agregar = mysql_query($SQLEditar) or die("1");
        $objConnect->closeConect();
        echo 2;
        return;
    }
} else {
Пример #17
0
 function thumb()
 {
     global $registrant_avatar_width, $registrant_avatar_height;
     ob_clean();
     include JPATH_SITE . "/components/com_dtregister/lib/thumbnail.inc.php";
     $registrant_avatar_width = JRequest::getVar('w', $registrant_avatar_width);
     $registrant_avatar_height = JRequest::getVar('h', $registrant_avatar_height);
     $thumb = new Thumbnail($_GET['filename']);
     $thumb->resize($registrant_avatar_width, $registrant_avatar_height);
     $thumb->show();
     exit;
 }
Пример #18
0
                mkdir($carpeta, 0755);
                if (isset($_FILES["imagen"])) {
                    $temp = $_FILES["imagen"]["tmp_name"];
                    $thumb = new Thumbnail($temp);
                    if ($thumb->error) {
                        echo $thumb->error;
                    } else {
                        $thumb->resize(200, 150);
                        $thumb->save_jpg($URL_long, $nombre_archivo);
                    }
                }
            } else {
                if (isset($_FILES["imagen"])) {
                    $temp = $_FILES["imagen"]["tmp_name"];
                    $thumb = new Thumbnail($temp);
                    if ($thumb->error) {
                        echo $thumb->error;
                    } else {
                        $thumb->resize(200, 150);
                        $thumb->save_jpg($URL_long, $nombre_archivo);
                    }
                }
            }
            //FIN cambio de imagen ************
            echo 1;
            return;
        }
    }
} else {
    header("Location: ../plantillas/errorPrivilegios.html");
}
Пример #19
0
 public static function update($values, $user)
 {
     $id = $values['id'];
     if ($id) {
         $q = new Doctrine_Query();
         $q = $q->select('m.*')->from('Madule m');
         $q = $q->addWhere('id = ?', array($id));
         if (!$user->getRole() == User::ADMIN) {
             $q = $q->addWhere('user_id = ?', array($user->getId()));
         }
         $module = $q->fetchOne();
     } else {
         $module = new Madule();
     }
     if ($module) {
         $module->setName($values['name']);
         $module->setDescription($values['description']);
         $module->setSourceUrl($values['source_url']);
         if (!$module->getUserId()) {
             $module->setUserId($user->getId());
         }
         $module->setApplicationId($values['application_id']);
         $module->setApproved(false);
         $module->save();
         $folderpath = $module->getFolderPath();
         if (!is_dir($folderpath)) {
             mkdir($folderpath);
         }
         $screenshot = $values['screenshot'];
         if ($screenshot) {
             $screenshotpath = $folderpath . $module->getId() . $screenshot->getOriginalName();
             $screenshot->save($screenshotpath);
             $smallThumb = new Thumbnail($screenshotpath);
             if ($smallThumb->getCurrentWidth() > 150 || $smallThumb->getCurrentHeight() > 150) {
                 $smallThumb->resize(150, 150);
             }
             $smallThumb->show(100, $folderpath . 'smallthumb.png');
             $bigThumb = new Thumbnail($screenshotpath);
             if ($bigThumb->getCurrentWidth() > 500 || $bigThumb->getCurrentHeight() > 500) {
                 $bigThumb->resize(500, 500);
             }
             $bigThumb->show(100, $folderpath . 'bigthumb.png');
             $screenshot = new Thumbnail($screenshotpath);
             $screenshot->show(100, $folderpath . 'screenshot.png');
             unlink($screenshotpath);
         }
         return $module;
     }
     return null;
 }
Пример #20
0
 function getThumb($text, $size = 70, $reflections = false)
 {
     preg_match("/\\<img.+?src=\"(.+?)\".+?\\/>/", $text, $matches);
     $paths = array();
     if (isset($matches[1])) {
         $image_path = $matches[1];
         //joomla 1.5 only
         $full_url = JURI::base();
         //remove any protocol/site info from the image path
         $parsed_url = parse_url($full_url);
         $paths[] = $full_url;
         if (isset($parsed_url['path']) && $parsed_url['path'] != "/") {
             $paths[] = $parsed_url['path'];
         }
         foreach ($paths as $path) {
             if (strpos($image_path, $path) !== false) {
                 $image_path = substr($image_path, strpos($image_path, $path) + strlen($path));
             }
         }
         // remove any / that begins the path
         if (substr($image_path, 0, 1) == '/') {
             $image_path = substr($image_path, 1);
         }
         //if after removing the uri, still has protocol then the image
         //is remote and we don't support thumbs for external images
         if (strpos($image_path, 'http://') !== false || strpos($image_path, 'https://') !== false) {
             return false;
         }
         // create a thumb filename
         $file_div = strrpos($image_path, '.');
         $thumb_ext = substr($image_path, $file_div);
         $thumb_prev = substr($image_path, 0, $file_div);
         $thumb_path = $thumb_prev . "_thumb" . $thumb_ext;
         // check to see if this file exists, if so we don't need to create it
         if (function_exists("gd_info") && !file_exists($thumb_path)) {
             // file doens't exist, so create it and save it
             include_once 'thumbnail.inc.php';
             $thumb = new Thumbnail($image_path);
             if ($thumb->error) {
                 if (MICRONEWS) {
                     echo "ROKMININEWS ERROR: " . $thumb->errmsg . ": " . $image_path;
                 }
                 return false;
             }
             $thumb->resize($size);
             if ($reflections) {
                 $thumb->createReflection(30, 30, 60, false);
             }
             if (!is_writable(dirname($thumb_path))) {
                 $thumb->destruct();
                 return false;
             }
             $thumb->save($thumb_path);
             $thumb->destruct();
         }
         return $thumb_path;
     } else {
         return false;
     }
 }
Пример #21
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") );
	}