Skip to content
Browse files

The real first import

  • Loading branch information...
1 parent a67bdc6 commit b19176706640891e55c37c57436ede60ae7332a3 @ericboehs committed Oct 27, 2008
View
21 README
@@ -0,0 +1,21 @@
+This is a WoW Addon Manager coded in PHP by Eric Boehs.
+
+Installation:
+1. Edit the "config.php.example" and save it as "config.php".
+2. Navigate to the install directory with your web browser.
+3. Remove the install directory.
+4. Add a cronjob to run the dailyUpdater.php everyday. (This step isn't required, it will just speed up the zip file creation process and clean up the customZips directory, which will get large over time).
+5. Add some addons!
+
+Adding Addons:
+1. Navigate to http://curse.com and find an addon you would like to add.
+2. Mouse over the "Install via curse client" image and get the Addon ID. For example: the addon QuestHelper has an Addon ID of 4922.
+3. Go to the admin panel and type the Addon ID followed by enter. Your addon may take a little while to add (depending on the file size). Be Patient. Once it has downloaded from curse.com to your web server, it will be added and should show in the admin panel.
+
+That's it! Everything else should be pretty intuitive (manually updating, downloading, deleting).
+
+Features:
+-Keeps addons synced with curse.com
+-Creates a custom zip file of all the addons you choose
+-Allows easy adding and removing of addons via a control panel
+-Add addons via a bookmarklet (click a bookmark, click install with curse client) (This is experimental - having an issue in firefox)
View
BIN admin/.DS_Store
Binary file not shown.
View
41 admin/ajax.js
@@ -0,0 +1,41 @@
+var myimage = new Image();
+myimage.src = 'loading.gif';
+//Browser Support Code
+function ajaxFunction(){
+ var ajaxRequest; // The variable that makes Ajax possible!
+
+ try{
+ // Opera 8.0+, Firefox, Safari
+ ajaxRequest = new XMLHttpRequest();
+ } catch (e){
+ // Internet Explorer Browsers
+ try{
+ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ try{
+ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e){
+ // Something went wrong
+ alert("Your browser broke!");
+ return false;
+ }
+ }
+ }
+ // Create a function that will receive data sent from the server
+ ajaxRequest.onreadystatechange = function(){
+ if(ajaxRequest.readyState == 1){
+ var ajaxDisplay = document.getElementById('ajaxDiv');
+ //ajaxDisplay.innerHTML = "<img src=\"../images/loading.gif\" alt=\"Loading... Please wait\" />";
+ }
+ if(ajaxRequest.readyState == 4){
+ var ajaxDisplay = document.getElementById('ajaxDiv');
+ ajaxDisplay.innerHTML = ajaxRequest.responseText;
+ }
+ }
+ //var myid = document.getElementById('myid').value;
+ var queryString = "?curseAddonID=";// + myid;
+ ajaxRequest.open("GET", "listAddonsQuery.php" + queryString, true);
+ ajaxRequest.send(null);
+ document.addAddon.elements[0].focus();
+}
+setInterval(ajaxFunction, 5000);
View
0 admin/index.php
No changes.
View
105 admin/listAddons.php
@@ -0,0 +1,105 @@
+<?php
+session_start();
+$baseURL = "../";
+require($baseURL.'functions.php');
+require($baseURL.'config.php');
+$debug = 0;
+if($_POST['formSubmitted'] == "true" || ((isset($_GET['id']) && is_numeric($_GET['id'])) || isset($_GET['url']))){
+ if(isset($_GET['url'])) $curseAddonID = getIdFromURL($_GET['url']);
+ if($_POST['formSubmitted'] == "true") $curseAddonID = trim($_POST['curseAddonID']);
+ if(isset($_GET['id'])) $curseAddonID = trim($_GET['id']);
+ if(isset($_GET['deleteAddon']) && $_GET['deleteAddon']) $deleteAddon = true;
+ if($deleteAddon){
+ if(deleteAddon($curseAddonID)){
+ $_SESSION['message'] = "Deleted Addon.";
+ }else{
+ $_SESSION['message'] = "Deletting Addon failed.";
+ }
+ }else{
+ if(updateNeeded($curseAddonID)){
+ if(updateAddon($curseAddonID)){
+ $_SESSION['message'] = stripslashes($addonName)." was updated.";
+ }else{
+ $_SESSION['message'] = stripslashes($addonName)." could not be updated.";
+ }
+ }else{
+ $_SESSION['message'] = stripslashes($addonName)." is up to date as of ".$lastDownloadDateTimeHuman.".";
+ }
+ }
+}
+$orderBy = "addonName";
+$orderDir = "asc";
+if(in_array($_GET['sort'], array("addonName", "version", "lastUpdateDateTime", "lastDownloadDateTime"))) $orderBy = $_GET['sort'];
+if($_GET['direction'] == "desc") $orderDir = "desc";
+$query = "SELECT id, curseAddonID, addonName, version, addonURL, lastDownloadID, lastDownloadDateTime, lastDownloadDateTimeHuman, lastUpdateDateTime, lastUpdateDateTimeHuman FROM amz_addonsList ORDER BY ".$orderBy." ".$orderDir;
+$result = mysql_query($query);
+
+$numRows = mysql_num_rows($result);
+echo '<html>
+ <head>
+ <title>List Addons</title>
+ <script type="text/javascript"></script>
+ <style type="text/css">
+ @import url("'.$baseURL.'style.css");
+ </style>
+ <script type="text/javascript" src="ajax.js"></script>
+ </head>
+ <body onload="ajaxFunction();" >
+ <div id=\'ajaxDiv\'></div>
+ <form name="addAddon" method="post" action="'.$_SERVER['PHP_SELF'].'">
+ Curse ID: <input name="curseAddonID" value="" size="7" />
+ <input type="hidden" name="formSubmitted" value="true" />
+ <input type="submit" value="Add AddOn" />
+ </form>
+ &nbsp;<br />';
+if($numRows != 0){
+ if($orderBy=="addonName" && $orderDir=="asc") $addonNameSortURL .= "&direction=desc";
+ if($orderBy=="version" && $orderDir=="asc") $versionSortURL .= "&direction=desc";
+ if($orderBy=="lastUpdateDateTime" && $orderDir=="asc") $lastUpdateDateTimeSortURL .= "&direction=desc";
+ if($orderBy=="lastDownloadDateTime" && $orderDir=="asc") $lastDownloadDateTimeSortURL .= "&direction=desc";
+ echo '<table>
+ <thead>
+ <th scope="col"><a href="'.$_SERVER['PHP_SELF'].'?sort=addonName'.$addonNameSortURL.'">Addon Name</a></th>
+ <th scope="col"><a href="'.$_SERVER['PHP_SELF'].'?sort=version'.$versionSortURL.'">Version</a></th>
+ <th scope="col"><a href="'.$_SERVER['PHP_SELF'].'?sort=lastUpdateDateTime'.$lastUpdateDateTimeSortURL.'">Last Checked</a></th>
+ <th scope="col"><a href="'.$_SERVER['PHP_SELF'].'?sort=lastDownloadDateTime'.$lastDownloadDateTimeSortURL.'">Last Download</a></th>
+ <th scope="col">Updt</th>
+ <th scope="col">Dwnld</th>
+ <th scope="col">Dlt</th>
+ </thead>
+ <tbody>';
+
+ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
+ if($i%2){
+ echo '<tr class="odd">';
+ }else{
+ echo '<tr>';
+ }
+ echo "<th scope=\"row\"><a href=\"".$row['addonURL']."\">".$row['addonName']."</a></td>" .
+ "<td>".$row['version']."</td>" .
+ "<td>".$row['lastUpdateDateTimeHuman']."</td>";
+ ////
+ if($row['lastDownloadDateTime'] == NULL){
+ echo "<td>None</td>" .
+ "<td align=\"center\">< <a href=\"".$_SERVER['PHP_SELF']."?id=".$row['curseAddonID']."\"><img src=\"".$baseURL."images/update.gif\" width=\"25\" height=\"25\" border=\"0\"></a></td>";
+ }else{
+ echo "<td>".$row['lastDownloadDateTimeHuman']."</td>" .
+ "<td align=\"center\"><a href=\"".$_SERVER['PHP_SELF']."?id=".$row['curseAddonID']."&sort=".$orderBy."&direction=".$orderDir."\"><img src=\"".$baseURL."images/update.gif\" width=\"25\" height=\"25\" border=\"0\"></a>";
+ }
+ ////
+ echo "<td align=\"center\"><a href=\"../cachedZips/".$row['addonName'].".zip\"><img src=\"".$baseURL."images/download.gif\" width=\"25\" height=\"25\" border=\"0\"></a></td>" .
+ "<td align=\"center\"><a href=\"".$_SERVER['PHP_SELF']."?deleteAddon=true&id=".$row['id']."&sort=".$orderBy."&direction=".$orderDir."\"><img src=\"".$baseURL."images/delete.png\" width=\"25\" height=\"25\" border=\"0\"></a></td>" .
+ "</tr>";
+ $i++;
+ }
+ mysql_select_db($dbname);
+}else{
+ echo 'No addons in database.<br />';
+}
+echo '
+</tbody>
+</table>
+</body>
+</html>
+';
+?>
View
27 admin/listAddonsQuery.php
@@ -0,0 +1,27 @@
+<?php
+session_start();
+$baseURL = "../";
+require($baseURL.'functions.php');
+require($baseURL.'config.php');
+if(isset($_SESSION['addonName']) && isset($_SESSION['curseAddonID'])){
+ if(!checkForUpdateCompletion($_SESSION['curseAddonID'])){
+ $progressInBytes = checkDownloadProgress($_SESSION['addonName']);
+ $progressInKilobytes = round($progressInBytes/1024);
+ $addonSize = $_SESSION['addonSize'];
+ $addonSizeInKilobytes = round($addonSize/1024);
+ echo '<font color="blue">'.$_SESSION['addonName'].' is currently updating. '.$progressInKilobytes.'KB of '.$addonSizeInKilobytes.'KB downloaded so far.</font><br />';
+ $downloadFinished = true;
+ }else{
+ if(!$downloadFinished) echo '<font color="blue">'.$_SESSION['addonName'].' has completed downloading!<br />';
+ else echo '<font color="blue">'.$_SESSION['addonName'].' has been updated!<br />';
+ md5Addon($_SESSION['addonName']);
+ unset($_SESSION['addonName']);
+ unset($_SESSION['curseAddonID']);
+ unset($_SESSION['addonSize']);
+ }
+}
+if (isset($_SESSION['message']) || isset($message)){
+ echo "<font color=\"blue\">".$_SESSION['message'].$message."</font><br />&nbsp;<br />";
+ unset($_SESSION['message']);
+}
+?>
View
18 config.php.example
@@ -0,0 +1,18 @@
+<?php
+//config.php - This file is required in every page and is required.
+//It stores the username and passwords for connecting to the database.
+//You should probably make sure the permissions are said to read/write for your user only (chmod 600 config.php).
+
+//Please edit the next 4 variables to reflect the correct settings:
+$dbhost = 'mysql.example.com'; //Sometimes this is localhost
+$dbuser = 'ericboehs'; //The username you use to connect to the above MySQL server
+$dbpass = 'm4c0r0n1!!4ND!!ch33Z3'; //The password required for the above username
+$dbname = 'wow-addons-manager'; //This is the database name
+//That's it you're done.
+
+
+//This intiates the connection and selects the database you set above.
+//You shouldn't have to edit these.
+$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
+mysql_select_db($dbname);
+?>
View
23 dailyUpdater.php
@@ -0,0 +1,23 @@
+<?php
+$baseURL="/home/ericboehs/ericboehs.com/addons/";
+require('config.php');
+require('functions.php');
+$query = "SELECT id FROM amz_addonsList";
+$result = mysql_query($query);
+if(!$result) die('Could not get list of Addons!');
+while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
+ $checkQuery = "SELECT curseAddonID, addonName from amz_addonsList WHERE id=".$row['id'];
+ $checkResult = mysql_query($checkQuery);
+ while($checkRow = mysql_fetch_array($checkResult, MYSQL_ASSOC)){
+ $curseAddonID = trim($checkRow['curseAddonID']);
+ $addonName = trim($checkRow['addonName']);
+ }
+ if(updateNeeded($curseAddonID)){
+ if(!updateAddon($curseAddonID)){
+ die(stripslashes($addonName)." could not be updated.");
+ }
+ }
+}
+//Cleanse the customZips
+shell_exec('find '.$baseURL.'customZips/* -mmin +1440 -exec rm {} \;');
+?>
View
220 functions.php
@@ -0,0 +1,220 @@
+<?php
+/*
+TODO:
+-Make a "favorites" zip section
+-Add a cron job for creating those favorites
+-Make it XHTML valid
+-Fix it to die gracefully if curse isn't providing the xml correctly
+*/
+
+/*This function is used to store the Session ID, I got from Curse using a packet sniffer and their
+original curse client. I've been using this ID for a while and it hasn't expired. Here's to hoping
+it never will.*/
+function getCurseSessionID(){
+ return "VNIBQDUBUCEUPATP";
+}
+/*This will get the XML file that is associated with the curseAddonID. It contains everything we need
+including the URL to the addon and the addon's zip files. Eventually I'd like to make this return the
+contents of the file in XML format, rather than a filename of where it's stored.*/
+function fetchAddonXML($curseAddonID){
+ //This registers the $baseURL and $debug variables as global variables so that they can be used inside
+ //(or outside) this function. If I don't make them global, then only what I return is accessable.
+ global $baseURL, $debug;
+ $curseSessionID = getCurseSessionID();
+ //Create a random file name to store the XML temporarily. This would be located up one level if
+ //$baseURL was set to "../" and if it was blank then it would use the current directory of the file
+ //that included this file, not the directory of this file.
+ $filename = $baseURL.rand().'.xml';
+ //This is what actually get's the xml file and saves it.
+ $xml = shell_exec('wget -q -O '.$filename.' http://addonservice.curse.com/AddOnService.asmx/GetAddOn?pAddOnId='.$curseAddonID.'\&pSession='.$curseSessionID);
+ return $filename;
+ //$xml = shell_exec('wget -O- http://addonservice.curse.com/AddOnService.asmx/GetAddOn?pAddOnId='.$curseAddonID.'\&pSession='.$curseSessionID);
+ //return $xml;
+}
+/*Checks the content length of a file. Used for ajax progress updates.*/
+function getContentLength($url){
+ $contentLength = shell_exec('curl -s -I '.$url.' | grep Content-Length');
+ $contentLength = explode(" ", $contentLength);
+ $contentLength = $contentLength[1];
+ return $contentLength;
+}
+/*Grabs the ID from the "Install via Curse Client" link using a bookmarklet.*/
+function getIdFromURL($url){
+ global $message;
+ $pieces = explode("=", $url);
+ if(count($pieces)!=2 && substr($url,0,4) != "psyn"){
+ $message .= "Invalid URL passed.";
+ return false;
+ }
+ return trim($pieces[1]);
+}
+function checkForNullFieldsForAdd(){}
+/*Checks to see if the "InProgress" file exists - used for ajax queries*/
+function checkForUpdateCompletion($curseAddonID){
+ global $baseURL;
+ if(file_exists($baseURL.$curseAddonID.'InProgress')) return false;
+ return true;
+}
+function checkDownloadProgress($addonName){
+ global $baseURL;
+ $sizeInBytes = shell_exec('ls -l '.$baseURL.'cachedZips/'.$addonName.'.zip | awk \'{print $5}\'');
+ return $sizeInBytes;
+}
+function fork($shellCmd){
+ $shellCmd = addslashes($shellCmd);
+ exec("nice sh -c \"$shellCmd\" > /dev/null 2>&1 &");
+}
+function addonExists($curseAddonID){
+ global $debug, $baseURL;
+ require($baseURL.'config.php');
+ $query = "SELECT id from amz_addonsList WHERE curseAddonID=".$curseAddonID;
+ $result = mysql_query($query);
+ if(mysql_num_rows($result)) return true;
+ return false;
+}
+function parseXML($xml){
+ if(!isset($xml)) return false;
+ global $debug, $lastDownloadDateTime, $lastDownloadDateTimeHuman, $addonName, $zipURL, $addonURL, $currentVersion, $currentDownloadID;
+ //$line = explode("<name>",$xml);
+ ///// YOU WERE HERE
+ //die(print_r($line));
+ $lastDownloadDateTime = trim(date('Y-m-d H:i:s'));
+ $lastDownloadDateTimeHuman = trim(date('M j, Y \a\t g:i a'));
+ $addonName = addslashes(trim(shell_exec('cat '.$xml.' | tr -s \'><\' \'\n\' | grep -a -m 1 -A 1 name | tail -1')));
+ $zipURL = trim(shell_exec('cat '.$xml.' | tr -s \'><\' \'\n\' | grep -a -B 2 date | grep zip | tail -1'));
+ $addonURL = trim(shell_exec('cat '.$xml.' | tr -s \'><\' \'\n\' | grep -a -m 1 aspx'));
+ $currentVersion = trim(shell_exec('cat '.$xml.' | tr -s \'><\' \'\n\' | grep -a -A 2 \'file id\' | tail -1'));
+ $currentDownloadID = trim(shell_exec('cat '.$xml.' | tr -s \'><\' \'\n\' | grep -a \'file id\' | tail -1 | awk -F\'"\' \'{print $2}\''));
+ unlink($xml);
+ return true;
+}
+/*
+function compareVersions($){
+ foreach($addonVersions as $thisAddon){
+ if($thisAddon != $
+ }
+}
+*/
+function getVersionsFromZip($userZipLocation, $userExtractLocation){
+ global $debug, $baseURL;
+ $zipFilename = "AddonPack-".date('Ymd-His');
+ if(file_exists($zipFilename)){
+ $zipFilename .= "-".rand().".zip";
+ }else{
+ $zipFilename .= ".zip";
+ }
+ shell_exec('unzip "'.$userZipLocation.'" -d "'.$userExtractLocation.'"');
+ unlink($userZipLocation);
+ $directoryListing = scandir($userExtractLocation.'/versions');
+ foreach($directoryListing as $thisFilename){
+ if($thisFilename != "." || $thisFilename != ".."){
+ $pieces = explode(".", $thisFilename);
+ if($pieces[0]){
+ $addonNames[] = $pieces[0];
+ $addonHashes[] = file_get_contents($userExtractLocation.'/versions/'.$thisFilename);
+ }
+ }
+ }
+ $i=0;
+ foreach($addonNames as $thisAddonName){
+ if($addonHashes[$i] != file_get_contents($baseURL.'cachedZips/'.$thisAddonName.'.dir/versions/'.$thisAddonName.'.md5')){
+ $updated = true;
+ shell_exec('cd "'.$baseURL.'" && cd "cachedZips/'.$thisAddonName.'.dir" && zip -r "../../customZips/'.$zipFilename.'" * && cd ../..');
+ }
+ $i++;
+ }
+ shell_exec('rm -rf "'.$userExtractLocation.'"');
+ if($updated) return 'customZips/'.$zipFilename;
+ return false;
+}
+function updateNeeded($curseAddonID){
+ global $debug, $baseURL, $lastDownloadDateTime, $lastDownloadDateTimeHuman, $addonName, $ourAddonName, $zipURL, $addonURL, $currentVersion, $currentDownloadID;
+ require('config.php');
+ if(!parseXML(fetchAddonXML($curseAddonID))) return false;
+ $query = "SELECT lastDownloadID from amz_addonsList WHERE curseAddonID=".$curseAddonID;
+ $result = mysql_query($query);
+ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
+ $lastDownloadID = trim($row['lastDownloadID']);
+ }
+ $query = "UPDATE amz_addonsList SET addonName='$addonName', addonURL='$addonURL', version='$currentVersion', lastUpdateDateTime='$lastDownloadDateTime', lastUpdateDateTimeHuman='$lastDownloadDateTimeHuman' WHERE curseAddonID=$curseAddonID";
+ if($debug){ echo $query."<br />"; }
+ $updatesult = mysql_query($query);
+ if($debug && !$updateResult) die('Invalid query: ' . mysql_error());
+ if($currentDownloadID != $lastDownloadID) return true;
+ if(!file_exists($baseURL.'cachedZips/'.$addonName.'.zip')) return true;
+ if(!file_exists($baseURL.'cachedZips/'.$addonName.'.dir')) fork('unzip -d "'.$baseURL.'cachedZips/'.$addonName.'.dir" "'.$baseURL.'cachedZips/'.$addonName.'.zip"');
+ if(!file_exists($baseURL.'cachedZips/'.$addonName.'.dir/versions/'.$addonName.'.md5')) md5Addon($addonName);
+ return false;
+}
+function md5Addon($addonName){
+ global $debug, $baseURL;
+ $md5hash = md5_file($baseURL.'cachedZips/'.$addonName.'.zip');
+ shell_exec('mkdir "'.$baseURL.'cachedZips/'.$addonName.'.dir/versions/" && echo '.$md5hash.' >> "'.$baseURL.'cachedZips/'.$addonName.'.dir/versions/'.$addonName.'.md5"');
+ return;
+}
+function updateAddon($curseAddonID){
+ global $debug, $baseURL, $lastDownloadDateTime, $lastDownloadDateTimeHuman, $addonName, $zipURL, $addonURL, $currentVersion, $currentDownloadID;
+ require('config.php');
+ if(!parseXML(fetchAddonXML($curseAddonID))) return false;
+ $_SESSION['addonName'] = $addonName;
+ $_SESSION['curseAddonID'] = $curseAddonID;
+ $_SESSION['addonSize'] = getContentLength($zipURL);
+ touch($baseURL.$curseAddonID."InProgress");
+ fork('wget -O "'.$baseURL.'cachedZips/'.$addonName.'.zip" '.$zipURL.' && rm '.$baseURL.$curseAddonID.'InProgress && rm -rf "'.$baseURL.'cachedZips/'.$addonName.'.dir"; unzip -d "'.$baseURL.'cachedZips/'.$addonName.'.dir" "'.$baseURL.'cachedZips/'.$addonName.'.zip" && md5 "'.$baseURL.'cachedZips/'.$addonName.'.zip" -out "'.$baseURL.'cachedZips/'.$addonName.'.dir/md5checksum.txt"');
+ if(addonExists($curseAddonID)){
+ $query = "UPDATE amz_addonsList SET addonName='$addonName', version='$currentVersion', addonURL='$addonURL', lastDownloadID=$currentDownloadID, lastDownloadDateTime='$lastDownloadDateTime', lastDownloadDateTimeHuman='$lastDownloadDateTimeHuman', lastUpdateDateTime='$lastDownloadDateTime', lastUpdateDateTimeHuman='$lastDownloadDateTimeHuman' WHERE curseAddonID=$curseAddonID";
+ }else{
+ $query = "INSERT INTO amz_addonsList (curseAddonID, addonName, version, addonURL, lastDownloadID, lastDownloadDateTime, lastDownloadDateTimeHuman, lastUpdateDateTime, lastUpdateDateTimeHuman) VALUES ($curseAddonID, '$addonName', '$currentVersion', '$addonURL', $currentDownloadID, '$lastDownloadDateTime', '$lastDownloadDateTimeHuman', '$lastDownloadDateTime', '$lastDownloadDateTimeHuman')";
+ }
+ $result = mysql_query($query);
+ if($debug && !$result) die('Invalid query: ' . mysql_error());
+ if(!$result) return false;
+ return true;
+}
+function deleteAddon($curseAddonID){
+ global $debug, $baseURL, $addonName, $message;
+ if($curseAddonID == null || !is_numeric($curseAddonID)){
+ $message .= "Addon ID must contain numbers only. Please select update from the list below.";
+ return false;
+ }
+ require('config.php');
+ $query = "SELECT addonName from amz_addonsList WHERE curseAddonID=".$curseAddonID;
+ $result = mysql_query($query);
+ if(!result) return false;
+ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
+ $addonName = trim($row['addonName']);
+ }
+ if(file_exists("$baseURLcachedZips/$addonName.dir")){
+ shell_exec('rm -rf "'.$baseURL.'cachedZips/'.$addonName.'.dir"');
+ }
+ if(file_exists("$baseURLcachedZips/$addonName.zip")){
+ shell_exec('rm -rf "'.$baseURL.'cachedZips/'.$addonName.'.zip"');
+ }
+ $query = "DELETE FROM amz_addonsList WHERE id=".$curseAddonID;
+ $deleteResult = mysql_query($query);
+ if(!$deleteResult) return false;
+ return true;
+}
+function newParseXML(){
+ $file = "xml_test.xml";
+ function contents($parser, $data){
+ echo $data;
+ }
+ function startTag($parser, $data){
+ echo "<b>";
+ }
+ function endTag($parser, $data){
+ echo "</b><br />";
+ }
+ $xml_parser = xml_parser_create();
+ xml_set_element_handler($xml_parser, "startTag", "endTag");
+ xml_set_character_data_handler($xml_parser, "contents");
+ $fp = fopen($file, "r");
+ $data = fread($fp, 80000);
+ if(!(xml_parse($xml_parser, $data, feof($fp)))){
+ die("Error on line " . xml_get_current_line_number($xml_parser));
+ }
+ xml_parser_free($xml_parser);
+ fclose($fp);
+}
+?>
View
BIN images/bg_caption.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/bg_td1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/bg_td2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/bg_th.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/bg_total.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/delete.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/download.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/update.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
91 index.php
@@ -0,0 +1,91 @@
+<?php
+session_start();
+require('config.php');
+require('functions.php');
+$orderBy = "addonName";
+$orderDir = "asc";
+$query = "SELECT id, curseAddonID, addonName, version, lastDownloadID, lastDownloadDateTime, lastDownloadDateTimeHuman, addonURL FROM amz_addonsList ORDER BY ".$orderBy." ".$orderDir;
+$result = mysql_query($query);
+if($_POST['formSubmitted']){
+ $filename = "AddonPack-".date('Ymd-His');
+ if(file_exists($filename))
+ $filename .= "-".rand().".zip";
+ else
+ $filename .= ".zip";
+ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
+ if($_POST[$row['id']] == "on"){
+ $checkQuery = "SELECT curseAddonID, addonName, lastDownloadID from amz_addonsList WHERE id=".$row['id'];
+ $checkResult = mysql_query($checkQuery);
+ while($checkRow = mysql_fetch_array($checkResult, MYSQL_ASSOC)){
+ $curseAddonID = trim($checkRow['curseAddonID']);
+ $addonName = trim($checkRow['addonName']);
+ }
+ if(updateNeeded($curseAddonID)){
+ if(updateAddon($curseAddonID)){
+ while(!checkForUpdateCompletion($curseAddonID)) sleep(2);
+ }else{
+ die(stripslashes($addonName)." could not be added.");
+ }
+ }
+ if($_POST['onWindows'] == "on"){
+ shell_exec('cd "cachedZips/'.$row['addonName'].'.dir" && zip -r "../../customZips/'.$filename.'" * && cd ../..');
+ }else{
+ shell_exec('cat cachedZips/'.$row['addonName'].'.zip >> customZips/'.$filename);
+ }
+ }
+ }
+ header("Location: customZips/$filename");
+}
+?>
+<html>
+<head>
+<title>List Addons</title>
+<style type="text/css">
+ @import url("style.css");
+</style>
+</head>
+<body>
+<?php
+if (isset($_SESSION['message'])){
+ echo "<font color=\"blue\">".$_SESSION['message']."</font>";
+ unset($_SESSION['message']);
+}
+?>
+<p>This page will create a zip file with all of the Addons you select below. One zip file, one download, one extract, every addon updated.</p>
+<p>&nbsp;</p>
+<p>Check each addon you want to include in your pack.</p>
+<p>&nbsp;</p>
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+<table summary="WoW Addon Manager">
+ <caption>WoW Addon Manager</caption>
+ <thead>
+ <th scope="col" class="checkbox">Add</th>
+ <th scope="col" class="addonName">Addon Name</th>
+ <th scope="col" class="version">Version</th>
+ <th scope="col" class="download">Dld</th>
+ </thead>
+ <?php
+while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
+ if($i%2){
+ echo ' <tr class="odd">';
+ }else{
+ echo ' <tr>';
+ }
+ echo '
+ <td><input type="checkbox" name="'.$row['id'].'" /></td>
+ <td><a href="'.$row['addonURL'].'">'.$row['addonName'].'</a></td>
+ <td>'.$row['version'].'</td>
+ <td><a href="cachedZips/'.$row['addonName'].'.zip"><img src="images/download.gif" width="25" height="25" border="0"></a></td>
+ </tr>
+';
+ $i++;
+}
+?>
+</table>
+&nbsp;<br />
+<input type="hidden" name="formSubmitted" value="true" />
+<input type="checkbox" name="onWindows" checked /> Using Windows? <br />
+<input type="submit" name="submit" value="Download Selected" />
+</form>
+</body>
+</html>
View
30 install/index.php
@@ -0,0 +1,30 @@
+<?php
+if(!file_exists('../config.php')){
+ echo "Config.php does not exist. Please create one based on the config.php.example";
+ exit();
+}
+if(file_exists('structureImported')){
+ echo "Installation complete. Please remove the install directory.";
+ exit();
+}
+include('../config.php');
+$query = "CREATE TABLE IF NOT EXISTS `amz_addonsList` (
+ `id` int(11) NOT NULL auto_increment,
+ `curseAddonID` int(11) NOT NULL,
+ `addonName` varchar(64) NOT NULL,
+ `version` varchar(25) default NULL,
+ `addonURL` varchar(200) default NULL,
+ `lastDownloadID` int(11) default NULL,
+ `lastDownloadDateTime` datetime default NULL,
+ `lastDownloadDateTimeHuman` varchar(64) default NULL,
+ `lastUpdateDateTime` datetime default NULL,
+ `lastUpdateDateTimeHuman` varchar(64) default NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=102" ;
+$installSQLResult = mysql_query($query);
+if(!$instalSQLRResult) die(mysql_error());
+if(!file_exists('../cachedZips/')) mkdir('../cachedZips');
+if(!file_exists('../customZips/')) mkdir('../customZips');
+touch ('structureImported');
+header("Location: ".$_SERVER['PHP_SELF']);
+?>
View
113 style.css
@@ -0,0 +1,113 @@
+*{
+ margin:0;
+ padding:0;
+}
+img{
+ border: 0;
+}
+body{
+ font-family:Arial,Verdana,Sans-Serif;
+ font-size:.9em;
+ background:#FFFFFF;
+ padding:.2em 1em;
+}
+#boundary{
+ text-align:left;
+ position:relative;
+ width:700px;
+ margin:1em 0;
+}
+#itsthetable{
+ background: #fff;
+ padding: 1em;
+}
+h1{
+ padding:0px 20px;
+ color:#000;
+ text-transform:uppercase;
+ font-family:"trebuchet ms",Helvetica,Arial,Sans-Serif;
+ letter-spacing:-1px;
+}
+h2{
+ padding:10px 10px 0 0;
+ color:#030;
+ font-size:140%;
+ text-transform:uppercase;
+ font-family:"trebuchet ms",Helvetica,Arial,Sans-Serif;
+}
+table {
+ border-collapse:collapse;
+ border:1px solid #FFCA5E;
+}
+caption {
+ font: 1.8em/1.8em Arial, Helvetica, sans-serif;
+ text-align: left;
+ text-indent: 10px;
+ background: url(images/bg_caption.jpg) right top;
+ height: 45px;
+ color: #FFAA00;
+}
+thead th {
+ background: url(images/bg_th.jpg) no-repeat right;
+ height: 47px;
+ color: #FFFFFF;
+ font-size: 0.8em;
+ font-weight: bold;
+ padding: 0px 7px;
+ margin: 20px 0px 0px;
+ text-align: left;
+ border-right: 1px solid #FCF1D4;
+}
+thead th.addonName {
+ width: 150px;
+}
+thead th.version {
+ width: 150px;
+}
+thead#topisbottom th {
+ background: url(images/bg_total.jpg) repeat-x bottom;
+ color: #FFFFFF;
+ height: 30px;
+}
+tbody tr {
+ background: url(images/bg_td1.jpg) repeat-x top;
+}
+tbody tr.odd {
+ background: #FFF8E8 url(images/bg_td2.jpg) repeat-x;
+}
+
+tbody th,td {
+ font-size: 0.8em;
+ line-height: 1.4em;
+ font-family: Arial, Helvetica, sans-serif;
+ color: #777777;
+ padding: 10px 7px;
+ border-top: 1px solid #FFCA5E;
+ border-right: 1px solid #DDDDDD;
+ text-align: left;
+}
+a {
+ color: #777777;
+ font-weight: bold;
+ text-decoration: underline;
+}
+a:hover {
+ color: #F8A704;
+ text-decoration: underline;
+}
+tfoot th {
+ background: url(images/bg_total.jpg) repeat-x bottom;
+ color: #FFFFFF;
+ height: 30px;
+ text-align: right;
+
+}
+tfoot td {
+ background: url(images/bg_total.jpg) repeat-x bottom;
+ color: #FFFFFF;
+ height: 30px;
+ text-align: right;
+}
+#cartCaclulateRow{
+ text-align:left;
+}
View
5 upload.php
@@ -0,0 +1,5 @@
+<form enctype="multipart/form-data" action="uploadProcess.php" method="POST">
+ <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
+ Send this file: <input name="userfile" type="file" />
+ <input type="submit" value="Send File" />
+</form>
View
16 uploadProcess.php
@@ -0,0 +1,16 @@
+<?php
+require('functions.php');
+$uploaddir = '/home/ericboehs/ericboehs.com/addons/'.rand().'/';
+$uploadfile = $uploaddir.'versions.zip';
+mkdir($uploaddir);
+if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
+ if($zipFilename = getVersionsFromZip($uploadfile, $uploaddir)) {
+ header("Location: ".$zipFilename);
+ }else{
+ echo "All of your Addons are up to date.";
+ }
+} else {
+ echo "Possible file upload attack!\n";
+}
+
+?>

0 comments on commit b191767

Please sign in to comment.
Something went wrong with that request. Please try again.