1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| <?php
//this function enable us to connect to the database and retrieve data
//the query retrieves the values of the menu table
include('menu_connection.php');
$cx=new menu_connection();
$cx->SignIn();
// here we extract only the first link
$cx->RequestData(" select * from menu ");
$result=$cx->ResultData();
$n=$cx->NumberRow();
$menu=new menu();
$submenu=new submenu();
$menu->retrieve_menu($result);
if (!isset($_GET['menu_id']) || !is_numeric($_GET['menu_id']) || $_GET['menu_id']>$n )
{
$id=1;
}
else
{
$id=$_GET['menu_id'];
}
//$menu->show_menu($n,$id);
// traitement si l'id du menu était changé
if(isset($_GET['hash']) ) {
// echo $_GET['menu_id'].' '.$_GET['hash'].' '.md5($id);
if($_GET['hash']==md5($id))
{
// echo 'ok' ;
}
else
{
$cx->RequestData(" select menu_id from menu where hash_id='".$_GET['hash']."'");
$result=$cx->ResultData();
foreach($result as $key)
{
if(!is_numeric($_GET['menu_id']))
{ $id=1; } else {$id=$key['menu_id']; }
}
// echo 'no';
}
} else { $_GET['hash']='c4ca4238a0b923820dcc509a6f75849b'; }
$menu->show_menu($n,$id);
echo '</ul><ul id="subnav">';
//here we assign the submenus to their menu
//we check if there is a value assigned to the variable that allows us to know which link we have activated
// if there's no value assigned to the variable, that help us to know which link, we stay in the default page
if (isset($_GET['menu_id']) && is_numeric($_GET['menu_id']) && $_GET['menu_id']<=$n)
{
$id=$_GET['menu_id'];
}
$cx=new menu_connection();
$cx->SignIn();
$cx->RequestData("SELECT menu_id ,submenu_id FROM sub_menu ");
$n_s=$cx->NumberRow();
/////::::::::::::::::::::::::::::::::::::::::::::::::::::
////////////////////////////////////// reverification de la valeur de l'url
////////////////////////////////////////////:::::
$hash="";
if (isset($_GET['submenu_id']) && is_numeric($_GET['submenu_id'])&& $_GET['menu_id']<=$n_s )
{
$sid=$_GET['submenu_id'];
}
else
{
$sid=1;
}
if(isset($_GET['hash'])) {
$hash=$_GET['hash'];
if($_GET['hash']==md5($id))
{
// echo 'ok' ;
}
else
{
$cx->RequestData("select menu_id from menu where hash_id='".$hash."'");
$result=$cx->ResultData();
$n=$cx->NumberRow();
//////////:echo $n;
foreach($result as $key)
{
if(!is_numeric($_GET['menu_id']) || $n==0 )
{
$id=1;
$hash='c4ca4238a0b923820dcc509a6f75849b';
} else {$id=$key['menu_id']; }
}
$hash=md5(1);
}
} else { $hash=md5(1); }
///:::::::::::::::::::::::::::::::::::::::
// echo $hash;
$cx->RequestData("select sub_menu.submenu_id,sub_menu.submenu_libel, sub_menu.submenu_url, menu.hash_id from sub_menu , menu where menu.menu_id=sub_menu.menu_id and menu.menu_id=".$id."");
$result=$cx->ResultData();
$num=$cx->NumberRow();
$submenu->retrieve_submenu($result);
$submenu->show_submenu($num,$sid,$id);
if($num==0)
{
$id=1;
// $hash=md5(1);
}
$cx->cancel_connection();
?> |
Partager