Exemplo n.º 1
0
function foaf_password($config, $realm, $authreqissuer)
{
    /*
    print "<pre>";
    print_r($_SERVER);
    print "</pre>";
    */
    if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
        header('HTTP/1.1 401 Unauthorized');
        header('WWW-Authenticate: Digest realm="' . $realm . '",qop="auth,auth-int",nonce="' . uniqid() . '",opaque="' . md5($realm) . '"');
        //        failed_password_check('Authentication was cancelled', $authreqissuer);
        die;
    }
    // analyze the PHP_AUTH_DIGEST variable
    if (!($data = http_digest_parse($_SERVER['HTTP_AUTHORIZATION']))) {
        failed_password_check('HTTP Digest was incomplete', $authreqissuer);
    }
    //$uri = 'http://'. $data['username'];
    $uri = $data['username'];
    $uri = urldecode($uri);
    if (!is_valid_url($uri)) {
        //        $errmsg = "Authentication Failed - $uri is not a valid username for this service";
        //        failed_password_check($errmsg, $authreqissuer);
        $agent = NULL;
    } else {
        $agent = get_agent($uri);
    }
    // set up db
    $db = new db_class();
    $db->connect('localhost', $config['db_user'], $config['db_pwd'], $config['db_name']);
    $webid = isset($agent) ? $agent['agent']['webid'] : '';
    //    $sql ='select password from passwords where webid="'. $webid . '" or mbox = "' . $data['username'] . '" and active = 1 and verified_mbox = 1 ';
    $sql = 'select password from passwords where webid="' . $webid . '" and active = 1 and verified_mbox = 1 ';
    //    print $sql . "<br/>";
    $results = $db->select($sql);
    if ($row = mysql_fetch_assoc($results)) {
        $pin = $row['password'];
        // generate the valid response
        $A1 = md5($data['username'] . ':' . $realm . ':' . $pin);
        $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);
        $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);
        /*
            print "<br/>A1 = md5 (  username= "******" :realm= " . $realm . " :password/pin=  ". $pin . ")<br/>";
            print "A2 = md5 (  request_method = " . $_SERVER['REQUEST_METHOD']. " uri = " . $data['uri'] . ")<br/>";
            print "valid = md5 ( A1 : nonce= " . $data['nonce'] . " :nc= " . $data['nc'] . " :cnonce=  " . $data['cnonce'] . " :qop= " .  $data['qop'] . ")<br/>";
            print "valid response = " . $valid_response . "<br/><br/>";
            print "http digest response = " . $data['response'] . "<br/><br/>";
        */
        if ($valid_response == $data['response']) {
            //           print "auth " . $authreqissuer . "<br/><br/>";
            //           print "webid " . $agent['agent']['webid'] . "<br/><br/>";
            if (isset($authreqissuer)) {
                webid_redirect($authreqissuer, $agent['agent']['webid']);
            } else {
                login_screen($agent['agent']['webid']);
            }
        } else {
            failed_password_check('FOAF Password doesnot match', $authreqissuer);
        }
    } else {
        failed_password_check('FOAF Password doesnot match', $authreqissuer);
    }
}
Exemplo n.º 2
0
$timespace = get_timespace();
$in = $timespace[0];
$out = $timespace[1];
// set smarty config
require_once WEBROOT . 'libraries/smarty/Smarty.class.php';
$tpl = new Smarty();
$tpl->template_dir = 'templates/';
$tpl->compile_dir = 'compile/';
// read kga ---------------------------------------
$output = $kga;
// clean out sone data that is way too private to be shown in the frontend ...
if (!$kga['show_sensible_data']) {
    $output['server_hostname'] = "xxx";
    $output['server_database'] = "xxx";
    $output['server_username'] = "******";
    $output['server_password'] = "******";
    $output['usr']['secure'] = "xxx";
    $output['usr']['usr_ID'] = "xxx";
    $output['usr']['pw'] = "xxx";
}
$kga_display = print_r($output, true);
$tpl->assign('kga', $kga);
$tpl->assign('kga_display', $kga_display);
$tpl->assign('browser', get_agent());
// /read kga --------------------------------------
if ($kga['logfile_lines'] == "@") {
    $tpl->assign('limitText', "(unlimited lines)");
} else {
    $tpl->assign('limitText', "(limited to " . $kga['logfile_lines'] . " lines)");
}
$tpl->display('index.tpl');
Exemplo n.º 3
0
function getAuth($foafuri = NULL)
{
    if (!$_SERVER['HTTPS']) {
        return array('isAuthenticated' => 0, 'authDiagnostic' => 'No client certificate supplied on an unsecure connection');
    }
    if (!$_SERVER['SSL_CLIENT_CERT']) {
        return array('isAuthenticated' => 0, 'authDiagnostic' => 'No client certificate supplied');
    }
    $certrsakey = openssl_pkey_get_public_hex();
    if (!$certrsakey) {
        return array('isAuthenticated' => 0, 'authDiagnostic' => 'No RSA Key in the supplied client certificate');
    }
    $result = array('certRSAKey' => $certrsakey);
    $san = openssl_get_subjectAltName();
    $foafuri = $san['URI'];
    //	$foafuri = 'http://www.w3.org/People/Berners-Lee/card#i';
    //  $foafuri = 'http://bblfish.net/people/henry/card#me';
    //	$foafuri = 'http://danbri.org/foaf.rdf#danbri';
    //	$foafuri = 'http://foafbuilder.qdos.com/people/melvster.com/foaf.rdf';
    //	$foafuri = 'http://test.foaf-ssl.org/certs/1235593768725.rdf#accnt';
    //	$foafuri = 'http://myopenlink.net/dataspace/person/kidehen#this';
    $result = safe_array_merge($result, array('subjectAltName' => $foafuri));
    //	$foafrsakey = get_foaf_rsakey($foafuri);
    //	$result = array_merge($result, array('subjectAltNameRSAKey'=>$foafrsakey));
    if ($agent = get_agent($foafuri)) {
        $result = safe_array_merge($result, $agent);
        if ($agent['agent']['RSAKey']) {
            if (equal_rsa_keys($certrsakey, $agent['agent']['RSAKey'])) {
                $result = safe_array_merge($result, array('isAuthenticated' => 1, 'authDiagnostic' => 'Client Certificate RSAkey matches SAN RSAkey'));
            } else {
                $result = safe_array_merge($result, array('isAuthenticated' => 0, 'authDiagnostic' => 'Client Certificate RSAkey does not match SAN RSAkey'));
            }
        } else {
            $result = safe_array_merge($result, array('isAuthenticated' => 0, 'authDiagnostic' => 'No RSAKey found at supplied agent'));
        }
    } else {
        $result = safe_array_merge($result, array('isAuthenticated' => 0, 'authDiagnostic' => 'No agent found at supplied SAN'));
    }
    return $result;
}
Exemplo n.º 4
0
                $building = !empty($_POST["building"]) ? $_POST["building"] : '';
                $agentid = modify_agent($agentid, $name, $iata, $contact, $phone, $fax, $email, $billing, $town, $postcode, $street, $building, $country, $ebridgeID, $IM);
            }
            break;
        case $_L['BTN_list']:
            //link ("self","agents_list.php");
            break;
        case $_L['BTN_search']:
            //check if user is searching using name, payrollno, national id number or other fields
            //			find($_POST["search"]);
            break;
    }
}
$agent = array();
if ($agentid) {
    get_agent($agentid, $agent);
}
?>
       <table height="500" class="listing-table">	        
	       <tbody>
	       	<tr>      		
	 		<?php 
print_rightMenu_admin();
?>
 		
	          <td valign="top">
	          	
				<form action="<?php 
echo $_SERVER['REQUEST_URI'];
?>
" method="post" enctype="multipart/form-data">
Exemplo n.º 5
0
 }
 if (get_user_class() >= $userprofile_class || $user["id"] == $CURUSER["id"]) {
     if ($enablelocation_tweak == 'yes') {
         list($loc_pub, $loc_mod) = get_ip_location($user[ip]);
         $locationinfo = "<span title=\"" . $loc_mod . "\">[" . $loc_pub . "]</span>";
     } else {
         $locationinfo = "";
     }
     tr_small($lang_userdetails['row_ip_address'], $user[ip] . $locationinfo, 1);
 }
 $res = sql_query("SELECT agent, peer_id, ip, port FROM peers WHERE userid = {$user['id']} GROUP BY agent") or sqlerr();
 if (mysql_num_rows($res) > 0) {
     $first = true;
     $clientselect = "";
     while ($arr = mysql_fetch_assoc($res)) {
         $clientselect .= ($first == true ? "" : " ; ") . get_agent($arr["peer_id"], $arr["agent"]);
         $first = false;
         if (get_user_class() >= $userprofile_class || $user["id"] == $CURUSER["id"]) {
             $clientselect .= " (" . $arr["ip"] . ":" . $arr["port"] . ")";
         }
     }
 }
 if ($clientselect) {
     tr_small($lang_userdetails['row_bt_client'], $clientselect, 1);
 }
 if ($user["downloaded"] > 0) {
     $sr = floor($user["uploaded"] / $user["downloaded"] * 1000) / 1000;
     $sr = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['row_share_ratio'] . "</strong>:  <font color=\"" . get_ratio_color($sr) . "\">" . number_format($sr, 3) . "</font></td><td class=\"embedded\">&nbsp;&nbsp;" . get_ratio_img($sr) . "</td></tr>";
 }
 $xfer = "<tr><td class=\"embedded\"><strong>" . $lang_userdetails['row_uploaded'] . "</strong>:  " . mksize($user["uploaded"]) . "</td><td class=\"embedded\">&nbsp;&nbsp;<strong>" . $lang_userdetails['row_downloaded'] . "</strong>:  " . mksize($user["downloaded"]) . "</td></tr>";
 tr_small($lang_userdetails['row_transfer'], "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" . $sr . $xfer . "</table>", 1);
Exemplo n.º 6
0
function doAuth($info, $trusted = null, $fail_cancels = false, $idpSelect = null)
{
    if (!$info) {
        // There is no authentication information, so bail
        return authCancel(null);
    }
    $auth = getAuth();
    $cert_webid_23 = str_replace('#', '%23', $auth['agent']['webid']);
    $cert_webid = str_replace('http://', '', $cert_webid_23);
    //	$cert_webid = urlencode($auth['agent']['webid']);
    if ($_SERVER['HTTPS']) {
        $host = "https://openid4.me/";
    } else {
        $host = "http://openid4.me/";
    }
    $normalized_webid = $host . $cert_webid;
    if ($info->idSelect()) {
        //        if ($idpSelect) {
        //            $req_url = idURL($idpSelect);
        if ($auth[isAuthenticated]) {
            $req_url = $normalized_webid;
        } else {
            $trusted = false;
        }
        //        } else {
        //            $trusted = false;
        //        }
    } else {
        $req_url = $info->identity;
        if ($req_url != $normalized_webid) {
            //Get link header
            $link_webid = fetch_foaf_profile($req_url);
            if ($cert_webid == $link_webid) {
                $trusted = true;
            } else {
                $agent = get_agent(urldecode($link_webid));
                /*
                					print "<pre>";
                					print_r($agent);
                					print "</pre>";
                */
                $link_webid = isset($agent['agent']['webid']) ? str_replace('#', '%23', $agent['agent']['webid']) : '';
                if ($cert_webid_23 == $link_webid) {
                    $trusted = true;
                } else {
                    $trusted = false;
                }
            }
        } else {
            $trusted = true;
        }
    }
    $user = getLoggedInUser();
    setRequestInfo($info);
    /*
        if ((!$info->idSelect()) && ($req_url != idURL($user))) {
            return login_render(array(), $req_url, $req_url);
        }
    */
    $trust_root = $info->trust_root;
    if ($trusted) {
        setRequestInfo();
        $server =& getServer();
        $response =& $info->answer(true, null, $req_url);
        // Answer with some sample Simple Registration data.
        $agent = get_agent($auth['agent']['webid']);
        $sreg_data = array();
        if ($fullname = $agent['agent']['name']) {
            $sreg_data = array_merge($sreg_data, array('fullname' => $fullname));
        }
        if ($nickname = $agent['agent']['nick'][0]) {
            $sreg_data = array_merge($sreg_data, array('nickname' => $nickname));
        }
        if ($mbox = $agent['agent']['mbox'][0]) {
            $mbox = str_replace('mailto:', '', $mbox);
            $sreg_data = array_merge($sreg_data, array('email' => $mbox));
        }
        // Add the simple registration response values to the OpenID
        // response message.
        $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
        $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data);
        $sreg_response->toMessage($response->fields);
        // Generate a response to send to the user agent.
        $webresponse =& $server->encodeResponse($response);
        $new_headers = array();
        foreach ($webresponse->headers as $k => $v) {
            $new_headers[] = $k . ": " . $v;
        }
        return array($new_headers, $webresponse->body);
    } elseif ($fail_cancels) {
        return authCancel($info);
    } else {
        return trust_render($info);
    }
}
Exemplo n.º 7
0
}
if ($_SERVER['HTTPS']) {
    $host = "https://openid4.me/";
} else {
    $host = "http://openid4.me/";
}
$foaf = urldecode(substr($_SERVER['REQUEST_URI'], strlen('/')));
if (strncmp('http://', $foaf, strlen('http://')) != 0) {
    $foaf = str_replace('https://', '', $foaf);
    $foaf = 'http://' . $foaf;
}
$valid = is_valid_url($foaf);
if ($valid) {
    $store = create_store($foaf);
    $keys = get_foaf_rsakey($store, $foaf);
    $agent = get_agent($foaf);
    $len = strlen(strstr($foaf, '#'));
    $foaf_file = $rest = substr($foaf, 0, -$len);
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" 
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"
      xmlns:cert="http://www.w3.org/ns/auth/cert#"
      xmlns:foaf="http://xmlns.com/foaf/0.1/"
      xmlns:rsa="http://www.w3.org/ns/auth/rsa#"
      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="openid.server" href="<?php 
    print $host;
Exemplo n.º 8
0
 function dltable($name, $arr, $torrent)
 {
     global $lang_viewpeerlist, $viewanonymous_class, $userprofile_class, $enablelocation_tweak;
     global $CURUSER;
     $s = "<b>" . count($arr) . " {$name}</b>\n";
     if (!count($arr)) {
         return $s;
     }
     $s .= "\n";
     $s .= "<table width=825 class=main border=1 cellspacing=0 cellpadding=3>\n";
     $s .= "<tr><td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_user_ip'] . "</td>" . ($enablelocation_tweak == 'yes' || get_user_class() >= $userprofile_class ? "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_location'] . "</td>" : "") . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_connectable'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_uploaded'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_rate'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_downloaded'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_rate'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_ratio'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_complete'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_connected'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_idle'] . "</td>" . "<td class=colhead align=center width=1%>" . $lang_viewpeerlist['col_client'] . "</td></tr>\n";
     $now = time();
     foreach ($arr as $e) {
         $privacy = get_single_value("users", "privacy", "WHERE id=" . sqlesc($e['userid']));
         ++$num;
         $highlight = $CURUSER["id"] == $e['userid'] ? " bgcolor=#BBAF9B" : "";
         $s .= "<tr{$highlight}>\n";
         if ($privacy == "strong" || $torrent['anonymous'] == 'yes' && $e['userid'] == $torrent['owner']) {
             if (get_user_class() >= $viewanonymous_class || $e['userid'] == $CURUSER['id']) {
                 $s .= "<td class=rowfollow align=left width=1%><i>" . $lang_viewpeerlist['text_anonymous'] . "</i><br />(" . get_username($e['userid']) . ")";
             } else {
                 $s .= "<td class=rowfollow align=left width=1%><i>" . $lang_viewpeerlist['text_anonymous'] . "</i></a></td>\n";
             }
         } else {
             $s .= "<td class=rowfollow align=left width=1%>" . get_username($e['userid']);
         }
         $secs = max(1, $e["la"] - $e["st"]);
         if ($enablelocation_tweak == 'yes') {
             list($loc_pub, $loc_mod) = get_ip_location($e["ip"]);
             $location = get_user_class() >= $userprofile_class ? "<div title='" . $loc_mod . "'>" . $loc_pub . "</div>" : $loc_pub;
             $s .= "<td class=rowfollow align=center width=1%><nobr>" . $location . "</nobr></td>\n";
         } elseif (get_user_class() >= $userprofile_class) {
             $location = $e["ip"];
             $s .= "<td class=rowfollow align=center width=1%><nobr>" . $location . "</nobr></td>\n";
         } else {
             $location = "";
         }
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . ($e[connectable] == "yes" ? $lang_viewpeerlist['text_yes'] : "<font color=red>" . $lang_viewpeerlist['text_no'] . "</font>") . "</nobr></td>\n";
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . mksize($e["uploaded"]) . "</nobr></td>\n";
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . mksize(($e["uploaded"] - $e["uploadoffset"]) / $secs) . "/s</nobr></td>\n";
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . mksize($e["downloaded"]) . "</nobr></td>\n";
         if ($e["seeder"] == "no") {
             $s .= "<td class=rowfollow align=center width=1%><nobr>" . mksize(($e["downloaded"] - $e["downloadoffset"]) / $secs) . "/s</nobr></td>\n";
         } else {
             $s .= "<td class=rowfollow align=center width=1%><nobr>" . mksize(($e["downloaded"] - $e["downloadoffset"]) / max(1, $e["finishedat"] - $e[st])) . "/s</nobr></td>\n";
         }
         if ($e["downloaded"]) {
             $ratio = floor($e["uploaded"] / $e["downloaded"] * 1000) / 1000;
             $s .= "<td class=rowfollow align=\"center\" width=1%><font color=" . get_ratio_color($ratio) . "><nobr>" . number_format($ratio, 3) . "</nobr></font></td>\n";
         } elseif ($e["uploaded"]) {
             $s .= "<td class=rowfollow align=center width=1%>" . $lang_viewpeerlist['text_inf'] . "</td>\n";
         } else {
             $s .= "<td class=rowfollow align=center width=1%>---</td>\n";
         }
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . sprintf("%.2f%%", 100 * (1 - $e["to_go"] / $torrent["size"])) . "</nobr></td>\n";
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . mkprettytime($now - $e["st"]) . "</nobr></td>\n";
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . mkprettytime($now - $e["la"]) . "</nobr></td>\n";
         $s .= "<td class=rowfollow align=center width=1%><nobr>" . htmlspecialchars(get_agent($e["peer_id"], $e["agent"])) . "</nobr></td>\n";
         $s .= "</tr>\n";
     }
     $s .= "</table>\n";
     return $s;
 }
Exemplo n.º 9
0
    exit;
}
$k = 1;
foreach ($xml->taxon as $rec) {
    print "\n" . " {$k} of " . count($xml->taxon) . " " . $rec["name"];
    $dwc_ScientificName = "";
    $dwc_Genus = "";
    $dwc_Family = "";
    if (@$rec["rank"] == "Species") {
        $dwc_ScientificName = trim($rec["name"]);
        $dwc_Genus = substr($rec["name"], 0, stripos($rec["name"], " "));
    } else {
        $dwc_ScientificName = trim($rec["name"]);
    }
    $taxon_identifier = "AI_" . $rec["ID"];
    $agent = get_agent($rec->original_description);
    /* obsolete
       $source_url = "http://antiz.redmon.com/taxon_view.cfm?mode=advancedSearch&name=" . urlencode($dwc_ScientificName) . "&rank=&phylum=&match=substring&Submit=Search";
       */
    $source_url = "http://invertebrates.si.edu/antiz/taxon_view.cfm?mode=advancedSearch&name=" . urlencode($dwc_ScientificName) . "&rank=&phylum=&match=substring&Submit=Search";
    print "\n";
    if (@$used_taxa[$taxon_identifier]) {
        $taxon_parameters = $used_taxa[$taxon_identifier];
    } else {
        $taxon_parameters = array();
        $taxon_parameters["identifier"] = $taxon_identifier;
        $taxon_parameters["family"] = $dwc_Family;
        $taxon_parameters["genus"] = $dwc_Genus;
        $taxon_parameters["scientificName"] = $dwc_ScientificName;
        $taxon_parameters["source"] = $source_url;
        $taxon_parameters["dataObjects"] = array();
Exemplo n.º 10
0
function is_bot_agent($agent = NULL)
{
    return is_user_agent(array($robot = "/(ICC-Crawler|Teoma|Y!J-BSC|Pluggd\\/Nutch|psbot|CazoodleBot|Googlebot|Antenna|BlogPeople|AppleWebKitOpenbot|NaverBot|PlantyNet|livedoor|msnbot|FlashGet|WebBooster|MIDown|moget|InternetLinkAgent|Wget|InterGet|WebFetch|WebCrawler|ArchitextSpider|Scooter|WebAuto|InfoNaviRobot|httpdown|Inetdown|Slurp|Spider|^Iron33|^fetch|^PageDown|^BMChecker|^Jerky|^Nutscrape|Baiduspider|TMCrawler)/m"), get_agent($agent));
}
Exemplo n.º 11
0
<?php

// Include the SimplePie library, and the one that handles internationalized domain names.
require_once 'simplepie/1.1.3/simplepie.inc';
require_once 'simplepie/1.1.3/idn/idna_convert.class.php';
require_once 'lib/libAuthentication.php';
$auth = $_SESSION['auth'];
if (isset($_REQUEST['webid'])) {
    $auth = get_agent($_REQUEST['webid']);
}
// Initialize some feeds for use.
$feed = new SimplePie();
$a1 = replace_with_rss($auth['agent']['holdsAccount']);
$a2 = replace_with_rss($auth['agent']['accountProfilePage']);
if ($a1 || $a2) {
    $feed->set_feed_url(array_merge($a1 ? $a1 : array(), $a2 ? $a2 : array()));
} else {
    $feed->set_feed_url("http://example.com");
}
// When we set these, we need to make sure that the handler_image.php file is also trying to read from the same cache directory that we are.
$feed->set_favicon_handler('./handler_image.php');
$feed->set_image_handler('./handler_image.php');
// Initialize the feed.
$feed->init();
// Make sure the page is being served with the UTF-8 headers.
$feed->handle_content_type();
// Begin the (X)HTML page.
?>