Current oav website
This commit is contained in:
202
include/function.inc.php
Normal file
202
include/function.inc.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?php
|
||||
// Functions Kazar
|
||||
//
|
||||
|
||||
// Test si le fichier est appell<6C> "seul"
|
||||
//if (preg ("function.inc.php", $_SERVER['PHP_SELF']))
|
||||
//{
|
||||
// header("Location: /");
|
||||
// exit;
|
||||
//}
|
||||
|
||||
function printheader($titre){
|
||||
if(!strlen($titre)) {
|
||||
$titre = "Homepage";
|
||||
}
|
||||
require("header.inc.php");
|
||||
}
|
||||
|
||||
function printheader2($titre){
|
||||
if(!strlen($titre)) {
|
||||
$titre = "Homepage";
|
||||
}
|
||||
require("header-jquery.inc.php");
|
||||
}
|
||||
|
||||
function getimage() {
|
||||
$curdir=basename(dirname($_SERVER['SCRIPT_NAME']));
|
||||
if(empty($curdir)) {
|
||||
return "intro";
|
||||
} else {
|
||||
return $curdir;
|
||||
}
|
||||
}
|
||||
|
||||
// Captcha (cf http://www.webelix.net/trucs_et_astuces-(PHP)_Anti_Robots_Spammeurs.html)
|
||||
|
||||
function aff_captcha()
|
||||
{
|
||||
// Tableau de valeurs
|
||||
$input = array(2, 35, 15, 6, 40, 4, 8, 22, 11, 5, 32, 10, 1, 12, 26, 16, 55, 17);
|
||||
// Extraction al<61>atoire de deux valeurs du tableau
|
||||
$rand_keys = array_rand($input, 2);
|
||||
// Creation et calcul de la somme des deux valeurs
|
||||
$question = 'Quelle est la somme de <strong>'.$input[$rand_keys[0]].' + '.$input[$rand_keys[1]].' = </strong>';
|
||||
$add = md5($input[$rand_keys[0]] + $input[$rand_keys[1]]);
|
||||
|
||||
echo '<table cellspacing="0" cellpadding="6" style="border: 1px solid red">
|
||||
<tr>
|
||||
<td><strong>Anti-Spam : </strong>'. $question .'</td>
|
||||
<td><input name="reponse" type="text" size="3" maxlength="3" value="" style="font-weight: bold" />
|
||||
<input name="captcha" type="hidden" value="'. $add .'" /></td>
|
||||
</tr>
|
||||
</table>';
|
||||
}
|
||||
|
||||
function valid_captcha()
|
||||
{
|
||||
// if (md5($_POST['reponse']) == $_POST['captcha'])
|
||||
if (md5(get_post('reponse')) == get_post('captcha'))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// escape_string
|
||||
// Action: Escape a string
|
||||
// Call: escape_string (string string)
|
||||
//
|
||||
function escape_string ($string)
|
||||
{
|
||||
if (get_magic_quotes_gpc () == 0)
|
||||
{
|
||||
$search = array ("/'/", "/\"/", "/;/");
|
||||
$replace = array ("\\\'", "\\\"", "\\;");
|
||||
$escaped_string = preg_replace ($search, $replace, $string);
|
||||
}
|
||||
else
|
||||
{
|
||||
$escaped_string = $string;
|
||||
}
|
||||
return $escaped_string;
|
||||
}
|
||||
|
||||
//
|
||||
// get_post
|
||||
// Action: Get a variable from POST
|
||||
// Call: get_post('var');
|
||||
//
|
||||
function get_post ($string)
|
||||
{
|
||||
if (($_SERVER['REQUEST_METHOD'] == "POST") && isset($_POST[$string]))
|
||||
{
|
||||
return escape_string($_POST[$string]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// get_get
|
||||
// Action: Get a variable from GET
|
||||
// Call: get_get('var');
|
||||
//
|
||||
function get_get ($string)
|
||||
{
|
||||
if (($_SERVER['REQUEST_METHOD'] == "GET") && isset($_GET[$string]))
|
||||
{
|
||||
return escape_string($_GET[$string]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Pour le menu parse_ini_file();
|
||||
|
||||
function searchini() {
|
||||
return dirname(__FILE__)."/menu.ini";
|
||||
}
|
||||
|
||||
function domenu() {
|
||||
$menu = parse_ini_file(searchini(),true);
|
||||
$topmenu = $menu['topmenu'];
|
||||
$out = ""; // Out text for menu
|
||||
if (count($topmenu)> 10) {
|
||||
return "Error Too mutch lines in top menu (max 4)";
|
||||
}
|
||||
// Top menu
|
||||
$out .= "<div class=\"divmenuhaut\">\n";
|
||||
//$out .= "<p> </p><p> </p>\n";
|
||||
$out .= "<p> </p>\n";
|
||||
$out .= "<ul class=\"menu\">\n";
|
||||
foreach ($topmenu as $line => $val) {
|
||||
$out .= "<li><a class=\"";
|
||||
if ($line == getimage()) {
|
||||
$out .= "menuon";
|
||||
} else {
|
||||
$out .= "menuoff";
|
||||
}
|
||||
$out .= "\" href=\"/";
|
||||
if ($line != "intro") {
|
||||
$out .= $line."/";
|
||||
}
|
||||
$out .= "\" >";
|
||||
if ($line == getimage()) {
|
||||
$out .= "> ";
|
||||
}
|
||||
$out .= $val."</a></li>";
|
||||
}
|
||||
$out .= "</ul></div>\n";
|
||||
// Bottom menu
|
||||
/*
|
||||
$out .= "<div class=\"divmenubas\">\n";
|
||||
$out .= "<ul class=\"menu\">\n";
|
||||
foreach ($bottommenu as $line => $val) {
|
||||
$out .= "<li><a class=\"";
|
||||
if ($line == getimage()) {
|
||||
$out .= "menuon";
|
||||
} else {
|
||||
$out .= "menuoff";
|
||||
}
|
||||
$out .= "\" href=\"/";
|
||||
if ($line != "intro") {
|
||||
$out .= $line."/";
|
||||
}
|
||||
$out .= "\" >";
|
||||
if ($line == getimage()) {
|
||||
$out .= "> ";
|
||||
}
|
||||
$out .= $val."</a></li>";
|
||||
}
|
||||
$out .= "</ul></div>\n";
|
||||
*/
|
||||
|
||||
print $out;
|
||||
|
||||
}
|
||||
|
||||
// Page
|
||||
// Do the page with the right title
|
||||
function page($titre) {
|
||||
printheader($titre);
|
||||
domenu();
|
||||
print "<div class=\"textebox\">\n";
|
||||
}
|
||||
function page2($titre) {
|
||||
printheader2($titre);
|
||||
domenu();
|
||||
print "<div class=\"textebox\">\n";
|
||||
}
|
||||
|
||||
// finpage
|
||||
// ajoute les tags en fin de page
|
||||
function finpage(){
|
||||
require("bottom.inc.php");
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user