403Webshell
Server IP : 213.186.33.2  /  Your IP : 216.73.216.39
Web Server : Apache
System : Linux webm005.cluster102.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : symetry ( 21728)
PHP Version : 8.2.31
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/symetry/www/ARCHIVES/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/symetry/www/ARCHIVES/application/controllers/ProjectsController.php
<?php 
/** @see Zend_Controller_Action */ 
require_once 'Zend/Controller/Action.php'; 
 
class ProjectsController extends Zend_Controller_Action 
{	
		function preDispatch()
		{
			$auth = Zend_Auth::getInstance();
			
			if (!$auth->hasIdentity()) {
				$this->view->identified = false;
				
				if (!$auth->hasIdentity()) {
					$this->_redirect('Auth/Login');
				}
			}
			else
			{
				$this->view->identified = true;
			}
		}
    
    public function indexAction() 
    {    	
    	$projects = new Projects();
    	$this->view->projects = $projects->fetchAll(null, 'pro_name ASC');
    } 
    
    public function addAction() 
    { 
    	$this->view->title = Zend_registry::get('translate')->_('AddProject');

			$form = new FormProjects();
			$form->submit->setLabel(Zend_registry::get('translate')->_('Add'));
			$this->view->form = $form;
			
			if ($this->_request->isPost()) {
				$formData = $this->_request->getPost();
			
				if ($form->isValid($formData)) {
					$project = new Projects();
					$row = $project->createRow();
					$row->pro_name = $form->getValue('pro_name');
					$row->pro_date = $form->getValue('pro_date');
					$row->pro_long_description = $form->getValue('pro_long_description');
					$row->pro_cat_id = $form->getValue('pro_cat_id');
					$row->save();

					$this->_redirect('/Projects/');
				} else {
					$form->populate($formData);
				}
			}
    } 
    
    public function delAction() 
    { 
    	$this->view->title = Zend_registry::get('translate')->_('DelProject');
    	
    	// confirmation has been done
    	if ($this->_request->isPost()) {
				$id = (int)$this->_request->getPost('id');
				$del = $this->_request->getPost('del');
				if ($del == Zend_registry::get('translate')->_('Yes') && $id > 0) {
					$project = new Projects();
					$where = 'pro_id = ' . $id;
					$project->delete($where);
				}
				
				$this->_redirect('/Projects/');
			
			// confirmation has to be done
			} else {
				
				$id = (int)$this->_request->getParam('id');
				if ($id > 0) {
					$project = new Projects();
					$this->view->project = $project->fetchRow('pro_id='.$id);
				}
			}
    }
    
    public function fileuploadcallbackAction(){
    	// disable layouts for this action:
      $this->_helper->layout->disableLayout();
      

      if ($this->_request->isPost() && isset($_FILES['fileToUpload']))
			{
				$filename = basename($_FILES['fileToUpload']['name']);
				$max_file_size = 1000000;
				$size = filesize($_FILES['fileToUpload']['tmp_name']);
				$extensions = array('.jpg', '.jpeg');
				$file_extension = strtolower(strrchr($_FILES['fileToUpload']['name'], '.')); 
				
				$this->view->json = array();
				$this->view->json['msg'] = '';
				$this->view->json['error'] = '';
				$this->view->json['images'] = array();
					
				if(in_array($file_extension, $extensions) && $size < $max_file_size && isset($_FILES['fileToUpload']['tmp_name']))
				{				     
				     try
				     {
					     $dir = Zend_registry::get('root').'public/images/projects/';
					     $new_filename = md5($_FILES['fileToUpload']['tmp_name']).$file_extension;
					     
					     list($x, $y) = getimagesize($_FILES['fileToUpload']['tmp_name']);
					     
					     if($x <= 800 && $y <= 800) // size check
					     {
						     if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $dir.$new_filename)) //Si la fonction renvoie TRUE, c'est que �a a fonctionn�...
						     {
											if(isset($_GET['p']))
											{									
												$db = Zend_Registry::get('db');
                        
                        $stmt = $db->query('SELECT max(img_position) as max_image_position FROM images WHERE img_pro_id='.(int) $_GET['p']);
					              $obj = $stmt->fetchObject();
                        
                        // save new file
												$image = new Images();
												$row = $image->createRow();
												$row->img_pro_id = (int) $_GET['p'];
												$row->img_filename = $new_filename;
												$row->img_position = $obj->max_image_position + 1;
												$row->save();
												
												$result = $this->generateThumb($dir, $new_filename);
												
												if($result == true)
												{
													$imagelist = new Images();
													$select = $imagelist->select()
                          ->where('img_pro_id = ?', (int) $_GET['p'])
                          ->order(array('img_position ASC'));
							    				$imagesResult= $imagelist->fetchAll($select);
							    				
							    				foreach($imagesResult as $img)
							    				{
							    					$this->view->json['images'][] = $img->img_filename;	
							    					$this->view->json['img_id'][] = $img->img_id;
							    					$this->view->json['img_position'][] = $img->img_position;
							    				}
													
													$this->view->json['msg'] = 'upload succeeded\r\n';
												}else{
													$this->view->json['error'] = 'thumnail generation failed. file is too big\r\n';
												}
											}
											else
											{
												$this->view->json['error'] = 'not saved in database\r\n';
											}
						     }
						     else //Sinon (la fonction renvoie FALSE).
						     {
						          $this->view->json['error'] = 'move_uploaded_file failed\r\n';
						     }
						 }
						 else
						 {
						 	 $this->view->json['error'] = 'upload failed : file is too big\r\n';
						 }
					 }
					 catch (Exception $e) {
					 	$this->view->json['error'] = stripslashes ($e -> getMessage());
					 }
				}
				else
				{
				     if(!in_array($file_extension, $extensions)) //
							{
							     $this->view->error .= 'file is not a jpeg : '.htmlentities($file_extension).'\r\n';
							}
							
							if($size > $max_file_size)
							{
							     $this->view->error .= 'file is too heavy\r\n';
							}
							
							if(!is_uploaded_file($_FILES['fileToUpload']['tmp_name']))
							{
									$this->view->error .= 'filename provided is not an uploaded file\r\n';
							}	
				}
			}
    }
    
    public function modAction() 
    {    	
    	$this->view->title = Zend_registry::get('translate')->_('ModProject');
			
			$form = new FormProjects();
			$form->submit->setLabel(Zend_registry::get('translate')->_('Save'));
			
			$this->view->form = $form;
			if ($this->_request->isPost()) {
				$formData = $this->_request->getPost();
				
				if ($form->isValid($formData)) {
					$project = new Projects();
					$id = (int)$form->getValue('pro_id');					
					$row = $project->fetchRow('pro_id='.$id);
					
					$where = 'pro_id = ' . $id;
					$row->pro_name = d($form->getValue('pro_name'));
					$row->pro_date = $form->getValue('pro_date');
					$row->pro_long_description = d($form->getValue('pro_long_description'));
					$row->pro_cat_id = $form->getValue('pro_cat_id');
					$row->save($where);
					
					$this->_redirect('/Projects/Index');
				} else {
					$form->populate($formData);
				}
				
				} else {
					// L'id du projet est attendu dans $params['id']
					$id = (int)$this->_request->getParam('id', 0);
					if ($id > 0) {
						$project = new Projects();
						$project = $project->fetchRow('pro_id='.$id);
						$form->populate($project->toArray());
						
						// get images for this project
						$images = new Images();
						$select = $images->select()->where('img_pro_id = ?', (int) $id)->order(array('img_position ASC'));
    				$this->view->images = $images->fetchAll($select);
    				$this->view->pro_id = $id;
					}
				}
    } 
    
    public function deletepictureAction()
    {
    		// disable layouts for this action:
      	$this->_helper->layout->disableLayout();
      	
      	$id = (int) $this->_request->getParam('id', 0);
				if ($id > 0) {
					$db = Zend_Registry::get('db');
					
					// get images for this project
	    		$stmt = $db->query('SELECT img_pro_id, img_position FROM images WHERE img_id='.(int) $id);
					$obj = $stmt->fetchObject();
					
					$image = new Images();
					$where = 'img_id = ' . $id;
					$image->delete($where);
					
          $result = $db->getConnection()->exec('UPDATE images SET img_position = img_position - 1 WHERE img_pro_id ='.$obj->img_pro_id.' AND img_position >= '.$obj->img_position);
					
					$this->_redirect('/Projects/mod/id/'.$obj->img_pro_id);
				}
				else
				{
					$this->_redirect('/Projects/');
				}
    }
    
    public function tagpictureAction()
    {
    		$id = (int) $this->_request->getParam('id', 0);
				if ($id > 0) {
					
					$db = Zend_Registry::get('db');
					
					if ($this->_request->isPost())
					{				
						
						if(isset($_POST['tag']))
						{
							$currentTag = array();
							
							if(isset($_POST['currentTag']))
							{
								$currentTag = $_POST['currentTag'];
							}							
							
							$added = array_diff($_POST['tag'],$currentTag);
							$deleted = array_diff($currentTag,$_POST['tag']);

							if(count($added) > 0)
							{
								$data = '';
								
								foreach($added as $new)
								{
									$data .= '('.(int)$id.','.(int)$new.'),';
								}
								$data = substr($data, 0, -1); 
								
								echo 'INSERT INTO images_tags (imtg_img_id,imtg_tag_id) VALUES '.$data;
								
								$stmt = $db->query('INSERT INTO images_tags (imtg_img_id,imtg_tag_id) VALUES '.$data);
								
								try {
								     $obj = $stmt->execute();
								} catch (Zend_Db_Exception $e) {
									echo 'exception';
								} 
								
							}
							
							if(count($deleted) > 0)
							{
								foreach($deleted as $old)
								{
									$stmt = $db->query('DELETE FROM images_tags WHERE imtg_img_id = '.(int)$id.' AND imtg_tag_id = '.(int)$old);
									$obj = $stmt->execute();
								}
							}
						}
						else
						{
								$stmt = $db->query('DELETE FROM images_tags WHERE imtg_img_id = '.(int)$id);
								$obj = $stmt->execute();
						}
						
						// get images for this project
		    		$stmt = $db->query('SELECT img_pro_id FROM images WHERE img_id='.(int) $id);
						$obj = $stmt->fetchObject();
						
						$this->_redirect('/Projects/mod/id/'.$obj->img_pro_id);
					}
					
					// get images for this project
	    		$stmt = $db->query('SELECT * FROM images WHERE img_id='.(int) $id);
					$this->view->image = $stmt->fetchObject();
					
					$stmt = $db->query('SELECT tag_id, tag_name, imtg_img_id FROM tags LEFT JOIN images_tags ON ( imtg_tag_id = tag_id AND imtg_img_id = '.(int) $id.' )');
					$this->view->tags = $stmt->fetchAll();
				}
				else
				{
					$this->_redirect('/Projects/');
				}
    }
    
    public function changepicturepositionAction()
    {
    		// disable layouts for this action:
      	$this->_helper->layout->disableLayout();
      	
      	$params = $this->_request->getParams();
      	$img_id = (int) $params['img_id'];
      	$new_pos = (int) $params['new_pos'];
      	
				if ($img_id > 0 && $new_pos > 0) {
					$db = Zend_Registry::get('db');
					$logger = Zend_Registry::get('logger');
					
					// get images for this project
	    		$stmt = $db->query('SELECT img_pro_id,img_position FROM images WHERE img_id='.(int) $img_id);
					$obj = $stmt->fetchObject();
									
					// Update the image position
					$result = $db->query('UPDATE images SET img_position = '.$new_pos.' WHERE img_id ='.$img_id);
					
					// Update other image from project to set default = 0
					if($obj->img_position > $new_pos)
					{
            $result = $db->query('UPDATE images SET img_position = img_position + 1 WHERE img_pro_id ='.$obj->img_pro_id.' AND img_position >= '.$new_pos.' AND img_id != '.$img_id.' AND img_position < '.$obj->img_position);
          }
          else
          {
            $result = $db->query('UPDATE images SET img_position = img_position - 1 WHERE img_pro_id ='.$obj->img_pro_id.' AND img_position > '.$obj->img_position.' AND img_id != '.$img_id.' AND img_position <= '.$new_pos);
          }
					
					$this->_redirect('/Projects/mod/id/'.$obj->img_pro_id);
				}
				else
				{
					$this->_redirect('/Projects/');	
				}
    }
    
    /*
    public function defaultpictureAction()
    {
    		// disable layouts for this action:
      	$this->_helper->layout->disableLayout();
      	
      	$id = (int) $this->_request->getParam('id', 0);
				if ($id > 0) {
					$db = Zend_Registry::get('db');
					
					// get images for this project
	    		$stmt = $db->query('SELECT img_pro_id FROM images WHERE img_id='.(int) $id);
					$obj = $stmt->fetchObject();
									
					// Update other image from project to set default = 0
					$data = array('img_default' => '0');
					$n = $db->update('images', $data, 'img_pro_id = ' . $obj->img_pro_id);
					
					// Update other image from project to set default = 0
					$data = array('img_default' => '1');
					$n = $db->update('images', $data, 'img_id = ' . $id);
					
					$this->_redirect('/Projects/mod/id/'.$obj->img_pro_id);
				}
				else
				{
					$this->_redirect('/Projects/');	
				}
    }*/
    
    /*private function checkImageDefault($proId)
    {
    	$db = Zend_Registry::get('db');
					
			// get images for this project
	    $stmt = $db->query('SELECT count(*) as counter FROM images WHERE img_pro_id='.(int) $proId);
			$obj = $stmt->fetchObject();
					
			if($obj->counter == 1)
			{
				$n = $db->update( 'images', array('img_default' => 1), 'img_pro_id ='.(int) $proId);
			}else if($obj->counter > 1 ){
				 $stmt = $db->query('SELECT count(*) as counter FROM images WHERE img_pro_id='.(int) $proId.' AND img_default = 1');
				 $obj = $stmt->fetchObject();
				 
				 if($obj->counter == 0)
				 {			 		
				 		$stmt = $db->query('UPDATE images SET img_default = 1 WHERE img_pro_id = '.(int) $proId.' ORDER BY img_id DESC LIMIT 1');
						$obj = $stmt->execute();
				 }
			}
    }*/
    
    private function generateThumb($dir, $filename)
    {
	   		try {
		   		list($x, $y) = getimagesize($dir.$filename);
		   		
		   		if($x > $y){
		   				// Y is the smallest dimension
							$thumbY = Zend_registry::get('config')->thumb->max_size_y;
							$thumbX = round($thumbY * ($x/$y));
							$imgX = Zend_registry::get('config')->zoom->max_size_x;
							$imgY = round($imgX / ($x/$y));
					}else{
							// X is the smallest dimension
							$thumbX = Zend_registry::get('config')->thumb->max_size_x;
							$thumbY = round($thumbX * ($y/$x));
							
							$imgY = Zend_registry::get('config')->zoom->max_size_y;
							$imgX = round($imgY / ($y/$x));
					}
					
					//echo 'x'.$x.' y'.$y.' thumbx '.$thumbX.' thumby'.$thumbY.' imgx'.$imgX.' imgy'.$imgY;
		   		
		   		$src=ImageCreateFromJpeg($dir.$filename);
		   		
		   		// Create the thumbnail
		   		$dst_thumb_rectangular = imagecreatetruecolor($thumbX, $thumbY);
		   		$dst_thumb_square = imagecreatetruecolor(Zend_registry::get('config')->thumb->max_size_x, Zend_registry::get('config')->thumb->max_size_y);
		   		
		   		// Step 1 : resize to the appropriate rectangle before cut to square
		   		imagecopyresampled($dst_thumb_rectangular, $src, 0, 0, 0, 0, $thumbX, $thumbY, $x, $y);
		   		
		   		imagecopy($dst_thumb_square, $dst_thumb_rectangular, 0, 0, 0, 0, Zend_registry::get('config')->thumb->max_size_x, Zend_registry::get('config')->thumb->max_size_y);
		   		
		   		// Save the quare thumbnail
		   		ImageJpeg($dst_thumb_square, $dir.'/thumbs/thumb_'.$filename);
		   		
		   		// Free memory
		   		imagedestroy($dst_thumb_rectangular);
		   		imagedestroy($dst_thumb_square);
		   		
		   		// Create the zoom image
		   		$dst_zoom = imagecreatetruecolor($imgX, $imgY);
		   		
		   		// Resize the zoom iamge
		   		imagecopyresampled($dst_zoom, $src, 0, 0, 0, 0, $imgX, $imgY, $x, $y);						
		   		
		   		// Save the zoom image
		   		ImageJpeg($dst_zoom, $dir.'/'.$filename);
		   		
		   		// Free memory
		   		imagedestroy($src);
		   		imagedestroy($dst_zoom);
		   		
		   		return true;
		   	}
				catch (Exception $e) {
				  return false;
				}
    }
} 

Youez - 2016 - github.com/yon3zu
LinuXploit