Esempio n. 1
0
if (!$user_id) {
    $db->print_last_error(false);
}
$db->print_last_query();
$db->dump_query("SELECT * FROM users WHERE user_id={$user_id}");
// This is similar to the above, only it updates the data rather than insert. Also
// you'll notice that in the first one we used a string to represent the date
// and this time we're using the time function to generate a timestamp.  This is
// done to illustrate the class' ability to convert the date and time formats
// to a MySQL compatible format.  I like that alot :)
echo "<br>Updating the data in the table by changing the date_added... ";
$data = array('date_added' => time());
$rows = $db->update_array('users', $data, "user_id={$user_id}");
if (!$rows) {
    $db->print_last_error(false);
}
if ($rows > 0) {
    echo "{$rows} rows updated.";
}
$db->print_last_query();
$db->dump_query("SELECT * FROM users WHERE user_id={$user_id}");
// And now I'll just show you really quickly how to use this class to itereate
// a results set.  It's not much differnt that without using the class.  In fact,
// if you don't need to use the stripslashes and addslashes, that is, if
// $db->auto_slahses=false then using the get_row() function is totally pointless
// and can be replaced with mysql_fetch_array($r);
echo "<br>Example of how to iterate through a result set...<br> ";
$r = $db->select("SELECT user_name, email FROM users");
while ($row = $db->get_row($r, 'MYSQL_ASSOC')) {
    echo '<b>' . $row['user_name'] . "</b>'s email address is <b>" . $row['email'] . "</b><br>";
}
Esempio n. 2
0
function naming_authority($config, $webid)
{
    // set up db
    $db = new db_class();
    $db->connect('localhost', $config['db_user'], $config['db_pwd'], $config['db_name']);
    $sql = 'select webid, mbox from passwords where webid="' . $webid . '" and active = 1 and publish_mbox_sha1sum = 1 and verified_mbox=1 ';
    //print $sql . "<br/>";
    $results = $db->select($sql);
    if ($row = mysql_fetch_assoc($results)) {
        /*
        if (detect_ie() or detect_safari()) {
        
            header('Content-Type: application/xml');
        
        } else {
        
            header('Content-Type: application/rdf+xml');
        }
        
        print '<?xml version="1.0" encoding="ISO-8859-1"?>'. "\n";
        
        print '<rdf:RDF' . "\n";
        print 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n" ;
        print 'xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"' . "\n";
        print 'xmlns:foaf="http://xmlns.com/foaf/0.1/">'. "\n";
        
        print '<rdf:Description rdf:about="">' . "\n";
        print '<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/PersonalProfileDocument"/>'. "\n";
        print '<foaf:maker rdf:resource="http://webid4.me/#agent"/>' . "\n";
        print '<foaf:primaryTopic rdf:resource="http://webid4.me/#agent"/>' . "\n";
        print '</rdf:Description>'. "\n";
        
        print '<foaf:Agent rdf:about="http://webid4.me/#agent">' . "\n";
        print '<foaf:knows>' . "\n";
        print '<foaf:Agent rdf:about="' . $row['webid'] . '">' . "\n";
        print '<foaf:mbox_sha1sum>' . sha1($row['mbox']). '</foaf:mbox_sha1sum>' . "\n";
        print '</foaf:Agent>' . "\n";
        print '</foaf:knows>' . "\n";
        print '</foaf:Agent>' . "\n";
            
        print '</rdf:RDF>' . "\n";
        */
        head("knows");
        print '<table border="0" cellspacing="10">';
        print "<tr><td>webid: </td><td>" . $row['webid'] . "</td></tr>";
        print "<tr><td>mbox_sha1sum: </td><td>" . sha1($row['mbox']) . "</td></tr>";
        print "</table>";
        print "Signature: <a href='https://" . $_SERVER["SERVER_NAME"] . "/gpg.php?sign=https://" . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI'] . "'>" . $_GET['webid'] . "</a>";
        //        print "Export to: <a href='http://www.w3.org/2007/08/pyRdfa/extract?uri=https://webid4.me/?webid=" . $row['webid'] . "&amp;format=pretty-xml&amp;warnings=false&amp;parser=lax&amp;space-preserve=true&amp;submit=Go!&amp;text='>RDF/XML</a>";
        print '<div typeof="foaf:PersonalProfileDocument" about="">' . "\n";
        print '<div rel="foaf:primaryTopic" href="http://' . $_SERVER["SERVER_NAME"] . '/#agent"/>' . "\n";
        print '</div>' . "\n";
        print '<div about="http://' . $_SERVER["SERVER_NAME"] . '/#agent" typeof="foaf:Agent">' . "\n";
        print '<div rel="foaf:knows">' . "\n";
        print '<div about="' . $row['webid'] . '" typeof="foaf:Agent">' . "\n";
        print '<div property="foaf:mbox_sha1sum" content="' . sha1($row['mbox']) . '"/>' . "\n";
        print '</div>' . "\n";
        print '</div>' . "\n";
        print '</div>' . "\n";
        print '<div about="#key" typeof="wot:PubKey">' . "\n";
        print '<div rel="wot:identity" href="#agent"></div>' . "\n";
        print '<div rel="wot:pubkeyAddress" href="http://' . $_SERVER["SERVER_NAME"] . '/' . $_SERVER["SERVER_NAME"] . '-pgp.asc"></div>' . "\n";
        print '<div property="wot:hex_id" content="2E899F21"></div>' . "\n";
        print '<div property="wot:length" content="2048"></div>' . "\n";
        print '<div property="wot:fingerprint" content="DCBE32FC0BD85797360BE1D27757B1562E899F21"></div>' . "\n";
        print '</div>' . "\n";
        print '<div typeof="rdf:Description" about="">' . "\n";
        print '<div rel="wot:assurance" href="http://' . $_SERVER["SERVER_NAME"] . '/' . $_SERVER["SCRIPT_NAME"] . '.htm.asc"></div>' . "\n";
        print '</div>' . "\n";
    } else {
        main();
    }
}
Esempio n. 3
0
$certrsakey = openssl_pkey_get_public_hex();
$rdf = $_POST['rdf'];
if (empty($rdf) || $rdf == '0') {
    $rdf = '<rdf:RDF';
    printrdf('	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"');
    printrdf('	xmlns:cert="http://www.w3.org/ns/auth/cert#"');
    printrdf('	xmlns:rsa="http://www.w3.org/ns/auth/rsa#">');
    printrdf('<rsa:RSAPublicKey>');
    $foaffile = $subjectAltName['URI'] ? $subjectAltName['URI'] : 'TYPE YOUR WEBID HERE';
    printrdf('   <cert:identity rdf:resource="' . $foaffile . '"/>');
    printrdf('   <rsa:public_exponent cert:decimal="');
    $exponent = $certrsakey['exponent'] ? hexdec($certrsakey['exponent']) : 'TYPE THE EXPONENT OF YOUR PUBLIC KEY HERE';
    printrdf($exponent . '"/>');
    printrdf('   <rsa:modulus cert:hex="');
    $modulus = $certrsakey['modulus'] ? $certrsakey['modulus'] : 'TYPE THE MODULUS OF YOUR PUBLIC RSA KEY HERE';
    printrdf($modulus . '"/>');
    printrdf('</rsa:RSAPublicKey>');
    printrdf('</rdf:RDF>');
}
$res = $db->select(" select * from foaf where username like '{$_POST['uri']}' ");
if ($db->row_count == 0) {
    $db->insert_sql(" insert into foaf (id, username, rdf) VALUES (NULL, '{$_POST['uri']}', '{$rdf}')  ");
} else {
    $db->update_sql(" update foaf set rdf = '{$_POST['rdf']}' , rdf2 = '{$rdf}' where username like '{$_POST['uri']}'  ");
}
print "Congratulations, you have successfully created a foaf file, which can be permanently accessed  here: <br/><br/><a href='http://{$_SERVER['HTTP_HOST']}/{$_POST['uri']}'>http://{$_SERVER['HTTP_HOST']}/{$_POST['uri']}</a>";
?>
</div>
</body>
</html>
Esempio n. 4
0
//// number of students that have a question for individual assignment
//select count(id) as count from grp member where grp =  and assignment = 450;
//
//// number of students that have a question for group assignment
//SELECT count( DISTINCT grp ) FROM grp_member WHERE assignment =451
error_reporting(E_ERROR);
require_once './header.php';
//if (!$_SESSION['sid']){
//  header("Location:/src/php/pages/");
//}
require_once '../db.class.php';
$db = new db_class();
// query for assignment list
$aid = 0;
//assignment id
$ass = $db->select("select * from assignment");
if (isset($_REQUEST['id']) && isset($_REQUEST['is_group'])) {
    $aid = $_REQUEST['id'];
    // get range depending on if group or not
    if ($_REQUEST['is_group'] == 0) {
        $q = $db->select('select count(id) as count from grp_member where assignment =' . $aid);
    } else {
        $q = $db->select('SELECT count( DISTINCT grp ) as count FROM grp_member WHERE assignment=' . $aid);
    }
    $r = $db->get_row($q);
    $range = $r['count'];
    // we have range for the graph
    // now get questions in assignment
    //$db->print_last_error();
    $questions = $db->select('select question.id, question.description from question, assignment_question where question.id = assignment_question.question and assignment_question.assignment=' . $aid . ' order by assignment_question.ord asc');
    $jsquestions = array();
Esempio n. 5
0
    $xsl = 'foaf.xsl';
    if ($_SERVER['HTTPS'] == 'on') {
        $xsl = 'foaf_secure.xsl';
    }
    if ($auth['isAuthenticated'] == 1) {
        $xsl = 'foaf_self.xsl';
    }
    //if ($authentication_level == 'client_certificate_rsakey_matches_foaf_friend_rsakey') $xsl = 'foaf_friend.xsl';
    // overrides
    /*
    if ($_SERVER['HTTPS'] == 'on' && $_GET[username] == 'julietasfriend' ) $xsl = 'foaf_friend.xsl';
    if ($_SERVER['HTTPS'] == 'on' && $_GET[username] == 'romeoasfriend' ) $xsl = 'foaf_friend.xsl';
    if ($_SERVER['HTTPS'] == 'on' && $_GET[username] == 'julietasself' ) $xsl = 'foaf_self.xsl';
    if ($_SERVER['HTTPS'] == 'on' && $_GET[username] == 'romeoasself' ) $xsl = 'foaf_self.xsl';
    */
    $res = $db->select(" select * from foaf where username like '{$username}' ");
    if ($row = mysql_fetch_assoc($res)) {
        //logger('/home/foaf/www/datawiki/read.log', $webid, $username);
        xmlheader($xsl);
        $searchstring = '<?xml version="1.0"?>' . "\n";
        $out = $row['rdf'];
        $out = str_replace($searchstring, '', $out);
        print $out;
    } else {
        if (strstr($username, 'mbox/')) {
            //		logger('/home/foaf/www/datawiki/insert.log', $webid, $username);
            $rdf = '<rdf:RDF 
		xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
		xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
		xmlns:foaf="http://xmlns.com/foaf/0.1/" 
		xmlns:rsa="http://www.w3.org/ns/auth/rsa#" 
Esempio n. 6
0
<html>
	<head>
	<title>A SERIES OF TUBES</title>
	<link rel="stylesheet" type="text/css" href="braincrave.css" />
	<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="braincrave.js"></script>
	<script src="http://scripts.embed.ly/jquery.embedly.min.js"></script>
	</head>

	<body>
		<div align="center">
			<?php 
if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
    $image_id = $_REQUEST['id'];
    $row = $db->select("SELECT * FROM images WHERE id = {$image_id} LIMIT 1");
} else {
    $row = $db->select("SELECT * FROM images ORDER BY RAND() LIMIT 1");
}
$media = $db->get_row($row, 'MYSQL_ASSOC');
// we've got an image
$md5 = $media['md5'];
$sql = "SELECT username FROM users u WHERE id = {$media['user_id']};";
$poster = $db->select_one($sql);
$image_id = $media['id'];
$image_type = $media['type'];
$image_url = "bimages/{$md5}.{$image_type}";
$r = $db->select("SELECT id, md5, youtube_url, type FROM images WHERE id < {$image_id} ORDER BY id DESC LIMIT 1 ");
$row = $db->get_row($r, 'MYSQL_ASSOC');
$prev_img = $row['md5'] . '.' . $row['type'];
$prev_img_id = $db->select_one("SELECT id FROM images WHERE id < {$image_id} ORDER BY id DESC LIMIT 1");