commit 8f28ae10c40de0794a72fef07f7e05f1017cb691 Author: Jeremy Newman Date: Mon Mar 15 16:22:00 2004 +0000 Initial revision diff --git a/README b/README new file mode 100644 index 0000000..ddd178a --- /dev/null +++ b/README @@ -0,0 +1,5 @@ +WineHQ Application Database +------------------------------------------------------------------------ +Authors: + Jeremy Newman + Charles Leop diff --git a/account.php b/account.php new file mode 100644 index 0000000..4f46342 --- /dev/null +++ b/account.php @@ -0,0 +1,197 @@ +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; + } +} + +?> diff --git a/addcomment.php b/addcomment.php new file mode 100644 index 0000000..1a95b44 --- /dev/null +++ b/addcomment.php @@ -0,0 +1,98 @@ +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 = "Post New Comment"; + + if($thread) + { + $result = mysql_query("SELECT subject,body FROM appComments WHERE commentId = $thread"); + $ob = mysql_fetch_object($result); + if($ob) + { + $mesTitle = "Replying To ... $ob->subject\n"; + echo html_frame_start($ob->subject,500); + echo htmlify_urls($ob->body), "

\n"; + echo html_frame_end(); + } + } + + echo "
\n"; + + echo html_frame_start($mesTitle,500,"",0); + + echo '',"\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo "
From:  ". ($current->username ? $current->username : "Anonymous") ."
Subject:  
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo html_frame_end(); + + echo "\n"; + echo "\n"; + echo "\n"; + echo "

 

\n"; + + apidb_footer(); + +} + +?> diff --git a/admin/.cvsignore b/admin/.cvsignore new file mode 100644 index 0000000..55d2fba --- /dev/null +++ b/admin/.cvsignore @@ -0,0 +1,2 @@ +stderr + diff --git a/admin/addAppFamily.php b/admin/addAppFamily.php new file mode 100644 index 0000000..8d88956 --- /dev/null +++ b/admin/addAppFamily.php @@ -0,0 +1,37 @@ +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 "

query: $query

"; } + + $t->create($query, $table, "appId"); +} + +apidb_footer(); + +?> diff --git a/admin/addAppNote.php b/admin/addAppNote.php new file mode 100644 index 0000000..d6103a5 --- /dev/null +++ b/admin/addAppNote.php @@ -0,0 +1,51 @@ +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 "

query: $query

"; } + + $t->create($query, $table, "noteId"); + + echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId"); +} + +apidb_footer(); + +?> diff --git a/admin/addAppVersion.php b/admin/addAppVersion.php new file mode 100644 index 0000000..aa9cf3a --- /dev/null +++ b/admin/addAppVersion.php @@ -0,0 +1,48 @@ +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

\n"; + + $t->create($query, $table, "versionId"); +} + +echo html_back_link(1,$apidb_root."appview.php?appId=$appId"); + +apidb_footer(); + +?> diff --git a/admin/addCategory.php b/admin/addCategory.php new file mode 100644 index 0000000..6cb3625 --- /dev/null +++ b/admin/addCategory.php @@ -0,0 +1,42 @@ +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

\n"; + + $t->create($query, $table, "catId"); +} + +apidb_footer(); + +?> diff --git a/admin/addVendor.php b/admin/addVendor.php new file mode 100644 index 0000000..611067a --- /dev/null +++ b/admin/addVendor.php @@ -0,0 +1,44 @@ +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

\n"; + + $t->create($query, $table, "vendorId"); +} + +apidb_footer(); + +?> diff --git a/admin/adminAppQueue.php b/admin/adminAppQueue.php new file mode 100644 index 0000000..bdefe4d --- /dev/null +++ b/admin/adminAppQueue.php @@ -0,0 +1,308 @@ +',"\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 '

Application Not Found!

',"\n"; + echo html_frame_end(" "); + } + + //process according to sub flag + if ($sub == 'view' && $queueId) + { + $x = new TableVE("view"); + + //help + echo "
\n\n"; + echo "

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.

\n"; + echo "

There are two kinds of applications in this database:

\n"; + echo "
    \n"; + echo "
  1. App Family This is a parent group application, that will have multiple versions under it.
    \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.
    \n"; + echo " If the vendor does not exist, leave the vendor drop down unset, and the field will be used.
  2. \n"; + echo "

  3. App Version This type of application will be nested under the selected application parent. The category,\n"; + echo " name, and vendor fields will be ignored.
  4. \n"; + echo "
\n\n"; + + //view application details + echo html_frame_start("New Application Form",400,"",0); + echo "\n"; + + //type + echo '',"\n"; + + //category + echo '',"\n"; + + //app parent + echo '',"\n"; + + //name + echo '',"\n"; + + //version + echo '',"\n"; + + //vendor + echo '',"\n"; + + //alt vendor + echo '',"\n"; + + //url + echo '',"\n"; + + //desc + echo '',"\n"; + + //echo '',"\n"; + //echo '',"\n"; + + echo '',"\n"; + echo '
Type',"\n"; + echo '',"\n"; + echo '
Category',"\n"; + $x->make_option_list("cat","","appCategory","catId","catName"); + echo '
App Parent',"\n"; + $x->make_option_list("appParent","","appFamily","appId","appName"); + echo '
App Name
App Version
App Vendor
 ',"\n"; + $x->make_option_list("altvendor","","vendor","vendorId","vendorName"); + echo '
App URL
App Desc
Email
Image
',"\n"; + echo '',"\n"; + echo '',"\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 = "

The application $queueName was successfully added into the database

\n"; + $goodtogo = 1; + } + else + { + //error + $statusMessage = "

Database Error!
".mysql_error()."

\n"; + $statusMessage .= "

Note: The application family was successfully added.

\n"; + } + + } + else + { + //error + $statusMessage = "

Database Error!
".mysql_error()."

\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 = "

The application $queueName was successfully added into the database

\n"; + mysql_query("DELETE from appQueue where queueId = $queueId;"); + $goodtogo = 1; + + } + else + { + //error + $statusMessage = "

Database Error!
".mysql_error()."

\n"; + } + } + else + { + $statusMessage = "

Error
You did not pick an application Parent!

\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 "

$statusMessage

\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 "

Internal Error: unable to delete selected application!

\n"; + } + else + { + //success + echo "

Application was successfully deleted from the Queue.

\n"; + } + echo html_frame_end(" "); + echo html_back_link(1,'adminAppQueue.php'); + } + else + { + //error no sub! + echo html_frame_start("Error","300"); + echo '

Internal Routine Not Found!

',"\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 '

The Application Queue is empty.

',"\n"; + echo '

There is nothing for you to do. Check back later.

',"\n"; + echo html_frame_end(" "); + } + else + { + //help + echo "
\n\n"; + echo "

This is the list of applications waiting for your approval, or to be annihilated from existence.

\n"; + echo "

To view a submission, click on its name. From that page you can edit, and approve it into the AppDB.
\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.

\n"; + echo "
\n\n"; + + //show applist + echo html_frame_start("","90%","",0); + echo "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c = 1; + while($ob = mysql_fetch_object($result)) + { + if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + $c++; + } + echo "
Application NameVersionVendorSubmitter Email 
$ob->queueName".stripslashes($ob->queueVersion)."  ".stripslashes($ob->queueVendor)."  ".stripslashes($ob->queueEmail)."  [delete]
\n\n"; + echo html_frame_end(" "); + } + +} + +echo ""; +apidb_footer(); + + +?> diff --git a/admin/deleteAny.php b/admin/deleteAny.php new file mode 100644 index 0000000..8230dcd --- /dev/null +++ b/admin/deleteAny.php @@ -0,0 +1,99 @@ +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"); +} + + +?> diff --git a/admin/editAppFamily.php b/admin/editAppFamily.php new file mode 100644 index 0000000..5f986ea --- /dev/null +++ b/admin/editAppFamily.php @@ -0,0 +1,93 @@ +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 "

query: $query

"; } + + if (mysql_query($query)) + { + //success + $statusMessage = "

The URL was successfully added into the database

\n"; + } + else + { + //error + $statusMessage = "

Database Error!
".mysql_error()."

\n"; + } + } + + // display status message + if ($statusMessage) + { + echo html_frame_start("Edit Application","300"); + echo "

$statusMessage

\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 "

query: $query

"; } + + $t->edit($query); + + //url entry box + echo '
',"\n"; + echo html_frame_start("Add URL","400","",0); + echo '',"\n"; + + echo '',"\n"; + echo '',"\n"; + + echo '',"\n"; + + echo '
URL
Description
',"\n"; + echo html_frame_end(); + echo '',"\n"; + echo '
',"\n"; + + echo html_back_link(1,$apidb_root."appview.php?appId=$appId"); + +} + +apidb_footer(); + +?> diff --git a/admin/editAppNote.php b/admin/editAppNote.php new file mode 100644 index 0000000..c21765f --- /dev/null +++ b/admin/editAppNote.php @@ -0,0 +1,46 @@ +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 "

query: $query

"; } + + $t->edit($query); + + echo html_back_link(1,$apidb_root."noteview.php?noteId=$noteId"); + +} + +apidb_footer(); + +?> diff --git a/admin/editAppOwners.php b/admin/editAppOwners.php new file mode 100644 index 0000000..37172cc --- /dev/null +++ b/admin/editAppOwners.php @@ -0,0 +1,120 @@ +\n"; + while($ob = mysql_fetch_object($result)) + { + echo "\n"; + } + echo "\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 "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c = 1; + while($ob = mysql_fetch_object($result)) + { + //set row color + if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; } + + $delete_link = "[delete]"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "
User Name Delete
$ob->username  $delete_link  
\n\n"; + echo html_frame_end(); + + } + + echo "
\n"; + + echo html_frame_start("Manually Add User","300",'',5); + echo "\n"; + echo "\n"; + echo html_frame_end(); + + + echo html_frame_start("User List","",'',2); + build_user_list(); + echo html_frame_end(); + + echo "\n"; + echo "\n"; + echo "
\n"; + + apidb_footer(); +} + + +?> diff --git a/admin/editAppVersion.php b/admin/editAppVersion.php new file mode 100644 index 0000000..b03f3a7 --- /dev/null +++ b/admin/editAppVersion.php @@ -0,0 +1,111 @@ +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 "

Screenshot: ($appId) file=$imagefile size=$imagefile_size\n"; + echo " name=$imagefile_name type=$imagefile_type
"; + } + + if(!copy($imagefile, "../data/screenshots/".basename($imagefile_name))) + { + // whoops, copy failed. do something + echo html_frame_start("Edit Application","300"); + echo "

debug: copy failed; $imagefile; $imagefile_name

\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 "

query: $query

"; } + + if (mysql_query($query)) + { + //success + $statusMessage = "

The image was successfully added into the database

\n"; + } + else + { + //error + $statusMessage = "

Database Error!
".mysql_error()."

\n"; + if(debugging()) { $statusMessage .= "

$query

"; } + } + + } + + // display status message + if ($statusMessage) + { + echo html_frame_start("Edit Application","300"); + echo "

$statusMessage

\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 "

query: $query

"; } + + $t->edit($query); + + + //image upload box + echo '
',"\n"; + echo html_frame_start("Upload Screenshot","400","",0); + echo '',"\n"; + + echo '',"\n"; + echo '',"\n"; + + echo '',"\n"; + + echo '
Image
Description
',"\n"; + echo html_frame_end(); + echo '',"\n"; + echo '',"\n"; + echo '',"\n"; + echo '
',"\n"; + + echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId"); + +} + +apidb_footer(); + +?> diff --git a/admin/editBundle.php b/admin/editBundle.php new file mode 100644 index 0000000..ba0cd4b --- /dev/null +++ b/admin/editBundle.php @@ -0,0 +1,98 @@ +\n"; + while($ob = mysql_fetch_object($result)) + { + echo "\n"; + } + echo "\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 "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c = 1; + while($ob = mysql_fetch_object($result)) + { + //set row color + if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; } + + $delete_link = "[delete]"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "
Application Name Delete
$ob->appName  $delete_link  
\n\n"; + echo html_frame_end(); + + } + + echo "
\n"; + + echo html_frame_start("Application List (double click to add)","",'',2); + build_app_list(); + echo html_frame_end(); + + echo "\n"; + echo "\n"; + echo "
\n"; + + apidb_footer(); +} + + +?> diff --git a/admin/editCategory.php b/admin/editCategory.php new file mode 100644 index 0000000..85fc771 --- /dev/null +++ b/admin/editCategory.php @@ -0,0 +1,42 @@ +update($HTTP_POST_VARS); +} +else +{ + $table = "appCategory"; + $query = "SELECT * FROM $table WHERE catId = $catId"; + + if(debugging()) + echo "$query

\n"; + + $t->edit($query); +} + +apidb_footer(); + +?> diff --git a/admin/editVendor.php b/admin/editVendor.php new file mode 100644 index 0000000..d80998d --- /dev/null +++ b/admin/editVendor.php @@ -0,0 +1,41 @@ +update($HTTP_POST_VARS); +} +else +{ + $table = "vendor"; + $query = "SELECT * FROM $table WHERE vendorId = $vendorId"; + + if(debugging()) + echo "$query

\n"; + + $t->edit($query); +} + +apidb_footer(); + +?> diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..3d73fd7 --- /dev/null +++ b/admin/index.php @@ -0,0 +1,78 @@ +\n"; + echo "\n"; +} + +//desc +function make_options($name, $options, $label = "Submit") +{ + echo "\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(); + +?> diff --git a/admin/path.php b/admin/path.php new file mode 100644 index 0000000..8e1d095 --- /dev/null +++ b/admin/path.php @@ -0,0 +1,3 @@ + diff --git a/apidb.css b/apidb.css new file mode 100644 index 0000000..aee6462 --- /dev/null +++ b/apidb.css @@ -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; } diff --git a/appbrowse.php b/appbrowse.php new file mode 100644 index 0000000..8e408bb --- /dev/null +++ b/appbrowse.php @@ -0,0 +1,140 @@ +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 "

Category: ". $catFullPath ."
\n"; + echo html_frame_end(); + + echo html_frame_start("","98%","",0); + echo "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\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 "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "
Sub CategoryDescriptionNo. Apps
".stripslashes($name)."$desc  $appcount  
\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 "

Category: ". $catFullPath ."
\n"; + echo html_frame_end(); + + echo html_frame_start("","98%","",0); + echo "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\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 "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "
Application NameDescriptionNo. Versions
".stripslashes($name)."$desc  $ob->versions  
\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(); + +?> diff --git a/appimage.php b/appimage.php new file mode 100644 index 0000000..14aa9c5 --- /dev/null +++ b/appimage.php @@ -0,0 +1,96 @@ +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); +} + +?> diff --git a/appsubmit.php b/appsubmit.php new file mode 100644 index 0000000..a517134 --- /dev/null +++ b/appsubmit.php @@ -0,0 +1,85 @@ +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 "

Error:

\n"; + echo "

$error

\n"; + } + else + { + echo "

Your application has been submitted for Review. You should hear back\n"; + echo "soon about the status of your submission

\n"; + } + +} +else +{ + // show add to queue form + + echo '
',"\n"; + + echo "

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.

\n"; + echo "

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 !

\n"; + echo "

To submit screenshots, please email them to "; + echo "appdb@winehq.com

\n"; + + echo html_frame_start("New Application Form",400,"",0); + + echo "\n"; + echo '',"\n"; + echo '',"\n"; + echo '',"\n"; + echo '',"\n"; + echo '',"\n"; + echo '',"\n"; + //echo '',"\n"; + echo '',"\n"; + echo '
App Name
App Version
App Vendor
App URL
App Desc
Email
Image
',"\n"; + + echo html_frame_end(); + + echo "
"; +} +apidb_footer(); + +?> diff --git a/appview.php b/appview.php new file mode 100644 index 0000000..b884d01 --- /dev/null +++ b/appview.php @@ -0,0 +1,420 @@ +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 = "No Screenshot"; + } + else + { + $ob = mysql_fetch_object($result); + $imgFile = "$ob->description"; + } + + $img = html_frame_start("",'128','',2); + $img .= "$imgFile"; + $img .= html_frame_end()."
"; + + return $img; +} + + +function display_catpath($catId) +{ + $cat = new Category($catId); + + $catFullPath = make_cat_path($cat->getCategoryPath()); + echo html_frame_start("",'98%','',2); + echo "

Category: ". $catFullPath ."
\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 "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\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 "\n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "
Application NameDescription
".stripslashes($ob->appName)."$desc  
\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 " Notes\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 " $c. ".substr(stripslashes($ob->noteTitle),0,30)."
\n"; + $c++; + } + + echo "\n"; +} + +/* display the versions */ +function display_versions($appId, $versions) +{ + if ($versions) + { + + echo html_frame_start("","98%","",0); + echo "\n\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\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 "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "
VersionDescriptionRating With WindowsRating Without WindowsComments
".$ver->versionName."$desc  $r_win$r_fake$r_count
\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) ? "".substr(stripslashes($data->webPage),0,30)."": " "; + + //set Image + $img = get_screenshot_img($appId, $versionId); + + //start display application + echo html_frame_start("","98%","",0); + + echo '',"\n"; + echo '',"\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //display notes + display_notes($appId); + + //main URL + echo "\n"; + + //optional links + $result = mysql_query("SELECT * FROM appData WHERE appId = $appId AND type = 'url'"); + if($result && mysql_num_rows($result) > 0) + { + echo "\n"; + } + + // display app owner + $result = mysql_query("SELECT * FROM appOwners WHERE appId = $appId"); + if($result && mysql_num_rows($result) > 0) + { + echo "\n"; + } + + echo "
Name ".stripslashes($data->appName)."
App Id ".$data->appId."
Vendor ". + " ".stripslashes($vendor->vendorName)."  \n"; + echo "
URL".$appLinkURL."
Links\n"; + while($ob = mysql_fetch_object($result)) + { + echo " ".substr(stripslashes($ob->description),0,30)."
\n"; + } + echo "
Owner\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 " ".substr(stripslashes($foo->username),0,30)."
\n"; + } + } + echo "
\n"; + + //Desc + echo "
Description
\n"; + echo add_br(stripslashes($data->description)); + + echo "
\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) ? "".substr(stripslashes($data->webPage),0,30)."": " "; + + //set image + $img = get_screenshot_img($appId, $versionId); + + //start version display + echo html_frame_start("","98%","",0); + + echo '',"\n"; + echo '',"\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //Rating Area + $r_win = rating_stars_for_version($versionId, "windows"); + $r_fake = rating_stars_for_version($versionId, "fake"); + + echo "\n"; + + //notes + display_notes($appId, $versionId); + + //Image + echo "\n"; + + echo "
Name".stripslashes($data->appName)."
Ver Id $ver->versionId
Version".stripslashes($ver->versionName)."
URL".stripslashes($appLinkURL)."
Rating $r_win \n"; + echo "
$r_fake
$img
\n"; + + //Desc Image + echo "
Description
\n"; + echo add_br(stripslashes($ver->description)); + echo "
\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(); + +?> diff --git a/banner/468x60/cw-ad01.gif b/banner/468x60/cw-ad01.gif new file mode 100644 index 0000000..b4328e9 Binary files /dev/null and b/banner/468x60/cw-ad01.gif differ diff --git a/banner/468x60/cw-ad02.gif b/banner/468x60/cw-ad02.gif new file mode 100644 index 0000000..e70660b Binary files /dev/null and b/banner/468x60/cw-ad02.gif differ diff --git a/banner/468x60/cw-ad04.gif b/banner/468x60/cw-ad04.gif new file mode 100644 index 0000000..3c648ff Binary files /dev/null and b/banner/468x60/cw-ad04.gif differ diff --git a/banner/xml/cw-ad01.xml b/banner/xml/cw-ad01.xml new file mode 100644 index 0000000..d5c9223 --- /dev/null +++ b/banner/xml/cw-ad01.xml @@ -0,0 +1,7 @@ + + + + cw-ad04 + http://www.codeweavers.com/products/crossover/?ad=1 + QuickTime for Linux! + diff --git a/banner/xml/cw-ad02.xml b/banner/xml/cw-ad02.xml new file mode 100644 index 0000000..321b43c --- /dev/null +++ b/banner/xml/cw-ad02.xml @@ -0,0 +1,7 @@ + + + + cw-ad04 + http://www.codeweavers.com/products/crossover/support_wine.php?ad=1 + Support the Wine Project! + diff --git a/banner/xml/cw-ad04.xml b/banner/xml/cw-ad04.xml new file mode 100644 index 0000000..2c1efdb --- /dev/null +++ b/banner/xml/cw-ad04.xml @@ -0,0 +1,7 @@ + + + + cw-ad04 + http://www.codeweavers.com/products/office/?ad=1 + Microsoft Office On Linux! + diff --git a/commentview.php b/commentview.php new file mode 100644 index 0000000..31c061a --- /dev/null +++ b/commentview.php @@ -0,0 +1,21 @@ + diff --git a/edituser.php b/edituser.php new file mode 100644 index 0000000..0c45eac --- /dev/null +++ b/edituser.php @@ -0,0 +1,55 @@ +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

\n"; + + $t->edit($query); +} + +apidb_footer(); + +?> diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..6b8f928 Binary files /dev/null and b/favicon.ico differ diff --git a/help/.cvsignore b/help/.cvsignore new file mode 100644 index 0000000..55d2fba --- /dev/null +++ b/help/.cvsignore @@ -0,0 +1,2 @@ +stderr + diff --git a/help/appdb_faq.help b/help/appdb_faq.help new file mode 100644 index 0000000..63aceda --- /dev/null +++ b/help/appdb_faq.help @@ -0,0 +1,66 @@ + + +

Application Database FAQ

+ +

This FAQ answers questions related to the usage of the +Application Database.

+ +
    + +

    Q: What is the Application Database?

    +
    +

    A: The Application Database is a repository for +compatibility information of applications for Microsoft Windows +running on Wine.

    +

    + +

    Q: What is Wine?

    +
    +

    A: Wine is an execution layer that allows Windows programs to be run +on Linux Systems. More information can be found at the +Wine FAQ.

    +

    + +

    Q: What is the benefit Application Database?

    +
    +

    A: 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.

    +

    + +

    Q: How does a new application get added to the database?

    +
    +

    A: 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.

    +

    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.

    +
    + +

    Q: How can I submit HowTo's and Screenshots?

    +
    +

    A: We love to hear from our users. Send those helpful HowTo's and +Screenshots right on over to appdb@winehq.com. +We'll be happy to post them, and give you proper credit for your great contribution.

    +
    + + +

    Q: How do I become an authorized application database maintainer.

    +
    +

    A: Pretty much anyone with an established reputation supporting Wine +is welcome (begged?) to be an application maintainer. +Simply send email to appdb@winehq.com +to apply. Once we have a community of maintainers, we hope that community +will further refine the policies and procedures.

    +
    + +
+ +If you have more questions you would like to add to our FAQ, please contact us +at appdb@winehq.com. + +

 

+ diff --git a/help/generic.help b/help/generic.help new file mode 100644 index 0000000..251f585 --- /dev/null +++ b/help/generic.help @@ -0,0 +1,54 @@ + + +This is meant as generic instructions in case an AppDB entry +for a certain program doesn't exist. + +
    + +
  1. Make sure your Wine release is pretty recent. +Current possibilities are:
  2. + +

      +
    • CodeWeavers Wine Preview + simple, complete configuration
    • +
    • TransGaming WineX, + Wine version with special DirectX support, use this one for games.
    • +
    • Misc. Wine packages/versions downloadable via + WineHQ
    • +
    +

    + +

  3. Run winecheck +(chmod +x winecheck; ./winecheck) +to verify the most important aspects of Wine environment +configuration
  4. + +

  5. Run your program
  6. + +

  7. 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.
  8. + +

  9. In case of persisting failure, check out +Wine Troubleshooting Guide +and read all of the available documentation at +WineHQ Support
  10. + +

  11. If that doesn't help, then ask people on +irc.openprojects.net +channel #WineHQ or on the +wine-users +mailing list.
  12. + +

  13. If you have more questions, please contact us +at appdb@codeweavers.com.
  14. + +

+ +

 

+ diff --git a/help/index.php b/help/index.php new file mode 100644 index 0000000..b80876f --- /dev/null +++ b/help/index.php @@ -0,0 +1,102 @@ +Providing all the help you need 24x7


\n"; + + echo "
    \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 "
  • $title
  • \n"; + } + + echo "


\n"; + + echo "

Need more help? Contact us at appdb@winehq.com

\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 "

No help available on that topic

\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("^$", $line, $arr)) + { + return $arr[1]; + } + return "Internal Error: missing title"; +} + +?> diff --git a/help/path.php b/help/path.php new file mode 100644 index 0000000..8e1d095 --- /dev/null +++ b/help/path.php @@ -0,0 +1,3 @@ + diff --git a/help/privacy.help b/help/privacy.help new file mode 100644 index 0000000..16dc8bb --- /dev/null +++ b/help/privacy.help @@ -0,0 +1,45 @@ + + +

Application DB Privacy Policy

+ +

+CodeWeavers is decidated to the privacy of its customers.
+

    + 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. +
+

+ +

+Cookies +

    + 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. +
+

+ +

+Changes to this Privacy Policy
+

    + 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. +
+

+ +

+Questions or Suggestions
+

    + If you have questions or suggestions, feel free to contact us at + appdb@winehq.com +
+

+ +

+NOTICE: Click here +for important information about safe surfing from the Federal Trade Commission. +

+ +

 

diff --git a/help/ratings.help b/help/ratings.help new file mode 100644 index 0000000..fcc7536 --- /dev/null +++ b/help/ratings.help @@ -0,0 +1,95 @@ + + +

Application Ratings System Help

+ +

+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. +

+ +
    + +
  1. Log into the Application Database.
  2. + +

  3. Browse to the Application you wish to rate.
  4. + +

  5. In the sidebar, choose whether you are rating Wine running + in Windows mode, or Fake Windows Mode.
    +
      +
    • With Windows With Windows = Wine Configured to use a Windows partition.
    • +
    • Without Windows Without Windows = Wine using its own internal Windows (Fake Windows).
    • +
    +
  6. + +

  7. In the sidebar, click the number of stars you want to + rate this application.
    +
      +
    • 0 -- Unrated. +
    • 1 -- Totally nonfunctional. Crashes on load. +
    • 2 -- Partial functionality. Good enough for a carefully scripted demo. +
    • 3 -- Sufficient functionality for noncritical work. Occasional crashes okay, + as are weird setup problems, required patches, or missing major functionality. + Alpha quality. +
    • 4 -- Substantially correct. Good enough for general use, with possible + caveats. +
    • 5 -- Perfect. No flaws under any mode +
    +
  8. + +

  9. Click the Rate! button to store your vote for this + application. +
  10. + +

+ + + How to rate an application
+ +Please 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. + +
    + +
  • First, figure out the name of the app, the vendor, and the product + version number.
  • + +

  • 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.
  • + +

  • 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. +
  • + +

  • If you don't normally use the app, stop here. Higher ratings should + only be given for app performance under actual use.
  • + +

  • 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 could do useful work with this app'' but + ``I have used this app for useful work, not just fooling around.''
  • + +

  • 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.
  • + +

  • After a new version of Wine, test the application again. If the app + improves or gets worse, come back and change your vote.
  • + +

+ +Remember: only you can prevent rating inflation. + +

 

diff --git a/help/voting.help b/help/voting.help new file mode 100644 index 0000000..30964fe --- /dev/null +++ b/help/voting.help @@ -0,0 +1,40 @@ + + +

Application Voting System Help

+ +

+The Application Database features a voting system that allows you to pick which 3 applications +you would MOST like to see running in Wine. +

+ +

Step by Step on Voting

+
    + +
  1. Log into the Application Database.
  2. + +

  3. Browse to the Application you wish to add to your vote list.
  4. + +

  5. In the sidebar, Click one of the 3 available slots, and click Vote.
  6. + +

  7. Done!
  8. + +
+ + +

Voting System Notes

+ +
    + +
  • Please 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.
  • + +

  • When voting for an application, you are voting for ALL its various versions. There is + a separate system in place for ranking versions.
  • + +

  • 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.
  • + +

+ +

 

diff --git a/images/appdb_montage.jpg b/images/appdb_montage.jpg new file mode 100644 index 0000000..f9cc46a Binary files /dev/null and b/images/appdb_montage.jpg differ diff --git a/images/back.gif b/images/back.gif new file mode 100644 index 0000000..abb3072 Binary files /dev/null and b/images/back.gif differ diff --git a/images/bk.gif b/images/bk.gif new file mode 100644 index 0000000..743ac5f Binary files /dev/null and b/images/bk.gif differ diff --git a/images/blank.gif b/images/blank.gif new file mode 100644 index 0000000..c080147 Binary files /dev/null and b/images/blank.gif differ diff --git a/images/compare.gif b/images/compare.gif new file mode 100644 index 0000000..b2d6268 Binary files /dev/null and b/images/compare.gif differ diff --git a/images/go.gif b/images/go.gif new file mode 100644 index 0000000..60ec749 Binary files /dev/null and b/images/go.gif differ diff --git a/images/grey_pixel.gif b/images/grey_pixel.gif new file mode 100644 index 0000000..bf677fd Binary files /dev/null and b/images/grey_pixel.gif differ diff --git a/images/list.gif b/images/list.gif new file mode 100644 index 0000000..54b1256 Binary files /dev/null and b/images/list.gif differ diff --git a/images/next.gif b/images/next.gif new file mode 100644 index 0000000..bbe694e Binary files /dev/null and b/images/next.gif differ diff --git a/images/no_screenshot.gif b/images/no_screenshot.gif new file mode 100644 index 0000000..74bdfe3 Binary files /dev/null and b/images/no_screenshot.gif differ diff --git a/images/remove.gif b/images/remove.gif new file mode 100644 index 0000000..13a3066 Binary files /dev/null and b/images/remove.gif differ diff --git a/images/s0.gif b/images/s0.gif new file mode 100644 index 0000000..21b6be5 Binary files /dev/null and b/images/s0.gif differ diff --git a/images/s1.gif b/images/s1.gif new file mode 100644 index 0000000..0bf6bfb Binary files /dev/null and b/images/s1.gif differ diff --git a/images/s2.gif b/images/s2.gif new file mode 100644 index 0000000..1205878 Binary files /dev/null and b/images/s2.gif differ diff --git a/images/tree.gif b/images/tree.gif new file mode 100644 index 0000000..e4e818c Binary files /dev/null and b/images/tree.gif differ diff --git a/images/w0.gif b/images/w0.gif new file mode 100644 index 0000000..ab10835 Binary files /dev/null and b/images/w0.gif differ diff --git a/images/w1.gif b/images/w1.gif new file mode 100644 index 0000000..70ea8f2 Binary files /dev/null and b/images/w1.gif differ diff --git a/images/winehq_border_bottom_left.gif b/images/winehq_border_bottom_left.gif new file mode 100644 index 0000000..e633092 Binary files /dev/null and b/images/winehq_border_bottom_left.gif differ diff --git a/images/winehq_border_bottom_right.gif b/images/winehq_border_bottom_right.gif new file mode 100644 index 0000000..41e12a1 Binary files /dev/null and b/images/winehq_border_bottom_right.gif differ diff --git a/images/winehq_border_dot_left.gif b/images/winehq_border_dot_left.gif new file mode 100644 index 0000000..1fa3ff0 Binary files /dev/null and b/images/winehq_border_dot_left.gif differ diff --git a/images/winehq_border_dot_right.gif b/images/winehq_border_dot_right.gif new file mode 100644 index 0000000..4e75cdd Binary files /dev/null and b/images/winehq_border_dot_right.gif differ diff --git a/images/winehq_border_top_left.gif b/images/winehq_border_top_left.gif new file mode 100644 index 0000000..6a51eb0 Binary files /dev/null and b/images/winehq_border_top_left.gif differ diff --git a/images/winehq_border_top_right.gif b/images/winehq_border_top_right.gif new file mode 100644 index 0000000..9150224 Binary files /dev/null and b/images/winehq_border_top_right.gif differ diff --git a/images/winehq_top_logo.gif b/images/winehq_top_logo.gif new file mode 100644 index 0000000..92182b7 Binary files /dev/null and b/images/winehq_top_logo.gif differ diff --git a/include/.cvsignore b/include/.cvsignore new file mode 100644 index 0000000..55d2fba --- /dev/null +++ b/include/.cvsignore @@ -0,0 +1,2 @@ +stderr + diff --git a/include/appbyvendor_inc.php b/include/appbyvendor_inc.php new file mode 100644 index 0000000..fe0a21b --- /dev/null +++ b/include/appbyvendor_inc.php @@ -0,0 +1,58 @@ + + "; + + foreach($fields as $aField) + { + echo ""; + } + + echo ""; +} + +?> diff --git a/include/appdb.php b/include/appdb.php new file mode 100644 index 0000000..a85ffe0 --- /dev/null +++ b/include/appdb.php @@ -0,0 +1,35 @@ +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)"); + } +} + +?> diff --git a/include/application.php b/include/application.php new file mode 100644 index 0000000..087a9a3 --- /dev/null +++ b/include/application.php @@ -0,0 +1,78 @@ +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; + } +} diff --git a/include/appversion_inc.php b/include/appversion_inc.php new file mode 100644 index 0000000..6591fa6 --- /dev/null +++ b/include/appversion_inc.php @@ -0,0 +1,61 @@ + + "; + + foreach($fields as $aField) + { + echo ""; + } + + echo ""; +} + +?> diff --git a/include/banner.php b/include/banner.php new file mode 100644 index 0000000..044ed5b --- /dev/null +++ b/include/banner.php @@ -0,0 +1,55 @@ + + * 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".''."\n"; + $banner .= '
'."\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 .= ''; + $banner .= ''.$alt.''; + $banner .= ''."\n"; + + // closing html + $banner .= '
'."\n"; + $banner .= ''."\n\n"; + + return $banner; + +} + +?> diff --git a/include/category.php b/include/category.php new file mode 100644 index 0000000..eae9471 --- /dev/null +++ b/include/category.php @@ -0,0 +1,208 @@ +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 ""; // 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 ""; // 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; +} + +?> diff --git a/include/comments.php b/include/comments.php new file mode 100644 index 0000000..48ee412 --- /dev/null +++ b/include/comments.php @@ -0,0 +1,251 @@ +email) + { + $mailto = '' . $ob->username . ''; + } + else + { + $mailto = $ob->username; + } + + echo html_frame_start('','98%'); + echo '',"\n"; + + $ob->subject = stripslashes($ob->subject); + $ob->body = stripslashes($ob->body); + + // message header + echo "
\n"; + echo " $ob->subject
\n"; + echo " by $mailto on $ob->time
\n"; + echo "
\n"; + + // body + echo htmlify_urls($ob->body), "

\n"; + + // only add RE: once + if(eregi("RE:", $ob->subject)) + $subject = $ob->subject; + else + $subject = "RE: $ob->subject"; + + // reply post buttons + echo " [post new] \n"; + echo " [reply to this] \n"; + + echo "
\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 "
\n"; + do_display_comments_nested($result); + echo "
\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 "
    \n"; + + while($ob = mysql_fetch_object($handle)) + { + if($is_main) + view_app_comment($ob); + else + echo "
  • ". + " $ob->subject by $ob->username on $ob->time
  • \n"; + $result = grab_comments($ob->appId, $ob->versionId, $ob->commentId); + if($result && mysql_num_rows($result)) + { + echo "
    \n"; + do_display_comments_threaded($result, 0); + echo "
    \n"; + } + } + if(!$is_main) + echo "
\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 '',"\n"; + + echo '',"\n"; + echo '
',"\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 '',"\n"; + } + + // blank space + echo '',"\n"; + + // post new message button + echo '',"\n"; + + //end comment format table + echo '
',"\n"; + echo "Application Comments $messageCount total comments "; + echo 'Mode ',"\n"; + echo '
 
',"\n"; + echo '
',"\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 '
',"\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 '
',"\n"; + +} + + +?> diff --git a/include/config.php b/include/config.php new file mode 100644 index 0000000..fe30761 --- /dev/null +++ b/include/config.php @@ -0,0 +1,27 @@ + diff --git a/include/db.php b/include/db.php new file mode 100644 index 0000000..a708c37 --- /dev/null +++ b/include/db.php @@ -0,0 +1,35 @@ + diff --git a/include/footer.php b/include/footer.php new file mode 100644 index 0000000..6627b08 --- /dev/null +++ b/include/footer.php @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/include/form_edit.php b/include/form_edit.php new file mode 100644 index 0000000..b5bb103 --- /dev/null +++ b/include/form_edit.php @@ -0,0 +1,41 @@ + + + + + +   User Name + + + +   Password + + + +   Password (again) + + + +   Real Name + + + +   Email Address + + + +   + + + + + diff --git a/include/form_login.php b/include/form_login.php new file mode 100644 index 0000000..8a9e5cd --- /dev/null +++ b/include/form_login.php @@ -0,0 +1,61 @@ +',"\n"; +echo html_frame_start("Login to Application DB","400","",0) + +?> + + + + + + + + + + + + + + + + + +
User Name
Password
+ +
+ + + +',"\n"; +echo '',"\n"; +echo '',"\n"; + +?> + +

Don't have an account yet?
+ [Create a New Account]

+ +

Lost your password?
+ [Email a New Password]

+ + diff --git a/include/form_new.php b/include/form_new.php new file mode 100644 index 0000000..2a1bbe7 --- /dev/null +++ b/include/form_new.php @@ -0,0 +1,53 @@ +',"\n"; +echo html_frame_start("Create New Application DB Account","400","",0) + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
User Name
Password
Password (again)
Real Name
Email Address
+ +
+ + +',"\n"; +echo '',"\n"; + +echo p(),p(),p(); + +?> diff --git a/include/header.php b/include/header.php new file mode 100644 index 0000000..9e02439 --- /dev/null +++ b/include/header.php @@ -0,0 +1,51 @@ + + + + + + + + Wine Application DB <?=$title?> + + + + + + + + + + + + + +
+ + + + + + + +
Wine HQ + + + + + +
+ +
+ +
+
+ diff --git a/include/html.php b/include/html.php new file mode 100644 index 0000000..3a49f72 --- /dev/null +++ b/include/html.php @@ -0,0 +1,351 @@ + 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("", 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)." ", 0); + } + } + $str .= do_indent("", -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("", 1); +} + +function html_table_end() +{ + return do_indent("
", -1); +} + + +// HTML HTML +function html_begin() +{ + return do_indent("", 1); +} + +function html_end() +{ + return do_indent("", -1); +} + + +// HTML HEAD +function html_head($title, $stylesheet = 0) +{ + $str = do_indent("", 1); + $str .= do_indent(" $title ", 0); + if($stylesheet) + $str .= do_indent("", 0); + $str .= do_indent("", -1); + + return $str; +} + + +// HTML BODY +function html_body_begin() +{ + return do_indent("", 1); +} + +function html_body_end() +{ + return do_indent("", -1); +} + + +// HTML BR +function html_br($count = 1) +{ + return do_indent(str_repeat("
", $count)); +} + +// HTML A HREF +function html_ahref($label, $url, $extra = "") +{ + $label = stripslashes($label); + if (!$label and $url) + { + return do_indent(" $url "); + } + else if (!$label) + { + return do_indent("   "); + } + else + { + return do_indent(" $label "); + } +} + +// HTML echo a string +function html_echo($str) +{ + return do_indent($str); +} + +// HTML B (bold) +function html_b($str) +{ + return do_indent("$str"); +} + +// HTML SMALL (small text) +function html_small($str) +{ + return do_indent("$str"); +} + +// HTML P +function html_p() +{ + return do_indent("

"); +} + +function html_line($thickness = 1, $colspan = 1, $color = "#000000") +{ + return do_indent(" ". + " "); +} + + + +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\n $text \n"; +} + + +function html_frame_start($title = "", $width = "", $extra = "", $innerPad = 5) +{ + + global $apidb_root; + + if ($width) { $width = 'width="'.$width.'"'; } + +$str .= ''."\n"; + +if ($title) +{ +$str .= ' + +'; +} + +$str .= ' + + + + + +
+ +
+ + + + + + + + + + + + + + + + +
'.$title.'
+
- + +
+
+'; + + return $str; +} + +function html_frame_end($text = "") +{ + global $apidb_root; + +$str = ' +
+
-
+
+'; + + return $str; +} + + +function html_select($name, $values, $default = null, $descs = null) +{ + $str = "\n"; + + return $str; +} + +function html_back_link($howmany = 1, $url = "") +{ + if (!$url) + { + $url = 'javascript:history.back('.$howmany.');'; + } + return '

   << Back

'."\n"; +} + + +function p() +{ + return "\n

 

\n"; +} + +function add_br($text = "") +{ + $text = ereg_replace("\n","
\n",$text); + return $text; +} + +function make_dll_option_list($varname, $dllid = -1) +{ + $db = new ApiDB(); + + echo "\n"; +} + + +function make_inx_option_list($varname, $inx = null) +{ + $list = array("yes", "no", "stub", "unknown"); + echo "\n"; + +} + + +function make_quality_option_list($varname, $quality) +{ + $list = array(-1, 1, 2, 3, 4, 5); + echo "\n"; +} + +?> diff --git a/include/incl.php b/include/incl.php new file mode 100644 index 0000000..3632475 --- /dev/null +++ b/include/incl.php @@ -0,0 +1,241 @@ +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 "\n"; + echo "\n"; + echo "\n"; + echo "\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 "
$text
\n"; + echo "

$message

\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 = " $text \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 "
$r->message
"; + echo html_frame_end(" "); + echo "
\n"; + } + + mysql_query("DELETE FROM sessionMessages WHERE sessionId = '$PHPSESSID'"); +} + +?> diff --git a/include/menu.php b/include/menu.php new file mode 100644 index 0000000..de5e392 --- /dev/null +++ b/include/menu.php @@ -0,0 +1,77 @@ +\n"; + +echo ' +
+
\n"; + apidb_sidebar(); + echo "\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 "
+ + + + + + + +
+ + + + + + + + + + + + +
  '.$name.'
+
+ + +
+ +'; + + } + + /* add a table row */ + function add($name, $url = null) + { + if($url) + { + echo " \n"; + } else { + echo " \n"; + } + } + + function addmisc($stuff, $align = "left") + { + echo " \n"; + } + + function done($form = null) + { + global $apidb_root; + +echo ' +
 $name
 $name
 $stuff
+
+
-
+ +
+'; + + if ($form) + echo "\n"; + + } +} +?> diff --git a/include/parsedate.php b/include/parsedate.php new file mode 100644 index 0000000..dfa8326 --- /dev/null +++ b/include/parsedate.php @@ -0,0 +1,81 @@ + 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)
"; + + /* 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'
\n"; + + } + + return mktime($hour, $minute, $second, $month, $day, $year); +} + +?> diff --git a/include/pn_buttons.php b/include/pn_buttons.php new file mode 100644 index 0000000..716c093 --- /dev/null +++ b/include/pn_buttons.php @@ -0,0 +1,76 @@ + 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 "
".html_small("listing $numRows record".($numRows == 1 ? "" : "s")." ".($curPos+1)." to $endpos of $totalCount total"); +} + +?> diff --git a/include/qclass.php b/include/qclass.php new file mode 100644 index 0000000..79fffd0 --- /dev/null +++ b/include/qclass.php @@ -0,0 +1,246 @@ + "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
\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]
\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); + } +} diff --git a/include/query_appbyvendor.php b/include/query_appbyvendor.php new file mode 100644 index 0000000..51c5476 --- /dev/null +++ b/include/query_appbyvendor.php @@ -0,0 +1,37 @@ + + + + + + + + +
Search Apps by Vendor +
+
+ Vendor Name: + (leave blank to match all) + +

+ Verbose query results
+ Edit mode
\n"; ?> + +
Entries Per Page: + +
+
+
+ + diff --git a/include/query_apps.php b/include/query_apps.php new file mode 100644 index 0000000..9b04132 --- /dev/null +++ b/include/query_apps.php @@ -0,0 +1,53 @@ + + + + + + + + + +
Search Apps +
+
+ + App Name: + (leave blank to match all) + + + + +

+ Verbose query results
+ Edit mode
\n"; ?> + +
Rating + or higher + + + +
Entries Per Page: + +
+
+
+ + diff --git a/include/query_inc.php b/include/query_inc.php new file mode 100644 index 0000000..09d16ca --- /dev/null +++ b/include/query_inc.php @@ -0,0 +1,189 @@ +"; + + // Only permit sql SELECT statements + if(!eregi("^select .*$", $query)) + { + echo " Invalid SQL Query "; + echo "
$query
"; + 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 " QUERY TIME: $tstamp seconds
\n"; + + // query error! + if(!$result) + { + echo "$query

\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)", + "
\\1
", $tmpq); + echo "
$str
\n"; + } + + echo html_echo("
"); + + 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[] = "
$val
"; + } + 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("
"); + + mysql_free_result($result); + closedb(); +} + + +?> + diff --git a/include/query_users.php b/include/query_users.php new file mode 100644 index 0000000..b5c9259 --- /dev/null +++ b/include/query_users.php @@ -0,0 +1,59 @@ + + + + +
+ + + + + + + + + + + + + + + + + +
Pattern
(leave blank to match all)
Entries Per Page + +
+ + + + + + + + +
+ + + + diff --git a/include/query_vendors.php b/include/query_vendors.php new file mode 100644 index 0000000..0b2de0b --- /dev/null +++ b/include/query_vendors.php @@ -0,0 +1,37 @@ + + + + + + + + + +
Search Vendors +
+
+ + Pattern: + (leave blank to match all) + + + + +

+ Verbose query results
+ Edit mode
\n"; ?> + +
Entries Per Page: + +
+
+
+ + diff --git a/include/rating.php b/include/rating.php new file mode 100644 index 0000000..6622ce5 --- /dev/null +++ b/include/rating.php @@ -0,0 +1,210 @@ +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 = 's1'; + $n = '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("". + "". + "". + "
With Windows With WindowsWithout Windows Without Windows
"); + + $j->addmisc("".$n.$n.$n.$n.$n."","center"); + $j->addmisc("".$s.$n.$n.$n.$n."","center"); + $j->addmisc("".$s.$s.$n.$n.$n."","center"); + $j->addmisc("".$s.$s.$s.$n.$n."","center"); + $j->addmisc("".$s.$s.$s.$s.$n."","center"); + $j->addmisc("".$s.$s.$s.$s.$s."","center"); + + + $j->addmisc("","center"); + $j->addmisc(""); + + $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 = 's1'; + $n = 's0'; + $h = '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 = "$alt_desc ".$str."
"."unrated".""; + 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 = "$alt_desc ".$result. + "
".substr($r->rating,0,4). + " (".$r->hits." votes) ".""; + + 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"); + } +} + +?> diff --git a/include/session.php b/include/session.php new file mode 100644 index 0000000..73b85c7 --- /dev/null +++ b/include/session.php @@ -0,0 +1,113 @@ +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"); + +?> diff --git a/include/sidebar.php b/include/sidebar.php new file mode 100644 index 0000000..28713cc --- /dev/null +++ b/include/sidebar.php @@ -0,0 +1,41 @@ +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 .= "
\n"; + $str .= ""; + $str .= "\n"; + $str .= "
\n"; + return $str; +} + +?> diff --git a/include/sidebar_admin.php b/include/sidebar_admin.php new file mode 100644 index 0000000..6915859 --- /dev/null +++ b/include/sidebar_admin.php @@ -0,0 +1,26 @@ +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(); + +} + +?> diff --git a/include/sidebar_login.php b/include/sidebar_login.php new file mode 100644 index 0000000..8193dbe --- /dev/null +++ b/include/sidebar_login.php @@ -0,0 +1,28 @@ +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(); + +} + +?> diff --git a/include/tableve.php b/include/tableve.php new file mode 100644 index 0000000..cb68493 --- /dev/null +++ b/include/tableve.php @@ -0,0 +1,503 @@ +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
Fields: $nfields
Rows: $nrows

\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
\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 "
\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 "\n"; + //echo "\n"; + + //echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c = 0; + while($ob = mysql_fetch_object($result)) + { + //skip if a NONAME + if ($ob->appName == "NONAME") { continue; } + + //set row color + if ($c % 2 == 1) { $bgcolor = '#E0E0E0'; } else { $bgcolor = '#EFEFEF'; } + + //count versions + $query = mysql_query("SELECT count(*) as versions FROM appVersion WHERE appId = $ob->appId AND versionName != 'NONAME'"); + $y = mysql_fetch_object($query); + + //format desc + $desc = substr(stripslashes($ob->description),0,75); + + //display row + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n\n"; + + $c++; + } + + echo "\n"; + echo "
\n"; + + echo html_frame_start("Viewing $titleValue $titleText","80%","",0); + echo "\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 "\n"; + $cur_impl = $arr[1]; + } + + echo ""; + echo "\n"; + } + + echo "
".ucfirst($arr[1])." Implementation
$field->name "; + $this->view_entry_output_field($field, $fields[$i], 0); + echo "
\n"; + echo html_frame_end(); + + } + + + function edit($query) + { + $result = mysql_query($query); + if(!$result) + echo "Oops: ".mysql_error()."
$query
\n"; + $nrows = mysql_num_rows($result); + + echo "
\n"; + + for($i = 0; $i < $nrows; $i++) + { + $this->edit_entry($result); + echo "
\n"; + } + + echo html_frame_start("Update Database",100); + echo "\n"; + echo html_frame_end(); + + echo "
\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 "\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 "\n"; + $cur_impl = $arr[1]; + } + + echo ""; + echo "\n"; + } + + echo "
".ucfirst($arr[1])." Implementation
$field->name    "; + $this->edit_entry_output_field($field, $fields[$i], $len); + echo "
\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 "\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 "\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 "\n"; + return; + } + + switch($field->type) + { + case "string": + case "enum": + case "int": + case "text": + echo "\n"; + break; + case "blob": + echo "\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
\n"; + if(ereg($r, $name)) + { + //echo "ID for $name -> $id
\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 " $table (".$this->get_id($table).") "; + + if($fieldnames[$this->get_id($table)]) + echo "OK!"; + + echo "
\n"; + + for($i = 0; $i < sizeof($fields); $i++) + echo "- $fields[$i]
\n"; + + echo "
\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 = "

Query:: $update

\n"; + $thisError .= "

".mysql_error()."

"; + 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; + } + +}; + +?> diff --git a/include/user.php b/include/user.php new file mode 100644 index 0000000..9de9a42 --- /dev/null +++ b/include/user.php @@ -0,0 +1,319 @@ +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)."
\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 "
User: $this->userid ($this->username, $this->realname)
\n"; + return 0; + } + + + function login($username, $password) + { + $result = $this->restore($username, $password); + + if($result != null) + return $result; + //echo "
LOGIN($this->username)
\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 " $text \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); +} + +?> diff --git a/include/util.php b/include/util.php new file mode 100644 index 0000000..582f266 --- /dev/null +++ b/include/util.php @@ -0,0 +1,174 @@ +\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 "
$query

\n"; + echo "A QUERY error occurred: ". + "".mysql_error()."

\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
"; + $arr[] = rawurlencode($key."[]")."=".rawurlencode($value); + } + } + else + $arr[] = $key."=".rawurlencode($val); + } + return implode("&", $arr); +} + + +function add_option_menu($options, $label, $id) +{ + echo "

\n"; + echo "\n"; + echo "\n"; + echo "

\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, ",,,
    ,
  • "); + + // html-ify urls + $urlreg = "([a-zA-Z]+://([^\t\r\n ]+))"; + $text = ereg_replace($urlreg, " \\2 ", $text); + + $emailreg = "([a-zA-Z0-9_%+.-]+@[^\t\r\n ]+)"; + $text = ereg_replace($emailreg, " \\1", $text); + + $text = str_replace("\n", "
    ", $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 . ">(.*)", $data, $out)) + { + return $out[1]; + } + } + else + { + return null; + } +} + +?> diff --git a/include/vote.php b/include/vote.php new file mode 100644 index 0000000..3360fcd --- /dev/null +++ b/include/vote.php @@ -0,0 +1,199 @@ +userid; + else + return 0; + } + $result = mysql_query("SELECT * FROM appVotes WHERE appId = $appId AND userId = $userId"); + return mysql_num_rows($result); +} + +/* + * total votes by userId + */ +function vote_count_user_total($userId = null) +{ + global $current; + + if(!$userId) + { + if(loggedin()) + $userId = $current->userid; + else + return 0; + } + $result = mysql_query("SELECT * FROM appVotes WHERE userId = $userId"); + return mysql_num_rows($result); +} + +/* + * total votes for appId + */ +function vote_count_app_total($appId) +{ + $result = mysql_query("SELECT * FROM appVotes WHERE appId = $appId"); + return mysql_num_rows($result); +} + + + + +/* + * add a vote for appId + */ +function vote_add($appId, $slot, $userId = null) +{ + global $current; + global $MAX_VOTES; + + if(!$userId) + { + if(loggedin()) + $userId = $current->userid; + else + return; + } + + //if(vote_count_user_total($userId) >= $MAX_VOTES) + // return; + vote_remove($appId, $slot, $userId); + mysql_query("INSERT INTO appVotes VALUES (null, null, $appId, $userId, $slot)"); +} + + +/* + * remove vote for appId + */ +function vote_remove($appId, $slot, $userId = null) +{ + global $current; + + if(!$userId) + { + if(loggedin()) + $userId = $current->userid; + else + return; + } + mysql_query("DELETE FROM appVotes WHERE appId = $appId AND userId = $userId AND slot = $slot"); +} + +function vote_get_user_votes($userId = null) +{ + global $current; + + if(!$userId) + { + if(loggedin()) + $userId = $current->userid; + if(!$userId) + return array(); + } + $result = mysql_query("SELECT * FROM appVotes WHERE userId = $userId"); + if(!$result) + return array(); + + $obs = array(); + while($ob = mysql_fetch_object($result)) + $obs[$ob->slot] = $ob; + return $obs; +} + +function vote_menu() +{ + global $appId; + global $apidb_root; + + $m = new htmlmenu("Votes","updatevote.php"); + + $votes = vote_get_user_votes(); + + if($votes[1]) + { + $str = " App #".$votes[1]->appId.""; + $m->add(" ".$str); + } + else + $m->add(" No App Selected"); + + if($votes[2]) + { + $str = " App #".$votes[2]->appId.""; + $m->add(" ".$str); + } + else + $m->add(" No App Selected"); + + if($votes[3]) + { + $str = " App #".$votes[3]->appId.""; + $m->add(" ".$str); + } + else + $m->add(" No App Selected"); + + $m->addmisc(" "); + + $m->add(""); + $m->add(""); + + $m->addmisc(""); + + $m->add("View Results", $apidb_root."votestats.php"); + $m->add("Voting Help", $apidb_root."help/?topic=voting"); + + $m->done(1); +} + + +function dump($arr) +{ + while(list($key, $val) = each($arr)) + { + echo "$key => $val
    \n"; + } +} + +function vote_update($vars) +{ + global $current; + + //FIXME this doesn't work since msgs only work when logged in + if(!$current) + { + addmsg("You must be logged in to vote", "red"); + return; + } + + dump($vars); + echo "
    \n"; + + if($vars["vote"]) + { + addmsg("Registered vote for App #".$vars["appId"], "green"); + vote_add($vars["appId"], $vars["slot"]); + } + else + if($vars["clear"]) + { + addmsg("Removed vote for App #".$vars["appId"], "green"); + vote_remove($vars["appId"], $vars["slot"]); + } +} + + +?> diff --git a/index.php b/index.php new file mode 100644 index 0000000..56b49ee --- /dev/null +++ b/index.php @@ -0,0 +1,70 @@ + + + Wine AppDB + +

    Welcome

    + +

    This is the Wine Application Database. From here you get info on application + compatibility with Wine. For developers, you can get information on the APIs used in an + application.

    + +

    Most of the features of the Application database require that you have a user account and + are logged in. Some of the benefits of membership are:

    + +

      +
    • Ability to Vote on Favorite Applications
    • +
    • Access to the Application Rating System. Rate the apps that "Don't Suck"
    • +
    • Ability to customize the View of the Apps DB and Comment System
    • +
    • Take Credit for your witty posts.
    • +
    + +

    So what are you waiting for, [login now]. Your help in + stomping out Wine issues will be greatly appreciated.

    + +

    + If you have anything to contribute (screenshots, howtos), contact us at: + appdb@winehq.com +

    +hits; + + $voteQuery = "SELECT appVotes.appId, appName, count(userId) as count ". + "FROM appVotes, appFamily ". + "WHERE appVotes.appId = appFamily.appId ". + "GROUP BY appId ORDER BY count DESC LIMIT 1"; + $result = mysql_query($voteQuery); + $ob = mysql_fetch_object($result); + + $voteAppId = $ob->appId; + $voteAppName = $ob->appName; + + + echo "There are $numApps applications currently in the database with\n"; + echo "$voteAppName being the\n"; + echo "top voted application.\n"; + + echo "

     

    \n"; + +apidb_footer(); + + + + +?> diff --git a/noteview.php b/noteview.php new file mode 100644 index 0000000..bb84d92 --- /dev/null +++ b/noteview.php @@ -0,0 +1,60 @@ +add("Edit this Note", $apidb_root."admin/editAppNote.php?noteId=$noteId"); + $m->done(); +} + +//do query +$result = mysql_query("SELECT noteTitle, noteDesc FROM appNotes WHERE noteId = $noteId"); +$ob = mysql_fetch_object($result); + +//die if error +if(!$result || mysql_num_rows($result) == 0) +{ + // error + errorpage("No Note Found","The selected note was not found."); + exit; +} + +//display admin menu +if(loggedin() && (havepriv("admin") || $current->ownsApp($appId))) { + apidb_sidebar_add("admin_menu"); +} + +//show page +apidb_header(); + +echo html_frame_start("View Note - $ob->noteTitle ","80%"); + +echo add_br(stripslashes($ob->noteDesc)); + +echo html_frame_end(); + +if ($versionId) +{ + echo html_back_link(1,"appview.php?appId=$appId&versionId=$versionId"); +} +else +{ + echo html_back_link(1,"appview.php?appId=$appId"); +} + +apidb_footer(); + +?> diff --git a/path.php b/path.php new file mode 100644 index 0000000..2a71d45 --- /dev/null +++ b/path.php @@ -0,0 +1,3 @@ + diff --git a/preferences.php b/preferences.php new file mode 100644 index 0000000..3111000 --- /dev/null +++ b/preferences.php @@ -0,0 +1,106 @@ +name == "query:mode") + continue; + if($r->name == "sidebar") + continue; + if($r->name == "window:query") + continue; + if($r->name == "query:hide_header") + continue; + if($r->name == "query:hide_sidebar") + continue; + if($r->name == "debug") + continue; + } + + $input = html_select("pref_$r->name", explode('|', $r->value_list), + $current->getpref($r->name, $r->def_value)); + echo html_tr(array("  $r->description", $input)); + } +} + +function show_user_fields() +{ + global $current; + $user = new User(); + + $ext_username = $current->username; + $ext_realname = $user->lookup_realname($current->userid); + $ext_email = $user->lookup_email($current->userid); + + include(BASE."include/"."form_edit.php"); +} + +if($HTTP_POST_VARS) +{ + global $ext_username, $ext_password1, $ext_password2, $ext_realname, $ext_email; + global $current; + + $user = new User(); + + while(list($key, $value) = each($HTTP_POST_VARS)) + { + if(!ereg("^pref_(.+)$", $key, $arr)) + continue; + $current->setpref($arr[1], $value); + } + + if ($ext_password == $ext_password2) + { + $passwd = $ext_password; + } + else if ($ext_password) + { + addmsg("The Passwords you entered did not match.", "red"); + } + + if ($user->update($current->userid, $passwd, $ext_realname, $ext_email)) + { + addmsg("Preferences Updated", "green"); + } + else + { + addmsg("There was a problem updating your userinfo", "red"); + } +} + +apidb_header("User Preferences"); + +echo "
    \n"; +echo html_frame_start("Preferences for $current->username", "80%"); +echo html_table_begin("width='100%' border=0 align=left cellspacing=0 class='box-body'"); + +show_user_fields(); +build_prefs_list(); + +echo html_table_end(); +echo html_frame_end(); +echo "

    \n"; +echo "
    \n"; + + +apidb_footer(); +?> diff --git a/screenshots.php b/screenshots.php new file mode 100644 index 0000000..dba9d94 --- /dev/null +++ b/screenshots.php @@ -0,0 +1,103 @@ +\n"; + while($ob = mysql_fetch_object($result)) + { + //set img tag + $imgSRC = ''.$ob->description.''; + + //get image size + $size = getimagesize("data/screenshots/".$ob->url); + + //generate random tag for popup window + $randName = generate_passwd(5); + + //set image link based on user pref + $img = ''.$imgSRC.''; + if (loggedin()) + { + if ($current->getpref("window:screenshot") == "no") + { + $img = ''.$imgSRC.''; + } + } + + //display image + echo "\n"; + + //end row if counter of 3 + if ($c % 3 == 0) { echo "\n"; } + + $c++; + } + echo "
    \n"; + echo html_frame_start(substr(stripslashes($ob->description),0,20),128,"",0); + echo $img; + + //show admin delete link + if(loggedin() && (havepriv("admin") || $current->ownsApp($appId))) + { + echo ""; + } + + echo html_frame_end(" "); + echo "

    \n"; + + + echo html_frame_end("Click thumbnail to view image in new window."); + + echo html_back_link(1); + + apidb_footer(); + +} + +?> diff --git a/scripts.js b/scripts.js new file mode 100644 index 0000000..5f9ee23 --- /dev/null +++ b/scripts.js @@ -0,0 +1,18 @@ + +function openWin(fileToOpen,nameOfWindow,width,height) { + myWindow = window.open("",nameOfWindow,"menubar=no,scrollbars=yes,status=no,width="+width+",height="+height); + myWindow.document.open(); + myWindow.document.write('ScreenShot Viewer') + myWindow.document.write(''); + myWindow.document.write(''); + myWindow.document.write(''); + myWindow.document.close(); +} + +function deleteURL(text, url) { + if (confirm(text)) { + self.location = url; + } +} + + diff --git a/search.php b/search.php new file mode 100644 index 0000000..16282e8 --- /dev/null +++ b/search.php @@ -0,0 +1,66 @@ +\n\n"; + + echo "
Application NameDescriptionNo. Versions
".html_ahref($ob->appName,"appview.php?appId=$ob->appId")."$desc  $y->versions  
$c match(es) found
\n\n"; +} + +apidb_footer(); + +?> diff --git a/stdquery.php b/stdquery.php new file mode 100644 index 0000000..589b4b4 --- /dev/null +++ b/stdquery.php @@ -0,0 +1,125 @@ +getpref("query:hide_header") == "yes") + disable_header(); + if($current->getpref("query:hide_sidebar") == "yes") + disable_sidebar(); +} + + +// create $vars object +$vars = $HTTP_GET_VARS; +$qc = new qclass(); +$qc->process($vars); +$query = $qc->get_query(); + + +// set default lines per page +if(!$linesPerPage) +{ + $linesPerPage = 20; +} +$vars["linesPerPage"] = $linesPerPage; + + +// set default currrent posistion +if(!$curPos) +{ + $curPos = 0; +} +$vars["curPos"] = $curPos; + + +// Get total count +if($totalCount == 0) +{ + $tempResult = mysql_query($query); + if(!$tempResult) + { + echo "$query
\n"; + echo "An error occurred: ".mysql_error()."

"; + exit; + } + $totalCount = mysql_num_rows($tempResult); + $vars["totalCount"] = $totalCount; + mysql_free_result($tempResult); +} + +// No data +if($totalCount == 0) +{ + if(debugging()) + { + echo $query; + echo "

"; + } + + echo "Your query returned no data.\n"; + return; +} + +$endPos=$curPos+$linesPerPage; + + +if($verbose) +{ + // verbose view (edit mode) + + include(BASE."include/"."tableve.php"); + if(!$mode) + $mode = "view"; + apidb_header(ucfirst($mode)." Query"); + + $t = new TableVE($mode); + $query = str_replace("\\", "", $query); + + $endPos = $curPos + $linesPerPage; + $query .= " LIMIT $curPos,$endPos"; + + if(debugging()) + echo "$query

\n"; + + add_pn_buttons($vars, $endPos); + echo "
curPos: $curPos
linesPerPage: $linesPerPage
totalCount: $totalCount
"; + + if($mode == "edit") + $t->edit($query); + else + $t->view($query); + + add_pn_buttons($vars, $endPos); + + apidb_footer(); +} +else +{ + // normal view (user view) + + apidb_header("Query Results"); + + include(BASE."include/"."query_inc.php"); + + twinedb_query($query, $vars); + + apidb_footer(); +} + + +?> diff --git a/support.php b/support.php new file mode 100644 index 0000000..3212d26 --- /dev/null +++ b/support.php @@ -0,0 +1,42 @@ + +

Who Can Help Me Out?

+ +

+ If you have questions, comments on the Wine Application Database, you can contact + us at appdb@winehq.com. +

+ +

+ If you notice something that seems to be wrong, or busticated, there is a way you can + help us out.
+ We also have a Bug Tracking Database + where you can register bugs. This is the best way to get problems fixed. You can go directly + to the App DB Bug Database by following this + link. +

+ +

+ If you need more information on the Wine Project itself, there are plenty of resources. +

+ + + diff --git a/tables/.htaccess b/tables/.htaccess new file mode 100644 index 0000000..c9c4d1b --- /dev/null +++ b/tables/.htaccess @@ -0,0 +1,2 @@ +deny from all + diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql new file mode 100644 index 0000000..481cd3d --- /dev/null +++ b/tables/appdb_tables.sql @@ -0,0 +1,246 @@ +use apidb; + +drop table vendor; +drop table appFamily; +drop table appVersion; +drop table userExperience; +drop table apiUsage; +drop table appCategory; +drop table appHitStats; +drop table catHitStats; +drop table appOwners; +drop table appComments; +drop table appData; + + +/* + * vendor information + */ +create table vendor ( + vendorId int not null auto_increment, + vendorName varchar(100) not null, + vendorURL varchar(200), + key(vendorId) +); + + +/* + * application + */ +create table appFamily ( + appId int not null auto_increment, + appName varchar(100) not null, + vendorId int not null, + keywords text, + description text, + webPage varchar(100), + catId int, + key(appId) +); + + +/* + * a version of an application + */ +create table appVersion ( + versionId int not null auto_increment, + appId int not null, + versionName varchar(100) not null, + keywords text, + description text, + webPage varchar(100), + rating_windows float default 0.0, + rating_fake float default 0.0, + key(versionId) +); + +create table appQueue ( + queueId int not null auto_increment, + queueName varchar(100) not null, + queueVersion varchar(100) not null, + queueVendor varchar(100) not null, + queueDesc text, + queueEmail varchar(100), + queueURL varchar(100), + queueImage varchar(100) not null, + key(queueId) +); + +create table userExperience ( + uExpId int not null auto_increment, + versionId int not null, + userComments text, + testPlatform varchar(100), + wineVintage varchar(100), + entryDate timestamp not null, + userName text not null, + wineCfgFile text, + key(uExpId) +); + +create table apiUsage ( + apiUsageId int not null auto_increment, + versionId int not null, + apiid int(11) not null, + key(apiUsageId) +); + + +/* + * application category + */ +create table appCategory ( + catId int not null auto_increment, + catName varchar(64) not null, + catDescription text, + catParent int default 0, + key(catId) +); + + +/* + * not used yet + */ +create table appCrosslink ( + appId int not null, + catId int not null, + key(appId), + index(catId) +); + + +/* + * bundleId is the appId of the 'owner app' + */ +create table appBundle ( + bundleId int not null, + appId int not null, + key(bundleId), + index(appId) +); + + +/* + * appHitStats and catHitStats are to record statistics + */ +create table appHitStats ( + appHitId int not null auto_increment, + time timestamp, + ip varchar(16), + appId int not null, + count int, + key(appHitId) +); + +create table catHitStats ( + catHitId int not null auto_increment, + time timestamp, + ip varchar(16), + catId int not null, + count int, + key(catHitId) +); + + + +/* + * application <> owner mapping + */ +create table appOwners ( + appId int not null, + ownerId int not null, + key(appId) +); + + +/* + * user comments + */ +create table appComments ( + time timestamp, + commentId int not null auto_increment, + parentId int default 0, + appId int not null, + versionId int default 0, + userId int, + hostname varchar(80), + subject varchar(128), + body text, + score int, + key(commentId), + index(appId), + index(versionId) +); + + + +/* + * links to screenshots and other stuff + */ +create table appData ( + id int not null auto_increment, + appId int not null, + versionId int default 0, + type enum('image', 'url'), + description text, + url varchar(255), + key(id), + index(appId), + index(versionId) +); + + +/* + * allow users to vote for apps, as in, request that an app gets better support + */ +create table appVotes ( + id int not null auto_increment, + time timestamp, + appId int not null, + userId int not null, + slot int not null, + key(id), + index(appId), + index(userId) +); + + +/* + * app ratings + */ +create table appRating ( + id int not null auto_increment, + time timestamp, /* we might wanna expire old ratings */ + versionId int not null, + userId int not null, + system enum('windows', 'fake'), + score int not null, + key(id), + index(versionId), + index(userId) +); + + +/* + * application notes + */ +create table appNotes ( + noteId int not null auto_increment, + noteTitle varchar(255), + noteDesc text, + appId int not null, + versionId int not null, + key(noteId) +); + +/* + * + */ +create table sessionMessages ( + id int not null auto_increment, + time timestamp, + sessionId varchar(32), + message text, + key(id), + index(sessionId) +); diff --git a/tables/appratings.sql b/tables/appratings.sql new file mode 100644 index 0000000..b509b49 --- /dev/null +++ b/tables/appratings.sql @@ -0,0 +1,7 @@ +SELECT appVersion.appId, appVersion.versionId, appName, versionName, avg(score) as rating, count(appVersion.versionId) as hits +FROM appRating, appFamily, appVersion +WHERE (appVersion.versionId = appRating.versionId +AND appFamily.appId = appVersion.appId) +AND system = 'fake' AND rating = 5 +GROUP BY appVersion.versionId +ORDER BY appName ASC diff --git a/tables/banner.sql b/tables/banner.sql new file mode 100644 index 0000000..08b824f --- /dev/null +++ b/tables/banner.sql @@ -0,0 +1,12 @@ +CREATE TABLE banner ( + id int not null, + desc text, + img varchar(255), + url varchar(255), + alt varchar(255), + imp int not null, + clk int not null, + lastmod timestamp, + + primary key(id) +) diff --git a/tables/prefs_list.sql b/tables/prefs_list.sql new file mode 100644 index 0000000..e06bb19 --- /dev/null +++ b/tables/prefs_list.sql @@ -0,0 +1,19 @@ +CREATE TABLE prefs_list ( + id int auto_increment not null, + name varchar(32), + def_value text, + value_list text, + description text, + + primary key(id) +); + +INSERT INTO prefs_list VALUES (0, 'debug', 'no', 'yes|no', 'Enable debugging information'); +INSERT INTO prefs_list VALUES (0, 'sidebar', 'left', 'left|right', 'Sidebar location'); +INSERT INTO prefs_list VALUES (0, 'window:query', 'no', 'yes|no', 'Display query results in a new window'); +INSERT INTO prefs_list VALUES (0, 'window:help', 'no', 'yes|no', 'Display help in a new window'); +INSERT INTO prefs_list VALUES (0, 'window:offsite', 'no', 'yes|no', 'Display offsite URLs in a new window'); + +INSERT INTO prefs_list VALUES (0, 'query:mode', 'view', 'view|edit', 'Default API details mode'); +INSERT INTO prefs_list VALUES (0, 'query:hide_header', 'no', 'yes|no', 'Hide apidb header in query results'); +INSERT INTO prefs_list VALUES (0, 'query:hide_sidebar', 'no', 'yes|no', 'Hide apidb sidebar in query results'); diff --git a/tables/user_list.sql b/tables/user_list.sql new file mode 100644 index 0000000..48ddfe9 --- /dev/null +++ b/tables/user_list.sql @@ -0,0 +1,19 @@ + +create table user_list ( + stamp timestamp not null, + userid int not null auto_increment, + username text not null, + password text not null, + realname text not null, + email text not null, + created datetime not null, + status int(4), + perm int(4), + unique key(userid), + unique(username(12)) +); + +insert into user_list values (NOW(), 0, 'int', password('testing'), 'Charles Loep', + 'charles@codeweavers.com', NOW(), 0, 0xffffffff); +update user_list set userid = 1000 where username = 'int'; + diff --git a/tables/user_prefs.sql b/tables/user_prefs.sql new file mode 100644 index 0000000..a2be08f --- /dev/null +++ b/tables/user_prefs.sql @@ -0,0 +1,7 @@ +CREATE TABLE user_prefs ( + userid int not null, + name varchar(64) not null, + value text, + key(userid), + key(name) +); diff --git a/tables/user_privs.sql b/tables/user_privs.sql new file mode 100644 index 0000000..5f53557 --- /dev/null +++ b/tables/user_privs.sql @@ -0,0 +1,6 @@ +CREATE TABLE user_privs ( + userid int not null, + priv varchar(64) not null, + primary key(userid) +); + diff --git a/updaterating.php b/updaterating.php new file mode 100644 index 0000000..0325d6d --- /dev/null +++ b/updaterating.php @@ -0,0 +1,18 @@ + diff --git a/updatevote.php b/updatevote.php new file mode 100644 index 0000000..4c712d3 --- /dev/null +++ b/updatevote.php @@ -0,0 +1,15 @@ + diff --git a/vendorview.php b/vendorview.php new file mode 100644 index 0000000..80ecce6 --- /dev/null +++ b/vendorview.php @@ -0,0 +1,75 @@ +vendorName
\n"; + +if ($vendor->vendorURL) { + echo "Vendor URL: $vendor->vendorURL
\n"; +} + +$result = mysql_query("SELECT * FROM appFamily WHERE vendorId = $vendorId ORDER BY appName"); +if($result) +{ + echo "
Applications by $vendor->vendorName
    \n"; + while($app = mysql_fetch_object($result)) + { + echo "
  1. $app->appName
  2. \n"; + } + echo "
\n"; +} + +echo html_frame_end(); +echo html_back_link(1); +apidb_footer(); + + + +// SUBS // + +//admin menu for sidebar +function admin_menu() +{ + global $vendorId; + + $m = new htmlmenu("Admin"); + $m->add("Edit this vendor", "admin/editVendor.php?vendorId=$vendorId"); + $m->done(); +} + +?> diff --git a/votestats.php b/votestats.php new file mode 100644 index 0000000..370fed2 --- /dev/null +++ b/votestats.php @@ -0,0 +1,45 @@ +Application Name\n"; + echo "Votes\n"; + + $c = 1; + while($row = mysql_fetch_object($result)) + { + if ($c % 2 == 1) { $bgcolor = "color0"; } else { $bgcolor = "color1"; } + $link = "$row->appName"; + echo "$c. $link $row->count \n"; + $c++; + } + echo html_table_end(); + echo html_frame_end(); + + echo "
What does this screen mean?
\n"; + +} +else +{ + echo "Error: " . mysql_error(); +} + +apidb_footer(); + +?>