403Webshell
Server IP : 104.21.17.213  /  Your IP : 216.73.217.141
Web Server : Apache
System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64
User : corbizre ( 1013)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/corbizre/gotofindhomes.com/components/Image/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/corbizre/gotofindhomes.com/components/Image/Controllers/IndexController.php
<?php
/**
 * Documentation
 * @author keeper, djes
 * @category
 * @package
 * @subpackage
 * @copyright  Copyright (c) 2005-2011 ITCrimea Ukraine Inc. (http://www.itcrimea.com)
 * @license
 */
class Image_IndexController extends System_Controller_Db_Table
{

    /**
    * getlist action
    * @author dray, keeper
    * @return mixed
    */
    function getlistAction()
    {
        $Assign = $this->getRequest()->getParam('Assign', $this->getRequest()->getParam('assign'));
        $AssignID = $this->getRequest()->getParam('AssignID', $this->getRequest()->getParam('assignid'));
        $Group = $this->getRequest()->getParam('Group', $this->getRequest()->getParam('group'));
        
        if ($Assign) {
            $this->_select->where('Assign = ?', $Assign);
            $this->_selectCount->where('Assign = ?', $Assign);
        }
        if ($AssignID) {
            $this->_select->where('AssignID = ?', $AssignID);
            $this->_selectCount->where('AssignID = ?', $AssignID);
        }
        if ($Group) {
            $this->_select->where('`Group` = ?', $Group);
            $this->_selectCount->where('`Group` = ?', $Group);
        }

        $this->view->title = $this->getRequest()->getParam('title');
        $this->view->alt = $this->getRequest()->getParam('alt','');
        
        parent::getlistAction();
    }

    /**
    * "get image" action, by default returns the fulfilled html tag <img>
    * @author keeper, djes
    * @return mixed
    */
	function getAction()
	{
	    $config = $this->getConfig();
	    //print_r($this->getRequest()->getParams());
	    $ID = $this->getRequest()->getParam('id', $this->getRequest()->getParam('ID', $this->getRequest()->getParam('imageid')));
		$objImage = null;
		if ($ID) {
		    $objImage = $this->_model->find($ID)->current();
		} else {
		    $AssignID = intval($this->getRequest()->getParam('assignid'));
		    $Assign = trim($this->getRequest()->getParam('assign'));
		    $Group = trim($this->getRequest()->getParam('group'));
		    $Primary = $this->getRequest()->getParam('primary', null);

		    if ($AssignID && $Assign) {
    		    $this->_select->where('AssignID = ?', $AssignID);
    		    $this->_select->where('Assign = ?', trim($Assign));
    		    if ($Group) $this->_select->where('`Group` = ?', trim($Group));
    		    if ($Primary!==null) $this->_select->where('Primary = ?', ($Primary ? 1 : 0) );
    		    $objImage = $this->_model->fetchRow($this->_select);
    		    //echo $this->_select;
		    }
		}
		// check is image active and user has rights to see it
		if (is_object($objImage) && !$objImage->Active) {
		    if (System_User::getRoleID() != System_User::getAdminRoleID()) {
		        $objImage = null;
		    }
		}
		// get default image if requested image can not be found
                $default_loaded = false;
		if (!is_object($objImage)) {
		    $DefaultID = intval($this->getRequest()->getParam('defaultid'));
		    $DefaultActive = $this->getRequest()->getParam('defaultactive', null);
		    if ($DefaultActive !== 0) {
		        if ($DefaultID) {
		            $objImage = $this->_model->find($DefaultID)->current();
		        }
		        if (!is_object($objImage)) {
		            if ($DefaultActive>0 || $config->Image->Default->Active>0) {
                                $objImage = $this->_model->find($config->Image->Default->ID)->current();
		            }
		        }
                        if (is_object($objImage))
                            $default_loaded = true;
		    }
		}
		// get thumbnail object or generate new if not exists
		if (is_object($objImage)) {
    		$Width = intval($this->getRequest()->getParam('w'));
    		$WidthMax = intval($this->getRequest()->getParam('mw'));
    		$Height = intval($this->getRequest()->getParam('h'));
    		$HeightMax = intval($this->getRequest()->getParam('mh'));

            $tableThumb = new Image_Thumb_Table();
            if (empty($objImage->ExternalSourceID)) {
                $arrThumbParams = $objImage->calcThumbParams($Width, $Height, $WidthMax, $HeightMax);
                $select = $tableThumb->select()->
                                where('Image_ID = ?', $objImage->ID)->
                                where('Width = ?', $arrThumbParams['Width'])->
                                where('Height = ?', $arrThumbParams['Height']);
                $objThumb = $tableThumb->fetchRow($select);

                if (!is_object($objThumb) || !file_exists(Zend_Registry::get('AppFolder') . $objThumb->Path . $objThumb->File)) {
                    if (is_object($objThumb)) {
                        $objThumb->delete();
                    }
                    $objThumb = $objImage->generateThumb($arrThumbParams);
                }
            } else {
                $select = $tableThumb->select()->where('Image_ID = ?', $objImage->ID);
                if (!empty($Width) && !empty($Height)) {
                    $select->where('Width >= ?', $Width)
                           ->where('Height >= ?', $Height)
                           ->order('Width ASC');
                } elseif (!empty($Width)) {
                    $select->where('Width = ?', $Width);
                } elseif (!empty($Height)) {
                    $select->where('Width = ?', $Height);
                } else {
                    // get largest
                    $select->order(array('Width DESC', 'Height DESC'));
                }
                $objThumb = $tableThumb->fetchRow($select);
//                 if($_SERVER['REMOTE_ADDR']=='204.12.241.146'){
//                 	echo "<pre>";
//                 	print_r($objThumb);
//                 	echo "</pre>";
//                 }
                if (is_object($objThumb) && !empty($Width) && !empty($Height)) {
                    $objThumb->Width = $Width;
                    $objThumb->Height = $Height;
                }
            }

            if ($default_loaded) {
                $objImage->Name = 'No photo available';
            } else {
                $objImage->Name = $this->getRequest()->getParam('alt', '');
            }

    		$this->view->row = $objImage->toArray();
    		if (is_object($objThumb)) {
                $this->view->Thumb = $objThumb->toArray();
    		}
		}

        if (is_object($objImage) && $objImage->ExternalSourceID) {
            $srcId = $objImage->ExternalSourceID;
            $company = 'company' . System_Company::getID();
            if (isset($config->External->$srcId->$company) && isset($config->External->$srcId->$company->path_odd) && isset($config->External->$srcId->$company->path_even)) {
                if ($objImage->ID % 2 == 0) {
                    $this->view->ImageUrl = $config->External->$srcId->$company->path_even;
                } else {
                    $this->view->ImageUrl = $config->External->$srcId->$company->path_odd;
                }
            } else {
                $this->view->ImageUrl = $config->External->$srcId->path;
            }
        } else {
            $this->view->ImageUrl = Zend_Registry::get('baseUrl');
        }

		$strTemplate = trim($this->getRequest()->getParam('template'));
		if ($strTemplate) {
		    $this->render('get-'.trim($strTemplate));
		}
	}


	/**
    * add new image form
    * @todo use System_Translate for messages inside action
    * @author keeper
    * @return mixed
    */
	function addAction()
	{
        $objImage = $this->_model->fetchNew();
        $objImage->Name = trim($this->getRequest()->getParam('Name'));
        $objImage->Desc = trim($this->getRequest()->getParam('Desc'));
        $objImage->Assign = trim($this->getRequest()->getParam('Assign', $this->getRequest()->getParam('assign')));
        $objImage->AssignID = intval($this->getRequest()->getParam('AssignID', $this->getRequest()->getParam('assignid')));
        $objImage->Group = trim($this->getRequest()->getParam('Group', $this->getRequest()->getParam('group')));
        $objImage->Primary = intval($this->getRequest()->getParam('Primary'));
        $objImage->Active = intval($this->getRequest()->getParam('Active', 1));

        if ($this->getRequest()->isPost()) {
            $config = $this->getConfig();

            // upload files to temporary folder
            if (isset($_FILES['File']) && $_FILES['File']['name']) {
                $Filename = $this->uploadFile('File', Zend_Registry::get('AppFolder').$config->Image->PathTemp, 'Image File');
                if ($Filename) {
                    $objImage->File = $Filename;
                }
            } else {
                $objImage->File = $this->getRequest()->getParam('FileCache');
                $objImage->File = preg_replace('/([^a-zA-Z_0-9\-_.]+)/', '', $objImage->File);
                if ($objImage->File && !file_exists(Zend_Registry::get('AppFolder').$config->Image->PathTemp.$objImage->File)) $objImage->File = '';
                if (!$objImage->File) $this->addErrorMessage('Upload image');
            }

            // validate
            if (!$objImage->Name) $this->addErrorMessage('Enter Title');
            if (!$objImage->Desc) $this->addErrorMessage('Enter a description of the image');

            if (!$this->isErrorMessages()) {
                $objImage->Path = '';
                $objImage->save();
                $objImage->Path = $objImage->getPath();
                $objImage->File = Image::moveFile($objImage->File, Zend_Registry::get('AppFolder').$config->Image->PathTemp, Zend_Registry::get('AppFolder').$objImage->Path);
                if ($objImage->File) {
                    $Image = Image::create(Zend_Registry::get('AppFolder').$objImage->Path.$objImage->File);
                    $objImage->Width = imagesx($Image);
                    $objImage->Height = imagesy($Image);
                    $objImage->save();
                    $this->addOkMessage('The image was successfully added');
                    $this->view->row = $objImage->toArray();
                    $this->render('add-success');
                } else {
                    $objImage->delete();
                    $this->addOkMessage('An error occurred while saving. Please try again');
                }
            }

        }

        $this->view->Image = $objImage->toArray();
	}

	/**
    * edit exists image
    * @todo finish action
    * @author keeper
    * @return mixed
    */
	function editAction()
	{
        $ID = $this->getRequest()->getParam('id', $this->getRequest()->getParam('ID'));
	}

    /**
    * action to show FULL-SIZE image
    * @author keeper
    * @return mixed
    */
    function viewAction()
    {
        $ID = $this->getRequest()->getParam('id');
        if ($ID) {
            $objImage = $this->_model->find($ID)->current();
            if (is_object($objImage)) {
                $this->view->row = $this->view->Image = $objImage->toArray();
            }
        }
    }


    /**
     * get the file from $_FILES and move to requested folder
     * @todo use System_Translate for messages inside action
     * @author keeper
     * @param string $FieldName
     * @param string $Dirname
     * @param string $FieldDesc
     * @return string Name of uploaded file
     */
    function uploadFile($FieldName, $Dirname, $FieldDesc, $Extensions=array('pdf','jpeg','jpg','tif','tiff','png','gif'))
    {
        if ($_FILES[$FieldName]['error']) {
            if ($_FILES[$FieldName]['error'] == 4) {
                $this->addErrorMessage('Please upload '.$FieldDesc);
            } else {
                $this->addErrorMessage('Can not load '.$FieldDesc);
            }
        } else {
            if (!is_dir($Dirname)) {
                if (!mkdir($Dirname, 0777)) {
                    $this->addErrorMessage('Unable to create directory '.$FieldDesc);
                }
            }
            $Filename = $this->convertFilename($_FILES[$FieldName]['name']);
            if (!$Filename) {
                $this->addErrorMessage($FieldDesc.' invalid name');
            } elseif (strpos($Filename, '.') === false) {
                $this->addErrorMessage($FieldDesc.' extension is not defined');
            } else {
                $extension = substr($Filename, strrpos($Filename, '.')+1);
                if (!in_array(strtolower($extension), $Extensions)) {
                    $this->addErrorMessage($FieldDesc.' extension is not correct');
                } else {
                    $nameonly = substr($Filename, 0, strrpos($Filename, '.'));
                    $i = 0;
                    while (file_exists($Dirname . $Filename)) {
                        $Filename = $nameonly.$i.'.'.$extension;
                        $i++;
                    }
                    if (!move_uploaded_file($_FILES[$FieldName]['tmp_name'], $Dirname.$Filename)) {
                        $this->addErrorMessage('Unable to move '.$FieldDesc);
                    }
                    return $Filename;
                }
            }
        }
        return;
    }

    /**
     * delete image
     * @author dray, keeper
     * @todo delete files!
     */
    function deleteAction()
    {
        $ImageID = $this->getRequest()->getParam('id', $this->getRequest()->getParam('ID'));
        $ThumbID = $this->getRequest()->getParam('thumbid', $this->getRequest()->getParam('ThumbID'));
        $tableThumb = new Image_Thumb_Table();
        if ($ImageID) {
            $objImage = $this->_model->find($ImageID)->current();
            if (!is_object($objImage)) {
                throw new Zend_Exception('Image ID in invalid');
            }
        } elseif ($ThumbID) {
            $objThumb = $tableThumb->find($ThumbID)->current();
            if (!is_object($objThumb)) {
                throw new Zend_Exception('Image ID in invalid');
            }
            $objImage = $objThumb->findParentRow('Image_Table', 'Image_ID');
        } else {
            if (!is_object($objThumb)) {
                throw new Zend_Exception('Request in not valid');
            }
        }

        // todo: delete files!

        $this->view->Image = $this->view->row = $objImage->toArray();

        $tableThumb->delete('Image_ID = '.$objImage->ID);
        $objImage->delete();
    }

    /**
     * translit cyrillic to eng
     * @author keeper
     * @param string $text
     * @return string
     */
    function toTranslit($text)
    {
        $text = strtr($text, array(
                            'а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d','е'=>'e','ё'=>'e',
                            'з'=>'z','и'=>'i','й'=>'y','к'=>'k','л'=>'l','м'=>'m','н'=>'n',
                            'о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u','ф'=>'f',
                            'х'=>'h','ъ'=>'\'','ы'=>'i','э'=>'e','і'=>'i'));
        $text = strtr($text, array(
                            'А'=>'A','Б'=>'B','В'=>'V','Г'=>'G','Д'=>'D','Е'=>'E','Ё'=>'E',
                               'З'=>'Z','И'=>'I','Й'=>'Y','К'=>'K','Л'=>'L','М'=>'M','Н'=>'N',
                               'О'=>'O','П'=>'P','Р'=>'R','С'=>'S','Т'=>'T','У'=>'U','Ф'=>'F',
                               'Х'=>'H','Ъ'=>'\'','Ы'=>'I','Э'=>'E','І'=>'I'));

        $text = strtr($text, array(
                         "ж"=>"zh", "ц"=>"ts", "ч"=>"ch", "ш"=>"sh", "щ"=>"shch","ь"=>"", "ю"=>"yu", "я"=>"ya",
                         "Ж"=>"Zh", "Ц"=>"Ts", "Ч"=>"Ch", "Ш"=>"Sh", "Щ"=>"Shch","Ь"=>"", "Ю"=>"Yu", "Я"=>"Ya",
                         "ї"=>"i", "Ї"=>"Yi", "є"=>"ie", "Є"=>"Ye"
                         )
                    );
        return $text;
    }

    /**
     * convert
     * @author keeper
     * @param string $Filename
     * @return string
     */
    function convertFilename($Filename)
    {
        $Filename = $this->toTranslit($Filename);
        $Filename = trim($Filename);
        $Filename = strtolower($Filename);

        $Filename = str_replace('\n', '', $Filename);
        $Filename = str_replace('\n\r', '', $Filename);
        $Filename = str_replace('\t', '', $Filename);
        $Filename = trim($Filename);
        $Filename = str_replace(' ', '-', $Filename);

        $Filename = preg_replace('/([^a-zA-Z_0-9-\.]+)/', '', $Filename);

        $Filename = str_replace('--', '-', $Filename);
        $Filename = str_replace('--', '-', $Filename);
        return $Filename;
    }
    
    public function getSpaceAction()
    {
        $select = $this->_model->select();
        $select->where('AssignID = ?', intval($this->getRequest()->getParam('house_id')));
        $select->where('Assign = "House"');
        $objImage = $this->_model->fetchRow($select);
        
        // check is image active and user has rights to see it
        if (is_object($objImage) && !$objImage->Active) {
            if (System_User::getRoleID() != System_User::getAdminRoleID()) {
                $objImage = null;
            }
        }
        
        //Set default house image if space hasn't got any
        if(is_object($objImage)){
            $this->getRequest()->setParam('defaultid',$objImage->ID);
        }
        
        $this->getAction();
    }
    
    public function getlistSpaceAction()
    {
        $this->getlistAction();
        if($this->_list->count() == 0) $this->getSpaceAction();
    }
    

}

Youez - 2016 - github.com/yon3zu
LinuXploit