Permalink
Browse files

first, and probably only, commit

  • Loading branch information...
0 parents commit 75ef290012037fc64fddd9bc098ba270c95d38eb james committed May 31, 2010
Showing with 1,504 additions and 0 deletions.
  1. +13 −0 README
  2. +142 −0 a/add.php
  3. +94 −0 a/category.php
  4. +15 −0 a/config.php
  5. +130 −0 a/edit.php
  6. +280 −0 a/index.php
  7. +13 −0 a/loggedin.php
  8. +26 −0 a/login.php
  9. +75 −0 browse.php
  10. 0 css/style.css
  11. +62 −0 db.sql
  12. +47 −0 game.php
  13. +45 −0 game3.php
  14. BIN images/bg-content.gif
  15. +20 −0 inc/config.php
  16. +13 −0 inc/db.php
  17. +96 −0 inc/global.php
  18. +345 −0 inc/template.tpl
  19. +44 −0 index.php
  20. +44 −0 search.php
13 README
@@ -0,0 +1,13 @@
+This is a flash game hosting site written in PHP. Needs PHP 4+, MySQL, and Apache with mod_rewrite
+
+Install:
+
+Create a database
+
+Run the db.sql file using phpMyAdmin or similar
+
+Add the database info to inc/db.php
+
+Edit inc/config.php to change the site name, description, and Google Adsense ID
+
+Copy files to your server
142 a/add.php
@@ -0,0 +1,142 @@
+<?php require_once("loggedin.php");
+require_once("../inc/db.php");
+error_reporting(E_ALL);
+//print_r($_FILES);
+
+//exit;
+
+if($_POST['do'] == "add") {
+ $v3arcade = false;
+ if(is_uploaded_file($_FILES['varcade']['tmp_name'])) {
+ $file = file_get_contents($_FILES['varcade']['tmp_name']);
+ $start = strpos($file,"## EDIT HERE ##");
+ $stop = strpos($file,"## NO MORE EDITS BELOW THIS LINE ##");
+ $eval = "//".substr($file,$start,$stop-$start);
+ eval($eval);
+ if(isset($title) && isset($shortname) && isset($description) && isset($game_width) && isset($game_height)) {
+ $v3arcade = true;
+ }
+ }
+
+ if($_POST['type'] == "SWF"){
+ if(is_uploaded_file($_FILES['swf']['tmp_name'])) {
+ $targetpath = "../swf/".basename($_FILES['swf']['name']);
+ //$targetpath = basename($_FILES['swf']['name']);
+ //echo $targetpath;
+ if(move_uploaded_file($_FILES['swf']['tmp_name'],$targetpath)) {
+ $swf = str_replace("..","",$targetpath);
+ }
+ else echo "error 2";
+ }
+ else echo "error 1";
+ }
+ else {
+ $swf = $_POST['url'];
+ }
+ if(is_uploaded_file($_FILES['thumbnail1']['tmp_name'])) {
+ $targetpath = "../thumbs/".basename($_FILES['thumbnail1']['name']);
+ if(move_uploaded_file($_FILES['thumbnail1']['tmp_name'],$targetpath)) {
+ $image1 = str_replace("..","",$targetpath);
+ }
+ }
+ if(is_uploaded_file($_FILES['thumbnail2']['tmp_name'])) {
+ $targetpath = "../thumbs/".basename($_FILES['thumbnail2']['name']);
+ if(move_uploaded_file($_FILES['thumbnail2']['tmp_name'],$targetpath)) {
+ $image2 = str_replace("..","",$targetpath);
+ }
+ }
+ if(!$v3arcade) {
+ $query = "INSERT INTO `games` VALUES (NULL,
+ '".$_POST['shortname']."',
+ '".$_POST['longname']."',
+ '".$image1."',
+ '".$image2."',
+ '".$swf."',
+ '".$_POST['desc']."',
+ '".$_POST['descsmall']."',
+ '".$_POST['width']."', '".$_POST['height']."',
+ '".$_POST['category']."',
+ '".$_POST['type']."',
+ '".$_POST['keywords']."',
+ 0,
+ 'Yes')";
+ }
+ else {
+ $query = "INSERT INTO `games` VALUES (NULL,
+ '".$shortname."',
+ '".$title."',
+ '".$image1."',
+ '".$image2."',
+ '".$swf."',
+ '".$description."',
+ '".$_POST['descsmall']."',
+ '".$game_width."', '".$game_height."',
+ '".$_POST['category']."',
+ '".$_POST['type']."',
+ '".$_POST['keywords']."',
+ 0,
+ 'Yes')";
+ }
+
+ @mysql_query($query) or die("<b>MySQL ERROR</b><br /><br />".mysql_error());
+
+ echo "<html><head><title>Added Successfully</title></head><body><center><br /><br />Game Added Successfully<br /><br /><br /><a href=\"add.php\">Add Another</a><br /><a href=\"index.php?pane=right\">Return to Admin Index</a></body></html>";
+ exit;
+}
+else {
+
+?>
+<html><head>
+<title>Add Game</title>
+<style type="text/css">
+body
+{
+ line-height: 2.0em;
+}
+</style>
+</head>
+<body>
+<form action="add.php" method="post" enctype="multipart/form-data">
+<h1>Add Game</h1>
+
+<input type="hidden" name="do" value="add" />
+v3Arcade Install File: <input type="file" name="varcade" /><br /><br />
+
+Name: <input type="text" name="longname" /><br />
+Short name (url name): <input type="text" name="shortname" /><br />
+
+Category: <select name="category">
+<?php include("../inc/db.php");
+$result = mysql_query("SELECT * FROM `categories` WHERE `type` = 'Games' ORDER BY `name`");
+$num = mysql_numrows($result);
+
+for($i=0;$i<$num;$i++) {
+ echo "<option value=\"".mysql_result($result,$i,"name")."\">".mysql_result($result,$i,"name")."</option>\n";
+}
+?>
+</select><br />
+Description: <br /><textarea name="desc" rows="5" cols="25"></textarea><br />
+Description (short, optional):<br /> <textarea name="descsmall" rows="3" cols="25"></textarea><br />
+
+<br />
+
+Type: <select name="type"><option value="SWF">SWF</option><option value="extlink">External Link</option><option value="CustomCode">Custom Code</option></select><br />
+SWF: <input type="file" name="swf" /><br />
+Thumbnail Large: <input type="file" name="thumbnail1" /><br />
+Thumbnail Small (optional): <input type="file" name="thumbnail2" /><br />
+<br />
+Width: <input type="text" name="width" /><br />
+Height: <input type="text" name="height" /><br />
+<br />
+Keywords: <input type="text" name="keywords" />
+
+<br /><br />
+<input type="submit" value="Add Game" />
+
+
+
+</form>
+<?php
+}
+?>
+</body></html>
@@ -0,0 +1,94 @@
+<?php require_once("loggedin.php");
+require_once("../inc/db.php");
+error_reporting(E_ALL);
+
+function errorproc($content) {
+ echo "<html><head><title>Error!</title>
+ <script type=\"text/javascript\">
+ function goback() {
+ history.go(-1);
+ return false;
+ }
+ </script>
+ </head><body>
+ There was an error processing your information.<br /><br />
+ Error: $content<br /><br />
+ <a href=\"".$_SERVER['HTTP_REFERER']."\" onclick=\"return goback()\">Go Back</a>
+ </body></html>";
+ exit;
+}
+
+if(isset($_GET['remove'])) {
+ if(isset($_GET['confirm']) AND $_GET['confirm'] == "yes") {
+ if(isset($_GET['updategames']) AND $_GET['updategames'] == "on") {
+ if($_GET['moveto'] == "") {
+ errorproc("Need to set new category name for games to be moved into");
+ }
+ else {
+ mysql_query("UPDATE `games` SET `cat` = '".$_GET['moveto']."' WHERE `cat` = '".$_GET['remove']."'") or die("MySQL Error: ".mysql_error());
+ }
+ }
+ mysql_query("DELETE FROM `categories` WHERE `name` = '".$_GET['remove']."' LIMIT 1") or die("MySQL Error: ".mysql_error());
+ echo "Successfully deleted... <a href=\"category.php\">Back To Cateory Management</a>";
+ exit;
+ }
+
+
+ echo "<html><head><title>Confirm Deletion</title></head><body>";
+ echo "<br />Are you sure you want to remove category '".$_GET['remove']."'?<br /><br />";
+ echo "<form action=\"category.php\" method=\"get\"><input type=\"hidden\" name=\"remove\" value=\"".$_GET['remove']."\" /><input type=\"hidden\" name=\"confirm\" value=\"yes\" /><input type=\"checkbox\" name=\"updategames\" />
+ Move games from old category to <select name=\"moveto\">";
+ $result = mysql_query("SELECT * FROM `categories` WHERE `name` != '".$_GET['remove']."' ORDER BY `name` ASC");
+ for($i=0;$i<mysql_numrows($result);$i++) {
+ echo "<option value=\"".mysql_result($result,$i,"name")."\">".mysql_result($result,$i,"name")."</option>";
+ }
+ echo "</select>?<br /><br />
+ <input type=\"submit\" value=\"Confirm\" /> <input type=\"button\" value=\"Cancel\" onclick=\"history.go(-1)\" /></form>
+ </body></html>";
+ exit;
+
+}
+
+if(isset($_GET['edit'])) {
+ if(isset($_GET['confirm']) AND $_GET['confirm'] == "yes") {
+ if($_GET['newname'] == "") errorproc("You need to put a new name for the category");
+ if(isset($_GET['updategames']) AND $_GET['updategames'] == "on") {
+ mysql_query("UPDATE `games` SET `cat` = '".$_GET['newname']."' WHERE `cat` = '".$_GET['edit']."'") or die("MySQL Error: ".mysql_error());
+ }
+ mysql_query("UPDATE `categories` SET `name` = '".$_GET['newname']."' WHERE `name` = '".$_GET['edit']."' LIMIT 1") or die("MySQL Error: ".mysql_error());
+ echo "Successfully changed....<a href=\"category.php\">Go Back To Category Management</a>";
+ exit;
+ }
+
+ echo "<html><head><title>Edit Category</title></head><body>
+ <form action=\"category.php\" method=\"get\">
+ <input type=\"hidden\" name=\"edit\" value=\"".$_GET['edit']."\" />
+ <input type=\"hidden\" name=\"confirm\" value=\"yes\" />
+ New Name: <input type=\"text\" name=\"newname\" /><br />
+ <input type=\"checkbox\" name=\"updategames\" checked=\"checked\" /> Update Games?<br /><br />
+ <input type=\"submit\" value=\"Confirm\" /> <input type=\"button\" value=\"Cancel\" onclick=\"history.go(-1)\" /></form>
+ </body></html>";
+ exit;
+}
+
+if(isset($_GET['category'])) {
+ mysql_query("INSERT INTO `categories` VALUES(NULL, '".$_GET['category']."', 'Games', '', '', 0)")or die("MySQL Error: ".mysql_error());
+ echo "Added ".$_GET['category']."...<a href=\"category.php\">Go Back To Category Management</a>";
+ exit;
+}
+
+$result = mysql_query("SELECT * FROM `categories` ORDER BY `name` ASC");
+
+echo "<html><head><title>Category Management</title></head><body>";
+echo "<table><thead><th>Category</th><th>Num Games</th><th>Remove</th><th>Edit</th></thead>";
+for($i=0;$i<mysql_numrows($result);$i++) {
+ $category = mysql_result($result,$i,"name");
+ echo "<tr><td>$category</td><td style=\"text-align: center;\">".mysql_result(mysql_query("SELECT COUNT(*) AS `count` FROM `games` WHERE `cat` = '$category'"),0,"count")."</td><td><a href=\"category.php?remove=$category\" rel=\"nofollow\">Remove</a></td><td><a href=\"category.php?edit=$category\">Edit</a></tr>";
+}
+echo "</table>";
+?>
+<br /><br />
+<form action="category.php" method="get">
+<input type="text" name="category" /><input type="submit" value="Add New" />
+</form>
+</body></html>
@@ -0,0 +1,15 @@
+<?php
+
+$user = "ah_skeet";
+
+// OPTIONS
+// MD5 of password. This way is suggested
+$md5 = "d8578edf8458ce06fbc5bb76a58c5ca4";
+// OR enter plain text password. Not suggested
+$pass = "";
+
+
+
+
+
+?>
Oops, something went wrong.

0 comments on commit 75ef290

Please sign in to comment.