Skip to content

Commit

Permalink
v1.5 (#24)
Browse files Browse the repository at this point in the history
* 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

* Move deploy prereqs to deploy script

* Update README

* Fix links

* Update copyright
  • Loading branch information
nearwood authored Oct 31, 2019
1 parent fe2b037 commit 46d7489
Show file tree
Hide file tree
Showing 19 changed files with 117 additions and 40 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ jobs:
script: phpunit tests
- stage: deploy
script: bash deploy.sh

before_install:
- mkdir -p ~\/.ssh
- openssl aes-256-cbc -K $encrypted_571de2096706_key -iv $encrypted_571de2096706_iv -in .travis/travis_ci.enc -out .travis/id_rsa -d
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
# MSQur #
# MSQur

'Masker' I guess? Supposed to be a play on imgur.
MegaSquirt MSQ file sharing and viewing site.

Parses MSQ "XML" in tandem with an associated INI (config) file and displays it in a familiar format for viewing and comparing.

Try it now at: http://msqur.com/
Try it now at: https://msqur.com/

### Build Status:
* msqur.com [![Build Status](https://travis-ci.org/nearwood/msqur.svg?branch=msqur.com)](https://travis-ci.org/nearwood/msqur)
* master [![Build Status](https://travis-ci.org/nearwood/msqur.svg?branch=master)](https://travis-ci.org/nearwood/msqur)

### Installation ###
### Installation

#### Needed software ####
#### Needed software

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

#### Recommended software ####
#### Recommended software

* phpMyAdmin - For managing the DB
* rsync - For the deployment script

#### Development Setup ####
#### Development Setup

> 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. Run deploy script
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

### Update & Deployment Instructions ###
> These steps are outdated
* Pull updates on host.
* Update any configuration files (config.php, script.config) if needed.
* Run any new DB scripts.
* Run deploy.sh to copy web files to web server.

### License ###
### License

msqur is licensed under the GPL v3.0. A copy of this license is included in the LICENSE.md file in the source tree.

### Who do I talk to? ###
### Who do I talk to?

* Nicholas Earwood
* nearwood@gmail.com
* http://nearwood.net/
* https://nearwood.dev/

### Credits

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

> This section needs to be updated
### Credits ###
* Apache
* PHP
* MariaDB
Expand Down
3 changes: 3 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#. script.config

mkdir -p ~\/.ssh
openssl aes-256-cbc -K $encrypted_571de2096706_key -iv $encrypted_571de2096706_iv -in .travis/travis_ci.enc -out .travis/id_rsa -d

eval "$(ssh-agent -s)"
chmod 600 .travis/id_rsa
ssh-add .travis/id_rsa
Expand Down
2 changes: 1 addition & 1 deletion src/about.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/admin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
6 changes: 3 additions & 3 deletions src/browse.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down 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
36 changes: 35 additions & 1 deletion src/db.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down 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 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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";
}
?>
2 changes: 1 addition & 1 deletion src/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/msq.format.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
3 changes: 2 additions & 1 deletion src/msq.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down 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
8 changes: 7 additions & 1 deletion src/msqur.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down 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
2 changes: 1 addition & 1 deletion src/search.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/upload.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/util.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/view.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2016 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/view/msqur.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2015 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down
2 changes: 1 addition & 1 deletion src/view/msqur.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* msqur - MegaSquirt .msq file viewer web application
Copyright (C) 2015 Nicholas Earwood nearwood@gmail.com http://nearwood.net
Copyright 2014-2019 Nicholas Earwood nearwood@gmail.com https://nearwood.dev
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
Expand Down

0 comments on commit 46d7489

Please sign in to comment.