[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 /** 5 * Page pour fixer les plages horaires du squidguard sur le proxy 6 * @Version $Id: getTimes.php 3462 2009-01-08 16:26:38Z misterT $ 7 8 * @Projet LCS-SE3 9 * @auteurs MrT 10 * @Licence Distribue sous la licence GPL 11 */ 12 13 /** 14 * @Repertoire se3-internet/ 15 * file getTimes.php 16 */ 17 18 19 include "Internet.inc.php"; 20 include "entete_ajax.inc.php"; 21 include "ldap.inc.php"; 22 include "ihm.inc.php"; 23 24 function mk_select($id,$jours) { 25 26 $choix_jours ='<select class="days" id="'.$id.'" name="'.$id.'">'; 27 28 if ($jours == 'weekly *') 29 $choix_jours .='<option value="weekly *" selected>Tous les jours</option>'; 30 else 31 $choix_jours .='<option value="weekly *" >Tous les jours</option>'; 32 if ($jours == 'weekly saturday') 33 $choix_jours .='<option value="weekly saturday" selected>Le samedi</option>'; 34 else 35 $choix_jours .='<option value="weekly saturday">Le samedi</option>'; 36 if ($jours == 'weekly sunday') 37 $choix_jours .='<option value="weekly sunday" selected>Le dimanche</option>'; 38 else 39 $choix_jours .='<option value="weekly sunday">Le dimanche</option>'; 40 if ($jours == 'weekly mtwhf') 41 $choix_jours .='<option value="weekly mtwhf" selected>Du lundi au vendredi</option>'; 42 else 43 $choix_jours .='<option value="weekly mtwhf">Du lundi au vendredi</option>'; 44 $choix_jours .='</select>'; 45 echo $choix_jours; 46 } 47 48 // recuperer les parametres passes par POST 49 if ($_POST) 50 extract($_POST); 51 if ($_GET) 52 extract($_GET); 53 54 55 if (is_admin("se3_is_admin",$login)=="Y") { 56 $role="admin"; 57 } elseif (is_admin("sovajon_is_admin",$login)=="Y") { 58 $role="prof"; 59 } else { 60 $role="eleve"; 61 } 62 63 if ($role !="admin") { 64 //redirection 65 } 66 67 if ($mode == 'show_plages') { 68 69 $sql = "select * from squid_plages WHERE nom <> 'all' ORDER BY `nom` "; 70 $c = mysql_query($sql) or die("Erreur $sql"); 71 $x = 1; 72 echo "<table width=\"90%\" align=\"center\" border=\"0\"><tr>"; 73 while ($R = mysql_fetch_object($c)) { 74 echo "<td width=\"120px\" ><strong><div id=\"nom_plage\">$R->nom</div></strong><br />"; 75 if ($R->nom != 'pause' && $R->nom != 'soir' && $R->nom != 'cours1') 76 echo "<A href=\"#\" class=\"link_delete\" id=\"linkD_$R->nom\">Effacer</A>"; 77 echo "<br /><A href=\"#\" class=\"link_modify\" id=\"linkM_$R->nom\">Modifier</A></td>". 78 "<td width=120px><img width=60px id=\"img_$R->nom\" src=\"/elements/images/se3-internet/clock.jpg\"></img></td>"; 79 if ($x % 3 == 0) 80 echo "</tr><tr>"; 81 $x++; 82 } 83 echo '<tr><td colspan="3" width="120px"> </td></tr><tr><td colspan="3"><input id="new_plage" value="coursX"></input><input id="btn_add_plage" type="button" value="Ajouter une plage horaire"></input></td></tr>'; 84 echo '<tr><td colspan="3" ><A href="#" onclick="readConf();">Lire la configuration</A></td></tr>'; 85 echo "</table>"; 86 87 88 die(''); 89 90 } 91 92 if ($mode == 'delete') { 93 $info = explode('_',$plage); 94 $plage = $info[1]; 95 $sql = "SELECT id from squid_plages where nom ='$plage'"; 96 $c = mysql_query($sql) or die("Err $sql"); 97 if (mysql_num_rows($c) != 0) { 98 $id = mysql_result($c,"id",0); 99 $sql = "DELETE from squid_horaire where id_plage ='$id'"; 100 $c = mysql_query($sql) or die("Err $sql"); 101 $sql = "DELETE from squid_plages where id ='$id'"; 102 $c = mysql_query($sql) or die("Err $sql"); 103 } 104 105 die(''); 106 } 107 108 109 if ($mode == 'update') { 110 $infos = array_reverse(explode('_',$id_hor)); 111 $idH = $infos[0]; 112 $sql = "SELECT * from squid_horaire where id='$idH'"; 113 $c = mysql_query($sql) or die("Err $sql"); 114 if (mysql_num_rows($c) != 0) { 115 116 $sql = "UPDATE squid_horaire SET `de`='$from', `a`='$to', `jours`='$days' WHERE id='$idH';"; 117 $c = mysql_query($sql) or die("Err $sql"); 118 } 119 die(''); 120 121 } 122 123 124 125 if ($mode == 'modify') { 126 127 $info = explode('_',$plage); 128 $plage = $info[1]; 129 $sql = "SELECT id from squid_plages where nom ='$plage'"; 130 $c = mysql_query($sql) or die("Err $sql"); 131 if (mysql_num_rows($c) != 0) { 132 $id = mysql_result($c,"id",0); 133 $sql = "SELECT * from squid_horaire where id_plage ='$id'"; 134 $c = mysql_query($sql) or die("Err $sql"); 135 echo "<br /><strong><div id=\"nom_plage\">$plage</div></strong><br />"; 136 while ($R = mysql_fetch_object($c)) { 137 $from =$R->de; 138 $to = $R->a; 139 $days = $R->jours; 140 echo '<br />De <input class="from" size="3" id="from_'.$plage.'_'.$R->id.'" value="'.$from.'"></input> '; 141 echo 'à <input class="to" size="3" id="to_'.$plage.'_'.$R->id.'" value="'.$to.'"></input> '; 142 echo mk_select("days_".$plage."_".$R->id,$days); 143 echo ' <A href="#" id="'.$R->id.'_del_cren" class="del_cren">Effacer</A>'; 144 145 } 146 147 148 } 149 if (mysql_num_rows($c) != 0) 150 echo '<br /><input id="save_modifs" type="button" value="Enregistrer les modifications"></input>'; 151 152 echo '<br /><br />De <input size="3" id="new_from" value="00:00"></input> '; 153 echo 'à <input size="3" id="new_to" value="00:00"></input> '; 154 echo mk_select("new_days","*"); 155 echo ' <A href="#" id="addCren_'.$plage.'" class="add_cren">Ajouter</A>'; 156 157 echo '<br /><br /><A target="main" href="config_time.php">Retour</A> '; 158 die(''); 159 } 160 161 if ($mode == 'add_plage') { 162 163 $sql = "SELECT * from squid_plages where nom ='$plage'"; 164 $c = mysql_query($sql) or die("Err $sql"); 165 if (mysql_num_rows($c) == 0) { 166 $sql = "INSERT INTO squid_plages VALUE ('','$new_plage')"; 167 $c = mysql_query($sql) or die("Err $sql"); 168 } 169 die(''); 170 } 171 172 173 if ($mode == 'add_cren') { 174 $infos = explode('_',$plage); 175 $plage = $infos[1]; 176 $sql = "SELECT id from squid_plages where nom ='$plage'"; 177 $c = mysql_query($sql) or die("Err $sql"); 178 if (mysql_num_rows($c) != 0) { 179 $R = mysql_fetch_object($c); 180 $sql = "INSERT INTO squid_horaire VALUE ('','$R->id','$from','$to','$days');"; 181 $c = mysql_query($sql) or die("Err $sql"); 182 } 183 die(''); 184 185 } 186 187 if ($mode == 'del_cren') { 188 $infos = explode('_',$id); 189 $id_cren = $infos[0]; 190 $sql = "DELETE from squid_horaire where id ='$id_cren'"; 191 $c = mysql_query($sql) or die("Err $sql"); 192 die(''); 193 194 } 195 196 197
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |