Your IP : 172.28.240.42


Current Path : /var/www/html/clients/kampol.e-nk.ru/plugins/community/
Upload File :
Current File : /var/www/html/clients/kampol.e-nk.ru/plugins/community/ecarte.php

<?php
/*------------------------------------------------------------------------
# plg_ecarte - eCarte for Joomla 2.5 and Jomsocial 2.6
# ------------------------------------------------------------------------
# author JeuxCoquins
# copyright (C) 2012 www.jeuxcoquins.net. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.jeuxcoquins.net
# Technical Support: Forum - http://www.jeuxcoquins.net/expression-libre/forum.html
-------------------------------------------------------------------------*/
// no direct access
defined('_JEXEC') or die('Restricted access');

require_once( JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php');

jimport('joomla.html.pagination');

class plgCommunityecarte extends CApplications
{
	var $name		= 'ecarte';
	var $_name		= 'ecarte';
	var $_user		= null;
	var $pagination	= null;
	
    function plgCommunityecarte(& $subject, $config)
    {
		$this->_user	=& CFactory::getActiveProfile();
		$this->_my		=& CFactory::getUser();

		$db	= JFactory::getDBO();
		$query = 'SELECT params FROM #__extensions WHERE element="ecarte" AND folder="community"';
		$db->setQuery($query);
		$params	= new JParameter($db->loadResult());
		$this->params =& $params;
		
		parent::__construct($subject, $config);
    }


		function onProfileDisplay()
		{
			$mainframe =& JFactory::getApplication();
		
			// Attach CSS
			$document	=& JFactory::getDocument();
			$user     = CFactory::getRequestUser();
			$userid	= $user->id;
			
			$def_limit = $this->params->get('count', 10);
			$limit = JRequest::getVar('limit', $def_limit, 'REQUEST');
			$limitstart = JRequest::getVar('limitstart', 0, 'REQUEST');		
			
			$row = $this->getPhotos($userid, $limitstart, $limit);
			$total = count($row);		
			
			$caching = $this->params->get('cache', 1);		
			if($caching)
			{
				$caching = $mainframe->getCfg('caching');
			}
			
			$cache =& JFactory::getCache('plgCommunityecarte');
			$cache->setCaching($caching);
			$callback = array('plgCommunityecarte', '_getLatestPhotoHTML');		
			$content = $cache->call($callback, $userid, $limit, $limitstart, $row, $total);
						
			return $content;
		}
	
	
		function _getLatestPhotoHTML($userid, $limit, $limitstart, $row, $total)
		{
			
			CFactory::load( 'models' , 'photos' );
			$photo =& JTable::getInstance( 'Photo' , 'CTable' );
							
			ob_start();				
			if(!empty($row))
			{
				?>				
				<div id="application-photo">
					<ul class="cThumbList clrfix">
				<?php
				
				foreach($row as $data)
				{
					$photo->load( $data->id );
					
					$link = plgCommunityecarte::buildLink($photo->albumid, $data->id, $userid);
					$thumbnail	= $photo->getThumbURI();
					?>					
						<li>
							<a href="<?php echo $link; ?>">
								<img class="avatar jomTips" title="<?php echo CTemplate::escape($photo->caption);?>::" alt="<?php echo CTemplate::escape($photo->caption); ?>" src="<?php echo $thumbnail; ?>"/>
							</a>
						</li>
					<?php
				}			
				?>
					</ul>
				</div>
				<?php
			}
			else
			{
				?>
				<div><?php echo JText::_('PLG_LATESTPHOTO NO PHOTO')?></div>
				<?php
			}	
			?>
			<div style='clear:both;'></div>
			<?php
			$contents  = ob_get_contents();
			@ob_end_clean();
			$html = $contents;
			
			return $html;
		}
		
		function getPhotos($userid, $limitstart, $limit)
		{		
			$photoType = PHOTOS_USER_TYPE;
      $db	= JFactory::getDBO();
	
			$sql  = "	SELECT
								a.id
						FROM
								".$db->nameQuote('#__community_photos')." AS a
						INNER JOIN 
								".$db->nameQuote('#__community_photos_albums')." AS b ON a.`albumid` = b.`id` 
						WHERE
								a.".$db->nameQuote('creator')." = ".$db->quote($userid)." AND
								b.".$db->nameQuote('type')." = ".$db->quote($photoType)." AND								
								a.".$db->nameQuote('published')."=".$db->quote(1)."
						ORDER BY
								a.".$db->nameQuote('created')." DESC
						LIMIT 
								".$limitstart.",".$limit;
						
			$query = $db->setQuery($sql);
			$row  = $db->loadObjectList();
			if($db->getErrorNum()) {
				JError::raiseError( 500, $db->stderr());
			}
			
			return $row;
		}
		
		function buildLink($albumid, $photoid, $userid){			
			$link	= CRoute::_('index.php?option=com_community&view=profile&userid='.$userid.'&albumid='.$albumid.'&photoid='.$photoid.'&task=app&app=ecarte');
			return $link;
		}
	
	function onAppDisplay()
	{
		JPlugin::loadLanguage( 'plg_ecarte', JPATH_ADMINISTRATOR );
		$mainframe =& JFactory::getApplication();
		$document		=& JFactory::getDocument();


		$db	= JFactory::getDBO();
		$query = 'SELECT params FROM #__extensions WHERE element="ecarte" AND folder="community"';
		$db->setQuery($query);
		$params	= new JParameter($db->loadResult());
		$this->params =& $params;
		
		
		//if( $this->_my->id == $this->_user->id ){
			CFactory::load( 'helpers' , 'user' );
			ob_start();
			
			$method	= JRequest::getMethod();
	$albumid = $_GET['albumid'];
	$photoid = $_GET['photoid'];
  $query = "SELECT * "
    .' FROM #__community_photos'
    .' WHERE `albumid`='.$db->Quote($albumid)
    .' AND `id`='.$db->Quote($photoid);
  $db->setQuery($query);
			if($db->getErrorNum()) {
				JError::raiseError( 500, $db->stderr());
			}  
  $row = $db->loadObject(); 
  $image = $row->image;
		?>

<?php

$user     = CFactory::getRequestUser();
			$userid	= $user->id;
$user =& JFactory::getUser();
			$usermail	= $user->email;
$user =& JFactory::getUser();
			$usernamed	= $user->name;
$to = $_POST['to'];

$msg = $_POST['msg'];
$from = $_POST['from'];
$fromail = $_POST['fromail'];
//Image in e-mail
$info = pathinfo($image);
$file_name =  basename($image,'.'.$info);
$mailimg = file_get_contents("./images/photos/$userid/$albumid/$file_name");


//Mail Body - Position, background, font color, font size...
/*$body ='
<html>
<head>
<style>
<!--
body, P.msoNormal, LI.msoNormal
{
background-position: top;
background-color: #336699;
margin-left:  10em;
margin-top: 1em;
font-family: "verdana";
font-size:   10pt;
font-weight:bold ;
color:    "000000";
}
-->
</style>
</head>

</body>
';*/
//To send HTML mail, the Content-type header must be set:
$subject .="Vous avez reçu une carte de"." $from !";
$headers="From: $from <$fromail>\r\n";
$headers.="MIME-Version: 1.0\r\n"
		."Content-Type: multipart/mixed; boundary=\"1a2a3a\"";
$body   .= "If you can see this MIME than your client doesn't accept MIME types!\r\n"
		."--1a2a3a\r\n";
$body	.="Content-type: text/html;charset=UTF-8"
		."\r\n"
		."Content-Transfer-Encoding: 7bit\r\n\r\n"
		."$msg\r\n"
		."--1a2a3a\r\n";
$body   .= "Content-Type: image/jpg; name=\"$file_name\"\r\n" 
		."Content-Transfer-Encoding: base64\r\n"
		."Content-disposition: attachment; file=\"$file_name\"\r\n"
		."\r\n"
		.chunk_split(base64_encode($mailimg))
		."--1a2a3a--\r\n";


if (mail($to, $subject, $body, $headers))
{
        "L'email a bien été envoyé.";
}
else
{
        "Une erreur c'est produite lors de l'envois de l'email.";
}


 // outputs 'image'
?>
<html>
<style>
.componentheading {
	display: none !important;
	}
</style>
<body>
<form name="myform" action="<?php $link ?>" method="POST">

<center><strong><?php echo JText::_('PLG_ECARTE_PICTURE') ?></strong><br/>
<img src="<?php echo JURI::root().$image; ?>" width="666" height="500" border="0"/><br>
<strong><?php echo JText::_('PLG_ECARTE_YOURNAME') ?></strong><br/>
        <input type=text name="from" value="<?php echo $usernamed ?>" size="25"><br>
<strong><?php echo JText::_('PLG_ECARTE_YOURMAIL') ?></strong><br/>
        <input type=text name="fromail" value="<?php echo $usermail ?>" size="25"><br>
<strong><?php echo JText::_('PLG_ECARTE_MAILTO') ?></strong><br/>
        <input type=text name="to" size="25"><br>
<strong><?php echo JText::_('PLG_ECARTE_MESSAGE') ?></strong><br/>
        <textarea type=text name="msg" rows="2" cols="25"></textarea><br>

<input type="submit" value="<?php echo JText::_('PLG_ECARTE_SEND') ?>">
</center>
</form>
</body>
</html>


		<?php
			$content	= ob_get_contents();
			@ob_end_clean();

			return $content;
		//}
	}
}