Skip to content

Commit

Permalink
update to YOURLS 1.7.9 (usrv check)
Browse files Browse the repository at this point in the history
fix SVG generation error
finish fixing hardcoded png error in share box (about time)
remove backwards compatability to YOURLS <1.7.4
  • Loading branch information
joshp23 committed Jul 22, 2020
1 parent 25be3ed commit e273301
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ YOURLS Integrated QRCodes plugin with exposed options and full integration

This is an updated fork of [Inline QRCode](http://techlister.com/plugins-2/qrcode-plugin-for-yourls/354/) which is more compact, configurable, and just as efficient with more features.

Updating to v2.0.0 + from the 1.x.x branch may cause some unexpected behavior. Deleting the cache and re-generating qr codes may be necessary. Note, attempting to install this before the required U-SRV will result in failure.

## Requires:
YOURLS 1.7.3 ready. Works with YOURLS 1.7.2
YOURLS 1.7.9 +
[U-SRV](https://github.com/joshp23/YOURLS-U-SRV) v2.0.0 +

## Features
Expand Down Expand Up @@ -43,9 +41,9 @@ YOURLS 1.7.3 ready. Works with YOURLS 1.7.2
- the following commands are run from `YOURLS` root folder. Eg, `/absolute/path/to/YOURLS`
3. Symlink or copy `qrchk.php` into the `pages` folder. Automation of this task is planned for a future release.
- Symlink:
`ln -s user/plugins/iqrcodes/assets/qrchk.php pages/qrchk.php`
`ln -s user/plugins/iqrcodes/assets/qrchk.php user/pages/qrchk.php`
- Copy:
`cp user/plugins/iqrcodes/assets/qrchk.php pages/qrchk.php`
`cp user/plugins/iqrcodes/assets/qrchk.php user/pages/qrchk.php`
3. Set permissions and cache
- There needs to be two cache folders (relative to YOURLS root)
- `user/plugins/iqrcodes/cache`
Expand Down Expand Up @@ -87,7 +85,7 @@ All of my published code is developed and maintained in spare time, if you would

===========================

Copyright (C) 2016 - 2018 Josh Panter
Copyright (C) 2016 Josh Panter

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 iqrcodes/assets/iqrcodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function iqrcodes(url, site) {
}
var timestamp = getCookie('usrv_iqrcodes');
var key = md5(timestamp + 'iqrcodes');
var fn = 'qrc_' + md5(shorturl) + '.png';
var fn = 'qrc_' + md5(shorturl) + '.' + iqrcodes_imagetype;
var qrcimg = base_url + '/srv/?id=iqrcodes&key=' + key + '&fn=' + fn;
}

Expand Down
5 changes: 5 additions & 0 deletions iqrcodes/assets/qrchk.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
if ( !file_exists( $filepath ) && $shorturl == !null ) {
iqrcodes_mkdir( $opt[10] );
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );
if ( $opt[5] === 'svg' ) {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3], 0xFFFFFF, 0x000000);
} else {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );
}
}
} else {
echo <<<HTML
Expand Down
35 changes: 20 additions & 15 deletions iqrcodes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: IQRCodes
Plugin URI: https://github.com/joshp23/YOURLS-IQRCodes
Description: Integrated QR Codes
Version: 2.1.2
Version: 2.2.0
Author: Josh Panter
Author URI: https://unfettered.net
*/
Expand Down Expand Up @@ -106,7 +106,7 @@ function iqrcodes_do_page() {
echo '<span style="color:green;">Success</span>: U-SRV is installed and enabled.</p>';
echo '<p><code>srv.php</code> satus: ';

$srvLoc = YOURLS_ABSPATH.'/pages/srv.php';
$srvLoc = YOURLS_ABSPATH.'/user/pages/srv.php';
if ( !file_exists( $srvLoc ) ) {
echo '<font color="red">srv.php is not in the "pages" directory!</font>';
} else {
Expand Down Expand Up @@ -497,7 +497,11 @@ function iqrcodes_add_url( $data ) {

$data['qrcimg'] = $imgname;

QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );
if ( $opt[5] === 'svg' ) {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3], 0xFFFFFF, 0x000000);
} else {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );
}

if( !yourls_is_API() ) {
// required for direct call to yourls_add_new_link() which does not fire the javascript - lets do it manually
Expand Down Expand Up @@ -645,13 +649,8 @@ function iqrcodes_mass_chk() {
$table = 'url';
}

if (version_compare(YOURLS_VERSION, '1.7.3') >= 0) {
$sql = "SELECT * FROM `$table` ORDER BY timestamp DESC";
$all_keys = $ydb->fetchObjects($sql);
} else {
$all_keys = $ydb->get_results("SELECT * FROM `$table` ORDER BY timestamp DESC");

}
$sql = "SELECT * FROM `$table` ORDER BY timestamp DESC";
$all_keys = $ydb->fetchObjects($sql);

iqrcodes_mkdir( $opt[10] );

Expand All @@ -663,7 +662,11 @@ function iqrcodes_mass_chk() {
$filename = '/qrc_' . md5($shorturl) . "." . $opt[5];
$filepath = $opt[10]. '/' . $filename;
if ( !file_exists( $filepath ) && $shorturl == !null ) {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );
if ( $opt[5] === 'svg' ) {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3], 0xFFFFFF, 0x000000);
} else {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );
}
$i++;
}
}
Expand All @@ -676,7 +679,7 @@ function iqrcodes_mass_chk() {
}
}

yourls_add_action( 'loader_failed', 'iqrcode_dot_qr' );
yourls_add_action( 'pre_load_template', 'iqrcode_dot_qr' );
function iqrcode_dot_qr( $request ) {
$base = YOURLS_SITE;
// Get authorized charset in keywords and make a regexp pattern
Expand All @@ -698,9 +701,11 @@ function iqrcode_dot_qr( $request ) {
$filepath = $opt[10]. '/' . $filename;

if ( !file_exists( $filepath ) ) {

QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );

if ( $opt[5] === 'svg' ) {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3], 0xFFFFFF, 0x000000);
} else {
QRcode::{$opt[5]}( $shorturl, $filepath, $opt[1], $opt[2], $opt[3] );
}
}

$imgname = $base . '/srv/?id=iqrcodes&key=' . $key . '&fn=' . $filename;
Expand Down

0 comments on commit e273301

Please sign in to comment.