XOOPS  2.6.0
index.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
21 include __DIR__ . '/header.php';
22 
24 
25 $xoops->header();
26 
27 $admin_page = new \Xoops\Module\Admin();
28 $admin_page->displayNavigation('index.php');
29 
30 $bg = $xoops->getModuleConfig('qrcode_bgcolor', 'qrcode');
32 
33 $fg = $xoops->getModuleConfig('qrcode_fgcolor', 'qrcode');
35 
37 $contrastStatus = 'accept';
38 
39 if ($bg < $fg) { // inverse (light cells on dark backgound) does not work on many readers
41  $contrastStatus = 'error';
42 } elseif (($bg-$fg) < 100) {
44  $contrastStatus = 'error';
45 }
46 $admin_page->addConfigBoxLine($contrastMessage, $contrastStatus);
47 $admin_page->displayIndex();
48 
49 $xoops->footer();
50 
58 function getBrightness($color)
59 {
60  $rgb = normalizeColor($color);
61  //$brightness = ($rgb['r']*299 + $rgb['g']*587 + $rgb['b']*114) / 1000;
62  // luminosity is L = 0.2126 * R + 0.7152 * G + 0.0722.
63  $brightness = ($rgb['r']*0.2126 + $rgb['g']*0.7152 + $rgb['b']*0.0722);
64  return $brightness + 0.00001; // no zero
65 }
66 
74 function normalizeColor($color)
75 {
76  $color = preg_replace('/[^a-fA-F0-9]+/', '', $color); // only hex digits
77  $color = substr('000000'.$color, -6); // only 6 digits, pad with leading zeros
78  $rgb = array(
79  'r' => hexdec(substr($color, 0, 2)),
80  'g' => hexdec(substr($color, 2, 2)),
81  'b' => hexdec(substr($color, 4, 2)),
82  );
83  return $rgb;
84 }
$contrastMessage
Definition: index.php:36
static getInstance()
Definition: Xoops.php:160
$fg
Definition: index.php:33
const _MI_QRCODE_CONTRAST_OK
Definition: modinfo.php:36
normalizeColor($color)
Definition: index.php:74
const _MI_QRCODE_CONTRAST_ERROR
Definition: modinfo.php:37
$contrastStatus
Definition: index.php:37
const _MI_QRCODE_CONTRAST_INVERSE
Definition: modinfo.php:38
getBrightness($color)
Definition: index.php:58
$admin_page
Definition: index.php:56
$bg
Definition: index.php:30
if(file_exists($mainfile)) elseif(file_exists(__DIR__. '/install/index.php')) $xoops
Definition: index.php:36