index.php
<?php //Note, you have to edit config.php with the required details. require "config.php"; $fooledkey = "fooled2008"; if(isset($_GET['action']) && $_GET['action']=="SHOW_SOURCE_CODE") { ?> <html><head><title>SOURCE CODE</title></head><body> <?php foreach ($php_files as $filename) { echo "<p>" . $filename . "</p>\n"; echo "<form><textarea rows=\"25\" cols=\"120\">\n"; $handle = @fopen($filename, "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); if(strncmp($buffer,"//SKIPLINE",10)==0) { echo "//Source code redacted\n"; echo "//SKIPLINE\n"; while (!feof($handle)&&(strncmp($buffer,"//RESUMELINE",10)!=0)) { $buffer = fgets($handle, 4096); } echo "//RESUMELINE\n"; echo "//End of redacted source code\n"; } else { echo htmlentities($buffer); } } fclose($handle); } else { echo "FAILED TO OPEN \"" . $filename . "\"\n"; } echo "</textarea>\n"; echo "</form>\n\n"; } echo "</body></html>"; return; } include( './render_row.php' ); $aprilfools = 0; /*if(((date("d-m")=="01-04")&&($_GET['fooled']!=$fooledkey))||($_GET['fooled']=="foolpage")) { $aprilfools = 1; }*/ $conn = new mysqli($location,$username,$password, $database); if ($conn->connect_error) die ("Connection failed: " . $conn->connect_error); // $timestart = microtime(true); if($aprilfools == 0) { include( './header.php' ); //echo "This was the april fools joke. <a href=\"index.php?fooled=foolpage\">link!</a>"; /* If($_GET['sortby']=="") { $sortby = "game"; } else { $sortby = $_GET['sortby']; if($sortby != "game" && $sortby != "size" && $sortby != "ripper" && $sortby != "tagger" && $sortby != "tracks" && $sortby != "cpu" && $sortby != "updated") { $sortby = "game"; } } If($_GET['order']=="" || $_GET['order']=="ASC") { $order = "ASC"; } else { $order = "DESC"; } */ if(isset($_GET['sortby'])) { switch($_GET['sortby']) { case "gamea": $sortby = "game"; $order = "ASC"; break; case "gamed": $sortby = "game"; $order = "DESC"; break; case "sizea": $sortby = "size"; $order = "ASC"; break; case "sized": $sortby = "size"; $order = "DESC"; break; case "rippera": $sortby = "ripper"; $order = "ASC"; break; case "ripperd": $sortby = "ripper"; $order = "DESC"; break; case "taggera": $sortby = "tagger"; $order = "ASC"; break; case "taggerd": $sortby = "tagger"; $order = "DESC"; break; case "tracksa": $sortby = "tracks"; $order = "ASC"; break; case "tracksd": $sortby = "tracks"; $order = "DESC"; break; case "cpua": $sortby = "cpu"; $order = "ASC"; break; case "cpud": $sortby = "cpu"; $order = "DESC"; break; case "updateda": $sortby = "updated"; $order = "ASC"; break; case "updatedd": $sortby = "updated"; $order = "DESC"; break; default: $sortby = "game"; $order = "ASC"; break; } } else { $sortby = "game"; $order = "ASC"; } //<a href="index.php?action=login">Login to Admin Area</a><br> ?> <br><br> <table border="1" width="100%"> <tr> <td align="center" width="18%">Game <a href="index.php?sortby=gamea"><img src="images/s_asc.png" alt="Ascending"></a> <a href="index.php?sortby=gamed"><img src="images/s_desc.png" alt="Descending"></a></td> <td align="center" width="6%">Size <a href="index.php?sortby=sizea"><img src="images/s_asc.png" alt="Ascending"></a> <a href="index.php?sortby=sized"><img src="images/s_desc.png" alt="Descending"></a></td> <td align="center" width="10%">Ripper <a href="index.php?sortby=rippera"><img src="images/s_asc.png" alt="Ascending"></a> <a href="index.php?sortby=ripperd"><img src="images/s_desc.png" alt="Descending"></a></td> <td align="center" width="14%">Tagger <a href="index.php?sortby=taggera"><img src="images/s_asc.png" alt="Ascending"></a> <a href="index.php?sortby=taggerd"><img src="images/s_desc.png" alt="Descending"></a></td> <td align="center" width="5%">Tracks <a href="index.php?sortby=tracksa"><img src="images/s_asc.png" alt="Ascending"></a> <a href="index.php?sortby=tracksd"><img src="images/s_desc.png" alt="Descending"></a></td> <td align="center" width="11%">Average GBA CPU usage % <a href="index.php?sortby=cpua"><img src="images/s_asc.png" alt="Ascending"></a> <a href="index.php?sortby=cpud"><img src="images/s_desc.png" alt="Descending"></a></td> <td align="center" width="19%">Status/Link</td> <td align="center" width="11%">Last Updated <a href="index.php?sortby=updateda"><img src="images/s_asc.png" alt="Ascending"></a> <a href="index.php?sortby=updatedd"><img src="images/s_desc.png" alt="Descending"></a></td> </tr> <?php $query = "SELECT * FROM `complete_gsf` WHERE `status` = 'Complete' AND homebrew = '0' ORDER BY ".$sortby." ".$order; MakeTable($conn, $query,"Complete"); $query = "SELECT * FROM `complete_gsf` WHERE `status` != 'Complete' AND homebrew = '0' ORDER BY ".$sortby." ".$order; MakeTable($conn, $query,"Needs Tags/Timers"); echo "<!--<tr> <td align=\"center\">All of my Private emails</td> <td align=\"center\">1.5MB</td> <td align=\"center\">CaitSith2</td> <td align=\"center\"> </td> <td align=\"center\">85-90</td> <td align=\"center\"> </td> <td align=\"center\"><a href=\"http://www.caitsith2.com/isothermal.php\">Needs Tagging/Timing</a></td> <td align=\"center\">Jan 15, 2004</td> </tr>-->"; $query = "SELECT * FROM `complete_gsf` WHERE homebrew = '1' ORDER BY ".$sortby." ".$order; MakeTable($conn, $query,"Homebrew Stuff"); $query = "SELECT * FROM `complete_gsf` WHERE homebrew = '2' ORDER BY ".$sortby." ".$order; MakeTable($conn, $query,"GBS2GSF conversions"); //Access to private files restricted. If lost in future webhost crash, so be it. //Source code redacted //End of redacted source code echo "</table>"; include ( './footer.php' ); //$timeend = microtime(true); //$timetaken = $timeend - $timestart; //echo "Rendering of page took $timetaken seconds."; ?> </body> </html> <?php Return; } /*else if ($aprilfools == 1) { include('./aprilfools.php'); echo "April <a href=\"index.php?fooled=$fooledkey\">Fools!</a>"; }*/ ?>
header.php
<html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta name="keywords" content="GSF Central Highly Advanced"> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" l gen true for "http://www.caitsith2.com" r (nz 1 vz 1 lz 1 oz 1 cz 1) gen true for "http://caitsith2.com" r (nz 1 vz 1 lz 1 oz 1 cz 1) gen true for "http://www.alpha-ii.com" r (nz 1 vz 1 lz 1 oz 1 cz 1) gen true for "http://www.w3.org" r (nz 1 vz 1 lz 1 oz 1 cz 1))'> <title>GSF Central</title> </head> <body> <script type="text/javascript"><!-- google_ad_client = "pub-6400824617468068"; google_alternate_color = "FFFFFF"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = ["336699","000000"]; google_color_bg = ["FFFFFF","F0F0F0"]; google_color_link = "0000FF"; google_color_url = "008000"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <p><font size="6"><b>GSF Central</b></font></p> <p>GSF is a <a href="http://www.neillcorlett.com/psf/">PSF</a> format for the Gameboy Advance.</p> <p> <img border="0" src="images/HA_logo.jpg" alt="HA Logo"> <br>GSF player v 0.11 by CaitSith2 and Zoopd<br><a href="player/HA_0.11.exe">download</a> - <a href="player/in_gsf_src_0.11.rar">Source code</a> - <a href="HA%20version%20history.txt"> Version History</a></p> <p>If you are having crashing issues, try these things first.</p> <ul> <li>Do a clean reinstall of winamp. 99% of the time, this fixes the problem, because a clean reinstall means none of the plugins that were conflicting with Highly Advance are present.</li> <li>If the clean install worked, then add in plugins one at a time. When doing so, try to make sure you have the latest versions of the plugins.</li> <li>Finally, as a last resort, if you are still having crashing issues, try <a href="player/HA_0.11ni.exe">this</a> build, with has the interpolation code removed.</li> </ul> <p><a href="gsf%20spec.txt">GSF Specs v0.02</a></p> <p>There is now a player available for linux, based on Highly Advanced 0.11. Get it at <a href="http://projects.raphnet.net/#playgsf">http://projects.raphnet.net/#playgsf</a>. </p> <p>If you are an Audio programmer for whatever GBA game you are working on, and wish to allow the game your working on to be easily ripped to the GSF format, then you can include the following <a href="gsf driver block.c">block</a> of code in your program, and follow the instructions inside of that block.</p>
footer.php
<p>If you have tagged/timed a set, you can mail it to me at gsf [at] caitsith2 [dot] net. When you send me the set, please include the gsflib. Whoever does the site update might not have it on hand. These are the general tagging standards that should be followed.</p> <ul> <li>Time everything to 2 loops. Everything means unknown songs as well as known songs.</li> <li>Songs that end naturally should not have a fadeout. As YK always says, "You cannot fade silence".</li> <li>Follow OST numbering if there is an OST available. If not, then number in reasonable in game order. Use sound test order (if applicable), as a last resort.</li> <li>Finally, when emailing your submission, begin the subject line with [GSF], so that when the floods of infected emails do come, I don't accidently delete the submission in the process. </li> </ul> <p>If you are interested in the source code for this page, click <a href="?action=SHOW_SOURCE_CODE">here.</a></p> <p>The Current Site Admins able to add/update sets are, (in no particular order)</p> <ul> <li>CaitSith2</li> <li>Datschge</li> <li>UNKNOWNFILE</li> </ul> <p>* - Sap Tapper, still a work in progress was written by CaitSith2, and if you look in the sets gsfby tag, you will see "Sap Tapper" there.</p> <p>(*) in the updated column means that there was more than one update that day.</p> <p>You can get the ripping tools <a href="ripping.html">here</a>.</p> <p> <a href="http://validator.w3.org/check?uri=referer"><img border="0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" height="31" width="88"></a> </p>
render_row.php
<?php function render_row($results) { while($row = $results->fetch_assoc()) { if(file_exists("rebuild/render_row.php")) //Live or testing version. $filename = "./gsfs/".$row['file']; else $filename = "../gsfs/".$row['file']; if(file_exists($filename) || !file_exists("rebuild/render_row.php") || isset($_GET['show_broken_links'])) { if(file_exists($filename)) { if(filesize($filename) > 0) $background = ">"; else $background = " bgcolor=\"#FFFF00\">"; //Although the link IS valid, a zero byte file is still a problem. } else $background = " bgcolor=\"#FF0000\">"; echo "<tr>\n\t"; echo "<td align=\"center\" width=\"18%\"" . $background . $row['game'] . " </td> \n\t"; echo "<td align=\"center\" width=\"6%\"" . $background . $row['size'] . " </td> \n\t"; echo "<td align=\"center\" width=\"10%\"" . $background . $row['ripper'] . " </td> \n\t"; echo "<td align=\"center\" width=\"14%\"" . $background . $row['tagger'] . " </td> \n\t"; echo "<td align=\"center\" width=\"5%\"" . $background . $row['tracks'] . " </td> \n\t"; echo "<td align=\"center\" width=\"11%\"" . $background . $row['cpu'] . " </td> \n\t"; echo "<td align=\"center\" width=\"19%\"" . $background . "<a href=\"gsfs/" . $row['file'] . "\">" . $row['status'] . "</a>" . " </td> \n\t"; echo "<td align=\"center\" width=\"11%\"" . $background . $row['updated'] . " </td> \n\t"; echo "</tr>\n"; } } Return; } function MakeTable($conn, $sqlquery, $title_header) { $result = $conn->query($sqlquery); echo "<tr>\n"; echo "\t<td colspan=\"8\" align=\"center\" bgcolor=\"#00FF00\"><b>"; echo $title_header; echo "</b></td>\n"; echo "</tr>\n"; render_row($result); Return; } ?>
admin.php
<html><head><title>GSF Central Admin Area Login</title></head> <body> <?php //Note, you have to edit config.php with the required details. require "config.php"; $conn = new mysqli($location,$username,$password, $database); if ($conn->connect_error) die ("Connection failed: " . $conn->connect_error); if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { $loginForm = "<form action=\"admin.php?action=login\" method=\"POST\"> Login: <input type=\"text\" name=\"login\" size=\"20\"/><br /> Password: <input type=\"password\" name=\"password\" size=\"20\"/><br /> <input type=\"submit\" name=\"submit\" /><br /> </form>"; } else { echo "Sorry, you must connect to the admin interface over a secure connection"; die(); } $loginError = "Login Error: Please try again<br/>"; /** * @author CaitSith2 * @copyright 2010 */ $user = NULL; if (!isset($_GET['action']) || !isset($_POST['login']) || (!isset($_POST['password']) && !isset($_POST['session_id']))) { echo $loginForm; } else if ($_GET['action']=="login") { $login = preg_replace("/[^A-Za-z0-9 ]/", '', $_POST['login']); $query = "SELECT * FROM `users`"; $result = $conn->query($query); if ($result->num_rows == 0) { $query = "INSERT INTO `users` (`username`, `password`, `addset`, `updateset`, `delset`, `addadmin`, `updateha`) VALUES ('" . $login . "', '" . password_hash($_POST['password'], PASSWORD_DEFAULT) . "', '1', '1', '1', '1', '1')"; if ($conn->query($query) === TRUE) { echo "Admin user created successfully"; } else { echo "Error: " . $query . "<br>" . $conn->error . "<br><br>"; } } $query = "SELECT * FROM `users` WHERE `username` = '".$login."'"; $result = $conn->query($query); if($result->num_rows > 0) { while($row = $result->fetch_assoc()) { if(isset($_POST['password']) && password_verify($_POST['password'], $row["password"])) $user = $row; else if(isset($_POST['session_id']) && $row['session'] == $_POST['session_id']) { $loginError = "Session Expired. Please login again.<br>"; if(time() <= $row['session_expiration']) $user = $row; } } if ($user == NULL) { echo $loginError . "<br><br>" . $loginForm; } else { if(isset($_POST['password'])) echo "Login Successful. :) <br />"; $expiration = time() + 900; //15 minutes expiration. if(isset($_POST['session_id'])) $sessionkey = preg_replace("/[^A-Za-z0-9 ]/", '', $_POST['session_id']); else $sessionkey = preg_replace("/[^A-Za-z0-9 ]/", '', password_hash($expiration, PASSWORD_DEFAULT)); $query = "UPDATE `users` SET `session` = '" . $sessionkey . "', `session_expiration` = '" . $expiration . "' WHERE `users`.`username` = '" . $login . "'"; if ($conn->query($query) === FALSE) { echo "Could not maintain persistent session :(<br>"; } echo "ADMIN Area mostly not implemented yet. :P<br><br>"; echo "User: " . $user["username"] . "<br>"; echo "Password hash: " . $user["password"] . "<br>"; echo "Session ID: " . $user["session"] . "<br>"; echo "Session Expiration: " . $user["session_expiration"] . "<br>"; echo "Add GSF Sets: " . $user["addset"] . "<br>"; echo "Update GSF Sets: " . $user["updateset"] . "<br>"; echo "Delete GSF Sets: " . $user["delset"] . "<br>"; echo "Add Administrators: " . $user["addadmin"] . "<br>"; echo "Update Highly Advanced player: " . $user["updateha"] . "<br>"; echo "<form action=\"admin.php?action=login\" method=\"POST\"> <input type=\"hidden\" name=\"login\" value=\"" . $user["username"] . "\"/><br /> <input type=\"hidden\" name=\"session_id\" value=\"" . $sessionkey . "\" /><br />" . "<input type=\"hidden\" name=\"action2\" value=\"go_live\"/><br />" . "<input type=\"submit\" name=\"Go Live\" /><br /> </form>"; } } else { echo $loginError . "<br><br>" . $loginForm; } } if(isset($_POST['action2']) && $user != NULL) { switch($_POST['action2']) { case "go_live": echo "Moving everthing to production<br>"; foreach ($php_files as $filename) { copy($filename, "../" . $filename); } echo "Done<br>"; break; default: echo "This feature is NOT Implemented"; break; } } $conn->close(); ?> </body></html>
config.php
<?php $php_files = array("index.php", "header.php", "footer.php", "render_row.php", "admin.php", "config.php"); //These fields need to be set to point to a database. $location = "location of database, usually localhost"; $username = "username to access database"; $password = "password to access database"; $database = "name of database to access"; /*This is what your tables need to look like. CREATE TABLE `complete_gsf` ( `primarykey` int(11) NOT NULL auto_increment, `game` varchar(255) NOT NULL default '', `size` int(11) NOT NULL default '0', `ripper` varchar(32) NOT NULL default '', `tagger` varchar(32) default NULL, `tracks` smallint(6) NOT NULL default '0', `cpu` varchar(10) default NULL, `status` varchar(32) NOT NULL default '', `updated` date NOT NULL default '0000-00-00', `homebrew` tinyint(4) NOT NULL default '0', `file` varchar(128) default NULL, `homepage` varchar(64) default NULL, PRIMARY KEY (`primarykey`), KEY `game` (`game`) ) ENGINE=MyISAM AUTO_INCREMENT=270 DEFAULT CHARSET=latin1; and CREATE TABLE `users` ( `primarykey` int(11) NOT NULL auto_increment, `username` text character set ascii NOT NULL, `password` text character set ascii NOT NULL, `passcode` bigint(20) NOT NULL default '0', `passcodekey` varchar(64) default NULL, `addset` tinyint(4) NOT NULL default '0', `updateset` tinyint(4) NOT NULL default '0', `delset` tinyint(4) NOT NULL default '0', `addadmin` tinyint(4) NOT NULL default '0', `updateha` tinyint(4) NOT NULL default '0', PRIMARY KEY (`primarykey`) ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1; //passcode/passcode key of the usertable, are for 2nd factor authentication, perfect paper passwords. //It is optional. The values in between the //SKIPLINE and //RESUMELINE, are values that are automatically redacted from the source code view. */ //Source code redacted //SKIPLINE //RESUMELINE //End of redacted source code