commit 4b8091ae8abebdeea063eb47b603f936751902d8 from: nulani date: Sat May 6 13:16:36 2023 UTC added database directory commit - 1bd56cf0a0fd3597be038cec368e121b93a02d2f commit + 4b8091ae8abebdeea063eb47b603f936751902d8 blob - /dev/null blob + 06f5a1f75bd2d1bbd6c9efafd452982bbfc309c6 (mode 755) --- /dev/null +++ alexandria/database/db.php @@ -0,0 +1,13 @@ +You are not logged in correctly. Please log in before continuing."; + exit; + } + $link->select_db("games") or die ("Could not select database.\n"); + +?> \ No newline at end of file blob - /dev/null blob + f850d0bcf8cedf1b7ff17351a5cec4c54e116ed6 (mode 755) --- /dev/null +++ alexandria/database/faq.php @@ -0,0 +1,284 @@ + +Processing Addition...
"; + + //check that required values are filled in + if ($game == "" || $system == "" || $title == "" || $author == "") + { print "Please fill in all required values!
"; + return; + } + + //find game. + $result = mysql_query("SELECT gid, sstatus, linkgid, directory FROM games WHERE name='$game' AND system='$system'") or die("Error finding game!"); + if (mysql_num_rows($result) < 1) + { print "$game does not exist for $system! Please add it first."; + return; + } + $row = mysql_fetch_array($result, MYSQL_ASSOC); + $gid = $row["gid"]; + $sstatus = $row["sstatus"]; + $linkgid = $row['linkgid']; + $directory = $row['directory']; + mysql_free_result($result); + + if ($sstatus == "X") + { $result = mysql_query("SELECT name, system FROM games WHERE gid=$linkgid"); + $row = mysql_fetch_array($result, MYSQL_ASSOC); + $linkgame = $row['name']; + $linksystem = $row['system']; + print "$game for $system is only a nickname or link; please add an FAQ to $linkgame for $linksystem instead."; + return; + } + + //check that the FAQ does not already exist + $result = mysql_query("SELECT fid FROM faqs WHERE gid='$gid' AND title='$title' AND author='$author'"); + if (mysql_num_rows($result) > 0) + { print "This FAQ already exists!"; + exit; + } + + if ($directory == "") + { print "The indicated game does not have an FAQ directory! Please edit it and add one in!"; + exit; + } + + if (is_uploaded_file($upload['tmp_name'])) + { //find the max filename in the current directory + //first get file extension + $period = strrpos($upload['name'], "."); + $extension = substr($upload['name'], $period); + $okay = 0; + for ($i = 0; $i < sizeof($ext_list); $i++) + { if ($extension == $ext_list[$i]) $okay = 1; + } + if (!$okay) + { print "The given extension is invalid! You may only use one of the following extensions:"; + print ''; + return; + } + + //now get the *last* directory in the directory chain + $slash = strrpos($directory, "/"); + $lastdir = substr($directory, $slash); + $i = 1; + if (!file_exists(BASE_PATH . $sysdir . $directory)) + { mkdir(BASE_PATH . $sysdir . $directory, 0755); + @chgrp(BASE_PATH . $sysdir . $directory, 'psaserv'); + } + $file = BASE_PATH . $sysdir . $directory . "/" . $lastdir . "_1" . $extension; + $path = $lastdir . "_1" . $extension; + while (file_exists($file)) + { $i++; + $file = BASE_PATH . $sysdir . $directory . "/" . $lastdir . "_" . $i . $extension; + $path = $lastdir . "_" . $i . $extension; + } + + copy($upload['tmp_name'], $file); + @chgrp($file, "psaserv"); + chmod($file, 0664); + } + else print "Upload failed"; + //find max FID and make this FID one more than it + $result = mysql_query("SELECT MAX(fid) FROM faqs"); + $fid = mysql_result($result, 0) + 1; + mysql_free_result($result); + + $result = mysql_query("INSERT INTO faqs VALUES('$fid', '$gid', '$title', '$path', '$version', '$author', '$email')") or die("Error in inserting into database.\n"); + if ($result) + { print "The following FAQ was added to the database:"; + print "

Game Name: $game"; + print "
Game System: $system"; + print "
FAQ Title: $title"; + print "
File Uploaded To: alexandria.rpgclassics.com/" . $sysdir . $directory . "/" .$path; + print "
Version: $version"; + print "
Author: $author
"; + print ""; + } + else print "FAQ addition failed."; + } + else if ($HTTP_POST_VARS['mode'] == "edit") //edit an existing FAQ + { print "Edit An FAQ"; + print '

'; + + //get variables from form + $game = $HTTP_POST_VARS['game']; + $system = $HTTP_POST_VARS['system']; + $sysdir = str_replace(' ', '_', $system) . '/'; + + //check that required values are filled in + if ($game == "" || $system == "") + { print "Please fill in all required values!
"; + return; + } + + //find game + $result = mysql_query("SELECT gid, directory FROM games WHERE name=\"$game\" AND system=\"$system\"") or die("Error retrieving game!"); + if (mysql_num_rows($result) < 1) + { print "$game for $system does not exist! Please add it first!"; + return; + } + $row = mysql_fetch_array($result); + $gid = $row['gid']; + $directory = $row['directory']; + mysql_free_result($result); + + $result = mysql_query("SELECT fid, title, path, version, author, email FROM faqs WHERE gid=$gid") or die("Error finding FAQs!"); + + if (mysql_num_rows($result) < 1) print "No FAQs were found for $game ($system)"; + $i = 1; + + while($row = mysql_fetch_array($result, MYSQL_ASSOC)) + { $fid = $row['fid']; + $title = $row['title']; + $path = $row['path']; + $version = $row['version']; + $author = $row['author']; + $email = $row['email']; + + print "
\n"; + print ''; + print "
Game:$game\n"; + print "
System:$system\n"; + print "
FAQ Title:\n"; + print "
Re-upload File?: View Current\n"; + print ""; + print "
Version*:\n"; + print "
Author's Name:\n"; + print "
Author's E-mail*:\n"; + print "
Delete Entry?\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "
\n"; + $i++; + } + } + else if ($HTTP_POST_VARS['mode'] == "finish") //called from "edit" form above + { print "Processing Edit...
"; + + //get variables from form + $fid = $HTTP_POST_VARS['fid']; + $name = $HTTP_POST_VARS['name']; + $system = $HTTP_POST_VARS['system']; + $title = $HTTP_POST_VARS['title']; + $upload = $HTTP_POST_FILES['upload']; + $version = $HTTP_POST_VARS['version']; + $author = $HTTP_POST_VARS['author']; + $email = $HTTP_POST_VARS['email']; + $delete = $HTTP_POST_VARS['deleteit']; + $directory = $HTTP_POST_VARS['directory']; + $sysdir = str_replace(' ', '_', $system) . '/'; + $path = $HTTP_POST_VARS['path']; + + //check that required values are filled in + if (($title == "" || $path == "" || $author == "") && $delete != 'on') + { print "Please fill in all required values!
"; + return; + } + + if ($delete == "on") + { $result = mysql_query("DELETE FROM faqs WHERE fid=$fid") or die("Error deleting FAQ!"); + //delete the file. + if (is_file(BASE_PATH . $sysdir . $directory . '/' . $path)) + { $del = unlink(BASE_PATH. $sysdir . $directory . '/' . $path); + } + if ($del) print "File alexandria.rpgclassics.com/" . $sysdir . $directory . '/' . $path . " has been deleted.

"; + else print "File alexandria.rpgclassics.com/" . $sysdir . $directory . '/' . $path . " deletion failed.

"; + + if ($result) + { if (mysql_affected_rows($link) < 1) + { print "FAQ does not exist!"; + return; + } + } + else + { print "FAQ deletion failed."; + return; + } + + print "The following FAQ was deleted:"; + print "

Game Name: $name"; + print "
Game System: $system"; + print "
FAQ Title: $title"; + print "
File Path: alexandria.rpgclassics.com/".$path; + print "
Version: $version"; + print "
Author: $author
"; + print ""; + } + else + { if (is_uploaded_file($upload['tmp_name'])) + { //find the max filename in the current directory + //first get file extension + $period = strrpos($upload['name'], "."); + $extension = substr($upload['name'], $period); + $okay = 0; + for ($i = 0; $i < sizeof($ext_list); $i++) + { if ($extension == $ext_list[$i]) $okay = 1; + } + if (!$okay) + { print "The given extension is invalid! You may only use one of the following extensions:"; + print '

'; + return; + } + + if (!file_exists(BASE_PATH . $sysdir . $directory)) + { mkdir(BASE_PATH . $sysdir . $directory, 0755); + @chgrp(BASE_PATH . $sysdir . $directory, 'psaserv'); + } + $file = BASE_PATH . $sysdir . $directory . "/" . $path; + + copy($upload['tmp_name'], $file); + @chgrp($file, "psaserv"); + chmod($file, 0664); + } + else if ($upload['name'] != '') print "Upload failed"; + + if (!is_file(BASE_PATH . $sysdir . $directory . '/' . $path)) + { print "The file has not been uploaded yet!"; + return; + } + + $result = mysql_query("UPDATE faqs SET title='$title', path='$path', version='$version', author='$author', email='$email' WHERE fid=$fid") or die ("Error in editing shrine!"); + + if ($result) + { print "The FAQ was changed to the following information:"; + print "

Game Name: $name"; + print "
Game System: $system"; + print "
FAQ Title: $title"; + print "
File Path: alexandria.rpgclassics.com/". $sysdir . $path; + print "
Version: $version"; + print "
Author: $author
"; + print ""; + } + else print "Edit failed."; + } + } + else print "Internal code error: Mode unknown.\n"; +?> + \ No newline at end of file blob - /dev/null blob + d68b8b30f72a57b4e40a00b9f053c95850fb0229 (mode 755) --- /dev/null +++ alexandria/database/game.html @@ -0,0 +1,166 @@ +

RPGClassics Game Database +

Add Game To Database
+

You must be logged in to continue. +

If the game is a "recommended" game for shrining, check the box next to the game name. You must fill in the game name and system, but the other fields may be left blank. If a game is a "link" or "nickname", you must fill in which game and system it references. (Leaving the "linked system" blank will automatically fill in the same system the current game is for.) For LINKS ONLY, please indicate whether this game should have its own shrine (check the box next to the "linked game" field) or if it should be included with the shrine for the referenced game (leave it unchecked). +

+

+ + + + + +
Game: Recommended? +
System: +
Type of game: For nicknames or links, please select below which game is referenced. +
Linked Game*: With its own shrine? +
Linked System*: +
Developer: +
JP Publisher*: Year*:
NA Publisher*: Year*:
PAL Publisher*: Year*:
Descriptive Blurb*
(HTML format):
FAQ Directory*/databasefiles/
+

+


+

Edit Games
+

Please enter a search string for the game you wish to edit. +

+

+
Search for games starting with
Game: + +
+

+


+

Delete A Game
+

Please enter the game and system you wish to delete. This will result in all information about the game to be deleted. Any "nickname" games referring to it will be deleted. Any "link" games will have their link deleted (although the game itself will still be there). This action cannot be undone! +

+

Game: +
System: + +
+

+


+

Add A Collection
+

+ + +
Number of games in collection:
+
+ blob - /dev/null blob + 713ebae0bc768b2cfd0feb619198136a5b36f391 (mode 755) --- /dev/null +++ alexandria/database/game.php @@ -0,0 +1,824 @@ + +Processing Addition...
"; + + //check that required values are filled in + if ($game == "" || $system == "") + { print "Please fill in all required values!
"; + return; + } + $yesscreens = 0; + for ($i = 0; $i < sizeof($screen['name']); $i++) + { if ($screen['name'][$i] != '') $yesscreens = 1; + } + if ($yesscreens && $directory == "") + { print 'If you wish to upload screenshots, please define a directory name first.'; return; + } + + if (($status == "L" || $status == "N") && ($linkgame == "")) + { print "Please indicate which game and system this game references!"; + return; + } + + if ($status == "N") + { $developer = ""; + $jppub = ""; + $jpyear = ""; + $napub = ""; + $nayear = ""; + $palpub = ""; + $palyear = ""; + $wanted = "N"; + $directory = ""; + $blurb = ""; + $os = ''; + $hd = ''; + $ram = ''; + $recCPU = ''; + $minCPU = ''; + } + + if ($status != "L" && $status != "N") + { $linkgid = "NULL"; + } + + if ($status == "N" || ($status == "L" && !$linkshrine)) + { $sstatus = "X"; + } + else $sstatus = "A"; + + //check if game exists already + $result = mysql_query("SELECT gid FROM games WHERE name=\"$game\" AND system=\"$system\""); + if (mysql_num_rows($result) > 0) + { print "$game for $system already exists!"; + return; + } + mysql_free_result($result); + + if ($status == "N" || $status == "L") + { $result = mysql_query("SELECT gid, sstatus, status FROM games WHERE name=\"$linkgame\" AND system=\"$linksystem\"") or die("Error finding referenced game!"); + if (mysql_num_rows($result) < 1) + { print "The linked game, $linkgame ($linksystem), does not exist! Please add it first!"; + return; + } + $row = mysql_fetch_array($result, MYSQL_ASSOC); + $linkgid = $row['gid']; + if (($row['sstatus'] == "X" && $status == "L") || ($row['status'] == "N" && $status == "N")) + { print "The linked game, $linkgame ($linksystem), is itself a nickname or link that does not have its own entry! Please pick a \"normal\" game."; + return; + } + mysql_free_result($result); + } + //if directory doesn't exist, create it + if (!is_dir(BASE_PATH . $sysdir . $directory) && $directory != "") mkdir(BASE_PATH . $sysdir . $directory, 0775); + + $ext = array(); + $shots = array(); + + for ($i = 0; $i < sizeof($screen['tmp_name']); $i++) + { if (!$screen['tmp_name'][$i]) continue; + if (is_uploaded_file($screen['tmp_name'][$i])) + { //find the max filename in the current directory + //first get file extension + $period = strrpos($screen['name'][$i], "."); + $extension = strtolower(substr($screen['name'][$i], $period)); + if ($extension == '.jpeg') $extension = '.jpg'; + if ($extension != '.gif' && $extension != '.jpg' && $extension != '.png') + { print "Incorrect extension for " . $screen['tmp_name'][$i] . "! Only use .jpg, .gif, or .png files."; + break; + } + else $ext[$i] = $extension; + } + else if ($screen['name'][$i] != '') print "Upload failed for screenshot $i."; + } + for ($i = 0; $i < sizeof($screen['tmp_name']); $i++) + { if (!is_uploaded_file($screen['tmp_name'][$i]) || !$screen['tmp_name'][$i]) continue; + $path = BASE_PATH . $sysdir . $directory . "_" . ($i+1) . $ext[$i]; + copy($screen['tmp_name'][$i], $path); + chgrp($path, "rpgcdb"); + chmod($path, 0664); + $shots[] = $sysdir . $directory . '_' . ($i+1) . $ext[$i]; + } + //find max GID and make this GID one more than it + $result = mysql_query("SELECT MAX(gid) FROM games"); + $gid = mysql_result($result, 0) + 1; + mysql_free_result($result); + + $result = mysql_query("INSERT INTO games VALUES('$gid', '$game', '$system', '$wanted', '$status', $linkgid, '$blurb', '$sstatus', '$developer', '$jppub', '$jpyear', '$napub', '$nayear', '$palpub', '$palyear', '$directory', '$os', '$minCPU', '$recCPU', '$ram', '$hd')") or die("Error in inserting into database.\n"); + if ($result) + { print "The following game was added:"; + print "

Name: $game"; + print "
System: $system"; + print "
Recommended: "; + if ($wanted == "Y") print "Yes"; else print "No"; + print "
Status: "; + if ($status == "L") + { print "Linked"; + if ($sstatus == "X") print " (Without Own Shrine)"; + else print " (With Own Shrine)"; + } + else if ($status == "N") print "Nickname"; + else print "Normal"; + if ($status == "L" || $status == "N") + { print "
Linked Game: $linkgame"; + print "
Linked System: $linksystem"; + } + print "
Developer: $developer"; + print "
JP Release: $jppub"; + if ($jpyear != "") print " ($jpyear)"; + print "
NA Release: $napub"; + if ($nayear != "") print " ($nayear)"; + print "
PAL Release: $palpub"; + if ($palyear != "") print " ($palyear)"; + if ($system == "PC") + { print "
Operating System: $os"; + print "
Min. CPU Requirement: $minCPU"; + print "
Rec. CPU Requirement: $recCPU"; + print "
Min. Hard Drive: $hd"; + print "
Min. RAM: $ram"; + } + for ($i = 0; $i < sizeof($shots); $i++) print "
Screenshot " . ($i + 1) . ": /" . $shots[$i]; + if ($directory != "") print "
FAQ directory: /databasefiles/$sysdir" . $directory; + print "
Descriptive Blurb: $blurb
"; + print ""; + } + else print "Game addition failed."; + } + else if ($mode == "edit") //edit an existing game + { print "Edit A Game"; + print ''; + print "

"; + + //get variables from form + $game = $HTTP_POST_VARS['game']; + $start = $HTTP_POST_VARS['start']; + $system = $HTTP_POST_VARS['system']; + print '
'; + print ""; + print ""; + print ""; + print ""; + print ""; + print "
"; + + if ($getgid != '') $query = "SELECT * from games WHERE gid=$getgid"; + else + { //check that required values are filled in + if ($game == "") + { print "Please fill in the game name!
"; + return; + } + + //find game + if ($start != "") $clause = "WHERE name LIKE \"%$game%\""; + else $clause = "WHERE name = \"$game\""; + if ($system != '') $clause .= " AND system='$system'"; + $query = "SELECT gid, name, system, developer, jppub, jpyear, napub, nayear, palpub, palyear, wanted, status, linkgid, blurb, sstatus, directory FROM games $clause"; + } + $result = mysql_query($query) or die("Error retrieving game!"); + if (mysql_num_rows($result) < 1) + { print "No results found. Try adding the game first."; + return; + } + + while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) + { $game = $row['name']; + $gid = $row['gid']; + $system = $row['system']; + $developer = $row['developer']; + $jppub = $row['jppub']; + $jpyear = $row['jpyear']; + $napub = $row['napub']; + $nayear = $row['nayear']; + $palpub = $row['palpub']; + $palyear = $row['palyear']; + $os = $row['os']; + $minCPU = $row['minCPU']; + $recCPU = $row['recCPU']; + $hd = $row['hd']; + $ram = $row['ram']; + if ($row['wanted'] == "Y") $wanted = "CHECKED"; + $status = $row['status']; + $linkgid = $row['linkgid']; + $blurb = $row['blurb']; + $directory = $row['directory']; + $sstatus = $row['sstatus']; + if ($sstatus != "X" && $status == "L") $scheck = "CHECKED"; + $linkgame = ""; + $linksystem = ""; + $sysdir = str_replace(' ', '_', $system) . '/'; + + if ($status == "C") //collection + { //get games in collection + $names = array(); + $systems = array(); + $result2 = mysql_query("SELECT g.name, g.system FROM games as g, collections as c WHERE c.gid='$gid' AND g.gid=c.linkgid ORDER BY g.name"); + $i = 0; + while ($row = mysql_fetch_array($result2)) + { $names[$i] = $row['name']; + $systems[$i] = $row['system']; + $i++; + } + print "

If you wish to change the number of games in this collection, it's best to start over by deleting it and re-entering it. Otherwise feel free to edit the information below.
"; + print "
\n"; + print "

\n"; + print ""; + print ""; + for ($i = 0; $i < sizeof($names); $i++) + { print ""; + print "\n"; + print "\n"; + print "\n"; + if ($system == "PC") + { print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + } + print ""; + $numShots = $HTTP_POST_VARS['shots']; + if ($numShots < 2) $numShots = 2; + $i = 1; + $sys = str_replace(' ', '_', $system) . '/'; + //get screenshots. + $currentShots = array(); + while(true) + { if (file_exists(BASE_PATH . $sys . $directory . '_' . $i . '.gif')) $ext = '.gif'; + else if (file_exists(BASE_PATH . $sys . $directory . '_' . $i . '.jpg')) $ext = '.jpg'; + else if (file_exists(BASE_PATH . $sys . $directory . '_' . $i . '.png')) $ext = '.png'; + else break; + $currentShots[] = $sys . $directory . '_' . $i . $ext; + $i++; + } + if ($numShots < sizeof($currentShots)) $numShots = sizeof($currentShots); + for ($i = 0; $i < $numShots; $i++) + { print "'; + } + print "\n"; + print "
Name:\n"; + print "
System:$system
Type of game:Collection
Games In Collection
Game:
System:
Developer*:"; + print "
JP Publisher*: Year*:
NA Publisher*: Year*:
PAL Publisher*: Year*:
Operating System*:
Min. CPU Requirement*:
Rec. CPU Requirement*:
Min. Hard Drive*:
Min. RAM*:
Directory*
alexandria.rpgclassics.com/" . $sysdir . "
Screenshot " . (string)($i + 1) . "*:"; + if ($i == $numShots - 1 ) print ' '; + if (isset($currentShots[$i])) print ' View Current Delete?'; + print '
Descriptive Blurb*
(HTML format):
\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "

"; + continue; + } + + elseif ($status == "L" || $status == "N") + { $result2 = mysql_query("SELECT name, system FROM games WHERE gid=$linkgid") or die("Error finding referenced game!"); + $row = mysql_fetch_array($result2, MYSQL_ASSOC); + $linkgame = $row['name']; + $linksystem = $row['system']; + mysql_free_result($result2); + } + + //print HTML form containing correct values that will call game.php again + //when the form is submitted + + print "
\n"; + print "

\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + if ($system == "PC") + { print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + } + print ""; + $numShots = $HTTP_POST_VARS['shots']; + if ($numShots < 2) $numShots = 2; + $i = 1; + $sys = str_replace(' ', '_', $system) . '/'; + //get screenshots. + $currentShots = array(); + while(true) + { if (file_exists(BASE_PATH . $sys . $directory . '_' . $i . '.gif')) $ext = '.gif'; + else if (file_exists(BASE_PATH . $sys . $directory . '_' . $i . '.jpg')) $ext = '.jpg'; + else if (file_exists(BASE_PATH . $sys . $directory . '_' . $i . '.png')) $ext = '.png'; + else break; + $currentShots[] = $sys . $directory . '_' . $i . $ext; + $i++; + } + if ($numShots < sizeof($currentShots)) $numShots = sizeof($currentShots); + for ($i = 0; $i < $numShots; $i++) + { print "'; + } + print ""; + print "\n"; + print "
Game: Recommended? \n"; + print "
System:$system
Type of game: For nicknames/links, please select below which game is referenced.\n"; + print "
Linked Game*: Have its own shrine?\n"; + print "
Linked System*:
Developer*:"; + print "
JP Publisher*: Year*:
NA Publisher*: Year*:
PAL Publisher*: Year*:
Operating System*:
Min. CPU Requirement*:
Rec. CPU Requirement*:
Min. Hard Drive*:
Min. RAM*:
Directory*
alexandria.rpgclassics.com/" . $sysdir . "
Screenshot " . (string)($i + 1) . "*:"; + if ($i == $numShots - 1 ) print ' '; + if (isset($currentShots[$i])) print ' View Current Delete?'; + print '
Descriptive Blurb*
(HTML format):
\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "

"; + print "


"; + } + } + + else if ($mode == "finish") //called from "edit" form above + { print "Processing Edit...
"; + + //get variables from form + $gid = $HTTP_POST_VARS['gid']; + $name = $HTTP_POST_VARS['name']; + $system = $HTTP_POST_VARS['system']; + $developer = $HTTP_POST_VARS['developer']; + $jppub = $HTTP_POST_VARS['jppub']; + $jpyear = $HTTP_POST_VARS['jpyear']; + $napub = $HTTP_POST_VARS['napub']; + $nayear = $HTTP_POST_VARS['nayear']; + $palpub = $HTTP_POST_VARS['palpub']; + $palyear = $HTTP_POST_VARS['palyear']; + $os = $HTTP_POST_VARS['os']; + $minCPU = $HTTP_POST_VARS['minCPU']; + $recCPU = $HTTP_POST_VARS['recCPU']; + $hd = $HTTP_POST_VARS['hd']; + $ram = $HTTP_POST_VARS['ram']; + $wanted = $HTTP_POST_VARS['wanted']; + $status = $HTTP_POST_VARS['status']; + $linkgame = $HTTP_POST_VARS['linkgame']; + $linksystem = $HTTP_POST_VARS['linksystem']; + $blurb = $HTTP_POST_VARS['blurb']; + $linkshrine = $HTTP_POST_VARS['linkshrine'] != ""; + $sstatus = $HTTP_POST_VARS['sstatus']; + $linkgid = "NULL"; + $directory = $HTTP_POST_VARS['directory']; + $sysdir = str_replace(' ', '_', $system) . '/'; + $screen = $HTTP_POST_FILES['screen']; + $delete = $HTTP_POST_VARS['delete']; + if ($wanted == "on") $wanted = "Y"; + else $wanted = "N"; + $numShots = $HTTP_POST_VARS['numShots']; + + if ($linksystem == "") $linksystem = $system; + + if (($status == "L" || $status == "N") && ($linkgame == "" || $linksystem == "")) + { print "Please indicate which game and system this game references!
"; + return; + } + + $yesscreens = 0; + for ($i = 0; $i < sizeof($screen['name']); $i++) + { if ($screen['name'][$i] != '') $yesscreens = 1; + } + if ($yesscreens && $directory == "") + { print 'If you wish to upload screenshots, please define a directory name first.'; return; + } + + if ($status == "N") + { $developer = ""; + $jppub = ""; + $jpyear = ""; + $napub = ""; + $nayear = ""; + $palpub = ""; + $palyear = ""; + $os = ''; + $recCPU = ''; + $minCPU = ''; + $hd = ''; + $ram = ''; + $blurb = ""; + $wanted = "N"; + $directory = ""; + } + + if ($status != "L" && $status != "N") + { $linkgame = ""; + $linksystem = ""; + } + + if ($status == "N" || ($status == "L" && !$linkshrine)) + { $sstatus = "X"; + } + else if ($sstatus == "X") $sstatus = "A"; //newly changed to "normal" or "has its own shrine" + + $result = mysql_query("SELECT gid FROM games where gid != \"$gid\" && name=\"$name\" && system=\"$system\""); + if (mysql_num_rows($result) > 0) //name/system already exists and it's not me + { print "$name for $system already exists! Please choose a different name."; + return; + } + mysql_free_result($result); + + if ($status == "N" || $status == "L") + { $result = mysql_query("SELECT gid, sstatus, status FROM games WHERE name=\"$linkgame\" AND system=\"$linksystem\"") or die("Error finding referenced game!"); + if (mysql_num_rows($result) < 1) + { print "The linked game, $linkgame ($linksystem), does not exist! Please add it first!"; + return; + } + $row = mysql_fetch_array($result, MYSQL_ASSOC); + $linkgid = $row['gid']; + if (($row['sstatus'] == "X" && $status == "L") || ($row['status'] == "N" && $status == "N")) + { print "The linked game, $linkgame ($linksystem), is a nickname or link that does not have its own entry! Please pick a \"normal\" game."; + return; + } + mysql_free_result($result); + } + + //if directory doesn't exist, create it + if (!is_dir(BASE_PATH . $sysdir . $directory) && $directory != "") mkdir(BASE_PATH . $sysdir . $directory, 0775); + + $ext = array(); + $shots = array(); + + for ($i = 0; $i < $numShots; $i++) + { if ($delete[$i]) + { + @unlink(BASE_PATH . $sysdir . $directory . '_' . ($i + 1) . '.gif'); + @unlink(BASE_PATH . $sysdir . $directory . '_' . ($i + 1) . '.jpg'); + @unlink(BASE_PATH . $sysdir . $directory . '_' . ($i + 1) . '.png'); + } + elseif (!$screen['tmp_name'][$i]) continue; + elseif (is_uploaded_file($screen['tmp_name'][$i])) + { //first get file extension + $period = strrpos($screen['name'][$i], "."); + $extension = strtolower(substr($screen['name'][$i], $period)); + if ($extension == '.jpeg') $extension = '.jpg'; + if ($extension != '.gif' && $extension != '.jpg' && $extension != '.png') + { print "Incorrect extension for " . $screen['tmp_name'][$i] . "! Only use .jpg, .gif, or .png files."; + break; + } + else $ext[] = $extension; + } + elseif ($screen['name'][$i] != '') print "Upload failed for screenshot $i."; + } + $currentShots = array(); + $i = 1; + while(true) + { if (file_exists(BASE_PATH . $sysdir . $directory . '_' . $i . '.gif')) $extension = '.gif'; + else if (file_exists(BASE_PATH . $sysdir . $directory . '_' . $i . '.jpg')) $extension = '.jpg'; + else if (file_exists(BASE_PATH . $sysdir . $directory . '_' . $i . '.png')) $extension = '.png'; + else break; + $currentShots[] = $sysdir . $directory . '_' . $i . $extension; + $i++; + } + //if we deleted a screenshot, shift the rest down by one number. +/* for ($i = 0; $i < $numShots; $i++) + { if ($delete[$i]) + { for ($j = $i + 1; $j < $numShots; $j++) + { @copy(BASE_PATH . $currentShots[$j], BASE_PATH . $currentShots[$j - 1]); + $currentShots[$j] = $currentShots[$j - 1]; + } + } + }*/ + $j = 0; + $k = 0; + for ($i = 0; $i < $numShots; $i++) + { if (!is_uploaded_file($screen['tmp_name'][$i]) || !$screen['tmp_name'][$i]) + { $shots[$k] = $currentShots[$i]; + $k++; + continue; + } + elseif ($delete[$i]) continue; + $path = BASE_PATH . $sysdir . $directory . "_" . ($k+1) . $ext[$j]; + copy($screen['tmp_name'][$i], $path); + chgrp($path, "rpgcdb"); + chmod($path, 0664); + $shots[$i] = $sysdir . $directory . '_' . ($k+1) . $ext[$j]; + $j++; + $k++; + } + //update game with all new values + + $result = mysql_query("UPDATE games SET name='$name', developer='$developer', jppub='$jppub', jpyear='$jpyear', napub='$napub', nayear='$nayear', palpub='$palpub', palyear='$palyear', wanted='$wanted', status='$status', linkgid=$linkgid, blurb='$blurb', sstatus='$sstatus', directory='$directory', os='$os', minCPU='$minCPU', recCPU='$recCPU', hd='$hd', ram='$ram' WHERE gid=$gid") or die ("Error in editing game!"); + echo mysql_error($link); + + if ($status == "C") //collection; update the collection table. + { $games = $HTTP_POST_VARS['names']; + $systems = $HTTP_POST_VARS['systems']; + + //first delete all games for this collection, then re-enter them. + $result2 = mysql_query("DELETE FROM collections WHERE gid='$gid'"); + if (!$result2) { print "Error deleting from collections!"; exit; } + for ($i = 0; $i < sizeof($games); $i++) + { $result2 = mysql_query("SELECT gid FROM games WHERE name='" . $games[$i] . "' AND system='" . $systems[$i] . "'"); + $ourgid = mysql_result($result2, 0); + $result3 = mysql_query("INSERT INTO collections VALUES('$gid', '$ourgid')"); + if (!$result3) + { print "Error inserting game " . $games[$i] . " (" . $systems[$i] . ") into collection table!"; + exit; + } + } + } + + if ($result) + { print "The game information was changed to the following:"; + print "

Name: $name"; + print "
System: $system"; + print "
Recommended: "; + if ($wanted == "Y") print "Yes"; else print "No"; + print "
Status: "; + if ($status == "L") + { print "Linked"; + if ($sstatus == "X") print " (Without Own Shrine)"; + else print " (With Own Shrine)"; + } + else if ($status == "N") print "Nickname"; + else if ($status == "C") print "Collection"; + else print "Normal"; + if ($status == "L" || $status == "N") + { print "
Linked Game: $linkgame"; + print "
Linked System: $linksystem"; + } + if ($status == "C") + { print "

Games in collection:"; + for ($i = 0; $i < sizeof($games); $i++) + { print "
" . $games[$i] . " (" . $systems[$i] . ")"; + } + } + print "
Developer: $developer"; + print "
JP Release: $jppub"; + if ($jpyear != "") print " ($jpyear)"; + print "
NA Release: $napub"; + if ($nayear != "") print " ($nayear)"; + print "
PAL Release: $palpub"; + if ($palpub != "") print " ($palyear)"; + if ($system == "PC") + { print "
Operating System: $os"; + print "
Min. CPU Requirement: $minCPU"; + print "
Rec. CPU Requirement: $recCPU"; + print "
Min. Hard Drive: $hd"; + print "
Min. RAM: $ram"; + } + print "
Directory: alexandria.rpgclassics.com/" . $sysdir . $directory; + for ($i = 0; $i < sizeof($shots); $i++) + { if ($shots[$i] != "") print "
Screenshot " . ($i + 1) . ": alexandria.rpgclassics.com/" . $shots[$i]; + } + print "
Descriptive Blurb: $blurb

"; + print ""; + } + else print "Edit failed."; + } + else if ($mode == "delete") //delete a shrine + { //get variables from form + $game = $HTTP_POST_VARS['game']; + $system = $HTTP_POST_VARS['system']; + + //check that required values are filled in + if ($game == "" or $system == "") + { print "Please fill in all required values!"; + return; + } + + print "Processing Deletion...

"; + + //find game first + $result = mysql_query("SELECT gid, status, jppub, jpyear, napub, nayear, palpub, palyear, wanted, sstatus, developer, blurb, directory FROM games WHERE name=\"$game\" AND system=\"$system\"") or die("Error finding game!\n"); + if (mysql_num_rows($result) < 1) + { print "$game for $system does not exist! Please add it first!"; + return; + } + $row = mysql_fetch_array($result, MYSQL_ASSOC); + $gid = $row['gid']; + $status = $row['status']; + $jppub = $row['jppub']; + $jpyear = $row['jpyear']; + $palpub = $row['palpub']; + $palyear = $row['palyear']; + $os = $row['os']; + $minCPU = $row['minCPU']; + $recCPU = $row['recCPU']; + $hd = $row['hd']; + $ram = $row['ram']; + $napub = $row['napub']; + $nayear = $row['nayear']; + $sstatus = $row['sstatus']; + $developer = $row['developer']; + $blurb = $row['blurb']; + $wanted = $row['wanted']; + $directory = $row['directory']; + $sysdir = str_replace(' ', '_', $system) . '/'; + + //if this game is linked from a nickname, delete the nickname. + $result = mysql_query("SELECT gid FROM games WHERE status='N' AND linkgid=$gid") or die("Error finding nicknames!"); + while($row = mysql_fetch_array($result, MYSQL_ASSOC)) + { $nickgid = $row['gid']; + mysql_query("DELETE FROM games WHERE gid=$nickgid");// or die("Error deleting nicknames!"); + } + + //if this game is linked from a "link", delete the link referring to here. + $result = mysql_query("SELECT gid FROM games WHERE status='L' AND linkgid=$gid") or die("Error finding links!"); + while($row = mysql_fetch_array($result, MYSQL_ASSOC)) + { $nickgid = $row['gid']; + mysql_query("UPDATE games SET linkgid=NULL WHERE gid=$nickgid") or die("Error deleting links!"); + } + + //if this game is a collection or is inside a collection, delete the entry relating to it. + $result = mysql_query("DELETE FROM collections WHERE gid='$gid' or linkgid='$gid'") or die("Error in deleting from collection table!"); + + $result = mysql_query("DELETE FROM games WHERE gid=$gid") or die("Error in deleting game.\n"); + + if ($result) + { if (mysql_affected_rows($link) > 0) + { print "The following game was deleted:"; + print "

Name: $game"; + print "
System: $system"; + print "
Recommended: "; + if ($wanted == "Y") print "Yes"; else print "No"; + print "
Status: "; + if ($status == "L") + { print "Linked"; + if ($sstatus == "X") print " (Without Own Shrine)"; + else print " (With Own Shrine)"; + } + else if ($status == "N") print "Nickname"; + else print "Normal"; + if ($status == "L" || $status == "N") + { print "
Linked Game: $linkgame"; + print "
Linked System: $linksystem"; + } + print "
Developer: $developer"; + print "
JP Release: $jppub"; + if ($jpyear != "") print " ($jpyear)"; + print "
NA Release: $napub"; + if ($nayear != "") print " ($nayear)"; + print "
PAL Release: $palpub"; + if ($palyear != "") print " ($palyear)"; + if ($system == "PC") + { print "
Operating System: $os"; + print "
Min. CPU Requirement: $minCPU"; + print "
Rec. CPU Requirement: $recCPU"; + print "
Min. Hard Drive: $hd"; + print "
Min. RAM: $ram"; + } + print "
Directory: alexandria.rpgclassics.com/" . $sysdir . $directory; + print "
Descriptive Blurb: $blurb
"; + print "

"; + } + else print "$game for $system does not exist!"; + } + elseif ($mode == "addcoll") //add collection + { $number = intval($HTTP_POST_VARS['number']); + if ($number == 0) + { print "

Please enter an integer value (1 or more) for the number of games.
"; + exit; + } +?> +Add A Collection +

Add A Collection + +

+"; + print " + + + + +
Game: +
System: +
Games In Collection
Game " . ($i+1) . ":
System:
Developer: +
JP Publisher*: Year*:
NA Publisher*: Year*:
PAL Publisher*: Year*:
Descriptive Blurb*
(HTML format):
+ 0) + { print "This game already exists! Delete it first if you want to turn it into a collection."; + exit; + } + + $gid = array(); + for ($i = 0; $i < sizeof($game); $i++) + { $result = mysql_query("SELECT gid FROM games WHERE name='" . $game[$i] . "' AND system='" . $system[$i] . "'"); + $gid[$i] = mysql_result($result, 0); + } + + //add into game table + $result = mysql_query("SELECT MAX(gid) FROM games"); + $ourgid = mysql_result($result, 0) + 1; + $result = mysql_query("INSERT INTO games VALUES('$ourgid', '$cgame', '$csystem', 'N', 'C', '', '$blurb', 'N', '$developer', '$jppub', '$jpyear', '$napub', '$nayear', '$palpub', '$palyear', '$directory', '$os', '$minCPU', '$recCPU', '$hd', '$ram')") or die("Error in inserting into database.\n"); + if (!$result) + { print "Error inserting game into database!"; exit; + } + + //add into collection table + for ($i = 0; $i < sizeof($gid); $i++) + { $result = mysql_query("INSERT INTO collections VALUES('$ourgid', '" . $gid[$i] . "')"); + if (!$result) + { print "Error inserting link to " . $game[$i] . " (" . $system[$i] . ")!"; + exit; + } + } + print "Collection added successfully!"; + } + else print "Internal code error: Mode unknown.\n"; +?> + \ No newline at end of file blob - /dev/null blob + 78f07e5d0b5db3bea5649de64d35276b4569e554 (mode 755) --- /dev/null +++ alexandria/database/game.phtml @@ -0,0 +1,96 @@ +

RPGClassics Game Database + + +

Add Game To Database
+

You must be logged in to continue. +

If the game is a "recommended" game for shrining, check the box next to the game name. You must fill in the game name and system, but the other fields may be left blank. If a game is a "link" or "nickname", you must fill in which game and system it references. (Leaving the "linked system" blank will automatically fill in the same system the current game is for.) For LINKS ONLY, please indicate whether this game should have its own shrine (check the box next to the "linked game" field) or if it should be included with the shrine for the referenced game (leave it unchecked). +

The directory should be one word in lowercase (no slashes or special characters). +

+

+ + + + + + + +'; + } +?> + + + +
Game: Recommended? +
System: +
Type of game: For nicknames or links, please select below which game is referenced. +
Linked Game*: With its own shrine? +
Linked System*: +
Developer: +
JP Publisher*: Year*:
NA Publisher*: Year*:
PAL Publisher*: Year*:
Operating System*:
Min. CPU Speed*:
Rec. CPU Speed*:
Min. Hard Drive*:
Min. RAM*:
Screenshot " . (string)($i + 1) . "*:"; + if ($i == $numShots - 1 ) print ' '; + print '
Descriptive Blurb*
(HTML format):
FAQ Directory*alexandria.rpgclassics.com/(system name)/
+ +


+

Edit Games
+

Please enter a search string for the game you wish to edit. You can edit screenshots now, but don't try deleting them, since that's still being worked on. +

+

+
Search for games containing
Game: +
System: + +
+

+


+

Delete A Game
+

Please enter the game and system you wish to delete. This will result in all information about the game to be deleted. Any "nickname" games referring to it will be deleted. Any "link" games will have their link deleted (although the game itself will still be there). This action cannot be undone! +

+

Game: +
System: + +
+

+


+

Add A Collection
+

+ + +
Number of games in collection:
+
+ blob - /dev/null blob + 5790432b4ff307b715b5f3d26e673b27ec1635a8 (mode 755) --- /dev/null +++ alexandria/database/gamedisplay.php @@ -0,0 +1,149 @@ + + +RPGC Database Games + +

RPGC Database Games

+ +select_db("games") or die ("Could not select database\n"); +$mode = $_GET['mode']; + +if ($mode == "nick") { + print "\n"; + $result = $link->query("SELECT name, system, developer, jppub, jpyear, napub, nayear, palpub, palyear, wanted, status, linkgid, sstatus FROM games ORDER BY name") or die("Query failed."); + while($row = mysqli_fetch_array($result, MYSQL_ASSOC)) + { print "\n"; + } + mysqli_free_result($result); + } + + else if ($mode == "nonick") + { print "\n"; + $result = $link->query("SELECT name, system, developer, jppub, jpyear, napub, nayear, palpub, palyear, wanted, status, linkgid, sstatus FROM games WHERE status <> 'N' ORDER BY name") or die("Query failed."); + while($row = mysqli_fetch_array($result, MYSQL_ASSOC)) + { print "\n"; + } + mysqli_free_result($result); + } + +else if ($mode == "blurb") +{ + $result = $link->query("SELECT name, system, blurb FROM games WHERE blurb <> '' ORDER BY name"); + if (mysql_num_rows($result) < 1) + { print "No games currently are assigned blurbs."; + return; + } + +print ""; +while($row = mysqli_fetch_array($result, MYSQL_ASSOC)) + { print "\n"; + } + mysqli_free_result($result); +} +else print "Internal code error: Mode unknown."; + mysqli_close($link); +} +?> +
NameSystemWanted?StatusShrine StatusLinked Game/SystemDeveloperJP PublisherYearNA PublisherYearPAL PublisherYear
"; + echo $row['name']; + print ""; + echo $row['system']; + print ""; + echo $row['wanted']; + print ""; + switch($row['status']) + { case "A": print "Normal"; break; + case "N": print "Nickname"; break; + case "L": print "Linked"; break; + default: print "Error"; + } + print ""; + switch($row['sstatus']) + { case "A": print "Available"; break; + case "I": print "In Progress"; break; + case "C": print "Completed"; break; + case "X": print "Unshrinable"; break; + default: print "Error"; + } + print ""; + $linkgid = $row['linkgid']; + if ($linkgid != null) + { $result2 = $link->query("SELECT name, system FROM games WHERE gid=$linkgid"); + $row2 = mysqli_fetch_array($result2, MYSQL_ASSOC); + echo $row2['name']; + print " ("; + echo $row2['system']; + print ")"; + mysqli_free_result($result2); + } + print ""; + echo $row['developer']; + print ""; + echo $row['jppub']; + print ""; + echo $row['jpyear']; + print ""; + echo $row['napub']; + print ""; + echo $row['nayear']; + print ""; + echo $row['palpub']; + print ""; + echo $row['palyear']; + print "
NameSystemWanted?StatusShrine StatusLinked Game/SystemDeveloperJP PublisherYearNA PublisherYearPAL PublisherYear
"; + echo $row['name']; + print ""; + echo $row['system']; + print ""; + echo $row['wanted']; + print ""; + switch($row['status']) + { case "A": print "Normal"; break; + case "L": print "Linked"; break; + default: print "Error"; + } + print ""; + switch($row['sstatus']) + { case "A": print "Available"; break; + case "I": print "In Progress"; break; + case "C": print "Completed"; break; + case "X": print "Unshrinable"; break; + default: print "Error"; + } + print ""; + $linkgid = $row['linkgid']; + if ($linkgid != null) + { $result2 = $link->query("SELECT name, system FROM games WHERE gid=$linkgid"); + $row2 = mysqli_fetch_array($result2, MYSQL_ASSOC); + echo $row2['name']; + print " ("; + echo $row2['system']; + print ")"; + mysqli_free_result($result2); + } + print ""; + echo $row['developer']; + print ""; + echo $row['jppub']; + print ""; + echo $row['jpyear']; + print ""; + echo $row['napub']; + print ""; + echo $row['nayear']; + print ""; + echo $row['palpub']; + print ""; + echo $row['palyear']; + print "
Name/SystemDescriptive Blurb
"; + echo $row['name']; + print " ("; + echo $row['system']; + print ")"; + echo $row['blurb']; + print "
\ No newline at end of file blob - /dev/null blob + 2e333f10b8aaf0af34c5a8efc04786060d3b51f9 (mode 755) --- /dev/null +++ alexandria/database/gamelist.php @@ -0,0 +1,5 @@ + "Gamecube", "Genesis" => "Genesis", "N64" => "Nintendo 64", "NES" => "NES", "PC" => "PC", "PSX" => "PlayStation", "PS2" => "PlayStation 2", "PSP" => "PlayStation Portable", "Saturn" => "Sega Saturn", "SNES" => "Super Nintendo", "XBox" => "XBox", "GB" => "Game Boy", "GBA" => "Game Boy Advance", "GBC" => "Game Boy Color", "Game Gear" => "Game Gear", "3DO" => "3DO", "Apple IIe" => "Apple IIe", "Apple IIGS" => "Apple IIGS", "Arcade" => "Arcade", "Atari 8-Bit" => "Atari 8-Bit", "Atari ST" => "Atari ST", "Commodore 64" => "Commodore 64", "Commodore Amiga" => "Commodore Amiga", "Dreamcast" => "Dreamcast", "FDS" => "Famicom Disk System", "FM Towns" => "FM Towns", "Mac" => "Macintosh", "MSX" => "MSX", "NDS" => "Nintendo DS", "NEC PC-8801" => "NEC PC-8801", "NEC PC-9801" => "NEC PC-9801", "Ngage" => "Nokia N-Gage", "NGPC" => "Neo Geo Pocket Color", "PC-Engine/TG-16" => "PC-Engine/TG-16", "PC-FX" => "PC-FX", "Sega CD" => "Sega CD", "SMS" => "Sega Master System", "Turbo Duo" => "Turbo Duo", "Wonderswan" => "Wonderswan", "WSC" => "Wonderswan Color", "X68000" => "X68000", "XBox" => "XBox", "XBox 360" => "XBox 360"); + include_once('alexandria-config.php'); + +?> blob - /dev/null blob + 67e961cf36467c16a7c6017b8cfc9316c99d7310 (mode 755) --- /dev/null +++ alexandria/database/login.php @@ -0,0 +1,15 @@ +Login Error

Please return to the login page and log in properly.
"; + exit; + } + $link = new mysqli("localhost", $username, $password); + if (!$link) + { print "Login Error

Invalid username/password!
"; exit; + } + setcookie("username", $username, time() + 31536000, "/"); + setcookie("password", $password, time() + 31536000, "/"); + header("Location: http://alexandria.rpgclassics.com/database/db2.html"); +?> \ No newline at end of file blob - /dev/null blob + be336e49945bd2fa9bf9f034e704d3ff4f320618 (mode 755) --- /dev/null +++ alexandria/database/logout.php @@ -0,0 +1,5 @@ + \ No newline at end of file blob - /dev/null blob + a099acc12b3617f8b62657636b9c5a3034d5c3ca (mode 755) --- /dev/null +++ alexandria/database/search.php @@ -0,0 +1,158 @@ + +Search Results

Search Results
+ +*/ + +function getstatus($status) +{ if ($status == "A") return "Norm"; + if ($status == "N") return "Nick"; + if ($status == "L") return "Link"; + if ($status == "C") return "Coll"; +} + +function numremove($word) +{ $oldword = $word; + $word = str_replace("20", "XX", $word); + $word = str_replace("19", "XIX", $word); + $word = str_replace("18", "XVIII", $word); + $word = str_replace("17", "XVII", $word); + $word = str_replace("16", "XVI", $word); + $word = str_replace("15", "XV", $word); + $word = str_replace("14", "XIV", $word); + $word = str_replace("13", "XIII", $word); + $word = str_replace("12", "XII", $word); + $word = str_replace("11", "XI", $word); + $word = str_replace("10", "X", $word); + $word = str_replace("9", "IX", $word); + $word = str_replace("8", "VIII", $word); + $word = str_replace("7", "VII", $word); + $word = str_replace("6", "VI", $word); + $word = str_replace("5", "V", $word); + $word = str_replace("4", "IV", $word); + $word = str_replace("3", "III", $word); + $word = str_replace("2", "II", $word); + $word = str_replace("1", "I", $word); + if ($word == $oldword) $searchadd = ""; + else $searchadd = " OR g.name LIKE \"%" . $word . "%\""; + + $word = strtolower($oldword); + $word = str_replace("xx", "20", $word); + $word = str_replace("xix", "19", $word); + $word = str_replace("xviii", "19", $word); + $word = str_replace("xvii", "17", $word); + $word = str_replace("xvi", "16", $word); + $word = str_replace("xv", "15", $word); + $word = str_replace("xiv", "14", $word); + $word = str_replace("xiii", "14", $word); + $word = str_replace("xii", "12", $word); + $word = str_replace("xi", "11", $word); + $word = str_replace("ix", "9", $word); + $word = str_replace("x", "10", $word); + $word = str_replace("viii", "8", $word); + $word = str_replace("vii", "7", $word); + $word = str_replace("vi", "7", $word); + $word = str_replace("iv", "4", $word); + $word = str_replace("v", "5", $word); + $word = str_replace("iii", "3", $word); + $word = str_replace("ii", "2", $word); + $word = str_replace("i", "1", $word); + if ($word == $oldword) $searchadd .= ""; + else $searchadd .= " OR g.name LIKE \"%" . $word . "%\""; + return $searchadd; +} + + define("MAX_RESULTS", 20); + + $search = $_POST['search']; + $system = $_POST['system']; + $mode = $_POST['mode']; + $page = $_POST['page']; + if ($mode == "") + { print ""; + exit; + } + + $search = $_POST['search']; + $system = $_POST['system']; + $mode = $_POST['mode']; + $page = $_POST['page']; + + if (!strcasecmp(substr($search, 0, 4), "The ")) $search = substr($search, 4); //strip "The " from start + if ($page == "") $page = 1; + + $query = "SELECT * from games as g WHERE "; + if ($mode == "any") + { $words = explode(" ", $search); + $query .= "(g.name LIKE \"%" .$words[0] . "%\"" . numremove($words[0]); + for ($i = 1; $i < sizeof($words); $i++) $query .= " OR (g.name LIKE \"%" . $words[$i] . "%\"" . numremove($words[$i]) . ')'; + } + elseif ($mode == "all") + { $words = explode(" ", $search); + $query .= "(g.name LIKE \"%" . $words[0] . "%\"" .numremove($words[0]) . ')'; + for ($i = 1; $i < sizeof($words); $i++) $query .= " AND (g.name LIKE \"%" . $words[$i] . "%\"" . numremove($words[$i]) . ")"; + } + else $query .= "(g.name LIKE \"%$search%\"" .numremove($search) . ")"; + + $query .= " ORDER BY g.name, g.system"; + + $result = mysql_query($query) or die("Error fetching game information!"); + + if (mysql_num_rows($result) < 1) + { print "
No results were found.
"; + return; + } + print ''; + print ''; + + $i = 0; + while ($row = mysql_fetch_array($result)) + { if ($i <= (($page - 1) * MAX_RESULTS) - 1) {$i++; continue;} + if ($i > ($page * MAX_RESULTS) - 1) break; + $gid = $row['gid']; + $egid = $gid; + $name = $row['name']; + $gsystem = $row['system']; + $status = $row['status']; + if ($row['sstatus'] == 'X') + { $egid = $row['linkgid']; + $result2 = mysql_query("SELECT * from games where gid='$egid'") or die("Error in second query!"); + $row2 = mysql_fetch_array($result2); + if ($row2['sstatus'] == 'X') $egid = $row2['linkgid']; + } + print ""; + print ""; + $i++; + } + print '
Game NameStatus
$name ($gsystem)"; + print "" . getstatus($status) . "
   [View] [Edit]
'; + + print "
"; + if ($page > 1) + { print "
"; + print ""; + print ""; + print ""; + print ""; + print "
"; + } + print "
"; + if ($row != FALSE) + { $page++; + print "
"; + print ""; + print ""; + print ""; + print ""; + $next = mysql_num_rows($result) - $i ; + if ($next > MAX_RESULTS) $next = MAX_RESULTS; + print ""; + } + mysql_free_result($result); + print "
"; + +?> + \ No newline at end of file