Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43d66a2
commit d2a1c26
Showing
23 changed files
with
7,887 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
<?php | ||
|
||
$enable_debug = (!empty($_REQUEST['debug'])); | ||
|
||
function get_form_tag() | ||
{ | ||
global $enable_debug; | ||
if ($enable_debug) | ||
return("<form><input type='hidden' name='debug' value='true'>"); | ||
return("<form method='post' action='${_SERVER['PHP_SELF']}'>"); | ||
} // get_form_tag | ||
|
||
|
||
function is_authorized_vendor() | ||
{ | ||
return(!empty($_SERVER['REMOTE_USER'])); | ||
} // is_authorized_vendor | ||
|
||
|
||
function write_error($err) | ||
{ | ||
echo "<p><center><font color='#FF0000'>"; | ||
echo "ERROR: $err<br>"; | ||
echo "</font></center>\n"; | ||
} // write_error | ||
|
||
|
||
function write_debug($dbg) | ||
{ | ||
global $enable_debug; | ||
if ($enable_debug) | ||
{ | ||
echo "<p><center><font color='#0000FF'>"; | ||
echo "DEBUG: $dbg<br>"; | ||
echo "</font></center>\n"; | ||
} // if | ||
} // write_debug | ||
|
||
|
||
function current_sql_datetime() | ||
{ | ||
$t = localtime(time(), true); | ||
return( "" . ($t['tm_year'] + 1900) . '-' . | ||
($t['tm_mon'] + 1) . '-' . | ||
($t['tm_mday']) . ' ' . | ||
($t['tm_hour']) . ':' . | ||
($t['tm_min']) . ':' . | ||
($t['tm_sec']) ); | ||
} // current_sql_datetime | ||
|
||
|
||
function get_alext_wiki_url($extname) | ||
{ | ||
$htmlextname = htmlentities($extname, ENT_QUOTES); | ||
return("wiki/$htmlextname"); | ||
} // get_alext_wiki_url | ||
|
||
|
||
function get_alext_url($extname) | ||
{ | ||
$htmlextname = htmlentities($extname, ENT_QUOTES); | ||
return("${_SERVER['PHP_SELF']}?operation=op_showext&extname=${htmlextname}"); | ||
} // get_alext_url | ||
|
||
|
||
function get_input_sanitized($reqname, $reqtype, &$reqval, $defval=false) | ||
{ | ||
$val = $_REQUEST[$reqname]; | ||
if (!isset($val)) | ||
{ | ||
if (!$defval) | ||
{ | ||
write_error("No $reqtype specified."); | ||
return false; | ||
} // if | ||
$reqval = $defval; | ||
return true; | ||
} // if | ||
|
||
$reqval = trim($val); | ||
if ($reqval == '') | ||
{ | ||
write_error("$reqtype is blank: Please fill out all fields."); | ||
return false; | ||
} // if | ||
|
||
return true; | ||
} // get_input_sanitized | ||
|
||
|
||
function get_input_string($reqname, $reqtype, &$reqval, $defval=false) | ||
{ | ||
return get_input_sanitized($reqname, $reqtype, $reqval, $defval); | ||
} // get_input_string | ||
|
||
|
||
function get_input_bool($reqname, $reqtype, &$reqval, $defval=false) | ||
{ | ||
$tmp = ''; | ||
if (!get_input_sanitized($reqname, $reqtype, $tmp, $defval)) | ||
return false; | ||
|
||
$tmp = strtolower($tmp); | ||
if (($tmp == 'y') || ($tmp == 'yes') || | ||
($tmp == 't') || ($tmp == 'true') || | ||
($tmp == '1')) | ||
{ | ||
$reqval = 1; | ||
return true; | ||
} // if | ||
|
||
if (($tmp == 'n') || ($tmp == 'no') || | ||
($tmp == 'f') || ($tmp == 'false') || | ||
($tmp == '0')) | ||
{ | ||
$reqval = 0; | ||
return true; | ||
} // if | ||
|
||
write_error("$reqtype is not true or false"); | ||
return false; | ||
} // get_input_bool | ||
|
||
|
||
function get_input_number($reqname, $reqtype, &$reqval, $defval=false) | ||
{ | ||
if (!get_input_sanitized($reqname, $reqtype, $reqval, $defval)) | ||
return false; | ||
|
||
if (sscanf($reqval, "0x%X", &$hex) == 1) // it's a 0xHEX value. | ||
$reqval = $hex; | ||
|
||
if (!is_numeric($reqval)) | ||
{ | ||
write_error("$reqtype isn't a number"); | ||
return false; | ||
} // if | ||
|
||
return true; | ||
} // get_input_number | ||
|
||
|
||
function get_input_int($reqname, $reqtype, &$reqval, $defval=false) | ||
{ | ||
if (!get_input_number($reqname, $reqtype, $reqval)) | ||
return false; | ||
|
||
$reqval = (int) $reqval; | ||
return true; | ||
} // get_input_int | ||
|
||
|
||
function get_input_float($reqname, $reqtype, &$reqval, $defval=false) | ||
{ | ||
if (!get_input_number($reqname, $reqtype, $reqval)) | ||
return false; | ||
|
||
$reqval = (float) $reqval; | ||
return true; | ||
} // get_input_float | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?php | ||
|
||
// This file adds a little bit of a wrapper over MySQL, and a little | ||
// bit of convenience functionality. | ||
|
||
require_once 'common.php'; | ||
|
||
// This should have the following lines, minus comments: | ||
// | ||
// $dbuser = 'username'; | ||
// $dbpass = 'password'; | ||
// | ||
// Obviously, those should be a real username and password for the database. | ||
require_once 'dbpasswd.php'; | ||
|
||
$dblink = NULL; | ||
|
||
function get_dblink() | ||
{ | ||
global $dblink; | ||
|
||
if ($dblink == NULL) | ||
{ | ||
global $dbuser, $dbpass; | ||
$dblink = mysql_connect('localhost', $dbuser, $dbpass); | ||
if (!$dblink) | ||
{ | ||
$err = mysql_error(); | ||
write_error("Failed to open database link: ${err}."); | ||
$dblink = NULL; | ||
} // if | ||
|
||
if (!mysql_select_db("alextreg")) | ||
{ | ||
$err = mysql_error(); | ||
write_error("Failed to select database: ${err}."); | ||
mysql_close($dblink); | ||
$dblink = NULL; | ||
} // if | ||
} // if | ||
|
||
return($dblink); | ||
} // get_dblink | ||
|
||
|
||
function db_escape_string($str) | ||
{ | ||
return(mysql_escape_string($str)); | ||
} // db_escape_string | ||
|
||
|
||
function do_dbquery($sql, $link = NULL) | ||
{ | ||
if ($link == NULL) | ||
$link = get_dblink(); | ||
|
||
if ($link == NULL) | ||
return(false); | ||
|
||
write_debug("SQL query: [$sql]"); | ||
|
||
$rc = mysql_query($sql, $link); | ||
if ($rc == false) | ||
{ | ||
$err = mysql_error(); | ||
write_error("Problem in SELECT statement: {$err}"); | ||
return(false); | ||
} // if | ||
|
||
return($rc); | ||
} // do_dbquery | ||
|
||
|
||
function do_dbwrite($sql, $verb, $expected_rows = 1, $link = NULL) | ||
{ | ||
if ($link == NULL) | ||
$link = get_dblink(); | ||
|
||
if ($link == NULL) | ||
return(false); | ||
|
||
write_debug("SQL $verb: [$sql]"); | ||
|
||
$rc = mysql_query($sql, $link); | ||
if ($rc == false) | ||
{ | ||
$err = mysql_error(); | ||
$upperverb = strtoupper($verb); | ||
write_error("Problem in $upperverb statement: {$err}"); | ||
return(false); | ||
} // if | ||
|
||
$retval = mysql_affected_rows($link); | ||
if (($expected_rows >= 0) and ($retval != $expected_rows)) | ||
{ | ||
$err = mysql_error(); | ||
write_error("Database $verb error: {$err}"); | ||
} // if | ||
|
||
return($retval); | ||
} // do_dbwrite | ||
|
||
|
||
function do_dbinsert($sql, $expected_rows = 1, $link = NULL) | ||
{ | ||
return(do_dbwrite($sql, 'insert', $expected_rows, $link)); | ||
} // do_dbinsert | ||
|
||
|
||
function do_dbupdate($sql, $expected_rows = 1, $link = NULL) | ||
{ | ||
return(do_dbwrite($sql, 'update', $expected_rows, $link)); | ||
} // do_dbupdate | ||
|
||
|
||
function do_dbdelete($sql, $expected_rows = 1, $link = NULL) | ||
{ | ||
return(do_dbwrite($sql, 'delete', $expected_rows, $link)); | ||
} // do_dbdelete | ||
|
||
|
||
function db_num_rows($query) | ||
{ | ||
return(mysql_num_rows($query)); | ||
} // db_num_rows | ||
|
||
|
||
function db_fetch_array($query) | ||
{ | ||
return(mysql_fetch_array($query)); | ||
} // db_fetch_array | ||
|
||
|
||
function db_free_result($query) | ||
{ | ||
return(mysql_free_result($query)); | ||
} // db_free_result | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
require_once 'common.php'; | ||
|
||
function render_header($title = 'OpenAL Extension Registry') | ||
{ | ||
$img = ((is_authorized_vendor()) ? '../' : '') . 'openal_title_sm.jpg'; | ||
|
||
// !!! FIXME: need more here, I guess. | ||
echo <<< EOF | ||
<html><head><title>$title</title></head><body> | ||
<center><img src='$img'><br>OpenAL Extension Registry<hr></center> | ||
EOF; | ||
} // render_header | ||
|
||
function render_footer() | ||
{ | ||
// !!! FIXME: need more here, I guess. | ||
echo "<hr>\n"; | ||
if (is_authorized_vendor()) | ||
{ | ||
echo "<i>Logged in as: ${_SERVER['REMOTE_USER']}\n"; | ||
echo "(<a href='${_SERVER['PHP_SELF']}?operation=op_changepw'>"; | ||
echo "change password</a>)\n"; | ||
echo "(<a href='${_SERVER['PHP_SELF']}?operation=op_addvendor'>"; | ||
echo "add a new login</a>)</i><br>\n"; | ||
} // if | ||
echo "</body></html>\n"; | ||
} // render_footer | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
require_once 'common.php'; | ||
|
||
function icculux() | ||
{ | ||
// $img = ((is_authorized_vendor()) ? '../' : '') . 'openal_title_sm.jpg'; | ||
|
||
// !!! FIXME: need more here, I guess. | ||
//echo <<< EOF | ||
//<html><head><title>$title</title></head><body> | ||
//<center><img src='$img'><br>OpenAL Extension Registry<hr></center> | ||
|
||
//EOF; | ||
} // icculux | ||
|
||
function render_footer() | ||
{ | ||
// !!! FIXME: need more here, I guess. | ||
echo "<hr>\n"; | ||
if (is_authorized_vendor()) | ||
{ | ||
echo "<i>Logged in as: ${_SERVER['REMOTE_USER']}\n"; | ||
echo "(<a href='${_SERVER['PHP_SELF']}?operation=op_changepw'>"; | ||
echo "change password</a>)\n"; | ||
echo "(<a href='${_SERVER['PHP_SELF']}?operation=op_addvendor'>"; | ||
echo "add a new login</a>)</i><br>\n"; | ||
} // if | ||
echo "</body></html>\n"; | ||
} // render_footer | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php include ("../header.php") ?> | ||
|
||
<?php | ||
require_once 'operations.php'; | ||
//require_once 'headerandfooter.php'; | ||
require_once 'icculux.php' | ||
require_once 'listandsearch.php'; | ||
|
||
icculux(); | ||
if (do_operation()) | ||
echo "<p>Back to <a href='${_SERVER['PHP_SELF']}'>search page</a>.\n"; | ||
else | ||
render_search_ui(); | ||
render_footer(); | ||
?> | ||
|
||
<?php include ("../footer.php") ?> |
Oops, something went wrong.