$GLOBALS["default_DisplayLimit"] = 15;
$GLOBALS["default_DisplayFrom"] = 0;
$GLOBALS["default_upload_doc"] = "default";
$GLOBALS["default_upload_img"] = "jpg";
$GLOBALS["default_date"] = "0000-00-00";
$GLOBALS["default_lang"] = "fr";
$GLOBALS["default_resume_length"]= "120";
$GLOBALS["default_document_length"]= "48";
$GLOBALS["default_editorial_length"]= "768";
$GLOBALS["content_limit_display"]= "4";
$GLOBALS["actuality_archive_delay"]= "120";
$GLOBALS["default_page_lines"] = 2;
$GLOBALS["default_page_columns"] = 3;
?>
$Site['siteDomaine'] = $_SERVER['HTTP_HOST'];
$Site['baseDir'] = './';
$Site['homeDir'] = "/var/www/vhosts/cafeboukhari.com/httpdocs";
$Site['adminDir'] = $Site['homeDir']."/admin";
$Site['Protocol'] = "http://";
$Site['baseUrl'] = $Site['Protocol'].$Site['siteDomaine'];
$Site['adminUrl'] = $Site['baseUrl']."/admin";
$Site['cmsConfigTemplate'] = 'default';
$Site["siteName"]["fr"] = "Café Boukhari";
$Site["code"] = "boukhari";
?>
//SGBD LOCAL
$GLOBALS["db_host"]="localhost";
$GLOBALS["db_name"]="boukhari_db";
$GLOBALS["db_user"]="boukhari_db_user";
$GLOBALS["db_pass"]="ATTkmcqEVhvJXoK3";
?>
$GLOBALS["global_strech"] = 1;
$GLOBALS["global_quality"] = 100;
$GLOBALS["scale"] = 39;
$GLOBALS["thumbnail"] = "80x53";
$GLOBALS["default_image"] = "/themes/default/images/spacer.gif";
$GLOBALS["default_process"] = "none";
$GLOBALS["default_bg"] = "ffffff";
$GLOBALS["valign"] = "middle";
$GLOBALS["halign"] = "center";
?>
//Comptes email
$GLOBALS["contact_mail"] = "contact@cafeboukhari.com";
$GLOBALS["job_mail"] = "contact@cafeboukhari.com";
$GLOBALS["support_mail"] = "contact@cafeboukhari.com";
$GLOBALS["contact_subject"] = "Demande d'information";
?>
function initLangue()
{
global $Site;
$Site['Lang'] = $Site['lang']= $GLOBALS["default_lang"];
$Site['Direction'] = $GLOBALS["direction"][$GLOBALS["default_lang"]];
// set language
if($GLOBALS["direction"][$_GET["language"]])
{
$Site['Lang'] = $Site['lang']= $_GET["language"];
$Site['Direction'] = $GLOBALS["direction"][$_GET["language"]];
}
}
?>
function ajouterSlashes($argument)
{
if(get_magic_quotes_gpc()) return $argument;
else return addslashes($argument);
}
function no_accent($str_accent) {
$pattern = Array("/é/", "/è/", "/ê/", "/ç/", "/à /", "/â/", "/î/", "/ï/", "/ù/", "/ô/");
// notez bien les / avant et après les caractères
$rep_pat = Array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o");
$str_noacc = preg_replace($pattern, $rep_pat, $str_accent);
return $str_noacc;
}
function charsToHTML($argument)
{
$newValue = htmlentities($argument, ENT_QUOTES, "UTF-8");
$newValue = nl2br($newValue);
return $newValue;
}
//Remplacement des retour lignes en liste énumérée (puces).
//Idéale pour les fiches techniques en champ TEXT
function myBullets($argument, $separator="
", $withinGroup=true)
{
$newArgument=charsTOHTML($argument);
if($withinGroup) $formattedText="
Début pour ".$path;
$fileInfos = pathinfo($fileName);
$fileExtension = $fileInfos['extension'];
if(strlen($fileExtension)) $fileName = substr($fileName,0,strlen($fileName)-strlen($fileExtension)-1);
//Le dossier n'existe pas :
if(is_dir($dirName))
{
$found=0;
$dirHandle = dir($dirName);
while (($fileHandle = $dirHandle->read())!==false && $found==0)
{
unset($fileInfos);
$fileInfos = pathinfo($fileHandle);
$fileHandleExtension = $fileInfos['extension'];
//echo "extension :".$fileHandleExtension." de longueur ".strlen($fileHandleExtension)." sur ".strlen($fileHandle);
if(strlen($fileHandleExtension)) $fileHandle = substr($fileHandle,0,strlen($fileHandle)-strlen($fileHandleExtension)-1);
//echo "
".$fileHandle." comparé à ".$fileName;
if($fileName == $fileHandle)
{
$foundFile = $path.".".$fileHandleExtension;
$found=1;
}
}
$dirHandle->close();
if($log) echo "
Fin avec ".$foundFile."";
}
}
return $foundFile;
}
?>
function creerImage($width, $height)
{
return imagecreatetruecolor($width, $height);
}
function mergeImages($width, $height, $images_array, $strech=FALSE, $image_file_name ="")
{
global $Site, $global_quality;
define("UNKNOWN", "0");
$image_to_send = creerImage ($width, $height);
for($indice=0; $indice < count($images_array); $indice+=2)
{
$image_path = clean_path($images_array[$indice]);
$image_info = getimagesize($Site['homeDir'].$image_path);
switch($image_info[2])
{
case "1" : $image_type = $function_suffix = "GIF";
break;
case "2" : $image_type = "JPG";
$function_suffix = "JPEG";
break;
case "3" : $image_type = $function_suffix = "PNG";
break;
default : $image_type = "UNKNOWN";
}
if (!imagetypes() & constant("IMG_".$image_type))
{
continue;
}
if (!function_exists('imagecreatefrom'.strtolower($function_suffix)))
{
continue;
}
$image = call_user_func ('imagecreatefrom'.strtolower($function_suffix), $Site['homeDir'].$image_path);
if (!$image)
{
continue;
}
$image_blend = min (100, abs($images_array[$indice+1]));
if($strech)
{
$tmp_image = creerImage ($image_info[0], $image_info[1]);
imagecopy ($tmp_image, $image, 0, 0, 0, 0, $image_info[0], $image_info[1]);
unset($image);
$image = creerImage ($width, $height);
imagecopyresized ($image, $tmp_image, 0, 0, 0, 0, $width, $height, $image_info[0]-1, $image_info[1]-1);
unset($tmp_image);
$image_info[0]=$width;
$image_info[1]=$height;
}
imagecopymerge ($image_to_send, $image, max(0, $width-$image_info[0]), max(0, $height-$image_info[1]), max(0, ($image_info[0]-$width)/2), max(0, ($image_info[1]-$height)/2), min($width, $image_info[0]), min($height, $image_info[1]), $image_blend);
$local_log .= "image $indice : point x ".max(0, $width-$image_info[0])." point Y ".max(0, $height-$image_info[1])." largeur ".min($width, $image_info[0])." hauteur ". min($height, $image_info[1])." alpha ".$image_blend."
";
}
//echo $local_log ;
if($image_file_name)
{
$image_file_name = clean_path($image_file_name);
call_user_func ('imagejpeg', $image_to_send, $Site['homeDir'].$image_file_name, $qualite);
return $image_file_name;
}
else
{
header("MIME-Version: 1.0");
header("Content-Type: image/jpeg");
header("Content-Transfer-Encoding: 8bit");
call_user_func ('imagejpeg', $image_to_send, NULL, $global_quality);
}
}
function insertImage($path, $size, $operation, $optionnal_arguments="", $atributes="")
{
$imageInfos = array();
$imageInfos = howToInsertImage($path, $size, $operation, $optionnal_arguments, $atributes);
return '';
}
function howToInsertImage($path, $size, $operation, $optionnal_arguments="", $atributes="")
{
global $Site;
$argumentsToSend = array();
//Vérification de l'existence du fichier image
if(($foundFile=searchFile($path))!=FALSE) $imageToInsert=$foundFile;
else $imageToInsert=$GLOBALS["default_image"];
//Determination de la taille de la fenêtre
$imageSize=getimagesize($Site['homeDir'].$imageToInsert);
if(!$size)
{
$size = $imageSize[0]."x".$imageSize[1];
}
$windowWidth=substr($size, 0, strpos($size,"x"));
if(!$windowWidth) $windowWidth = $imageSize[0];
$windowHeight=substr($size, strpos($size,"x")+1);
if(!$windowHeight) $windowHeight = $imageSize[1];
//Récupération des valeurs optionnelles en leur créant des variables locales
//Décomposition de la chaine complète
$argumentsArray = explode(" ", $optionnal_arguments);
foreach($argumentsArray as $option)
{
//effacement des balncs de chaque couple
$option = trim($option);
//Décomposition du couple
$option_elements = explode("=",$option);
//création de la variable
${$option_elements[0]} = $option_elements[1];
}
//Traitements à faire selon l'oprétation demandées
if(!$operation) $operation = $GLOBALS["default_process"];
switch($operation)
{
//Zoom
case "zoom" : //Vérification du zoom
if (!$zoom) $zoom = 100;
$zoom = abs($zoom);
//Multiplication par le facteur zoom
$imageSize[0] = floor($imageSize[0]*$zoom/100);
$imageSize[1] = floor($imageSize[1]*$zoom/100);
$ImageHeight = $windowHeight;
$ImageWidth = $windowWidth;
$argumentsToSend[] = "zoom=".$zoom;
break;
//Adaptation comme l'étirement mais avec sauvegarde des proportions
case "adapt" : //Ajustement si la taille de l'image est plus grande que la fenêtre
if($imageSize[0]!=$windowWidth)
{
$imageSize[1] = floor($imageSize[1]*$windowWidth/$imageSize[0]);
$imageSize[0] = $windowWidth;
}
if($imageSize[1]>$windowHeight)
{
$imageSize[0] = floor($imageSize[0]*$windowHeight/$imageSize[1]);
$imageSize[1] = $windowHeight;
}
$argumentsToSend[] = "strech=1";
$ImageWidth = $imageSize[0];
$ImageHeight = $imageSize[1];
break;
//Etirement
case "strech": //Nous fixons la taille de l'image à la taille de la fenêtre
//Nous fixons la variable strech à 1
$argumentsToSend[] = "strech=1";
$ImageWidth = $windowWidth;
$ImageHeight = $windowHeight;
break;
//Rien ! ! !
default :
case "none" : //Rien n'est fait.
$argumentsToSend[] = "zoom=100";
$ImageWidth = $windowWidth;
$ImageHeight = $windowHeight;
break;
}
//Nous fixons tout débordement à l'intérieur de la fenêtre
//Si l'image est plus petite alors c'est ok
//Sinon tronquer voir l'alignement si possible
//Si les dimensions sont différentes de celles de la fenêtre alors on appele le script:
if($background_color) $argumentsToSend[] = "background_color=".$background_color;
if($halign) $argumentsToSend[] = "halign=".$halign;
if($valign) $argumentsToSend[] = "valign=".$valign;
if($imageToInsert!=$default && ($windowWidth!=$imageSize[0] || $windowHeight!=$imageSize[1]))
{
$imageToInsert = "/js/images.php?source=".$imageToInsert."&width=".$ImageWidth."&height=".$ImageHeight;
if(count($argumentsToSend))
{
$argumentsString = join("&", $argumentsToSend);
$imageToInsert .= "&".$argumentsString;
}
//echo $optionnal_arguments;
}
return array($imageToInsert, $ImageWidth, $ImageHeight, $atributes);
}
function processImage($width, $height, $image_source, $optionnal_arguments)
{
global $Site, $global_quality;
define("UNKNOWN", "0");
//Récupération des valeurs optionnelles en leur créant des variables locales
//Décomposition de la chaine complète
$argumentsArray = explode(" ", $optionnal_arguments);
foreach($argumentsArray as $option)
{
//effacement des balncs de chaque couple
$option = trim($option);
//Décomposition du couple
$option_elements = explode("=",$option);
//création de la variable
${$option_elements[0]} = $option_elements[1];
}
//Positionnement de certaines variable
if(!isset($quality)) $quality = $global_quality;
if(isset($zoom))
{
if($zoom==0) unset($zoom);
$zoom = abs($zoom);
}
//Variable de positionnement de l'image dans la fenêtre :
if(!isset($valign)) $valign = $GLOBALS["valign"];
if(!isset($halign)) $halign = $GLOBALS["halign"];
//Couleur de fond ?
if(!isset($background_color)) $background_color = $GLOBALS["default_bg"];
//Création de l'image à envoyer
$image_to_send = creerImage($width, $height);
//Récupération des composantes de la couleur de fond
$background_color_integer = hexdec($background_color);
//remplissage avec la couleur
imagefill ($image_to_send, 0, 0, $background_color_integer);
//Récupération de l'image source
$image_path = searchFile($image_source);
//Obtention des infos
$image_info = getimagesize($Site['homeDir'].$image_path);
switch($image_info[2])
{
case "1" : $image_type = $function_suffix = "GIF";
break;
case "2" : $image_type = "JPG";
$function_suffix = "JPEG";
break;
case "3" : $image_type = $function_suffix = "PNG";
break;
case "4" : $image_type = $function_suffix = "UNKNOWN";
break;
case "5" : $image_type = $function_suffix = "PSD";
break;
case "6" : $image_type = $function_suffix = "BMP";
break;
case "7" :
case "8" : $image_type = $function_suffix = "TIFF";
break;
case "9" : $image_type = $function_suffix = "JPC";
break;
case "10" : $image_type = $function_suffix = "JP2";
break;
case "11" : $image_type = $function_suffix = "JPX";
break;
case "12" : $image_type = $function_suffix = "JB2";
break;
case "13" : $image_type = $function_suffix = "SWC";
break;
case "14" : $image_type = $function_suffix = "IFF";
break;
default : $image_type = "UNKNOWN";
}
if(function_exists('imagecreatefrom'.strtolower($function_suffix)))
{
$image = call_user_func ('imagecreatefrom'.strtolower($function_suffix), $Site['homeDir'].$image_path);
if($function_suffix=="PNG" || $function_suffix="GIF") imagecolortransparent($image_to_send, $background_color_integer);
}
else
{
$image = creerImage ($image_info[0], $image_info[1]);
imagestring($image, 1, 0, 0, "No imagecreatefrom".strtolower);
}
if ($image)
{
imagealphablending($image,true);
$xFromPos = 0;
$yFromPos = 0;
//Si adaptation
if($strech)
{
//désactiver le zoom
unset($zoom);
//Récupération de l'image ouverte dans une variable temporaire
$tmp_image = creerImage ($width, $height);
imagefill ($tmp_image, 0, 0, $background_color_integer);
imagecolortransparent($tmp_image, $background_color_integer);
imagealphablending($tmp_image,false);
imagesavealpha($tmp_image,true);
imagecopyresampled($tmp_image, $image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
//Destruction et recréation de l'image dans la bonne taille
/*unset($image);
$image = creerImage ($width, $height);
imagefill ($image, 0, 0, $background_color_integer);
imagealphablending($image,false);
imagesavealpha($image,true);
imagecolortransparent($image, $background_color_integer);
//Copie et réechantillonage de l'image depuis le contenu original vers le contenu adapté
imagecopyresampled($image, $tmp_image, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
//destruction de l'image temporaire et ajustement des tailles de l'image
unset($tmp_image);*/
$image_info[0]=$width;
$image_info[1]=$height;
}
if(isset($zoom))
{
//Calcul de la nouvelle taille
$zoomedWidth = max(floor($image_info[0]*$zoom/100),1);
$zoomedHeight = max(floor($image_info[1]*$zoom/100),1);
//Récupération de l'image ouverte dans une variable temporaire
$tmp_image = creerImage ($zoomedWidth, $zoomedHeight);
imagefill ($tmp_image, 0, 0, $background_color_integer);
imagecolortransparent($tmp_image, $background_color_integer);
imagealphablending($tmp_image,false);
imagesavealpha($tmp_image,true);
imagecopyresampled($tmp_image, $image, 0, 0, 0, 0, $zoomedWidth, $zoomedHeight, $image_info[0], $image_info[1]);
//Destruction et recréation de l'image dans la bonne taille
/*unset($image);
$image = creerImage ($zoomedWidth, $zoomedHeight);
/*imagefill ($image, 0, 0, $background_color_integer);
imagecolortransparent($image, $background_color_integer);
//Copie et réechantillonage de l'image depuis le contenu original vers le contenu adapté
imagecopyresampled($image, $tmp_image, 0, 0, 0, 0, $zoomedWidth, $zoomedHeight, $image_info[0], $image_info[1]);
//destruction de l'image temporaire et ajustement des tailles de l'image
unset($tmp_image);*/
$image_info[0]=$zoomedWidth;
$image_info[1]=$zoomedHeight;
switch($valign)
{
default :
case "top" :
break;
case "middle": $yDecal = floor(($zoomedHeight-$height)/2);
break;
case "bottom": $yDecal = ($zoomedHeight-1)-$height;
break;
}
switch($halign)
{
default :
case "left" :
break;
case "center": $xDecal = floor(($zoomedWidth-$width)/2);
break;
case "right": $xDecal = ($zoomedWidth-1)-$width;
break;
}
//Qui est plus petit ?
if($zoomedWidth>$width) $xFromPos = $xDecal;
else $xToPos = abs($xDecal);
if($zoomedHeight>$height) $yFromPos = $yDecal;
else $yToPos = abs($yDecal);
}
imagealphablending($tmp_image,true);
imagealphablending($image_to_send,false);
imagesavealpha($image_to_send,true);
//Copie de l'image traitée vers l'image finale
imagecopy($image_to_send, $tmp_image, $xToPos, $yToPos, $xFromPos, $yFromPos, $image_info[0], $image_info[1]);
}
//echo $local_log ;
if($image_file_name)
{
$image_file_name = clean_path($image_file_name);
call_user_func ('imagejpeg', $image_to_send, $Site['homeDir'].$image_file_name, $quality);
return $image_file_name;
}
else
{
header("MIME-Version: 1.0");
header("Content-Type: ".$image_info["mime"]);
header("Content-Transfer-Encoding: 8bit");
call_user_func ('image'.strtolower($function_suffix), $image_to_send);
}
}
?>
// fonction qui
function resume($message, $limit)
{
$resume ='';
$a = split(' ', $message);
$count =0;
foreach($a as $b)
{
$count = $count + strlen($b);
if($count<=$limit) $resume = $resume.' '.$b;
};
return $resume;
}
function downloadit($file)
{
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".basename($file)."\"");
readfile("$file");
}
?>
function DateFromMySQL($datestring)
{
$time_array = explode("-", $datestring);
$time_array = array_reverse($time_array);
$datestring = implode("/", $time_array);
return $datestring;
}
?>