Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nearwood/msqur
Browse files Browse the repository at this point in the history
  • Loading branch information
nearwood committed Oct 31, 2019
2 parents 7fa6b3e + c39d5e3 commit 1b4698d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 9 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Try it now at: https://msqur.com/

#### Needed software

* AMP Stack: Apache, MySQL (MariaDB), PHP
* MariaDB, PHP
* PDO extension for PHP.

#### Recommended software
Expand All @@ -27,12 +27,11 @@ Try it now at: https://msqur.com/
> These steps could be improved
1. Clone repo to dev directory
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. Hit webserver to start using it.
1. Copy script.config.dist to script.config and modify for use (setup DB connection information)
1. Copy src/config.php.dist to src/config.php (setup DB information again)
1. Update DB with update scripts in sequential order (patse into phpMyAdmin or piped to `sqlcmd`, etc.)
1. Hit webserver to start using it (eg. `php -S`, etc.)

### Update & Deployment Instructions

Expand All @@ -55,7 +54,7 @@ msqur is licensed under the GPL v3.0. A copy of this license is included in the

### Credits


[CamHenlin](https://github.com/CamHenlin)

> This section needs to be updated
Expand Down
4 changes: 2 additions & 2 deletions src/browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@

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>';

Expand Down
34 changes: 34 additions & 0 deletions src/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,40 @@ public function getMSQ($id)
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
Expand Down
31 changes: 31 additions & 0 deletions src/download.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood [email protected] 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";
}
?>
1 change: 1 addition & 0 deletions src/msq.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function parseMSQ($xml, &$engine, &$metadata)
$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'];
Expand Down
6 changes: 6 additions & 0 deletions src/msqur.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public function getMSQ($id)
return $this->db->getMSQ($id);
}

public function getMSQForDownload($id)
{

return $this->db->getMSQForDownload($id);
}

public function addMSQs($files, $engineid)
{
$fileList = array();
Expand Down

0 comments on commit 1b4698d

Please sign in to comment.