Skip to content

Commit

Permalink
Fixing a bug in the installer and a missing table. #555
Browse files Browse the repository at this point in the history
  • Loading branch information
wilpig committed Jun 9, 2015
1 parent cdb2492 commit 077a209
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
19 changes: 16 additions & 3 deletions api/v1/index.php
@@ -1,13 +1,26 @@
<?php

require_once( "../../db.inc.php" );
require_once( "../../facilities.inc.php" );
require_once( "../../Slim/Slim.php" );

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

//
// URL: /api/v1/test
// Method: GET
// Params: none
// Returns: a response. this is a test to make sure mod_rewrite is working
//
$app->get('/test', function() {
$response['error'] = false;
$response['errorcode'] = 200;
echoResponse(200, $response);
});

// load up the rest of our dependencies for the app
require_once( "../../db.inc.php" );
require_once( "../../facilities.inc.php" );

/*
*
* General notes about the API
Expand Down
17 changes: 17 additions & 0 deletions db-3.3-to-4.0.sql
@@ -1,3 +1,20 @@
--
-- Fix for an ancient bug that was just discovered
--

CREATE TABLE IF NOT EXISTS fac_Zone (
ZoneID int(11) NOT NULL AUTO_INCREMENT,
DataCenterID int(11) NOT NULL,
Description varchar(120) NOT NULL,
MapX1 int(11) NOT NULL,
MapY1 int(11) NOT NULL,
MapX2 int(11) NOT NULL,
MapY2 int(11) NOT NULL,
MapZoom int(11) DEFAULT '100' NOT NULL,
PRIMARY KEY (ZoneID),
KEY DataCenterID (DataCenterID)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

--
-- Move entries from fac_CabinetAudit to fac_GenericLog
--
Expand Down
4 changes: 2 additions & 2 deletions install.php
Expand Up @@ -94,7 +94,7 @@
}
}else{
$tests['authentication']['state']="fail";
$tests['authentication']['message']=($tests['db.inc']['state']=="good")?"You didn't read the upgrade notes. Jerk.":"How can you expect to work this if you can't even copy the db.inc.php into the right place?";
$tests['authentication']['message']=($tests['db.inc']['state']=="good")?"You didn't read the upgrade notes. Jerk. There is no AUTHENTICATION defined in db.inc.php":"How can you expect to work this if you can't even copy the db.inc.php into the right place?";
$errors++;
}

Expand All @@ -117,7 +117,7 @@
$errors++;
}
if ($errors >0 || !isset($_GET['preflight-ok'])) {
echo '<!doctype html><html><head><title>openDCIM :: pre-flight environment sanity check</title><script type="text/javascript" src="scripts/jquery.min.js"></script><script type="text/javascript">$(document).ready(function(){$("tr").each(function(){if($(this).find("td:last-child").text()=="fail"){$(this).addClass("fail");}});$.get("api/v1/devicetemplate/image").done(function(data){if(!data.error){$("#api_test").removeClass("fail").find("td:nth-child(2)").text("").next("td").text("GOOD");document.getElementById("continue").className=document.getElementById("continue").className.replace(/\bhide\b/,"");location.href="?preflight-ok";}});});</script><style type="text/css">table{width:80%;border-collapse:collapse;border:3px solid black;}th{text-align:left;text-transform:uppercase;border-right: 1px solid black;}th,td{padding:5px;}tr:nth-child(even){background-color:#d1e1f1;}td:last-child{text-align:center;text-transform:uppercase;border:2px solid;background-color:green;}.fail td:last-child{font-weight: bold;background-color: red;}.hide{display: none;}</style></head><body><h2>Pre-flight environment checks</h2><table>';
echo '<!doctype html><html><head><title>openDCIM :: pre-flight environment sanity check</title><script type="text/javascript" src="scripts/jquery.min.js"></script><script type="text/javascript">$(document).ready(function(){$("tr").each(function(){if($(this).find("td:last-child").text()=="fail"){$(this).addClass("fail");}});$.get("api/v1/test").done(function(data){if(!data.error){$("#api_test").removeClass("fail").find("td:nth-child(2)").text("").next("td").text("GOOD");document.getElementById("continue").className=document.getElementById("continue").className.replace(/\bhide\b/,"");location.href="?preflight-ok";}});});</script><style type="text/css">table{width:80%;border-collapse:collapse;border:3px solid black;}th{text-align:left;text-transform:uppercase;border-right: 1px solid black;}th,td{padding:5px;}tr:nth-child(even){background-color:#d1e1f1;}td:last-child{text-align:center;text-transform:uppercase;border:2px solid;background-color:green;}.fail td:last-child{font-weight: bold;background-color: red;}.hide{display: none;}</style></head><body><h2>Pre-flight environment checks</h2><table>';
foreach($tests as $test => $text){
$hide=($test=='api_test')?' class="hide"':'';
print "<tr id=\"$test\"$hide><th>$test</th><td>{$text['message']}</td><td>{$text['state']}</td></tr>";
Expand Down

0 comments on commit 077a209

Please sign in to comment.