radavy2009
Messages postés3Date d'inscriptionmardi 23 février 2010StatutMembreDernière intervention25 février 2010
-
23 févr. 2010 à 15:59
radavy2009
Messages postés3Date d'inscriptionmardi 23 février 2010StatutMembreDernière intervention25 février 2010
-
25 févr. 2010 à 07:49
Merci de trouver ci-dessous mon code qui ne fonctionne pas!
Merci pour votre aide!
<?php
/*
$Id: index.php,v 1.20.2.13.2.1 2007/07/16 20:26:43 sullrich Exp $
part of m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
if (!$clientip) {
/* not good - bail out */
echo "An error occured. Please check the system logs for more information.";
log_error("Captive portal could not deterimine clients ip address.");
exit;
}
if ($orig_host != $ourhostname) {
/* the client thinks it's connected to the desired web server, but instead
it's connected to us. Issue a redirect... */
/* find MAC address for client */
$clientmac = arp_get_mac_by_ip($clientip);
if (!$clientmac && $macfilter) {
/* unable to find MAC address - shouldn't happen! - bail out */
captiveportal_logportalauth("unauthenticated","noclientmac",$clientip,"ERROR");
echo "An error occured. Please check the system logs for more information.";
log_error("Captive portal could not deterimine clients MAC address. Disable MAC address filtering in captive portal if you do not needs this functionality.");
exit;
}
/* find out if we need RADIUS + RADIUSMAC or not */
if (file_exists("{$g['vardb_path']}/captiveportal_radius.db")) {
$radius_enable = TRUE;
if ($radius_enable && isset($config['captiveportal']['radmac_enable']))
$radmac_enable = TRUE;
}
if ($_POST['logout_id']) {
disconnect_client($_POST['logout_id']);
echo <<<EOD
<HTML>
<HEAD><TITLE>Disconnecting...</TITLE></HEAD>
You have been disconnected.
<SCRIPT LANGUAGE ="JavaScript">
<!--
setTimeout('window.close();',5000) ;
-->
</SCRIPT>
</HTML>
EOD;
/* The $macfilter can be removed safely since we first check if the $clientmac is present, if not we fail */
} else if ($clientmac && portal_mac_fixed($clientmac)) {
/* punch hole in ipfw for pass thru mac addresses */
portal_allow($clientip, $clientmac, "unauthenticated");
exit;
} else if ($clientmac && $radmac_enable && portal_mac_radius($clientmac,$clientip)) {
/* radius functions handle everything so we exit here since we're done */
exit;
} else if ($_POST['accept'] && $radius_enable) {
if ($_POST['auth_user'] && $_POST['auth_pass']) {
$auth_list = radius($_POST['auth_user'],$_POST['auth_pass'],$clientip,$clientmac,"USER LOGIN");
/* authentication against the radius server */
$username = mac_format($clientmac);
$auth_list = radius($username,$radmac_secret,$clientip,$clientmac,"MACHINE LOGIN");
if ($auth_list['auth_val'] == 2) {
return TRUE;
}
return FALSE;
}
function portal_allow($clientip,$clientmac,$username,$password null, $attributes null, $ruleno = null) {
global $redirurl, $g, $config, $url_redirection, $type;
/* See if a ruleno is passed, if not start locking the sessions because this means there isn't one atm */
if ($ruleno == null) {
captiveportal_lock();
$ruleno = captiveportal_get_next_ipfw_ruleno();
}
/* if the pool is empty, return appropriate message and exit */
if (is_null($ruleno)) {
portal_reply_page($redirurl, "error", "System reached maximum login capacity");
log_error("WARNING! Captive portal has reached maximum login capacity");
captiveportal_unlock();
exit;
}
// Ensure we create an array if we are missing attributes
if (!is_array($attributes))
$attributes = array();
/* read in client database */
$cpdb = captiveportal_read_db();
/* Find an existing session */
for ($i = 0; $i < count($cpdb); $i++) {
/* on the same ip */
if($cpdb[$i][2] == $clientip) {
captiveportal_logportalauth($cpdb[$i][4],$cpdb[$i][3],$cpdb[$i][2],"CONCURRENT LOGIN - REUSING OLD SESSION");
$sessionid = $cpdb[$i][5];
break;
}
elseif ((isset($config['captiveportal']['noconcurrentlogins'])) && ($username != 'unauthenticated')) {
/* on the same username */
if ($cpdb[$i][4] == $username) {
/* This user was already logged in so we disconnect the old one */
captiveportal_disconnect($cpdb[$i],$radiusservers,13);
captiveportal_logportalauth($cpdb[$i][4],$cpdb[$i][3],$cpdb[$i][2],"CONCURRENT LOGIN - TERMINATING OLD SESSION");
unset($cpdb[$i]);
break;
}
}
}
/* Add rules for traffic shaping
* We don't need to add extra l3 allow rules since traffic will pass due to the following kernel option
* net.inet.ip.fw.one_pass: 1
*/
$peruserbw = isset($config['captiveportal']['peruserbw']);
if ($peruserbw && !empty($bw_up) && is_numeric($bw_up)) {
$bw_up_pipeno = $ruleno + 40500;
exec("/sbin/ipfw add $ruleno set 2 pipe $bw_up_pipeno ip from $clientip to any in");
exec("/sbin/ipfw pipe $bw_up_pipeno config bw {$bw_up}Kbit/s queue 100");
} else {
exec("/sbin/ipfw add $ruleno set 2 skipto 50000 ip from $clientip to any in");
}
if ($peruserbw && !empty($bw_down) && is_numeric($bw_down)) {
$bw_down_pipeno = $ruleno + 45500;
exec("/sbin/ipfw add $ruleno set 2 pipe $bw_down_pipeno ip from any to $clientip out");
exec("/sbin/ipfw pipe $bw_down_pipeno config bw {$bw_down}Kbit/s queue 100");
} else {
exec("/sbin/ipfw add $ruleno set 2 skipto 50000 ip from any to $clientip out");
}
/* add ipfw rules for layer 2 */
if (!isset($config['captiveportal']['nomacfilter'])) {
$l2ruleno = $ruleno + 10000;
exec("/sbin/ipfw add $l2ruleno set 3 deny all from $clientip to any not MAC any $clientmac layer2 in");
exec("/sbin/ipfw add $l2ruleno set 3 deny all from any to $clientip not MAC $clientmac any layer2 out");
}
/* encode password in Base64 just in case it contains commas */
$bpassword = base64_encode($password);
$cpdb[] = array(time(), $ruleno, $clientip, $clientmac, $username, $sessionid, $bpassword,
$attributes['session_timeout'],
$attributes['idle_timeout'],
$attributes['session_terminate_time']);
<SCRIPT LANGUAGE ="JavaScript">
ss= 0;
s=00;
m='0'+0;
h='0'+0;
window.status = "Chrono " +h + ' : ' + m + ' : ' + s ;
function Chrono(){
if (m==0) {m='00'}
if(h==0) {h='00'}
if (ss<10){ss='0'+ss;}
if (s<10){s='0'+s;}
window.status = "Chrono " +h + ' : ' + m + ' : ' + s ;
document.formu.heure.value =+h + ' : ' + m + ' : ' + s ;
s++;
ss++;
if (h==24){h='0'+0;}
if (s==60){s=0;s=0; m++;if(m<10){m='0'+m;}}
if (m==60){m='0'+0;h++;if(h<10){h='0'+h;}}
chrono=window.setTimeout("Chrono();",1000);
}
krimog
Messages postés1860Date d'inscriptionlundi 28 novembre 2005StatutMembreDernière intervention14 février 201549 23 févr. 2010 à 16:15
AMICAL BONJOUR A TOI AUSSI
Tout d'abord, c'est du PHP. Merci de poster sur le bon forum (www.phpfrance.com) la prochaine fois.
Ensuite, tu te doutes qu'on ne va pas s'amuser à lire tout ton code pour deviner ce qui ne va pas.
Si tu as une erreur, merci de nous dire quelle erreur et où.
Krimog : while (!(succeed = try())) ; - Nous ne sommes pas des décodeurs ambulants. Le style SMS est prohibé. -
radavy2009
Messages postés3Date d'inscriptionmardi 23 février 2010StatutMembreDernière intervention25 février 2010 24 févr. 2010 à 07:07
Merci pour votre remarque !
Comme je suis bloqué pendant trois mois, et déjà demandé une solution sur le net ==> pas de solution. merci pour votre considération ici:
Mon Problème:
Il s'agit d'une code JS insérée dans un php
c'est un php d'un serveur qui nous invite une "page d'authentification" ==> une fois connecté, j'ai une fenêtre pop Up pour le déconnexion <== jusqu'ici pas de Pb.
J'ai essayé d'introduire une code JS (code chrono) (voir dessous)pour que dans ma fenêtre pop Up, on voit le chrono indiquant la durée de connexion:
kohntark
Messages postés3705Date d'inscriptionlundi 5 juillet 2004StatutMembreDernière intervention27 avril 201230 24 févr. 2010 à 18:58
En tout état de cause RT15 a mal fait son travail() puisqu'il s'agit alors de javascript, pas de PHP.
Par ailleurs nous ne toujours pas le problème exact : ça ne s'affiche pas ? Ca ne compte pas ? Tu as une erreur ? Autre chose ?
Tu devrais abandonner window.status :
- nombre d'internautes n'aiment pas (moins le premier) que l'on interfère avec les fonctionnalités du navigateur (masquage des infos de chargement en cours, terminé, ...)
- mise à part sous IE je doute que ça fonctionne sous d'autres navigateurs
radavy2009
Messages postés3Date d'inscriptionmardi 23 février 2010StatutMembreDernière intervention25 février 2010 25 févr. 2010 à 07:49
Mille merci pour votre réponse Kohntark (excuse pour ma question mal orientée,c'est très urgent pour moi)
En phase de test; je vous tiens au courant les résultats