%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/devcapijob/public_html/liberary/
Upload File :
Create Path :
Current File : /home/devcapijob/public_html/liberary/factory.php

<?php



/**



* @version		1



* @package		yassir



* @copyright	Copyright (C) 2011 Open Source Matters. All rights reserved.



* @license		sharware



*/











//protection contre accée direct



defined('PATH_BASE') or die( 'Restricted access' );







class Factory{



	



	



	function build_module($module,$param=NULL){



		if(file_exists(MDP.$module.DS.'index.php')){



			require_once ( MDP.$module.DS.'index.php' );



			$classname=$module.'Module';



			$object=new $classname;



			$data=&$object->execute($param);



			$this->set_javascript($object->js);



			$this->set_css($object->css);



			return $data;



		}



		else{



			return 'Module introuvable';



			}

			



	}



	



	



	



	function build_component($component){



		if(file_exists(CMP.$component.DS.'index.php')){



			require_once ( CMP.$component.DS.'index.php' );



			$classname=$component.'Component';



			$object=new $classname;



			$data=&$object->execute($this->_instance);



			$this->set_principal_params($object->_params_array);



			return $data;



			



		}



		else{



			return 'Composant introuvable';



			}



	}



	



	function verif_reecriture_langue(){



		Request::setVar('lang','get','fr');



		$url=parse_url($_SERVER['REQUEST_URI']);



		$path=(DIR_BASE!='')? preg_replace('#/'.DIR_BASE.'#i','',$url['path']) : $url['path'];



		if(preg_match('#^(\w{2})/#i',$path,$lang))



				{



					$path = str_replace($lang[0], '', $path);



					$uri['lang'] = $lang[1];



					Request::setVar('lang','get',$lang[1]);



				}



		if($suffix = pathinfo($path, PATHINFO_EXTENSION))



				{



					$path = str_replace('.'.$suffix, '', $path);



					$uri['format'] = $suffix;



				}



		if($file = pathinfo($path,PATHINFO_FILENAME))



				{



					$path = str_replace('/'.$file, '', $path);



					$uri['file'] = $file;



					Request::setVar('alias','get',$file);



				}



		if($parent = pathinfo($path,PATHINFO_BASENAME))



				{



					if($file!=$parent){



						$path = str_replace('/'.$parent, '', $path);



						$uri['parent'] = $parent;



						}



				}



				



		$path = trim($path,'/');



		if($path!=$parent){



			$uri['dir']=$path;



		}



		$GLOBALS['info_URI']=$uri;



		



		if(!isset($_GET['lang'])){



			



			if(S_config::$reecriture ){



				Request::setVar('id_lang','get','1');



				$this->goHome();



				}



			}



		elseif(Request::get('lang')!=null){



			Request::setVar('id_lang','get','1');

 //  var_dump($GLOBALS['info_URI']);

			if(S_config::$reecriture ){



				if(!isset($_GET['alias'])){

					$this->goHome();

					}

        elseif($GLOBALS['info_URI']['parent']=="annonce"){
        	 Request::setVar('type','get','resultat');
				   Request::setVar('id_com','get','25');
           Request::setVar('id_item','get','7878');
           //var_dump($_REQUEST);
        }
        elseif($GLOBALS['info_URI']['parent']=="annonceur"){
        	 Request::setVar('type','get','resultat');
				   Request::setVar('id_com','get','25');
           Request::setVar('id_item','get','7877');
           Request::setVar('annonceur','get',''.$_GET['alias'].'');
           //var_dump($_REQUEST);
        }elseif($GLOBALS['info_URI']['parent']=="rubrique"){
        	 Request::setVar('type','get','resultat');
				   Request::setVar('id_com','get','25');
           Request::setVar('id_item','get','913');
  
           //var_dump($_REQUEST);
         }elseif($GLOBALS['info_URI']['parent']=="regions"){
        	 Request::setVar('type','get','resultat');
				   Request::setVar('id_com','get','25');
           Request::setVar('id_item','get','4242');
           Request::setVar('regions_alias','get',''.$_GET['alias'].'');
           //var_dump($_REQUEST);
        }elseif($GLOBALS['info_URI']['file']=="resultat"){
			Request::setVar('type','get','resultat');
			Request::setVar('id_com','get','25');
	        Request::setVar('id_item','get','999');

		}else{

            //var_dump($_REQUEST);exit;

					$this->setGets(Request::get('alias'));



					}



				



				}



						



			}



		}



	



	function goHome(){



		$accueil=Model::getAccueil();



		Request::setVar('alias','get',$accueil[1]);



		$this->setGets(Request::get('alias'));



		}



	



	function setGets($alias){



		 $query='SELECT * 



				FROM  #_alias



				WHERE  alias =  "'.$alias.'"';



		$data=DB::do_query($query);



		if($data!='' && $data->RowCount()>0){



			$data= $data->fetch(PDO::FETCH_ASSOC);


       
			extract($data);


//var_dump($data);exit;
		



				Request::setVar('type','get',$this->getComName($id_com));



				Request::setVar('id_com','get',$id_com);



				if($id!=0){



				Request::setVar('id','get',$id);



				}



				if($id_item!=0){



				Request::setVar('id_item','get',$id_item);



				}



	



			}



		elseif($alias=='rechercher'){



			Request::setVar('type','get','rechercher');}



		else{



			//$this->goHome();
              header('Location:'.URL_BASE.'erreur_404.html');


			}



		}



	function getComName($id){



		$query='SELECT  com_class 



				FROM  #_composants 



				WHERE  id_com ='.$id.'



				AND  etat =1';



		$data=DB::do_query($query);



		if($data!='' && $data->RowCount()>0){



			$data=$data->fetch(PDO::FETCH_ASSOC);



			return $data['com_class'];



			}



		



		}



		



		



function fctredimimage($W_max, $H_max, $rep_Dst, $img_Dst, $rep_Src, $img_Src) {









 // ------------------------------------------------------------------



 $condition = 0;



 // Si certains parametres ont pour valeur '' :



   if ($rep_Dst == '') { $rep_Dst = $rep_Src; } // (meme repertoire)



   if ($img_Dst == '') { $img_Dst = $img_Src; } // (meme nom)



 // ------------------------------------------------------------------



 // si le fichier existe dans le répertoire, on continue...



 if (file_exists($rep_Src.$img_Src) && ($W_max!=0 || $H_max!=0)) { 



   // ----------------------------------------------------------------



   // extensions acceptees : 



   $ExtfichierOK = '" jpg jpeg png"'; // (l espace avant jpg est important)



   // extension fichier Source



   $tabimage = explode('.',$img_Src);



   $extension = $tabimage[sizeof($tabimage)-1]; // dernier element



   $extension = strtolower($extension); // on met en minuscule



   // ----------------------------------------------------------------



   // extension OK ? on continue ...



   if (strpos($ExtfichierOK,$extension) != '') {



      // -------------------------------------------------------------



      // recuperation des dimensions de l image Src



      $img_size = getimagesize($rep_Src.$img_Src);



      $W_Src = $img_size[0]; // largeur



      $H_Src = $img_size[1]; // hauteur



      // -------------------------------------------------------------



      // condition de redimensionnement et dimensions de l image finale



      // -------------------------------------------------------------



      // A- LARGEUR ET HAUTEUR maxi fixes



      if ($W_max != 0 && $H_max != 0) {



         $ratiox = $W_Src / $W_max; // ratio en largeur



         $ratioy = $H_Src / $H_max; // ratio en hauteur



         $ratio = max($ratiox,$ratioy); // le plus grand



         $W = $W_Src/$ratio;



         $H = $H_Src/$ratio;   



         $condition = ($W_Src>$W) || ($W_Src>$H); // 1 si vrai (true)



      }      // -------------------------------------------------------------



      // B- HAUTEUR maxi fixe



      if ($W_max == 0 && $H_max != 0) {



         $H = $H_max;



         $W = $H * ($W_Src / $H_Src);



         $condition = $H_Src > $H_max; // 1 si vrai (true)



      }



      // -------------------------------------------------------------



      // C- LARGEUR maxi fixe



      if ($W_max != 0 && $H_max == 0) {



         $W = $W_max;



         $H = $W * ($H_Src / $W_Src);         



         $condition = $W_Src > $W_max; // 1 si vrai (true)



      }



      // -------------------------------------------------------------



      // on REDIMENSIONNE si la condition est vraie



      // -------------------------------------------------------------



      // Par defaut : 



	  // Si l'image Source est plus petite que les dimensions indiquees :



	  // PAS de redimensionnement.



	  // Mais on peut "forcer" le redimensionnement en ajoutant ici :



	  // $condition = 1;



      if ($condition == 1) {



         // ----------------------------------------------------------



         // creation de la ressource-image "Src" en fonction de l extension



         switch($extension) {



         case 'jpg':



         case 'jpeg':



           $Ress_Src = imagecreatefromjpeg($rep_Src.$img_Src);



           break;



         case 'png':



           $Ress_Src = imagecreatefrompng($rep_Src.$img_Src);



           break;



         }



         // ----------------------------------------------------------



         // creation d une ressource-image "Dst" aux dimensions finales



         // fond noir (par defaut)



         switch($extension) {



         case 'jpg':



         case 'jpeg':



           $Ress_Dst = imagecreatetruecolor($W,$H);



           break;



         case 'png':



           $Ress_Dst = imagecreatetruecolor($W,$H);



           // fond transparent (pour les png avec transparence)



           imagesavealpha($Ress_Dst, true);



           $trans_color = imagecolorallocatealpha($Ress_Dst, 0, 0, 0, 127);



           imagefill($Ress_Dst, 0, 0, $trans_color);



           break;



         }



         // ----------------------------------------------------------



         // REDIMENSIONNEMENT (copie, redimensionne, re-echantillonne)



         imagecopyresampled($Ress_Dst, $Ress_Src, 0, 0, 0, 0, $W, $H, $W_Src, $H_Src); 



         // ----------------------------------------------------------



         // ENREGISTREMENT dans le repertoire (avec la fonction appropriee)



         switch ($extension) { 



         case 'jpg':



         case 'jpeg':



           imagejpeg ($Ress_Dst, $rep_Dst.$img_Dst);



           break;



         case 'png':



           imagepng ($Ress_Dst, $rep_Dst.$img_Dst);



           break;



         }



         // ----------------------------------------------------------



         // liberation des ressources-image



         imagedestroy ($Ress_Src);



         imagedestroy ($Ress_Dst);



      }



      // -------------------------------------------------------------



   }



 }



// 	---------------------------------------------------------------



 // si le fichier a bien ete cree



 if ($condition == 1 && file_exists($rep_Dst.$img_Dst)) { return true; }



 else { return false; }}



 



function randomname($lenth =5) {







    $aZ09 = range(0, 9);



    $out ='';



    for($c=0;$c < $lenth;$c++) {



       $out .= $aZ09[mt_rand(0,count($aZ09)-1)];



    }



    return $out;



	} 

		





		



}



?>

Zerion Mini Shell 1.0