Skip to content

Commit

Permalink
Ding Dong the witch is dead
Browse files Browse the repository at this point in the history
  • Loading branch information
gig3m committed Jan 9, 2014
1 parent 91b056c commit ce3d5db
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 67 deletions.
126 changes: 60 additions & 66 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,56 +51,58 @@
//Status
$app->get('/status/:last/:vin/', function ($last, $vin) use ($app) {

//Get environment and DI
$env = $app->environment();
$redis = $env['redis'];

//Check redis cache for record
if ($cached = $redis->get($vin))
{
//decode redis/JSON and pass it to VOTS class
$jeep = new VOTSService(json_decode($cached, TRUE));


$data = array(
'statusCode' => $jeep->getStatusCode(),
'statusDesc' => $jeep->getStatusDesc(),
'statusExplanation' => $jeep->getStatusExplanation()
);

//Do something
$app->render('response.twig', $data);
}

//redis has no key, lets go fetch Chrysler's response
else
{
$jeep = new VOTSService();
$jeep->getJSON($last, $vin);
if ($jeep->isValid())
{
$data = array(
'statusCode' => $jeep->getStatusCode(),
'statusDesc' => $jeep->getStatusDesc(),
'statusExplanation' => $jeep->getStatusExplanation()
);

//put json into redis on key=vin for caching
$redis->set($vin, json_encode($jeep::$decoded));
$redis->expire($vin,60*20); //cache for 20 minutes

//Do something
$app->render('response.twig', $data);
}
else
{
//set an error message to display, courtesy of Chrysler
$data = array(
'error' => $jeep->getError()
);
$app->render('error.twig', $data);
}
}
$app->redirect("/home/");

// //Get environment and DI
// $env = $app->environment();
// $redis = $env['redis'];

// //Check redis cache for record
// if ($cached = $redis->get($vin))
// {
// //decode redis/JSON and pass it to VOTS class
// $jeep = new VOTSService(json_decode($cached, TRUE));


// $data = array(
// 'statusCode' => $jeep->getStatusCode(),
// 'statusDesc' => $jeep->getStatusDesc(),
// 'statusExplanation' => $jeep->getStatusExplanation()
// );

// //Do something
// $app->render('response.twig', $data);
// }

// //redis has no key, lets go fetch Chrysler's response
// else
// {
// $jeep = new VOTSService();
// $jeep->getJSON($last, $vin);
// if ($jeep->isValid())
// {
// $data = array(
// 'statusCode' => $jeep->getStatusCode(),
// 'statusDesc' => $jeep->getStatusDesc(),
// 'statusExplanation' => $jeep->getStatusExplanation()
// );

// //put json into redis on key=vin for caching
// $redis->set($vin, json_encode($jeep::$decoded));
// $redis->expire($vin,60*20); //cache for 20 minutes

// //Do something
// $app->render('response.twig', $data);
// }
// else
// {
// //set an error message to display, courtesy of Chrysler
// $data = array(
// 'error' => $jeep->getError()
// );
// $app->render('error.twig', $data);
// }
// }

});

Expand All @@ -109,23 +111,15 @@

$jeep = new VOTSService();
$jeep->getJSON($last, $vin);
if ($jeep->isValid())
{
$data = array(
'JSON' => $jeep::$raw
);

//Do something
$app->render('debug.twig', $data);
}
else
{
//set an error message to display, courtesy of Chrysler
$data = array(
'error' => $jeep->getError()
);
$app->render('error.twig', $data);
}
$data = array(
'JSON' => $jeep::$raw
);

//Do something
$app->render('debug.twig', $data);


});


Expand Down
2 changes: 1 addition & 1 deletion views/application.twig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<div class="sixteen columns" style="margin-top:20px">
<p>
Comments? Broken? <a href='&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#107;&#121;&#108;&#101;&#64;&#97;&#114;&#114;&#105;&#110;&#103;&#116;&#111;&#110;&#46;&#99;&#111;'>Email me.</a> Read about changes <a href="/changelog">here</a>.
Comments? <a href='&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#107;&#121;&#108;&#101;&#64;&#97;&#114;&#114;&#105;&#110;&#103;&#116;&#111;&#110;&#46;&#99;&#111;'>Email me.</a> Read about changes <a href="/changelog">here</a>.
</p>
</div>

Expand Down
5 changes: 5 additions & 0 deletions views/changelog.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<p>
<strong>Changelog</strong>
</p>
<p>
<strong>0.Dead</strong><br>
Dead. Chrysler wants to control you with their crappy software.
</p>


<p>
<strong>0.2</strong><br>
Expand Down
12 changes: 12 additions & 0 deletions views/home.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
{% block container %}

<div class="six columns offset-by-five">

<h4>The end of an era...</h4>
<p>They say all good things must come to an end, and it appears that Jeepstatus' time has come. Chrysler has decided to add a random number generator to it's VOTS system to disallow the reused of URLs. If you're not a geek like me I'll make that more plain: Chrsyler doesn't want you to use JeepStatus or any other means of seeing into the backend of their VOTS system. In fact, you can't even save your backend URL anymore as it will expire and be unusable.</p>

<p>If Chrysler's web team had designed a nice, simple, usuable tool from the beginning there would have been no need for JeepStatus to exist. (For the geeks, they didn't even use proper JSON responses)</p>

<p>So farewell, and may your Jeep see more dirt than pavement.</p>

<p>To Chrysler, please take my code. Make something usuable out of VOTS instead of the crap you provide.</p>

<!--
<form action="/status" method="post" name="getStatus">
<h4>Enter your details...</h4>
<fieldset>
Expand All @@ -11,6 +22,7 @@
<button type="submit">Submit</button>
</fieldset>
</form>
-->
</div>

{% endblock container %}

0 comments on commit ce3d5db

Please sign in to comment.