Initial revision
5
README
Normal file
@@ -0,0 +1,5 @@
|
||||
WineHQ Application Database
|
||||
------------------------------------------------------------------------
|
||||
Authors:
|
||||
Jeremy Newman <jnewman@codeweavers.com>
|
||||
Charles Leop <charles@codeweavers.com>
|
||||
197
account.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Account Login / Logout Handler for AppDB
|
||||
*
|
||||
*/
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
|
||||
//set http header to not cache
|
||||
header("Pragma: no-cache");
|
||||
header("Cache-control: no-cache");
|
||||
|
||||
//check command and process
|
||||
do_account($cmd);
|
||||
|
||||
//process according to $cmd from URL
|
||||
function do_account($cmd = null)
|
||||
{
|
||||
global $ext_username, $ext_password, $ext_password2, $ext_realname, $ext_email;
|
||||
|
||||
if (! $cmd) return 0;
|
||||
switch($cmd)
|
||||
{
|
||||
|
||||
case "new":
|
||||
apidb_header("New Account");
|
||||
include(BASE."include/"."form_new.php");
|
||||
apidb_footer();
|
||||
exit;
|
||||
|
||||
case "do_new":
|
||||
cmd_do_new();
|
||||
exit;
|
||||
|
||||
case "login":
|
||||
apidb_header("Login");
|
||||
include(BASE."include/"."form_login.php");
|
||||
apidb_footer();
|
||||
exit;
|
||||
|
||||
case "do_login":
|
||||
cmd_do_login();
|
||||
exit;
|
||||
|
||||
case "send_passwd":
|
||||
cmd_send_passwd();
|
||||
exit;
|
||||
|
||||
case "logout":
|
||||
apidb_session_destroy();
|
||||
addmsg("You are successfully logged out.", "green");
|
||||
redirect(apidb_fullurl("index.php"));
|
||||
exit;
|
||||
}
|
||||
//not valid command, display error page
|
||||
errorpage("Internal Error","This module was called with incorrect parameters");
|
||||
exit;
|
||||
}
|
||||
|
||||
//retry
|
||||
function retry($cmd, $msg)
|
||||
{
|
||||
addmsg($msg, "red");
|
||||
do_account($cmd);
|
||||
}
|
||||
|
||||
//create new account
|
||||
function cmd_do_new()
|
||||
{
|
||||
global $ext_username, $ext_password, $ext_password2, $ext_realname, $ext_email;
|
||||
global $current;
|
||||
|
||||
if(ereg("^.+@.+\\..+$", $ext_username))
|
||||
{
|
||||
$ext_username = "";
|
||||
retry("new", "Invalid Username, must not contain special characters");
|
||||
return;
|
||||
}
|
||||
if(strlen($ext_username) < 3)
|
||||
{
|
||||
$ext_username = "";
|
||||
retry("new", "Username must be at least 3 characters");
|
||||
return;
|
||||
}
|
||||
if(strlen($ext_password) < 5)
|
||||
{
|
||||
retry("new", "Password must be at least 5 characters");
|
||||
return;
|
||||
}
|
||||
if($ext_password != $ext_password2)
|
||||
{
|
||||
retry("new", "Passwords don't match");
|
||||
return;
|
||||
}
|
||||
if(strlen($ext_realname) == 0)
|
||||
{
|
||||
retry("new", "You don't have a Real name?");
|
||||
return;
|
||||
}
|
||||
if(!ereg("^.+@.+\\..+$", $ext_email))
|
||||
{
|
||||
$ext_email = "";
|
||||
retry("new", "Invalid email address");
|
||||
return;
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
|
||||
if($user->exists($ext_username))
|
||||
{
|
||||
$ext_username = "";
|
||||
retry("new", "That username is already in use");
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $user->create($ext_username, $ext_password, $ext_realname, $ext_email);
|
||||
|
||||
if($result == null)
|
||||
{
|
||||
$user->login($ext_username, $ext_password);
|
||||
addmsg("Account created! ($ext_username)", "green");
|
||||
redirect(apidb_fullurl());
|
||||
}
|
||||
else
|
||||
retry("new", "Failed to create account: $result");
|
||||
}
|
||||
|
||||
//email lost password
|
||||
function cmd_send_passwd()
|
||||
{
|
||||
global $ext_username;
|
||||
|
||||
$user = new User();
|
||||
|
||||
$userid = $user->lookup_userid($ext_username);
|
||||
$passwd = generate_passwd();
|
||||
|
||||
if ($userid)
|
||||
{
|
||||
if ($user->update($userid, $passwd))
|
||||
{
|
||||
|
||||
$msg = "Application DB Lost Password\n";
|
||||
$msg .= "----------------------------\n";
|
||||
$msg .= "We have received a request that you lost your password.\n";
|
||||
$msg .= "We will create a new password for you. You can then change\n";
|
||||
$msg .= "your password at the Preferences screen.\n\n";
|
||||
$msg .= "Your new password is: ".$passwd."\n\n";
|
||||
|
||||
if (mail($user->lookup_email($userid), '[AppDB] Lost Password', $msg))
|
||||
{
|
||||
addmsg("Your new password has been emailed to you.", "green");
|
||||
}
|
||||
else
|
||||
{
|
||||
addmsg("Your password has changed, but we could not email it to you. Contact Support!", "red");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addmsg("Internal Error, we could not update your password.", "red");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
addmsg("Sorry, that username [$ext_username] does not exist.", "red");
|
||||
}
|
||||
|
||||
redirect(apidb_fullurl("account.php?cmd=login"));
|
||||
}
|
||||
|
||||
//on login handler
|
||||
function cmd_do_login()
|
||||
{
|
||||
global $ext_username, $ext_password;
|
||||
global $ext_referer;
|
||||
global $current;
|
||||
|
||||
$user = new User();
|
||||
$result = $user->login($ext_username, $ext_password);
|
||||
|
||||
if($result == null)
|
||||
{
|
||||
$current = $user;
|
||||
addmsg("You are successfully logged in.", "green");
|
||||
redirect(apidb_fullurl("index.php"));
|
||||
}
|
||||
else
|
||||
{
|
||||
retry("login","Login failed ($result)");
|
||||
$current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
98
addcomment.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
require(BASE."include/"."incl.php");
|
||||
|
||||
global $current;
|
||||
|
||||
if(!$appId) {
|
||||
errorpage('Internal Database Access Error');
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!$versionId) {
|
||||
$versionId = 0;
|
||||
}
|
||||
|
||||
if(!$thread) {
|
||||
$thread = 0;
|
||||
}
|
||||
|
||||
opendb();
|
||||
|
||||
|
||||
if($body)
|
||||
{
|
||||
// add comment to db
|
||||
|
||||
$hostname = get_remote();
|
||||
|
||||
$subject = strip_tags($subject);
|
||||
$subject = mysql_escape_string($subject);
|
||||
$body = mysql_escape_string($body);
|
||||
|
||||
// get current userid
|
||||
$userId = (loggedin()) ? $current->userid : 0;
|
||||
|
||||
$result = mysql_query("INSERT INTO appComments VALUES (null, null, $thread, ".
|
||||
"$appId, $versionId, $userId, '$hostname', '$subject', ".
|
||||
"'$body', 0)");
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
errorpage('Internal Database Access Error',mysql_error());
|
||||
exit;
|
||||
}
|
||||
|
||||
addmsg("New Comment Posted", "green");
|
||||
redirect(apidb_fullurl("appview.php?appId=$appId&versionId=$versionId"));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
apidb_header("Add Comment");
|
||||
|
||||
$mesTitle = "<b>Post New Comment</b>";
|
||||
|
||||
if($thread)
|
||||
{
|
||||
$result = mysql_query("SELECT subject,body FROM appComments WHERE commentId = $thread");
|
||||
$ob = mysql_fetch_object($result);
|
||||
if($ob)
|
||||
{
|
||||
$mesTitle = "<b>Replying To ...</b> $ob->subject\n";
|
||||
echo html_frame_start($ob->subject,500);
|
||||
echo htmlify_urls($ob->body), "<br><br>\n";
|
||||
echo html_frame_end();
|
||||
}
|
||||
}
|
||||
|
||||
echo "<form method=POST action='addcomment.php'>\n";
|
||||
|
||||
echo html_frame_start($mesTitle,500,"",0);
|
||||
|
||||
echo '<table width="100%" border=0 cellpadding=0 cellspacing=1>',"\n";
|
||||
echo "<tr bgcolor=#E0E0E0><td align=right><b>From:</b> </td>\n";
|
||||
echo " <td> ". ($current->username ? $current->username : "Anonymous") ." </td></tr>\n";
|
||||
echo "<tr bgcolor=#E0E0E0><td align=right><b>Subject:</b> </td>\n";
|
||||
echo " <td> <input type=text size=35 name=subject value='$subject'> </td></tr>\n";
|
||||
echo "<tr bgcolor=#C0C0C0><td colspan=2><textarea name=body cols=70 rows=15 wrap=virtual>$body</textarea></td></tr>\n";
|
||||
echo "<tr bgcolor=#C0C0C0><td colspan=2 align=center>\n";
|
||||
echo " <input type=SUBMIT value='Post Comment' class=button>\n";
|
||||
echo " <input type=RESET value='Reset' class=button>\n";
|
||||
echo "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
echo html_frame_end();
|
||||
|
||||
echo "<input type=HIDDEN name=thread value=$thread>\n";
|
||||
echo "<input type=HIDDEN name=appId value=$appId>\n";
|
||||
echo "<input type=HIDDEN name=versionId value=$versionId>\n";
|
||||
echo "</form><p> </p>\n";
|
||||
|
||||
apidb_footer();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
2
admin/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
stderr
|
||||
|
||||
37
admin/addAppFamily.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
//check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin")) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Add Application Family");
|
||||
|
||||
$t = new TableVE("create");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appFamily";
|
||||
$query = "INSERT INTO $table VALUES(0, 'NONAME', 0, null, null, null, $catId)";
|
||||
|
||||
mysql_query("DELETE FROM $table WHERE appName = 'NONAME'");
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
$t->create($query, $table, "appId");
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
51
admin/addAppNote.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Add Application Note
|
||||
*
|
||||
*/
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
//check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Add Application Note");
|
||||
|
||||
$t = new TableVE("create");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appNotes";
|
||||
|
||||
if (!$versionId) { $versionId = 0; }
|
||||
|
||||
//delete old NONAMES
|
||||
mysql_query("DELETE FROM $table WHERE noteTitle = 'NONAME'");
|
||||
|
||||
//show edit form
|
||||
$query = "INSERT INTO $table VALUES(0, 'NONAME', '', $appId, $versionId)";
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
$t->create($query, $table, "noteId");
|
||||
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId");
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
48
admin/addAppVersion.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
//FIXME: need to check for admin privs
|
||||
if(!loggedin())
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $admin_mode;
|
||||
$admin_mode = 1;
|
||||
}
|
||||
|
||||
apidb_header("Add Application Version");
|
||||
|
||||
$t = new TableVE("create");
|
||||
|
||||
if(!$appId)
|
||||
$appId = 0;
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appVersion";
|
||||
$query = "INSERT INTO $table VALUES(0, $appId, 'NONAME', null, null, null, 0.0, 0.0)";
|
||||
|
||||
mysql_query("DELETE FROM $table WHERE versionName = 'NONAME'");
|
||||
|
||||
if(debugging())
|
||||
echo "$query <br><br>\n";
|
||||
|
||||
$t->create($query, $table, "versionId");
|
||||
}
|
||||
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId");
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
42
admin/addCategory.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
if(!loggedin() || !havepriv("admin"))
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $admin_mode;
|
||||
$admin_mode = 1;
|
||||
}
|
||||
|
||||
apidb_header("Add Application Category");
|
||||
|
||||
$t = new TableVE("create");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appCategory";
|
||||
$query = "INSERT INTO $table VALUES(0, 'NONAME', null, 0)";
|
||||
|
||||
mysql_query("DELETE FROM $table WHERE catName = 'NONAME'");
|
||||
|
||||
if(debugging())
|
||||
echo "$query <br><br>\n";
|
||||
|
||||
$t->create($query, $table, "catId");
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
44
admin/addVendor.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?
|
||||
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
|
||||
if(!loggedin() || !havepriv("admin"))
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $admin_mode;
|
||||
$admin_mode = 1;
|
||||
}
|
||||
|
||||
apidb_header("Add Vendor");
|
||||
|
||||
$t = new TableVE("create");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "vendor";
|
||||
$query = "INSERT INTO $table VALUES(0, 'NONAME', null)";
|
||||
|
||||
mysql_query("DELETE FROM $table WHERE vendorName = 'NONAME'");
|
||||
|
||||
if(debugging())
|
||||
echo "$query <br><br>\n";
|
||||
|
||||
$t->create($query, $table, "vendorId");
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
308
admin/adminAppQueue.php
Normal file
@@ -0,0 +1,308 @@
|
||||
<?
|
||||
|
||||
/* code to View and approve new Apps */
|
||||
/* last modified 06-07-01 by Jeremy Newman */
|
||||
|
||||
include("path.php");
|
||||
require(BASE."include/"."incl.php");
|
||||
require(BASE."include/"."tableve.php");
|
||||
|
||||
//deny access if not logged in
|
||||
if(!loggedin())
|
||||
{
|
||||
errorpage("You need to be logged in to use this page.");
|
||||
exit;
|
||||
}
|
||||
else if (!havepriv("admin"))
|
||||
{
|
||||
errorpage("You must be an administrator to use this page.");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Admin App Queue");
|
||||
echo '<form name="qform" action="adminAppQueue.php" method="post" enctype="multipart/form-data">',"\n";
|
||||
|
||||
if ($sub)
|
||||
{
|
||||
if ($queueId)
|
||||
{
|
||||
//get data
|
||||
$query = "SELECT * from appQueue where queueId = $queueId;";
|
||||
$result = mysql_query($query);
|
||||
$ob = mysql_fetch_object($result);
|
||||
mysql_free_result($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
//error no Id!
|
||||
echo html_frame_start("Error","300");
|
||||
echo '<p><b>Application Not Found!</b></p>',"\n";
|
||||
echo html_frame_end(" ");
|
||||
}
|
||||
|
||||
//process according to sub flag
|
||||
if ($sub == 'view' && $queueId)
|
||||
{
|
||||
$x = new TableVE("view");
|
||||
|
||||
//help
|
||||
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
|
||||
echo "<p>This is the full view of the application waiting to be approved. You need to pick a category before submitting \n";
|
||||
echo "it into the database. If you approve this application, an email will be sent to the author of the submission.<p>\n";
|
||||
echo "<p>There are two kinds of applications in this database:</p>\n";
|
||||
echo "<ol>\n";
|
||||
echo " <li><b>App Family</b> This is a parent group application, that will have multiple versions under it.<br>\n";
|
||||
echo " To add this submission as a Family, choose 'Application' from the type drop down. Then set the category.\n";
|
||||
echo " The version and app parent fields will be ignored in this type.<br>\n";
|
||||
echo " If the vendor does not exist, leave the vendor drop down unset, and the field will be used.</li><p>\n";
|
||||
echo " <li><b>App Version</b> This type of application will be nested under the selected application parent. The category,\n";
|
||||
echo " name, and vendor fields will be ignored.</li>\n";
|
||||
echo "</td></tr></table></div>\n\n";
|
||||
|
||||
//view application details
|
||||
echo html_frame_start("New Application Form",400,"",0);
|
||||
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||
|
||||
//type
|
||||
echo '<tr valign=top><td class=color0><b>Type</b></td><td>',"\n";
|
||||
echo '<select name=type><option value=app>Application</option><option value=ver>Version</option></select>',"\n";
|
||||
echo '</td></tr>',"\n";
|
||||
|
||||
//category
|
||||
echo '<tr valign=top><td class=color0><b>Category</b></td><td>',"\n";
|
||||
$x->make_option_list("cat","","appCategory","catId","catName");
|
||||
echo '</td></tr>',"\n";
|
||||
|
||||
//app parent
|
||||
echo '<tr valign=top><td class=color0><b>App Parent</b></td><td>',"\n";
|
||||
$x->make_option_list("appParent","","appFamily","appId","appName");
|
||||
echo '</td></tr>',"\n";
|
||||
|
||||
//name
|
||||
echo '<tr valign=top><td class=color0><b>App Name</b></td><td><input type=text name="queueName" value="'.stripslashes($ob->queueName).'" size=20></td></tr>',"\n";
|
||||
|
||||
//version
|
||||
echo '<tr valign=top><td class=color0><b>App Version</b></td><td><input type=text name="queueVersion" value="'.stripslashes($ob->queueVersion).'" size=20></td></tr>',"\n";
|
||||
|
||||
//vendor
|
||||
echo '<tr valign=top><td class=color0><b>App Vendor</b></td><td><input type=text name="queueVendor" value="'.stripslashes($ob->queueVendor).'" size=20></td></tr>',"\n";
|
||||
|
||||
//alt vendor
|
||||
echo '<tr valign=top><td class=color0> </td><td>',"\n";
|
||||
$x->make_option_list("altvendor","","vendor","vendorId","vendorName");
|
||||
echo '</td></tr>',"\n";
|
||||
|
||||
//url
|
||||
echo '<tr valign=top><td class=color0><b>App URL</b></td><td><input type=text name="queueURL" value="'.stripslashes($ob->queueURL).'" size=20></td></tr>',"\n";
|
||||
|
||||
//desc
|
||||
echo '<tr valign=top><td class=color0><b>App Desc</b></td><td><textarea name="queueDesc" rows=10 cols=35>'.stripslashes($ob->queueDesc).'</textarea></td></tr>',"\n";
|
||||
|
||||
//echo '<tr valign=top><td bgcolor=class=color0><b>Email</b></td><td><input type=text name="queueEmail" value="'.$ob->queueEmail.'" size=20></td></tr>',"\n";
|
||||
//echo '<tr valign=top><td bgcolor=class=color0><b>Image</b></td><td><input type=file name="queueImage" value="'.$ob->.'" size=15></td></tr>',"\n";
|
||||
|
||||
echo '<tr valign=top><td class=color3 align=center colspan=2> <input type=submit value=" Submit App Into Database " class=button> </td></tr>',"\n";
|
||||
echo '</table>',"\n";
|
||||
echo '<input type=hidden name="sub" value="add">',"\n";
|
||||
echo '<input type=hidden name="queueId" value="'.$queueId.'">',"\n";
|
||||
|
||||
echo html_frame_end(" ");
|
||||
echo html_back_link(1,'adminAppQueue.php');
|
||||
}
|
||||
else if ($sub == 'add' && $queueId)
|
||||
{
|
||||
//add item to main db
|
||||
$statusMessage = "";
|
||||
$goodtogo = 0;
|
||||
if ($type == 'app')
|
||||
{
|
||||
//process as application family
|
||||
if ($altvendor == 0 && $queueVendor)
|
||||
{
|
||||
//add new vendor
|
||||
mysql_query("INSERT into vendor VALUES (null, '".addslashes($queueVendor)."', '');");
|
||||
$altvendor = mysql_insert_id();
|
||||
}
|
||||
|
||||
$query = "INSERT into appFamily VALUES (null, '".
|
||||
addslashes($queueName)."', $altvendor, '', '".
|
||||
addslashes($queueDesc)."', '".
|
||||
addslashes($queueURL)."', $cat);";
|
||||
|
||||
if (mysql_query($query))
|
||||
{
|
||||
//get the id of the app just added
|
||||
$appParent = mysql_insert_id();
|
||||
|
||||
//delete queue item
|
||||
mysql_query("DELETE from appQueue where queueId = $queueId;");
|
||||
|
||||
//set ver if not set
|
||||
if (!$queueVersion)
|
||||
$queueVersion = '1.0';
|
||||
if (!$queueDesc)
|
||||
$queueDesc = 'released version';
|
||||
|
||||
$verQuery = "INSERT into appVersion VALUES (null, $appParent, '".
|
||||
addslashes($queueVersion)."', '', '".
|
||||
addslashes($queueDesc)."', '".
|
||||
addslashes($queueURL)."', 0.0, 0.0);";
|
||||
|
||||
//Now add a version
|
||||
if (mysql_query($verQuery))
|
||||
{
|
||||
//successful
|
||||
$statusMessage = "<p>The application $queueName was successfully added into the database</p>\n";
|
||||
$goodtogo = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//error
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
||||
$statusMessage .= "<p><b>Note:</b> The application family was successfully added.</p>\n";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//error
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
||||
}
|
||||
}
|
||||
else if ($type == 'ver')
|
||||
{
|
||||
//process as application version
|
||||
if ($appParent)
|
||||
{
|
||||
$query = "INSERT into appVersion VALUES (null, $appParent, '".
|
||||
addslashes($queueVersion)."', '', '".
|
||||
addslashes($queueDesc)."', '".
|
||||
addslashes($queueURL)."', 0.0, 0.0);";
|
||||
|
||||
if (mysql_query($query))
|
||||
{
|
||||
//successful
|
||||
$statusMessage = "<p>The application $queueName was successfully added into the database</p>\n";
|
||||
mysql_query("DELETE from appQueue where queueId = $queueId;");
|
||||
$goodtogo = 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//error
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$statusMessage = "<p><b>Error<br>You did not pick an application Parent!</b></p>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Send Status Email
|
||||
if ($ob->queueEmail && $goodtogo)
|
||||
{
|
||||
$ms = "Application Database Status Report\n";
|
||||
$ms .= "----------------------------------\n\n";
|
||||
$ms .= "Your application ".stripslashes($ob->queueName)." has been entered ";
|
||||
$ms .= "into the application database.\n\n";
|
||||
$ms .= "Thanks!\n";
|
||||
|
||||
mail(stripslashes($ob->queueEmail),'[AppDB] Status Report',$ms);
|
||||
}
|
||||
|
||||
//done
|
||||
echo html_frame_start("Submit Application","300");
|
||||
echo "<p><b>$statusMessage</b></p>\n";
|
||||
echo html_frame_end(" ");
|
||||
echo html_back_link(1,'adminAppQueue.php');
|
||||
}
|
||||
else if ($sub == 'delete' && $queueId)
|
||||
{
|
||||
//delete main item
|
||||
$query = "DELETE from appQueue where queueId = $queueId;";
|
||||
$result = mysql_query($query);
|
||||
echo html_frame_start("Delete Application: $ob->queueName",400,"",0);
|
||||
if(!$result)
|
||||
{
|
||||
//error
|
||||
echo "<p>Internal Error: unable to delete selected application!</p>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
//success
|
||||
echo "<p>Application was successfully deleted from the Queue.</p>\n";
|
||||
}
|
||||
echo html_frame_end(" ");
|
||||
echo html_back_link(1,'adminAppQueue.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
//error no sub!
|
||||
echo html_frame_start("Error","300");
|
||||
echo '<p><b>Internal Routine Not Found!</b></p>',"\n";
|
||||
echo html_frame_end(" ");
|
||||
echo html_back_link(1,'adminAppQueue.php');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//get available apps
|
||||
$query = "SELECT * from appQueue;";
|
||||
$result = mysql_query($query);
|
||||
|
||||
if(!$result || !mysql_num_rows($result))
|
||||
{
|
||||
//no apps in queue
|
||||
echo html_frame_start("","90%");
|
||||
echo '<p><b>The Application Queue is empty.</b></p>',"\n";
|
||||
echo '<p>There is nothing for you to do. Check back later.</p>',"\n";
|
||||
echo html_frame_end(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
//help
|
||||
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
|
||||
echo "<p>This is the list of applications waiting for your approval, or to be annihilated from existence.</p>\n";
|
||||
echo "<p>To view a submission, click on its name. From that page you can edit, and approve it into the AppDB.<br>\n";
|
||||
echo "Click the delete link to remove the selected item from the queue. An email will automatically be sent to the\n";
|
||||
echo "submitter to let them know the item was deleted.</p>\n";
|
||||
echo "</td></tr></table></div>\n\n";
|
||||
|
||||
//show applist
|
||||
echo html_frame_start("","90%","",0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td><font color=white>Application Name</font></td>\n";
|
||||
echo " <td><font color=white>Version</font></td>\n";
|
||||
echo " <td><font color=white>Vendor</font></td>\n";
|
||||
echo " <td><font color=white>Submitter Email</font></td>\n";
|
||||
echo " <td> </td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c = 1;
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
|
||||
echo "<tr class=$bgcolor>\n";
|
||||
echo " <td><a href='adminAppQueue.php?sub=view&queueId=$ob->queueId'>$ob->queueName</a></td>\n";
|
||||
echo " <td>".stripslashes($ob->queueVersion)." </td>\n";
|
||||
echo " <td>".stripslashes($ob->queueVendor)." </td>\n";
|
||||
echo " <td>".stripslashes($ob->queueEmail)." </td>\n";
|
||||
echo " <td>[<a href='adminAppQueue.php?sub=delete&queueId=$ob->queueId'>delete</a>]</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
$c++;
|
||||
}
|
||||
echo "</table>\n\n";
|
||||
echo html_frame_end(" ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo "</form>";
|
||||
apidb_footer();
|
||||
|
||||
|
||||
?>
|
||||
99
admin/deleteAny.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?
|
||||
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
|
||||
|
||||
if(!loggedin() || !havepriv("admin"))
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
|
||||
if($confirmed != "yes")
|
||||
{
|
||||
// ask for confirmation
|
||||
// could do some Real Damage if someone accidently hits the delete button on the main category :)
|
||||
//
|
||||
// perhaps we can do this with some javascript, popup
|
||||
|
||||
errorpage("Not confirmed");
|
||||
}
|
||||
|
||||
|
||||
function deleteCategory($catId)
|
||||
{
|
||||
$r = mysql_query("SELECT appId FROM appFamily WHERE catId = $catId");
|
||||
if($r)
|
||||
{
|
||||
while($ob = mysql_fetch_object($r))
|
||||
deleteAppFamily($ob->appId);
|
||||
$r = mysql_query("DELETE FROM appCategory WHERE catId = $catId");
|
||||
|
||||
if($r)
|
||||
addmsg("Category $catId deleted", "green");
|
||||
else
|
||||
addmsg("Failed to delete category $catId:".mysql_error(), "red");
|
||||
}
|
||||
else
|
||||
{
|
||||
addmsg("Failed to delete category $catId: ".mysql_error(), "red");
|
||||
}
|
||||
}
|
||||
|
||||
function deleteAppFamily($appId)
|
||||
{
|
||||
$r = mysql_query("DELETE FROM appFamily WHERE appId = $appId");
|
||||
if($r)
|
||||
{
|
||||
$r = mysql_query("DELETE FROM appVersion WHERE appId = $appId");
|
||||
if($r)
|
||||
addmsg("Application and versions deleted", "green");
|
||||
else
|
||||
addmsg("Failed to delete appVersions: " . mysql_error(), "red");
|
||||
}
|
||||
else
|
||||
addmsg("Failed to delete appFamily $appId: " . mysql_error(), "red");
|
||||
|
||||
}
|
||||
|
||||
function deleteAppVersion($versionId)
|
||||
{
|
||||
$r = mysql_query("DELETE FROM appVersion WHERE versionId = $versionId");
|
||||
if($r)
|
||||
addmsg("Application Version $versionId deleted", "green");
|
||||
else
|
||||
addmsg("Failed to delete appVersion $versionId: " . mysql_error(), "red");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($what)
|
||||
{
|
||||
switch($what)
|
||||
{
|
||||
case "comment":
|
||||
// delete a comment
|
||||
//TODO
|
||||
break;
|
||||
case "category":
|
||||
// delete category and the apps in it
|
||||
deleteCategory($catId);
|
||||
break;
|
||||
case "appFamily":
|
||||
// delete app family & all its versions
|
||||
deleteAppFamily($appId);
|
||||
break;
|
||||
case "appVersion":
|
||||
// delete a version
|
||||
deleteAppVersion($versionId);
|
||||
break;
|
||||
}
|
||||
|
||||
//FIXME need to redirect to the page before the confirmation page
|
||||
redirect($apidb_root."appbrowse.php");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
93
admin/editAppFamily.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?
|
||||
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
//FIXME: need to check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Edit Application Family");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
if($cmd)
|
||||
{
|
||||
$statusMessage = '';
|
||||
|
||||
//process add URL
|
||||
if($cmd == "add_url")
|
||||
{
|
||||
$query = "INSERT INTO appData VALUES (null, $appId, 0, 'url', ".
|
||||
"'$url_desc', '$url')";
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
if (mysql_query($query))
|
||||
{
|
||||
//success
|
||||
$statusMessage = "<p>The URL was successfully added into the database</p>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
//error
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// display status message
|
||||
if ($statusMessage)
|
||||
{
|
||||
echo html_frame_start("Edit Application","300");
|
||||
echo "<p><b>$statusMessage</b></p>\n";
|
||||
echo html_frame_end();
|
||||
echo html_back_link(1,"editAppFamily.php?appId=$appId");
|
||||
}
|
||||
|
||||
}
|
||||
else if($HTTP_POST_VARS)
|
||||
{
|
||||
// commit changes of form to database
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// show form
|
||||
$table = "appFamily";
|
||||
$query = "SELECT * FROM $table WHERE appId = $appId";
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
$t->edit($query);
|
||||
|
||||
//url entry box
|
||||
echo '<form enctype="multipart/form-data" action="editAppFamily.php" method="post">',"\n";
|
||||
echo html_frame_start("Add URL","400","",0);
|
||||
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
|
||||
|
||||
echo '<tr><td class=color1>URL</td><td class=color0><input name="url" type="text"></td></tr>',"\n";
|
||||
echo '<tr><td class=color1>Description</td><td class=color0><input type="text" name="url_desc"></td></tr>',"\n";
|
||||
|
||||
echo '<tr><td colspan=2 align=center class=color3><input type="submit" value="Add URL"></td></tr>',"\n";
|
||||
|
||||
echo '</table>',"\n";
|
||||
echo html_frame_end();
|
||||
echo '<input type="hidden" name="cmd" value="add_url">',"\n";
|
||||
echo '<input type="hidden" name="appId" value="'.$appId.'"></form>',"\n";
|
||||
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId");
|
||||
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
46
admin/editAppNote.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Edit AppNote
|
||||
*/
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
//check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Edit Application Note");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
// commit changes of form to database
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
// show form
|
||||
$table = "appNotes";
|
||||
$query = "SELECT * FROM $table WHERE noteId = $noteId";
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
$t->edit($query);
|
||||
|
||||
echo html_back_link(1,$apidb_root."noteview.php?noteId=$noteId");
|
||||
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
120
admin/editAppOwners.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?
|
||||
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
|
||||
if(!loggedin() || !havepriv("admin"))
|
||||
{
|
||||
errorpage("Insufficient Privileges","You do not have access to this section of the website");
|
||||
exit;
|
||||
}
|
||||
|
||||
function build_user_list()
|
||||
{
|
||||
$result = mysql_query("SELECT username,email FROM user_list ORDER BY username");
|
||||
|
||||
echo "<select name=username size=15 onChange='this.form.ownerName.value = this.value; this.form.submit()'>\n";
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
echo "<option value='$ob->username'>$ob->username - $ob->email</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
|
||||
if($cmd)
|
||||
{
|
||||
if($cmd == "delete")
|
||||
{
|
||||
$result = mysql_query("DELETE FROM appOwners WHERE appId = $appId AND ownerId = $ownerId");
|
||||
if($result)
|
||||
{
|
||||
addmsg("Owner deleted", "green");
|
||||
redirectref();
|
||||
}
|
||||
else
|
||||
echo "Failed: " . mysql_error();
|
||||
}
|
||||
if($cmd == "add")
|
||||
{
|
||||
$result = mysql_query("SELECT userid FROM user_list WHERE username = '$ownerName'");
|
||||
if($result)
|
||||
{
|
||||
$ob = mysql_fetch_object($result);
|
||||
if(!$ob || !$ob->userid)
|
||||
{
|
||||
errorpage("Not Found!","User $ownerName was not found in the database");
|
||||
exit;
|
||||
}
|
||||
$result = mysql_query("INSERT INTO appOwners VALUES ($appId, $ob->userid)");
|
||||
if(!$result)
|
||||
{
|
||||
errorpage("Failed!",mysql_error());
|
||||
exit;
|
||||
}
|
||||
addmsg("Owner $ownerName added", "green");
|
||||
redirectref();
|
||||
}
|
||||
else
|
||||
echo "Failed: " . mysql_error();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
apidb_header("Edit Application Owners");
|
||||
|
||||
$result = mysql_query("SELECT ownerId,username FROM appOwners, user_list WHERE appId = $appId AND userid = ownerId");
|
||||
|
||||
if($result && mysql_num_rows($result))
|
||||
{
|
||||
echo html_frame_start("Current Owners","300",'',0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td><font color=white> User Name </font></td>\n";
|
||||
echo " <td><font color=white> Delete </font></td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c = 1;
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
//set row color
|
||||
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
|
||||
|
||||
$delete_link = "[<a href='editAppOwners.php?cmd=delete&appId=$appId&ownerId=$ob->ownerId'>delete</a>]";
|
||||
|
||||
echo "<tr class=$bgcolor>\n";
|
||||
echo " <td>$ob->username </td>\n";
|
||||
echo " <td>$delete_link </td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
echo "</table>\n\n";
|
||||
echo html_frame_end();
|
||||
|
||||
}
|
||||
|
||||
echo "<form method=post action=editAppOwners.php>\n";
|
||||
|
||||
echo html_frame_start("Manually Add User","300",'',5);
|
||||
echo "<input type=text name=ownerName size=15>\n";
|
||||
echo "<input type=submit value=' Add User ' class=button>\n";
|
||||
echo html_frame_end();
|
||||
|
||||
|
||||
echo html_frame_start("User List","",'',2);
|
||||
build_user_list();
|
||||
echo html_frame_end();
|
||||
|
||||
echo "<input type=hidden name=appId value=$appId>\n";
|
||||
echo "<input type=hidden name=cmd value=add>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
apidb_footer();
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
111
admin/editAppVersion.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?
|
||||
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
//check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Edit Application Version");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
|
||||
if($cmd)
|
||||
{
|
||||
$statusMessage = '';
|
||||
|
||||
//process screenshot upload
|
||||
if($cmd == "screenshot_upload")
|
||||
{
|
||||
if(debugging())
|
||||
{
|
||||
echo "<p align=center>Screenshot: ($appId) file=$imagefile size=$imagefile_size\n";
|
||||
echo " name=$imagefile_name type=$imagefile_type<br>";
|
||||
}
|
||||
|
||||
if(!copy($imagefile, "../data/screenshots/".basename($imagefile_name)))
|
||||
{
|
||||
// whoops, copy failed. do something
|
||||
echo html_frame_start("Edit Application","300");
|
||||
echo "<p><b>debug: copy failed; $imagefile; $imagefile_name</b></p>\n";
|
||||
echo html_frame_end();
|
||||
echo html_back_link(1,"editAppVersion.php?appId=$appId&versionID=$versionId");
|
||||
apidb_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = "INSERT INTO appData VALUES (null, $appId, $versionId, 'image', ".
|
||||
"'".addslashes($screenshot_desc)."', '".basename($imagefile_name)."')";
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
if (mysql_query($query))
|
||||
{
|
||||
//success
|
||||
$statusMessage = "<p>The image was successfully added into the database</p>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
//error
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."<br></b></p>\n";
|
||||
if(debugging()) { $statusMessage .= "<p>$query</p>"; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// display status message
|
||||
if ($statusMessage)
|
||||
{
|
||||
echo html_frame_start("Edit Application","300");
|
||||
echo "<p><b>$statusMessage</b></p>\n";
|
||||
echo html_frame_end();
|
||||
echo html_back_link(1,"editAppVersion.php?appId=$appId&versionId=$versionId");
|
||||
}
|
||||
|
||||
}
|
||||
else if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appVersion";
|
||||
$query = "SELECT * FROM $table WHERE appId = $appId AND versionId = $versionId";
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
|
||||
$t->edit($query);
|
||||
|
||||
|
||||
//image upload box
|
||||
echo '<form enctype="multipart/form-data" action="editAppVersion.php" name=imageForm method="post">',"\n";
|
||||
echo html_frame_start("Upload Screenshot","400","",0);
|
||||
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
|
||||
|
||||
echo '<tr><td class=color1>Image</td><td class=color0><input name="imagefile" type="file"></td></tr>',"\n";
|
||||
echo '<tr><td class=color1>Description</td><td class=color0><input type="text" name="screenshot_desc"></td></tr>',"\n";
|
||||
|
||||
echo '<tr><td colspan=2 align=center class=color3><input type="submit" value="Send File"></td></tr>',"\n";
|
||||
|
||||
echo '</table>',"\n";
|
||||
echo html_frame_end();
|
||||
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000">',"\n";
|
||||
echo '<input type="hidden" name="cmd" value="screenshot_upload">',"\n";
|
||||
echo '<input type="hidden" name="appId" value="'.$appId.'">',"\n";
|
||||
echo '<input type="hidden" name="versionId" value="'.$versionId.'"></form>',"\n";
|
||||
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId");
|
||||
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
98
admin/editBundle.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
|
||||
if(!loggedin() || !havepriv("admin"))
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
|
||||
function build_app_list()
|
||||
{
|
||||
$result = mysql_query("SELECT appId, appName FROM appFamily ORDER BY appName");
|
||||
|
||||
echo "<select name=appId size=5 onChange='this.form.submit()'>\n";
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
echo "<option value=$ob->appId>$ob->appName</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
|
||||
if($cmd)
|
||||
{
|
||||
if($cmd == "delete")
|
||||
{
|
||||
$result = mysql_query("DELETE FROM appBundle WHERE appId = $appId AND bundleId = $bundleId");
|
||||
if($result)
|
||||
addmsg("App deleted from bundle", "green");
|
||||
else
|
||||
addmsg("Failed: " . mysql_error(), "red");
|
||||
}
|
||||
if($cmd == "add")
|
||||
{
|
||||
$result = mysql_query("INSERT INTO appBundle VALUES ($bundleId, $appId)");
|
||||
if($result)
|
||||
addmsg("App $appId added to Bundle $bundleId", "green");
|
||||
else
|
||||
addmsg("Failed: " . mysql_error(), "red");
|
||||
}
|
||||
redirectref();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
apidb_header("Edit Application Bundle");
|
||||
|
||||
$result = mysql_query("SELECT bundleId, appBundle.appId, appName FROM appBundle, appFamily ".
|
||||
"WHERE bundleId = $bundleId AND appFamily.appId = appBundle.appId");
|
||||
|
||||
if($result && mysql_num_rows($result))
|
||||
{
|
||||
echo html_frame_start("Apps in this Bundle","300",'',0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td><font color=white> Application Name </font></td>\n";
|
||||
echo " <td><font color=white> Delete </font></td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c = 1;
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
//set row color
|
||||
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
|
||||
|
||||
$delete_link = "[<a href='editBundle.php?cmd=delete&bundleId=$bundleId&appId=$ob->appId'>delete</a>]";
|
||||
|
||||
echo "<tr class=$bgcolor>\n";
|
||||
echo " <td>$ob->appName </td>\n";
|
||||
echo " <td>$delete_link </td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
echo "</table>\n\n";
|
||||
echo html_frame_end();
|
||||
|
||||
}
|
||||
|
||||
echo "<form method=post action=editBundle.php>\n";
|
||||
|
||||
echo html_frame_start("Application List (double click to add)","",'',2);
|
||||
build_app_list();
|
||||
echo html_frame_end();
|
||||
|
||||
echo "<input type=hidden name=bundleId value=$bundleId>\n";
|
||||
echo "<input type=hidden name=cmd value=add>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
apidb_footer();
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
42
admin/editCategory.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?
|
||||
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
if(!loggedin() || !havepriv("admin"))
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $admin_mode;
|
||||
$admin_mode = 1;
|
||||
}
|
||||
|
||||
apidb_header("Edit Category");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appCategory";
|
||||
$query = "SELECT * FROM $table WHERE catId = $catId";
|
||||
|
||||
if(debugging())
|
||||
echo "$query <br><br>\n";
|
||||
|
||||
$t->edit($query);
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
41
admin/editVendor.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
if(!loggedin() || !havepriv("admin"))
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
global $admin_mode;
|
||||
$admin_mode = 1;
|
||||
}
|
||||
|
||||
apidb_header("Edit Vendor Information");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "vendor";
|
||||
$query = "SELECT * FROM $table WHERE vendorId = $vendorId";
|
||||
|
||||
if(debugging())
|
||||
echo "$query <br><br>\n";
|
||||
|
||||
$t->edit($query);
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
78
admin/index.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?
|
||||
|
||||
//
|
||||
// Admin Script for API Db
|
||||
// last modified 04-20-01
|
||||
//
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
|
||||
//FIXME: need to check for admin privs
|
||||
if(!loggedin())
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
|
||||
// desc
|
||||
function get_tables()
|
||||
{
|
||||
$result = mysql_query("SHOW TABLES");
|
||||
$arr = array();
|
||||
$arr[] = "ALL";
|
||||
while($r = mysql_fetch_array($result))
|
||||
{
|
||||
$arr[] = $r[0];
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
// desc
|
||||
function input_form()
|
||||
{
|
||||
echo "<form method=get action=".apidb_url("admin").">\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
||||
//desc
|
||||
function make_options($name, $options, $label = "Submit")
|
||||
{
|
||||
echo "<select name='$name'>\n";
|
||||
while(list($idx, $val) = each($options))
|
||||
echo "<option>$val</option>\n";
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
//desc
|
||||
if($table_cmd)
|
||||
{
|
||||
apidb_header("Table Operation");
|
||||
$t = new TableVE("view");
|
||||
switch($table_cmd)
|
||||
{
|
||||
case "check":
|
||||
$t->view("CHECK TABLE $table_id");
|
||||
break;
|
||||
case "describe":
|
||||
$t->view("DESCRIBE $table_id");
|
||||
break;
|
||||
case "optimize":
|
||||
$t->view("OPTIMIZE TABLE $table_id");
|
||||
break;
|
||||
}
|
||||
apidb_footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
// output of admin page begins here
|
||||
apidb_header("Admin");
|
||||
|
||||
// Draw User List
|
||||
include(BASE."include/"."query_users.php");
|
||||
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
3
admin/path.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?
|
||||
define("BASE","../");
|
||||
?>
|
||||
160
apidb.css
Normal file
@@ -0,0 +1,160 @@
|
||||
/* Body Document Defaults */
|
||||
BODY { background-color: #E2E2E2;
|
||||
color: #000000; margin: 0; }
|
||||
|
||||
/* Link Colors */
|
||||
A { color: #A50D0D; }
|
||||
A:visited { color: #FF0000; }
|
||||
A:hover { color: #FF6666; text-decoration: underline; }
|
||||
A:active { color: #FF0000; }
|
||||
A.hidden { text-decoration: none; color: #000000; }
|
||||
|
||||
OL,UL,P,BODY { font-family: Helvetica, Arial; font-size: 10pt; }
|
||||
TD,TR,TH,FORM { font-family: Helvetica, Arial; font-size: 10pt; }
|
||||
SPAN { font-family: Helvetica, Arial; font-size: 10pt; }
|
||||
H1,H2,H3 { font-family: Helvetica, Arial; font-size: 14pt; }
|
||||
H4,H5,H6 { font-family: Helvetica, Arial; font-size: 12pt; }
|
||||
INPUT { font-family: Helvetica, Arial; font-size: 10pt; }
|
||||
PRE,T1 { font-family: Helvetica, Arial; font-size: 10pt; }
|
||||
SMALL { font-family: Helvetica, Arial; font-size: 8pt; }
|
||||
|
||||
TD.cline { background-color: #EEEEEE; color: #000000;
|
||||
text-align: center; font-weight: bold; font-size: 10pt; }
|
||||
|
||||
TH.qheader { background-color: #C3C8E5; color: #555555; font-size: 10pt; }
|
||||
TR.qheader { background-color: #C3C8E5; color: #555555; font-size: 10pt; }
|
||||
|
||||
TABLE.bg { background-color: #FF6666; color: #FFFFFF }
|
||||
TABLE.bg2 { background-color: #E0E0E0; }
|
||||
TD.bg2 { background-color: #E0E0E0; }
|
||||
|
||||
TD.line1 { background-color: #E7E7E7; }
|
||||
TD.line2 { background-color: #C0C0C0; color: #505050; font-size: 8pt; }
|
||||
TD.line3 { background-color: #6F6F6F; }
|
||||
TR.line1 { background-color: #E7E7E7; }
|
||||
TR.line2 { background-color: #C0C0C0; color: #505050 }
|
||||
TR.line3 { background-color: #6F6F6F; }
|
||||
|
||||
|
||||
TH.titlex { background-color: #BBC2E5 }
|
||||
TH.title { background-color: #C0C0C0; font-weight: bold }
|
||||
TD.title { background-color: #C0C0C0; font-weight: bold }
|
||||
TD.btitle { background-color: #FFFFFF }
|
||||
|
||||
TH.sqtitle { background-color: #C3C8E5; color: #555555 }
|
||||
|
||||
|
||||
TR.buttons { background-color: #BDDAE5 }
|
||||
TD.button { background-color: #BDDAE5 }
|
||||
TD.button2 { background-color: #ABB2D5; }
|
||||
|
||||
/* query row colors */
|
||||
.color0 { background-color: #E0E0E0 }
|
||||
.color1 { background-color: #C0C0C0 }
|
||||
.color2 { background-color: #FFFFFF }
|
||||
.color3 { background-color: #666666 }
|
||||
.color4 { background-color: #999999 }
|
||||
|
||||
/* box */
|
||||
.box-title { background-color: #AAAAAA; color: #FFFFFF; font-weight: bold }
|
||||
.box-label { background-color: #C0C0C0 }
|
||||
.box-body { background-color: #E0E0E0 }
|
||||
|
||||
/* labels */
|
||||
TD.label { font-weight: bold }
|
||||
|
||||
/* for inwine/intwine */
|
||||
TD.yes { color: #00B100; font-weight: italic; text-align: center }
|
||||
TD.no { color: #B10000; font-weight: italic; text-align: center }
|
||||
TD.stub { color: #0000B1; font-weight: italic; text-align: center }
|
||||
|
||||
|
||||
/* Copyright Notice */
|
||||
.copyright { font-family: Helvetica, Arial; font-size: 8pt; color: #6F6F6F; }
|
||||
|
||||
|
||||
/* Rating Number */
|
||||
.rating { font-family: Helvetica, Arial; font-size: 6pt; color: #333333; }
|
||||
|
||||
|
||||
/* background colors */
|
||||
.vltgrey { background-color: #f9f9f9; }
|
||||
.ltgrey { background-color: #EFEFEF; }
|
||||
.grey { background-color: #C0C0C0; }
|
||||
.white { background-color: #FFFFFF; }
|
||||
.dkgrey { background-color: #888888; }
|
||||
.ltblack { background-color: #999999; }
|
||||
.black { background-color: #000000; }
|
||||
.blueish { background-color: #bed5f7; }
|
||||
|
||||
/* text colors */
|
||||
.inverse { color: #FFFFFF; }
|
||||
.disabled { color: #999999; }
|
||||
.normal { color: #000000; }
|
||||
.error { color: #ff0000; }
|
||||
.water { color: #6060ff; }
|
||||
.good { color: #60ff60; }
|
||||
.warning { color: #fffa00; }
|
||||
.blueman { color: #335184; }
|
||||
|
||||
/* text styles */
|
||||
.strike { text-decoration: line-through; }
|
||||
.bold { font-weight: bold; }
|
||||
.newstitle { font-size: 14px; font-weight: bold; color: #000000; }
|
||||
|
||||
/* Menu Config */
|
||||
.menuTitle { font-size: 12px; color: #ffffff; font-weight: bold; text-decoration: none; }
|
||||
.menuTitle:visited { font-size: 12px; color: #ffffff; font-weight: bold; text-decoration: none; }
|
||||
.menuTitle:hover { font-size: 12px; color: #ffffff; font-weight: bold; text-decoration: none; }
|
||||
.menuLink { font-size: 10px; color: #ffffff; font-weight: bold; }
|
||||
.menuItem { font-size: 10px; color: #000000; }
|
||||
.menuItem:visited { font-size: 10px; color: #000000; }
|
||||
.menuItem:hover { font-size: 10px; color: #A50D0D; }
|
||||
|
||||
.topMenu { background-color: #601919; }
|
||||
.sideMenu { background-color: #FFFFFF; }
|
||||
.border { background-color: #601919; }
|
||||
|
||||
/* Misc */
|
||||
.tiny { font-size: 6pt; }
|
||||
.small { font-size: 8pt; }
|
||||
.big { font-size: 14pt; }
|
||||
|
||||
/* Generic Buttons */
|
||||
.button { background-color: #6b86bb; color: #ffffff; font-family: Helvetica, Arial, Sans-Serif; font-size: 10pt;
|
||||
padding: 0; }
|
||||
.searchInput { background-color: #FFFFFF; color: #000000; font-family: Helvetica, Arial, Sans-Serif; font-size: 10pt;
|
||||
padding: 0; }
|
||||
|
||||
/* Note Blip */
|
||||
.blip { color: #ff0000; font-size: 8pt; }
|
||||
|
||||
/* Footer */
|
||||
.footer { font-size: 8pt; color: #777777; }
|
||||
|
||||
/* Footer Link */
|
||||
.footerLink { font-family: Helvetica, Arial; font-size: 8pt; color: #666666; }
|
||||
|
||||
|
||||
/* Generic Buttons */
|
||||
.button { background-color: #666666; color: #ffffff; font-family: Helvetica, Arial; font-size: 10pt;
|
||||
groove #000000; padding: 0; }
|
||||
|
||||
|
||||
/* Vote Button */
|
||||
.votebutton { background-color: #666666; color: #ffffff; font-family: Helvetica, Arial; font-size: 8pt;
|
||||
groove #000000; padding: 0; }
|
||||
|
||||
|
||||
/* Rate Button */
|
||||
.ratebutton { background-color: #666666; color: #ffffff; font-family: Helvetica, Arial; font-size: 8pt;
|
||||
groove #000000; padding: 0; }
|
||||
|
||||
|
||||
/* Search Button */
|
||||
.searchbutton { background-color: #666666; color: #ffffff; font-family: Helvetica, Arial; font-size: 10pt;
|
||||
groove #000000; padding: 0; }
|
||||
|
||||
/* Search Field */
|
||||
.searchfield { background-color: #EOEOEO; color: #666666; font-family: Helvetica, Arial; font-size: 10pt;
|
||||
groove #000000; padding: 0; }
|
||||
140
appbrowse.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?
|
||||
|
||||
/* code to BROWSE categories/apps */
|
||||
|
||||
|
||||
include("path.php");
|
||||
require(BASE."include/"."incl.php");
|
||||
require(BASE."include/"."appdb.php");
|
||||
require(BASE."include/"."category.php");
|
||||
|
||||
|
||||
function admin_menu()
|
||||
{
|
||||
global $catId;
|
||||
|
||||
$m = new htmlmenu("Admin");
|
||||
$m->add("Edit this Category", $apidb_root."admin/editCategory.php?catId=$catId");
|
||||
$url = $apidb_root."admin/deleteAny.php?what=category&catId=$catId&confirmed=yes";
|
||||
$m->add("Delete this Category", "javascript:deleteURL(\"Are you sure?\", \"".$url."\")");
|
||||
|
||||
|
||||
$m->done();
|
||||
}
|
||||
|
||||
if(!$catId)
|
||||
$catId = 0; // ROOT
|
||||
|
||||
// list sub categories
|
||||
$cat = new Category($catId);
|
||||
$catFullPath = make_cat_path($cat->getCategoryPath());
|
||||
$subs = $cat->getCategoryList();
|
||||
|
||||
//display admin box
|
||||
if(havepriv("admin") && $catId != 0)
|
||||
apidb_sidebar_add("admin_menu");
|
||||
|
||||
//output header
|
||||
apidb_header("Browse Applications");
|
||||
|
||||
if($subs)
|
||||
{
|
||||
echo html_frame_start("",'98%','',2);
|
||||
echo "<p><b>Category: ". $catFullPath ."</b><br>\n";
|
||||
echo html_frame_end();
|
||||
|
||||
echo html_frame_start("","98%","",0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=1>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td><font color=white>Sub Category</font></td>\n";
|
||||
echo " <td><font color=white>Description</font></td>\n";
|
||||
echo " <td><font color=white>No. Apps</font></td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c = 0;
|
||||
while(list($id, list($name, $desc)) = each($subs))
|
||||
{
|
||||
//set row color
|
||||
$bgcolor = ($c % 2 == 0) ? "color0" : "color1";
|
||||
|
||||
//get number of apps
|
||||
$appcount = $cat->getAppCount($id);
|
||||
|
||||
//format desc
|
||||
$desc = substr(stripslashes($desc),0,70);
|
||||
|
||||
//display row
|
||||
echo "<tr class=$bgcolor>\n";
|
||||
echo " <td><a href='appbrowse.php?catId=$id'>".stripslashes($name)."</a></td>\n";
|
||||
echo " <td>$desc </td>\n";
|
||||
echo " <td>$appcount </td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
echo "</table>\n\n";
|
||||
echo html_frame_end("$c categories");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// list applications in this category
|
||||
$apps = $cat->getAppList($catId);
|
||||
if($apps)
|
||||
{
|
||||
echo html_frame_start("",'98%','',2);
|
||||
echo "<p><b>Category: ". $catFullPath ."</b><br>\n";
|
||||
echo html_frame_end();
|
||||
|
||||
echo html_frame_start("","98%","",0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=1>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td><font color=white>Application Name</font></td>\n";
|
||||
echo " <td><font color=white>Description</font></td>\n";
|
||||
echo " <td><font color=white>No. Versions</font></td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c = 0;
|
||||
while(list($id, list($name, $desc)) = each($apps))
|
||||
{
|
||||
//skip if a NONAME
|
||||
if ($ob->appName == "NONAME") { continue; }
|
||||
|
||||
//set row color
|
||||
$bgcolor = ($c % 2 == 0) ? "color0" : "color1";
|
||||
|
||||
//get number of versions
|
||||
$query = mysql_query("SELECT count(*) as versions FROM appVersion WHERE appId = $id AND versionName != 'NONAME'");
|
||||
$ob = mysql_fetch_object($query);
|
||||
|
||||
//format desc
|
||||
$desc = substr(stripslashes($desc),0,70);
|
||||
|
||||
//display row
|
||||
echo "<tr class=$bgcolor>\n";
|
||||
echo " <td><a href='appview.php?appId=$id'>".stripslashes($name)."</a></td>\n";
|
||||
echo " <td>$desc </td>\n";
|
||||
echo " <td>$ob->versions </td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
echo "</table>\n\n";
|
||||
echo html_frame_end("$c applications in this category");
|
||||
}
|
||||
|
||||
// Disabled for now
|
||||
//if ($catId != 0)
|
||||
//{
|
||||
// log_category_visit($cat->id);
|
||||
//}
|
||||
|
||||
echo p();
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
96
appimage.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
require(BASE."include/"."incl.php");
|
||||
|
||||
/*
|
||||
* app image handler
|
||||
*
|
||||
* valid arguments:
|
||||
*
|
||||
* appId (required)
|
||||
* versionId
|
||||
*
|
||||
* imageId (no appId required if this is specified)
|
||||
*
|
||||
* width
|
||||
* height
|
||||
*
|
||||
* When both width/height are specified, the image is scaled
|
||||
*/
|
||||
|
||||
function handle_error($text)
|
||||
{
|
||||
echo $text;
|
||||
// output image with the text, or something
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!$appId && !$imageId) {
|
||||
handle_error("No appId");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$versionId) {
|
||||
$versionId = 0;
|
||||
}
|
||||
|
||||
opendb();
|
||||
|
||||
if($imageId)
|
||||
$result = mysql_query("SELECT * FROM appData WHERE id = $imageId");
|
||||
else
|
||||
$result = mysql_query("SELECT * FROM appData WHERE appId = $appId AND ".
|
||||
"versionId = $versionId AND type = 'image' LIMIT 1");
|
||||
|
||||
if(mysql_num_rows($result) == 0)
|
||||
handle_error("No image found");
|
||||
|
||||
$ob = mysql_fetch_object($result);
|
||||
|
||||
// atm assumes the image is in png format
|
||||
|
||||
if(!ereg("/", $ob->url))
|
||||
$url = "data/screenshots/$ob->url";
|
||||
else
|
||||
$url = $ob->url;
|
||||
|
||||
if(eregi(".+\\.(jpg|jpeg)$", $url))
|
||||
$type = "jpeg";
|
||||
else
|
||||
if(eregi(".+\\.(png)$", $url))
|
||||
$type = "png";
|
||||
|
||||
if(!$type)
|
||||
handle_error("Unknown Image Type");
|
||||
|
||||
if($type == "png")
|
||||
$im = ImageCreateFromPNG($url);
|
||||
else
|
||||
if($type == "jpeg")
|
||||
$im = ImageCreateFromJpeg($url);
|
||||
|
||||
if(!$im)
|
||||
handle_error("Error");
|
||||
|
||||
if($width && $height) {
|
||||
// do scaling
|
||||
$sim = ImageCreate($width, $height);
|
||||
ImageCopyResized($sim, $im, 0, 0, 0, 0, $width, $height, ImageSX($im), ImageSY($im));
|
||||
$im = $sim;
|
||||
}
|
||||
|
||||
// output the image
|
||||
if($type == "png")
|
||||
{
|
||||
header("Content-type: image/png");
|
||||
ImagePNG($im);
|
||||
}
|
||||
else
|
||||
if($type == "jpeg")
|
||||
{
|
||||
header("Content-type: image/jpeg");
|
||||
ImageJPEG($im);
|
||||
}
|
||||
|
||||
?>
|
||||
85
appsubmit.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?
|
||||
|
||||
/* code to Submit a new application */
|
||||
/* last modified 06-06-01 by Jeremy Newman */
|
||||
|
||||
|
||||
include("path.php");
|
||||
require(BASE."include/"."incl.php");
|
||||
global $current;
|
||||
|
||||
// set email field if logged in
|
||||
if ($current && loggedin())
|
||||
{
|
||||
$email = $current->lookup_email($current->userid);
|
||||
}
|
||||
|
||||
//header
|
||||
apidb_header("Submit Application");
|
||||
|
||||
|
||||
if ($queueName)
|
||||
{
|
||||
// add to queue
|
||||
|
||||
//FIXME: need to get image upload in
|
||||
|
||||
$query = "INSERT INTO appQueue VALUES (null, '".
|
||||
addslashes($queueName)."', '".
|
||||
addslashes($queueVersion)."', '".
|
||||
addslashes($queueVendor)."', '".
|
||||
addslashes($queueDesc)."', '".
|
||||
addslashes($queueEmail)."', '".
|
||||
addslashes($queueURL)."', '".
|
||||
addslashes($queueImage)."');";
|
||||
|
||||
mysql_query($query);
|
||||
|
||||
|
||||
if ($error = mysql_error())
|
||||
{
|
||||
echo "<p><font color=red><b>Error:</b></font></p>\n";
|
||||
echo "<p>$error</p>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<p>Your application has been submitted for Review. You should hear back\n";
|
||||
echo "soon about the status of your submission</p>\n";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// show add to queue form
|
||||
|
||||
echo '<form name="newApp" action="appsubmit.php" method="post" enctype="multipart/form-data">',"\n";
|
||||
|
||||
echo "<p>This page is for submitting new applications to be added to this\n";
|
||||
echo "database. The application will be reviewed by the AppDB Administrator\n";
|
||||
echo "and you will be notified via email if this application will be added to\n";
|
||||
echo "the database.</p>\n";
|
||||
echo "<p>Please don't forget to mention whether you actually tested this\n";
|
||||
echo "application under Wine, which Wine version you used and how well it worked. Thank you !</p>\n";
|
||||
echo "<p>To submit screenshots, please email them to ";
|
||||
echo "<a href='mailto:appdb@winehq.com'>appdb@winehq.com</a></p>\n";
|
||||
|
||||
echo html_frame_start("New Application Form",400,"",0);
|
||||
|
||||
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||
echo '<tr valign=top><td class=color0><b>App Name</b></td><td><input type=text name="queueName" value="" size=20></td></tr>',"\n";
|
||||
echo '<tr valign=top><td class=color0><b>App Version</b></td><td><input type=text name="queueVersion" value="" size=20></td></tr>',"\n";
|
||||
echo '<tr valign=top><td class=color0><b>App Vendor</b></td><td><input type=text name="queueVendor" value="" size=20></td></tr>',"\n";
|
||||
echo '<tr valign=top><td class=color0><b>App URL</b></td><td><input type=text name="queueURL" value="" size=20></td></tr>',"\n";
|
||||
echo '<tr valign=top><td class=color0><b>App Desc</b></td><td><textarea name="queueDesc" rows=10 cols=35></textarea></td></tr>',"\n";
|
||||
echo '<tr valign=top><td class=color0><b>Email</b></td><td><input type=text name="queueEmail" value="'.$email.'" size=20></td></tr>',"\n";
|
||||
//echo '<tr valign=top><td class=color0><b>Image</b></td><td><input type=file name="queueImage" value="" size=15></td></tr>',"\n";
|
||||
echo '<tr valign=top><td class=color3 align=center colspan=2> <input type=submit value=" Submit New Application " class=button> </td></tr>',"\n";
|
||||
echo '</table>',"\n";
|
||||
|
||||
echo html_frame_end();
|
||||
|
||||
echo "</form>";
|
||||
}
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
420
appview.php
Normal file
@@ -0,0 +1,420 @@
|
||||
<?
|
||||
|
||||
|
||||
/*
|
||||
* Application Database - appview.php
|
||||
*
|
||||
*/
|
||||
|
||||
include("path.php");
|
||||
require(BASE."include/"."incl.php");
|
||||
require(BASE."include/"."application.php");
|
||||
require(BASE."include/"."comments.php");
|
||||
require(BASE."include/"."appdb.php");
|
||||
|
||||
require(BASE."include/"."vote.php");
|
||||
require(BASE."include/"."rating.php");
|
||||
require(BASE."include/"."category.php");
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
|
||||
// NOTE: app Owners will see this menu too, make sure we don't show admin-only options
|
||||
function admin_menu()
|
||||
{
|
||||
global $appId;
|
||||
global $versionId;
|
||||
global $apidb_root;
|
||||
|
||||
$m = new htmlmenu("Admin");
|
||||
if($versionId)
|
||||
{
|
||||
$m->add("Add Note", $apidb_root."admin/addAppNote.php?appId=$appId&versionId=$versionId");
|
||||
$m->addmisc(" ");
|
||||
|
||||
$m->add("Edit Version", $apidb_root."admin/editAppVersion.php?appId=$appId&versionId=$versionId");
|
||||
|
||||
$url = $apidb_root."admin/deleteAny.php?what=appVersion&versionId=$versionId&confirmed=yes";
|
||||
$m->add("Delete Version", "javascript:deleteURL(\"Are you sure?\", \"".$url."\")");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$m->add("Add Version", $apidb_root."admin/addAppVersion.php?appId=$appId");
|
||||
$m->addmisc(" ");
|
||||
|
||||
$m->add("Edit App", $apidb_root."admin/editAppFamily.php?appId=$appId");
|
||||
|
||||
// global admin options
|
||||
if(havepriv("admin"))
|
||||
{
|
||||
$url = $apidb_root."admin/deleteAny.php?what=appFamily&appId=$appId&confirmed=yes";
|
||||
$m->add("Delete App", "javascript:deleteURL(\"Are you sure?\", \"".$url."\")");
|
||||
$m->addmisc(" ");
|
||||
$m->add("Edit Owners", $apidb_root."admin/editAppOwners.php?appId=$appId");
|
||||
$m->add("Edit Bundle", $apidb_root."admin/editBundle.php?bundleId=$appId");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$m->done();
|
||||
}
|
||||
|
||||
|
||||
function get_screenshot_img($appId, $versionId)
|
||||
{
|
||||
global $apidb_root;
|
||||
|
||||
if(!$versionId)
|
||||
$versionId = 0;
|
||||
|
||||
$result = mysql_query("SELECT * FROM appData WHERE appId = $appId AND versionId = $versionId AND type = 'image'");
|
||||
|
||||
if(!$result || !mysql_num_rows($result))
|
||||
{
|
||||
$imgFile = "<img src='".$apidb_root."images/no_screenshot.gif' border=0 alt='No Screenshot'>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ob = mysql_fetch_object($result);
|
||||
$imgFile = "<img src='appimage.php?appId=$appId&versionId=$versionId&width=128&height=128' ".
|
||||
"border=0 alt='$ob->description'>";
|
||||
}
|
||||
|
||||
$img = html_frame_start("",'128','',2);
|
||||
$img .= "<a href='screenshots.php?appId=$appId&versionId=$versionId'>$imgFile</a>";
|
||||
$img .= html_frame_end()."<br>";
|
||||
|
||||
return $img;
|
||||
}
|
||||
|
||||
|
||||
function display_catpath($catId)
|
||||
{
|
||||
$cat = new Category($catId);
|
||||
|
||||
$catFullPath = make_cat_path($cat->getCategoryPath());
|
||||
echo html_frame_start("",'98%','',2);
|
||||
echo "<p><b>Category: ". $catFullPath ."</b><br>\n";
|
||||
echo html_frame_end();
|
||||
}
|
||||
|
||||
/* display the SUB apps that belong to this app */
|
||||
function display_bundle($appId)
|
||||
{
|
||||
$result = mysql_query("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ".
|
||||
"WHERE bundleId = $appId AND appBundle.appId = appFamily.appId");
|
||||
if(!$result || mysql_num_rows($result) == 0)
|
||||
{
|
||||
// do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
echo html_frame_start("","98%","",0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=1>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td><font color=white>Application Name</font></td>\n";
|
||||
echo " <td><font color=white>Description</font></td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c = 0;
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
//set row color
|
||||
$bgcolor = ($c % 2 == 0) ? "color0" : "color1";
|
||||
|
||||
//format desc
|
||||
$desc = substr(stripslashes($ob->description),0,50);
|
||||
if(strlen($desc) == 50)
|
||||
$desc .= " ...";
|
||||
|
||||
//display row
|
||||
echo "<tr class=$bgcolor>\n";
|
||||
echo " <td><a href='appview.php?appId=$ob->appId'>".stripslashes($ob->appName)."</a></td>\n";
|
||||
echo " <td>$desc </td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
echo "</table>\n\n";
|
||||
echo html_frame_end();
|
||||
}
|
||||
|
||||
|
||||
/* display the notes for the app */
|
||||
function display_notes($appId, $versionId = 0)
|
||||
{
|
||||
$result = mysql_query("SELECT noteId,noteTitle FROM appNotes ".
|
||||
"WHERE appId = $appId AND versionId = $versionId");
|
||||
|
||||
if(!$result || mysql_num_rows($result) == 0)
|
||||
{
|
||||
// do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<tr class=color1><td valign=top align=right> <b>Notes</b></td><td>\n";
|
||||
|
||||
$c = 1;
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
//skip if NONAME
|
||||
if ($ob->noteTitle == "NONAME") { continue; }
|
||||
|
||||
//set link for version
|
||||
if ($versionId != 0)
|
||||
{
|
||||
$versionLink = "&versionId=$versionId";
|
||||
}
|
||||
|
||||
//display row
|
||||
echo " <a href='noteview.php?noteId=".$ob->noteId."&appId=$appId".$versionLink."'> $c. ".substr(stripslashes($ob->noteTitle),0,30)."</a><br>\n";
|
||||
$c++;
|
||||
}
|
||||
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
|
||||
/* display the versions */
|
||||
function display_versions($appId, $versions)
|
||||
{
|
||||
if ($versions)
|
||||
{
|
||||
|
||||
echo html_frame_start("","98%","",0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=1>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td width=80><font color=white>Version</font></td>\n";
|
||||
echo " <td><font color=white>Description</font></td>\n";
|
||||
echo " <td width=80><font color=white class=small>Rating With Windows</font></td>\n";
|
||||
echo " <td width=80><font color=white class=small>Rating Without Windows</font></td>\n";
|
||||
echo " <td width=40><font color=white class=small>Comments</font></td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c = 0;
|
||||
while(list($idx, $ver) = each($versions))
|
||||
{
|
||||
//set row color
|
||||
$bgcolor = ($c % 2 == 0) ? "color0" : "color1";
|
||||
|
||||
//format desc
|
||||
$desc = substr(stripslashes($ver->description),0,75);
|
||||
if(strlen($desc) == 75)
|
||||
$desc .= " ...";
|
||||
|
||||
//get ratings
|
||||
$r_win = rating_stars_for_version($ver->versionId, "windows");
|
||||
$r_fake = rating_stars_for_version($ver->versionId, "fake");
|
||||
|
||||
//count comments
|
||||
$r_count = count_comments($appId,$ver->versionId);
|
||||
|
||||
//display row
|
||||
echo "<tr class=$bgcolor>\n";
|
||||
echo " <td><a href='appview.php?appId=$appId&versionId=$ver->versionId'>".$ver->versionName."</a></td>\n";
|
||||
echo " <td>$desc </td>\n";
|
||||
echo " <td align=center>$r_win</td>\n";
|
||||
echo " <td align=center>$r_fake</td>\n";
|
||||
echo " <td align=center>$r_count</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo html_frame_end("Click the Version Name to view the details of that Version");
|
||||
}
|
||||
}
|
||||
|
||||
/* code to VIEW an application & versions */
|
||||
|
||||
if($appId && !$versionId)
|
||||
{
|
||||
$app = new Application($appId);
|
||||
$data = $app->data;
|
||||
if(!$data) {
|
||||
// Oops! application not found or other error. do something
|
||||
errorpage('Internal Database Access Error');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Show Vote Menu
|
||||
if(loggedin())
|
||||
apidb_sidebar_add("vote_menu");
|
||||
|
||||
// Show Admin Menu
|
||||
if(loggedin() && (havepriv("admin") || $current->ownsApp($appId))) {
|
||||
apidb_sidebar_add("admin_menu");
|
||||
}
|
||||
|
||||
// header
|
||||
apidb_header("Viewing App - ".$data->appName);
|
||||
|
||||
//cat display
|
||||
display_catpath($app->data->catId);
|
||||
|
||||
//set Vendor
|
||||
$vendor = $app->getVendor();
|
||||
|
||||
//set URK
|
||||
$appLinkURL = ($data->webPage) ? "<a href='$data->webPage'>".substr(stripslashes($data->webPage),0,30)."</a>": " ";
|
||||
|
||||
//set Image
|
||||
$img = get_screenshot_img($appId, $versionId);
|
||||
|
||||
//start display application
|
||||
echo html_frame_start("","98%","",0);
|
||||
|
||||
echo '<tr><td class=color4 valign=top>',"\n";
|
||||
echo '<table width="250" border=0 cellpadding=3 cellspacing=1">',"\n";
|
||||
echo "<tr class=color0 valign=top><td width='100' align=right> <b>Name</b></td><td width='100%'> ".stripslashes($data->appName)." </td>\n";
|
||||
echo "<tr class=color1 valign=top><td width='100' align=right> <b>App Id</b></td><td width='100%'> ".$data->appId." </td>\n";
|
||||
echo "<tr class=color0 valign=top><td align=right> <b>Vendor</b></td><td> ".
|
||||
" <a href='vendorview.php?vendorId=$vendor->vendorId'> ".stripslashes($vendor->vendorName)." </a> \n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
//display notes
|
||||
display_notes($appId);
|
||||
|
||||
//main URL
|
||||
echo "<tr class=color0 valign=top><td align=right> <b>URL</b></td><td>".$appLinkURL."</td></tr>\n";
|
||||
|
||||
//optional links
|
||||
$result = mysql_query("SELECT * FROM appData WHERE appId = $appId AND type = 'url'");
|
||||
if($result && mysql_num_rows($result) > 0)
|
||||
{
|
||||
echo "<tr class=color1><td valign=top align=right> <b>Links</b></td><td>\n";
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
echo " <a href='$ob->url'>".substr(stripslashes($ob->description),0,30)."</a> <br>\n";
|
||||
}
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
|
||||
// display app owner
|
||||
$result = mysql_query("SELECT * FROM appOwners WHERE appId = $appId");
|
||||
if($result && mysql_num_rows($result) > 0)
|
||||
{
|
||||
echo "<tr class=color0><td valign=top align=right> <b>Owner</b></td><td>\n";
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
$inResult = mysql_query("SELECT username,email FROM user_list WHERE userid = $ob->ownerId");
|
||||
if ($inResult && mysql_num_rows($inResult) > 0)
|
||||
{
|
||||
$foo = mysql_fetch_object($inResult);
|
||||
echo " <a href='mailto:$foo->email'>".substr(stripslashes($foo->username),0,30)."</a> <br>\n";
|
||||
}
|
||||
}
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
|
||||
echo "</table></td><td class=color2 valign=top width='100%'>\n";
|
||||
|
||||
//Desc
|
||||
echo "<table width='100%' border=0><tr><td width='100%' valign=top><b>Description</b><br>\n";
|
||||
echo add_br(stripslashes($data->description));
|
||||
|
||||
echo "</td></tr></table>\n";
|
||||
|
||||
echo html_frame_end("For more details and user comments, view the versions of this application.");
|
||||
|
||||
//display versions
|
||||
display_versions($appId,$app->getAppVersionList());
|
||||
|
||||
//display bundle
|
||||
display_bundle($appId);
|
||||
|
||||
// disabled for now
|
||||
//log_application_visit($appId);
|
||||
|
||||
}
|
||||
else if($appId && $versionId)
|
||||
{
|
||||
$app = new Application($appId);
|
||||
$data = $app->data;
|
||||
|
||||
if(!$data) {
|
||||
// Oops! application not found or other error. do something
|
||||
errorpage('Internal Database Access Error');
|
||||
exit;
|
||||
}
|
||||
|
||||
// rating menu
|
||||
if(loggedin()) {
|
||||
apidb_sidebar_add("rating_menu");
|
||||
}
|
||||
|
||||
// admin menu
|
||||
if(loggedin() && (havepriv("admin") || $current->ownsApp($appId))) {
|
||||
apidb_sidebar_add("admin_menu");
|
||||
}
|
||||
|
||||
// header
|
||||
$ver = $app->getAppVersion($versionId);
|
||||
apidb_header("Viewing App Version - ".$data->appName);
|
||||
|
||||
//cat
|
||||
display_catpath($app->data->catId);
|
||||
|
||||
//set URL
|
||||
$appLinkURL = ($data->webPage) ? "<a href='$data->webPage'>".substr(stripslashes($data->webPage),0,30)."</a>": " ";
|
||||
|
||||
//set image
|
||||
$img = get_screenshot_img($appId, $versionId);
|
||||
|
||||
//start version display
|
||||
echo html_frame_start("","98%","",0);
|
||||
|
||||
echo '<tr><td class=color4 valign=top>',"\n";
|
||||
echo '<table width="250" border=0 cellpadding=3 cellspacing=1">',"\n";
|
||||
echo "<tr class=color0 valign=top><td width=100> <b>Name</b></td><td width='100%'>".stripslashes($data->appName)."</td>\n";
|
||||
echo "<tr class=color1 valign=top><td width=100> <b>Ver Id</b></td><td width='100%'> $ver->versionId</td>\n";
|
||||
echo "<tr class=color0 valign=top><td> <b>Version</b></td><td>".stripslashes($ver->versionName)."</td></tr>\n";
|
||||
echo "<tr class=color1 valign=top><td> <b>URL</b></td><td>".stripslashes($appLinkURL)."</td></tr>\n";
|
||||
|
||||
//Rating Area
|
||||
$r_win = rating_stars_for_version($versionId, "windows");
|
||||
$r_fake = rating_stars_for_version($versionId, "fake");
|
||||
|
||||
echo "<tr class=color0 valign=top><td> <b>Rating</b></td><td> $r_win \n";
|
||||
echo "<br> $r_fake </td></tr>\n";
|
||||
|
||||
//notes
|
||||
display_notes($appId, $versionId);
|
||||
|
||||
//Image
|
||||
echo "<tr><td align=center colspan=2>$img</td></tr>\n";
|
||||
|
||||
echo "</table></td><td class=color2 valign=top width='100%'>\n";
|
||||
|
||||
//Desc Image
|
||||
echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br>\n";
|
||||
echo add_br(stripslashes($ver->description));
|
||||
echo "</td></tr></table>\n";
|
||||
|
||||
echo html_frame_end();
|
||||
|
||||
//TODO: code to view/add user experience records
|
||||
if(!$versionId) {
|
||||
$versionId = 0;
|
||||
}
|
||||
|
||||
// Comments Section
|
||||
view_app_comments($appId, $versionId);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Oops! Called with no params, bad llamah!
|
||||
errorpage('Page Called with No Params!');
|
||||
exit;
|
||||
}
|
||||
|
||||
echo p();
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
BIN
banner/468x60/cw-ad01.gif
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
banner/468x60/cw-ad02.gif
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
banner/468x60/cw-ad04.gif
Normal file
|
After Width: | Height: | Size: 18 KiB |
7
banner/xml/cw-ad01.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE bannerAd>
|
||||
<ad>
|
||||
<id>cw-ad04</id>
|
||||
<url>http://www.codeweavers.com/products/crossover/?ad=1</url>
|
||||
<alt>QuickTime for Linux!</alt>
|
||||
</ad>
|
||||
7
banner/xml/cw-ad02.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE bannerAd>
|
||||
<ad>
|
||||
<id>cw-ad04</id>
|
||||
<url>http://www.codeweavers.com/products/crossover/support_wine.php?ad=1</url>
|
||||
<alt>Support the Wine Project!</alt>
|
||||
</ad>
|
||||
7
banner/xml/cw-ad04.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE bannerAd>
|
||||
<ad>
|
||||
<id>cw-ad04</id>
|
||||
<url>http://www.codeweavers.com/products/office/?ad=1</url>
|
||||
<alt>Microsoft Office On Linux!</alt>
|
||||
</ad>
|
||||
21
commentview.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* view comments
|
||||
*
|
||||
* script expects appId, versionId and threadId as argument
|
||||
*
|
||||
*/
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
require(BASE."include/"."comments.php");
|
||||
|
||||
apidb_header("Comments");
|
||||
|
||||
view_app_comments($appId, $versionId, $threadId);
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
55
edituser.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
|
||||
if(!havepriv("admin"))
|
||||
{
|
||||
errorpage();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$user_fields = array("stamp", "userid", "username", "password", "realname", "email", "created", "status");
|
||||
|
||||
function make_fields($fields, $prefix)
|
||||
{
|
||||
$arr = array();
|
||||
while(list($idx, $field) = each($fields))
|
||||
$arr[] = "$prefix.$field";
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
apidb_header("Edit User");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
}
|
||||
else
|
||||
{
|
||||
$qc = new qclass();
|
||||
$qc->add_fields(make_fields($user_fields, "user_list"));
|
||||
if($username)
|
||||
$qc->add_where("username = '$username'");
|
||||
else
|
||||
$qc->add_where("userid = $userid");
|
||||
$qc->resolve();
|
||||
|
||||
$query = $qc->get_query();
|
||||
|
||||
if(debugging())
|
||||
echo "$query <br><br>\n";
|
||||
|
||||
$t->edit($query);
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
BIN
favicon.ico
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
2
help/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
stderr
|
||||
|
||||
66
help/appdb_faq.help
Normal file
@@ -0,0 +1,66 @@
|
||||
<!--TITLE: Application Database FAQ -->
|
||||
|
||||
<h3>Application Database FAQ</h3>
|
||||
|
||||
<p>This FAQ answers questions related to the usage of the
|
||||
Application Database.</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<p><b>Q: What is the Application Database?</b></p>
|
||||
<blockquote>
|
||||
<p><b>A:</b> The Application Database is a repository for
|
||||
compatibility information of applications for Microsoft Windows
|
||||
running on Wine.<p>
|
||||
</blockquote>
|
||||
|
||||
<p><b>Q: What is Wine?</b></p>
|
||||
<blockquote>
|
||||
<p><b>A:</b> Wine is an execution layer that allows Windows programs to be run
|
||||
on Linux Systems. More information can be found at the
|
||||
<a href="http://www.winehq.com/fom-meta/cache/3.html">Wine FAQ</a>.<p>
|
||||
</blockquote>
|
||||
|
||||
<p><b>Q: What is the benefit Application Database?</b></p>
|
||||
<blockquote>
|
||||
<p><b>A:</b> The Application database will give the Wine developers a
|
||||
resource for compatibility information. This will allow them to focus their
|
||||
efforts on those applications the community most wants to see working. It also
|
||||
provides end-user support. Users can find out before they even install Wine if
|
||||
their application is supported.<p>
|
||||
</blockquote>
|
||||
|
||||
<p><b>Q: How does a new application get added to the database?</b></p>
|
||||
<blockquote>
|
||||
<p><b>A:</b> In order to ensure consistency, only authorized application database
|
||||
maintainers are permitted to add new applications to the database.
|
||||
Anyone can comment on, or rate a particular application.</p>
|
||||
<p>Anyone can request that an application be added to the database,
|
||||
but the application is not actually added until after it has been
|
||||
reviewed and categorized by a maintainer.</p>
|
||||
</blockquote>
|
||||
|
||||
<p><b>Q: How can I submit HowTo's and Screenshots?</b></p>
|
||||
<blockquote>
|
||||
<p><b>A:</b> We love to hear from our users. Send those helpful HowTo's and
|
||||
Screenshots right on over to <a href="mailto:appdb@winehq.com">appdb@winehq.com</a>.
|
||||
We'll be happy to post them, and give you proper credit for your great contribution.</p>
|
||||
</blockquote>
|
||||
|
||||
|
||||
<p><b>Q: How do I become an authorized application database maintainer.</b></p>
|
||||
<blockquote>
|
||||
<p><b>A:</b> Pretty much anyone with an established reputation supporting Wine
|
||||
is welcome (begged?) to be an application maintainer.
|
||||
Simply send email to <a href="mailto:appdb@winehq.com">appdb@winehq.com</a>
|
||||
to apply. Once we have a community of maintainers, we hope that community
|
||||
will further refine the policies and procedures.</p>
|
||||
</blockquote>
|
||||
|
||||
</ul>
|
||||
|
||||
If you have more questions you would like to add to our FAQ, please contact us
|
||||
at <a href="mailto:appdb@winehq.com">appdb@winehq.com</a>.
|
||||
|
||||
<p> </p>
|
||||
|
||||
54
help/generic.help
Normal file
@@ -0,0 +1,54 @@
|
||||
<!--TITLE: Additional Wine Help -->
|
||||
|
||||
This is meant as generic instructions in case an AppDB entry
|
||||
for a certain program doesn't exist.
|
||||
|
||||
<ol>
|
||||
|
||||
<li> Make sure your Wine release is pretty recent.
|
||||
Current possibilities are:</li><p>
|
||||
|
||||
<ul>
|
||||
<li> <a href="http://www.codeweavers.com">CodeWeavers Wine</a> Preview
|
||||
simple, complete configuration</li>
|
||||
<li><a href="http://sourceforge.net/projects/winex">TransGaming WineX</a>,
|
||||
Wine version with special DirectX support, use this one for games.</li>
|
||||
<li> Misc. Wine packages/versions downloadable via
|
||||
<a href="http://www.winehq.com">WineHQ</a></li>
|
||||
</ul>
|
||||
<p>
|
||||
|
||||
<li> Run <a href="http://home.nexgo.de/andi.mohr/download/winecheck">winecheck</a>
|
||||
(chmod +x winecheck; ./winecheck)
|
||||
to verify the most important aspects of Wine environment
|
||||
configuration</li><p>
|
||||
|
||||
<li> Run your program</li><p>
|
||||
|
||||
<li> In case of failure, try different builtin, native DLL settings:
|
||||
Run Wine with --debugmsg +loaddll to find out which
|
||||
DLLs are loaded as native or builtin ones.
|
||||
Then make sure appropriate native versions are in the
|
||||
c:\windows\system directory as configured in your wine
|
||||
config file, and then use either --dll DLL1, DLL2,...=n or
|
||||
--dll DLL1,DLL2,...=b
|
||||
to use native or builtin setting for certain DLLs, respectively.</li><p>
|
||||
|
||||
<li> In case of persisting failure, check out
|
||||
<a href="http://www.winehq.com/Trouble/">Wine Troubleshooting Guide</a>
|
||||
and read all of the available documentation at
|
||||
<a href="http://www.winehq.com/support.shtml">WineHQ Support</a></li><p>
|
||||
|
||||
<li> If that doesn't help, then ask people on
|
||||
<a href="http://irc.openprojects.net">irc.openprojects.net</a>
|
||||
channel #WineHQ or on the
|
||||
<a href="http://www.winehq.com/mailman/listinfo/wine-users">wine-users</a>
|
||||
mailing list. </li><p>
|
||||
|
||||
<li> If you have more questions, please contact us
|
||||
at <a href="mailto:appdb@codeweavers.com">appdb@codeweavers.com</a>.</li><p>
|
||||
|
||||
</ol>
|
||||
|
||||
<p> </p>
|
||||
|
||||
102
help/index.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Application Database Documentation Center
|
||||
*
|
||||
*/
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
|
||||
$help_path = $apidb_root."/help";
|
||||
|
||||
if($topic)
|
||||
{
|
||||
display_help($topic);
|
||||
} else {
|
||||
display_index();
|
||||
}
|
||||
|
||||
function display_index ()
|
||||
{
|
||||
global $help_path;
|
||||
global $apidb_root;
|
||||
|
||||
apidb_header("Documentation Index");
|
||||
|
||||
echo "<p><b>Providing all the help you need 24x7</b><p><hr noshade>\n";
|
||||
|
||||
echo "<ul>\n";
|
||||
|
||||
// read dir
|
||||
$files = array();
|
||||
$d = opendir($help_path);
|
||||
while($entry = readdir($d))
|
||||
{
|
||||
array_push($files, $entry);
|
||||
}
|
||||
closedir($d);
|
||||
|
||||
//sort dir
|
||||
sort($files);
|
||||
|
||||
// display dir
|
||||
while (list($key,$file) = each($files))
|
||||
{
|
||||
if(!ereg("(.+)\\.help$", $file, $arr))
|
||||
continue;
|
||||
|
||||
$id = $arr[1];
|
||||
$title = get_help_title("$help_path/$file");
|
||||
|
||||
echo " <li> <a href='".$apidb_root."help?topic=$id'> $title </a> </li><p>\n";
|
||||
}
|
||||
|
||||
echo "</ul><hr noshade>\n";
|
||||
|
||||
echo "<p>Need more help? Contact us at <a href='mailto:appdb@winehq.com'>appdb@winehq.com</a><p>\n";
|
||||
|
||||
apidb_footer();
|
||||
}
|
||||
|
||||
function display_help ($topic)
|
||||
{
|
||||
global $help_path;
|
||||
|
||||
$file = "$help_path/$topic.help";
|
||||
$title = get_help_title($file);
|
||||
|
||||
if(! $title) {
|
||||
$title = "Help on $topic";
|
||||
}
|
||||
|
||||
apidb_header($title);
|
||||
if(file_exists($file)) {
|
||||
include($file);
|
||||
} else {
|
||||
echo "<p><b> No help available on that topic </b><p>\n";
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
}
|
||||
|
||||
function get_help_title ($file)
|
||||
{
|
||||
$fp = @fopen($file, "r");
|
||||
if(!$fp)
|
||||
return null;
|
||||
|
||||
$line = fgets($fp, 1024);
|
||||
if(!$line)
|
||||
return null;
|
||||
|
||||
$line = trim($line);
|
||||
|
||||
if(eregi("^<!--TITLE: (.+)-->$", $line, $arr))
|
||||
{
|
||||
return $arr[1];
|
||||
}
|
||||
return "Internal Error: missing title";
|
||||
}
|
||||
|
||||
?>
|
||||
3
help/path.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?
|
||||
define("BASE","../");
|
||||
?>
|
||||
45
help/privacy.help
Normal file
@@ -0,0 +1,45 @@
|
||||
<!--TITLE: Application DB Privacy Policy -->
|
||||
|
||||
<h3>Application DB Privacy Policy</h3>
|
||||
|
||||
<p>
|
||||
<b>CodeWeavers is decidated to the privacy of its customers.</b><br>
|
||||
<ul>
|
||||
Whatever specific information you give to us will be used only to enable user
|
||||
specific features of the Application Database. We will give your information
|
||||
to no third parties, nor will we send you email you did not request. We may
|
||||
use your information in the aggregate to better understand our market.
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Cookies</b>
|
||||
<ul>
|
||||
The Application Database uses cookies only to preserve login information in your web browser.
|
||||
Advertisers or other companies do not have access to the AppDB's cookies.
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Changes to this Privacy Policy</b><br>
|
||||
<ul>
|
||||
We may amend this policy from time to time. If we make any
|
||||
substantial changes in the way we use your personal information we
|
||||
will notify you by posting a prominent announcement on our pages.
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Questions or Suggestions</b><br>
|
||||
<ul>
|
||||
If you have questions or suggestions, feel free to contact us at
|
||||
<a href="mailto:appdb@winehq.com">appdb@winehq.com</a>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>NOTICE:</b> <a href="http://www.ftc.gov/bcp/conline/pubs/online/sitesee/index.html">Click here</a>
|
||||
for important information about safe surfing from the Federal Trade Commission.
|
||||
</p>
|
||||
|
||||
<p> </p>
|
||||
95
help/ratings.help
Normal file
@@ -0,0 +1,95 @@
|
||||
<!--TITLE: Ratings Help -->
|
||||
|
||||
<h3>Application Ratings System Help</h3>
|
||||
|
||||
<p>
|
||||
The Application Database features a rating system that allows us and you to see
|
||||
which applications work the best in Wine. This voting system is designed to be
|
||||
pessimistic.
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
|
||||
<li>Log into the Application Database.</li><p>
|
||||
|
||||
<li>Browse to the Application you wish to rate.</li><p>
|
||||
|
||||
<li>In the sidebar, choose whether you are rating Wine running
|
||||
in Windows mode, or Fake Windows Mode.<br>
|
||||
<ul>
|
||||
<li><img src='../images/w1.gif' alt='With Windows'> <b>With Windows</b> = Wine Configured to use a Windows partition.</li>
|
||||
<li><img src='../images/w0.gif' alt='Without Windows'> <b>Without Windows</b> = Wine using its own internal Windows (Fake Windows).</li>
|
||||
</ul>
|
||||
</li><p>
|
||||
|
||||
<li>In the sidebar, click the number of stars you want to
|
||||
rate this application.<br>
|
||||
<ul>
|
||||
<li> <b>0</b> -- Unrated.
|
||||
<li> <b>1</b> -- Totally nonfunctional. Crashes on load.
|
||||
<li> <b>2</b> -- Partial functionality. Good enough for a carefully scripted demo.
|
||||
<li> <b>3</b> -- Sufficient functionality for noncritical work. Occasional crashes okay,
|
||||
as are weird setup problems, required patches, or missing major functionality.
|
||||
Alpha quality.
|
||||
<li> <b>4</b> -- Substantially correct. Good enough for general use, with possible
|
||||
caveats.
|
||||
<li> <b>5</b> -- Perfect. No flaws under any mode
|
||||
</ul>
|
||||
</li><p>
|
||||
|
||||
<li>Click the Rate! button to store your vote for this
|
||||
application.
|
||||
</li><p>
|
||||
|
||||
</ol>
|
||||
|
||||
|
||||
<b> How to rate an application </b></br>
|
||||
|
||||
<i>Please</i> don't exaggerate how well things work.
|
||||
It only creates expectations which
|
||||
can't be met, and doesn't do anybody
|
||||
any good in the long run.
|
||||
Here is a simple flowchart for testing applications.
|
||||
|
||||
<ul>
|
||||
|
||||
<li> First, figure out the name of the app, the vendor, and the product
|
||||
version number.</li><p>
|
||||
|
||||
<li> Try to start the application under the emulator.
|
||||
If it completes loading,
|
||||
without crashing, and displaying more or less what it would under
|
||||
some version of Windows, then the app deserves a 2. Otherwise, it gets a
|
||||
1.</li><p>
|
||||
|
||||
<li> Try doing a few things with it. If you can
|
||||
find several useful operations
|
||||
which can be correctly performed with the app, such that you would be
|
||||
willing to stand in front of a large group of people, saying ``This app
|
||||
works nearly perfectly on Wine'' and doing those operations, give it a 3.
|
||||
</li><p>
|
||||
|
||||
<li> If you don't normally use the app, stop here. Higher ratings should
|
||||
only be given for app performance under actual use.</li><p>
|
||||
|
||||
<li> At some time when there is something which you need to do with the
|
||||
app, try doing it under Wine. If you can get the job done without putting
|
||||
your fist through the screen, then the application deserves a 4. Note that
|
||||
this is not, ``Someone <i>could</i> do useful work with this app'' but
|
||||
``I have used this app for useful work, not just fooling around.''</li><p>
|
||||
|
||||
<li> If you use an app under Wine for months, and its behavior is robust
|
||||
under a variety of uses, its performance is adequate, and
|
||||
these characteristics are stable as Wine changes from release to release,
|
||||
and it works for a lot of people with varying setups under various OSes,
|
||||
then it deserves a 5.</li><p>
|
||||
|
||||
<li> After a new version of Wine, test the application again. If the app
|
||||
improves or gets worse, come back and change your vote.</li><p>
|
||||
|
||||
</ul>
|
||||
|
||||
Remember: only <i>you</i> can prevent rating inflation.
|
||||
|
||||
<p> </p>
|
||||
40
help/voting.help
Normal file
@@ -0,0 +1,40 @@
|
||||
<!--TITLE: Voting Help -->
|
||||
|
||||
<h3>Application Voting System Help</h3>
|
||||
|
||||
<p>
|
||||
The Application Database features a voting system that allows you to pick which <b>3</b> applications
|
||||
you would MOST like to see running in Wine.
|
||||
</p>
|
||||
|
||||
<p><b>Step by Step on Voting</b></p>
|
||||
<ol>
|
||||
|
||||
<li>Log into the Application Database.</li><p>
|
||||
|
||||
<li>Browse to the Application you wish to add to your vote list.</li><p>
|
||||
|
||||
<li>In the sidebar, Click one of the 3 available slots, and click Vote.</li><p>
|
||||
|
||||
<li>Done!</li></p>
|
||||
|
||||
</ol>
|
||||
|
||||
|
||||
<p><b> Voting System Notes </b></p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><i>Please</i> seriously only vote for applications which will benefit the community. Don't
|
||||
vote for applications that are known to work well. We know Solitaire works. Voting for it
|
||||
would not make much sense.</li><p>
|
||||
|
||||
<li>When voting for an application, you are voting for <b>ALL</b> its various versions. There is
|
||||
a separate system in place for ranking versions.</Li><p>
|
||||
|
||||
<li>You can clear your vote at anytime. Simply browse to any App in the database, select the app
|
||||
in your vote list you want to clear, and click the Clear button.</li><p>
|
||||
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
BIN
images/appdb_montage.jpg
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
images/back.gif
Normal file
|
After Width: | Height: | Size: 128 B |
BIN
images/bk.gif
Normal file
|
After Width: | Height: | Size: 109 B |
BIN
images/blank.gif
Normal file
|
After Width: | Height: | Size: 61 B |
BIN
images/compare.gif
Normal file
|
After Width: | Height: | Size: 146 B |
BIN
images/go.gif
Normal file
|
After Width: | Height: | Size: 130 B |
BIN
images/grey_pixel.gif
Normal file
|
After Width: | Height: | Size: 43 B |
BIN
images/list.gif
Normal file
|
After Width: | Height: | Size: 114 B |
BIN
images/next.gif
Normal file
|
After Width: | Height: | Size: 126 B |
BIN
images/no_screenshot.gif
Normal file
|
After Width: | Height: | Size: 903 B |
BIN
images/remove.gif
Normal file
|
After Width: | Height: | Size: 144 B |
BIN
images/s0.gif
Normal file
|
After Width: | Height: | Size: 59 B |
BIN
images/s1.gif
Normal file
|
After Width: | Height: | Size: 117 B |
BIN
images/s2.gif
Normal file
|
After Width: | Height: | Size: 117 B |
BIN
images/tree.gif
Normal file
|
After Width: | Height: | Size: 116 B |
BIN
images/w0.gif
Normal file
|
After Width: | Height: | Size: 65 B |
BIN
images/w1.gif
Normal file
|
After Width: | Height: | Size: 297 B |
BIN
images/winehq_border_bottom_left.gif
Normal file
|
After Width: | Height: | Size: 125 B |
BIN
images/winehq_border_bottom_right.gif
Normal file
|
After Width: | Height: | Size: 105 B |
BIN
images/winehq_border_dot_left.gif
Normal file
|
After Width: | Height: | Size: 114 B |
BIN
images/winehq_border_dot_right.gif
Normal file
|
After Width: | Height: | Size: 114 B |
BIN
images/winehq_border_top_left.gif
Normal file
|
After Width: | Height: | Size: 125 B |
BIN
images/winehq_border_top_right.gif
Normal file
|
After Width: | Height: | Size: 105 B |
BIN
images/winehq_top_logo.gif
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
2
include/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
stderr
|
||||
|
||||
58
include/appbyvendor_inc.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
|
||||
function create_appbyvendorsearch_url($vName)
|
||||
{
|
||||
global $fields, $orderby, $join;
|
||||
|
||||
$orderby = "appId";
|
||||
$fields[] = "vendor.vendorId";
|
||||
$fields[] = "appFamily.appId";
|
||||
$fields[] = "appFamily.appName";
|
||||
$fields[] = "appFamily.webPage";
|
||||
$join = "appFamily.vendorId=vendor.vendorId";
|
||||
|
||||
$searchwhat = "vendor.vendorId";
|
||||
|
||||
$url = "stdquery.php";
|
||||
$url .= "?orderby=$orderby";
|
||||
$url .= "&searchfor=$vName";
|
||||
$url .= "&searchwhat=$searchwhat";
|
||||
$url .= "&join=$join";
|
||||
|
||||
foreach($fields as $aField)
|
||||
{
|
||||
$url .= "&fields[]=$aField";
|
||||
}
|
||||
|
||||
$url .= "&linesPerPage=$linesPerPage";
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
function output_appbyvendor_forminputs()
|
||||
{
|
||||
global $fields, $orderby, $join;
|
||||
|
||||
$orderby = "appId";
|
||||
$fields[] = "vendor.vendorId";
|
||||
$fields[] = "appFamily.appId";
|
||||
$fields[] = "appFamily.appName";
|
||||
$fields[] = "appFamily.webPage";
|
||||
$join = "appFamily.vendorId=vendor.vendorId";
|
||||
|
||||
|
||||
$searchwhat = "vendor.vendorName";
|
||||
|
||||
echo "<input TYPE=\"HIDDEN\" NAME=\"orderby\" VALUE=\"$orderby\">
|
||||
<input TYPE=\"HIDDEN\" NAME=\"searchwhat\" VALUE=\"$searchwhat\">";
|
||||
|
||||
foreach($fields as $aField)
|
||||
{
|
||||
echo "<input TYPE=\"HIDDEN\" NAME=\"fields[]\" VALUE=\"$aField\">";
|
||||
}
|
||||
|
||||
echo "<input TYPE=\"HIDDEN\" NAME=\"join\" VALUE=\"$join\">";
|
||||
}
|
||||
|
||||
?>
|
||||
35
include/appdb.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?
|
||||
|
||||
function log_category_visit($catId)
|
||||
{
|
||||
global $REMOTE_ADDR;
|
||||
|
||||
$result = mysql_query("SELECT * FROM catHitStats WHERE ip = '$REMOTE_ADDR' AND catId = $catId");
|
||||
if($result && mysql_num_rows($result) == 1)
|
||||
{
|
||||
$stats = mysql_fetch_object($result);
|
||||
mysql_query("UPDATE catHitStats SET count = count + 1 WHERE catHitId = $stats->catHitId");
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("INSERT INTO catHitStats VALUES(null, null, '$REMOTE_ADDR', $catId, 1)");
|
||||
}
|
||||
}
|
||||
|
||||
function log_application_visit($appId)
|
||||
{
|
||||
global $REMOTE_ADDR;
|
||||
|
||||
$result = mysql_query("SELECT * FROM appHitStats WHERE ip = '$REMOTE_ADDR' AND appId = $appId");
|
||||
if($result && mysql_num_rows($result) == 1)
|
||||
{
|
||||
$stats = mysql_fetch_object($result);
|
||||
mysql_query("UPDATE appHitStats SET count = count + 1 WHERE appHitId = $stats->appHitId");
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("INSERT INTO appHitStats VALUES(null, null, '$REMOTE_ADDR', $appId, 1)");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
78
include/application.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?
|
||||
|
||||
/* this class represents an application incl. all versions */
|
||||
class Application {
|
||||
|
||||
var $data;
|
||||
|
||||
function Application($id)
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM appFamily WHERE appId = $id");
|
||||
if(!$result)
|
||||
return; // Oops
|
||||
if(mysql_num_rows($result) != 1)
|
||||
return; // Not found
|
||||
|
||||
$this->data = mysql_fetch_object($result);
|
||||
}
|
||||
|
||||
|
||||
function getAppVersionList()
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$result = mysql_query("SELECT * FROM appVersion ".
|
||||
"WHERE appId = ". $this->data->appId . " " .
|
||||
"ORDER BY versionName");
|
||||
if(!$result)
|
||||
return $list;
|
||||
|
||||
while($row = mysql_fetch_object($result))
|
||||
{
|
||||
if($row->versionName == "NONAME")
|
||||
continue;
|
||||
$list[] = $row;
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
function getAppVersion($versionId)
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM appVersion ".
|
||||
"WHERE appId = ". $this->data->appId ." AND ".
|
||||
"versionId = $versionId");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return 0;
|
||||
|
||||
return mysql_fetch_object($result);
|
||||
}
|
||||
|
||||
function getVendor()
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM vendor ".
|
||||
"WHERE vendorId = ". $this->data->vendorId);
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return array("vendorName" => "Unknown");
|
||||
|
||||
$vendor = mysql_fetch_object($result);
|
||||
return $vendor;
|
||||
}
|
||||
|
||||
function getComments($versionId = 0)
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$result = mysql_query("SELECT * FROM appComments ".
|
||||
"WHERE appId = ". $this->data->appId . " AND " .
|
||||
"versionId = $versionId " .
|
||||
"ORDER BY time");
|
||||
if(!$result)
|
||||
return $list;
|
||||
|
||||
while($row = mysql_fetch_object($result))
|
||||
$list[] = $row;
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
61
include/appversion_inc.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
|
||||
$fields = "";
|
||||
$join = "";
|
||||
$orderby = "";
|
||||
$searchfor = "";
|
||||
$searchwhat = "";
|
||||
|
||||
|
||||
|
||||
function create_appversionsearch_url($vName)
|
||||
{
|
||||
global $fields, $orderby, $searchwhat, $join;
|
||||
|
||||
$orderby = "appId";
|
||||
$searchwhat = "appVersion.appId";
|
||||
$fields[] = "appVersion.appId";
|
||||
$fields[] = "appVersion.versionId";
|
||||
$fields[] = "appVersion.versionName";
|
||||
|
||||
|
||||
$url = "stdquery.php";
|
||||
$url .= "?orderby=$orderby";
|
||||
$url .= "&searchfor=$vName";
|
||||
$url .= "&searchwhat=$searchwhat";
|
||||
|
||||
foreach($fields as $aField)
|
||||
{
|
||||
$url .= "&fields[]=$aField";
|
||||
}
|
||||
|
||||
$url .= "&join=$join";
|
||||
$url .= "&linesPerPage=$linesPerPage";
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
function output_appversion_forminputs()
|
||||
{
|
||||
global $fields, $orderby, $searchwhat, $join;
|
||||
|
||||
$orderby = "appId";
|
||||
$searchwhat = "appVersion.versionId";
|
||||
$fields[] = "appVersion.appId";
|
||||
$fields[] = "appVersion.versionId";
|
||||
$fields[] = "appVersion.versionName";
|
||||
|
||||
|
||||
echo "<input TYPE=\"HIDDEN\" NAME=\"orderby\" VALUE=\"$orderby\">
|
||||
<input TYPE=\"HIDDEN\" NAME=\"searchwhat\" VALUE=\"$searchwhat\">";
|
||||
|
||||
foreach($fields as $aField)
|
||||
{
|
||||
echo "<input TYPE=\"HIDDEN\" NAME=\"fields[]\" VALUE=\"$aField\">";
|
||||
}
|
||||
|
||||
echo "<input TYPE=\"HIDDEN\" NAME=\"join\" VALUE=\"$join\">";
|
||||
}
|
||||
|
||||
?>
|
||||
55
include/banner.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Banner Ad Library
|
||||
* by Jeremy Newman <jnewman@codeweavers.com>
|
||||
* last modified: 2001.10.08
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Path for Banner Ads
|
||||
*/
|
||||
|
||||
function banner_display ()
|
||||
{
|
||||
// import banner paths from config
|
||||
global $apidb_root;
|
||||
$banner_path_468x60 = $apidb_root."banner/468x60/";
|
||||
$banner_path_xml = $apidb_root."banner/xml/";
|
||||
|
||||
// opening html
|
||||
$banner = "";
|
||||
$banner .= "\n\n".'<!-- START BANNER AD -->'."\n";
|
||||
$banner .= '<div align=center>'."\n";
|
||||
|
||||
// read dir and get list of banners
|
||||
$ads = array();
|
||||
$d = opendir($banner_path_468x60);
|
||||
while($entry = readdir($d))
|
||||
{
|
||||
if(!ereg("(.+)\\.gif$", $entry, $arr))
|
||||
continue; //"
|
||||
array_push($ads, $arr[1]);
|
||||
}
|
||||
closedir($d);
|
||||
|
||||
// randomly select a banner and display it
|
||||
$img = $ads[(rand(1,count($ads))-1)];
|
||||
$url = get_xml_tag($banner_path_xml.$img.'.xml','url');
|
||||
$alt = get_xml_tag($banner_path_xml.$img.'.xml','alt');
|
||||
|
||||
// da banner
|
||||
$banner .= '<a href="'.$url.'">';
|
||||
$banner .= '<img src="'.$banner_path_468x60.$img.'.gif" border=0 width=468 height=60 alt="'.$alt.'">';
|
||||
$banner .= '</a>'."\n";
|
||||
|
||||
// closing html
|
||||
$banner .= '</div>'."\n";
|
||||
$banner .= '<!-- END BANNER AD -->'."\n\n";
|
||||
|
||||
return $banner;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
208
include/category.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?
|
||||
|
||||
/* this class represents a category + its children */
|
||||
class Category {
|
||||
|
||||
var $name;
|
||||
var $id;
|
||||
var $subcat;
|
||||
|
||||
|
||||
/*
|
||||
* the special name "ROOT" is the top category
|
||||
*/
|
||||
function Category($id = 0)
|
||||
{
|
||||
$this->load($id);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* load the category data into this class
|
||||
*/
|
||||
function load($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
if($id == 0)
|
||||
{
|
||||
$this->name = "ROOT";
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM appCategory WHERE catId = $id");
|
||||
if(!$result) {
|
||||
// category not found!
|
||||
errorpage("Internal Error: Category not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
$ob = mysql_fetch_object($result);
|
||||
$this->name = $ob->catName;
|
||||
}
|
||||
|
||||
$result = mysql_query("SELECT catId, catName, catDescription FROM ".
|
||||
"appCategory WHERE catParent = $this->id " .
|
||||
"ORDER BY catName");
|
||||
if(mysql_num_rows($result) == 0)
|
||||
return; // no sub categories
|
||||
|
||||
$this->subcat = array();
|
||||
while($row = mysql_fetch_object($result))
|
||||
{
|
||||
// Ignore NONAME categories
|
||||
if($row->catName == "NONAME")
|
||||
continue;
|
||||
$this->subcat[$row->catId] = array($row->catName, $row->catDescription);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* resolve the category id by name
|
||||
*/
|
||||
function getCategoryId($name)
|
||||
{
|
||||
if($name == "ROOT")
|
||||
return 0;
|
||||
|
||||
$result = mysql_query("SELECT catId FROM appCategory WHERE ".
|
||||
"catName = '$name'");
|
||||
if(!$result)
|
||||
return -1;
|
||||
if(mysql_num_rows($result) != 1)
|
||||
return -1;
|
||||
$row = mysql_fetch_object($result);
|
||||
return $row->catId;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* returns the list of sub categories
|
||||
*
|
||||
* category list has the following format:
|
||||
*
|
||||
* { { catId => { catName, catDescription } }, ... }
|
||||
*/
|
||||
function getCategoryList()
|
||||
{
|
||||
return $this->subcat;
|
||||
}
|
||||
|
||||
/*
|
||||
* returns a path like:
|
||||
*
|
||||
* { ROOT, Games, Simulation }
|
||||
*/
|
||||
function getCategoryPath()
|
||||
{
|
||||
$path = array();
|
||||
$id = $this->id;
|
||||
while(1)
|
||||
{
|
||||
$result = mysql_query("SELECT catName, catId, catParent FROM appCategory WHERE catId = $id");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
break;
|
||||
$cat = mysql_fetch_object($result);
|
||||
$path[] = array($cat->catId, $cat->catName);
|
||||
$id = $cat->catParent;
|
||||
}
|
||||
$path[] = array(0, "ROOT");
|
||||
return array_reverse($path);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* returns a list of applications in the specified category
|
||||
*/
|
||||
function getAppList($id)
|
||||
{
|
||||
$result = mysql_query("SELECT appId, appName, description FROM ".
|
||||
"appFamily WHERE catId = $id ".
|
||||
"ORDER BY appName");
|
||||
if(!$result || mysql_num_rows($result) == 0)
|
||||
return array();
|
||||
|
||||
$list = array();
|
||||
while($row = mysql_fetch_object($result))
|
||||
{
|
||||
if($row->appName == "NONAME")
|
||||
continue;
|
||||
$list[$row->appId] = array($row->appName, $row->description);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* returns the number of apps in the specified category
|
||||
*/
|
||||
function getAppCount($id, $recurse = 1)
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
$result = mysql_query("SELECT appId FROM appFamily WHERE catId = $id");
|
||||
if($result)
|
||||
$total += mysql_num_rows($result);
|
||||
|
||||
if($recurse)
|
||||
{
|
||||
$result = mysql_query("SELECT catId FROM appCategory WHERE catParent = $id");
|
||||
if($result)
|
||||
{
|
||||
while($ob = mysql_fetch_object($result))
|
||||
$total += $this->getAppCount($ob->catId, 1);
|
||||
}
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
};
|
||||
|
||||
function appIdToName($appId)
|
||||
{
|
||||
$result = mysql_query("SELECT appName FROM appFamily WHERE appId = $appId");
|
||||
if(!$result || !mysql_num_rows($result))
|
||||
return "<unknown>"; // shouldn't normally happen
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->appName;
|
||||
}
|
||||
|
||||
function versionIdToName($versionId)
|
||||
{
|
||||
$result = mysql_query("SELECT versionName FROM appVersion WHERE versionId = $versionId");
|
||||
if(!$result || !mysql_num_rows($result))
|
||||
return "<unknown>"; // shouldn't normally happen
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->versionName;
|
||||
}
|
||||
|
||||
// create the Category: line at the top of appdb pages
|
||||
function make_cat_path($path)
|
||||
{
|
||||
global $appId;
|
||||
global $versionId;
|
||||
|
||||
$str = "";
|
||||
$catCount = 0;
|
||||
while(list($idx, list($id, $name)) = each($path))
|
||||
{
|
||||
if($name == "ROOT")
|
||||
$catname = "Main";
|
||||
else
|
||||
$catname = $name;
|
||||
|
||||
if ($catCount > 0) { $str .= " > "; }
|
||||
$str .= html_ahref($catname,"appbrowse.php?catId=$id");
|
||||
$catCount++;
|
||||
}
|
||||
|
||||
if($appId)
|
||||
$str .= " > ".html_ahref(appIdToName($appId),"appview.php?appId=$appId");
|
||||
|
||||
if($versionId)
|
||||
$str .= " > ".html_ahref(versionIdToName($versionId),"appview.php?appId=$appId&versionId=$versionId");
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
?>
|
||||
251
include/comments.php
Normal file
@@ -0,0 +1,251 @@
|
||||
<?
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* display a single comment (in $ob)
|
||||
*
|
||||
*/
|
||||
function view_app_comment($ob)
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
if ($ob->email)
|
||||
{
|
||||
$mailto = '<a href="mailto:' . $ob->email . '">' . $ob->username . '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mailto = $ob->username;
|
||||
}
|
||||
|
||||
echo html_frame_start('','98%');
|
||||
echo '<table width="100%" border=0 cellpadding=2 cellspacing=1">',"\n";
|
||||
|
||||
$ob->subject = stripslashes($ob->subject);
|
||||
$ob->body = stripslashes($ob->body);
|
||||
|
||||
// message header
|
||||
echo "<tr bgcolor=#E0E0E0><td>\n";
|
||||
echo " <b>$ob->subject</b><br>\n";
|
||||
echo " by $mailto on $ob->time<br>\n";
|
||||
echo "</td></tr><tr><td>\n";
|
||||
|
||||
// body
|
||||
echo htmlify_urls($ob->body), "<br><br>\n";
|
||||
|
||||
// only add RE: once
|
||||
if(eregi("RE:", $ob->subject))
|
||||
$subject = $ob->subject;
|
||||
else
|
||||
$subject = "RE: $ob->subject";
|
||||
|
||||
// reply post buttons
|
||||
echo " [<a href='addcomment.php?appId=$ob->appId&versionId=$ob->versionId'><small>post new</small></a>] \n";
|
||||
echo " [<a href='addcomment.php?appId=$ob->appId&versionId=$ob->versionId&subject=".
|
||||
urlencode("$subject")."&thread=$ob->commentId'><small>reply to this</small></a>] \n";
|
||||
|
||||
echo "</td></tr></table>\n";
|
||||
echo html_frame_end();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* grab comments for appId / versionId
|
||||
* if parentId is not -1 only comments for that thread are returned
|
||||
*/
|
||||
function grab_comments($appId, $versionId, $parentId = -1)
|
||||
{
|
||||
$extra = "";
|
||||
if($parentId != -1)
|
||||
$extra = "AND parentId = $parentId ";
|
||||
|
||||
$qstring = "SELECT from_unixtime(unix_timestamp(time), \"%W %M %D %Y, %k:%i\") as time, ".
|
||||
"commentId, parentId, appId, versionId, username, email, subject, body ".
|
||||
"FROM appComments, user_list WHERE appComments.userId = user_list.userid ".
|
||||
$extra .
|
||||
"AND appId = $appId AND versionId = $versionId ".
|
||||
"ORDER BY appComments.time ASC";
|
||||
|
||||
$result = mysql_query($qstring);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* grab comments for appId / versionId
|
||||
* if parentId is not -1 only comments for that thread are returned
|
||||
*/
|
||||
function count_comments($appId, $versionId)
|
||||
{
|
||||
|
||||
$qstring = "SELECT count(commentId) as hits FROM appComments WHERE appId = $appId AND versionId = $versionId";
|
||||
$result = mysql_query($qstring);
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->hits;
|
||||
}
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* display nested comments
|
||||
*
|
||||
* handle is a db result set
|
||||
*
|
||||
*/
|
||||
function do_display_comments_nested($handle)
|
||||
{
|
||||
while($ob = mysql_fetch_object($handle))
|
||||
{
|
||||
view_app_comment($ob);
|
||||
$result = grab_comments($ob->appId, $ob->versionId, $ob->commentId);
|
||||
if($result && mysql_num_rows($result))
|
||||
{
|
||||
echo "<blockquote>\n";
|
||||
do_display_comments_nested($result);
|
||||
echo "</blockquote>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function display_comments_nested($appId, $versionId, $threadId)
|
||||
{
|
||||
$result = grab_comments($appId, $versionId, $threadId);
|
||||
|
||||
do_display_comments_nested($result);
|
||||
}
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* display threaded comments
|
||||
*
|
||||
* handle is a db result set
|
||||
*
|
||||
*/
|
||||
function do_display_comments_threaded($handle, $is_main)
|
||||
{
|
||||
if(!$is_main)
|
||||
echo "<ul>\n";
|
||||
|
||||
while($ob = mysql_fetch_object($handle))
|
||||
{
|
||||
if($is_main)
|
||||
view_app_comment($ob);
|
||||
else
|
||||
echo "<li> <a href='commentview.php?appId=$ob->appId&versionId=$ob->versionId&threadId=$ob->commentId'> ".
|
||||
" $ob->subject </a> by $ob->username on $ob->time </li>\n";
|
||||
$result = grab_comments($ob->appId, $ob->versionId, $ob->commentId);
|
||||
if($result && mysql_num_rows($result))
|
||||
{
|
||||
echo "<blockquote>\n";
|
||||
do_display_comments_threaded($result, 0);
|
||||
echo "</blockquote>\n";
|
||||
}
|
||||
}
|
||||
if(!$is_main)
|
||||
echo "</ul>\n";
|
||||
}
|
||||
|
||||
function display_comments_threaded($appId, $versionId, $threadId = 0)
|
||||
{
|
||||
$result = grab_comments($appId, $versionId, $threadId);
|
||||
|
||||
do_display_comments_threaded($result, 1);
|
||||
}
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* display flat comments
|
||||
*
|
||||
*/
|
||||
function display_comments_flat($appId, $versionId)
|
||||
{
|
||||
$result = grab_comments($appId, $versionId);
|
||||
|
||||
while($ob = mysql_fetch_object($result))
|
||||
{
|
||||
view_app_comment($ob);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function view_app_comments($appId, $versionId, $threadId = 0)
|
||||
{
|
||||
opendb();
|
||||
|
||||
global $current;
|
||||
global $cmode;
|
||||
|
||||
|
||||
$result = mysql_query("SELECT commentId FROM appComments WHERE appId = $appId AND versionId = $versionId");
|
||||
$messageCount = mysql_num_rows($result);
|
||||
|
||||
|
||||
//start comment format table
|
||||
echo html_frame_start("","98%",'',0);
|
||||
echo '<table width="100%" border=0 cellpadding=1 cellspacing=0">',"\n";
|
||||
|
||||
echo '<tr><td bgcolor=#C0C0C0 align=center><table border=0 cellpadding=0 cellspacing=0><tr bgcolor=#C0C0C0>',"\n";
|
||||
|
||||
// message display mode changer
|
||||
if (loggedin())
|
||||
{
|
||||
//FIXME we need to change this so not logged in users can change current view as well
|
||||
if ($cmode)
|
||||
$current->setpref("comments:mode", $cmode);
|
||||
|
||||
$sel[$current->getpref("comments:mode")] = 'selected';
|
||||
echo '<td><form method=get name=smode action="appview.php">',"\n";
|
||||
echo "<b>Application Comments</b> $messageCount total comments ";
|
||||
echo '<b>Mode</b> <select name="cmode" onchange="document.smode.submit();">',"\n";
|
||||
echo ' <option value=flat '.$sel['flat'].'>Flat</option>',"\n";
|
||||
echo ' <option value=threaded '.$sel['threaded'].'>Threaded</option>',"\n";
|
||||
echo ' <option value=nested '.$sel['nested'].'>Nested</option>',"\n";
|
||||
echo ' <option value=off '.$sel['off'].'>No Comments</option>',"\n";
|
||||
echo '</select><input type=hidden name="appId" value="'.$appId.'">',"\n";
|
||||
echo '<input type=hidden name="versionId" value="'.$versionId.'"></form></td>',"\n";
|
||||
}
|
||||
|
||||
// blank space
|
||||
echo '<td> </td>',"\n";
|
||||
|
||||
// post new message button
|
||||
echo '<td><form method=get name=message action="addcomment.php"><input type=submit value=" post new comment " class=button> ',"\n";
|
||||
echo '<input type=hidden name="appId" value="'.$appId.'"><input type=hidden name="versionId" value="'.$versionId.'"></form></td>',"\n";
|
||||
|
||||
//end comment format table
|
||||
echo '</tr></table></td></tr>',"\n";
|
||||
echo '</table>',"\n";
|
||||
echo html_frame_end("The following comments are owned by whoever posted them. CodeWeavers is not responsible for what they say.");
|
||||
|
||||
//start comments
|
||||
echo '<table width="100%" border=0 cellpadding=2 cellspacing=1"><tr><td>',"\n";
|
||||
|
||||
//hide or display depending on pref
|
||||
if (loggedin())
|
||||
$mode = $current->getpref("comments:mode");
|
||||
else
|
||||
$mode = "flat";
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case "flat":
|
||||
display_comments_flat($appId, $versionId);
|
||||
break;
|
||||
case "nested":
|
||||
display_comments_nested($appId, $versionId, $threadId);
|
||||
break;
|
||||
case "threaded":
|
||||
display_comments_threaded($appId, $versionId, $threadId);
|
||||
break;
|
||||
}
|
||||
|
||||
echo '</td></tr></table>',"\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
27
include/config.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?
|
||||
/* config file for apidb */
|
||||
|
||||
|
||||
/*
|
||||
* global params
|
||||
*/
|
||||
$apidb_debug = 0; //turns debugging on/off
|
||||
|
||||
/*
|
||||
* api database info
|
||||
*/
|
||||
$apidb_dbuser = "wineowner";
|
||||
$apidb_dbpass = "password";
|
||||
$apidb_dbhost = "localhost";
|
||||
$apidb_db = "winehq_appdb";
|
||||
|
||||
|
||||
/*
|
||||
* user database info
|
||||
*/
|
||||
$userdb_dbuser = "wineowner";
|
||||
$userdb_dbpass = "password";
|
||||
$userdb_dbhost = "localhost";
|
||||
$userdb_db = "winehq_appdb";
|
||||
|
||||
?>
|
||||
35
include/db.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?
|
||||
|
||||
|
||||
$public_link = null;
|
||||
$private_link = null;
|
||||
|
||||
|
||||
function apidb_query($query)
|
||||
{
|
||||
global $public_link;
|
||||
|
||||
if(!$public_link)
|
||||
{
|
||||
$public_link = mysql_pconnect($db_public_host, $db_public_user, $db_public_pass);
|
||||
mysql_select_db($db_public_db);
|
||||
}
|
||||
|
||||
return mysql_query($query, $public_link);
|
||||
}
|
||||
|
||||
|
||||
function userdb_query($query)
|
||||
{
|
||||
global $private_link;
|
||||
|
||||
if(!$private_link)
|
||||
{
|
||||
$private_link = mysql_pconnect($db_private_host, $db_private_user, $db_private_pass);
|
||||
mysql_select_db($db_private_db);
|
||||
}
|
||||
|
||||
return mysql_query($query, $private_link);
|
||||
}
|
||||
|
||||
?>
|
||||
8
include/footer.php
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
<!-- start of footer.inc -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!-- end of footer.inc -->
|
||||
|
||||
41
include/form_edit.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Edit Account Form
|
||||
*
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<!-- start of edit account form -->
|
||||
|
||||
<tr>
|
||||
<td> User Name </td>
|
||||
<td> <b> <?=$ext_username?> </b> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Password </td>
|
||||
<td> <input type="password" name="ext_password"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Password (again) </td>
|
||||
<td> <input type="password" name="ext_password2"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Real Name </td>
|
||||
<td> <input type="text" name="ext_realname" value="<?=$ext_realname?>"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Email Address </td>
|
||||
<td> <input type="text" name="ext_email" value="<?=$ext_email?>"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2> </td>
|
||||
</tr>
|
||||
|
||||
<!-- end of edit account form -->
|
||||
|
||||
<?
|
||||
|
||||
|
||||
?>
|
||||
61
include/form_login.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Login Form
|
||||
*
|
||||
*/
|
||||
|
||||
echo '<form method="post" name="flogin" action="account.php">',"\n";
|
||||
echo html_frame_start("Login to Application DB","400","",0)
|
||||
|
||||
?>
|
||||
|
||||
<!-- start of login form -->
|
||||
|
||||
<script language="javascript">
|
||||
<!--//
|
||||
function cmd_send_passwd() {
|
||||
document.flogin.cmd.value = "send_passwd";
|
||||
document.flogin.submit();
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<table border="0" width="100%" cellspacing=0 cellpadding="10">
|
||||
<tr>
|
||||
<td class=color1> User Name </td>
|
||||
<td class=color0> <input type="text" name="ext_username" value='<?=$ext_username?>'> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=color1> Password </td>
|
||||
<td class=color0> <input type="password" name="ext_password"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 align=center class=color3>
|
||||
<input type="submit" name="login" value=" Login " class=button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- end of login form -->
|
||||
|
||||
<?
|
||||
|
||||
echo html_frame_end(" ");
|
||||
echo '<input type="hidden" name="cmd" value="do_login">',"\n";
|
||||
echo '<input type="hidden" name="ext_referer" value="'.$HTTP_REFERER.'">',"\n";
|
||||
echo '</form>',"\n";
|
||||
|
||||
?>
|
||||
|
||||
<p align=center>Don't have an account yet?<br>
|
||||
[<a href="account.php?cmd=new" onMouseOver="document.status='';return true;">Create a New Account</a>]</p>
|
||||
|
||||
<p align=center>Lost your password?<br>
|
||||
[<a href="javascript:cmd_send_passwd();" onMouseOver="document.status='';return true;">Email a New Password</a>]</p>
|
||||
|
||||
<?
|
||||
|
||||
echo p(),p(),p();
|
||||
|
||||
?>
|
||||
53
include/form_new.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* New Account Form
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
echo '<form method="post" action="account.php">',"\n";
|
||||
echo html_frame_start("Create New Application DB Account","400","",0)
|
||||
|
||||
?>
|
||||
|
||||
<!-- start of new account form -->
|
||||
<table border=0 width="100%" cellspacing=0 cellpadding=20>
|
||||
<tr>
|
||||
<td class=color1> User Name </td>
|
||||
<td class=color0> <input type="text" name="ext_username" value='<?=$ext_username?>'> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=color1> Password </td>
|
||||
<td class=color0> <input type="password" name="ext_password"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=color1> Password (again) </td>
|
||||
<td class=color0> <input type="password" name="ext_password2"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=color1> Real Name </td>
|
||||
<td class=color0> <input type="text" name="ext_realname" value='<?=$ext_realname?>'> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=color1> Email Address </td>
|
||||
<td class=color0> <input type="text" name="ext_email" value='<?=$ext_email?>'> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=2 align=center class=color3>
|
||||
<input type="submit" name="create" value=" Create Account " class=button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- end of new account form -->
|
||||
|
||||
<?
|
||||
|
||||
echo html_frame_end(" ");
|
||||
echo '<input type="hidden" name="cmd" value="do_new">',"\n";
|
||||
echo '</form>',"\n";
|
||||
|
||||
echo p(),p(),p();
|
||||
|
||||
?>
|
||||
51
include/header.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Application Database - Header
|
||||
*
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
<!-- start of header.inc -->
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Wine Application DB <?=$title?></title>
|
||||
<meta HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">
|
||||
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" href="<?=$apidb_root?>apidb.css" type="text/css">
|
||||
<script language="JavaScript" src="<?=$apidb_root?>scripts.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#E2E2E2" text="#000000">
|
||||
|
||||
<table width="100%" border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width="100%"><a href="<?=$apidb_root?>"><img src="<?=$apidb_root?>images/winehq_top_logo.gif" width=300 height=99 border=0 alt="Wine HQ"></a></td>
|
||||
<td>
|
||||
<img src="<?=$apidb_root?>images/blank.gif" border=0 width=10 height=1 alt="">
|
||||
</td>
|
||||
<td width="100%" align="center" valign="middle">
|
||||
<!-- BANNER AD -->
|
||||
<table border=0 cellpadding=1 cellspacing=0>
|
||||
<tr><td valign="middle" align="center" class="black"
|
||||
><?=$banner_ad?></td
|
||||
></tr>
|
||||
</table>
|
||||
<!-- END BANNER AD -->
|
||||
</td>
|
||||
<td>
|
||||
<img src="<?=$apidb_root?>images/blank.gif" border=0 width=10 height=1 alt="">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- end of header.inc -->
|
||||
351
include/html.php
Normal file
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
|
||||
$_indent_level = 0;
|
||||
|
||||
function do_indent($str, $v = 0)
|
||||
{
|
||||
global $_indent_level;
|
||||
|
||||
if($v < 0)
|
||||
$_indent_level += $v;
|
||||
|
||||
if($_indent_level > 0)
|
||||
$str = str_repeat(" ", $_indent_level) . $str;
|
||||
|
||||
if($v > 0)
|
||||
$_indent_level += $v;
|
||||
|
||||
return $str . "\n";
|
||||
}
|
||||
|
||||
function do_html_tr($t, $arr, $class, $extra)
|
||||
{
|
||||
if(strlen($class))
|
||||
$class = " class=\"$class\"";
|
||||
|
||||
$str = do_indent("<tr$class>", 1);
|
||||
for($i = 0; $i < sizeof($arr); $i++)
|
||||
{
|
||||
if(is_array($arr[$i]))
|
||||
{
|
||||
$val = $arr[$i][0];
|
||||
$extra = " ".$arr[$i][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$val = $arr[$i];
|
||||
$extra = "";
|
||||
}
|
||||
|
||||
if (! $val)
|
||||
{
|
||||
$val = " ";
|
||||
}
|
||||
|
||||
if(stristr($val, "<$t"))
|
||||
{
|
||||
$str .= do_indent($val);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str .= do_indent("<$t$class$extra> ".trim($val)." </$t>", 0);
|
||||
}
|
||||
}
|
||||
$str .= do_indent("</tr>", -1);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// HTML TH
|
||||
function html_th($arr, $class = "", $extra = "")
|
||||
{
|
||||
return do_html_tr("th", $arr, $class, $extra);
|
||||
}
|
||||
|
||||
// HTML TR
|
||||
function html_tr($arr, $class = "", $extra = "")
|
||||
{
|
||||
return do_html_tr("td", $arr, $class, $extra);
|
||||
}
|
||||
|
||||
// HTML TABLE
|
||||
function html_table_begin($extra = "")
|
||||
{
|
||||
return do_indent("<table $extra>", 1);
|
||||
}
|
||||
|
||||
function html_table_end()
|
||||
{
|
||||
return do_indent("</table>", -1);
|
||||
}
|
||||
|
||||
|
||||
// HTML HTML
|
||||
function html_begin()
|
||||
{
|
||||
return do_indent("<html>", 1);
|
||||
}
|
||||
|
||||
function html_end()
|
||||
{
|
||||
return do_indent("</html>", -1);
|
||||
}
|
||||
|
||||
|
||||
// HTML HEAD
|
||||
function html_head($title, $stylesheet = 0)
|
||||
{
|
||||
$str = do_indent("<head>", 1);
|
||||
$str .= do_indent("<title> $title </title>", 0);
|
||||
if($stylesheet)
|
||||
$str .= do_indent("<link rel=\"stylesheet\" ".
|
||||
"href=\"$stylesheet\" type=\"text/css\">", 0);
|
||||
$str .= do_indent("</head>", -1);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
// HTML BODY
|
||||
function html_body_begin()
|
||||
{
|
||||
return do_indent("<body>", 1);
|
||||
}
|
||||
|
||||
function html_body_end()
|
||||
{
|
||||
return do_indent("</body>", -1);
|
||||
}
|
||||
|
||||
|
||||
// HTML BR
|
||||
function html_br($count = 1)
|
||||
{
|
||||
return do_indent(str_repeat("<br>", $count));
|
||||
}
|
||||
|
||||
// HTML A HREF
|
||||
function html_ahref($label, $url, $extra = "")
|
||||
{
|
||||
$label = stripslashes($label);
|
||||
if (!$label and $url)
|
||||
{
|
||||
return do_indent(" <a href=\"$url\" $extra>$url</a> ");
|
||||
}
|
||||
else if (!$label)
|
||||
{
|
||||
return do_indent(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
return do_indent(" <a href=\"$url\" $extra>$label</a> ");
|
||||
}
|
||||
}
|
||||
|
||||
// HTML echo a string
|
||||
function html_echo($str)
|
||||
{
|
||||
return do_indent($str);
|
||||
}
|
||||
|
||||
// HTML B (bold)
|
||||
function html_b($str)
|
||||
{
|
||||
return do_indent("<b>$str</b>");
|
||||
}
|
||||
|
||||
// HTML SMALL (small text)
|
||||
function html_small($str)
|
||||
{
|
||||
return do_indent("<small>$str</small>");
|
||||
}
|
||||
|
||||
// HTML P
|
||||
function html_p()
|
||||
{
|
||||
return do_indent("<p>");
|
||||
}
|
||||
|
||||
function html_line($thickness = 1, $colspan = 1, $color = "#000000")
|
||||
{
|
||||
return do_indent("<tr><td bgcolor=\"$color\" colspan=$colspan> ".
|
||||
"<img src=\"/images/blank.gif\" height=$thickness ".
|
||||
"vspace=0> </td></tr>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
function html_imagebutton($text, $url, $extra = "")
|
||||
{
|
||||
static $i = 1;
|
||||
|
||||
$i++;
|
||||
$img1 = apidb_url("util/button.php?text=".urlencode($text)."&pressed=0");
|
||||
$img2 = apidb_url("util/button.php?text=".urlencode($text)."&pressed=1");
|
||||
|
||||
$java = "onMouseDown = 'document.img$i.src = \"$img2\"; return true;' ";
|
||||
$java .= "onMouseUp = 'document.img$i.src = \"$img1\"; return true;' ";
|
||||
|
||||
return "\n<a href='$url' $extra $java>\n <img src='$img1' name='img$i' alt='$text' border=0> </a>\n";
|
||||
}
|
||||
|
||||
|
||||
function html_frame_start($title = "", $width = "", $extra = "", $innerPad = 5)
|
||||
{
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
if ($width) { $width = 'width="'.$width.'"'; }
|
||||
|
||||
$str .= '<table '.$width.' border=0 cellpadding=0 cellspacing=0 align=center>'."\n";
|
||||
|
||||
if ($title)
|
||||
{
|
||||
$str .= '
|
||||
<tr><td colspan=3><table width="100%" border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td>
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="topMenu">
|
||||
<tr>
|
||||
<td valign="top" align="left"><img src="'.$apidb_root.'images/winehq_border_top_left.gif" border="0" alt=""></td>
|
||||
<td rowspan="3" valign="middle" align="left"><img src="'.$apidb_root.'images/winehq_border_dot_left.gif" border="0" alt=""></td>
|
||||
<td width="100%" rowspan="3" align="center"><span class="menuTitle">'.$title.'</span></td>
|
||||
<td rowspan="3" valign="middle" align="right"><img src="'.$apidb_root.'images/winehq_border_dot_right.gif" border="0" alt=""></td>
|
||||
<td valign="top" align="left"><img src="'.$apidb_root.'images/winehq_border_top_right.gif" border="0" alt=""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="'.$apidb_root.'images/blank.gif" width="1" height="1" border="0" alt=""></td>
|
||||
<td><img src="'.$apidb_root.'images/blank.gif" width="1" height="1" border="0" alt=""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="bottom" align="right"><img src="'.$apidb_root.'images/winehq_border_bottom_left.gif" border="0" alt=""></td>
|
||||
<td valign="bottom" align="right"><img src="'.$apidb_root.'images/winehq_border_bottom_right.gif" border="0" alt=""></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table></td></tr>
|
||||
';
|
||||
}
|
||||
|
||||
$str .= '
|
||||
<tr>
|
||||
<td><img src="'.$apidb_root.'images/blank.gif" border=0 width=5 height=1 alt="-"></td>
|
||||
<td width="100%"><table width="100%" border=0 cellpadding=0 cellspacing=0>
|
||||
<tr><td class=topMenu>
|
||||
<table width="100%" border=0 cellpadding="'.$innerPad.'" cellspacing="1" '.$extra.'><tr><td class=white>
|
||||
';
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function html_frame_end($text = "")
|
||||
{
|
||||
global $apidb_root;
|
||||
|
||||
$str = '
|
||||
</td></tr></table></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
<td><img src="'.$apidb_root.'images/blank.gif" border=0 width=5 height=1 alt="-"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
';
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
function html_select($name, $values, $default = null, $descs = null)
|
||||
{
|
||||
$str = "<select name='$name'>\n";
|
||||
while(list($idx, $value) = each($values))
|
||||
{
|
||||
$desc = $value;
|
||||
if($descs)
|
||||
$desc = $descs[$idx];
|
||||
|
||||
if($value == $default)
|
||||
$str .= " <option selected value='$value'>$desc\n";
|
||||
else
|
||||
$str .= " <option value='$value'>$desc\n";
|
||||
}
|
||||
$str .= "</select>\n";
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function html_back_link($howmany = 1, $url = "")
|
||||
{
|
||||
if (!$url)
|
||||
{
|
||||
$url = 'javascript:history.back('.$howmany.');';
|
||||
}
|
||||
return '<p> <a href="'.$url.'"><< Back</a></p>'."\n";
|
||||
}
|
||||
|
||||
|
||||
function p()
|
||||
{
|
||||
return "\n<p> </p>\n";
|
||||
}
|
||||
|
||||
function add_br($text = "")
|
||||
{
|
||||
$text = ereg_replace("\n","<br>\n",$text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function make_dll_option_list($varname, $dllid = -1)
|
||||
{
|
||||
$db = new ApiDB();
|
||||
|
||||
echo "<select name='$varname'>\n";
|
||||
//echo "<option value='ALL'>ALL\n";
|
||||
$list = $db->get_dll_names();
|
||||
while(list($name, $id) = each($list))
|
||||
{
|
||||
if($dllid == $id)
|
||||
echo "<option value=$id selected>$name ($id)\n";
|
||||
else
|
||||
echo "<option value=$id>$name ($id)\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
|
||||
function make_inx_option_list($varname, $inx = null)
|
||||
{
|
||||
$list = array("yes", "no", "stub", "unknown");
|
||||
echo "<select name='$varname'>\n";
|
||||
while(list($idx, $value) = each($list))
|
||||
{
|
||||
if($value == $inx)
|
||||
echo "<option value=$value selected>$value\n";
|
||||
else
|
||||
echo "<option value=$value>$value\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
function make_quality_option_list($varname, $quality)
|
||||
{
|
||||
$list = array(-1, 1, 2, 3, 4, 5);
|
||||
echo "<select name='$varname'>\n";
|
||||
while(list($idx, $value) = each($list))
|
||||
{
|
||||
if($value == -1)
|
||||
$label = "unknown";
|
||||
else
|
||||
$label = $value;
|
||||
|
||||
if($quality == $value)
|
||||
echo "<option value=$value selected>$label\n";
|
||||
else
|
||||
echo "<option value=$value>$label\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
241
include/incl.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Main Include Library for Application Database
|
||||
*
|
||||
*/
|
||||
|
||||
//set global path
|
||||
global $apidb_root;
|
||||
$apidb_root = BASE;
|
||||
|
||||
//get modules
|
||||
require(BASE."include/"."config.php");
|
||||
require(BASE."include/"."util.php");
|
||||
require(BASE."include/"."user.php");
|
||||
require(BASE."include/"."session.php");
|
||||
require(BASE."include/"."menu.php");
|
||||
require(BASE."include/"."html.php");
|
||||
|
||||
// create arrays
|
||||
$sidebar_func_list = array();
|
||||
$help_list = array();
|
||||
|
||||
// Start session ...
|
||||
apidb_session_start();
|
||||
|
||||
|
||||
function apidb_help_add($desc, $id)
|
||||
{
|
||||
global $help_list;
|
||||
$help_list[] = array($desc, $id);
|
||||
}
|
||||
|
||||
|
||||
//return url with docroot prepended
|
||||
//
|
||||
function apidb_url($path)
|
||||
{
|
||||
global $apidb_root;
|
||||
return $apidb_root.$path;
|
||||
}
|
||||
|
||||
//return FULL url with docroot prepended
|
||||
function apidb_fullurl($path = "")
|
||||
{
|
||||
global $apidb_root;
|
||||
return $apidb_root.$path;
|
||||
}
|
||||
|
||||
function apidb_fullpath($path)
|
||||
{
|
||||
global $apidb_root;
|
||||
global $DOCUMENT_ROOT;
|
||||
return $DOCUMENT_ROOT.$apidb_root.$path;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* output the common apidb header
|
||||
*/
|
||||
function apidb_header($title = 0)
|
||||
{
|
||||
global $apidb_root, $current;
|
||||
|
||||
$username = $current->username;
|
||||
|
||||
// Set Page Title
|
||||
$page_title = $title;
|
||||
if ($title)
|
||||
$title = " - $title";
|
||||
|
||||
// banner ad
|
||||
include(BASE."include/"."banner.php");
|
||||
$banner_ad = banner_display();
|
||||
|
||||
// Display Header
|
||||
include(BASE."include/"."header.php");
|
||||
|
||||
// Display Sidebar
|
||||
echo "<table width='100%' border=0 cellspacing=0 cellpadding=0>\n";
|
||||
echo "<tr valign='top'>\n";
|
||||
echo "<td width=150>\n";
|
||||
apidb_sidebar();
|
||||
echo "</td>\n";
|
||||
echo "<td width='100%'>\n";
|
||||
|
||||
echo html_frame_start($page_title, '98%');
|
||||
|
||||
// Display Status Messages
|
||||
dumpmsgbuffer();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* output the common apidb footer
|
||||
*/
|
||||
function apidb_footer()
|
||||
{
|
||||
global $apidb_root;
|
||||
global $current;
|
||||
|
||||
echo html_frame_end();
|
||||
|
||||
//Close Sidebar and Content Well
|
||||
echo "<br></td>\n";
|
||||
|
||||
// Display Footer
|
||||
if(!$header_disabled)
|
||||
include(BASE."include/"."footer.php");
|
||||
}
|
||||
|
||||
/*
|
||||
* output the sidebar, calls all functions registered with apidb_sidebar_add
|
||||
*/
|
||||
function apidb_sidebar()
|
||||
{
|
||||
global $apidb_root;
|
||||
global $sidebar_func_list;
|
||||
|
||||
//TURN on GLOBAL ADMIN MENU
|
||||
if (havepriv("admin"))
|
||||
{
|
||||
include(BASE."include/"."sidebar_admin.php");
|
||||
apidb_sidebar_add("global_admin_menu");
|
||||
}
|
||||
|
||||
// Login Menu
|
||||
include(BASE."include/"."sidebar_login.php");
|
||||
apidb_sidebar_add("global_sidebar_login");
|
||||
|
||||
// Main Menu
|
||||
include(BASE."include/"."sidebar.php");
|
||||
apidb_sidebar_add("global_sidebar_menu");
|
||||
|
||||
//LOOP and display menus
|
||||
for($i = 0; $i < sizeof($sidebar_func_list); $i++)
|
||||
{
|
||||
$func = $sidebar_func_list[$i];
|
||||
$func();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* register a sidebar menu function
|
||||
* the supplied function is called when the sidebar is built
|
||||
*/
|
||||
function apidb_sidebar_add($funcname)
|
||||
{
|
||||
global $sidebar_func_list;
|
||||
array_unshift($sidebar_func_list, $funcname);
|
||||
}
|
||||
|
||||
|
||||
function apidb_image($name)
|
||||
{
|
||||
global $apidb_root;
|
||||
return $apidb_root."images/$name";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* display an error page
|
||||
*/
|
||||
function errorpage($text = null, $message = null)
|
||||
{
|
||||
if (!$text) {
|
||||
$text = "You must be logged in to perform that operation.";
|
||||
}
|
||||
apidb_header("Oops");
|
||||
echo "<div align=center><font color=red><b>$text</b></font></div>\n";
|
||||
echo "<p>$message</p>\n";
|
||||
apidb_footer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* redirect to $url
|
||||
*/
|
||||
function redirect($url)
|
||||
{
|
||||
header("Location: ".$url);
|
||||
}
|
||||
|
||||
/*
|
||||
* redirect back to referer, or else to the main page
|
||||
*/
|
||||
function redirectref($url = null)
|
||||
{
|
||||
global $HTTP_REFERER;
|
||||
|
||||
if(!$url)
|
||||
$url = $HTTP_REFERER;
|
||||
if(!$url)
|
||||
$url = apidb_fullurl();
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* msgs will be displayed on the Next page view of the same user
|
||||
*/
|
||||
function addmsg($text, $color = "black")
|
||||
{
|
||||
global $current;
|
||||
global $PHPSESSID;
|
||||
|
||||
if($color)
|
||||
$text = "<font color='$color'> $text </font>\n";
|
||||
|
||||
$text = str_replace("'", "\\'", $text);
|
||||
mysql_query("INSERT INTO sessionMessages VALUES (null, null, '$PHPSESSID', '$text')");
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* output msg_buffer and clear it.
|
||||
*/
|
||||
function dumpmsgbuffer()
|
||||
{
|
||||
global $current;
|
||||
global $PHPSESSID;
|
||||
|
||||
$result = mysql_query("SELECT * FROM sessionMessages WHERE sessionId = '$PHPSESSID'");
|
||||
if(!$result)
|
||||
return;
|
||||
|
||||
while($r = mysql_fetch_object($result))
|
||||
{
|
||||
echo html_frame_start("","300","",5);
|
||||
echo "<div align=center> $r->message </div>";
|
||||
echo html_frame_end(" ");
|
||||
echo "<br>\n";
|
||||
}
|
||||
|
||||
mysql_query("DELETE FROM sessionMessages WHERE sessionId = '$PHPSESSID'");
|
||||
}
|
||||
|
||||
?>
|
||||
77
include/menu.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?
|
||||
class htmlmenu {
|
||||
|
||||
function htmlmenu($name, $form = null)
|
||||
{
|
||||
global $apidb_root;
|
||||
|
||||
if ($form)
|
||||
echo "<form action='$form' method=get>\n";
|
||||
|
||||
echo '
|
||||
<div align=left>
|
||||
<table width="150" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="topMenu">
|
||||
<tr>
|
||||
<td width="100%" rowspan="3" align="left"><span class="menuTitle"> '.$name.'</span></td>
|
||||
<td rowspan="3" valign="middle" align="right"><img src="'.$apidb_root.'images/winehq_border_dot_right.gif" border="0" alt=""></td>
|
||||
<td valign="top" align="left"><img src="'.$apidb_root.'images/winehq_border_top_right.gif" border="0" alt=""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="'.$apidb_root.'images/blank.gif" width="1" height="1" border="0" alt=""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="bottom" align="right"><img src="'.$apidb_root.'images/winehq_border_bottom_right.gif" border="0" alt=""></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="145" border="0" cellspacing="0" cellpadding="1">
|
||||
<tr class="topMenu"><td>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="5">
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
/* add a table row */
|
||||
function add($name, $url = null)
|
||||
{
|
||||
if($url)
|
||||
{
|
||||
echo " <tr class=sideMenu><td width='100%'><span class=menuItem> <a href='$url' class=menuItem>$name</a></span></td></tr>\n";
|
||||
} else {
|
||||
echo " <tr class=sideMenu><td width='100%'><span class=menuItem> $name</span></td></tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function addmisc($stuff, $align = "left")
|
||||
{
|
||||
echo " <tr class=sideMenu><td width='100%' align=$align><span class=menuItem> $stuff</span></td></tr>\n";
|
||||
}
|
||||
|
||||
function done($form = null)
|
||||
{
|
||||
global $apidb_root;
|
||||
|
||||
echo '
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</td>
|
||||
<td><img src="'.$apidb_root.'images/blank.gif" border=0 width=5 height=1 alt="-"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<br>
|
||||
';
|
||||
|
||||
if ($form)
|
||||
echo "</form>\n";
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
81
include/parsedate.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?
|
||||
|
||||
function parsedate($datestr)
|
||||
{
|
||||
$daynames = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday");
|
||||
$monthnames = array("jan" => 1, "feb" => 2, "mar" => 3, "apr" => 4, "may" => 5, "jun" => 6,
|
||||
"jul" => 7, "aug" => 8, "sep" => 9, "oct" => 10, "nov" => 11, "dec" => 12);
|
||||
$ampm = array("am" => 00, "pm" => 12);
|
||||
|
||||
if(!$datestr)
|
||||
return -1;
|
||||
|
||||
$datestr = strtolower($datestr);
|
||||
$datestr = ereg_replace("[,]", "", $datestr);
|
||||
$dp = explode(' ', $datestr);
|
||||
while(list($idx, $part) = each($dp))
|
||||
{
|
||||
//echo "PART($part)<br>";
|
||||
|
||||
/* 23:59:59 */
|
||||
if(ereg("^([0-9]+):([0-9]+):([0-9]+)$", $part, $arr))
|
||||
{
|
||||
$hour = $arr[1];
|
||||
$minute = $arr[2];
|
||||
$second = $arr[3];
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 23:59 */
|
||||
if(ereg("^([0-9]+):([0-9]+)$", $part, $arr))
|
||||
{
|
||||
$hour = $arr[1];
|
||||
$minute = $arr[2];
|
||||
$second = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 2000-12-31 (mysql date format) */
|
||||
if(ereg("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$", $part, $arr))
|
||||
{
|
||||
$year = $arr[1];
|
||||
$month = $arr[2];
|
||||
$day = $arr[3];
|
||||
continue;
|
||||
}
|
||||
|
||||
if(defined($ampm[$part]))
|
||||
{
|
||||
$hour += $ampm[$part];
|
||||
continue;
|
||||
}
|
||||
if($monthnames[substr($part, 0, 3)])
|
||||
{
|
||||
$month = $monthnames[substr($part, 0, 3)];
|
||||
continue;
|
||||
}
|
||||
|
||||
if($part > 1900)
|
||||
{
|
||||
$year = $part;
|
||||
continue;
|
||||
}
|
||||
if($part > 31)
|
||||
{
|
||||
$year = 1900 + $part;
|
||||
continue;
|
||||
}
|
||||
if($part >= 1 && $part <= 31)
|
||||
{
|
||||
$day = $part;
|
||||
continue;
|
||||
}
|
||||
|
||||
//echo "Unparsed: '$part'<br>\n";
|
||||
|
||||
}
|
||||
|
||||
return mktime($hour, $minute, $second, $month, $day, $year);
|
||||
}
|
||||
|
||||
?>
|
||||
76
include/pn_buttons.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* add previous/next buttons
|
||||
*/
|
||||
function add_pn_buttons($vars, $endpos)
|
||||
{
|
||||
extract($vars);
|
||||
|
||||
if($linesPerPage == "ALL")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$curPage = $curPos / $linesPerPage;
|
||||
$numRows = $endpos - $curPos;
|
||||
$numButtons = $totalCount / $linesPerPage;
|
||||
$buttonCount = 1;
|
||||
|
||||
$prev_url = 0;
|
||||
$next_url = 0;
|
||||
|
||||
// define previous/next buttons
|
||||
if($curPos > 0)
|
||||
{
|
||||
$vars["curPos"] = $curPos - $linesPerPage;
|
||||
$prev_url = "stdquery.php?".build_urlarg($vars);
|
||||
}
|
||||
|
||||
if($endpos < $totalCount)
|
||||
{
|
||||
$vars["curPos"] = $curPos + $linesPerPage;
|
||||
$next_url = "stdquery.php?".build_urlarg($vars);
|
||||
}
|
||||
|
||||
// show prev button if nessessary
|
||||
if($prev_url)
|
||||
{
|
||||
echo html_b(html_ahref("<< Prev", $prev_url));
|
||||
}
|
||||
|
||||
// show numbered links
|
||||
if(!$useNextOnly && $endpos <= $totalCount)
|
||||
{
|
||||
while($buttonCount <= $numButtons + 1)
|
||||
{
|
||||
if($curPage == ($buttonCount - 1))
|
||||
{
|
||||
echo html_b("$buttonCount");
|
||||
}
|
||||
else
|
||||
{
|
||||
$vars["curPos"] = ($buttonCount - 1) * $linesPerPage;
|
||||
$url = "stdquery.php?".build_urlarg($vars);
|
||||
echo " ".html_ahref("$buttonCount", $url)." ";
|
||||
}
|
||||
|
||||
if(!($buttonCount % 40))
|
||||
{
|
||||
echo html_p();
|
||||
}
|
||||
$buttonCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// show next button if nessessary
|
||||
if($next_url)
|
||||
{
|
||||
echo html_b(html_ahref("Next >>", $next_url));
|
||||
}
|
||||
|
||||
echo "<br>".html_small("listing $numRows record".($numRows == 1 ? "" : "s")." ".($curPos+1)." to $endpos of $totalCount total");
|
||||
}
|
||||
|
||||
?>
|
||||
246
include/qclass.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?
|
||||
// query class
|
||||
// (de)compose/exec queries
|
||||
// this should have query_inc.php's query preprocessing etc.
|
||||
|
||||
class qclass {
|
||||
|
||||
var $fields;
|
||||
var $tables;
|
||||
var $where;
|
||||
var $limit;
|
||||
var $order;
|
||||
|
||||
var $table_ids = array("apimsdefinition" => "apiid",
|
||||
"apimslinks" => "apiid",
|
||||
"dlldefinition" => "dllid",
|
||||
"implementation" => "apiid",
|
||||
"user_list" => "userid",
|
||||
"project_list" => "id",
|
||||
"appFamily" => "appId",
|
||||
"appVersion" => "versionId",
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
function qclass()
|
||||
{
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
|
||||
function clear()
|
||||
{
|
||||
$this->fields = array();
|
||||
$this->tables = array();
|
||||
$this->where = array();
|
||||
$this->limit = 10;
|
||||
$this->order = "";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* resolve used tables from fields
|
||||
*/
|
||||
function resolve_tables($fields)
|
||||
{
|
||||
$tables = array();
|
||||
while(list($idx, $field) = each($fields))
|
||||
{
|
||||
//echo "Field: $field <br>\n";
|
||||
if(!ereg("^(.+)\\.(.+)$", $field, $arr))
|
||||
continue;
|
||||
$tables[$arr[1]] = $arr[1];
|
||||
}
|
||||
return values($tables);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function get_id($table)
|
||||
{
|
||||
$id = $this->table_ids[$table];
|
||||
if($id)
|
||||
return $id;
|
||||
if(ereg("^impl_.*$", $table))
|
||||
return "apiid";
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_rel($table1, $table2)
|
||||
{
|
||||
$id1 = $this->get_id($table1);
|
||||
$id2 = $this->get_id($table2);
|
||||
|
||||
if($id1 == "dllid" && $table2 == "apimsdefinition")
|
||||
return $id1;
|
||||
if($id2 == "dllid" && $table1 == "apimsdefinition")
|
||||
return $id2;
|
||||
|
||||
if($id1 == $id2)
|
||||
return $id1;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function resolve_where($tables)
|
||||
{
|
||||
$tables = values($tables);
|
||||
$arr = array();
|
||||
$have = array();
|
||||
while(list($idx, $table) = each($tables))
|
||||
{
|
||||
for($i = 0; $i < sizeof($tables); $i++)
|
||||
{
|
||||
//echo "Checking $table - $tables[$i] <br>\n";
|
||||
if($table == $tables[$i])
|
||||
continue;
|
||||
$id = $this->get_rel($table, $tables[$i]);
|
||||
if(!$id)
|
||||
continue;
|
||||
if($have[$id][$table])
|
||||
continue;
|
||||
$have[$id][$table] = 1;
|
||||
$have[$id][$tables[$i]] = 1;
|
||||
$arr[] = "$table.$id = $tables[$i].$id";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
apidb_header();
|
||||
echo "RESULT: ".implode(" AND ", $arr);
|
||||
apidb_footer();
|
||||
exit;
|
||||
*/
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function process($vars)
|
||||
{
|
||||
extract($vars);
|
||||
//var_dump($vars);
|
||||
|
||||
$sfields = $fields;
|
||||
|
||||
if(!$implementations)
|
||||
$implementations = array("wine"); //FIXME
|
||||
|
||||
while(list($idx, $impl) = each($implementations))
|
||||
{
|
||||
|
||||
// Check for quality?
|
||||
if($quality[$idx] && $quality[$idx] != "ALL")
|
||||
{
|
||||
if($quality[$idx] == "UNKNOWN")
|
||||
$this->where[] = "impl_$impl.quality IS NULL";
|
||||
else
|
||||
$this->where[] = "impl_$impl.quality >= $quality[$idx]";
|
||||
$sfields[] = "impl_$impl.quality";
|
||||
}
|
||||
|
||||
// Check for presence?
|
||||
if($presence[$idx] && $presence[$idx] != "ALL")
|
||||
{
|
||||
$this->where[] = "impl_$impl.presence = '$presence[$idx]'";
|
||||
$sfields[] = "impl_$impl.presence";
|
||||
}
|
||||
|
||||
// Check last modified?
|
||||
if($lastmod[$idx] > 0)
|
||||
{
|
||||
$time = time() - ($lastmod[$idx] * 24 * 3600);
|
||||
$this->where[] = "impl_$impl.lastmod > from_unixtime($time)";
|
||||
$sfields[] = "impl_$impl.lastmod";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Search in a specific DLL?
|
||||
if($dllid && $dllid != "ALL")
|
||||
$this->where[] = "dlldefinition.dllid = $dllid";
|
||||
|
||||
// Check for rating? (APPDB)
|
||||
if($rating && $rating != "ANY")
|
||||
{
|
||||
|
||||
$q = "";
|
||||
if($system == "ANY" || $system == "windows")
|
||||
{
|
||||
$q .= " appVersion.rating_windows >= $rating ";
|
||||
$sfields[] = "appVersion.rating_windows";
|
||||
}
|
||||
if($system == "ANY" || $system == "fake")
|
||||
{
|
||||
if($system == "ANY")
|
||||
$q .= " OR ";
|
||||
$q .= " appVersion.rating_fake >= $rating ";
|
||||
$sfields[] = "appVersion.rating_fake";
|
||||
}
|
||||
$this->where[] = "appVersion.appId = appFamily.appId AND ($q)";
|
||||
}
|
||||
|
||||
// Are we searching?
|
||||
if($searchfor)
|
||||
{
|
||||
if(ereg("^[0-9]+$", $searchfor))
|
||||
// exact match if we're searching for a number
|
||||
$this->where[] = "$searchwhat = $searchfor";
|
||||
else
|
||||
// patterns are case insensitive in MySQL
|
||||
$this->where[] = "$searchwhat LIKE '%$searchfor%'";
|
||||
}
|
||||
|
||||
// Must we join?
|
||||
if($join)
|
||||
{
|
||||
$this->where[] = $join;
|
||||
}
|
||||
|
||||
$this->fields = $fields;
|
||||
$this->tables = $this->resolve_tables($sfields);
|
||||
$this->where = array_merge($this->resolve_where($this->tables), $this->where);
|
||||
|
||||
}
|
||||
|
||||
function add_where($str)
|
||||
{
|
||||
$this->where[] = $str;
|
||||
}
|
||||
|
||||
function add_field($field)
|
||||
{
|
||||
$this->fields[] = $field;
|
||||
}
|
||||
|
||||
function add_fields($arr)
|
||||
{
|
||||
$this->fields = array_merge($this->fields, $arr);
|
||||
}
|
||||
|
||||
function resolve()
|
||||
{
|
||||
$this->tables = $this->resolve_tables($this->fields);
|
||||
$this->where = array_merge($this->resolve_where($this->tables), $this->where);
|
||||
}
|
||||
|
||||
|
||||
function get_query()
|
||||
{
|
||||
$query = array();
|
||||
$query[] = "SELECT";
|
||||
$query[] = implode(", ", $this->fields);
|
||||
$query[] = "FROM";
|
||||
$query[] = implode(", ", $this->tables);
|
||||
if(sizeof($this->where))
|
||||
{
|
||||
$query[] = "WHERE";
|
||||
$query[] = implode(" AND ", $this->where);
|
||||
}
|
||||
// add LIMIT etc.
|
||||
|
||||
return implode(" ", $query);
|
||||
}
|
||||
}
|
||||
37
include/query_appbyvendor.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<!-- start of App query -->
|
||||
<table border=1 width="100%" cellspacing=0 cellpadding=3 bordercolor=black>
|
||||
<tr>
|
||||
<th class="box-title">Search Apps by Vendor
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="box-body">
|
||||
<form ACTION="stdquery.php" METHOD="get">
|
||||
Vendor Name:
|
||||
<input TYPE="TEXT" NAME="searchfor"> (leave blank to match all)
|
||||
<?
|
||||
include(BASE."include/"."appbyvendor_inc.php");
|
||||
|
||||
output_appbyvendor_forminputs();
|
||||
|
||||
?>
|
||||
<br><br>
|
||||
<input type=checkbox name=verbose value=yes> Verbose query results <br>
|
||||
<? if(havepriv("admin")) echo "<input type=checkbox name=mode value=edit> Edit mode <br>\n"; ?>
|
||||
|
||||
<br>Entries Per Page:
|
||||
<select NAME="linesPerPage">
|
||||
<option>50
|
||||
<option>100
|
||||
<option>150
|
||||
<option>200
|
||||
<option>500
|
||||
<option>ALL
|
||||
</select>
|
||||
<br> <input TYPE="SUBMIT" VALUE="List Apps">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- end of App query -->
|
||||
|
||||
53
include/query_apps.php
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
<!-- start of App query -->
|
||||
<table border=1 width="100%" cellspacing=0 cellpadding=3 bordercolor=black>
|
||||
<tr>
|
||||
<th class="box-title">Search Apps
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="box-body">
|
||||
<form ACTION="stdquery.php" METHOD="get">
|
||||
<input TYPE="HIDDEN" NAME="orderby" VALUE="appId">
|
||||
App Name:
|
||||
<input TYPE="TEXT" NAME="searchfor"> (leave blank to match all)
|
||||
<input TYPE="HIDDEN" NAME="searchwhat" VALUE="appFamily.appName">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="appFamily.appId">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="appFamily.appName">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="appFamily.webPage">
|
||||
<br><br>
|
||||
<input type=checkbox name=verbose value=yes> Verbose query results <br>
|
||||
<? if(havepriv("admin")) echo "<input type=checkbox name=mode value=edit> Edit mode <br>\n"; ?>
|
||||
|
||||
<br>Rating
|
||||
<select NAME="rating">
|
||||
<option>ANY
|
||||
<option>1
|
||||
<option>2
|
||||
<option>3
|
||||
<option>4
|
||||
<option>5
|
||||
</select> or higher
|
||||
|
||||
<select NAME="system">
|
||||
<option>ANY
|
||||
<option value=windows> Windows
|
||||
<option value=fake> Fake Windows
|
||||
</select>
|
||||
|
||||
<br>Entries Per Page:
|
||||
<select NAME="linesPerPage">
|
||||
<option>50
|
||||
<option>100
|
||||
<option>150
|
||||
<option>200
|
||||
<option>500
|
||||
<option>ALL
|
||||
</select>
|
||||
<br> <input TYPE="SUBMIT" VALUE="List Apps">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- end of App query -->
|
||||
|
||||
189
include/query_inc.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
|
||||
include(BASE."include/"."appversion_inc.php");
|
||||
include(BASE."include/"."appbyvendor_inc.php");
|
||||
|
||||
function initFields()
|
||||
{
|
||||
global $fields, $orderby, $join, $searchfor, $searchwhat;
|
||||
|
||||
$fields = "";
|
||||
$searchfor = "";
|
||||
$searchwhat = "";
|
||||
$join = "";
|
||||
$orderby = "";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* perform a sql query
|
||||
*/
|
||||
function twinedb_query($query, $vars)
|
||||
{
|
||||
// imports vars into symbol table
|
||||
extract($vars);
|
||||
|
||||
if(debugging())
|
||||
echo "QUERY: $query <p>";
|
||||
|
||||
// Only permit sql SELECT statements
|
||||
if(!eregi("^select .*$", $query))
|
||||
{
|
||||
echo "<b> Invalid SQL Query </b>";
|
||||
echo "<br> $query <br>";
|
||||
return;
|
||||
}
|
||||
|
||||
opendb();
|
||||
|
||||
$tmpq = str_replace("\\", "", $query);
|
||||
|
||||
$endPos=$curPos+$linesPerPage;
|
||||
$tcurpos = $curPos+$startapi;
|
||||
$tendpos = $endPos+$startapi;
|
||||
|
||||
// set a limit if not already set
|
||||
if(!stristr($query, "limit"))
|
||||
$tmpq .= " LIMIT $tcurpos,$linesPerPage";
|
||||
|
||||
// execute the db query
|
||||
$tstamp = time();
|
||||
$result = mysql_query($tmpq);
|
||||
$tstamp = time() - $tstamp;
|
||||
|
||||
if(debugging())
|
||||
echo "<b> QUERY TIME: $tstamp seconds </b><br>\n";
|
||||
|
||||
// query error!
|
||||
if(!$result)
|
||||
{
|
||||
echo "$query <br><br>\n";
|
||||
echo "A QUERY error occurred: ".mysql_error()."\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$numRows = mysql_num_rows($result);
|
||||
$numCols = mysql_num_fields($result);
|
||||
|
||||
$curPage = $curPos/$linesPerPage;
|
||||
$tmendpos = $curPos + $numRows;
|
||||
$explain = "stdquery.php?query=".urlencode("EXPLAIN $tmpq");
|
||||
|
||||
|
||||
echo html_br(2);
|
||||
|
||||
// set $debug to enable query debugging
|
||||
if($debug || stristr($tmpq, "explain"))
|
||||
{
|
||||
$str = eregi_replace("(SELECT|EXPLAIN|DISTINCT|FROM|WHERE|AND".
|
||||
"|OR |IS NULL|IS NOT NULL|LIMIT|ORDER BY".
|
||||
"|GROUP BY)",
|
||||
"<br><b>\\1</b><br>", $tmpq);
|
||||
echo "<br>$str<br>\n";
|
||||
}
|
||||
|
||||
echo html_echo("<div align=center>");
|
||||
|
||||
add_pn_buttons($vars, $tmendpos);
|
||||
echo html_br(2);
|
||||
|
||||
// output table header
|
||||
echo html_table_begin("width='80%' cellspacing=1 border=0 rules=rows frame=hsides");
|
||||
$helems = array();
|
||||
for($k = 0; $k < $numCols; $k++)
|
||||
{
|
||||
$name = mysql_field_name($result, $k);
|
||||
$helems[] = $name;
|
||||
if($name == "apiid")
|
||||
$have_apiid = 1;
|
||||
}
|
||||
echo html_th($helems, "title");
|
||||
|
||||
$curapiid=0;
|
||||
$curName="[NONAME]";
|
||||
|
||||
for($i = 0; $i < $numRows; $i++)
|
||||
{
|
||||
$row = mysql_fetch_array($result, MYSQL_BOTH);
|
||||
$color = ($i % 2);
|
||||
$arr = array();
|
||||
|
||||
for($k = 0; $k < $numCols; $k++)
|
||||
{
|
||||
$fname = mysql_field_name($result, $k);
|
||||
|
||||
|
||||
if($fname == "username")
|
||||
{
|
||||
$username = $row[$k];
|
||||
$userid = $row["userid"];
|
||||
$arr[] = html_ahref($username." ", apidb_url("edituser.php?userid=$userid&username=$username"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if($fname == "vendorName")
|
||||
{
|
||||
initFields();
|
||||
$url = "vendorview.php?vendorId=".$row["vendorId"];
|
||||
$arr[] = html_ahref($row[$k], $url);
|
||||
continue;
|
||||
}
|
||||
|
||||
if($fname == "appName")
|
||||
{
|
||||
initFields();
|
||||
$url = "appview.php?appId=".$row["appId"];
|
||||
$arr[] = html_ahref($row[$k], $url);
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if($fname == "versionName")
|
||||
{
|
||||
$versionId = $row["versionId"];
|
||||
$url = "admin/editAppVersion.php?versionId=$versionId";
|
||||
$arr[] = html_ahref($row[$k], $url);
|
||||
continue;
|
||||
}
|
||||
|
||||
if($fname == "webPage")
|
||||
{
|
||||
|
||||
$url = $row[$k];
|
||||
$theLink = "$url";
|
||||
$arr[] = html_ahref($url, $theLink);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(mysql_field_type($result, $k) == "int")
|
||||
{
|
||||
$val = (int)$row[$k];
|
||||
$arr[] = "<div align=right>$val</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$row[$k])
|
||||
$arr[] = " ";
|
||||
else
|
||||
$arr[] = "$row[$k]";
|
||||
}
|
||||
}
|
||||
|
||||
echo html_tr($arr, "color$color");
|
||||
}
|
||||
|
||||
echo html_table_end();
|
||||
echo html_br();
|
||||
|
||||
add_pn_buttons($vars, $tmendpos);
|
||||
echo html_echo("</div>");
|
||||
|
||||
mysql_free_result($result);
|
||||
closedb();
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!-- end of query.php -->
|
||||
59
include/query_users.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* User List
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
echo html_frame_start("List Users","400","",0)
|
||||
|
||||
?>
|
||||
|
||||
<!-- start of users query -->
|
||||
|
||||
<form ACTION="<?=$apidb_root?>stdquery.php" METHOD="get">
|
||||
|
||||
<table width="100%" border=0 cellpadding=0 cellspacing=0>
|
||||
|
||||
<tr>
|
||||
<td class=color1>Pattern</td>
|
||||
<td><input TYPE="TEXT" NAME="searchfor"><br><small>(leave blank to match all)</small></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class=color1>Entries Per Page</td>
|
||||
<td>
|
||||
<select NAME="linesPerPage">
|
||||
<option>100</option>
|
||||
<option>200</option>
|
||||
<option>500</option>
|
||||
<option>ALL</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=2 class=color3 align=center><input TYPE="SUBMIT" VALUE="List Users" class=button></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<input TYPE="HIDDEN" NAME="orderby" VALUE="userid">
|
||||
<input TYPE="HIDDEN" NAME="searchwhat" VALUE="user_list.username">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="user_list.userid">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="user_list.username">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="user_list.email">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="user_list.realname">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="user_list.created">
|
||||
</form>
|
||||
|
||||
<!-- end of users query -->
|
||||
|
||||
<?
|
||||
|
||||
echo html_frame_end();
|
||||
|
||||
echo p(),p(),p();
|
||||
|
||||
?>
|
||||
37
include/query_vendors.php
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
<!-- start of Vendor query -->
|
||||
<table border=1 width="100%" cellspacing=0 cellpadding=3 bordercolor=black>
|
||||
<tr>
|
||||
<th class="box-title">Search Vendors
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="box-body">
|
||||
<form ACTION="stdquery.php" METHOD="get">
|
||||
<input TYPE="HIDDEN" NAME="orderby" VALUE="vendorId">
|
||||
Pattern:
|
||||
<input TYPE="TEXT" NAME="searchfor"> (leave blank to match all)
|
||||
<input TYPE="HIDDEN" NAME="searchwhat" VALUE="vendor.vendorName">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="vendor.vendorId">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="vendor.vendorName">
|
||||
<input TYPE="HIDDEN" NAME="fields[]" VALUE="vendor.vendorURL">
|
||||
<br><br>
|
||||
<input type=checkbox name=verbose value=yes> Verbose query results <br>
|
||||
<? if(havepriv("admin")) echo "<input type=checkbox name=mode value=edit> Edit mode <br>\n"; ?>
|
||||
|
||||
<br>Entries Per Page:
|
||||
<select NAME="linesPerPage">
|
||||
<option>50
|
||||
<option>100
|
||||
<option>150
|
||||
<option>200
|
||||
<option>500
|
||||
<option>ALL
|
||||
</select>
|
||||
<br> <input TYPE="SUBMIT" VALUE="List Vendors">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- end of Vendor query -->
|
||||
|
||||
210
include/rating.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
*
|
||||
* App Compatibility Rating
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function rating_current_for_user($versionId, $system)
|
||||
{
|
||||
global $current;
|
||||
|
||||
if(!loggedin())
|
||||
return 0;
|
||||
|
||||
$userId = $current->userid;
|
||||
|
||||
$result = mysql_query("SELECT score FROM appRating WHERE versionId = $versionId AND system = '$system' AND userId = $userId");
|
||||
if(!$result)
|
||||
return 0;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->score;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* Display the app(-version) rating menu
|
||||
*
|
||||
*/
|
||||
function rating_menu()
|
||||
{
|
||||
global $versionId;
|
||||
global $apidb_root;
|
||||
|
||||
$s = '<img src="'.$apidb_root.'images/s1.gif" border=0 alt="s1">';
|
||||
$n = '<img src="'.$apidb_root.'images/s0.gif" border=0 alt="s0">';
|
||||
|
||||
$j = new htmlmenu("Compatibility Rating","updaterating.php");
|
||||
|
||||
$r_win = rating_current_for_user($versionId, "windows");
|
||||
$r_fake = rating_current_for_user($versionId, "fake");
|
||||
|
||||
$wchk = array('checked',' ',' ',' ',' ',' ');
|
||||
$fchk = array('checked',' ',' ',' ',' ',' ');
|
||||
|
||||
if($r_win)
|
||||
{
|
||||
$wchk[0] = ' ';
|
||||
$wchk[$r_win] = 'checked';
|
||||
}
|
||||
|
||||
if($r_fake)
|
||||
{
|
||||
$fchk[0] = ' ';
|
||||
$fchk[$r_fake] = 'checked';
|
||||
}
|
||||
|
||||
$j->addmisc("<table width='100%' border=0 cellpadding=2 cellspacing=0><tr align=center valign=top>".
|
||||
"<td width='50%'><small><img src='images/w1.gif' alt='With Windows'> With Windows</small></td>".
|
||||
"<td width='50%'><small><img src='images/w0.gif' alt='Without Windows'> Without Windows</small></td>".
|
||||
"</tr></table>");
|
||||
|
||||
$j->addmisc("<input type=radio name=score_w value='0' ".$wchk[0].">".$n.$n.$n.$n.$n."<input type=radio name=score_f value='0' ".$fchk[0].">","center");
|
||||
$j->addmisc("<input type=radio name=score_w value='1' ".$wchk[1].">".$s.$n.$n.$n.$n."<input type=radio name=score_f value='1' ".$fchk[1].">","center");
|
||||
$j->addmisc("<input type=radio name=score_w value='2' ".$wchk[2].">".$s.$s.$n.$n.$n."<input type=radio name=score_f value='2' ".$fchk[2].">","center");
|
||||
$j->addmisc("<input type=radio name=score_w value='3' ".$wchk[3].">".$s.$s.$s.$n.$n."<input type=radio name=score_f value='3' ".$fchk[3].">","center");
|
||||
$j->addmisc("<input type=radio name=score_w value='4' ".$wchk[4].">".$s.$s.$s.$s.$n."<input type=radio name=score_f value='4' ".$fchk[4].">","center");
|
||||
$j->addmisc("<input type=radio name=score_w value='5' ".$wchk[5].">".$s.$s.$s.$s.$s."<input type=radio name=score_f value='5' ".$fchk[5].">","center");
|
||||
|
||||
|
||||
$j->addmisc("<input type=submit value=' Rate it! ' class=ratebutton>","center");
|
||||
$j->addmisc("<input type=hidden name=versionId value=$versionId>");
|
||||
|
||||
$j->add("Rating Help", $apidb_root."help/?topic=ratings");
|
||||
|
||||
$j->done(1);
|
||||
}
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* returns the avg rating for versionId
|
||||
*
|
||||
*/
|
||||
function rating_for_version($versionId, $system)
|
||||
{
|
||||
$result = mysql_query("SELECT avg(score) as rating, count(id) as hits FROM appRating ".
|
||||
"WHERE versionId = $versionId and system = '$system'");
|
||||
if(!$result)
|
||||
return 0;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob;
|
||||
}
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* returns rating as star images
|
||||
*
|
||||
*/
|
||||
function rating_stars_for_version($versionId, $system)
|
||||
{
|
||||
global $apidb_root;
|
||||
|
||||
$r = rating_for_version($versionId, $system);
|
||||
|
||||
$s = '<img src="'.$apidb_root.'images/s1.gif" border=0 alt="s1">';
|
||||
$n = '<img src="'.$apidb_root.'images/s0.gif" border=0 alt="s0">';
|
||||
$h = '<img src="'.$apidb_root.'images/s2.gif" border=0 alt="s2">';
|
||||
|
||||
if ($system == "fake")
|
||||
{
|
||||
$win_gif = "w0.gif";
|
||||
$alt_desc = "Without Windows";
|
||||
}
|
||||
else
|
||||
{
|
||||
$win_gif = "w1.gif";
|
||||
$alt_desc = "With Windows";
|
||||
}
|
||||
|
||||
if(!$r->rating)
|
||||
{
|
||||
$str = "";
|
||||
for($c = 0; $c < 5; $c++) { $str .= $n; }
|
||||
$str = "<img src='images/$win_gif' alt='$alt_desc'> ".$str." <br><small class=rating>"."unrated"."</small>";
|
||||
return $str;
|
||||
}
|
||||
|
||||
$result = "";
|
||||
for($i = 0; $i < (int)floor($r->rating); $i++)
|
||||
$result .= $s;
|
||||
if(floor($r->rating) < round($r->rating))
|
||||
{
|
||||
$i++;
|
||||
$result .= $h;
|
||||
}
|
||||
for(; $i < 5; $i++)
|
||||
$result .= $n;
|
||||
|
||||
$result = "<img src='images/$win_gif' alt='$alt_desc'> ".$result.
|
||||
" <br><small class=rating>".substr($r->rating,0,4).
|
||||
" (".$r->hits." votes) "."</small>";
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* called by /updaterating.php to update the rating table
|
||||
*
|
||||
*/
|
||||
function rating_update($vars)
|
||||
{
|
||||
global $current;
|
||||
|
||||
if(!loggedin())
|
||||
{
|
||||
// do something, must be logged in
|
||||
return;
|
||||
}
|
||||
|
||||
$userId = $current->userid;
|
||||
$versionId = $vars["versionId"];
|
||||
$score_w = $vars["score_w"];
|
||||
$score_f = $vars["score_f"];
|
||||
|
||||
if($score_w)
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM appRating WHERE versionId = $versionId AND ".
|
||||
"userId = $userId AND system = 'windows'");
|
||||
if($result && mysql_num_rows($result))
|
||||
{
|
||||
$ob = mysql_fetch_object($result);
|
||||
mysql_query("UPDATE appRating SET score = $score_w WHERE id = $ob->id");
|
||||
}
|
||||
else
|
||||
mysql_query("INSERT INTO appRating VALUES (null, null, $versionId, $userId, 'windows', $score_w)");
|
||||
|
||||
$r = rating_for_version($versionId, "windows");
|
||||
mysql_query("UPDATE appVersion SET rating_windows = $r->rating WHERE versionId = $versionId");
|
||||
}
|
||||
|
||||
if($score_f)
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM appRating WHERE versionId = $versionId AND ".
|
||||
"userId = $userId AND system = 'fake'");
|
||||
if($result && mysql_num_rows($result))
|
||||
{
|
||||
$ob = mysql_fetch_object($result);
|
||||
mysql_query("UPDATE appRating SET score = $score_f WHERE id = $ob->id");
|
||||
}
|
||||
else
|
||||
mysql_query("INSERT INTO appRating VALUES (null, null, $versionId, $userId, 'fake', $score_f)");
|
||||
|
||||
$r = rating_for_version($versionId, "fake");
|
||||
mysql_query("UPDATE appVersion SET rating_fake = $r->rating WHERE versionId = $versionId");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
113
include/session.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?
|
||||
|
||||
function apidb_session_start()
|
||||
{
|
||||
global $current;
|
||||
|
||||
session_set_cookie_params(time() + 3600 * 48);
|
||||
session_start();
|
||||
|
||||
if($current)
|
||||
$current->connect();
|
||||
}
|
||||
|
||||
|
||||
function apidb_session_destroy()
|
||||
{
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* session handler functions
|
||||
* sessions are stored in a mysql table
|
||||
*
|
||||
*/
|
||||
|
||||
function _session_open($save_path, $session_name)
|
||||
{
|
||||
opendb();
|
||||
//mysql_query("CREATE TABLE IF NOT EXISTS session_list (session_id varchar(64) not null, ".
|
||||
// "userid int, ip varchar(64), data text, messages text, stamp timestamp, primary key(session_id))");
|
||||
return true;
|
||||
}
|
||||
|
||||
function _session_close()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function _session_read($key)
|
||||
{
|
||||
global $msg_buffer;
|
||||
|
||||
opendb();
|
||||
$result = mysql_query("SELECT data, messages FROM session_list WHERE session_id = '$key'");
|
||||
|
||||
if(!$result)
|
||||
return null;
|
||||
$r = mysql_fetch_object($result);
|
||||
|
||||
if($r->messages)
|
||||
$msg_buffer = explode("|", $r->messages);
|
||||
|
||||
return $r->data;
|
||||
}
|
||||
|
||||
function _session_write($key, $value)
|
||||
{
|
||||
global $current;
|
||||
global $msg_buffer;
|
||||
global $apidb_debug;
|
||||
|
||||
opendb();
|
||||
|
||||
|
||||
if($msg_buffer)
|
||||
$messages = implode("|", $msg_buffer);
|
||||
else
|
||||
$messages = "";
|
||||
|
||||
|
||||
// remove single quotes
|
||||
$value = str_replace("'", "", $value);
|
||||
|
||||
|
||||
//DEBUGGING
|
||||
if ($apidb_debug)
|
||||
mysql_query("INSERT INTO debug VALUES(null, '$key = $messages')");
|
||||
|
||||
|
||||
if($current)
|
||||
mysql_query("REPLACE session_list VALUES ('$key', $current->userid, '".get_remote()."', '$value', '$messages', NOW())");
|
||||
else
|
||||
mysql_query("REPLACE session_list VALUES ('$key', 0, '".get_remote()."', null, '$messages', NOW())");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function _session_destroy($key)
|
||||
{
|
||||
mysql_query("DELETE FROM session_list WHERE session_id = '$key'");
|
||||
return true;
|
||||
}
|
||||
|
||||
function _session_gc($maxlifetime)
|
||||
{
|
||||
// delete sessions older than 2 days
|
||||
mysql_query("DELETE FROM session_list WHERE to_days(now()) - to_days(stamp) >= 2");
|
||||
return true;
|
||||
}
|
||||
|
||||
session_set_save_handler("_session_open",
|
||||
"_session_close",
|
||||
"_session_read",
|
||||
"_session_write",
|
||||
"_session_destroy",
|
||||
"_session_gc");
|
||||
|
||||
session_register("current");
|
||||
|
||||
?>
|
||||
41
include/sidebar.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* SideBar
|
||||
*
|
||||
*/
|
||||
|
||||
function global_sidebar_menu() {
|
||||
|
||||
global $apidb_root, $q;
|
||||
|
||||
$g = new htmlmenu("WineHQ Menu");
|
||||
$g->add("Back to WineHQ", "http://www.winehq.org/");
|
||||
$g->done();
|
||||
|
||||
$g = new htmlmenu("App DB");
|
||||
$g->add("AppDB Home", $apidb_root);
|
||||
$g->add("Browse Apps", $apidb_root."appbrowse.php");
|
||||
$g->add("Top 25", $apidb_root."votestats.php");
|
||||
$g->add("Submit App", $apidb_root."appsubmit.php");
|
||||
$g->add("Documentation", $apidb_root."help/");
|
||||
$g->add("Help & Support", $apidb_root."support.php");
|
||||
$g->done();
|
||||
|
||||
$g = new htmlmenu("Search");
|
||||
$g->addmisc(app_search_box($q));
|
||||
$g->done();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function app_search_box($q = '')
|
||||
{
|
||||
$str .= "<form method=GET action=search.php>\n";
|
||||
$str .= "<input type=text name=q value='$q' size=8 class=searchfield>";
|
||||
$str .= "<input type=submit value='Search' class=searchbutton>\n";
|
||||
$str .= "</form>\n";
|
||||
return $str;
|
||||
}
|
||||
|
||||
?>
|
||||
26
include/sidebar_admin.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* sidebar_admin
|
||||
*
|
||||
*/
|
||||
|
||||
function global_admin_menu() {
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
$g = new htmlmenu("Global Admin");
|
||||
|
||||
$g->add("Add Category", $apidb_root."admin/addCategory.php");
|
||||
$g->add("Add Application", $apidb_root."admin/addAppFamily.php?catId=0");
|
||||
$g->add("Add Vendor", $apidb_root."admin/addVendor.php");
|
||||
|
||||
$g->addmisc(" ");
|
||||
$g->add("List Users", $apidb_root."admin/");
|
||||
$g->add("View App Queue", $apidb_root."admin/adminAppQueue.php");
|
||||
|
||||
$g->done();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
28
include/sidebar_login.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Login SideBar
|
||||
*
|
||||
*/
|
||||
|
||||
function global_sidebar_login() {
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
$g = new htmlmenu("User Menu");
|
||||
|
||||
if(loggedin())
|
||||
{
|
||||
$g->add("Logout", $apidb_root."account.php?cmd=logout");
|
||||
$g->add("Preferences", $apidb_root."preferences.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
$g->add("Login", $apidb_root."account.php?cmd=login");
|
||||
}
|
||||
|
||||
$g->done();
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
503
include/tableve.php
Normal file
@@ -0,0 +1,503 @@
|
||||
<?
|
||||
|
||||
require(BASE."include/"."parsedate.php");
|
||||
|
||||
class TableVE {
|
||||
|
||||
var $mode;
|
||||
var $titleField;
|
||||
var $titleText;
|
||||
var $numberedTitles;
|
||||
|
||||
/*
|
||||
* mode can be: view, edit, create
|
||||
*/
|
||||
function TableVE($mode)
|
||||
{
|
||||
$this->mode = $mode;
|
||||
$this->titleField = "";
|
||||
$this->titleText = "";
|
||||
$this->numberedTitles = 0;
|
||||
|
||||
opendb();
|
||||
}
|
||||
|
||||
function test($query)
|
||||
{
|
||||
$result = mysql_query($query);
|
||||
$nfields = mysql_num_fields($result);
|
||||
$nrows = mysql_num_rows($result);
|
||||
$table = mysql_field_table($result, 0);
|
||||
|
||||
echo "Table: $table <br> Fields: $nfields <br> Rows: $nrows <br> <br>\n";
|
||||
|
||||
$i = 0;
|
||||
while($i < $nfields)
|
||||
{
|
||||
$type = mysql_field_type($result, $i);
|
||||
$name = mysql_field_name($result, $i);
|
||||
$len = mysql_field_len($result, $i);
|
||||
$flags = mysql_field_flags($result, $i);
|
||||
|
||||
echo "$type | $name | $len | $flags <br>\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* this is a bit of a hack,
|
||||
* we first create an empty entry, and then simply use the
|
||||
* edit() function to do the rest of the work for us.
|
||||
*/
|
||||
function create($query, $table, $idcolumn)
|
||||
{
|
||||
$result = mysql_query($query);
|
||||
$id = mysql_insert_id();
|
||||
|
||||
$new_query = "SELECT * FROM $table WHERE $idcolumn = $id";
|
||||
$this->edit($new_query);
|
||||
}
|
||||
|
||||
|
||||
function view($query)
|
||||
{
|
||||
//$this->test($query);
|
||||
|
||||
$nrows = 0;
|
||||
|
||||
$result = mysql_query($query);
|
||||
$nrows = mysql_num_rows($result);
|
||||
|
||||
if(debugging())
|
||||
{
|
||||
echo "Query returns $nrows rows.";
|
||||
}
|
||||
|
||||
for($i = 0; $i < $nrows; $i++)
|
||||
{
|
||||
$this->view_entry($result, $i);
|
||||
echo "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function view_entry($result, $num)
|
||||
{
|
||||
$nfields = mysql_num_fields($result);
|
||||
$fields = mysql_fetch_array($result, MYSQL_BOTH);
|
||||
|
||||
$titleValue = $fields[$this->titleField];
|
||||
$titleText = $this->titleText;
|
||||
if($this->numberedTitles)
|
||||
{
|
||||
// don't want zero-based.
|
||||
$num++;
|
||||
$titleText .= " # $num";
|
||||
}
|
||||
|
||||
//echo "<table border=1 bordercolor=black width='80%' cellpadding=0 cellspacing=0>\n";
|
||||
//echo "<th class='box-title' colspan='2'></th></tr>\n";
|
||||
|
||||
//echo "<tr><td>\n";
|
||||
|
||||
echo html_frame_start("Viewing $titleValue $titleText","80%","",0);
|
||||
echo "<table border=0 width='100%' cellspacing=0 cellpadding=2>\n";
|
||||
|
||||
for($i = 0; $i < $nfields; $i++)
|
||||
{
|
||||
$field = mysql_fetch_field($result, $i);
|
||||
|
||||
if(ereg("^impl_(.+)$", $field->table, $arr))
|
||||
{
|
||||
if($cur_impl != $arr[1])
|
||||
echo "<tr><th class='box-label' colspan=2> ".ucfirst($arr[1])." Implementation </th></tr>\n";
|
||||
$cur_impl = $arr[1];
|
||||
}
|
||||
|
||||
echo "<tr><td width='15%' class='box-label'><b> $field->name </b></td>";
|
||||
echo "<td class='box-body'>";
|
||||
$this->view_entry_output_field($field, $fields[$i], 0);
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo html_frame_end();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function edit($query)
|
||||
{
|
||||
$result = mysql_query($query);
|
||||
if(!$result)
|
||||
echo "Oops: ".mysql_error()."<br>$query<br>\n";
|
||||
$nrows = mysql_num_rows($result);
|
||||
|
||||
echo "<form method=post action='".apidb_url("editapi.php")."'>\n";
|
||||
|
||||
for($i = 0; $i < $nrows; $i++)
|
||||
{
|
||||
$this->edit_entry($result);
|
||||
echo "<br>\n";
|
||||
}
|
||||
|
||||
echo html_frame_start("Update Database",100);
|
||||
echo "<input type=submit value='Update Database'>\n";
|
||||
echo html_frame_end();
|
||||
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
||||
|
||||
function edit_entry($result)
|
||||
{
|
||||
$nfields = mysql_num_fields($result);
|
||||
$fields = mysql_fetch_array($result);
|
||||
|
||||
echo html_frame_start(ucfirst($this->mode),"80%","",0);
|
||||
echo "<table border=0 width='100%' cellspacing=0 cellpadding=2>\n";
|
||||
|
||||
$cur_impl = null;
|
||||
for($i = 0; $i < $nfields; $i++)
|
||||
{
|
||||
global $testvar;
|
||||
$field = mysql_fetch_field($result, $i);
|
||||
$len = mysql_field_len($result, $i);
|
||||
|
||||
if(ereg("^impl_(.+)$", $field->table, $arr))
|
||||
{
|
||||
if($cur_impl != $arr[1])
|
||||
echo "<tr><th class='box-label' colspan=2> ".ucfirst($arr[1])." Implementation </th></tr>\n";
|
||||
$cur_impl = $arr[1];
|
||||
}
|
||||
|
||||
echo "<tr><td width='15%' class='box-label'><b> $field->name </b></td>";
|
||||
echo "<td class='box-body'> ";
|
||||
$this->edit_entry_output_field($field, $fields[$i], $len);
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo html_frame_end();
|
||||
}
|
||||
|
||||
function timestamp_to_unix($stamp)
|
||||
{
|
||||
$result = mysql_query("select unix_timestamp($stamp)");
|
||||
if(!$result)
|
||||
return 0;
|
||||
$r = mysql_fetch_row($result);
|
||||
return $r[0];
|
||||
}
|
||||
|
||||
function make_option_list($varname, $cvalue, $table, $idField, $nameField, $where = "")
|
||||
{
|
||||
|
||||
$result = mysql_query("SELECT $idField, $nameField FROM $table $where ORDER BY $nameField");
|
||||
if(!result)
|
||||
return; // Oops
|
||||
|
||||
echo "<select name='$varname'>\n";
|
||||
echo "<option value=0>Choose ...</option>\n";
|
||||
while(list($id, $name) = mysql_fetch_row($result))
|
||||
{
|
||||
if ($name == "NONAME")
|
||||
continue;
|
||||
if($id == $cvalue)
|
||||
echo "<option value=$id selected>$name\n";
|
||||
else
|
||||
echo "<option value=$id>$name\n";
|
||||
|
||||
}
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
|
||||
function edit_entry_output_field($field, $value, $len)
|
||||
{
|
||||
static $idx = 0;
|
||||
|
||||
$idx++;
|
||||
if($len > 50)
|
||||
$len = 50;
|
||||
|
||||
$varname = "FIELD_".$field->table."___".$field->name."[]";
|
||||
echo "<input type=hidden name='TYPE_$varname' value='$field->type'>\n";
|
||||
|
||||
if($field->name == "appId" && $field->table != "appFamily")
|
||||
{
|
||||
$this->make_option_list($varname, $value, "appFamily", "appId", "appName");
|
||||
return;
|
||||
}
|
||||
|
||||
if($field->name == "vendorId" && $field->table != "vendor")
|
||||
{
|
||||
$this->make_option_list($varname, $value, "vendor", "vendorId", "vendorName");
|
||||
return;
|
||||
}
|
||||
|
||||
if($field->name == "catId" && $field->table != "appCategory")
|
||||
{
|
||||
$this->make_option_list($varname, $value, "appCategory", "catId", "catName");
|
||||
return;
|
||||
}
|
||||
|
||||
if($field->name == "catParent")
|
||||
{
|
||||
$this->make_option_list($varname, $value, "appCategory", "catId", "catName");
|
||||
return;
|
||||
}
|
||||
|
||||
if($field->name == "keywords")
|
||||
{
|
||||
echo "<textarea cols=$len rows=3 name='$varname'>".stripslashes($value)."</textarea>\n";
|
||||
return;
|
||||
}
|
||||
|
||||
switch($field->type)
|
||||
{
|
||||
case "string":
|
||||
case "enum":
|
||||
case "int":
|
||||
case "text":
|
||||
echo "<input type=text size=$len name='$varname' value='".stripslashes($value)."'>\n";
|
||||
break;
|
||||
case "blob":
|
||||
echo "<textarea cols=$len rows=10 name='$varname'>".stripslashes($value)."</textarea>\n";
|
||||
break;
|
||||
case "timestamp":
|
||||
$time = $this->timestamp_to_unix($value);
|
||||
echo makedate($time);
|
||||
break;
|
||||
case "datetime":
|
||||
$time = parsedate($value);
|
||||
echo makedate($time);
|
||||
break;
|
||||
default:
|
||||
echo "$value \n";
|
||||
break;
|
||||
}
|
||||
|
||||
$this->entry_add_extra($field, $value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function view_entry_output_field($field, $value, $len)
|
||||
{
|
||||
if($len > 50)
|
||||
$len = 50;
|
||||
|
||||
//FIXME: need a better way for special cases
|
||||
if(!$value && $field->name == "comments")
|
||||
{
|
||||
echo "none";
|
||||
return;
|
||||
}
|
||||
if(!$value && ($field->name == "location" || $field->name == "quality"))
|
||||
{
|
||||
echo "unknown";
|
||||
return;
|
||||
}
|
||||
|
||||
if($field->name == "lastmodby")
|
||||
{
|
||||
$user = new user();
|
||||
$name = $user->lookup_username($value);
|
||||
if(!$name)
|
||||
$name = "system";
|
||||
echo "$name ($value)";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch($field->type)
|
||||
{
|
||||
case "string":
|
||||
case "enum":
|
||||
case "int":
|
||||
case "blob":
|
||||
echo "$value \n";
|
||||
break;
|
||||
case "timestamp":
|
||||
$time = $this->timestamp_to_unix($value);
|
||||
echo makedate($time);
|
||||
break;
|
||||
case "datetime":
|
||||
$time = parsedate($value);
|
||||
echo makedate($time);
|
||||
break;
|
||||
default:
|
||||
echo "$value \n";
|
||||
break;
|
||||
}
|
||||
|
||||
$this->entry_add_extra($field, $value);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* add extra stuff to certain fields
|
||||
*/
|
||||
function entry_add_extra($field, $value)
|
||||
{
|
||||
/*
|
||||
* add extra stuff to certain fields
|
||||
*/
|
||||
|
||||
if($field->name == "mslink" && $value)
|
||||
{
|
||||
echo html_imagebutton("Go!", $value);
|
||||
}
|
||||
|
||||
if($field->name == "apiname")
|
||||
{
|
||||
echo html_imagebutton("Wine LXR", "http://twine.codeweavers.com/lxr/ident?i=$value");
|
||||
echo html_imagebutton("Wine API", "http://www.winehq.com/WineAPI/$value.html");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* required field for each table.
|
||||
* When editing a query this field needs to be present in the query
|
||||
* in order to identify the correct row to update.
|
||||
*/
|
||||
var $table_ids = array(
|
||||
"user_list" => "userid",
|
||||
"appFamily" => "appId",
|
||||
"appVersion" => "versionId",
|
||||
"userExperience" => "uExpId",
|
||||
"appCategory" => "catId",
|
||||
"vendor" => "vendorId",
|
||||
"appNotes" => "noteId"
|
||||
);
|
||||
|
||||
function get_id($name)
|
||||
{
|
||||
reset($this->table_ids);
|
||||
while(list($table, $id) = each($this->table_ids))
|
||||
{
|
||||
$r = "^$table$";
|
||||
//echo "Checking $r against $name <br>\n";
|
||||
if(ereg($r, $name))
|
||||
{
|
||||
//echo "ID for $name -> $id <br>\n";
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* update() expects $HTTP_POST_VARS as argument
|
||||
* this is where things are getting kinda complex, here we update "
|
||||
* multiple entries with multiple fields in multiple tables (get it?)
|
||||
*/
|
||||
function update($vars)
|
||||
{
|
||||
global $current;
|
||||
|
||||
$tables = array();
|
||||
$fieldnames = array();
|
||||
$num_entries = 0;
|
||||
|
||||
while(list($varname, $arr) = each($vars))
|
||||
{
|
||||
if(!ereg("^FIELD_([a-zA-Z_]+)___(.+)$", $varname, $regs))
|
||||
continue;
|
||||
|
||||
$tables[$regs[1]][] = $regs[2];
|
||||
$fieldnames[$regs[2]] = $arr;
|
||||
$num_entries = sizeof($arr);
|
||||
}
|
||||
|
||||
while(list($table, $fields) = each($tables))
|
||||
{
|
||||
echo "<b> $table (".$this->get_id($table).") </b>";
|
||||
|
||||
if($fieldnames[$this->get_id($table)])
|
||||
echo "OK!";
|
||||
|
||||
echo "<br>\n";
|
||||
|
||||
for($i = 0; $i < sizeof($fields); $i++)
|
||||
echo "- $fields[$i] <br>\n";
|
||||
|
||||
echo "<br>\n";
|
||||
}
|
||||
|
||||
for($i = 0; $i < $num_entries; $i++)
|
||||
{
|
||||
reset($tables);
|
||||
while(list($table, $fields) = each($tables))
|
||||
{
|
||||
$update = "UPDATE $table SET ";
|
||||
|
||||
$count = sizeof($fields);
|
||||
reset($fields);
|
||||
while(list($idx, $field) = each($fields))
|
||||
{
|
||||
$count--;
|
||||
|
||||
if($this->table_ids[$table] == $field)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$key = "FIELD_".$table."___".$field;
|
||||
$type = $vars["TYPE_$key"][$i];
|
||||
|
||||
if($type == "int")
|
||||
$update .= "$field = ".$vars[$key][$i];
|
||||
else
|
||||
$update .= "$field = '".addslashes($vars[$key][$i])."'";
|
||||
|
||||
if($count)
|
||||
$update .= ", ";
|
||||
}
|
||||
|
||||
$value = $fieldnames[$this->get_id($table)][$i];
|
||||
|
||||
$update .= " WHERE ".$this->get_id($table)." = $value";
|
||||
|
||||
if(!mysql_query($update))
|
||||
{
|
||||
$thisError = "<p><font color=black><b>Query:</b>: $update</font></p>\n";
|
||||
$thisError .= "<p><font color=red>".mysql_error()."</font></p>";
|
||||
addmsg($thisError,"red");
|
||||
}
|
||||
else
|
||||
{
|
||||
addmsg("Database Operation Complete!","green");
|
||||
}
|
||||
|
||||
if(ereg("^impl_.+$", $table))
|
||||
{
|
||||
$value = $fieldnames["apiid"][$i];
|
||||
mysql_query("UPDATE $table SET lastmodby = $current->userid WHERE apiid = $value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function set_title_field($newTitleField)
|
||||
{
|
||||
$this->titleField = $newTitleField;
|
||||
}
|
||||
|
||||
function set_title_text($newTitleText)
|
||||
{
|
||||
$this->titleText = $newTitleText;
|
||||
}
|
||||
|
||||
function set_numbered_titles()
|
||||
{
|
||||
$this->numberedTitles = 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
319
include/user.php
Normal file
@@ -0,0 +1,319 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* This class represents a logged in user
|
||||
*/
|
||||
class User {
|
||||
|
||||
var $link; // database connection
|
||||
|
||||
var $stamp;
|
||||
var $userid;
|
||||
var $username;
|
||||
var $realname;
|
||||
var $created;
|
||||
var $status;
|
||||
var $perm;
|
||||
|
||||
/*
|
||||
* constructor
|
||||
* opens a connection to the user database
|
||||
*/
|
||||
function User()
|
||||
{
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
|
||||
function connect()
|
||||
{
|
||||
$this->link = opendb();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check if a user exists
|
||||
* returns TRUE if the user exists
|
||||
*/
|
||||
function exists($username)
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM user_list WHERE username = '$username'", $this->link);
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function lookup_username($userid)
|
||||
{
|
||||
$result = mysql_query("SELECT username FROM user_list WHERE userid = $userid");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->username;
|
||||
}
|
||||
|
||||
function lookup_userid($username)
|
||||
{
|
||||
$result = mysql_query("SELECT userid FROM user_list WHERE username = '$username'");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->userid;
|
||||
}
|
||||
|
||||
function lookup_realname($userid)
|
||||
{
|
||||
$result = mysql_query("SELECT realname FROM user_list WHERE userid = $userid");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->realname;
|
||||
}
|
||||
|
||||
function lookup_email($userid)
|
||||
{
|
||||
$result = mysql_query("SELECT email FROM user_list WHERE userid = $userid");
|
||||
if(!$result || mysql_num_rows($result) != 1)
|
||||
return null;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->email;
|
||||
}
|
||||
|
||||
/*
|
||||
* restore a user from the database
|
||||
* returns 0 on success and an error msg on failure
|
||||
*/
|
||||
function restore($username, $password)
|
||||
{
|
||||
$result = mysql_query("SELECT stamp, userid, username, realname, ".
|
||||
"created, status, perm FROM user_list WHERE ".
|
||||
"username = '$username' AND ".
|
||||
"password = password('$password')", $this->link);
|
||||
//echo "RESTORE($username, $password) result=$result rows=".mysql_num_rows($result)."<br>\n";
|
||||
if(!$result)
|
||||
return "Error: ".mysql_error($this->link);
|
||||
|
||||
if(mysql_num_rows($result) == 0)
|
||||
return "Invalid username or password";
|
||||
|
||||
list($this->stamp, $this->userid, $this->username, $this->realname,
|
||||
$this->created, $status, $perm) = mysql_fetch_row($result);
|
||||
|
||||
//echo "<br> User: $this->userid ($this->username, $this->realname) <br>\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function login($username, $password)
|
||||
{
|
||||
$result = $this->restore($username, $password);
|
||||
|
||||
if($result != null)
|
||||
return $result;
|
||||
//echo "<br>LOGIN($this->username)<br>\n";
|
||||
//FIXME: update last_login here
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* create a new user
|
||||
* returns 0 on success and an error msg on failure
|
||||
*/
|
||||
function create($username, $password, $realname, $email)
|
||||
{
|
||||
$result = mysql_query("INSERT INTO user_list VALUES ( NOW(), 0, ".
|
||||
"'$username', password('$password'), ".
|
||||
"'$realname', '$email', NOW(), 0, 0)", $this->link);
|
||||
//echo "error: ".mysql_error();
|
||||
if(!$result)
|
||||
return mysql_error($this->link);
|
||||
return $this->restore($username, $password);
|
||||
}
|
||||
|
||||
// Update User Account;
|
||||
function update($userid = 0, $password = null, $realname = null, $email = null)
|
||||
{
|
||||
if (!$userid)
|
||||
return 0;
|
||||
if ($password)
|
||||
{
|
||||
if (!mysql_query("UPDATE user_list SET password = password('$password') WHERE userid = $userid"))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($realname)
|
||||
{
|
||||
if (!mysql_query("UPDATE user_list SET realname = '".addslashes($realname)."' WHERE userid = $userid"))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($email)
|
||||
{
|
||||
if (!mysql_query("UPDATE user_list SET email = '".addslashes($email)."' WHERE userid = $userid"))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* remove the current, or specified user from the database
|
||||
* returns 0 on success and an error msg on failure
|
||||
*/
|
||||
function remove($username = 0)
|
||||
{
|
||||
if($username == 0)
|
||||
$username = $this->username;
|
||||
|
||||
$result = mysql_query("DELETE FROM user_list WHERE username = '$username'", $this->link);
|
||||
|
||||
if(!$result)
|
||||
return mysql_error($this->link);
|
||||
if(mysql_affected_rows($result) == 0)
|
||||
return "No such user.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function done()
|
||||
{
|
||||
mysql_close($this->link);
|
||||
}
|
||||
|
||||
|
||||
function getpref($key, $def = null)
|
||||
{
|
||||
if(!$this->userid || !$key)
|
||||
return $def;
|
||||
|
||||
$result = mysql_query("SELECT * FROM user_prefs WHERE userid = $this->userid AND name = '$key'", $this->link);
|
||||
if(!$result || mysql_num_rows($result) == 0)
|
||||
return $def;
|
||||
$ob = mysql_fetch_object($result);
|
||||
return $ob->value;
|
||||
}
|
||||
|
||||
function setpref($key, $value)
|
||||
{
|
||||
if(!$this->userid || !$key || !$value)
|
||||
return null;
|
||||
|
||||
$result = mysql_query("DELETE FROM user_prefs WHERE userid = $this->userid AND name = '$key'");
|
||||
$result = mysql_query("INSERT INTO user_prefs VALUES($this->userid, '$key', '$value')");
|
||||
echo mysql_error();
|
||||
|
||||
return $result ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check if this user has $priv
|
||||
*/
|
||||
function checkpriv($priv)
|
||||
{
|
||||
if(!$this->userid || !$priv)
|
||||
return 0;
|
||||
|
||||
$result = mysql_query("SELECT * FROM user_privs WHERE userid = $this->userid AND priv = '$priv'", $this->link);
|
||||
if(!$result)
|
||||
return 0;
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function addpriv($priv)
|
||||
{
|
||||
if(!$this->userid || !$priv)
|
||||
return 0;
|
||||
|
||||
if($this->checkpriv($priv))
|
||||
return 1;
|
||||
|
||||
$result = mysql_query("INSERT INTO user_privs VALUES ($this->userid, '$priv')", $this->link);
|
||||
|
||||
return mysql_affected_rows($result);
|
||||
}
|
||||
|
||||
function delpriv($priv)
|
||||
{
|
||||
if(!$this->userid || !$priv)
|
||||
return 0;
|
||||
|
||||
$result = mysql_query("DELETE FROM user_privs WHERE userid = $this->userid AND priv = '$priv'", $this->link);
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
*
|
||||
* App Owners
|
||||
*
|
||||
*/
|
||||
function ownsApp($appId)
|
||||
{
|
||||
$result = mysql_query("SELECT * FROM appOwners WHERE ownerId = $this->userid AND appId = $appId");
|
||||
if($result && mysql_num_rows($result))
|
||||
return 1; // OK
|
||||
return 0; // NOPE!
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function loggedin()
|
||||
{
|
||||
global $current;
|
||||
|
||||
if($current && $current->userid)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function havepriv($priv)
|
||||
{
|
||||
global $current;
|
||||
|
||||
if(!loggedin())
|
||||
return false;
|
||||
|
||||
return $current->checkpriv($priv);
|
||||
}
|
||||
|
||||
function debugging()
|
||||
{
|
||||
global $current;
|
||||
|
||||
if(!loggedin())
|
||||
return false;
|
||||
return $current->getpref("debug") == "yes";
|
||||
}
|
||||
|
||||
|
||||
function makeurl($text, $url, $pref = null)
|
||||
{
|
||||
global $current;
|
||||
|
||||
if(loggedin())
|
||||
{
|
||||
if($current->getpref($pref) == "yes")
|
||||
$extra = "window='new'";
|
||||
}
|
||||
return "<a href='$url' $extra> $text </a>\n";
|
||||
}
|
||||
|
||||
// create a new random password
|
||||
function generate_passwd($pass_len = 10)
|
||||
{
|
||||
$nps = "";
|
||||
mt_srand ((double) microtime() * 1000000);
|
||||
while (strlen($nps)<$pass_len)
|
||||
{
|
||||
$c = chr(mt_rand (0,255));
|
||||
if (eregi("^[a-z0-9]$", $c)) $nps = $nps.$c;
|
||||
}
|
||||
return ($nps);
|
||||
}
|
||||
|
||||
?>
|
||||
174
include/util.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
$dbcon = null;
|
||||
$dbref = 0;
|
||||
|
||||
function opendb()
|
||||
{
|
||||
global $apidb_dbuser, $apidb_dbpass, $apidb_dbhost, $apidb_db;
|
||||
global $dbcon, $dbref;
|
||||
|
||||
$dbref++;
|
||||
|
||||
if($dbcon)
|
||||
return $dbcon;
|
||||
|
||||
$dbcon = mysql_connect($apidb_dbhost, $apidb_dbuser, $apidb_dbpass);
|
||||
if(!$dbcon)
|
||||
{
|
||||
echo "An error occurred: ".mysql_error()."<p>\n";
|
||||
exit;
|
||||
}
|
||||
mysql_select_db($apidb_db);
|
||||
return $dbcon;
|
||||
}
|
||||
|
||||
function closedb()
|
||||
{
|
||||
global $dbcon, $dbref;
|
||||
|
||||
if(--$dbref)
|
||||
return;
|
||||
|
||||
mysql_close($dbcon);
|
||||
}
|
||||
|
||||
function querydb($query)
|
||||
{
|
||||
$result = mysql_query($query);
|
||||
if(!$result)
|
||||
{
|
||||
echo "<br><font color=green> $query </font> <br><br>\n";
|
||||
echo "<font color=red>A QUERY error occurred:</font> ".
|
||||
"<font color=blue>".mysql_error()."</font><p>\n";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function mysql_field_is_null($result, $row, $field)
|
||||
{
|
||||
if(mysql_result($result, $row, $field) == null)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function read_string($filename)
|
||||
{
|
||||
return join("", file($filename));
|
||||
}
|
||||
|
||||
|
||||
function build_urlarg($vars)
|
||||
{
|
||||
$arr = array();
|
||||
while(list($key, $val) = each($vars))
|
||||
{
|
||||
if(is_array($val))
|
||||
{
|
||||
while(list($idx, $value) = each($val))
|
||||
{
|
||||
//echo "Encoding $key / $value<br>";
|
||||
$arr[] = rawurlencode($key."[]")."=".rawurlencode($value);
|
||||
}
|
||||
}
|
||||
else
|
||||
$arr[] = $key."=".rawurlencode($val);
|
||||
}
|
||||
return implode("&", $arr);
|
||||
}
|
||||
|
||||
|
||||
function add_option_menu($options, $label, $id)
|
||||
{
|
||||
echo "<form action='project.php' method='get'>\n";
|
||||
echo "<select name='prj_id'>\n";
|
||||
while(list($idx, $val) = each($options))
|
||||
echo "<option>$val</option>\n";
|
||||
echo "</select>\n";
|
||||
echo "<input type='submit' value='$label'>\n";
|
||||
echo "</form> <br>\n";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return all keys of a mapping as an array
|
||||
*/
|
||||
function keys($arr)
|
||||
{
|
||||
$res = array();
|
||||
while(list($k, $v) = each($arr))
|
||||
$res[] = $k;
|
||||
return $res;
|
||||
}
|
||||
|
||||
/*
|
||||
* return all values of a mapping as an array
|
||||
*/
|
||||
function values($arr)
|
||||
{
|
||||
$res = array();
|
||||
while(list($k, $v) = each($arr))
|
||||
$res[] = $v;
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* format date
|
||||
*/
|
||||
function makedate($time)
|
||||
{
|
||||
return date("F d, Y H:i:s", $time);
|
||||
}
|
||||
|
||||
|
||||
function get_remote()
|
||||
{
|
||||
global $REMOTE_HOST, $REMOTE_ADDR;
|
||||
|
||||
if($REMOTE_HOST)
|
||||
$ip = $REMOTE_HOST;
|
||||
else
|
||||
$ip = $REMOTE_ADDR;
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
function htmlify_urls($text)
|
||||
{
|
||||
//FIXME: wonder what the syntax is, this doesn't seem to work
|
||||
// $text = strip_tags($text, "<a>,<b>,<i>,<ul>,<li>");
|
||||
|
||||
// html-ify urls
|
||||
$urlreg = "([a-zA-Z]+://([^\t\r\n ]+))";
|
||||
$text = ereg_replace($urlreg, "<a href=\"\\1\"> \\2 </a>", $text);
|
||||
|
||||
$emailreg = "([a-zA-Z0-9_%+.-]+@[^\t\r\n ]+)";
|
||||
$text = ereg_replace($emailreg, " <a href='mailto:\\1'>\\1</a>", $text);
|
||||
|
||||
$text = str_replace("\n", "<br>", $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
// open file and display contents of selected tag
|
||||
function get_xml_tag ($file, $mode = null)
|
||||
{
|
||||
if ($mode and file_exists($file))
|
||||
{
|
||||
$fp = @fopen($file, "r");
|
||||
$data = fread($fp, filesize($file));
|
||||
@fclose($fp);
|
||||
if (eregi("<" . $mode . ">(.*)</" . $mode . ">", $data, $out))
|
||||
{
|
||||
return $out[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||