Hacked By AnonymousFox

Current Path : /home/missmand/public_html/learning/admin/lib/class/
Upload File :
Current File : /home/missmand/public_html/learning/admin/lib/class/Tool.class.php

<?php

	class Tool {


		/******************************************/
		/* Verifier si l'utilisateur est connecté */
		/******************************************/
		public static function verif_connect(){

			if($_SESSION['utilisateur']['id'] == 'visiteur')
				header('location:'.BASEADMIN.'deco.php');

		}


		/*************************/		
		/* Affichage des erreurs */
		/*************************/
		public static function afficheErreur ($erreur = array()) {
	
			$affiche = '';
			foreach($erreur as $element){
				$affiche .= $element.'<br />';
			}

			return $affiche;

		}


		/***********************************/
		/*   Retourne le script en cours   */
		/***********************************/
		public static function url() {

			$url = $_SERVER['PHP_SELF'];
			$url = explode('/',$url);
	
			return end($url);

		}


		/*****************************************************/
		/*   Coupe une chaine de caractére et ajoute "..."   */
		/*****************************************************/
		public static function tronquer($description,$max_caracteres){
			
			if (strlen($description)>$max_caracteres){    

				$description = substr($description, 0, $max_caracteres);
				$position_espace = strrpos($description, " "); 
				
				if($position_espace == false)
					$position_espace = strrpos($description, "-");

				$description = substr($description, 0, $position_espace);    
				$description = $description."...";

			}
			
			return $description;

		}


		/***************************************************/
		/*   Récupération d'une argument en GET numéraire  */
		/***************************************************/
		public static function getId($get,$redirection = NULL){

		    if(!isset($get) || empty($get) || !is_numeric($get) ){
		       	if($redirection != NULL){
		        	header('location:'.$redirection);
		        	die();
		    	}
		    	else{
		    		die('Erreur identifiant');
		    	}
		    }else
		        return $get;

		}


		/*********************************************************/
		/*   Récupération d'une argument en GET alphanumérique   */
		/*********************************************************/
		public static function getString($get,$redirection = NULL){

		    if(!isset($get) || empty($get) ){
		       	if($redirection != NULL){
		        	header('location:'.$redirection);
		        	die();
		    	}
		    	else{
		    		die('Erreur identifiant');
		    	}
		    }else
		        return $get;
		        
		}


		/***********************/
		/*  Nettoyer une url   */
		/***********************/
		static public function slug($url){ 

		  $url = preg_replace('~[^\\pL\d]+~u', '-', $url);
		  $url = trim($url, '-');
		  $url = iconv('utf-8', 'us-ascii//TRANSLIT', $url);
		  $url = strtolower($url);
		  $url = preg_replace('~[^-\w]+~', '', $url);
		  return $url;

		}



		/************************************************/
		/* Page en cours ( ajout de la classe current ) */
		/************************************************/	
		public static function currentMenu ($pages){

			$current  = self::url();
			if(in_array($current, $pages)){
				echo 'current';
			}else
				echo '';

		}

		public static function currentSousMenu ($url){

			$current = self::url();
			if($current == $url) 
				echo 'current';
			else
				echo '';

		}


		public static function initPagination($nombre){

		    $page = 1;
		    $debut = 0;
		    if (isset($_GET['page'])) {
		        $page = $_GET['page'];
		        $debut = $page-1;
		        $debut *=10;
		    }
			
		}


		/****************/	
		/*  Pagination  */
		/****************/
		public static function pagination ($requete,$url,$nombre,$page,$bdd){

			echo'<ul>';

		        $precedente = $page-1;
		        if ($precedente > 0){
		            echo ('<li>');
		                echo ('<a href="'.BASEADMIN.$url.'.php?page='.$precedente.'"><span>Précédente</span></a>');
		            echo('</li>');
		        }


		        $sql = $bdd->query($requete);
		        $data = $sql->fetch(); 
		        $count = $data['total'];
		        $count = ceil($count / $nombre); 


		        for ($i=$page-4; $i<= $page+4; $i++){

		            if (($i > 0 )&&($i < $count+1)){
		                            
		                if ($i == $page){
		                    echo('<li class="page active">');
		                        echo('<p>'.$i.'</p>');
		                    echo('</li>');		
		                }else{
		                     echo('<li>');
		                         echo('<a href="'.BASEADMIN.$url.'.php?page='.$i.'">'.$i.'</a>');
		                     echo('</li>');
		                 }
		            }
		        }


		        $suivante = $page+1;
		        if ($suivante <= $count){
		            echo ('<li>');
		                echo ('<a href="'.BASEADMIN.$url.'.php?page='.$suivante.'"><span>Suivante</span></a>');
		            echo('</li>');
		        }

	        echo'</ul>';

		}


		/* Initialisation de la pagination */


		/***********************************/	
		/*  Compte des caractères restant  */
		/***********************************/
		public static function totalLimit($string, $limit){

			$total = $limit - strlen($string);
			return $total;

		}


	}



?>

Hacked By AnonymousFox1.0, Coded By AnonymousFox