? GR0V Shell

GR0V shell

Linux www.koreapackagetour.com 2.6.32-042stab145.3 #1 SMP Thu Jun 11 14:05:04 MSK 2020 x86_64

Path : /home/admin/public_html/old/administrator/components/com_coalawebtraffic/controllers/
File Upload :
Current File : /home/admin/public_html/old/administrator/components/com_coalawebtraffic/controllers/geoupload.php

<?php

/**
 * @package             Joomla
 * @subpackage          com_coalawebtraffic
 * @author              Steven Palmer
 * @author url          http://coalaweb.com
 * @author email        support@coalaweb.com
 * @license             GNU/GPL, see /files/en-GB.license.txt
 * @copyright           Copyright (c) 2016 Steven Palmer All rights reserved.
 *
 * CoalaWeb Traffic is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

defined('_JEXEC') or die('Restricted access');

jimport('joomla.filesystem');
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.archive');

// Load version.php
$version_php = JPATH_COMPONENT_ADMINISTRATOR . '/version.php';
if (!defined('COM_CWTRAFFIC_VERSION') && JFile::exists($version_php)) {
    include_once $version_php;
}

/**
 * Geoupload controller class.
 *
 * @package    Joomla.Administrator
 * @subpackage com_coalawebtraffic
 */
class CoalawebtrafficControllerGeoupload extends JControllerLegacy
{
    
    /**
     * @var        string    The prefix to use with controller messages.
     * @since    1.6
     */
    protected $text_prefix = 'COM_CWTRAFFIC';

    /**
     * Constructor.
     *
     * @param array An optional associative array of configuration settings.
     * @see   JController
     */
    public function __construct() 
    {
        if (COM_CWTRAFFIC_PRO == 1) {
            $this->path = JFactory::getConfig()->get('tmp_path') . '/com_coalawebtraffic';
            $this->pathArchive = $this->path . '/archivesv2';
            $this->pathUnzipped = JPATH_COMPONENT_ADMINISTRATOR . '/assets/geoip/v2';
            $this->dbName = 'GeoLite2-City.mmdb.gz';

        } else {
            $this->path = JFactory::getConfig()->get('tmp_path') . '/com_coalawebtraffic';
            $this->pathArchive = $this->path . '/archives';
            $this->pathUnzipped = JPATH_COMPONENT_ADMINISTRATOR . '/assets/geoip';
            $this->dbName = 'GeoLiteCity.dat.gz';
        }

        parent::__construct();
    }

    /**
     * Upload the GeoLiteCity dat file
     * 
     * @return boolean
     */
    public function upload() 
    {
        JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
        $appl = JFactory::getApplication();
        
            $destination = $this->pathArchive . '/' . $this->dbName;
            $source = 'http://geolite.maxmind.com/download/geoip/database/' . $this->dbName;

        // create a new cURL resource
        $resource = curl_init();

        // set URL and other appropriate options
        $options = array(CURLOPT_URL => $source,
            CURLOPT_HEADER => false,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_CONNECTTIMEOUT => 600
        );

        curl_setopt_array($resource, $options);

        // grab URL and pass it to the browser
        $content = curl_exec($resource);

        // close cURL resource, and free up system resources
        curl_close($resource);

        $path = $this->pathArchive;

        // if the archive folder doesn't exist - create it!
        if (!JFolder::exists($path)) {
            JFolder::create($path);
        } else {
            // let us remove all previous uploads
            $archiveFiles = JFolder::files($path);

            foreach ($archiveFiles as $archive) {
                if (!JFile::delete($this->pathArchive . '/' . $archive)) {
                    echo 'could not delete' . $archive;
                }
            }
        }

        if ($content != '') {
            $fp = fopen($destination, 'w');
            $fw = fwrite($fp, $content);
            fclose($fp);
        }
        if ($fw != false) {
            $message = 'COM_CWTRAFFIC_UPLOAD_SUCCESSFUL';
        } else {
            $message = 'COM_CWTRAFFIC_UPLOAD_FAILED';
        }

        $appl->redirect('index.php?option=com_coalawebtraffic&view=geoupload', JText::_($message));

        return $fw;
    }

    /**
     * Unzip the GeoLiteCity dat file
     * 
     * @return string
     */
    public function unzip() 
    {
        JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
        $appl = JFactory::getApplication();

        // if folder doesn't exist - create it!
        if (!JFolder::exists($this->pathUnzipped)) {
            JFolder::create($this->pathUnzipped);
        }

        $result = JArchive::extract($this->pathArchive . '/' . $this->dbName, $this->pathUnzipped);
        
        if ($result) {
            $message = 'COM_CWTRAFFIC_UNZIP_SUCCESSFUL';
            if (JFolder::exists($this->pathArchive)) {
                JFolder::delete($this->pathArchive);
            }
                
        } else {
            $message = 'COM_CWTRAFFIC_UNZIP_FAILED';
        }

        $appl->redirect('index.php?option=com_coalawebtraffic&view=geoupload', JText::_($message));

    }
    
        /**
     * Messages and redirect for the optimization of Traffic tables
     */
    function optimize() {
        $model = $this->getModel();
        $results = $model->optimize();
        $msgType = '';

        if (!$results['test']) {
            $msg = JText::_('COM_CWTRAFFIC_OPTIMIZE_ERROR_MSG');
            $msgType = 'error';
        } else {
            $msg = JText::sprintf('COM_CWTRAFFIC_OPTIMIZE_SUCCESS_MSG', $results['repaired'], $results['optimized']);
        }
        $this->setRedirect('index.php?option=com_coalawebtraffic&view=controlpanel', $msg, $msgType);
    }

}

T1KUS90T
  root-grov@210.1.60.28:~$