mirror of https://github.com/rusefi/msqur.git
Download button (#20)
* add functioning download button. seems like some of the temperature values are mangled when importing in to tunerstudio but this at least gives the ability to read in the majority of the tune. will troubleshoot the temp issues later * blank out mariadb username and password from local docker, users can set their own as needed * add download link to browse file as well * complete items from @nearwood's code review: delete db/msqur-4.sql, revert script.config.dist, update src/browse.php to have a capital D for Download and use the floppy emoji in place of download MSQ text, drop null xml check from src/db.php.getMSQForDownload function, change content-type header to application/xml in src/download.php, use floppy emoji in download link in src/msq.php * remove duplicate DB_USER param from script.config.dist * oops: forgot to commit changes to config.php.dist switching DB_HOST and DB_USERNAME back to original settings
This commit is contained in:
parent
fe2b03776e
commit
c39d5e3b9a
10
README.md
10
README.md
|
@ -15,7 +15,7 @@ Try it now at: http://msqur.com/
|
|||
|
||||
#### Needed software ####
|
||||
|
||||
* AMP Stack: Apache, MySQL (MariaDB), PHP
|
||||
* MariaDB, PHP
|
||||
* PDO extension for PHP.
|
||||
|
||||
#### Recommended software ####
|
||||
|
@ -29,10 +29,10 @@ Try it now at: http://msqur.com/
|
|||
1. Copy script.config.dist to script.config
|
||||
1. Copy src/config.php.dist to src/config.php
|
||||
1. Create database for msqur, and assign it a user
|
||||
1. Setup parameters in each config file
|
||||
1. Update DB with update scripts in sequential order
|
||||
1. Run deploy script
|
||||
1. Hit webserver to start using it.
|
||||
1. Setup parameters in each config file (meaning db connection info)
|
||||
1. Update DB with update scripts in sequential order (just paste everything in to mysqlworkbench)
|
||||
1. Run deploy script (???)
|
||||
1. Hit webserver to start using it. (php -S)
|
||||
|
||||
### Update & Deployment Instructions ###
|
||||
|
||||
|
|
|
@ -88,11 +88,11 @@ $numResults = count($results);
|
|||
|
||||
echo '<div id="content"><div class="info">' . $numResults . ' results.</div>';
|
||||
echo '<table ng-controller="BrowseController">';
|
||||
echo '<tr><th>ID</th><th>Engine Make</th><th>Engine Code</th><th>Cylinders</th><th>Liters</th><th>Compression</th><th>Aspiration</th><th>Firmware/Version</th><th>Upload Date</th><th>Views</th></tr>';
|
||||
echo '<tr><th>ID</th><th>Download</th><th>Engine Make</th><th>Engine Code</th><th>Cylinders</th><th>Liters</th><th>Compression</th><th>Aspiration</th><th>Firmware/Version</th><th>Upload Date</th><th>Views</th></tr>';
|
||||
for ($c = 0; $c < $numResults; $c++)
|
||||
{
|
||||
$aspiration = $results[$c]['induction'] == 1 ? "Turbo" : "NA";
|
||||
echo '<tr><td><a href="view.php?msq=' . $results[$c]['mid'] . '">' . $results[$c]['mid'] . '</a></td><td>' . $results[$c]['make'] . '</td><td>' . $results[$c]['code'] . '</td><td>' . $results[$c]['numCylinders'] . '</td><td>' . $results[$c]['displacement'] . '</td><td>' . $results[$c]['compression'] . ':1</td><td>' . $aspiration . '</td><td>' . $results[$c]['firmware'] . '/' . $results[$c]['signature'] . '</td><td>' . $results[$c]['uploadDate'] . '</td><td>' . $results[$c]['views'] . '</td></tr>';
|
||||
echo '<tr><td><a href="view.php?msq=' . $results[$c]['mid'] . '">' . $results[$c]['mid'] . '</a></td><td><a href="download.php?msq=' . $results[$c]['mid'] . '">💾</a></td><td>' . $results[$c]['make'] . '</td><td>' . $results[$c]['code'] . '</td><td>' . $results[$c]['numCylinders'] . '</td><td>' . $results[$c]['displacement'] . '</td><td>' . $results[$c]['compression'] . ':1</td><td>' . $aspiration . '</td><td>' . $results[$c]['firmware'] . '/' . $results[$c]['signature'] . '</td><td>' . $results[$c]['uploadDate'] . '</td><td>' . $results[$c]['views'] . '</td></tr>';
|
||||
}
|
||||
echo '</table></div>';
|
||||
|
||||
|
|
34
src/db.php
34
src/db.php
|
@ -280,6 +280,40 @@ class DB
|
|||
return $html;
|
||||
}
|
||||
|
||||
public function getMSQForDownload($id)
|
||||
{
|
||||
|
||||
if (!$this->connect()) return null;
|
||||
|
||||
$xml = FALSE;
|
||||
|
||||
try
|
||||
{
|
||||
$st = $this->db->prepare("SELECT xml FROM msqs INNER JOIN metadata ON metadata.msq = msqs.id WHERE metadata.id = :id LIMIT 1");
|
||||
DB::tryBind($st, ":id", $id);
|
||||
$st->execute();
|
||||
if ($st->rowCount() > 0)
|
||||
{
|
||||
$result = $st->fetch(PDO::FETCH_ASSOC);
|
||||
$st->closeCursor();
|
||||
$xml = $result['xml'];
|
||||
if (DEBUG) debug('<div class="debug">Cached, returning HTML.</div>');
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<div class=\"debug\">No result for $id</div>";
|
||||
echo '<div class="error">Invalid MSQ err 2</div>';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->dbError($e);
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a list of MSQs
|
||||
* @param $bq The BrowseQuery to filter results
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/* msqur - MegaSquirt .msq file viewer web application
|
||||
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
require "msqur.php";
|
||||
|
||||
if (isset($_GET['msq'])) {
|
||||
|
||||
header('Content-Type: application/xml');
|
||||
header('Content-Disposition: attachment; filename=' . $_GET['msq'] . '.msq');
|
||||
header('Pragma: no-cache');
|
||||
|
||||
echo $msqur->getMSQForDownload($_GET['msq']);
|
||||
} else {
|
||||
|
||||
include "index.php";
|
||||
}
|
||||
?>
|
|
@ -60,6 +60,7 @@ class MSQ
|
|||
$msqHeader .= "<div>MS Signature: " . $msq->versionInfo['signature'] . "</div>";
|
||||
$msqHeader .= "<div>Tuning SW: " . $msq->bibliography['author'] . "</div>";
|
||||
$msqHeader .= "<div>Date: " . $msq->bibliography['writeDate'] . "</div>";
|
||||
$msqHeader .= "<div><a href='download.php?msq=" . $_GET['msq'] . "'>💾</a></div>";
|
||||
$msqHeader .= '</div>';
|
||||
|
||||
$sig = $msq->versionInfo['signature'];
|
||||
|
|
|
@ -43,6 +43,12 @@ class Msqur
|
|||
return $this->db->getMSQ($id);
|
||||
}
|
||||
|
||||
public function getMSQForDownload($id)
|
||||
{
|
||||
|
||||
return $this->db->getMSQForDownload($id);
|
||||
}
|
||||
|
||||
public function addMSQs($files, $engineid)
|
||||
{
|
||||
$fileList = array();
|
||||
|
|
Loading…
Reference in New Issue