Update dependencies

This commit is contained in:
Raphael Zimmermann 2015-05-20 21:25:44 +02:00
commit f61d300229
9 changed files with 61 additions and 67 deletions

View File

@ -17,9 +17,7 @@ checks:
fix_identation_4spaces: true
fix_doc_comments: true
tools:
external_code_coverage:
timeout: 600
runs: 3
external_code_coverage: false
php_analyzer: true
php_code_coverage: false
php_code_sniffer:

View File

@ -7,6 +7,7 @@
[![Code Climate](https://codeclimate.com/github/raphiz/passwordcards/badges/gpa.svg)](https://codeclimate.com/github/raphiz/passwordcards)
[![Test Coverage](https://codeclimate.com/github/raphiz/passwordcards/badges/coverage.svg)](https://codeclimate.com/github/raphiz/passwordcards)
[![Dependency Status](https://www.versioneye.com/user/projects/5506fc2766e561bb9b00016e/badge.svg?style=flat)](https://www.versioneye.com/user/projects/5506fc2766e561bb9b00016e)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/6152eda9-0cd1-41a3-84fb-9601d0996a86/mini.png)](https://insight.sensiolabs.com/projects/6152eda9-0cd1-41a3-84fb-9601d0996a86)
This tool allows you to generate customized password cards in the spirit of Qwertycards.com.
@ -25,8 +26,3 @@ If you discover any security related issues, please email mister.norbert ät gma
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## To be done:
add
* Analysis via https://insight.sensiolabs.com/
* make .htaccess that only allows requests to /resources OR /index.php!

View File

@ -1,5 +1,6 @@
{
"name": "raphiz/passwordcards",
"description" : "Generate customized password cards in the spirit of Qwertycards.com",
"require": {
"tecnick.com/tcpdf": "6.2.8",
"rain/raintpl": "3.1.0"

2
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "65a45ca0206b2cc637c8c59adf1d93b8",
"hash": "3f6772a3d073ab279017db06314e6f7b",
"packages": [
{
"name": "rain/raintpl",

View File

@ -19,43 +19,42 @@ if (!RequestUtils::isPost()) {
$tpl = new Tpl;
$tpl->assign('seconds', $spamPrevention);
$tpl->draw('spam');
exit;
} else {
// Parse request
$pattern = RequestUtils::parsePattern();
$keyboardLayout = RequestUtils::parseKeyboardLayout();
$seed = RequestUtils::parseSeed();
$text = RequestUtils::parseText();
$primary = RequestUtils::parsePrimaryColor();
$secondary = RequestUtils::parseSecondaryColor();
$spaceBarSize = RequestUtils::parseSpacebarSize();
// Setup configuration
$cfg = new Configuration($seed, $pattern, $keyboardLayout, $spaceBarSize, $text, $primary, $secondary);
$creator = new CardCreator($cfg);
// Load SVG templates
$front_template = $creator->getSvgTemplate('simple_back');
$back_template = $creator->getSvgTemplate('simple_front');
// Render SVG into tempfiles
$front = $creator->renderIntoTempfile($front_template);
$back = $creator->renderIntoTempfile($back_template);
// Render the PDF
$doc = PDFRenderer::render($front, $back);
// Prepare response PDF file header
RequestUtils::preparePdfHeader(strlen($doc));
// Ignore user abort to cleanup afterwards
ignore_user_abort(true);
// Strem the PDF
echo $doc;
// Cleanup temporary SVG images
unlink($back);
unlink($front);
}
// Parse request
$pattern = RequestUtils::parsePattern();
$keyboardLayout = RequestUtils::parseKeyboardLayout();
$seed = RequestUtils::parseSeed();
$text = RequestUtils::parseText();
$primary = RequestUtils::parsePrimaryColor();
$secondary = RequestUtils::parseSecondaryColor();
$spaceBarSize = RequestUtils::parseSpacebarSize();
// Setup configuration
$cfg = new Configuration($seed, $pattern, $keyboardLayout, $spaceBarSize, $text, $primary, $secondary);
$creator = new CardCreator($cfg);
// Load SVG templates
$front_template = $creator->getSvgTemplate('simple_back');
$back_template = $creator->getSvgTemplate('simple_front');
// Render SVG into tempfiles
$front = $creator->renderIntoTempfile($front_template);
$back = $creator->renderIntoTempfile($back_template);
// Render the PDF
$doc = PDFRenderer::render($front, $back);
// Prepare response PDF file header
RequestUtils::preparePdfHeader(strlen($doc));
// Ignore user abort to cleanup afterwards
ignore_user_abort(true);
// Strem the PDF
echo $doc;
// Cleanup temporary SVG images
unlink($back);
unlink($front);
}

View File

@ -11,12 +11,12 @@
$('#other-chars').parent().slideToggle();
});
$("#primary").tinycolorpicker();
var picker = $('#primary').data("plugin_tinycolorpicker");
picker.setColor("#1ABC9C");
var primaryPicker = $('#primary').data("plugin_tinycolorpicker");
primaryPicker.setColor("#1ABC9C");
$("#secondary").tinycolorpicker();
var picker = $('#secondary').data("plugin_tinycolorpicker");
picker.setColor("#ffffff");
var secondaryPicker = $('#secondary').data("plugin_tinycolorpicker");
secondaryPicker.setColor("#ffffff");
})(jQuery);

View File

@ -8,11 +8,11 @@ class CardCreator
public function __construct($configration)
{
if ($configration == null) {
if ($configration === null) {
throw new \Exception('The given $configuration is null!');
}
if ($configration instanceof Configuration == false) {
if ($configration instanceof Configuration === false) {
throw new \Exception(
'The given $configuration is not a valid ' .
'Configuration object.'
@ -42,8 +42,8 @@ class CardCreator
$seed = $this->configration->seed;
mt_srand($seed);
for ($i = 0; $i < strlen($this->configration->keys); $i++) {
$prefix = '$' . ($i+1);
$number_of_keys = strlen($this->configration->keys);
for ($i = 0; $i < $number_of_keys; $i++) {
$equivalent = $chars[mt_rand(0, $char_count-1)];
$equivalent = $this->escape($equivalent);

View File

@ -57,7 +57,7 @@ class Configuration
*/
public static function evalSeed($seed)
{
if ($seed == null || !is_numeric($seed)) {
if ($seed === null || !is_numeric($seed)) {
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
}
@ -69,7 +69,7 @@ class Configuration
*/
public static function evalPattern($pattern)
{
if ($pattern == null) {
if ($pattern === null) {
$pattern = self::DEFAULT_PATTERN;
}
return $pattern;

View File

@ -26,20 +26,20 @@ class PDFRenderer
// Add the front svg
$pdf->ImageSVG(
$file = $front,
$x = 10,
$y = 15,
$w = '85',
$h = '55'
$front, // filename
10, // x
15, // y
'85', // width
'55' // height
);
// Add the back svg
$pdf->ImageSVG(
$file = $back,
$x = 95,
$y = 15,
$w = '85',
$h = '55'
$back, // filename
95, // x
15, // y
'85', // width
'55' // height
);