%PDF- %PDF-
Direktori : /home/devcapijob/public_html/gestion/liberary/ |
Current File : /home/devcapijob/public_html/gestion/liberary/model.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 Model{ function nombre_annonce(){ $mysql ="select DISTINCT a.id_annonce FROM `#_annonce` AS `a` Inner Join `#_annonceur` ON `a`.`id_annonceur` = `#_annonceur`.`id_annonceur` Left Join `#_annonce_departement` ON `a`.`id_annonce` = `#_annonce_departement`.`id_annonce` Left Join `#_annonce_domaine` ON `a`.`id_annonce` = `#_annonce_domaine`.`id_annonce` where 1=1 AND `#_annonceur`.`site`<> 5 AND a.etat=1 and a.active=0 GROUP BY a.id_annonce order by date_misejour"; $cout_nb=DB::get_count($mysql); return $cout_nb; } function nombre_annonceyaka(){ $mysql ="select DISTINCT a.id_annonce FROM `#_annonce` AS `a` Inner Join `#_annonceur` ON `a`.`id_annonceur` = `#_annonceur`.`id_annonceur` Left Join `#_annonce_departement` ON `a`.`id_annonce` = `#_annonce_departement`.`id_annonce` Left Join `#_annonce_domaine` ON `a`.`id_annonce` = `#_annonce_domaine`.`id_annonce` where 1=1 AND `#_annonceur`.`site`= 5 AND a.etat=1 and a.active=0 GROUP BY a.id_annonce order by date_misejour"; $cout_nb=DB::get_count($mysql); return $cout_nb; } function formatdatefr($date){ $date = explode('-',$date); $datenew = $date['2'].'-'.$date['1'].'-'.$date['0']; return $datenew; } function formatdatefr_table($date){ if($date!=""){ $date = explode('-',$date); $datenew = $date['2'].'/'.$date['1'].'/'.$date['0']; }else{ $datenew =""; } return $datenew; } function formatdatefrtime($date){ $date = explode('-',$date); $time = explode(' ',$date['2']); $datenew = $time['0'].'-'.$date['1'].'-'.$date['0'].' '.$time['1']; return $datenew; } function formatdatebase($date){ $date = explode('-',$date); $datenew = $date['2'].'-'.$date['1'].'-'.$date['0']; return $datenew; } function date_base($date){ if($date!=""){ $date = explode('/',$date); $datenew = $date['2'].'-'.$date['1'].'-'.$date['0']; }else{ $datenew =''; } return $datenew; } function getlisteregion($regions){ $regions = explode(',',$regions); $nb= count($regions); $i=1; foreach($regions as $key=>$value){ $query='SELECT * FROM #_region where id_region ="'.$value.'"'; $datas=DB::do_query($query); if($i!=$nb){$virgule = ', ';}else{$virgule = '';} while($row = mysqli_fetch_assoc($datas)){ $region .= $row['nom'].$virgule; } $i++; } return $region; //var_dump($region); } function liste_c_langue(){ $langue = array(); $query = "select * from #_c_langue order by c_langue"; $hs = DB::do_query($query); while($rs = mysqli_fetch_array($hs)){ array_push($langue,$rs); } return $langue; } function liste_commercial($id_com=''){ $rqt_com=($id_com!='')?' where id_commercial="'.$id_com.'"':''; $array = array(); $query ="SELECT * from #_commercial ".$rqt_com." ORDER BY nom_com ASC"; $data = DB::do_query($query); while($result = mysqli_fetch_array($data)){ array_push($array,$result); } return $array; } function get_type_poste($genre=NULL){ $query='SELECT * FROM #_type_poste '; $query .=(!is_null($genre))?' WHERE genre="'.$genre.'"' : ''; $query .= ' ORDER BY type_poste ASC'; $con = DB::connect(); $mc = new Memcached(); $mc->addServer("localhost", 11211); $mcd = array(); $querykey = "KEY" . md5(DB::query($query)); $mcd = $mc->get($querykey); if($mcd===false){ $data=$con->query(DB::query($query)); //$data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } $mcd = $array; $mc->set($querykey,serialize($mcd),1000); $type_poste =$mcd; }else{ $type_poste = unserialize($mcd); } return $type_poste; } function getdoamine($id_domaine=''){ $rqt_dom=($id_domaine!='')?' and id_domaine="'.$id_domaine.'"':''; $query='SELECT * FROM #_domaine where parent = 0 '.$rqt_dom.''; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } return $array; } function type_annonce_order_search(){ $query='SELECT * FROM #_type_annonce order by order_search ASC'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } return $array; } function getAllDoaminetest($type=NULL){ if($type!=''){ $sql = " and id_type='".$type."'"; } $mcd = array(); $query='SELECT cap_domaine.id_domaine, cap_domaine.id_type, cap_domaine.nom, childer.chlids, childer.nom_chlids FROM cap_domaine LEFT JOIN (SELECT GROUP_CONCAT( cap_domaine.id_domaine SEPARATOR "|") as chlids, GROUP_CONCAT( cap_domaine.nom SEPARATOR "|") as nom_chlids, cap_domaine.nom, cap_domaine.parent FROM cap_domaine WHERE cap_domaine.parent<>0 GROUP BY cap_domaine.parent ) as childer on childer.parent=cap_domaine.id_domaine where cap_domaine.parent=0 '.$sql.' order by cap_domaine.nom ASC'; //$con = DB::connect(); $data=DB::do_query($query); while($row = mysqli_fetch_array($data)){ $mcd[$row['id_type']][] = $row; } return $mcd; } function getAllDoamine_no_type(){ $mcd = array(); $query='SELECT cap_domaine.id_domaine, cap_domaine.id_type, cap_domaine.nom, childer.chlids, childer.nom_chlids FROM cap_domaine LEFT JOIN (SELECT GROUP_CONCAT( cap_domaine.id_domaine SEPARATOR "|") as chlids, GROUP_CONCAT( cap_domaine.nom SEPARATOR "|") as nom_chlids, cap_domaine.nom, cap_domaine.parent FROM cap_domaine WHERE cap_domaine.parent<>0 GROUP BY cap_domaine.parent ) as childer on childer.parent=cap_domaine.id_domaine where cap_domaine.parent=0 order by cap_domaine.nom ASC'; //$con = DB::connect(); $data=DB::do_query($query); while($row = mysqli_fetch_array($data)){ array_push($mcd,$row); } return $mcd; } function getAllDoamine($type=NULL){ if($type!=''){ $sql = " and id_type='".$type."'"; } $query='SELECT * FROM #_domaine where parent = 0 '.$sql.' order by nom ASC'; $con = DB::connect(); $mc = new Memcached(); $mc->addServer("localhost", 11211); $mcd = array(); $querykey = "KEY" . md5(DB::query($query)); $mcd = $mc->get($querykey); $mc->delete($querykey); if($mcd===false){ $array = array(); $data=$con->query(DB::query($query)); while($row = mysqli_fetch_array($data)){ $query2='SELECT * FROM #_domaine where parent = '.$row['id_domaine'].' order by nom ASC '; $data2=DB::do_query($query2); $row['sub_domain']=array(); while($row2 = mysqli_fetch_array($data2)){ array_push($row['sub_domain'],$row2); } array_push($array,$row); } $mcd =$array; //echo 'sdsd'; // var_dump($mcd); //echo serialize($mcd);exit; $mc->set($querykey,serialize($mcd),1000); $test =$mcd; }else{ $test = unserialize($mcd); } return $test; } function getregion(){ $array = array('pays'=>'Pays', 'depar'=>'Département', 'regi'=>'Région'); return $array; } function getdapartement(){ $query='SELECT * FROM #_depart '; $con = DB::connect(); $mc = new Memcached(); $mc->addServer("localhost", 11211); $mcd = array(); $querykey = "KEY" . md5(DB::query($query)); $mcd = $mc->get($querykey); if($mcd===false){ //$data=DB::do_query($query); $data=$con->query(DB::query($query)); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } $mcd = $array; $mc->set($querykey,serialize($mcd),1000); $dapartement =$mcd; }else{ $dapartement = unserialize($mcd); } return $dapartement; } function type_annonce(){ $query='SELECT * FROM #_type_annonce where site_def=1 order by type_annonce asc'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } return $array; } function getlistedomaine($domaine){ $domaine = explode(',',$domaine); $nb= count($domaine); $i=1; foreach($domaine as $key=>$value){ $query='SELECT * FROM #_domaine where id_domaine ="'.$value.'"'; $datas=DB::do_query($query); if($i!=$nb){$virgule = ', ';}else{$virgule = '';} while($row = mysqli_fetch_assoc($datas)){ $domaines .= $row['nom'].$virgule; } $i++; } return $domaines; //var_dump($region); } function getannonceur($annonceur){ $query='SELECT * FROM #_annonceur where id_annonceur ="'.$annonceur.'"'; $datas=DB::do_query($query); $row = mysqli_fetch_assoc($datas); return $row['raison_social']; } function getcandidat($candidat){ $query='SELECT * FROM #_candidat where id_candidat ="'.$candidat.'"'; $datas=DB::do_query($query); $row = mysqli_fetch_assoc($datas); return $row['nom'].' '.$row['prenom']; } function generatePassword($length=9, $strength=0) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEUY"; } if ($strength & 4) { $consonants .= '23456789'; } if ($strength & 8) { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password; } function type_annonceurs(){ $query='select * from #_type_annonceur'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } return $array; } function active_lagues(){ $query='select * from #_langues WHERE etat=1'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } return $array; } function active_composants(){ $query='select * from #_composants WHERE etat=1'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } return $array; } function soc_info($element=NULL){ $el=(is_null($element))? '*' : $element; $query='select '.$el.' from #_societe'; $data=DB::do_query($query); $array=array(); $row = mysqli_fetch_assoc($data); if(!is_null($element)){return $row[$el];} return $row; } function soc_info_rs($element=NULL,$site){ $el=(is_null($element))? '*' : $element; $query='select '.$el.' from #_societe where id_soc='.$site; $data=DB::do_query($query); $array=array(); $row = mysqli_fetch_assoc($data); if(!is_null($element)){return $row[$el];} return $row; } function liste_produits($type=NULL){ $query='select * from #_produits p,#_produit_langues pl WHERE p.id_produit=pl.id_produit And pl.id_langue=1'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row);} return $array; } function liste_categories($parent=NULL){ $query = 'select * from #_categories c,#_categorie_langues cl WHERE c.id_categorie=cl.id_categorie And cl.id_langue=1 '; $query .= (is_null($parent))? '' : 'And parent='.$parent; $query .= ' order by rang asc'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ $row['children']=$this->liste_categories($row['id_categorie']); array_push($array,$row);} return $array; } function liste_pages($type=NULL){ $query='select * from #_pages p,#_page_langues pl WHERE p.id_page=pl.id_page And pl.id_langue=1 AND p.accueil=0'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ if(!is_null($type)){ array_push($array,array(utf8_encode($row['p_titre']),ROOT_BASE.$row['alias'].'.html')); } else{ array_push($array,$row);} } return $array; } function genere_alias($string){ //remove any '-' from the string they will be used as concatonater $str = str_replace('-', ' ', $string); $str = htmlentities($str); $str = preg_replace(array('/ß/','/&(..)lig;/', '/&([aouAOU])uml;/','/&(.)[^;]*;/'),array('ss',"$1","$1".'e',"$1"),$str); // remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); // lowercase and trim $str= str_replace('--','-',$str); $str = trim(strtolower($str)); return $str; } function upload_file($dossier,$nom_input,$nom=NULL,$width=NULL,$height=NULL,$redimensioner=NULL){ if($_FILES[$nom_input]['name']!=''){ $extension = strrchr($_FILES[$nom_input]['name'], '.'); $fichier = (!is_null($nom))? $nom.$extension : basename($_FILES[$nom_input]['name']); $taille_maxi = 3000000; $taille = filesize($_FILES[$nom_input]['tmp_name']); $extensions = array('.png', '.gif', '.jpg', '.jpeg'); //sécurité... if(!in_array($extension, $extensions)) { $erreur = 'Vous devez uploader un fichier de type png, gif, jpg, jpeg, txt ou doc...'; } if($taille>$taille_maxi) { $erreur = 'Le fichier est trop gros...'; } if(!isset($erreur)) { //On formate le nom du fichier $fichier = strtr($fichier, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy'); $fichier = preg_replace('/([^.a-z0-9]+)/i', '-', $fichier); if(move_uploaded_file($_FILES[$nom_input]['tmp_name'], $dossier . $fichier)) { if($redimensioner==1){ $this->fctredimimage($width, $height, $dossier, $fichier, $dossier, $fichier); } return $fichier; } else { return false; } } else { return false; } } else{ return 'empty'; } } function safe_url($data){ if(DIR_BASE!=''){ $data=preg_replace('#('.HOST.'\/?)?(\/?'.DIR_BASE.')#i','[#url#]',$data); } else{ $data=preg_replace('#('.HOST.'\/?)#i','[#url#]',$data); } //$data=str_replace('//','/',$data); return $data; } function taille_fichier($fichier){ $taille_fichier = filesize($fichier); if ($taille_fichier >= 1073741824) { $taille_fichier = round($taille_fichier / 1073741824 * 100) / 100 . " Go"; } elseif ($taille_fichier >= 1048576) { $taille_fichier = round($taille_fichier / 1048576 * 100) / 100 . " Mo"; } elseif ($taille_fichier >= 1024) { $taille_fichier = round($taille_fichier / 1024 * 100) / 100 . " Ko"; } else { $taille_fichier = $taille_fichier . " o"; } return $taille_fichier; } static function dateswitch($Date) // swith MySql (year-mm-day) - input (day-mm-year) { $dates=explode(" ", " ".$Date); $Date=$dates[1]; $Time=$dates[2]; if ($Time!=null) $Time=" $Time"; $regs=explode("-", "-".$Date); return $regs['3']."-".$regs['2']."-".$regs['1']."$Time"; } static function cut($chaine, $max) { $chaine = strip_tags($chaine); //$chaine = enlever_img($chaine); if (strlen($chaine) >= $max) { $chaine = substr($chaine, 0, $max); $espace = strrpos($chaine, " "); $chaine = substr($chaine, 0, $espace) . " ..."; } else { $chaine = $chaine . '...'; } return $chaine; } /*static function resize_image_crop($image,$width,$height) { $ext = strrchr($image,'.'); switch($ext){ case '.png' : $image = imagecreatefrompng($image); break; case '.gif' : $image = imagecreatefromgif($image); break; case '.jpeg' | '.jpg' : $image = imagecreatefromjpeg($image); break; } $w = @imagesx($image); //current width $h = @imagesy($image); //current height if ((!$w) || (!$h)) { echo 'Image couldn\'t be resized because it wasn\'t a valid image.'; return false; } if (($w == $width) && ($h == $height)) { return $image; } //no resizing needed //try max width first... $ratio = $width / $w; $new_w = $width; $new_h = $h * $ratio; //if that created an image smaller than what we wanted, try the other way if ($new_h < $height) { $ratio = $height / $h; $new_h = $height; $new_w = $w * $ratio; } $image2 = imagecreatetruecolor ($new_w, $new_h); imagecopyresampled($image2,$image, 0, 0, 0, 0, $new_w, $new_h, $w, $h); //check to see if cropping needs to happen if (($new_h != $height) || ($new_w != $width)) { $image3 = imagecreatetruecolor ($width, $height); if ($new_h > $height) { //crop vertically $extra = $new_h - $height; $x = 0; //source x $y = round($extra / 2); //source y imagecopyresampled($image3,$image2, 0, 0, $x, $y, $width, $height, $width, $height); } else { $extra = $new_w - $width; $x = round($extra / 2); //source x $y = 0; //source y imagecopyresampled($image3,$image2, 0, 0, $x, $y, $width, $height, $width, $height); } imagedestroy($image2); return $image3; } else { return $image2; }*/ static function taille_images(){ $query = "select * from #_images_option"; $dn = DB::do_query($query); $rs = mysqli_fetch_array($dn); return $rs; } 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 gif"'; // (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; case 'gif': $Ress_Src = imagecreatefromgif($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; case 'gif': $Ress_Src = imagecreatetruecolor($rep_Src.$img_Src); 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; case 'gif': imagegif($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 recadrage($src_image_name,$x_src,$y_src,$src_w,$src_h){ $targ_w = $src_w; $targ_h = $src_h; $jpeg_quality = 90; $src = ROOT_BASE.'files_perso/actualites/'.$src_image_name; $save_name = '../files_perso/actualites/recadrage/'.$src_image_name; $ext = pathinfo($src_image_name,PATHINFO_EXTENSION); switch($ext){ case 'jpg': $img_r = imagecreatefromjpeg($src); $dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); imagecopyresampled($dst_r,$img_r,0,0,($x_src),($y_src),$targ_w,$targ_h,($src_w),($src_h)); imagejpeg($dst_r,$save_name); break; case 'png': $img_r = imagecreatefrompng($src); $dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); imagecopyresampled($dst_r,$img_r,0,0,($x_src),($y_src),$targ_w,$targ_h,($src_w),($src_h)); imagepng($dst_r,$save_name); break; case 'gif': $img_r = imagecreatefromgif($src); $dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); imagecopyresampled($dst_r,$img_r,0,0,($x_src),($y_src),$targ_w,$targ_h,($src_w),($src_h)); imagegif($dst_r,$save_name); break; } } function DateTimeEnToFr($date1) { $date1=explode(" ", $date1); $date_tab = explode("-", $date1[0]); return ($date1[0]!='')? $date_tab[2] . "/" . $date_tab[1] . "/" . $date_tab[0] : ''; } function historique_connexion(){ $query = "select * from #_utilisateur_historique Inner Join #_utilisateur ON #_utilisateur_historique.id_utilisateur = #_utilisateur.id ORDER BY #_utilisateur_historique.date DESC limit 1"; $hs = DB::do_query($query); $rs = mysqli_fetch_array($hs); return $rs; } function liste_annonceur(){ $annonceur = array(); $query = "select id_annonceur, raison_social from #_annonceur where etat=1 order by raison_social asc"; $hs = DB::do_query($query); while($rs = mysqli_fetch_array($hs)){ array_push($annonceur,$rs); } return $annonceur; } function liste_region(){ $region = array(); $query = "select * from #_region "; $hs = DB::do_query($query); while($rs = mysqli_fetch_array($hs)){ array_push($region,$rs); } return $region; } function liste_departement(){ $region = array(); $query = "select * from #_depart "; $hs = DB::do_query($query); while($rs = mysqli_fetch_array($hs)){ array_push($region,$rs); } return $region; } function get_nom_region($id_region){ $query = "select nom from #_region where id_region =".$id_region; $hs = DB::do_query($query); $region = mysqli_fetch_array($hs); return $region['nom']; } function liste_domaine(){ $domaine = array(); $query = "select * from #_domaine "; $hs = DB::do_query($query); while($rs = mysqli_fetch_array($hs)){ array_push($domaine,$rs); } return $domaine; } function nb_sous_cat($id_domaine){ $domaine = array(); $query = "select * from #_domaine where parent=".$id_domaine; $hs = DB::do_query($query); $nb=mysqli_num_rows($hs); return $nb; } function nbannonceur_en_ligne($id_annonceur){ $query = "select * from #_annonce where etat=1 and id_annonceur=".$id_annonceur; $hs = DB::do_query($query); $nb=mysqli_num_rows($hs); return $nb; } function nbannonceur_en_postule($id_candidat){ $query = "select * from #_annone_postule where id_candidat=".$id_candidat; $hs = DB::do_query($query); $nb=mysqli_num_rows($hs); return $nb; } function liste_pays($id_pays=''){ $rqt_pays=($id_pays!='')?' where id_pays="'.$id_pays.'"':''; //$region = array(); $query = "select id_pays, nom_fr from #_pays ".$rqt_pays." order by nom_fr"; //$hs = DB::do_query($query); $con = DB::connect(); $mc = new Memcached(); $mc->addServer("localhost", 11211); $mcd = array(); // $annonces['annonces']=array(); $querykey = "KEY" . md5(DB::query($query)); $mcd = $mc->get($querykey); //$mc->delete($querykey); if($mcd===false){ $data=$con->query(DB::query($query)); ///var_dump( mysqli_fetch_array($data));exit; while($rs = mysqli_fetch_array($data)){ $mcd[] = $rs; } $mc->set($querykey,serialize($mcd),10000); $pays =$mcd; }else{ $pays = unserialize($mcd); } return $pays; } function get_raison_social($id_annonceur){ $query='SELECT raison_social,alias_annonceur FROM #_annonceur where id_annonceur ="'.$id_annonceur.'"'; $datas=DB::do_query($query); $row = mysqli_fetch_assoc($datas); return $row; } function menuTop(){ /*<li><a href="'.URL_BASE.'index.php?type=annonceur&action=detail_annonceur">Informations</a></li> <li><a href="'.URL_BASE.'index.php?type=annonceur&action=detail_description_annonceur">Descriptions</a></li>*/ $annonceur = $this->get_raison_social($_SESSION['id_annonceur']); $menu=' <div class="menutop_annonceur"> <label>'.$annonceur['raison_social'].'</label> <ul> <li><a target="_blank" href="https://capijobnew.com/annonceur/'.$annonceur['alias_annonceur'].'">Voir les annonces en lignes</a></li> <li><a target="_blank" href="'.URL_BASE.'index.php?type=annonceur&action=form_edit&id_annonceur='.$_SESSION['id_annonceur'].'">info Annonceur</a></li> <li><a href="'.URL_BASE.'index.php?type=parution&from=annonceur">Parutions</a></li> <li><a href="'.URL_BASE.'index.php?type=annonceur&action=liste_parution">Annonces</a></li> <li><a href="#" onclick="login_annonceur('.$_SESSION['id_annonceur'].')">Se connecter avec son compte</a></li> <li><a href="#">Demande de paiement</a></li> <li><a href="#">Liste des règlements</a></li> <li><a href="#">Historique</a></li> </ul> </div> '; return $menu; } function get_info_annonce($id_annonce,$champs=''){ $rqt_champ= ($champs!='') ? $champs : '*' ; $query = "select ".$rqt_champ." from #_annonce where id_annonce=".$id_annonce; $data = DB::do_query($query); $result = mysqli_fetch_array($data); if(!is_null($champs)){return $result[$champs];} return $result; } function info_annonceurs($id_annonceur,$element=NULL){ $el=(is_null($element))? '*' : $element; $sql="select ".$el." from #_annonceur where id_annonceur =".$id_annonceur; //echo $sql; exit; $res_user=DB::do_query($sql); $user=mysqli_fetch_array($res_user); if(!is_null($element)){return $user[$el];} return $user; } function liste_email_sups($id_annonce){ $array_supp =array(); $query= "select * from #_annonce_email_sup where id_annonce=".$id_annonce; $sql=DB::do_query($query); while($row=mysqli_fetch_array($sql)){ array_push($array_supp,$row); } return $array_supp; } function liste_email_sups_rh($id_annonce){ $array_supp =array(); $query= "select * from #_annonce_rh_email_sup where id_annonce=".$id_annonce; $sql=DB::do_query($query); while($row=mysqli_fetch_array($sql)){ array_push($array_supp,$row); } return $array_supp; } function strtoupperFr($string) { //$string = strtoupper($string); $string = str_replace( array('é', 'è', 'ê', 'ë', 'à', 'â', 'î', 'ï', 'ô', 'ù', 'û','É', 'È', 'Ê', 'Ë', 'À', 'Â', 'Î', 'Ï', 'Ô', 'Ù', 'Û'), array('e', 'e', 'e', 'e', 'a', 'a', 'i', 'i', 'o', 'u', 'u','E', 'E', 'E', 'E', 'A', 'A', 'I', 'I', 'O', 'U', 'U'), $string ); return $string; } function liste_sites(){ $sites = array(); $query = "select * from #_societe"; $sql=DB::do_query($query); while($row=mysqli_fetch_assoc($sql)){ array_push($sites,$row); } return $sites; } function liste_users_ligne(){ $query = "select cl.id_connect,cl.id_user,cl.time, us.nom, us.prenom from #_utilisateur_connect cl inner join #_utilisateur us on cl.id_user=us.id where 1=1 order by us.nom"; $dn = DB::do_query($query); $array = array(); while($rs = mysqli_fetch_array($dn)){ array_push($array, $rs); }; return $array; } function liste_users_ligne_html(){ $users = $this->liste_users_ligne(); $html = '<ul class="toggle">'; foreach ($users as $user) { // echo 'UPDATE #_utilisateur_connect SET time = '.date('Y-m-d H:i:s').' WHERE id='.$user['id_user']; DB::do_query('UPDATE #_utilisateur_connect SET time = "'.date('Y-m-d H:i:s').'" WHERE id_user='.$_SESSION['id']); $html .= '<li><span style="border-radius:50%; display:inline-block; padding:5px; background:green; margin-right:8px;"></span>'.$user['nom'].' '.$user['prenom'].'</li>'; } $html .= '</ul>'; return $html; } function site_annonceur_principal($id_annonce){ $sql ="SELECT #_societe.rc FROM cap_annonce INNER JOIN cap_annonceur ON #_annonce.id_annonceur = #_annonceur.id_annonceur INNER JOIN cap_societe ON #_annonceur.site = #_societe.id_soc WHERE #_annonce.id_annonce =".$id_annonce; $requete = DB::do_query($sql); $rs = mysqli_fetch_array($requete); return $rs['rc']; } function annonce_site($id_annonce){ $array_sites =array(); $query = "select site_web from #_annonce_site where #_annonce_site.id_annonce=".$id_annonce; $data = DB::do_query($query); while($result = mysqli_fetch_array($data)){ $array_sites[] = $result['site_web']; } return $array_sites; } function evenement_sites($id_evenement){ $array_sites =array(); $query = "select site from cap_evenements_sites where id_evenement=".$id_evenement; $data = DB::do_query($query); while($result = mysqli_fetch_array($data)){ $array_sites[] = $result['site']; } return $array_sites; } function videcache(){ $files = glob(FILE_CACHE.'/caching-master/cache/*'); foreach ($files as $file) { //echo $file;exit; unlink($file); } return true; } function header_mail($src=NULL){ $header = '<body style="margin: 0; padding: 0;"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td> <table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;font-family:ebrima"> <tr> <td> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td > <img src="'.$src['site'].'/Templates/images/logo.png" width="200" alt="Creating Email Magic" style="display: block;" /> </td> <td align="right"> <span style="display: block;float: right; color: #f78128; font-size: 30px; font-weight: bold; margin-left: 10px;"> 2000 </span> <span style="display: block;float: right;font-weight: 600;font-size: 14px;"> Votre adresse d\'annonces d\'offres<br/> d\'emploi et de formation depuis </span> </td> </tr> </table> </td> </tr>'; return $header; } function footer_mail_annonceur($id_annonceur=NULL,$src=NULL){ //var_dump($src); $footer ='<tr> <td> <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="center" style="padding: 30px 0"> <p><strong>Toujours soucieux d\'être au plus proche de nos clients, nous vous souhaitons une excellente campagne sur nos supports.</strong></p> </td> </tr> <tr> <td align="center"><a style="background: #0b6a0b;color: #fff;padding: 5px 15px;-webkit-border-radius: 360px;-moz-border-radius: 360px;border-radius: 360px;" href="https://client.capijobnew.com/">Espace annonceur</a></td> </tr> <tr> <td align="center" style="padding: 30px 0"><strong>Vous souhaitez vous désinscrire</strong>: <a style="background: #0b6a0b;color: #fff;padding: 5px 15px;-webkit-border-radius: 360px;-moz-border-radius: 360px;border-radius: 360px;" href="'.$src['site'].'?action=annonceur_disable&id_annonceur='.$id_annonceur.'">cliquer ici</a></td> </tr> </table> </td> </tr> <tr> <td style="padding-bottom: 20px;border-top: 1px solid #dfdfdf; border-bottom: 1px solid #dfdfdf; margin-bottom: 30px;display: block;"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td > <img src="'.$src['site'].'Templates/images/logo.png" width="200" alt="Creating Email Magic" style="display: block;" /> <p><a style="color: #000; font-weight: 600;text-decoration: none;" href="'.$src['site'].'">'.$src['rc'].'</a></p> <p style="font-weight: 600;">L\'Equipe de '.$src['rc'].'<br/> Tel: '.$src['tel'].'</p> </td> <td align="right"> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/inded.jpg" alt="linkend" width="36" height="36" style="display: block;" border="0"></a> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/twiter.jpg" alt="Twiter" width="36" height="36" style="display: block;" border="0"></a> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/instagram.jpg" alt="Instagram" width="36" height="36" style="display: block;" border="0"></a> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/facebook.jpg" alt="Facebook" width="36" height="36" style="display: block;" border="0"></a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body>'; return $footer; } function footer_mail($soc=NULL){ $footer =' <tr> <td style="padding-bottom: 20px;border-top: 1px solid #dfdfdf; border-bottom: 1px solid #dfdfdf; margin-bottom: 30px;display: block;"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td > <img src="'.URL_BASE.'Templates/images/logos/'.$soc['id_soc'].'.png" width="200" alt="Creating Email Magic" style="display: block;" /> <p><a style="color: #000; font-weight: 600;text-decoration: none;" href="'.$soc['site'].'">'.$soc['site'].'</a></p> <p style="font-weight: 600;">L\'Equipe de'.$soc['rc'].'<br/> Tel: 01 53 38 55 10</p> </td> <td align="right"> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/inded.jpg" alt="linkend" width="36" height="36" style="display: block;" border="0"></a> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/twiter.jpg" alt="Twiter" width="36" height="36" style="display: block;" border="0"></a> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/instagram.jpg" alt="Instagram" width="36" height="36" style="display: block;" border="0"></a> <a href="#" style="display: inline-block;"><img src="'.URL_BASE.'Templates/images/accueil2/facebook.jpg" alt="Facebook" width="36" height="36" style="display: block;" border="0"></a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body>'; return $footer; } function encrypt($data) { $key = "JaDhKz1wKv"; // Clé de 8 caractères max $data = serialize($data); $td = mcrypt_module_open(MCRYPT_DES,"",MCRYPT_MODE_ECB,""); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td,$key,$iv); $data = base64_encode(mcrypt_generic($td, '!'.$data)); mcrypt_generic_deinit($td); return $data; } function decrypt($data) { $key = "JaDhKz1wKv"; $td = mcrypt_module_open(MCRYPT_DES,"",MCRYPT_MODE_ECB,""); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td,$key,$iv); $data = mdecrypt_generic($td, base64_decode($data)); mcrypt_generic_deinit($td); if (substr($data,0,1) != '!') return false; $data = substr($data,1,strlen($data)-1); return unserialize($data); } function word_texte($string){ $search = [ // www.fileformat.info/info/unicode/<NUM>/ <NUM> = 2018 "\xC2\xAB", // « (U+00AB) in UTF-8 "\xC2\xBB", // » (U+00BB) in UTF-8 "\xE2\x80\x98", // ‘ (U+2018) in UTF-8 "\xE2\x80\x99", // ’ (U+2019) in UTF-8 "\xE2\x80\x9A", // ‚ (U+201A) in UTF-8 "\xE2\x80\x9B", // ‛ (U+201B) in UTF-8 "\xE2\x80\x9C", // “ (U+201C) in UTF-8 "\xE2\x80\x9D", // ” (U+201D) in UTF-8 "\xE2\x80\x9E", // „ (U+201E) in UTF-8 "\xE2\x80\x9F", // ‟ (U+201F) in UTF-8 "\xE2\x80\xB9", // ‹ (U+2039) in UTF-8 "\xE2\x80\xBA", // › (U+203A) in UTF-8 "\xE2\x80\x93", // – (U+2013) in UTF-8 "\xE2\x80\x94", // — (U+2014) in UTF-8 "\xE2\x80\xA6", // … (U+2026) in UTF-8 "\r\n" // … (U+2026) in UTF-8 ]; $replacements = [ "<<", ">>", "'", "'", "'", "'", '"', '"', '"', '"', "<", ">", "-", "-", "...", " " ]; $content = str_replace($search, $replacements, $string); return $content; } function getchildrencat_blog($cat){ $query='SELECT * FROM #_actualistes_categories where parent_cat = '.$cat.' ORDER BY titres_cat ASC'; $data=DB::do_query($query); $table =array(); while ( $row = mysqli_fetch_assoc($data)) { array_push($table, $row); } return $table; } function getcategoriesblog($parent=NULL){ //$parents = (is_null($parent)) ? '' : ' where parent_cat = '.$parent.''; $query='SELECT * FROM #_actualistes_categories where parent_cat =0 ORDER BY titres_cat ASC'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ $row['children'] = $this->getchildrencat_blog($row['id_cat']); array_push($array,$row); } //var_dump($array); return $array; } function getdomaines($parent=NULL){ // $parents = (is_null($parent)) ? 'parent=0' : ' where parent = '.$parent.''; $query='SELECT id_domaine,parent,nom FROM #_domaine where parent=0 ORDER BY nom ASC'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ $row['children'] = $this->getdomaineschild($row['id_domaine']); array_push($array,$row); } // var_dump($array);exit; return $array; } function getdomaineschild($parent=NULL){ //$parents = (is_null($parent)) ? 'parent=0' : ' where parent = '.$parent.''; $query='SELECT id_domaine,parent,nom FROM #_domaine where parent = '.$parent.' ORDER BY nom ASC'; $data=DB::do_query($query); $array=array(); while($row = mysqli_fetch_array($data)){ array_push($array,$row); } return $array; } function upload($_files, $destination_rep){ //echo $destination_rep;exit; if(!empty($_files['tmp_name']) && !empty($_files['name'])){ $tmp_file = $_files['tmp_name']; //on test si l'upload a reussi if(!is_uploaded_file($tmp_file)){ $reponse = "error"; }else{ // on va ajouter une chaine pour rendre le nom du fichier unique et pratiquement introuvable. $unikifier = md5( uniqid('H', 5) ); // extension du fichier $ext = pathinfo($_files['name'], PATHINFO_EXTENSION); // nettoyage du nom du fichier (on peux pas d'accents ou d'espace) $file_name = $unikifier.'.'.$ext; $dir_parent = $destination_rep.date('Y').'/'; if (file_exists($dir_parent)) { $dir_child = $dir_parent.date('m').'/'; $retour = mkdir($dir_child, 0777); }else{ if(mkdir($dir_parent, 0777)){ $dir_child = $dir_parent.date('m').'/'; $retour = mkdir($dir_child, 0777); }; } $new_distination =$dir_child; if($dir_child){ //on déplace le fichier vers notre répertoire de destination ///echo $new_distination.$file_name;exit; if(!move_uploaded_file($tmp_file, $new_distination.$file_name)){ $reponse = "error"; }else{ $reponse = $file_name; } } } } $name = date('Y').'/'.date('m').'/'.$reponse; return $name; } function uploadNew($_files, $destination_rep){ if (!empty($_files['tmp_name']) && !empty($_files['name'])) { $tmp_file = $_files['tmp_name']; // Vérifiez si le fichier a été téléchargé avec succès if (!is_uploaded_file($tmp_file)) { return "error"; // L'upload a échoué } // Générer un nom de fichier unique $unikifier = md5(uniqid('H', true)); $ext = pathinfo($_files['name'], PATHINFO_EXTENSION); $file_name = preg_replace('/[^a-zA-Z0-9-_\.]/', '', $unikifier) . '.' . $ext; // Structure du répertoire de destination // $destination_rep = 'uploads/'; // Répertoire principal $dir_parent = $destination_rep . date('Y') . '/'; $dir_child = $dir_parent . date('m') . '/'; // Créer les répertoires si nécessaire if (!file_exists($dir_parent)) { mkdir($dir_parent, 0777, true); } if (!file_exists($dir_child)) { mkdir($dir_child, 0777, true); } // Déplacer le fichier téléchargé vers le répertoire de destination $new_destination = $dir_child . $file_name; if (!move_uploaded_file($tmp_file, $new_destination)) { return "error"; // Si le déplacement échoue } $resized_path = $dir_child . '' . $file_name; // Chemin de l'image redimensionnée $this->resizeImage($new_destination, $resized_path, 1000, 1000); // Créer une miniature après le téléchargement réussi $thumbnail_name = 'mini_' . $file_name; // Nom de la miniature $thumbnail_path = $dir_child . $thumbnail_name; // Chemin de la miniature $this->createThumbnail($new_destination, $thumbnail_path, 300, 300); // Génère la miniature // Retourner le chemin relatif des images en cas de succès $relative_path = date('Y') . '/' . date('m') . '/' . $file_name; $relative_thumbnail_path = date('Y') . '/' . date('m') . '/' . $thumbnail_name; //return $relative_thumbnail_path; return ["image" => $relative_path, "thumbnail" => $relative_thumbnail_path]; // Retourne les chemins des fichiers } return "error"; // Si aucune condition n'est remplie } function createThumbnail($sourceFile, $destinationFile, $maxWidth, $maxHeight) { // Obtenir les dimensions de l'image source list($originalWidth, $originalHeight, $type) = getimagesize($sourceFile); // Calculer les nouvelles dimensions en maintenant le ratio $ratio = min($maxWidth / $originalWidth, $maxHeight / $originalHeight); $newWidth = (int)($originalWidth * $ratio); $newHeight = (int)($originalHeight * $ratio); // Créer une nouvelle image pour la miniature $thumbnail = imagecreatetruecolor($newWidth, $newHeight); // Charger l'image source selon son type switch ($type) { case IMAGETYPE_JPEG: $source = imagecreatefromjpeg($sourceFile); break; case IMAGETYPE_PNG: $source = imagecreatefrompng($sourceFile); break; case IMAGETYPE_GIF: $source = imagecreatefromgif($sourceFile); break; default: throw new Exception("Type d'image non pris en charge."); } // Redimensionner l'image source pour créer la miniature imagecopyresampled($thumbnail, $source, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); // Sauvegarder la miniature dans le répertoire de destination switch ($type) { case IMAGETYPE_JPEG: imagejpeg($thumbnail, $destinationFile); break; case IMAGETYPE_PNG: imagepng($thumbnail, $destinationFile); break; case IMAGETYPE_GIF: imagegif($thumbnail, $destinationFile); break; } // Libérer la mémoire imagedestroy($thumbnail); imagedestroy($source); } function resizeImage($sourceFile, $destinationFile, $maxWidth, $maxHeight) { list($originalWidth, $originalHeight, $type) = getimagesize($sourceFile); // Calculer le ratio pour maintenir l'aspect $ratio = min($maxWidth / $originalWidth, $maxHeight / $originalHeight); $newWidth = (int)($originalWidth * $ratio); $newHeight = (int)($originalHeight * $ratio); $resizedImage = imagecreatetruecolor($newWidth, $newHeight); // Nouvelle image // Charger l'image source selon son type switch ($type) { case IMAGETYPE_JPEG: $source = imagecreatefromjpeg($sourceFile); break; case IMAGETYPE_PNG: $source = imagecreatefrompng($sourceFile); break; case IMAGETYPE_GIF: $source = imagecreatefromgif($sourceFile); break; default: throw new Exception("Type d'image non pris en charge."); } // Redimensionner l'image pour créer la nouvelle taille imagecopyresampled( $resizedImage, $source, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight ); // Sauvegarder l'image redimensionnée switch ($type) { case IMAGETYPE_JPEG: imagejpeg($resizedImage, $destinationFile); break; case IMAGETYPE_PNG: imagepng($resizedImage, $destinationFile); break; case IMAGETYPE_GIF: imagegif($resizedImage, $destinationFile); break; } imagedestroy($resizedImage); // Libérer la mémoire imagedestroy($source); } } ?>