require "setup.html" ?>
$username="scichem";
$password="sc1ch3m";
$database="scichem";
global $r_inchi; global $q_inchi; global $a_inchi;
global $r_cid; global $q_cid; global $a_cid;
global $r_sid; global $q_sid; global $a_sid;
global $r_cas; global $q_cas; global $a_cas;
global $r_name; global $q_name; global $a_name;
global $r_mass; global $q_mass; global $a_mass;
global $r_formula; global $q_formula; global $a_formula;
global $r_weight; global $q_weight; global $a_weight;
global $r_csmiles; global $q_csmiles; global $a_csmiles;
global $r_ismiles; global $q_ismiles; global $a_ismiles;
global $r_topo; global $q_topo; global $a_topo;
global $r_mono; global $q_mono; global $a_mono;
global $r_page; global $q_page; global $a_page;
global $r_syns; global $q_syns; global $a_syns;
global $r_chebi; global $q_chebi; global $a_chebi;
global $r_kegg; global $q_kegg; global $a_kegg;
global $r_med; global $q_med; global $a_med;
global $r_bio; global $q_bio; global $a_bio;
global $r_prod; global $q_prod; global $a_prod;
global $r_reg; global $q_reg; global $a_reg;
global $r_cname; global $q_cname; global $a_cname;
global $r_pretty; global $q_pretty; global $a_pretty;
global $r_symmetrical; global $q_symmetrical; global $a_symmetrical;
global $r_interesting; global $q_interesting; global $a_interesting;
global $r_comments; global $q_comments; global $a_comments;
global $r_image; global $q_image; global $a_image;
$link_identifier = mysql_connect(localhost,$username,$password);
if( mysql_error() )
die( "
" . mysql_error() );
@mysql_select_db($database) or die( "Unable to select database");
function myq( $query )
{
//
// mysql_query() shortcut with error handling
//
$sqlout = mysql_query($query);
if( mysql_error() )
die("
myq: ".mysql_error()."
query: ".$query);
else
return $sqlout;
}
//
// Quote variable to make safe
//
function quote_smart( $value, $id )
{
if( ! isset( $value ) )
return NULL;
if( $value == NULL )
return NULL;
//
// Stripslashes
//
if( get_magic_quotes_gpc() )
$value = stripslashes($value);
//
// Escape if not integer
//
if( ! is_numeric( $value ) )
{
//$value = mysql_real_escape_string( $value, $id );
$value = mysql_escape_string( $value );
}
return $value;
}
//
// Quote variable to make safe
//
function quote_number( $value, $id )
{
if( ! isset( $value ) )
return NULL;
if( $value == NULL )
return NULL;
//
// Stripslashes
//
if( get_magic_quotes_gpc() )
$value = stripslashes($value);
//
// Escape if not integer
//
if( ! is_numeric( $value ) )
{
$parts = explode( ",", $value );
$value = implode( "", $parts );
$value = mysql_escape_string( $value );
}
return $value;
}
function undo_escapes( $value )
{
$value = str_replace("\\r", "\r", $value);
$value = str_replace("\\n", "\n
", $value);
//
// Stripslashes
//
if( get_magic_quotes_gpc() )
$value = stripslashes($value);
return $value;
}
function remove_escapes( $value )
{
$value = str_replace("\\r", "\r", $value);
$value = str_replace("\\n", "\n", $value);
//
// Stripslashes
//
if( get_magic_quotes_gpc() )
$value = stripslashes($value);
return $value;
}
function space_to_plus( $value )
{
$value = str_replace(" ", "+", $value);
return $value;
}
function plus_to_space( $value )
{
$value = str_replace("+", " ", $value);
return $value;
}
function space_to_underscore( $value )
{
$value = str_replace(" ", "_", $value);
return $value;
}
function initial_cap( $value )
{
$first_letter = $value{0};
$rest = substr($value,1);
$first_letter = strtoupper( $first_letter );
$value = $first_letter . $rest;
return $value;
}
function mysql_result_all( $result )
{
echo '\n';
for( $i = 0; $i < mysql_num_fields( $result ); $i++ )
{
echo '';
echo mysql_field_name( $result, $i );
echo ' | ';
}
while( $row = mysql_fetch_array( $result ) )
{
echo '';
for( $i = 0; $i < count( $row ); $i++ )
{
echo '' . $row[$i] . ' | ';
}
echo '
';
}
echo '
\n';
}
function get_or_post( $str, $id )
{
$item = quote_smart( $_POST[$str], $id );
if( $item == '' )
$item = quote_smart( $_GET[$str], $id );
return $item;
}
function get_record( $i, $result )
{
global $link_identifier;
global $r_inchi; global $q_inchi; global $a_inchi;
global $r_cid; global $q_cid; global $a_cid;
global $r_sid; global $q_sid; global $a_sid;
global $r_cas; global $q_cas; global $a_cas;
global $r_name; global $q_name; global $a_name;
global $r_mass; global $q_mass; global $a_mass;
global $r_formula; global $q_formula; global $a_formula;
global $r_weight; global $q_weight; global $a_weight;
global $r_csmiles; global $q_csmiles; global $a_csmiles;
global $r_ismiles; global $q_ismiles; global $a_ismiles;
global $r_topo; global $q_topo; global $a_topo;
global $r_mono; global $q_mono; global $a_mono;
global $r_page; global $q_page; global $a_page;
global $r_syns; global $q_syns; global $a_syns;
global $r_chebi; global $q_chebi; global $a_chebi;
global $r_kegg; global $q_kegg; global $a_kegg;
global $r_med; global $q_med; global $a_med;
global $r_bio; global $q_bio; global $a_bio;
global $r_prod; global $q_prod; global $a_prod;
global $r_reg; global $q_reg; global $a_reg;
global $r_cname; global $q_cname; global $a_cname;
global $r_pretty; global $q_pretty; global $a_pretty;
global $r_symmetrical; global $q_symmetrical; global $a_symmetrical;
global $r_interesting; global $q_interesting; global $a_interesting;
global $r_comments; global $q_comments; global $a_comments;
global $r_image; global $q_image; global $a_image;
global $id;
print "";
}
$inchi = get_or_post( 'inchi', $link_identifier );
$cid = get_or_post( 'cid', $link_identifier );
$sid = get_or_post( 'sid', $link_identifier );
$cas = get_or_post( 'cas', $link_identifier );
$name = get_or_post( 'name', $link_identifier );
if( $arg_inchi != '' )
$inchi = $arg_inchi;
function utime()
{
return (vsprintf('%d%06d', gettimeofday()));
}
function link_inchi( $inchi )
{
global $r_inchi; global $q_inchi; global $a_inchi;
global $r_cid; global $q_cid; global $a_cid;
global $r_sid; global $q_sid; global $a_sid;
global $r_cas; global $q_cas; global $a_cas;
global $r_name; global $q_name; global $a_name;
global $r_mass; global $q_mass; global $a_mass;
global $r_formula; global $q_formula; global $a_formula;
global $r_weight; global $q_weight; global $a_weight;
global $r_csmiles; global $q_csmiles; global $a_csmiles;
global $r_ismiles; global $q_ismiles; global $a_ismiles;
global $r_topo; global $q_topo; global $a_topo;
global $r_mono; global $q_mono; global $a_mono;
global $r_page; global $q_page; global $a_page;
global $r_syns; global $q_syns; global $a_syns;
global $r_chebi; global $q_chebi; global $a_chebi;
global $r_kegg; global $q_kegg; global $a_kegg;
global $r_med; global $q_med; global $a_med;
global $r_bio; global $q_bio; global $a_bio;
global $r_prod; global $q_prod; global $a_prod;
global $r_reg; global $q_reg; global $a_reg;
global $r_cname; global $q_cname; global $a_cname;
global $r_pretty; global $q_pretty; global $a_pretty;
global $r_symmetrical; global $q_symmetrical; global $a_symmetrical;
global $r_interesting; global $q_interesting; global $a_interesting;
global $r_comments; global $q_comments; global $a_comments;
global $r_image; global $q_image; global $a_image;
$q = sprintf("SELECT * FROM scichem WHERE inchi='%s'",mysql_escape_string($inchi));
$result = myq($q,$link_identifier);
$num = mysql_num_rows($result);
if( $num > 0 )
{
get_record( $i, $result );
printf( "\n" );
printf( "%s\n", $r_page, $inchi );
}
else
{
printf( "%s\n", $r_page, $inchi );
}
flush();
}
?>