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/User/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/corbizre/gotofindhomes.com/components/User/Controllers/ProfileController.php
<?php
/**
 * Documentation
 * @author evgeniy
 * @category
 * @package
 * @subpackage
 * @copyright  Copyright (c) 2005-2012 ITCrimea Ukraine Inc. (http://www.itcrimea.com)
 * @license
 */
class User_ProfileController extends System_Controller_Db_Table
{

    public function editAction()
    {
        $objProfile = $this->_model->fetchByUserId(System_User::getID());
        if(!is_object($objProfile))
            $this->_redirect($this->view->BaseUrl, array('exit' => 1));
        $tblStates = new Address_State_Table();
        $tblUsers = new User_Table();
        $objUser = $tblUsers->find($objProfile->User_ID)->current();

        if ($this->getRequest()->isPost()){
            $objUser->Email = $this->getRequest()->getParam('Email');
            $objUser->FirstName = $this->getRequest()->getParam('FirstName');
            $objUser->LastName = $this->getRequest()->getParam('LastName');

            $objProfile->Phone = $this->getRequest()->getParam('Phone');
            $objProfile->WebsiteURL = $this->getRequest()->getParam('WebsiteURL');
            $objProfile->CompanyName = $this->getRequest()->getParam('CompanyName');
            $paramContactEmail = $this->getRequest()->getParam('ContactEmail');
            $objProfile->ContactEmail = $paramContactEmail;
            $objProfile->License = $this->getRequest()->getParam('License');
            $objProfile->State = $this->getRequest()->getParam('State');
            $objProfile->City = $this->getRequest()->getParam('City');
            $objProfile->Zip = $this->getRequest()->getParam('Zip');
            $objProfile->Address = $this->getRequest()->getParam('Address');
            $objProfile->AboutMe = $this->getRequest()->getParam('AboutMe');
            $objProfile->Education = $this->getRequest()->getParam('Education');
            $objProfile->Experience = $this->getRequest()->getParam('Experience');
            $objProfile->Facebook = trim($this->getRequest()->getParam('Facebook', ''));
            $objProfile->Twitter = trim($this->getRequest()->getParam('Twitter', ''));
            $objProfile->LinkedIn = trim($this->getRequest()->getParam('LinkedIn', ''));
            
            // array structure: field name=>label
            $required_fields = array('FirstName'=>'First Name','LastName'=>'Last Name',
                                    'Email'=>'Email','State'=>'State');

            foreach($required_fields as $key => $val) {
                if (!$this->getRequest()->getParam($key))
                    $this->addErrorMessage('Please fill in required field "' . $val . '"');
            }
            
            if(!$this->isErrorMessages()){
                
                // check email
                $validator = new Zend_Validate_EmailAddress();
                if (!$validator->isValid($objUser->Email)) {
                    $this->addErrorMessage('Email "' . $objUser->Email . '" is not valid');
                } else {
                    $select = $tblUsers->select()
                            ->where('Email = ?', $objUser->Email)->where('ID <> ?', $objUser->ID)
                            ->where('(Company_ID = ?', System_Company::getID())
                            ->orWhere('Company_ID = ?)', 0);
                    if (is_object($tblUsers->fetchRow($select)))
                        $this->addErrorMessage('Sorry, email  "' . $objUser->Email . '" already taken');
                }
                
                if (!empty($objProfile->ContactEmail) && !$validator->isValid($objProfile->ContactEmail))
                    $this->addErrorMessage('Email "' . $objProfile->ContactEmail . '" is not valid');
                
                if (!$this->isErrorMessages()) {

                    if (!empty($objProfile->WebsiteURL) && substr($objProfile->WebsiteURL, 0, 4) != 'http')
                        $objProfile->WebsiteURL = 'http://' . $objProfile->WebsiteURL;
                    
                    if (!empty($objProfile->Facebook) && substr($objProfile->Facebook, 0, 4) != 'http' && strpos($objProfile->Facebook, 'facebook.com') !== false)
                        $objProfile->Facebook = 'https://' . $objProfile->Facebook;
                    
                    if (!empty($objProfile->LinkedIn) && substr($objProfile->LinkedIn, 0, 4) != 'http' && strpos($objProfile->LinkedIn, 'linkedin.com') !== false)
                        $objProfile->LinkedIn = 'http://' . $objProfile->LinkedIn;
                    
                    if (!empty($objProfile->Twitter) && substr($objProfile->Twitter, 0, 4) != 'http' && strpos($objProfile->Twitter, 'twitter.com') !== false)
                        $objProfile->Twitter = 'https://' . $objProfile->Twitter;
                    
                    $objUser->save();
                    $objProfile->save();
                    
                    if ($objProfile->countCompletedPercents() == 100 && !$objProfile->Completed) {
                        $objProfile->Completed = 1;
                        $objProfile->save();
                    }
                    
                    $this->addOkMessage('Your profile information has been successfully saved.');
                    $this->_redirect($this->view->url(array('module'=>'user', 'controller'=>'profile', 'action'=>'my', 'section'=>'member'), 'section-default', true), array('exit'=>1));

                }
            }

        }else{
            System_Session::setParam('ProfilePhoto', '');
        }
        
        $this->view->User = $objUser->toArray();
        $this->view->Profile = $objProfile->toArray();
        $this->view->states = $tblStates->fetchAllSorted()->toArray();
    }
	
    /**
     * action to get image file from request, put it to temporary folder, and respond about success
     * @author evgeniy, keeper
     */
    public function uploadImageAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        $arrResponse = array('errorCode'=>1, 'errorDesc'=>'', 'ImageUrl'=>'');

        $Photos = System_Session::getParam('ProfilePhoto' , array());
        if (!(isset($Photos['Files']) && is_array($Photos['Files']))) {
            $Photos = array('Files' => array());
        }
       
        $imageConfig = System_Components::getComponentConfig('Image');
        $Dirname = Zend_Registry::get('AppFolder').$imageConfig->Image->PathTemp;
        
        if (count($Photos['Files']) >= 1) {
            foreach($Photos['Files'] as $FieldName=>$File){
                if(is_file($Dirname.$File)) unlink($Dirname.$File);
                System_Session::setParam('ProfilePhoto', '');
            }
        }
        
        if (empty($_FILES)) {
            $arrResponse['errorDesc'] = 'Photo does not provided';
            return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
        }
        
        foreach ($_FILES as $FieldName=>$File) {
            try {
                if ($_FILES[$FieldName]['error']) {
                    if ($_FILES[$FieldName]['error'] == 4) {
                        $arrResponse['errorDesc'] = 'Please upload file';
                        return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                    } else {
                        $arrResponse['errorDesc'] = 'Can not load image file';
                        return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                    }
                }
                if (!is_dir($Dirname)) {
                    if (!mkdir($Dirname, 0755)) {
                        $arrResponse['errorDesc'] = 'Unable to create temp directory';
                        return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                    }
                }
                
                $maxSize = 1024 * 1024;
                
                $Filename = preg_replace('/([^a-zA-Z_0-9\-_.]+)/', '', $_FILES[$FieldName]['name']);
                if (!$Filename) {
                    $arrResponse['errorDesc'] = 'File name invalid';
                    return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                } elseif (strpos($Filename, '.') === false) {
                    $arrResponse['errorDesc'] = 'File extension is not defined';
                    return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                } elseif ($maxSize < filesize($_FILES[$FieldName]['tmp_name'])) {
                    $arrResponse['errorDesc'] = 'Sorry, but the file size must be no more ' .($maxSize/1024). 'kb';
                    return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                } else {
                    $extension = substr($Filename, strrpos($Filename, '.')+1);
                    $validExt = explode(',', 'jpg,png,bmp');
                    if (!in_array(strtolower($extension), $validExt)) {
                        $arrResponse['errorDesc'] = 'File extension is not correct';
                        return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                    } else {
                        $nameonly = substr($Filename, 0, strrpos($Filename, '.'));
                        $nameonly = substr($nameonly, 0, 200);
                        $Filename = $nameonly.'.'.$extension;
                        $i = 0;
                        while (file_exists($Dirname.$Filename)) {
                            $Filename = $nameonly.'_'.$i.'.'.$extension;
                            $i++;
                        }
                        if (!move_uploaded_file($_FILES[$FieldName]['tmp_name'], $Dirname.$Filename)) {
                            $arrResponse['errorDesc'] = 'Unable to move image file';
                            return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
                        }
                    }
                }
                $ImageID = 'PID'.rand(10, 9999);
                if($Photos) {
                    while (isset($Photos['Files'][$ImageID])) {
                        $ImageID = 'PID' . rand(10, 9999);
                    }
                    $Photos['Files'][$ImageID] = $Filename;
                    System_Session::setParam('ProfilePhoto', $Photos);
                }
                
                $arrResponse['ImageID'] = $ImageID;
                $arrResponse['ImageUrl'] = $this->view->BaseUrl.$imageConfig->Image->PathTemp.'/'.$Filename.'?'.time();
                $arrResponse['errorCode'] = 0;
                return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
            } catch (Exception $ex) {
                $arrResponse['errorDesc'] = $ex->getMessage(); 
                return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
            }
        }
    }
    
    /**
     * Remove profile's image from DB and Session
     */
    public function removeImageAction()
    {
    	$this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();
        $arrResponse = array('errorCode'=>0, 'errorDesc'=>'');
        
        try{
            $imageConfig = System_Components::getComponentConfig('Image');
            $Dirname = Zend_Registry::get('AppFolder').$imageConfig->Image->PathTemp.'/';

            $Photos = System_Session::getParam('ProfilePhoto');
            if (isset($Photos['Files']) && is_array($Photos['Files'])) {
                $Filename = array_shift($Photos['Files']);
                if(file_exists($Dirname.$Filename)){
                    unlink($Dirname.$Filename);
                }
                System_Session::setParam('ProfilePhoto', '');
            }

            $tblProfile = new User_Profile_Table();
            $profile_select = $tblProfile->select()->where('User_ID = ?',  System_User::getID());
            $objProfile = $tblProfile->fetchRow($profile_select);
            if(is_object($objProfile)){
                $objProfile->removeImage();
                $objProfile->Image_ID = 0;
                $objProfile->save();
            }
        }  catch (Exception $ex){
            $arrResponse['errorCode'] = 1;
        }
        
        return $this->getResponse()->setBody(Zend_Json::encode($arrResponse));
    }
    
    public function myAction()
    {
        $objUser = System_User::getUser();
        $objProfile = $this->_model->fetchByUserId($objUser->ID);
        if (is_object($objProfile))
            $this->view->Profile = $objProfile->toArray();
        $this->view->User = $objUser->toArray();
    }
    
    public function getAction()
    {
        parent::getAction();
        if($this->_object->User_ID != System_User::getID()){
           $this->_object->Hits += 1;
           $this->_object->save();
        }
    }
    
    public function agentBlockAction()
    {
    	$limit = $this->getRequest()->getParam('results', 3);
    	$paramState = $this->getRequest()->getParam('state');
    	$agents = array();
    	$stateName = '';
    	
    	if($paramState){
    		$select = $this->_model->select();
    		$select->where('State = ?', $paramState);
    		$select->order('Order ASC');
    		$select->order('LastName ASC');
    		$select->limit($limit);

    		$rows = $this->_model->fetchAll($select);
    		
    		$agents = $rows->toArray();
    		$stateTable = new Address_State_Table();
    		$stateName = $stateTable->getNameByShort($paramState);
    	}
    	
    	$this->view->agentsList = $agents;
    	$this->view->State = $stateName ? $stateName : $paramState;
    }
    
    public function agentsAction()
    {
    	$this->getRequest()->setParam('sort','LastName');
        $this->getRequest()->setParam('dir','ASC');
        $this->getRequest()->setParam('results', $this->getRequest()->getParam('results', 20));
        
        $this->_select->where('PrimaryRole = ?', 'Broker/Agent');
        $this->_selectCount->where('PrimaryRole = ?', 'Broker/Agent');
        
    	parent::getlistAction();
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit