<?
<? // LDAP - PHP interface for Wagtail // v0.2 include("config.php"); include("functions.php"); // Login dn and password set as cookies $login_dn = (isset( $_COOKIE['login_dn'] ) and $_COOKIE['login_dn']!="" )? $_COOKIE['login_dn'] : "anon"; $login_pass = isset( $_COOKIE['login_pass'] ) ? $_COOKIE['login_pass'] : null; $Command=$_REQUEST['Command']; $region=$_REQUEST['region']; // Need to set new cookies before any text sent if($_REQUEST['Command']=='Log In'){ $uid=$_REQUEST['uid']; $ldapuser=getUserFromUID($uid); $login_pass=$_REQUEST['pw']; // See if can bind with those values $ldapConn = ldap_connect($ldapServer); ldap_set_option( $ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3 ); $ldapBind = ldap_bind($ldapConn,$ldapuser,$login_pass); if ($ldapBind){ setcookie('login_dn', $ldapuser); setcookie('login_pass', $login_pass); $login_dn=$ldapuser; $login_pass=$_REQUEST['pw']; } else{ print "Unable to connect to $ldapServer as $ldapuser with that password<p>"; }
if (isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $link = mysqli_connect('localhost', 'user', 'pass', "db") or die($debug ? mysqli_connect_error() : "0"); $link->set_charset("utf8"); $ipE = explode('.', $ip); $ipE = sprintf("%02X%02X%02X%02X", intval($ipE[0]), intval($ipE[1]), intval($ipE[2]), intval($ipE[3])); $link->query("update LOW_PRIORITY ignore protest set lastvisit=now() where ip='{$ipE}' limit 1") or die($debug ? $link->error : "0"); if (!$isupdate) { if ($link->affected_rows < 1) { $country = getCN($ip); if ($country) { $link->query("insert LOW_PRIORITY ignore into protest (ip,country) value ('{$ipE}','{$country}')") or die($debug ? $link->error : "0"); echo "{$country},me\n"; } } else { $result = $link->query("SELECT country FROM protest where ip='{$ipE}' limit 1") or die($debug ? $link->error : "0"); if ($result->num_rows > 0) { $row = $result->fetch_array(MYSQLI_NUM); echo $row[0] . ",me\n"; } } $link->query("insert LOW_PRIORITY ignore into protest_stats (num,numall) value ((select count(*) from protest where lastvisit>now()-interval 10 minute),(select count(*) from protest))"); } $result = $link->query("SELECT * FROM protest_show") or die($debug ? $link->error : "0"); if ($result->num_rows > 0) {