Changeset 3213836
- Timestamp:
- 12/27/2024 03:11:34 PM (3 months ago)
- Location:
- dynamic-qr-code/trunk
- Files:
-
- 75 added
- 12 deleted
- 65 edited
Legend:
- Unmodified
- Added
- Removed
-
dynamic-qr-code/trunk/admin/logs.php
r2753631 r3213836 1 1 <?php 2 defined( 'SOSIDEE_PROLICMAN' ) or die( 'you were not supposed to be here' ); 3 2 4 $plugin = \SOSIDEE_DYNAMIC_QRCODE\SosPlugin::instance(); 3 5 $form = $plugin->formSearchLog; 6 $show_lang = $form->showLang(); 7 $show_geo = $form->showGeo(); 8 $show_desc = $form->showDesc(); 9 $show_os = $form->showOS(); 10 4 11 $logs = $form->logs; 5 12 … … 8 15 $mfa_enabled = $plugin->config->mfaEnabled->value; 9 16 10 echo $plugin->help(' logs');17 echo $plugin->help('scan-logs'); 11 18 19 $plugin->htmlAdminPageTitle('Scan logs'); 12 20 ?> 13 <h1>Scan logs</h1>14 21 15 22 <div class="wrap"> … … 20 27 21 28 <table class="form-table" role="presentation"> 22 <t head>29 <tbody> 23 30 <tr> 24 <th scope="col" class="centered middled">QR-Code</th> 25 <th scope="col" class="centered middled">From date<br>(h <?php echo sosidee_time_format( \DateTime::createFromFormat('YmdHis', "20000001000000") ); ?>)</th> 26 <th scope="col" class="centered middled">To date<br>(h <?php echo sosidee_time_format( \DateTime::createFromFormat('YmdHis', "20000001235959") ); ?>)</th> 27 <th scope="col" class="centered middled">Status</th> 28 <th scope="col" class="centered middled"></th> 29 <th scope="col" class="centered middled"></th> 31 <td class="centered topped"> 32 <span class="bolded">QR-Code</span><br> 33 <?php $form->htmlQID(); ?> 34 </td> 35 <td class="centered topped"> 36 <span class="bolded">From date</span><br> 37 <?php $form->htmlFrom(); ?> 38 <br><span class="fs90pc">(h <?php echo sosidee_time_format( \DateTime::createFromFormat('YmdHis', "20000001000000") ); ?>)</span> 39 </td> 40 <td class="topped" rowspan="2"> 41 <span class="bolded" style="margin-bottom: 4px; display:block;">Display</span> 42 <?php $form->htmlShowGeo(); ?> 43 <br> 44 <?php $form->htmlShowLang(); ?> 45 <br> 46 <?php $form->htmlShowDesc(); ?> 47 <br> 48 <?php $form->htmlShowOS(); ?> 49 </td> 50 <td class="centered middled"> 51 <?php $form->htmlCancelAll(); ?> 52 </td> 30 53 </tr> 31 </thead> 32 <tbody> 33 <td class="centered middled"> 34 <?php $form->htmlQID(); ?> 35 </td> 36 <td class="centered middled"> 37 <?php $form->htmlFrom(); ?> 38 </td> 39 <td class="centered middled"> 40 <?php $form->htmlTo(); ?> 41 </td> 42 <td class="centered middled"> 43 <?php $form->htmlStatus(); ?> 44 </td> 45 <td class="centered middled"> 46 <?php $form->htmlButton( 'search', 'search' ); ?> 47 </td> 48 <td class="centered middled"> 49 <?php $form->htmlCancelAll(); ?> 50 </td> 54 <tr> 55 <td class="centered topped"> 56 <span class="bolded">Status</span><br> 57 <?php $form->htmlStatus(); ?> 58 </td> 59 <td class="centered middled"> 60 <span class="bolded">To date</span><br> 61 <?php $form->htmlTo(); ?> 62 <br><span class="fs90pc">(h <?php echo sosidee_time_format( \DateTime::createFromFormat('YmdHis', "20000001235959") ); ?>)</span> 63 </td> 64 <td class="centered middled"> 65 <?php $form->htmlButton( 'search', 'search' ); ?> 66 </td> 67 </tr> 51 68 </tbody> 52 69 </table> … … 58 75 echo '<p> Record(s) found: ' . count($logs) . '</p>'; 59 76 } 60 77 /* 61 78 $sw_uk = '30%'; 62 79 if ( $mfa_enabled ) { … … 81 98 $sw_btn = '20%'; 82 99 } 83 //100 */ 84 101 102 if ( is_array($logs) && count($logs)>0 ) { 85 103 ?> 86 104 … … 88 106 <thead> 89 107 <tr> 90 <th scope="col" class="bordered middled centered" style="width:<?php echo esc_attr( $sw_date ); ?>">Date</th>91 <th scope="col" class="bordered middled centered" style="width:<?php echo esc_attr( $sw_code ); ?>">Key</th>92 <th scope="col" class="bordered middled centered" style="width:<?php echo esc_attr( $sw_state ); ?>">Status</th>108 <th scope="col" class="bordered middled centered">Date</th> 109 <th scope="col" class="bordered middled centered">Status</th> 110 <th scope="col" class="bordered middled centered">Key</th> 93 111 <?php if ( $code_shared ) { ?> 94 <th scope="col" class="bordered middled centered" style="width:<?php echo esc_attr( $sw_qid ); ?>">Q-ID</th> 112 <th scope="col" class="bordered middled centered">Q-ID</th> 113 <?php } ?> 114 <?php if ( $show_desc ) { ?> 115 <th scope="col" class="bordered middled centered">Description</th> 116 <?php } ?> 117 <?php if ( $show_lang ) { ?> 118 <th scope="col" class="bordered middled centered">Language</th> 119 <?php } ?> 120 <?php if ( $show_geo ) { ?> 121 <th scope="col" class="bordered middled centered">Country</th> 122 <?php } ?> 123 <?php if ( $show_os ) { ?> 124 <th scope="col" class="bordered middled centered">Op. System</th> 95 125 <?php } ?> 96 126 <?php if ( $mfa_enabled ) { ?> 97 <th scope="col" class="bordered middled centered" style="width:<?php echo esc_attr( $sw_uk ); ?>">My FastAPP User Key</th>127 <th scope="col" class="bordered middled centered">My FastAPP User Key</th> 98 128 <?php } ?> 99 <th scope="col" class="centered middled" style="width:<?php echo esc_attr( $sw_btn ); ?>"> 100 <?php 101 if ( is_array($logs) && count($logs)>0 ) { 102 $form->htmlDownload( $logs, $code_shared, $mfa_enabled ); 103 } 104 ?> 129 <th scope="col" class="centered middled"> 130 <?php $form->htmlDownload( $logs, $mfa_enabled ); ?> 105 131 </th> 106 132 </tr> … … 108 134 <tbody> 109 135 <?php 110 if ( is_array($logs) && count($logs)>0 ) {111 136 for ($n=0; $n<count($logs); $n++) { 112 137 $item = $logs[$n]; … … 118 143 $status_icon = $item->status_icon; 119 144 $mfa_user_key = $item->user_key; 145 $lang = $show_lang ? $item->lang_desc : ''; 146 $geo = $show_geo ? $item->country_desc : ''; 147 $desc = $show_desc ? $item->qrcode_desc : ''; 148 $op_sys = $show_os ? $item->os_desc : ''; 120 149 121 150 ?> 122 151 <tr> 123 152 <td class="bordered middled centered"><?php echo esc_html( $creation ); ?></td> 153 <td class="bordered middled centered"><?php echo sosidee_kses( $status_icon ); ?></td> 124 154 <td class="bordered middled centered"><?php echo esc_html( $code ); ?></td> 125 <td class="bordered middled centered"><?php echo sosidee_kses( $status_icon ); ?></td>126 155 <?php if ( $code_shared ) { ?> 127 156 <td class="bordered middled centered"><?php echo esc_html( $quid ); ?></td> 157 <?php } ?> 158 <?php if ( $show_desc ) { ?> 159 <td class="bordered middled centered"><?php echo esc_html( $desc ); ?></td> 160 <?php } ?> 161 <?php if ( $show_lang ) { ?> 162 <td class="bordered middled centered"><?php echo esc_html( $lang ); ?></td> 163 <?php } ?> 164 <?php if ( $show_geo ) { ?> 165 <td class="bordered middled centered"><?php echo esc_html( $geo ); ?></td> 166 <?php } ?> 167 <?php if ( $show_os ) { ?> 168 <td class="bordered middled centered"><?php echo esc_html( $op_sys ); ?></td> 128 169 <?php } ?> 129 170 <?php if ( $mfa_enabled ) { ?> … … 132 173 <td class="bordered middled centered"><?php $form->htmlCancel( $id ); ?></td> 133 174 </tr> 134 <?php } 135 } ?> 175 <?php } ?> 136 176 </tbody> 137 177 </table> 178 <?php } ?> 138 179 139 180 <?php -
dynamic-qr-code/trunk/admin/qrcode.php
r2815343 r3213836 1 1 <?php 2 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 3 4 use SOSIDEE_DYNAMIC_QRCODE\SRC\FORM\CheckMode; 5 2 6 $plugin = \SOSIDEE_DYNAMIC_QRCODE\SosPlugin::instance(); 3 7 $form = $plugin->formEditQrCode; … … 7 11 $code_shared = $plugin->config->sharedCodeEnabled->value; 8 12 $mfa_enabled = $plugin->config->mfaEnabled->value; 13 $chkMode = $plugin->config->formCheckMode->value; 9 14 $anyQrHideEnabled = $plugin->config->anyQrHideEnabled->value; 10 11 echo $plugin->help('edit'); 15 //$hideContentEnabled = $anyQrHideEnabled || $form->cypher->value != ''; 16 17 echo $plugin->help('qr-code-edit'); 12 18 13 19 $title = 'QR-Code Edit'; … … 15 21 $title .= ' (new)'; 16 22 } 17 18 echo '<h1>'. esc_html( $title ) . '</h1>'; 19 23 $plugin->htmlAdminPageTitle($title); 20 24 ?> 21 25 … … 161 165 </td> 162 166 <td style="width: 120px;"> 163 <?php //$plugin->formSearchQrCode->htmlLinkButton(0, 'new'); ?>164 167 <?php $plugin->formEditQrCode->htmlButtonLink(0); ?> 165 168 </td> … … 167 170 <?php $form->htmlSave('save'); ?> 168 171 </td> 172 <td style="width: 120px;"> 173 <?php $form->htmlDuplicate(); ?> 174 </td> 169 175 </tr> 170 176 </tbody> 171 177 </table> 172 178 179 <?php if ( $code_shared || $anyQrHideEnabled ) { ?> 173 180 <table class="form-table sqc" role="presentation"> 174 181 <tbody> 182 <?php if ( $code_shared ) { ?> 183 <tr> 184 <th scope="row" class="middled">Q-ID</th> 185 <td class="middled"> 186 <?php $form->htmlQid(); ?> 187 </td> 188 </tr> 189 <?php 190 } 191 192 if ( $anyQrHideEnabled ) { 193 ?> 175 194 <tr> 176 195 <th scope="row" class="middled">Shortcode for content hiding</th> … … 179 198 </td> 180 199 </tr> 181 <?php if ( $code_shared ) { ?> 182 <tr> 183 <th scope="row" class="middled">Q-ID</th> 184 <td class="middled"> 185 <?php $form->htmlQid(); ?> 186 </td> 187 </tr> 188 <?php } ?> 189 <?php if ( $anyQrHideEnabled ) { ?> 200 <?php if ( $chkMode == CheckMode::FIELD ) { ?> 190 201 <tr> 191 202 <th scope="row" class="middled">Form hidden field</th> … … 194 205 </td> 195 206 </tr> 196 <?php } ?> 207 <?php 208 } 209 } 210 ?> 197 211 </tbody> 198 212 </table> 213 <?php } ?> 199 214 200 215 <p> </p> … … 202 217 <a id="a-std" href="javascript:void(0);" class="nav-tab<?php echo !$cypher ? ' nav-tab-active' : ''; ?>">Standard QR code</a> 203 218 <a id="a-enh" href="javascript:void(0);" class="nav-tab<?php echo $cypher ? ' nav-tab-active' : ''; ?>">Enhanced QR code</a> 204 <?php echo $plugin->help('st d-enh-img', 'vertical-align: text-bottom; margin: 4px; margin-left: 1em;'); ?>219 <?php echo $plugin->help('standard-enhanced-image', 'vertical-align: text-bottom; margin: 4px; margin-left: 1em;'); ?> 205 220 </nav> 206 221 <div id="div-std" style="display: <?php echo !$cypher ? 'block' : 'none'; ?>;"> … … 259 274 </table> 260 275 261 276 <?php if ( !$anyQrHideEnabled ) { ?> 262 277 <table class="form-table sqc" role="presentation"> 263 278 <tbody> 279 <tr> 280 <th scope="row" class="middled">Shortcode for content hiding</th> 281 <td class="middled"> 282 <?php $form->htmlQRShortcode1(); ?> 283 </td> 284 </tr> 285 <?php if ( $chkMode == CheckMode::FIELD ) { ?> 264 286 <tr> 265 287 <th scope="row" class="middled">Form hidden field</th> … … 268 290 </td> 269 291 </tr> 292 <?php } ?> 270 293 </tbody> 271 294 </table> 272 295 <?php } ?> 273 296 </div> 274 297 … … 285 308 286 309 <?php 310 $form->htmlCodeOld(); 287 311 $form->htmlId(); 288 312 $form->htmlCypher(); 289 313 $form->htmlClose(); 314 315 if ( !$plugin->hasDuplicate() ) { 316 echo '<hr style="margin-left:0;width:50%;">'; 317 echo $plugin->pro() . ' available in the PRO version'; 318 } 319 290 320 ?> 291 321 -
dynamic-qr-code/trunk/admin/qrcodes.php
r2779336 r3213836 1 1 <?php 2 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 3 4 use SOSIDEE_DYNAMIC_QRCODE\SRC\QrCode; 5 use SOSIDEE_DYNAMIC_QRCODE\SRC\QrCodeSearchStatus; 6 use SOSIDEE_DYNAMIC_QRCODE\SRC\Copy2CB; 2 7 3 8 $plugin = \SOSIDEE_DYNAMIC_QRCODE\SosPlugin::instance(); 4 9 $form = $plugin->formSearchQrCode; 5 10 $qrcodes = $form->qrcodes; 6 $plugin->config->load(); // load current configuration11 $plugin->config->load(); // load the current configuration 7 12 $code_shared = $plugin->config->sharedCodeEnabled->value; 13 8 14 9 15 if ( $code_shared ) { … … 13 19 } 14 20 15 echo $plugin->help('list'); 21 echo $plugin->help('qr-codes-list'); 22 23 $plugin->htmlAdminPageTitle('QR-Code List'); 16 24 ?> 17 <h1>QR-Code List</h1>18 25 19 26 <div class="wrap"> … … 64 71 $id = $item->qrcode_id; 65 72 $url = $item->url_api; 66 $quid = \SOSIDEE_DYNAMIC_QRCODE\SRC\QrCode::getQID( $item->qrcode_id ); 67 $copy = $plugin->getCopyApiUrl2CBIcon( $id, $code ); 73 $quid = QrCode::getQID( $item->qrcode_id ); 74 //$copy = $plugin->getCopyApiUrl2CBIcon( $id, $code ); 75 $copy = Copy2CB::getApiUrlIcon( $id, $code ); 68 76 ?> 69 77 <tr> … … 90 98 if ( is_array($qrcodes) && count($qrcodes) > 0 ) { 91 99 echo 'Legend<br>State:'; 92 $states = \SOSIDEE_DYNAMIC_QRCODE\SRC\QrCodeSearchStatus::getList();100 $states = QrCodeSearchStatus::getList(); 93 101 foreach ( $states as $key => $value ) { 94 102 echo ' '; 95 $icon = \SOSIDEE_DYNAMIC_QRCODE\SRC\QrCodeSearchStatus::getStatusIcon( $key );103 $icon = QrCodeSearchStatus::getStatusIcon( $key ); 96 104 echo sosidee_kses( $icon . ' ' . $value ); 97 105 } -
dynamic-qr-code/trunk/assets/css/admin.css
r2684394 r3213836 2 2 border-collapse: collapse; 3 3 } 4 table.bordered , th.bordered, td.bordered {4 table.bordered th, table.bordered td { 5 5 border: 1px solid gray; 6 6 } 7 table.topped th, table.topped td { 8 vertical-align: top; 9 } 10 table th.bottomed, table td.bottomed { 11 vertical-align: bottom; 12 } 13 7 14 table.rounded4 { 8 15 border-collapse: separate; … … 16 23 text-align: center; 17 24 } 25 th.topped, td.topped { 26 vertical-align: top; 27 } 18 28 th.middled, td.middled { 19 29 vertical-align: middle; … … 22 32 text-align: center; 23 33 vertical-align: middle; 24 }25 th.italiced, td.italiced {26 font-style: italic;27 34 } 28 35 table.pad2p th, table.pad2p td { … … 50 57 margin: 0; 51 58 } 59 60 .italiced { 61 font-style: italic; 62 } 63 .bolded { 64 font-weight: bold; 65 } 66 .fs90pc { 67 font-size: 90%; 68 } 69 70 /* to avoid flickering on mouseover (google charts bug, unfixed...) */ 71 .google-visualization-tooltip { pointer-events: none } -
dynamic-qr-code/trunk/assets/css/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/assets/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/assets/js/config.js
r2779336 r3213836 60 60 value = jsDynCypherObj.min; 61 61 } 62 let value64 = jsDynGetB64Len(value) + jsDynCypherObj.base; // manually inserted values c an be freak63 if ( ctrl.value != value64 ) {62 let value64 = jsDynGetB64Len(value) + jsDynCypherObj.base; // manually inserted values could be odd 63 if ( ctrl.value !== value64 ) { 64 64 ctrl.value = value64; 65 65 } -
dynamic-qr-code/trunk/assets/js/index.html
r2753631 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/assets/js/qrcode.js
r2753631 r3213836 1 1 (function($){ 2 2 'use strict'; 3 $(document).ready(function() 4 { 5 if (!$.ajax) { return null; } 3 $(document).ready(function() { 6 4 7 5 $('#a-std').click( function() { -
dynamic-qr-code/trunk/dynamic-qr-code.php
r2815343 r3213836 2 2 /* 3 3 Plugin Name: Dynamic QR Code 4 Version: 0.9.34 Version: 1.0.0 5 5 Description: Allows you to create DYNAMIC QR CODES: you can modify what happens when scanning your QR code without actually modifying (and reprinting) the QR code. 6 Requires at least: 5.9 7 Tested up to: 6.7 8 Requires PHP: 8.0 6 9 Author: SOSidee.com srl 7 10 Author URI: https://sosidee.com 8 11 Text Domain: dynamic-qr-code 9 12 Domain Path: /languages 13 Plugin URI: https://sosplugin.com/dynamic-qr-code/ 14 Contributors: sosidee 10 15 */ 11 16 namespace SOSIDEE_DYNAMIC_QRCODE; … … 15 20 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA as DATA; 16 21 17 require_once " loader.php";22 require_once "wp-loader.php"; 18 23 19 24 \SOSIDEE_CLASS_LOADER::instance()->add( __NAMESPACE__, __DIR__ ); … … 26 31 { 27 32 28 private static $helpUrl = 'https://redirect.soslink.net/dynamic-qr-code/help/';33 use SRC\TAddon; 29 34 30 35 //pages 31 36 private $pageQrCodes; 32 37 private $pageLogs; 38 33 39 public $pageQrCode; 34 public $pageConfig; 40 public $pageConfigs; 41 private $pageStats; 35 42 36 43 //database … … 42 49 public $formEditQrCode; 43 50 public $formSearchLog; 44 45 //API 46 private $apiRedirect; 51 public $formStatLog; 52 53 private $apiRedirect; //API 47 54 48 55 private $mbHC; //metabox for hiding post/page content 49 50 public static $FLD_HID;51 56 52 57 protected function __construct() { … … 57 62 $this->name = 'Dynamic QR Code'; 58 63 59 self::$FLD_HID = SRC\Shortcode::TAG . '_' . SRC\Shortcode::AUTH;64 SRC\FORM\Base::$FLD_HID = SRC\Shortcode::TAG . '_' . SRC\Shortcode::AUTH; 60 65 61 66 //if necessary, enable localization 62 67 //$this->internationalize( 'dynamic-qr-code' ); //Text Domain 68 69 self::$helpUrl = 'https://support.sosidee.com/{KEY}/'; 70 $this->setHelp('dynamic-qr-code'); 71 72 $this->checkAddon = true; 73 $this->addonClass = 'DQC'; 74 63 75 } 64 76 … … 68 80 // settings 69 81 $section = $this->addSection('config', 'Settings'); 70 //$section->validate = array($this, 'validateConfig'); //moved to form/config //function to be called on configuration data saving 71 $this->config = new SRC\FORM\Config( $section ); 82 $this->config = new SRC\FORM\Configs( $section ); 72 83 73 84 // database: custom tables for the plugin 74 85 $this->database = new SRC\Database(); 75 86 76 $this->apiRedirect = $this->addApiAny('dynamic-qr-code', [ $this, 'apiRedirectByCode'], 0 );87 $this->apiRedirect = $this->addApiAny('dynamic-qr-code', [ $this, 'apiRedirectByCode' ], 0 ); 77 88 $this->apiRedirect->nonceDisabled = true; 78 89 79 $ this->mbHC= $this->addMetaBox( 'post-content', $this->name );80 $this->mbHC ->addField( 'qid', 0);81 $this->mbHC->addField( 'form', false, true ); 82 $this->mbHC->html = [$this, 'htmlMetabox'];83 $this->mbHC->callback = [$this, 'saveMetabox'];84 90 $mb = $this->addMetaBox( 'post-content', $this->name ); 91 $this->mbHC = new SRC\Metabox($mb); 92 93 //if ( $this->hasAnyAddon() ) { 94 // $this->name .= ' PRO'; 95 //} 85 96 } 86 97 … … 89 100 $this->pageQrCodes = $this->addPage('qrcodes' ); 90 101 $this->pageQrCode = $this->addPage('qrcode' ); 102 $this->pageQrCode->menuHidden = true; 91 103 $this->pageLogs = $this->addPage('logs' ); 92 $this->pageConfig = $this->addPage('config' ); 104 $this->pageConfigs = $this->addPage('configs' ); 105 $this->pageStats = $this->addPage('stats' ); 93 106 94 107 //assign data cluster to page 95 $this->config->setPage( $this->pageConfig );108 $this->config->setPage( $this->pageConfigs ); 96 109 97 110 //menu … … 99 112 100 113 $this->menu->add( $this->pageQrCodes, 'QR-Codes' ); 101 $this->menu->add Hidden( $this->pageQrCode );114 $this->menu->add( $this->pageQrCode ); 102 115 $this->menu->add( $this->pageLogs, 'Scan logs' ); 103 $this->menu->add( $this->pageConfig, 'Settings' ); 116 $this->menu->add( $this->pageStats, 'Scan stats' ); 117 $this->menu->add( $this->pageConfigs, 'Settings' ); 104 118 105 119 $this->formSearchQrCode = new SRC\FORM\QrCodeSearch(); … … 112 126 $this->formSearchLog->addToPage( $this->pageLogs ); 113 127 128 $this->formStatLog = new SRC\FORM\logStat(); 129 $this->formStatLog->addToPage( $this->pageStats ); 130 114 131 $this->qsArgs[] = SRC\FORM\QrCodeEdit::QS_ID; 115 132 116 133 $this->addScript('admin')->addToPage( $this->pageQrCodes, $this->pageQrCode ); 117 134 $this->addScript('qrcode')->addToPage( $this->pageQrCode ); 118 $this->addScript('config')->addToPage( $this->pageConfig );119 $this->addStyle('admin')->addToPage( $this->pageQrCodes, $this->pageQrCode, $this->pageLogs );135 $this->addScript('config')->addToPage( $this->pageConfigs ); 136 $this->addStyle('admin')->addToPage( $this->pageQrCodes, $this->pageQrCode, $this->pageLogs, $this->pageStats ); 120 137 $this->addGoogleIcons(); 121 138 $this->addGoogleIconsToEditor(); … … 125 142 add_action('current_screen', [$this, 'checkConfig']); 126 143 127 } 128 129 public function loadQrCodeList( $caption = '' ) { 144 //TEST 145 //$dw = new SOS\WP\DashboardWidget('custom_help_widget', 'Pippo'); 146 //$dw->callback = [$this, 'xxx']; 147 } 148 149 /* 150 public function loadQrCodeList( $caption = false, $include_cancelled = false ) { 130 151 $ret = []; 131 if ( $caption != '') {152 if ( $caption !== false ) { 132 153 $ret[0] = $caption; 133 154 } 134 155 135 $results = $this->database->loadQrCodeList( );156 $results = $this->database->loadQrCodeList( $include_cancelled ); 136 157 137 158 if ( is_array($results) ) { … … 146 167 return $ret; 147 168 } 148 149 public function htmlMetabox( $metabox, $post ) { 150 151 echo '<p>Prevent users to view the post/page if not accessed by scanning the image of this QR-Code: '; 152 echo $this->help('hide-2', 'float: right;'); 153 echo '</p>'; 154 $options = $this->loadQrCodeList('- select -'); 155 $qid = $metabox->getField('qid'); 156 echo '<p>'; 157 echo $qid->getSelect( [ 'options' => $options ] ); 158 echo '</p>'; 159 $form = $metabox->getField('form'); 160 echo '<p>'; 161 echo $form->getCheckbox("allow reloading this post/page by submitting the form(s) contained in it"); 162 echo '</p>'; 163 164 } 165 166 public function saveMetabox( $metabox, $post, $update ) { 167 $res = $metabox->save( $post ); 168 if ( $res === false ) { 169 $metabox->err("{$this->name}: cannot save the data."); 170 } 171 } 172 173 private function setJsCookieEraser() { 174 $cookie = SRC\OTKey::COOKIENAME; 175 $js = "document.cookie = '{$cookie} =; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';"; 169 */ 170 171 public function addDeleteCookieScript( $js ) { 176 172 $this->addInlineScript( $js, 'cookie-delete' ); 177 173 } 178 174 179 p rivatefunction getJsRedirect( $url ) {175 public function getJsRedirect( $url ) { 180 176 $ret = '<p style="font-style: italic;">'; 181 $ret .= SOS\WP\DATA\FormTag::get( 'img', [182 'alt' => 'waiting...'177 $ret .= DATA\FormTag::get( 'img', [ 178 'alt' => 'waiting...' 183 179 ,'src' => $this->getLoaderSrc(24) 184 180 ,'width' => '12px' … … 190 186 self.window.location.replace('{$url}'); 191 187 EOD; 192 $ret .= SOS\WP\DATA\FormTag::get( 'script', [193 'type' => 'application/javascript'188 $ret .= DATA\FormTag::get( 'script', [ 189 'type' => 'application/javascript' 194 190 ,'content' => $js 195 191 ]); … … 198 194 } 199 195 200 private function isFormPosted() {201 return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) == 'POST';202 }203 204 private function checkPostedForm( $value ) {205 $ret = false;206 if ( $this->isFormPosted() ) {207 switch ( $this->config->formCheckMode->value ) {208 case SRC\FORM\CheckMode::METHOD:209 $ret = true;210 break;211 case SRC\FORM\CheckMode::REFERER:212 $ref = wp_get_raw_referer();213 $pid = url_to_postid($ref);214 if ( $pid == get_the_ID() ) {215 $ret = true;216 } else {217 sosidee_log("Hiding content: data posted from an invalid URL. Referer=$ref");218 }219 break;220 case SRC\FORM\CheckMode::FIELD:221 if ( isset($_POST[self::$FLD_HID]) ) {222 $hid = trim( $_POST[self::$FLD_HID] );223 if ( strcasecmp( $hid, $value) == 0 ) {224 $ret = true;225 } else {226 sosidee_log("Hiding content: hidden field value is {$hid} while {$value} was expected.");227 }228 } else {229 sosidee_log("Hiding content: hidden field not found.");230 }231 break;232 }233 } else {234 sosidee_log("Hiding content: invalid REQUEST_METHOD value.");235 }236 return $ret;237 }238 239 public function checkMetaboxPost( $content ) {240 $this->mbHC->load();241 $qid = $this->mbHC->getField('qid');242 243 if ( $qid->value > 0 ) {244 $show = false;245 $id = $qid->value;246 $form = $this->mbHC->getField('qid');247 $hasForm = boolval( $form->value );248 $delete_cookie = true;249 250 $isMobileBrowser = SRC\Mobile::is() && SRC\Mobile::isBrowser();251 $this->config->load(); // load current configuration252 $isDeviceEnabled = $isMobileBrowser || $this->config->anyDeviceEnabled->value; //it's a mobile browser OR any device253 254 if ( $isDeviceEnabled ) {255 //controllare il valore del cookie, e poi ...256 $key = SRC\OTKey::getCookie();257 if ( $key != '' ) {258 $otkey = $this->database->loadOTKey( $key, $id );259 if ( $otkey !== false && $otkey->otk_id > 0 ) {260 $tally = intval( $otkey->tally );261 $tally++;262 if ( $this->database->updateOTKey( $otkey->otk_id, $tally ) == false ) {263 sosidee_log("database.updateOTKey({$tally}) failed for key.id={$otkey->otk_id}");264 }265 if ( $tally == 1 ) {266 if ( $hasForm ) {267 $delete_cookie = false;268 }269 $show = true;270 } else {271 if ( $hasForm && $this->checkPostedForm( $id ) ) {272 $show = true;273 $delete_cookie = false;274 } else {275 sosidee_log("Hiding content: cookie already used.");276 }277 }278 } else {279 if ( $otkey !== false ) {280 sosidee_log("Hiding content: cookie key not found in the database.");281 } else {282 sosidee_log("Hiding content: a problem occurred while reading the cookie key in the database.");283 }284 }285 } else {286 sosidee_log("Hiding content: cookie not found.");287 }288 } else {289 sosidee_log("Hiding content: device not enabled.");290 }291 292 if ( $delete_cookie ) {293 $this->setJsCookieEraser();294 }295 296 if ( $show ) {297 $ret = $content;298 } else {299 $qrcode = $this->database->loadQrCode( $id );300 if ( $qrcode !== false ) {301 $url = $qrcode->url_cypher;302 } else {303 $url = '';304 sosidee_log("database.loadQrCode({$qid->value}) returned false.");305 }306 if ( $url == '') {307 $url = $this->config->urlError->value;308 }309 $ret = $this->getJsRedirect( $url );310 }311 312 } else {313 $ret = $content;314 }315 316 return $ret;317 }318 319 196 protected function initializeFrontend() { 320 add_filter( 'the_content', [ $this, 'checkMetaboxPost' ] ); 197 //add_filter( 'the_content', [ $this, 'checkMetaboxPost' ] ); 198 add_filter( 'the_content', [ $this->mbHC, 'checkPost' ] ); 321 199 $this->addShortCode( SRC\Shortcode::TAG, array($this, 'dynqrcode_handle_shortcode') ); 322 200 } 323 201 324 202 public function checkConfig() { 203 if ( !function_exists('ImageCreate') ) { 204 $msg = "<span class=\"dashicons dashicons-admin-generic\"></span> GD library (PHP) not found: please contact your server administrator."; 205 self::msgErr( $msg ); 206 } 325 207 326 208 if ( $this->pageQrCodes->isCurrent() || $this->pageQrCode->isCurrent() ) { 327 209 if ( !$this->config->check() ) { 328 $msg = "<span class=\"dashicons dashicons-admin-generic\"></span> Configuration is not valid: please check <a href=\"{$this->pageConfig ->url}\">{$this->pageConfig->title}</a>";210 $msg = "<span class=\"dashicons dashicons-admin-generic\"></span> Configuration is not valid: please check <a href=\"{$this->pageConfigs->url}\">{$this->pageConfigs->title}</a>"; 329 211 $this::msgErr($msg); 330 212 } … … 333 215 $this->config->logDisabled->load(); 334 216 if ( $this->config->logDisabled->value == true ) { 335 $msg = "<span class=\"dashicons dashicons-admin-generic\"></span> Logs are currently disabled: please check <a href=\"{$this->pageConfig ->url}\">{$this->pageConfig->title}</a>";217 $msg = "<span class=\"dashicons dashicons-admin-generic\"></span> Logs are currently disabled: please check <a href=\"{$this->pageConfigs->url}\">{$this->pageConfigs->title}</a>"; 336 218 self::msgWarn( $msg ); 337 219 } … … 429 311 } 430 312 431 if ( $msg != '' ) {313 if ( $msg != '' ) { 432 314 $ret .= DATA\FormTag::get( 'pre', [ 433 315 'content' => "{$this->name}: " . $msg … … 466 348 467 349 $this->config->load(); // load current configuration 468 $isMobileBrowser = S RC\Mobile::is() && SRC\Mobile::isBrowser();350 $isMobileBrowser = SOS\Mobile::is() && SOS\Mobile::isBrowser(); 469 351 $isDeviceEnabled = $isMobileBrowser || $this->config->anyDeviceEnabled->value; //it's a mobile browser OR any device 470 352 … … 486 368 } 487 369 } else { 488 if ( $sc->hasForm && $this->checkPostedForm( $sc->id ) ) {370 if ( $sc->hasForm && SRC\FORM\Base::checkPosted( $sc->id ) ) { 489 371 $show = true; 490 372 $delete_cookie = false; … … 528 410 529 411 if ( $delete_cookie ) { 530 $this->setJsCookieEraser();412 SRC\OTKey::setJsCookieEraser(); 531 413 } 532 414 … … 543 425 } 544 426 } 427 545 428 public function getApiUrlLength( $code_length = 0 ) { 546 429 if ( $code_length > 0 ) { … … 548 431 } 549 432 return strlen( $this->getApiUrl() ) + 4 + $code_length; 550 }551 552 private function getCopy2CBIcon( $text, $title ) {553 return '<a href="javascript:void(0);" onclick="jsSosCopy2Clipboard(\'' . esc_js($text) . '\')" title="' . esc_attr($title) . '" style="width: inherit;"><i class="material-icons" style="vertical-align: bottom; max-width: 1em; font-size: inherit; line-height: inherit;">content_copy</i></a>';554 }555 556 private function getCopy2CBAlert( $text, $title ) {557 return '<a href="javascript:void(0);" onclick="alert(\'' . esc_js($text) . '\')" title="' . esc_attr($title) . '" style="width: inherit;"><i class="material-icons" style="vertical-align: bottom; max-width: 1em; font-size: inherit; line-height: inherit;">content_copy</i></a>';558 }559 560 public function getShortcode1Template( $id ) {561 $ret = '[' . SRC\Shortcode::TAG . ' ' . SRC\Shortcode::AUTH . "={$id}]";562 $ret .= 'content displayed to QR code scanners';563 $ret .= '[/' . SRC\Shortcode::TAG . ']';564 return $ret;565 }566 567 public function getShortcode2Template( $id, $standard ) {568 $ret = '[' . SRC\Shortcode::TAG . ' ' . SRC\Shortcode::DISPLAY . "={$id}";569 if ( $standard ) {570 $ret .= ' ' . SRC\Shortcode::IMAGE . '="standard"';571 }572 $ret .= ']';573 return $ret;574 }575 576 public function getHiddenFieldTemplate( $id ) {577 return DATA\FormTag::get( 'input', [578 'type' => 'hidden'579 ,'name' => self::$FLD_HID580 ,'value' => $id581 ]);582 }583 584 public function getCopyApiUrl2CBIcon( $id, $code, $cypher = false ) {585 $title = "copy QR-Code URL to clipboard";586 if ( $id > 0 && $code != '' ) {587 return $this->getCopy2CBIcon( $this->getApiUrl($code, $cypher), $title );588 } else {589 if ( $id <= 0 ) {590 return $this->getCopy2CBAlert( "Please save the QR-Code before copying the URL to clipboard.", $title );591 } else {592 if ( !$cypher ) {593 return $this->getCopy2CBAlert( "Attention: key is empty.", $title );594 } else {595 return $this->getCopy2CBAlert( "Please generate the enhanced QR-Code image before copying the URL to clipboard.", $title );596 }597 }598 }599 }600 601 public function getCopyShortcode2CBIcon( $id, $index = 1, $standard = false ) {602 $title = "copy shortcode to clipboard";603 if ( $id > 0 ) {604 if ( $index == 1 ) {605 $text = $this->getShortcode1Template( $id );606 } else if ( $index == 2 ) {607 $text = $this->getShortcode2Template( $id, $standard );608 } else {609 $text = 'a problem occurred';610 }611 return $this->getCopy2CBIcon( $text , $title );612 } else {613 return $this->getCopy2CBAlert( "Please save the QR-Code before copying the shortcode to clipboard.", $title );614 }615 }616 617 public function getCopyHiddenField2CBIcon( $id ) {618 $title = "copy hidden field to clipboard";619 620 if ( $id > 0 ) {621 $text = $this->getHiddenFieldTemplate( $id );622 return $this->getCopy2CBIcon( $text , $title );623 } else {624 return $this->getCopy2CBAlert( "Please generate the enhanced QR-Code image before copying the hidden field to clipboard.", $title );625 }626 }627 628 public function getCopyApiRoot2CBIcon() {629 $title = "copy URL for MyFast App to clipboard";630 return $this->getCopy2CBIcon( $this->getApiUrl(), $title );631 433 } 632 434 … … 654 456 $anyDevice = $this->config->anyDeviceEnabled->value; 655 457 656 $isMobile = S RC\Mobile::is();458 $isMobile = SOS\Mobile::is(); 657 459 $deviceEnabled = $isMobile || $anyDevice; //it's mobile OR any device 658 460 659 $isMobileBrowser = S RC\Mobile::isBrowser();461 $isMobileBrowser = SOS\Mobile::isBrowser(); 660 462 if ( $isMFApp ) { 661 463 $insertLog = !$this->config->logDisabled->value; … … 664 466 } 665 467 468 if ( $insertLog ) { 469 $log['dev_type'] = $isMobile ? SRC\DeviceType::MOBILE : SRC\DeviceType::NOT_MOBILE; 470 if ( $this->config->geoEnabled->value && $this->hasGeo() ) { 471 $key = $this->config->geoKey->value; 472 $geo = $this->addon::getGeo($key); 473 if ( is_array($geo) ) { 474 $log['country'] = $geo['country']; 475 $log['region'] = $geo['region']; 476 $log['city'] = $geo['city']; 477 } 478 } 479 $langs = SRC\HTTP::getLanguages(); 480 if ( is_array($langs) && count($langs) > 0 ) { 481 $log['lang'] = $langs[0]; 482 } 483 if ( !$this->isPro ) { 484 $log['op_sys'] = SRC\OS::UNKNOWN; 485 } else { 486 $log['op_sys'] = $this->addon::getOS(); 487 } 488 } 489 666 490 $isCypher = false; 667 491 $otkey = false; 668 492 669 493 $method = $request->get_method(); 670 if ( $method == 'GET' && $deviceEnabled ) {494 if ( $method == 'GET' ) { // && $deviceEnabled 671 495 $qs = $request->get_query_params(); 672 496 if ( array_key_exists('qr', $qs) ) { … … 722 546 for ( $n=0; $n<count($items); $n++ ) { 723 547 $item = &$items[$n]; 548 $item->browser = $isMobileBrowser || !$isMobile; //dynamically added 724 549 if ( $item->only_mfa && !$isMFApp ) { 725 550 $status = SRC\QrCodeStatus::DISABLED; … … 727 552 $status = SRC\QrCode::getStatus( $item ); 728 553 } 729 $item->status = $status; 554 $item->status = $status; //dynamically added 730 555 if ( $status == SRC\QrCodeStatus::ACTIVE ) { 731 556 if ( $item->priority ) { … … 772 597 $log['qrcode_id'] = $qrcode->qrcode_id; 773 598 599 if ( !$deviceEnabled ) { 600 $qrcode->status = SRC\QrCodeStatus::DISABLED; 601 } 602 774 603 $log['status'] = $qrcode->status; 775 604 776 if ( $ isCypher || $this->config->anyQrHideEnabled->value) {605 if ( $deviceEnabled && ( $isCypher || $this->config->anyQrHideEnabled->value ) ) { 777 606 $otkey = SRC\OTKey::getNew(); 778 607 $otdata = [ … … 812 641 ,'Event-Id' => $qr_event_id 813 642 ,'User-Key' => $log['user_key'] ?? '' 814 ,'cookie' => $otkey !== false ? $otkey : 'false' 815 ], "API Redirect Parameters: " ); // note: it works if WP_DEBUG_LOG is true 816 643 ,'Cookie' => $otkey !== false ? $otkey : 'false' 644 ], "API Redirect Parameters: " ); // note: it works if WP_DEBUG_LOG constant is true 645 646 $url = $this->getRedirectUrl($url); 817 647 if ( $url != '' ) { 818 $url = $this->getRedirectUrl( $url );819 648 820 649 if ( $insertLog ) { … … 824 653 } 825 654 826 wp_redirect( $url, 302, 'Dynamic QR Code by SOSidee.com' ); 827 828 } else { 829 return new \WP_REST_Response( "Server response: a problem occurred. Please check the Smart QR Code plugin configuration.", 500); 655 wp_redirect( $url, 302, 'Dynamic QR Code plugin' ); 656 657 } else { 658 sosidee_log('Plugin.apiRedirectByCode(): redirect URL is empty.'); 659 return new \WP_REST_Response( "Server response: a problem occurred. Please check the Dynamic QR Code plugin configuration.", 500); 830 660 } 831 661 exit(); … … 833 663 834 664 private function getRedirectUrl( $path ) { 835 $ret = $path; 836 if ( !sosidee_str_starts_with($ret, ['https://', 'http://', '//']) ) { 837 if ( !sosidee_str_starts_with($ret, '/') ) { 838 $ret = '/' . $ret; 839 } 840 $ret = get_site_url() . $ret; 841 } 842 if ( $this->config->randQsEnabled->value ) { 843 $key = 'sos' . strval( random_int(6, 666) ); 844 $value = base64_encode( bin2hex( random_bytes(12) ) ); 845 $ret = add_query_arg( $key, $value, $ret ); 665 $ret = ''; 666 /** @noinspection HttpUrlsUsage */ 667 if ( $path != '' && !sosidee_str_starts_with($path, ['https://', 'http://', '//']) ) { 668 669 if ( $this->hasSocial() ) { 670 if ( $this->hasFacebook() && $this->addon->facebook::is( $path ) ) { 671 $url = $this->addon->facebook::getUrl($path); 672 if ($url !== false) { 673 $ret = $url; 674 } else { 675 sosidee_log("Addon\Facebook.getUrl() returned false for path: $path"); 676 } 677 } else if ( $this->hasInstagram() && $this->addon->instagram::is( $path ) ) { 678 $url = $this->addon->instagram::getUrl($path); 679 if ($url !== false) { 680 $ret = $url; 681 } else { 682 sosidee_log("Addon\Instagram.getUrl() returned false for path: $path"); 683 } 684 } else if ( $this->hasLinkedIn() && $this->addon->linkedin::is( $path ) ) { 685 $url = $this->addon->linkedin::getUrl($path); 686 if ($url !== false) { 687 $ret = $url; 688 } else { 689 sosidee_log("Addon\LinkedIn.getUrl() returned false for path: $path"); 690 } 691 } else if ( $this->hasWhatsApp() && $this->addon->whatsapp::is( $path ) ) { 692 $url = $this->addon->whatsapp::getUrl($path); 693 if ($url !== false) { 694 $ret = $url; 695 } else { 696 sosidee_log("Addon\WhatsApp.getUrl() returned false for path: $path"); 697 } 698 } else if ( $this->hasYouTube() && $this->addon->youtube::is( $path ) ) { 699 $url = $this->addon->youtube::getUrl($path); 700 if ($url !== false) { 701 $ret = $url; 702 } else { 703 sosidee_log("Addon\YouTube.getUrl() returned false for path: $path"); 704 } 705 } else { 706 $ret = $path; 707 } 708 } else { 709 if ( !sosidee_str_starts_with($path, '/') ) { 710 $path = '/' . $path; 711 } 712 $ret = get_site_url() . $path; 713 } 714 } else { 715 $ret = $path; 716 } 717 718 if ( sosidee_str_starts_with($ret, ['https://', 'http://', '//']) ) { 719 $this->config->randQsEnabled->load(); 720 if ( $this->config->randQsEnabled->value ) { 721 $key = 'sos' . strval( random_int(6, 666) ); 722 $value = base64_encode( bin2hex( random_bytes(12) ) ); 723 $ret = add_query_arg( $key, $value, $ret ); 724 } 846 725 } 847 726 return $ret; … … 849 728 850 729 private function deleteFiles( $folder ) { 851 foreach ( glob($folder) as $file ) { 852 if ( is_file($file) ) { 853 unlink($file); 854 } 855 } 856 } 730 try { 731 foreach ( glob($folder) as $file ) { 732 if ( is_file($file) ) { 733 unlink($file); 734 } 735 } 736 } catch ( \Exception $ex ) { 737 sosidee_log( $ex->getMessage() ); 738 } 739 } 740 857 741 public function onDeactivate() { 858 742 $tmp = $this->getTempFolder(); 859 if ( is_array($tmp) && key_exists('basedir', $tmp) ) { 860 $this->deleteFiles( $tmp['basedir'] . '/*.png' ); 861 $this->deleteFiles( $tmp['basedir'] . '/*.csv' ); 862 } 863 } 864 865 public function help( $path = '', $style = 'margin: 0.5em; float: right;' ) { 866 $url = self::$helpUrl . $path; 867 $ret = '<a href="' . esc_url($url) . '" onclick="this.blur();" target="_blank" title="help"><i class="material-icons"'; 743 if ( $tmp !== false ) { 744 $this->deleteFiles( $tmp['path'] . '*.png' ); 745 $this->deleteFiles( $tmp['path'] . '*.csv' ); 746 } 747 } 748 749 public function pro( $style = null, $title = 'PRO version' ) { 750 $url = self::$helpUrl . 'pro-version'; 751 $ret = '<a href="' . esc_url($url) . '" onclick="this.blur();" target="_blank" title="' . esc_attr($title) . '"><i class="dashicons-before dashicons-awards"'; 752 $style = SOS\WP\HtmlTag::getStyle($style, 'color: #ff0000;'); 868 753 if ( !is_null($style) ) { 869 $color = 'color: #ffcc00;';870 if ( $style != '' ) {871 $style = $color . ' ' . $style;872 } else {873 $style = $color;874 }875 754 $ret .= ' style="' . esc_attr($style) . '"'; 876 755 } 877 $ret .= '> help</i></a>';756 $ret .= '></i></a>'; 878 757 return $ret; 758 } 759 760 public function htmlAdminPageTitle( $title ) { 761 echo '<h1>' . esc_html( $title ); 762 if ( $this->hasAnyAddon() ) { 763 echo ' <sup><i class="dashicons-before dashicons-awards" style="font-size: 100%;" title="pro version"></i></sup>'; 764 } 765 echo '</h1>'; 879 766 } 880 767 … … 887 774 $plugin = SosPlugin::instance(); //the class must be the one defined in this file 888 775 $plugin->run(); 889 890 891 // this is the end (A B C) -
dynamic-qr-code/trunk/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/readme.txt
r3075156 r3213836 2 2 Plugin Name: Dynamic QR Code 3 3 Contributors: sosidee 4 Tags: qr code, dynamic qr code, dynamic qr code generator5 Requires at least: 5. 3.06 Tested up to: 6. 5.24 Tags: qr code, qr code generator, dynamic qr code, dynamic qr code generator 5 Requires at least: 5.9.0 6 Tested up to: 6.7 7 7 Stable tag: 0.9.3 8 Requires PHP: 7.48 Requires PHP: 8.0 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 17 17 18 18 A *dynamic* QR code? 19 Yes, the core idea is that *information* associated with the QR code is handled by the plugin and not encoded inside the QR code itself: that's, in short, the essence of *dynamic* QR codes.20 21 In other words, **Dynamic QR Code** permits to change the information encoded in a QR code **without having to modify** the QR code itself.22 Furthermore, the QR code scans are tracked and available for statistical analysis.23 24 Let's be plain withfew simple examples:25 > SCENARIO: you want to store in a QR code the web page of the pharmacy in duty.26 > PROBLEM: the pharmacy changes at everyshift, and you can't (or don't want to) rebuild and reprint the QR code every time.27 > SOLUTION: Dynamic QR Code lets you change the pharmacy web page URL without modifying the QR code.19 Yes, the core idea is that *information* associated with the QR code is managed by the plugin rather than being encoded directly within the QR code itself: this is, in essence, the definition of a *dynamic* QR code. 20 21 In other words, **Dynamic QR Code** allows you to change the information linked to a QR code **without having to alter** the QR code itself. 22 Additionally, scans of the QR codes are tracked and available for statistical analysis. 23 24 Let's be straightforward with a few simple examples: 25 > SCENARIO: you want to store the web page of the pharmacy in duty in a QR code. 26 > PROBLEM: the pharmacy changes with each shift, and you can't (or don't want to) rebuild and reprint the QR code every time. 27 > SOLUTION: Dynamic QR Code allows you to change the pharmacy webpage URL without modifying the QR code itself. 28 28 > 29 > SCENARIO: you want people will be redirected to your current promotion web page after scanning the QR codes thatyou distributed to your resellers.30 > PROBLEM: the page URL changes quite often for some reason (e.g. you want to promote different products without having to modify the very same web page continuously) but you don't want to waist your time inrebuilding, reprinting and resending QR codes to your resellers.31 > SOLUTION: Dynamic QR Code lets you change the redirect URL to your current promotion page without modifying the QR code.29 > SCENARIO: you want customers to be redirected to your current promotion webpage after scanning the QR codes you distributed to your resellers. 30 > PROBLEM: the page URL changes frequently for various reason (e.g. you want to promote different products without continuously modifying the same webpage) but you don't want to waste time rebuilding, reprinting and resending QR codes to your resellers. 31 > SOLUTION: Dynamic QR Code permits you to change the redirect URL to your current promotion page without modifying the QR code image. 32 32 > 33 > SCENARIO: you want to track the scans of your QR code to analyze data and g etstatistical information.33 > SCENARIO: you want to track the scans of your QR code to analyze data and gather statistical information. 34 34 > PROBLEM: there's no easy way to track the activity of people who scan static QR codes. 35 > SOLUTION: Dynamic QR Code automatically tracks the scans and let you download the data for statistical analysis.35 > SOLUTION: Dynamic QR Code automatically tracks the scans and lets you download the data for statistical analysis. 36 36 > 37 > SCENARIO: you want your customers to scan a QR code to view the menu of your restaurant.38 > PROBLEM: the menu changes every day of the week, so 7 different QR codes would be necessary to cover the week.39 > SOLUTION: Dynamic QR Code generates a single QR code that redirects your customers depending on the day of the week.40 41 ### Kinds of scenariofor dynamic QR codes ###42 43 * You need a QR code with a link that can be modified without having to change the QR code.44 * You need to knowhow many times your QR code has been scanned.37 > SCENARIO: you want your customers to scan a QR code to view your restaurant's menu. 38 > PROBLEM: the menu changes every day of the week, so you would need 7 different QR codes would to cover the entire week. 39 > SOLUTION: Dynamic QR Code generates a single QR code that redirects your customers to the appropriate menu depending on the day of the week. 40 41 ### Types of scenarios for dynamic QR codes ### 42 43 * You need a QR code with a link that can be modified without changing the QR code image. 44 * You need to track how many times your QR code has been scanned. 45 45 * You need a QR code that redirects users to different URLs depending on the date or on the day of the week. 46 * You need a web page that can be viewed onlyby scanning a QR code.46 * You need a webpage that can only be accessed by scanning a QR code. 47 47 * You need a QR code that can be scanned a limited number of times. 48 * You need a QR code that opens a Facebook/Instagram/LinkedIn profile directly in the Facebook/Instagram/LinkedIn app (PRO feature). 48 49 49 50 Examples: 50 51 51 * You want to track when customers open your products: *print on them a dynamic QR code for something appealing for t he customers (e.g. a giveaway lottery, a discount coupon, etc.) and getthe statistics.*52 * You want to provide additional product information through videos that can change from time totime: *use a dynamic QR code that redirects to the current video.*53 * You want to measure your customers' engagement in your physical stores: *with dynamic QR codes you can track the users'activity.*54 * You want to measure your marketing campaigns in the physical world: *dynamic QR codes make you be able to perform it.*55 * You want to give information on your weekly program: *use a dynamic QR code to show the program ofthe current day.*52 * You want to track when customers open your products: *print on them a dynamic QR code for something appealing for to customers (e.g. a giveaway lottery, a discount coupon, etc.) and gather the statistics.* 53 * You want to provide additional product information through videos that can change over time: *use a dynamic QR code that redirects to the current video.* 54 * You want to measure customer engagement in your physical stores: *dynamic QR codes allow you to track the user activity.* 55 * You want to measure the effectiveness of your marketing campaigns in the physical world: *dynamic QR codes enable you be able to do so.* 56 * You want to provide information about your weekly program: *use a dynamic QR code to show the schedule for the current day.* 56 57 * You want to display a prize voucher only to people that enter in your shop(s) and scan a QR code. 57 58 See the <a href="https://redirect.soslink.net/dynamic-qr-code/help/scenarios" target="_blank" title="tutorial">online manual</a> for details. 58 * You want to open a YouTube video directly in the YouTube app (PRO feature). 59 60 See the <a href="https://support.sosidee.com/dynamic-qr-code/general-concepts/" target="_blank" title="tutorial">online manual</a> for details. 59 61 60 62 ### GETTING STARTED ### … … 71 73 Then use the *QR-URL* generated by the plugin to create the image of your QR code, or just download the image generated in the plugin page. 72 74 73 » Check the <a href="https:// redirect.soslink.net/dynamic-qr-code/help/" target="_blank" title="tutorial">online manual</a> for details «75 » Check the <a href="https://support.sosidee.com/dynamic-qr-code/" target="_blank" title="tutorial">online manual</a> for details « 74 76 75 77 **Note** 76 If you need to create QR-Codes with the same key, you have to activate the 'Disable unique keys' check box in the Settings page: in this case, identical keys will generate identical qr code images and the redirect URL will be chosen randomly or on the base ofthe conditions set in the QR-Code.78 If you need to create QR-Codes with the same key, you have to activate the 'Disable unique keys' option on the Settings page: in this case, identical keys will generate identical qr code images and the redirect URL will be chosen either randomly or based on the conditions set in the QR-Code. 77 79 78 80 **RANDOM REDIRECT** 79 If you want users randomly redirected to a URL chosen among some:80 81 - activate the 'Disable unique keys' check 82 - create two or more QR-Codes with the same key anddifferent URLs83 84 Users will be redirected to a URL randomly drawn among the available ones (i.e. among the URLs of the valid QR-Codes with the same key of the scanned one).85 86 *Please note that the drawn procedure of URLs uses a pseudo-random generation of numbers. Therefore, do not use this feature to createtrue lotteries or gambling games.*87 88 **DATE 89 If you want users redirected to different URLs depending on the date:90 91 - activate the 'Disable unique keys' check box in the Settings page81 If you want users to be randomly redirected to a URL chosen from several options: 82 83 - activate the 'Disable unique keys' checkbox in the Settings page 84 - create two or more QR-Codes with the same key but different URLs 85 86 Users will be redirected to a URL randomly selected from the available ones (i.e. among the URLs of the valid QR-Codes that share the same key as the one scanned). 87 88 *Please note that the URL selection process uses a pseudo-random number generation. Therefore, do not use this feature for true lotteries or gambling games.* 89 90 **DATE-DEPENDENT REDIRECT** 91 If you want users to be redirected to different URLs depending on the date: 92 93 - activate the 'Disable unique keys' checkbox on the Settings page 92 94 - create two or more QR-Codes with 93 95 - the same key 94 - different date interval of validity95 - different URL 96 97 The URL users will be redirected to will depend on which QR-Code will be valid atthe scan date.98 99 **DAY OF THEWEEK DEPENDENT REDIRECT**100 If you want users redirected to different URLs depending on the day of the week:101 102 - activate the 'Disable unique keys' check box in the Settings page96 - different date intervals of validity 97 - different URLs 98 99 The URL users are redirected to will depend on which QR-Code is valid on the scan date. 100 101 **DAY-OF-THE-WEEK DEPENDENT REDIRECT** 102 If you want users to be redirected to different URLs depending on the day of the week: 103 104 - activate the 'Disable unique keys' checkbox on the Settings page 103 105 - create 7 QR-Codes with 104 106 - the same key 105 107 - different redirect URLs 106 - assign each QR-Code to a different day of the week 107 108 **EXCEPTION DATE FOR A DAY OF THE WEEK DEPENDENT REDIRECT** 109 Let's say you want your users redirected on Easter differently respect on the usual URL for Sunday: 110 111 - activate the 'Disable unique keys' check box in the Settings page 112 - create a QR-Code that redirects to URL1 and assign it to Sunday (this will be the usual redirect) 108 - assign each QR-Code to a specific day of the week 109 110 **EXCEPTION DATE FOR A DAY-OF-THE-WEEK DEPENDENT REDIRECT** 111 Let's say you want your users to be redirected on Easter differently compared to the usual Sunday URL: 112 113 - follow the DAY-OF-THE-WEEK DEPENDENT REDIRECT instructions to create 7 QR-Codes 113 114 - then create another QR-Code with 114 115 - the same key 115 - redirect set to URL2 (i.e. different from URL1)116 - activation date set onthe date of Easter117 - priority checkbox activated118 119 Users will be redirected to URL1 on every Sunday but on Easter, when they'll be redirected to URL2.120 121 » Check the <a href="https:// redirect.soslink.net/dynamic-qr-code/help/" target="_blank" title="tutorial">online manual</a> for more scenarios «116 - the redirect URL set to the URL for Easter 117 - the activation date set to the date of Easter 118 - the priority checkbox activated 119 120 If *https://mydomain.com/sunday* is the URL for Sunday and *https://mydomain.com/easter* is the URL for Easter, users will be redirected to *https://mydomain.com/sunday* on every Sunday except on Easter, when they'll be redirected to *https://mydomain.com/easter*. 121 122 » Check the <a href="https://support.sosidee.com/dynamic-qr-code/" target="_blank" title="tutorial">online manual</a> for more scenarios « 122 123 123 124 **My FastAPP** … … 129 130 130 131 - encoded information cannot be modified 131 - scans track procedures are all but straightforward132 - tracking scan activity is complicated and often not straightforward 132 133 133 134 DYNAMIC QR CODE 134 135 135 136 - embedded information can be changed 136 - scans can be easily tracked 137 - scans can be easily tracked and then analyzed 137 138 138 139 ### Statistics ### 139 140 140 141 QR code scans are logged and available for statistical analysis. 141 142 Enabling the *My FastAPP options* (from the *Settings* menu item), it's possible to distinguish the activity of the various users by the *User Key* values. 142 Some basic statistics, available as PRO add-ons, include scan distributions grouped by date, day, device type, country, and more. 143 144 By enabling the *My FastAPP options* (available under the *Settings* menu), you can differentiate user activity using *User Key* values. 143 145 144 146 == Screenshots == … … 152 154 153 155 Yes, Dynamic QR Code generates the image of your QR code. 154 Nevertheless, you can use an equivalent image created by any third party tool. 156 However, you can also use an equivalent image created by any third-party tool. 157 158 = How many dynamic QR codes can I generate ? = 159 160 As many as you wish (and as many as your WordPress site can handle). 161 162 = What is a dynamic QR code ? = 163 164 In short, it's a simple QR code with a redirection URL encoded in it. 165 This means that the information (the data read scanning the QR code) is stored outside the QR code. 166 With Dynamic QR Code this information is stored in your WordPress website, allowing you to change it whenever you wish. 167 168 = What is a static QR code ? = 169 170 A QR code is defined as *static* when the information associated with it is embedded directly in its code. Most QR codes are static. 171 172 = Do QR codes expire ? = 173 174 A *static* QR code can expire if the information encoded in it's' no longer valid, requiring you to rebuild and reprint it. 175 A *dynamic* QR code can expire in the same way, but (and that's the significant difference) it can be brought back to life simply updating the information stored online. 176 177 = Can I use a QR code image generated by another tool? = 178 179 Yes, as long as the image encodes the correct QR-URL. 155 180 156 181 = Is this plugin a free QR code generator ? = … … 158 183 Yes, Dynamic QR Code is free. 159 184 160 = How many dynamic QR codes can I generate ? = 161 162 As many as you wish (and your WP site handles). 163 164 = What is a dynamic QR code ? = 165 166 Shortly, it's a simple QR code with a redirection URL encoded in it. 167 That means that the information (the data read scanning the QR code) is located outside the QR code. 168 With Dynamic QR Code this information is memorized in your WordPress website, with the huge advantage that you can change it whenever you wish. 169 170 = What is a static QR code ? = 171 172 A QR code is defined *static* when the information associated with it is embedded in its code. Most QR codes are static. 173 174 = Do dynamic QR codes expire ? = 175 176 A *static* QR code can expire because the information you encoded in it may no longer be valid, so you need to rebuild and reprint it. 177 A *dynamic* QR code can expire in the same way, but (and that's the huge difference) it can be brought back to life simply updating the information stored online. 178 179 = Can I use a QR code image generated by another tool? = 180 181 Yes, as long as you encode in the image the correct QR-URL. 185 = Is there a PRO version? = 186 187 Yes, absolutely! You can find all the information about the PRO version and how to purchase it at this URL: [https://sosplugin.com/dynamic-qr-code/](https://sosplugin.com/dynamic-qr-code/) 182 188 183 189 == Upgrade Notice == 184 It seems this section is not used anymore.190 This is a major upgrade. Please ensure you back up your site before updating. 185 191 186 192 == Changelog == 193 194 = 1.0.0 = 195 * Code refactored to ensure compatibility with add-ons provided by the Pro License Manager plugin. 196 * Improved integration with Pro License Manager to support additional features. 197 * Minor bug fixes and performance improvements. 187 198 188 199 = 0.9.3 = -
dynamic-qr-code/trunk/sos/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/sos/wp/api/endpoint.php
r2815343 r3213836 15 15 private $route; 16 16 17 public $localized;18 17 private $configName; 19 18 private $configData; 20 19 20 public $localized; 21 21 public $nonceDisabled; 22 22 -
dynamic-qr-code/trunk/sos/wp/api/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/sos/wp/assets/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/sos/wp/assets/sosApi.js
r2815343 r3213836 1 function sosAjaxReqConf(config) 2 { 1 function sosAjaxReqConf(config) { 3 2 let ret = { 4 3 url: config.url -
dynamic-qr-code/trunk/sos/wp/be/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/sos/wp/be/menu.php
r2779336 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\BE; 3 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP;3 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 … … 9 9 class Menu 10 10 { 11 use SOS_WP\ Property {12 SOS_WP\ Property::__set as __setProp;11 use SOS_WP\TProperty { 12 SOS_WP\TProperty::__set as __setProp; 13 13 } 14 use SOS_WP\Translation; 14 use SOS_WP\TTranslation; 15 use SOS_WP\TBase; 15 16 16 17 public $name; … … 24 25 $this->_addProperty('icon', ''); 25 26 26 $this->name = '';27 $this->name = $name; 27 28 $this->slug = ''; 28 29 $this->color = false; 29 30 30 31 $this->pages = array(); 31 $this->name = $name;32 32 } 33 33 34 public function __set( $name, $value) {35 switch ( $name) {34 public function __set( $name, $value ) { 35 switch ( $name ) { 36 36 case 'icon': 37 if ( sosidee_str_starts_with($value, '-') == true ) {37 if ( sosidee_str_starts_with($value, '-') === true ) { 38 38 $value = 'dashicons' . $value; 39 39 } … … 52 52 * @return Menu object 53 53 */ 54 public function add( $page, $title = '', $role = null) {54 public function add( $page, $title = '', $role = null ) { 55 55 if (count($this->pages) == 0) { 56 56 $this->slug = $page->key; //set the menu base slug 57 57 } 58 if ( $page->title == '') {58 if ( $page->title == '' ) { 59 59 $page->title = $title; 60 60 } … … 70 70 * Adds a menu item without displaying it 71 71 */ 72 public function addHidden($page, $title = '', $role = null) { 72 /* 73 public function addHidden( $page, $title = '', $role = null ) { 73 74 $page->menuType = MenuType::HIDDEN; 74 75 return $this->add($page, $title, $role); 75 76 } 77 */ 76 78 77 79 /** 78 80 * Adds an item to the 'Tools' menu 79 81 */ 80 public function addTool( $page, $title = '', $role = null) {82 public function addTool( $page, $title = '', $role = null ) { 81 83 $page->menuType = MenuType::TOOLS; 82 84 return $this->add($page, $title, $role); … … 86 88 * Adds an item to the 'Settings' menu 87 89 */ 88 public function addSetting( $page, $title = '', $role = null) {90 public function addSetting( $page, $title = '', $role = null ) { 89 91 $page->menuType = MenuType::SETTINGS; 90 92 return $this->add($page, $title, $role); … … 93 95 public function initialize() { 94 96 95 for ($n=0; $n<count($this->pages); $n++) { 97 if ( self::plugin()->isPro ) { 98 $this->name .= ' PRO'; 99 $this->icon = '-awards'; 100 } 101 102 for ( $n=0; $n<count($this->pages); $n++ ) { 96 103 $page = $this->pages[$n]; 97 104 $file = $page->path; … … 105 112 $title = $page->key; 106 113 } 107 if ( $page->menuColor !== false ) {114 if ( $page->menuColor !== false ) { 108 115 $title = "<span style='color:{$page->menuColor};'>" . $title . '</span>'; 109 116 } 110 117 111 if ($page->menuType == MenuType::TOOLS) { 118 if ( $page->menuHidden ) { 119 $title = ''; 120 } 121 122 if ( $page->menuType == MenuType::TOOLS ) { 112 123 $page->hook = add_management_page( $this->name, $title, $page->role, $page->key, $callback ); 113 } 114 else if ($page->menuType == MenuType::SETTINGS) { 124 } else if ( $page->menuType == MenuType::SETTINGS ) { 115 125 $page->hook = add_options_page( $this->name, $title, $page->role, $page->key, $callback ); 116 126 } else { 117 $root = ($page->menuType != MenuType::HIDDEN) ? $this->slug : null; 118 if ($n == 0) { 127 if ( $n == 0 ) { 119 128 $item = $this->name; 120 129 if ($this->color !== false) { … … 122 131 } 123 132 add_menu_page( $this->name, $item, $page->role, $this->slug, $callback , $this->icon); 124 $page->hook = add_submenu_page( $ root, $this->name, $title, $page->role, $this->slug, $callback );133 $page->hook = add_submenu_page( $this->slug, $this->name, $title, $page->role, $this->slug, $callback ); 125 134 } else { 126 $page->hook = add_submenu_page( $ root, $this->name, $title, $page->role, $page->key, $callback );135 $page->hook = add_submenu_page( $this->slug, $this->name, $title, $page->role, $page->key, $callback ); 127 136 } 128 137 } 129 138 } 130 139 } 131 140 132 141 } -
dynamic-qr-code/trunk/sos/wp/be/menutype.php
r2684394 r3213836 5 5 class MenuType 6 6 { 7 const HIDDEN = -1;7 //const HIDDEN = -1; 8 8 const CUSTOM = 0; 9 9 const TOOLS = 1; -
dynamic-qr-code/trunk/sos/wp/be/page.php
r2779336 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\BE; 3 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP;3 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 … … 17 17 class Page 18 18 { 19 use SOS_WP\ Property {20 SOS_WP\ Property::__set as __setProp;19 use SOS_WP\TProperty { 20 SOS_WP\TProperty::__set as __setProp; 21 21 } 22 use SOS_WP\T ranslation;22 use SOS_WP\TTranslation; 23 23 24 24 private static $screen = null; … … 32 32 public $menuColor; 33 33 public $hook; 34 public $menuHidden; 34 35 35 36 public function __construct($path, $name) { … … 39 40 $this->key = ''; 40 41 $this->url = ''; 41 $this->name = '';42 42 $this->role = 'manage_options'; 43 43 $this->title = ''; 44 44 $this->menuType = MenuType::CUSTOM; 45 45 $this->menuColor = false; 46 $this->menuHidden = false; 46 47 $this->hook = false; 47 48 48 if ( $name == '') {49 if ( $name == '' ) { 49 50 $name = sosidee_str_remove('.php', basename( $path) ); 50 51 } -
dynamic-qr-code/trunk/sos/wp/cookie.php
r2815343 r3213836 35 35 private static $DOMAINS = []; 36 36 37 /** @noinspection HttpUrlsUsage */ 37 38 public static function getDomain() { 38 39 if ( empty(self::$domain) ) { 39 self::$domain = strrev( strtolower( esc_url_raw($_SERVER['HTTP_HOST'])) ); 40 $url = isset($_SERVER['HTTP_HOST']) ? strtolower( esc_url_raw($_SERVER['HTTP_HOST']) ) : ''; 41 if ( sosidee_str_starts_with($url, 'https://') ) { 42 $url = substr($url, strlen('https://')); 43 } else if ( sosidee_str_starts_with($url, 'http://') ) { 44 $url = substr($url, strlen('http://')); 45 } 46 self::$domain = strrev( $url ); 40 47 if ( count(self::$DOMAINS) == 0 ) { 41 48 self::loadDomains(); -
dynamic-qr-code/trunk/sos/wp/data/cluster.php
r2779336 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA; 3 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP;3 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 … … 10 10 class Cluster 11 11 { 12 use SOS_WP\ Property {13 SOS_WP\ Property::__set as __setProp;12 use SOS_WP\TProperty { 13 SOS_WP\TProperty::__set as __setProp; 14 14 } 15 use SOS_WP\T ranslation;15 use SOS_WP\TTranslation; 16 16 17 17 protected static $plugin = null; … … 112 112 * Assignes an admin page to the data cluster (or, if you prefer, assignes a data cluster to an admin page) 113 113 * 114 * @param string | BE\Page $page : ID of the page or the page itself114 * @param string | SOS_WP\BE\Page $page : ID of the page or the page itself 115 115 * 116 116 */ -
dynamic-qr-code/trunk/sos/wp/data/field.php
r2815343 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA; 3 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP;3 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 … … 10 10 class Field 11 11 { 12 use SOS_WP\ Property12 use SOS_WP\TProperty 13 13 { 14 SOS_WP\ Property::__get as __getProp;15 SOS_WP\ Property::__set as __setProp;16 } 17 use SOS_WP\T ranslation;18 use Encryption;19 20 p rivate$loaded;14 SOS_WP\TProperty::__get as __getProp; 15 SOS_WP\TProperty::__set as __setProp; 16 } 17 use SOS_WP\TTranslation; 18 use TEncryption; 19 20 public $loaded; 21 21 public $encrypted; 22 22 … … 393 393 */ 394 394 public function callback( $input ) { 395 $ret = $input; 395 396 if ( !is_null($this->validate) ) { 396 397 if ( !$this->handled ) { … … 398 399 $result = call_user_func( $this->validate, $this->parent->key, array($this->key => $input) ); 399 400 if ( is_array($result) ) { 400 $ret = array_values($result)[0]; 401 if ( !empty($result) ) { 402 $values = array_values($result); 403 if ( isset($values[0]) ) { 404 $ret = $values[0]; 405 } else { 406 $ret = null; 407 } 408 } else { 409 $ret = null; 410 } 401 411 } else { 402 412 $ret = $result; 403 413 } 404 if ( !$this->encrypted ) { 405 return $ret; 406 } else { 407 return $this->encrypt( $ret ); 408 } 409 } else { 410 return $input; 411 } 412 } 414 if ( $this->encrypted && !is_null($ret) ) { 415 $ret = $this->encrypt( $ret ); 416 } 417 } 418 } 419 return $ret; 413 420 } 414 421 -
dynamic-qr-code/trunk/sos/wp/data/form.php
r2815343 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA; 3 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP;3 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP; 4 4 5 5 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); … … 7 7 class Form 8 8 { 9 use SOS_WP\Message; 10 use SOS_WP\Translation; 9 use SOS_WP\TBase; 10 use SOS_WP\TMessage; 11 use SOS_WP\TTranslation; 11 12 12 13 private $_nonce_name; 13 14 private $_nonce_action; 14 15 private $_actions; 15 16 protected $_plugin;17 16 18 17 public $_name; … … 50 49 } 51 50 52 $this->_plugin = \SOSIDEE_DYNAMIC_QRCODE\SosPlugin::instance();53 54 51 } 55 52 … … 58 55 $ret = new FormField( $type, $id, $value ); 59 56 $ret->name = $name; 60 //$this->{$name} = $ret; not necessary ( why?)57 //$this->{$name} = $ret; not necessary (but don't remember why) 61 58 $this->_fields[] = $ret; 62 59 return $ret; … … 91 88 return $this->addField( FormFieldType::CHECK, $name, $value ); 92 89 } 90 public function addRadio( $name, $value = false ) { 91 return $this->addField( FormFieldType::RADIO, $name, $value ); 92 } 93 93 public function addSelect( $name, $value = 0 ) { 94 94 return $this->addField( FormFieldType::SELECT, $name, $value ); … … 100 100 $this->_encType = 'multipart/form-data'; 101 101 return $this->addField( FormFieldType::FILE, $name, null ); 102 } 103 public function addCheckList( $name, $value = [] ) { 104 return $this->addField( FormFieldType::CHECKLIST, $name, $value ); 102 105 } 103 106 … … 161 164 protected function isCached() { 162 165 $ret = false; 163 for ( $n=0; $n<count($this->_fields); $n++) {166 for ( $n=0; $n<count($this->_fields); $n++ ) { 164 167 if ($this->_fields[$n]->cached) { 165 168 $ret = true; … … 187 190 if ( !$continue ) { 188 191 for ( $n=0; $n<count($this->_pages); $n++ ) { 189 if ( $this->_pages[$n]->isCurrent() ) { 190 $continue = true; 191 break; 192 $page = $this->_pages[$n]; 193 if ( $page instanceof \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\BE\Page ) { 194 if ( $this->_pages[$n]->isCurrent() ) { 195 $continue = true; 196 break; 197 } 198 } else { 199 if ( !is_string($page) ) { 200 $page = print_r($page, true); 201 } 202 sosidee_log("Form.sanitize(): uninstantiated page ('{$page}'). Maybe it was not added to menu."); 192 203 } 193 204 } … … 222 233 case FormFieldType::CHECK: 223 234 $field->value = isset( $_POST[$field->name] ); 235 break; 236 case FormFieldType::CHECKLIST: 237 $values = sanitize_text_field( $_POST[$field->name] ); 238 if ( !empty($values) ) { 239 $field->value = explode(';', $values); 240 } else { 241 $field->value = []; 242 } 224 243 break; 225 244 default: … … 276 295 public function htmlClose() { 277 296 echo sosidee_kses( $this->getClose() ); 278 ;}297 } 279 298 280 299 public function addToPage() { … … 290 309 291 310 private function getCacheKey() { 292 return strtolower( str_replace("-", "_", "{$this->_plugin->key}_{$this->_name}_cache") ); 311 $key = self::plugin()->key . "_{$this->_name}_cache"; 312 return strtolower( str_replace("-", "_", $key) ); 293 313 } 294 314 -
dynamic-qr-code/trunk/sos/wp/data/formbutton.php
r2779336 r3213836 7 7 const STYLE_SUCCESS = 'color: #ffffff; background-color: #5cb85c; border-color: #4cae4c;'; 8 8 const STYLE_DANGER = 'color: #ffffff; background-color: #d9534f; border-color: #d43f3a;'; 9 const STYLE_WARNING = 'color: #ffffff; background-color: #f0ad4e; border-color: #f0ad4e;'; 10 const STYLE_SECONDARY = 'color: #ffffff; background-color: #6c757d; border-color: #6c757d'; 9 11 10 12 private static function get( $type, $name, $value, $style, $class, $onclick ) { 11 13 return FormTag::get( 'input', [ 12 'type' => $type14 'type' => $type 13 15 ,'id' => $name 14 16 ,'name' => $name … … 21 23 ); 22 24 } 23 24 25 25 26 public static function getSubmit( $name, $value = 'ok', $style = '', $class = '', $onclick = null ) { … … 40 41 41 42 public static function htmlLink( $value = 'ok', $style = '', $class = '', $onclick = null ) { 42 echo sosidee_kses( self::get Button(null, $value, $style, $class, $onclick ) );43 echo sosidee_kses( self::get( 'button', null, $value, $style, $class, $onclick ) ); 43 44 } 44 45 -
dynamic-qr-code/trunk/sos/wp/data/formfield.php
r2779336 r3213836 37 37 ,'cols' => null 38 38 ,'rows' => null 39 ,'size' => null 39 40 40 41 ,'onclick' => null … … 67 68 ,'value' => $this->value 68 69 ,'maxlength' => $keys['maxlength'] 70 ,'size' => $keys['size'] 69 71 ,'onclick' => $keys['onclick'] 70 72 ,'onchange' => $keys['onchange'] … … 78 80 79 81 $html = FormTag::get( 'input', [ 80 'type' => 'checkbox'82 'type' => 'checkbox' 81 83 ,'id' => $this->id 82 84 ,'name' => $this->name … … 105 107 ]); 106 108 109 } else if ( $this->type == FormFieldType::RADIO ) { 110 111 $options = $keys['options']; 112 if ( !is_null($options) ) { 113 $counter = 0; 114 foreach ( $options as $_value => $_text ) { 115 if ( $ret != '' ) { 116 $ret .= '<br>'; 117 } 118 $item_id = "{$this->id}_$counter"; 119 $ret .= FormTag::get('input',[ 120 'type' => 'radio' 121 ,'id' => $item_id 122 ,'name' => $this->name 123 ,'value' => $_value 124 ,'checked' => strcasecmp($_value, $this->value) == 0 125 ,'onclick' => $keys['onclick'] 126 ]); 127 $ret .= FormTag::get( 'label', [ 128 'for' => $item_id 129 ,'content' => $_text 130 ]); 131 $counter++; 132 } 133 } 134 107 135 } else if ( $this->type == FormFieldType::SELECT ) { 108 136 … … 114 142 if ( !is_array($_text) ) { 115 143 $html .= FormTag::get('option',[ 116 'id' => "{$this->id}_$counter"144 'id' => "{$this->id}_$counter" 117 145 ,'name' => "{$this->name}_$counter" 118 146 ,'value' => $_value … … 125 153 foreach ($_text as $gr_value => $gr_text) { 126 154 $gr_html .= FormTag::get('option',[ 127 'id' => "{$this->id}_$counter"155 'id' => "{$this->id}_$counter" 128 156 ,'name' => "{$this->name}_$counter" 129 157 ,'value' => $gr_value … … 144 172 145 173 $ret .= FormTag::get( 'select', [ 146 'id' => $this->id174 'id' => $this->id 147 175 ,'name' => $this->name 148 176 ,'html' => $html 149 177 ,'onchange' => $keys['onchange'] 178 ,'style' => $keys['style'] 150 179 ]); 151 180 … … 153 182 154 183 $ret .= FormTag::get( 'input', [ 155 'type' => 'number'184 'type' => 'number' 156 185 ,'id' => $this->id 157 186 ,'name' => $this->name … … 160 189 ,'max' => $keys['max'] 161 190 ,'step' => $keys['step'] 191 ,'style' => $keys['style'] 192 ,'class' => $keys['class'] 162 193 ,'onclick' => $keys['onclick'] 163 194 ,'onchange' => $keys['onchange'] … … 168 199 169 200 $ret .= FormTag::get( 'input', [ 170 'type' => 'color'201 'type' => 'color' 171 202 ,'id' => $this->id 172 203 ,'name' => $this->name … … 181 212 182 213 $ret .= FormTag::get( 'input', [ 183 'type' => 'date'214 'type' => 'date' 184 215 ,'id' => $this->id 185 216 ,'name' => $this->name … … 197 228 198 229 $ret .= FormTag::get( 'input', [ 199 'type' => 'time'230 'type' => 'time' 200 231 ,'id' => $this->id 201 232 ,'name' => $this->name … … 213 244 214 245 $ret .= FormTag::get( 'input', [ 215 'type' => 'hidden'246 'type' => 'hidden' 216 247 ,'id' => $this->id 217 248 ,'name' => $this->name … … 223 254 224 255 $ret .= FormTag::get( 'input', [ 225 'type' => 'file'256 'type' => 'file' 226 257 ,'id' => $this->id 227 258 ,'name' => $this->name … … 267 298 ]); 268 299 300 } else if ( $this->type == FormFieldType::CHECKLIST ) { 301 302 $jsFunc = $this->getJsFuncName( $this->id ); 303 $options = $keys['options']; 304 $count = 0; 305 foreach ($options as $value => $text) { 306 $id = "{$this->id}_{$count}"; 307 if ( $ret != '') { 308 $ret .= '<br>'; 309 } 310 $ret .= FormTag::get( 'input', [ 311 'type' => 'checkbox' 312 ,'id' => $id 313 ,'name' => "{$this->name}_{$count}" 314 ,'value' => $value 315 ,'checked' => in_array($value, $this->value) 316 ,'onclick' => "{$jsFunc}(this.value,this.checked);" 317 ]); 318 $ret .= FormTag::get( 'label', [ 319 'for' => $id 320 ,'content' => $text 321 ]); 322 $count++; 323 } 324 325 $ret .= FormTag::get( 'input', [ 326 'type' => 'hidden' 327 ,'id' => $this->id 328 ,'name' => $this->name 329 ,'value' => implode(';', $this->value) 330 ] ); 331 332 $js = <<<EOD 333 function {$jsFunc}( v, m ) { 334 let field = self.document.getElementById( '{$this->id}' ); 335 let values = field.value.split( ';' ).filter(element => element); 336 if ( m && !values.includes(v) ) { 337 values.push(v); 338 } else if ( !m && values.includes(v) ) { 339 values = values.filter( function(e, i, a) { return e != v; }, v ); 340 } 341 field.value = values.join( ';' ); 342 } 343 EOD; 344 $ret .= FormTag::get( 'script', [ 345 'type' => 'application/javascript' 346 ,'content' => $js 347 ]); 269 348 } 270 349 … … 272 351 if ( $description != '' ) { 273 352 if ( $description == strip_tags($description) ) { 274 $html = HtmlTag::get( 'span', [ 'content' => $description, 'style' => 'font-style:italic;' ]);275 $ret .= HtmlTag::get( 'p', [ 'html' => $html ]);353 $html = FormTag::get( 'span', [ 'content' => $description, 'style' => 'font-style:italic;' ]); 354 $ret .= FormTag::get( 'p', [ 'html' => $html ]); 276 355 } else { 277 356 $ret .= $description; … … 300 379 } 301 380 302 303 381 public function getValueAsDate( $end_of_day = false ) { 304 382 if ( is_null( $this->value ) ) { -
dynamic-qr-code/trunk/sos/wp/data/formfieldtype.php
r2779336 r3213836 16 16 const COMBOBOX = 10; 17 17 const FILE = 11; 18 const CHECKLIST = 12; 19 const RADIO = 13; 18 20 } -
dynamic-qr-code/trunk/sos/wp/data/formtag.php
r2779336 r3213836 6 6 { 7 7 8 public static function getStyle( $parameter, $default = null ) {9 if ( !is_null($default) ) {10 if ( !is_null($parameter) ) {11 $results = [];12 $defs = explode(';', $default);13 for ($n=0; $n<count($defs); $n++) {14 $kvs = explode(':', $defs[$n]);15 if (count($kvs) == 2) {16 $results[$kvs[0]] = rtrim( $kvs[1], ';');17 }18 }19 $pars = explode(';', $parameter);20 for ($n=0; $n<count($pars); $n++) {21 $kvs = explode(':', $pars[$n]);22 if (count($kvs) == 2) {23 $results[$kvs[0]] = rtrim( $kvs[1], ';');24 }25 }26 $ret = "";27 foreach ($results as $key => $value ) {28 $ret .= "$key:$value;";29 }30 return $ret;31 } else {32 return $default;33 }34 } else {35 return $parameter;36 }37 }38 39 8 } -
dynamic-qr-code/trunk/sos/wp/data/group.php
r2779336 r3213836 48 48 $value = $this->values[$field->key]; 49 49 $field->setValue( $value ); 50 $field->loaded = true; 50 51 } 51 52 } … … 59 60 */ 60 61 public function callback( $inputs ) { 61 if ( !is_null($this->validate) ) { 62 if ( !$this->handled ) { 62 if ( !is_null($this->validate) && !$this->handled ) { 63 63 $results = call_user_func( $this->validate, $this->key, $inputs ); 64 64 65 if ( $this->encrypted ) { //at least one field is encrypted65 if ( $this->encrypted && is_array($results) ) { //at least one field is encrypted 66 66 foreach ( $results as $key => $value ) { 67 67 $field = $this->getField($key); … … 74 74 $this->handled = true; // so it won't be handled anymore 75 75 return $results; 76 } else {77 return $inputs;78 }79 76 } 77 return $inputs; 80 78 } 81 79 -
dynamic-qr-code/trunk/sos/wp/data/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/sos/wp/data/mbfield.php
r2753631 r3213836 78 78 } 79 79 80 public function getCheckbox( $ label = '') {80 public function getCheckbox( $data = [] ) { 81 81 $ret = FormTag::get( 'input', [ 82 82 'type' => 'checkbox' … … 86 86 ]); 87 87 88 if ( $label != '') {88 if ( isset($data['label']) ) { 89 89 $ret .= FormTag::get( 'label', [ 90 'for' => $this->id91 ,'content' => $ label90 'for' => $this->id 91 ,'content' => $data['label'] 92 92 ]); 93 93 } -
dynamic-qr-code/trunk/sos/wp/data/wpcolumn.php
r2815343 r3213836 9 9 class WpColumn 10 10 { 11 12 use TDateTime; 13 11 14 protected $parent; //name 12 15 … … 62 65 return null; 63 66 } else { 64 return Db::getDatetimeAsString( $value, $quoted );67 return self::getDatetimeAsString( $value, $quoted ); 65 68 } 66 69 } … … 70 73 return null; 71 74 } else { 72 return Db::getDatetimeFromString( $value );75 return self::getDatetimeFromString( $value ); 73 76 } 74 77 } … … 78 81 return null; 79 82 } else { 80 return Db::getTimeAsString( $value, $quoted );83 return self::getTimeAsString( $value, $quoted ); 81 84 } 82 85 } … … 86 89 return null; 87 90 } else { 88 return Db::getTimeFromString( $value );91 return self::getTimeFromString( $value ); 89 92 } 90 93 } … … 92 95 public function setDefaultValue( $value ) { 93 96 $this->defaultValue = $value; 97 return $this; 98 } 99 100 public function setNullable( $value ) { 101 $this->nullable = $value; 94 102 return $this; 95 103 } -
dynamic-qr-code/trunk/sos/wp/data/wpdatabase.php
r2779336 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA; 3 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP_ROOT;3 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP_ROOT; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 … … 7 7 class WpDatabase 8 8 { 9 use SOS_WP_ROOT\Property; 9 use SOS_WP_ROOT\TProperty; 10 use SOS_WP_ROOT\TBase; 10 11 11 12 protected $prefix; //tables prefix … … 14 15 public $lastErrors; 15 16 16 public function __construct( $prefix = null) {17 public function __construct( $prefix ) { 17 18 global $wpdb; 18 if ( is_null($prefix) ) { 19 $prefix = 'sos_'; 19 if ( !sosidee_str_starts_with($prefix, 'sos') && !sosidee_str_starts_with($prefix, '_sos') ) { 20 if ( !sosidee_str_starts_with($prefix, '_') ) { 21 $prefix = '_' . $prefix; 22 } 23 $prefix = 'sos' . $prefix; 20 24 } 21 25 if ( !sosidee_str_ends_with($wpdb->prefix, '_') && !sosidee_str_starts_with($prefix, '_') ) { … … 44 48 $count = count($this->tables); 45 49 if ( $count > 0 ) { 46 require_once( ABSPATH . 'wp-admin/includes/upgrade.php');50 require_once( ABSPATH . str_replace('/', DIRECTORY_SEPARATOR, 'wp-admin/includes/upgrade.php') ); 47 51 if ( function_exists('dbDelta') ) { 48 52 $ret = true; … … 77 81 } 78 82 79 public function create() 80 { 83 public function create() { 81 84 add_action( 'plugins_loaded', function() { 82 $plugin = \SOSIDEE_DYNAMIC_QRCODE\SosPlugin::instance(); 83 $key = $plugin->key . '_db-version'; 85 $current = $this->plugin()->version; 86 if ( empty($current) ) { 87 $msg = "Plugin version is empty. Check if initialize() function contains the line 'parent::initialize();'"; 88 if ( is_admin() ) { 89 $this->plugin()::msgErr($msg, true); 90 } 91 sosidee_log("WpDatabase.create(): " . $msg); 92 } 93 $key = $this->plugin()->key . '_db-version'; 84 94 $installed = get_option($key, '0' ); 85 $current = $plugin->version;86 95 if ( version_compare($installed, $current) < 0 ) { 87 96 if ( $this->createTables() ) { 88 97 update_option($key, $current ); 98 $this->plugin()->onDatabaseUpdate($installed, $current); 89 99 } else { 90 100 if ( is_admin() ) { 91 101 for ( $n=0; $n<count($this->lastErrors); $n++ ) { 92 $ plugin::msgErr( $this->lastErrors[$n]);102 $this->plugin()::msgErr( $this->lastErrors[$n], true ); 93 103 } 94 104 } … … 124 134 125 135 /** 126 * @param string $formatted_sql sql query with formats (%d, %s, %f)127 * @param array $values values associated with the formats --> look out: order is important!128 * @return wpdb object|false136 * @param \string $formatted_sql sql query with formats (%d, %s, %f) 137 * @param \array $values values associated with the formats --> look out: order is important! 138 * @return \wpdb object|false 129 139 * 130 140 * Example: obj->query( "INSERT INTO <table> (foo, bar, baz) VALUES (%s, %d, %f)", 'pippo', 123, 1.23 ); -
dynamic-qr-code/trunk/sos/wp/data/wptable.php
r2779336 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA; 3 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP_ROOT;3 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP_ROOT; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 6 6 class WpTable 7 7 { 8 use SOS_WP_ROOT\ Property;8 use SOS_WP_ROOT\TProperty; 9 9 10 10 protected $columns; … … 64 64 return $this->addColumn($name, WpColumnType::TIME); 65 65 } 66 66 67 67 68 protected function getColumnByName($name) { … … 152 153 $clauses = array(); 153 154 $values = array(); 155 $filter_in = false; 154 156 foreach ( $filters as $key => $value ) { 155 157 $clauses[] = array(); … … 158 160 159 161 $name = $key; 160 $operator = '=';162 $operator = !is_array($value) ? '=' : ' IN '; 161 163 $p1 = strrpos($key, '['); 162 164 if ( $p1 !== false ) { … … 175 177 $values[$index] = $column->getTimeValueAsString( $value ); 176 178 } else { 177 $values[$index] = $value; 178 } 179 $clauses[$index]['format'] = $column->getQueryFormat(); 179 if ( !is_array($value) ) { 180 $values[$index] = $value; 181 } else { 182 $values[$index] = '{_(' . implode(',', $value) . ')_}'; 183 $filter_in = true; 184 } 185 } 186 if ( !is_array($value) ) { 187 $clauses[$index]['format'] = $column->getQueryFormat(); 188 } else { 189 $clauses[$index]['format'] = '%s'; 190 } 180 191 } else { 181 192 $error = true; … … 214 225 if ( count($values) > 0) { 215 226 $query = $wpdb->prepare($sql, $values); 227 if ( $filter_in ) { 228 $query = str_replace([" IN '{_(", ")_}'"], [" IN (", ")"], $query); 229 } 216 230 } else { 217 231 $query = $sql; … … 230 244 $values[$name] = $wpColumn->getNativeValueFromString( $value ); 231 245 } else { 232 sosidee_log( "WpTable.querySelect() :: {$this->name}.getColumnByName({$name}) returned false." );246 sosidee_log( "WpTable.querySelect(): returned column {$name} not found in the definition of table {$this->name}." ); 233 247 } 234 248 } -
dynamic-qr-code/trunk/sos/wp/elementor/control.php
r2714714 r3213836 20 20 public $options; 21 21 public $text; 22 public $multiple; 22 23 23 24 public function __construct( $key, $type ) { … … 30 31 $this->options = array(); 31 32 $this->text = ''; 33 $this->multiple = false; 32 34 } 33 35 … … 55 57 $ret['options'] = $this->options; 56 58 } 59 if ( $this->multiple != false ) { 60 $ret['multiple'] = true; 61 } 57 62 return $ret; 58 63 } -
dynamic-qr-code/trunk/sos/wp/elementor/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/sos/wp/elementor/section.php
r2684394 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\Elementor; 3 use \Elementor as NativeElementor;3 use Elementor as NativeElementor; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 -
dynamic-qr-code/trunk/sos/wp/elementor/widget.php
r2714714 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP\Elementor; 3 use \Elementor as NativeElementor;3 use Elementor as NativeElementor; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 … … 26 26 public $icon; 27 27 public $category; 28 public $keyword; 28 29 // 29 30 … … 37 38 38 39 * Example: 39 public function setKey() 40 { 40 public function setKey() { 41 41 $this->key = self::plugin()->key . '_unique_key'; 42 42 } … … 56 56 $this->icon = 'eicon-star-o'; 57 57 $this->category = 'general'; 58 $this->keyword = []; 58 59 } 59 60 … … 72 73 public function get_categories() { 73 74 return is_array($this->category) ? $this->category : [ $this->category ]; 75 } 76 77 public function get_keywords() { 78 return is_array($this->keyword) ? $this->keyword : [ $this->keyword ]; 74 79 } 75 80 -
dynamic-qr-code/trunk/sos/wp/functions.php
r2815343 r3213836 71 71 if ( !function_exists('sosidee_str_remove') ) { 72 72 function sosidee_str_remove( $search, $subject ) { 73 return str_replace($search, '', $subject); 73 if ( is_array($search) ) { 74 $blank = array_fill(0, count($search), ''); 75 } else { 76 $blank = ''; 77 } 78 return str_replace($search, $blank, $subject); 79 } 80 } 81 82 if ( ! function_exists( 'sosidee_check_path_separator' ) ) { 83 function sosidee_check_path_separator( $path ) { 84 return str_replace('/', DIRECTORY_SEPARATOR, $path); 85 } 86 } 87 88 if ( ! function_exists( 'sosidee_check_folder_separator' ) ) { 89 function sosidee_check_folder_separator( $path ) { 90 return rtrim( sosidee_check_path_separator($path) , DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; 91 } 92 } 93 94 if ( ! function_exists( 'sosidee_append_url_separator' ) ) { 95 function sosidee_append_url_separator( $url ) { 96 return rtrim( $url , '/') . '/'; 97 } 98 } 99 100 if ( ! function_exists( 'sosidee_upload_dir' ) ) { 101 function sosidee_upload_dir() { 102 $ret = false; 103 $root = wp_upload_dir(); 104 if ( $root['error'] === false && isset($root['baseurl']) && isset($root['basedir']) ) { 105 $ret = [ 106 'path' => sosidee_check_folder_separator( $root['basedir'] ) 107 ,'url' => sosidee_append_url_separator( $root['baseurl'] ) 108 ]; 109 } 110 return $ret; 74 111 } 75 112 } … … 86 123 87 124 if ( ! function_exists( 'sosidee_get_query_var' ) ) { 88 function sosidee_get_query_var($var, $ mixed= null) {125 function sosidee_get_query_var($var, $def_value = null) { 89 126 $ret = get_query_var($var, null); 90 127 if ( is_null($ret) && isset( $_GET[$var] ) ) { 91 128 $ret = sanitize_text_field( $_GET[$var] ); 92 129 } else { 93 $ret = $ mixed;130 $ret = $def_value; 94 131 } 95 132 return $ret; … … 106 143 if ( ! function_exists( 'sosidee_is_base64' ) ) { 107 144 function sosidee_is_base64($data) { 108 return base64_encode(base64_decode($data, true)) === $data; 145 if ( ( $str = base64_decode($data, true) ) === false) { 146 return false; 147 } 148 if ( in_array(mb_detect_encoding($str), ['UTF-8', 'ASCII']) ) { 149 return true; 150 } else { 151 return false; 152 } 109 153 } 110 154 } … … 112 156 if ( ! function_exists( 'sosidee_dirname' ) ) { 113 157 function sosidee_dirname( $path, $levels = 1 ) { 158 $ret = ''; 114 159 if ( version_compare( phpversion(), '7.0.0') >= 0 ) { 115 returndirname($path, $levels);160 $ret = dirname($path, $levels); 116 161 } else { 117 162 if ($levels > 1){ 118 returndirname( sosidee_dirname( $path, --$levels ) );163 $ret = dirname( sosidee_dirname( $path, --$levels ) ); 119 164 }else{ 120 return dirname( $path ); 121 } 122 } 165 $ret = dirname( $path ); 166 } 167 } 168 return $ret; //str_replace('/', DIRECTORY_SEPARATOR, $ret); 123 169 } 124 170 } … … 149 195 } 150 196 $plug = substr($path, $k); 151 $m = strpos($plug, '/') + $k;197 $m = strpos($plug, '/'); 152 198 if ( $m !== false ) { 199 $plug = substr($path, $k, $m); 200 /* 201 $m += $k; 153 202 $plug = substr($path, $k, $m - $k); 203 */ 154 204 } 155 205 } … … 173 223 } 174 224 return strpos( $_SERVER['REQUEST_URI'], trailingslashit( rest_get_url_prefix() ) ) !== false; 225 } 226 } 227 228 if ( ! function_exists( 'sosidee_is_local' ) ) { 229 function sosidee_is_local() { 230 $ret = false; 231 if (substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1') { 232 $ret = true; 233 } 234 return $ret; 235 } 236 } 237 238 if ( ! function_exists( 'sosidee_is_dev' ) ) { 239 function sosidee_is_dev() { 240 $file = realpath(ABSPATH) . DIRECTORY_SEPARATOR . 'sos_identifier.txt'; 241 return file_exists($file) && trim(file_get_contents($file)) === 'SOS-DEV'; 175 242 } 176 243 } … … 247 314 248 315 $tags = [ 249 'a', ' b', 'br', 'button', 'caption', 'code', 'col', 'colgroup'250 , 'data', 'd iv', 'em', 'form'316 'a', 'audio', 'b', 'br', 'button', 'caption', 'code', 'col', 'colgroup' 317 , 'data', 'datalist', 'div', 'em', 'form' 251 318 , 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' 252 , 'hr', 'i', 'i mg', 'input'319 , 'hr', 'i', 'iframe', 'img', 'input' 253 320 , 'label', 'legend', 'li', 'nav' 254 321 , 'ol', 'optgroup', 'option' 255 , 'p', 'pre', 'script', 'se lect', 'span', 'strong'322 , 'p', 'pre', 'script', 'section', 'select', 'span', 'strong', 'style' 256 323 , 'table', 'tbody', 'td', 'textarea', 'th', 'thead', 'title', 'tr' 257 , 'ul' 324 , 'ul', 'video' 258 325 ]; 259 326 … … 262 329 , 'disabled', 'download', 'enctype' 263 330 , 'for', 'form', 'height', 'href', 'id' 264 , 'label', ' max', 'maxlength', 'method', 'min', 'name'331 , 'label', 'lang', 'max', 'maxlength', 'method', 'min', 'name' 265 332 , 'onblur', 'onchange', 'onclick', 'onfocus', 'onload', 'onsubmit' 266 , 'readonly', 'rows', 'rowspan', 'scope', 'selected', 'size', 'span', 'src', 'step', 'style' 267 , 'target', 'title', 'type', 'value', 'width', 'wrap' 333 , 'readonly', 'rel', 'rows', 'rowspan' 334 , 'scope', 'selected', 'size', 'span', 'src', 'step', 'style' 335 , 'usemap', 'target', 'title', 'type', 'value', 'width', 'wrap' 268 336 ]; 269 337 -
dynamic-qr-code/trunk/sos/wp/htmltag.php
r2779336 r3213836 75 75 } 76 76 77 public static function getStyle( $parameter, $default = null ) { 78 if ( !is_null($default) ) { 79 if ( !is_null($parameter) ) { 80 $results = []; 81 $defs = explode(';', $default); 82 for ($n=0; $n<count($defs); $n++) { 83 $kvs = explode(':', $defs[$n]); 84 if (count($kvs) == 2) { 85 $results[$kvs[0]] = rtrim( $kvs[1], ';'); 86 } 87 } 88 $pars = explode(';', $parameter); 89 for ($n=0; $n<count($pars); $n++) { 90 $kvs = explode(':', $pars[$n]); 91 if (count($kvs) == 2) { 92 $results[$kvs[0]] = rtrim( $kvs[1], ';'); 93 } 94 } 95 $ret = ""; 96 foreach ($results as $key => $value ) { 97 $ret .= "$key:$value;"; 98 } 99 return $ret; 100 } else { 101 return $default; 102 } 103 } else { 104 return $parameter; 105 } 106 } 77 107 78 108 } -
dynamic-qr-code/trunk/sos/wp/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/sos/wp/metabox.php
r2815343 r3213836 18 18 class MetaBox 19 19 { 20 use Property, Message,Translation;20 use TProperty, TMessage, TTranslation; 21 21 22 22 public $fields; … … 186 186 } 187 187 } 188 sosidee_log( 'Metabox.callbackSave(): empty or invalid nonce (' . esc_attr($_POST[$nonce_name]) . ')' );188 sosidee_log( 'Metabox.callbackSave(): empty or invalid nonce' ); 189 189 } 190 190 } else { … … 207 207 $this->err($msg); 208 208 } 209 return $post_ID; 209 210 } 210 211 … … 270 271 * Save data in the 'postmeta' table 271 272 * 272 * @param WP_Post $post : the post related to the metabox273 * @param \WP_Post $post : the post related to the metabox 273 274 * @return mixed: 274 275 * (bool) true: success … … 284 285 $key = $field->key; 285 286 $values[$key] = $field->value; 286 if ( !is_array($prev_values) || $prev_values[$key] != $field->value ) {287 if ( !is_array($prev_values) || !array_key_exists($key, $prev_values) || $prev_values[$key] != $field->value ) { 287 288 $ret = false; 288 289 } … … 350 351 * Template for the displaying function 351 352 * 352 * @param Metabox $metabox : a metabox353 * @param WP_Post $post : the post353 * @param \Metabox $metabox : a metabox 354 * @param \WP_Post $post : the post 354 355 * 355 356 public function html( $metabox, $post ) { -
dynamic-qr-code/trunk/sos/wp/plugin.php
r2815343 r3213836 1 1 <?php 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP; 3 use \Elementor as NativeElementor;3 use Elementor as NativeElementor; 4 4 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 5 5 … … 12 12 class Plugin 13 13 { 14 use Property 15 { 16 Property::__get as __getProp; 17 Property::__set as __setProp; 18 } 19 use Message, Asset, Translation; 14 use TProperty 15 { 16 TProperty::__get as __getProp; 17 TProperty::__set as __setProp; 18 } 19 use TTransient, TMessage, TAsset, TTranslation, TAddon; 20 21 protected static $helpUrl = 'https://redirect.soslink.net/{KEY}/help/'; 20 22 21 23 private $localizedScriptHandles; … … 33 35 34 36 protected $dashLinks; 37 protected $customUpdate; 35 38 36 39 protected $file; … … 46 49 public static $path = ''; 47 50 public static $url = ''; 51 52 public $isPro; 48 53 49 54 protected function __construct() { 55 $this->isPro = false; 50 56 51 57 $this->_addProperty('key', 'sos-plugin'); … … 71 77 72 78 $this->dashLinks = array(); 73 74 self::$path = sosidee_dirname( plugin_dir_path( __FILE__ ) , 2); 79 $this->customUpdate = false; 80 81 $this->resetAddons(); 82 $this->plmVersionMin = '1.0.0'; 83 84 self::$path = sosidee_check_path_separator( sosidee_dirname( plugin_dir_path( __FILE__ ) , 2) ); 75 85 $this->folder = basename(self::$path); 76 86 self::$url = sosidee_dirname( plugin_dir_url( __FILE__ ) , 2); … … 85 95 self::$_instances[$calledClass] = new $calledClass(); 86 96 } 87 88 97 return self::$_instances[$calledClass]; 89 98 } 90 99 91 100 public function __get( $name ) { 92 $ret = null;93 101 switch($name) { 94 102 default: … … 113 121 return $ret; 114 122 } 115 123 116 124 /** 117 125 * Creates and adds a backend page located in the 'admin' folder … … 201 209 } 202 210 211 protected function addStyleInline( $code ) { 212 $key = $this->key . '-' . time(); 213 wp_register_style( $key, false ); 214 wp_enqueue_style( $key ); 215 wp_add_inline_style( $key, $code ); 216 } 217 203 218 protected function addScript( $file, $jquery_dependency = true, $in_body = false ) { 204 219 $key = $this->key . '-' . count($this->scripts); … … 224 239 $action = !is_admin() ? 'wp_enqueue_scripts' : 'admin_enqueue_scripts'; 225 240 add_action( $action, function() use ( $code, $pages, $handle ) { 226 if ( !is_array($pages)) {241 if ( !is_array($pages) ) { 227 242 $pages = [$pages]; 228 243 } … … 238 253 if ( $add ) { 239 254 $this->addInlineScript( $code, $handle ); 240 } else {241 return false;242 255 } 243 256 } ); … … 272 285 $data = $callback(); 273 286 $this->addLocalizedScript( $name, $data, $handle ); 274 } else {275 return false;276 287 } 277 288 } ); … … 294 305 $ret = new API\EndPoint($method, $route, $callback, $version ); 295 306 $this->endpoints[] = $ret; 296 $this->addApiAjax();307 //$this->addApiAjax(); //va aggiunta solo se serve 297 308 return $ret; 298 309 } … … 311 322 protected function addApiAny( $route, $callback = null, $version = 1 ) { 312 323 return $this->_addApiEndPoint( ['GET','POST'], $route, $callback, $version); 313 //return $this->_addApiEndPoint( \WP_REST_Server::ALLMETHODS, $route, $callback, $version);314 324 } 315 325 … … 376 386 if ( $this->version == '' ) { 377 387 $this->getInfo(); 378 if ( $this->version == '') {388 if ( $this->version == '' ) { 379 389 add_action('plugins_loaded', function() { 380 390 if ( $this->version == '' ) { … … 384 394 } 385 395 } 396 397 add_action('plugin_loaded', [$this, '_onLoad']); 398 399 if ( !has_action('plugins_loaded', [$this, 'initializeAddons']) ) { 400 add_action('plugins_loaded', [$this, 'initializeAddons']); 401 } 402 386 403 } 387 404 … … 429 446 430 447 public function initializePage() { 448 $data = array(); 431 449 for ( $n=0; $n<count($this->pages); $n++ ) { 432 $this->pages[$n]->translate(); 433 $this->pages[$n]->url = admin_url('admin.php?page=' . $this->pages[$n]->key); 450 $page = &$this->pages[$n]; 451 $page->translate(); 452 if ( $page->menuType == BE\MenuType::TOOLS ) { 453 $page->url = add_query_arg('page', $page->key, admin_url('tools.php')); 454 } else if ( $page->menuType == BE\MenuType::SETTINGS ) { 455 $page->url = add_query_arg('page', $page->key, admin_url('options-general.php')); 456 } else { 457 $page->url = add_query_arg('page', $page->key, admin_url('admin.php')); 458 } 459 if ( $page->menuHidden === true ) { 460 $last_slash_pos = strrpos($page->url, '/'); 461 if ( $last_slash_pos !== false ) { 462 $href = substr($page->url, $last_slash_pos + 1); 463 $data[] = $href; 464 } 465 } 466 unset($page); 467 } 468 if ( count($data) > 0 ) { 469 $js = "jQuery(document).ready(function($) { "; 470 foreach ($data as $item) { 471 $js .= "$('a[href=\"$item\"]').closest('li').remove(); "; 472 } 473 $js .= " });"; 474 $this->registerInlineScript($js); 434 475 } 435 476 } … … 446 487 add_action('elementor/widgets/widgets_registered', [$this, 'initializeElementor']); 447 488 } else { 448 // self::msgWarn('The minimum version of Elementor is 2.0.0.', true);489 // self::msgWarn('The minimum version of Elementor is 2.0.0.', true); 449 490 } 450 491 } else { 451 // self::msgWarn('Elementor is not loaded.', true);492 // self::msgWarn('Elementor is not loaded.', true); 452 493 } 453 494 } … … 476 517 $title = $link['title']; 477 518 $target = $link['target']; 478 if ( self::$internationalized) {519 if ( self::$internationalized ) { 479 520 $text = $this::t_($text); 480 521 } … … 521 562 if ( $after_title && $metabox->context == 'after_title' ) { 522 563 add_action('edit_form_after_title', function() { 523 if ($this->gutenbergEnabled) { return false;}564 if ($this->gutenbergEnabled) { return; } 524 565 global $post, $wp_meta_boxes; 525 566 do_meta_boxes( get_current_screen(), 'after_title', $post ); // Output the "after_title" meta boxes … … 531 572 } 532 573 } 533 if ( count($this->pages) > 0 ) { 534 add_action( 'admin_menu', array($this, 'initializePage') ); 535 } 536 if ( count($this->menu->pages) > 0 ) { 537 add_action( 'admin_menu', array($this, 'initializeMenu') ); 538 } 574 539 575 if ( count($this->scripts) > 0 ) { 540 576 for ($n=0; $n<count($this->scripts); $n++) { … … 552 588 } 553 589 554 $file = "{$this->folder}/{$this->folder}.php"; 555 if ( !is_multisite() ) { 556 add_action( "in_plugin_update_message-$file", [$this, 'displayUpdateNotice'], 10, 2 ); 557 } else { 558 add_action( "after_plugin_row_wp-{$file}", [$this, 'displayUpdateNoticeMS'], 10, 2 ); 590 if ( $this->customUpdate == false ) { 591 $file = "{$this->folder}/{$this->folder}.php"; 592 if ( !is_multisite() ) { 593 add_action( "in_plugin_update_message-$file", [$this, 'displayUpdateNotice'], 10, 2 ); 594 } else { 595 add_action( "after_plugin_row_wp-{$file}", [$this, 'displayUpdateNoticeMS'], 10, 2 ); 596 } 597 } 598 599 if ( count($this->pages) > 0 ) { 600 add_action( 'admin_menu', array($this, 'initializePage') ); 601 } 602 if ( count($this->menu->pages) > 0 ) { 603 add_action( 'admin_menu', array($this, 'initializeMenu') ); 559 604 } 560 605 … … 571 616 } 572 617 573 register_deactivation_hook($this->file, array($this, 'onDeactivate')); 618 if ( !is_null($this->file) ) { 619 register_activation_hook($this->file, array($this, 'onActivate')); 620 register_deactivation_hook($this->file, array($this, 'onDeactivate')); 621 } 622 623 } 624 625 public function onDatabaseUpdate($old_version, $new_version) { 626 //to be overridden, if needed 627 } 628 629 public function onActivate() { 630 //to be overridden, if needed 574 631 } 575 632 … … 578 635 } 579 636 637 public function onLoad() { 638 //to be overridden, if needed 639 } 640 641 public function _onLoad($file) { 642 $folder = sosidee_check_path_separator( sosidee_dirname($file) ); 643 if ( $folder == $this::$path ) { 644 $this->onLoad(); 645 } 646 } 580 647 581 648 /** … … 628 695 * @return integer : index of the group in the $clusters array 629 696 * 630 * @TODO: move to DATA\ Db or DATA\Group697 * @TODO: move to DATA\Group 631 698 **/ 632 699 protected function getGroupIndexById( $id ) { … … 634 701 635 702 $ret = false; 636 $sql = "SELECT option_name, option_value FROM $wpdb->optionsWHERE option_id=%d";703 $sql = "SELECT option_name, option_value FROM {$wpdb->options} WHERE option_id=%d"; 637 704 $query = $wpdb->prepare( $sql, $id); 638 705 $results = $wpdb->get_row($query, ARRAY_A); 639 if ( $results) {706 if ( $results ) { 640 707 $key = sanitize_key( $results["option_name"] ); 641 708 $ret = $this->getClusterIndex($key); 642 if ( $ret !== false) {709 if ( $ret !== false ) { 643 710 $cluster = $this->clusters[$ret]; 644 711 if ( $cluster instanceof Data\Group ) { … … 656 723 657 724 protected function isEncryptionPossible() { 658 659 660 725 return extension_loaded( 'openssl' ) 726 && defined('SECURE_AUTH_KEY') && SECURE_AUTH_KEY != '' 727 && defined('SECURE_AUTH_SALT') && SECURE_AUTH_SALT != ''; 661 728 } 662 729 663 730 public function getTempFolder() { 664 731 $ret = false; 665 $root = wp_upload_dir();666 if ( $root ['error'] === false ) {667 $url = $root[' baseurl'] . '/' . $this->key;668 $folder = $root[' basedir'] . '/' . $this->key;732 $root = sosidee_upload_dir(); 733 if ( $root !== false ) { 734 $url = $root['url'] . $this->key . '/'; 735 $folder = $root['path'] . $this->key . DIRECTORY_SEPARATOR; 669 736 $ok = is_dir($folder); 670 737 if ( !$ok ) { … … 672 739 } 673 740 if ( $ok ) { 674 $file = $folder . DIRECTORY_SEPARATOR .'index.html';741 $file = $folder . 'index.html'; 675 742 if ( !is_file($file) ) { 676 $content = "<!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>";743 $content = "<!DOCTYPE html><html lang=\"en\"><head><title>no way</title></head><body>you weren't supposed to be here</body></html>"; 677 744 file_put_contents( $file, $content ); 678 745 } 679 746 680 747 $ret = array(); 681 $ret[' basedir'] = $folder;682 $ret[' baseurl'] = $url;748 $ret['path'] = $folder; 749 $ret['url'] = $url; 683 750 } 684 751 } … … 779 846 } 780 847 848 protected function setHelp( $key ) { 849 self::$helpUrl = str_replace( '{KEY}', $key, self::$helpUrl ); 850 } 851 852 public function help( $path = '', $style = 'margin: 0.75em; float: right;' ) { 853 $url = self::$helpUrl . $path; 854 $ret = '<a href="' . esc_url($url) . '" onclick="this.blur();" target="_blank" title="help"><i class="dashicons dashicons-editor-help"'; 855 $style = HtmlTag::getStyle($style, 'color: #ffcc00; font-size: 1.5em; text-decoration: none;'); 856 if ( !is_null($style) ) { 857 $ret .= ' style="' . esc_attr($style) . '"'; 858 } 859 $ret .= '></i></a>'; 860 return $ret; 861 } 862 781 863 } -
dynamic-qr-code/trunk/sos/wp/script.php
r2753631 r3213836 13 13 class Script 14 14 { 15 use Property16 17 Property::__get as __getProp;18 Property::__set as __setProp;19 15 use TProperty 16 { 17 TProperty::__get as __getProp; 18 TProperty::__set as __setProp; 19 } 20 20 21 21 private $dependency; -
dynamic-qr-code/trunk/sos/wp/shortcode.php
r2779336 r3213836 25 25 if ( sosidee_is_rest() ) { 26 26 // do not sanitize if it's a block editor api call (in this case is_admin() always returns false and can't be used) 27 return ;27 return null; 28 28 } 29 29 … … 31 31 // prevent other plugins to call the $callback function 32 32 //@TODO: unless the call comes from Elementor (otherwise its display doesn't work...) 33 return ;33 return null; 34 34 } 35 35 -
dynamic-qr-code/trunk/sos/wp/style.php
r2753631 r3213836 12 12 class Style 13 13 { 14 use Property {15 Property::__get as __getProp;16 Property::__set as __setProp;14 use TProperty { 15 TProperty::__get as __getProp; 16 TProperty::__set as __setProp; 17 17 } 18 18 -
dynamic-qr-code/trunk/sos/wp/user.php
r2779336 r3213836 2 2 namespace SOSIDEE_DYNAMIC_QRCODE\SOS\WP; 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 5 //TEMPORARY: cache_users() not loaded with WP 6.1 6 if ( ! function_exists( 'cache_users' ) ) { 7 require_once realpath(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'pluggable.php'); 8 } 4 9 5 10 class User -
dynamic-qr-code/trunk/src/api.php
r2684394 r3213836 5 5 class Api 6 6 { 7 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\TBase; 8 7 9 const IMG_LOGO = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAC5fAAAuXwGHz8Q2AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAIABJREFUeJzt3Xl8VNXd+PHPuTOTDcIWQBZBUMEFBM0CuFQBrbVu7aPVulXtU7X+2qfWrdrlsdparV20VWvdaqtVH+veulXrgqIoQhIWURFlVZQdQliSzMz9/v6YBJLMJHNnMjNnlu/79coLmJy595sh53vPPfcsBpXT5G1KKWE0LqMR9gAGYhiEUIFDBUIFUAEUtb6lf+ufRUCv1r9vB1pa/7659c9mYCOwEcNGXDYCG1q/1uBjBU0sN4exM80/okojYzsAFZ/UEkDYD8MEYDzC3hhGAaOAPawGB2uB5RhWICxHeA94D8NHppqg5dhUHJoAsoy8TSnFVCNMxjAB4SDgQHZfwXNFC/ABhvcQFmJ4l2ZqtcWQXTQBWCaz2YMAk3CpwuFwhCOAEttxpUkIWADMQqjD8LqpZpXtoAqZJoAMkxn4KWcKcCJwDFBJYf8/LEN4BYfn6MN/zBiabQdUSAr5Fy9jZDZ74uckhK9imM7uzjfV0TbgVeBF/DxrDma17YDynSaANJFaBiIcj8O3EKYDju2YcowLvAM8jsPjppLPbQeUjzQBpJDUMhDDN3E5HcMRaKVPFReYCTxGmMfMZDbaDihfaAJIAamj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lY/NNEKWY1NxaALIca0thkgycBiCUAEMbP2qaP3qD5S1vqUPkceTAaB362vbiCyOEYZdC2PsADYDG1u/1hPZDmsDkRV0VtDICjONprT/kCpt/j/8SvJYpSjoeQAAAABJRU5ErkJggg=='; 8 9 private static function plugin() {10 return \SOSIDEE_DYNAMIC_QRCODE\SosPlugin::instance();11 }12 10 13 11 private static function getLogo() { -
dynamic-qr-code/trunk/src/database.php
r2779336 r3213836 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 4 5 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA as DATA;5 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA as DATA; 6 6 7 7 class Database … … 14 14 15 15 // TABLE QR-CODES 16 $tab 1= $this->native->addTable("qrcodes");17 $tab 1->addID("qrcode_id");18 $tab 1->addBoolean("disabled")->setDefaultValue(false);19 $tab 1->addVarChar("code", 255);20 $tab 1->addVarChar("description", 255);21 $tab 1->addVarChar("url_redirect", 255);22 $tab 1->addVarChar("url_inactive", 255);23 $tab 1->addVarChar("url_expired", 255);24 $fldDateFrom = $tab 1->addDateTime("date_from");16 $tabQC = $this->native->addTable("qrcodes"); 17 $tabQC->addID("qrcode_id"); 18 $tabQC->addBoolean("disabled")->setDefaultValue(false); 19 $tabQC->addVarChar("code", 255); 20 $tabQC->addVarChar("description", 255); 21 $tabQC->addVarChar("url_redirect", 255); 22 $tabQC->addVarChar("url_inactive", 255); 23 $tabQC->addVarChar("url_expired", 255); 24 $fldDateFrom = $tabQC->addDateTime("date_from"); 25 25 $fldDateFrom->nullable = true; 26 $fldDateUpto = $tab 1->addDateTime("date_to");26 $fldDateUpto = $tabQC->addDateTime("date_to"); 27 27 $fldDateUpto->nullable = true; 28 $fldTimeFrom = $tab 1->addTime("time_from");28 $fldTimeFrom = $tabQC->addTime("time_from"); 29 29 $fldTimeFrom->nullable = true; 30 $fldTimeUpto = $tab 1->addTime("time_to");30 $fldTimeUpto = $tabQC->addTime("time_to"); 31 31 $fldTimeUpto->nullable = true; 32 $tab 1->addTinyInteger("dotw");33 $tab 1->addBoolean("priority")->setDefaultValue(false);34 $tab 1->addInteger("max_scan_tot");35 $tab 1->addVarChar("url_finished", 255);36 $tab 1->addVarChar("cypher", 255);37 $tab 1->addVarChar("url_cypher", 255);38 $tab 1->addBoolean("only_mfa")->setDefaultValue(false);39 $tab 1->addTinyInteger("device_os")->setDefaultValue(0);40 $tab 1->addVarChar("device_lang", 2)->setDefaultValue('');41 $tab 1->addVarChar("img_forecolor", 16)->setDefaultValue(QRcode::IMAGE_FOREGROUND);42 $tab 1->addVarChar("img_backcolor", 16)->setDefaultValue(QRcode::IMAGE_BACKGROUND);43 $tab 1->addDateTime("creation")->setDefaultValueAsCurrentDateTime();44 $tab 1->addBoolean("cancelled")->setDefaultValue(false);32 $tabQC->addTinyInteger("dotw"); 33 $tabQC->addBoolean("priority")->setDefaultValue(false); 34 $tabQC->addInteger("max_scan_tot"); 35 $tabQC->addVarChar("url_finished", 255); 36 $tabQC->addVarChar("cypher", 255); 37 $tabQC->addVarChar("url_cypher", 255); 38 $tabQC->addBoolean("only_mfa")->setDefaultValue(false); 39 $tabQC->addTinyInteger("device_os")->setDefaultValue(0); 40 $tabQC->addVarChar("device_lang", 2)->setDefaultValue(''); 41 $tabQC->addVarChar("img_forecolor", 16)->setDefaultValue(QRcode::IMAGE_FOREGROUND); 42 $tabQC->addVarChar("img_backcolor", 16)->setDefaultValue(QRcode::IMAGE_BACKGROUND); 43 $tabQC->addDateTime("creation")->setDefaultValueAsCurrentDateTime(); 44 $tabQC->addBoolean("cancelled")->setDefaultValue(false); 45 45 46 46 // TABLE LOGS 47 $tab2 = $this->native->addTable("logs"); 48 $tab2->addID("log_id"); 49 $tab2->addTinyInteger("status"); 50 $tab2->addVarChar("code", 255); 51 $tab2->addInteger("qrcode_id"); 52 $tab2->addVarChar("user_key", 255)->setDefaultValue(''); 53 $tab2->addVarChar("event_id", 255)->setDefaultValue(''); 54 $tab2->addDateTime("creation")->setDefaultValueAsCurrentDateTime(); 55 $tab2->addBoolean("cancelled")->setDefaultValue(false); 47 $tabLog = $this->native->addTable("logs"); 48 $tabLog->addID("log_id"); 49 $tabLog->addTinyInteger("status"); 50 $tabLog->addVarChar("code", 255); 51 $tabLog->addInteger("qrcode_id"); 52 $tabLog->addVarChar("user_key", 255)->setDefaultValue(''); 53 $tabLog->addVarChar("event_id", 255)->setDefaultValue(''); 54 $tabLog->addTinyInteger("op_sys")->setDefaultValue(OS::UNKNOWN); //operative system 55 $tabLog->addTinyInteger("dev_type")->setDefaultValue(DeviceType::UNKNOWN); 56 $tabLog->addVarChar("lang", 2)->setDefaultValue(''); 57 $tabLog->addVarChar("country", 2)->setDefaultValue(''); 58 $tabLog->addVarChar("region", 255)->setDefaultValue(''); 59 $tabLog->addVarChar("city", 255)->setDefaultValue(''); 60 $tabLog->addDateTime("creation")->setDefaultValueAsCurrentDateTime(); 61 $tabLog->addBoolean("cancelled")->setDefaultValue(false); 56 62 57 63 // TABLE ONE-TIME KEYS 58 $tab 3= $this->native->addTable("otkeys");59 $tab 3->addID("otk_id");60 $tab 3->addInteger("qrcode_id");61 $tab 3->addVarChar("code", 255);62 $tab 3->addInteger("tally")->setDefaultValue(0);63 $tab 3->addDateTime("creation")->setDefaultValueAsCurrentDateTime();64 $tabOtk = $this->native->addTable("otkeys"); 65 $tabOtk->addID("otk_id"); 66 $tabOtk->addInteger("qrcode_id"); 67 $tabOtk->addVarChar("code", 255); 68 $tabOtk->addInteger("tally")->setDefaultValue(0); 69 $tabOtk->addDateTime("creation")->setDefaultValueAsCurrentDateTime(); 64 70 65 71 $this->native->create(); … … 102 108 } 103 109 104 private function loadQrCodeBy Code($field, $value ) {110 private function loadQrCodeByField($field, $value ) { 105 111 $table = $this->native->qrcodes; 106 112 107 113 $results = $table->select( [ 108 $field => $value114 $field => $value 109 115 ,'cancelled' => false 110 116 ] ); … … 121 127 $field = $table->code->name; 122 128 123 return $this->loadQrCodeBy Code( $field, $code );129 return $this->loadQrCodeByField( $field, $code ); 124 130 } 125 131 … … 128 134 $field = $table->cypher->name; 129 135 130 $results = $this->loadQrCodeBy Code( $field, $code );136 $results = $this->loadQrCodeByField( $field, $code ); 131 137 if ( is_array($results) && count($results) == 1 ) { 132 138 return $results[0]; … … 150 156 } 151 157 152 public function loadQrCodeList() { 153 $table = $this->native->qrcodes; 154 155 $filters = [ $table->cancelled->name => false ]; 158 public function loadQrCodeList( $include_cancelled = false ) { 159 $table = $this->native->qrcodes; 160 161 if ( !$include_cancelled ) { 162 $filters = [ $table->cancelled->name => false ]; 163 } else { 164 $filters = []; 165 } 156 166 $orders = ['description']; 157 167 158 return $table->distinct( ['qrcode_id', 'description'], $filters, $orders ); 168 return $table->select( $filters, $orders ); 169 } 170 171 public function loadQrKeyList() { 172 $table = $this->native->qrcodes; 173 174 $filters = [ 175 $table->cancelled->name => false 176 ]; 177 $orders = ['code']; 178 179 return $table->distinct( ['code'], $filters, $orders ); 159 180 } 160 181 … … 190 211 } 191 212 192 public function countActiveLogs ( $code) {213 public function countActiveLogsById( $qrcode_id ) { 193 214 $table = $this->native->logs; 194 215 $filters = [ 195 'code' => $code 216 'qrcode_id' => $qrcode_id 217 ,$table->cancelled->name => false 218 ]; 219 return $table->count( $filters ); 220 } 221 222 public function countActiveLogsByCode( $qrcode_code ) { 223 $table = $this->native->logs; 224 $filters = [ 225 'code' => $qrcode_code 196 226 ,$table->cancelled->name => false 197 227 ]; … … 213 243 214 244 if ( array_key_exists('status', $filters) && $filters['status'] != LogStatus::NONE ) { 215 $where[ $table->status->name ] = $filters['status']; 245 if ( !is_array($filters['status']) || count($filters['status']) > 0) { 246 $where[ $table->status->name ] = $filters['status']; 247 } 248 } 249 250 if ( array_key_exists('op_sys', $filters) && $filters['op_sys'] != OS::UNKNOWN ) { 251 if ( !is_array($filters['op_sys']) || count($filters['op_sys']) > 0) { 252 $where[ $table->op_sys->name ] = $filters['op_sys']; 253 } 254 } 255 256 if ( array_key_exists('dev_type', $filters) && $filters['dev_type'] != DeviceType::UNKNOWN ) { 257 $where[ $table->dev_type->name ] = $filters['dev_type']; 216 258 } 217 259 -
dynamic-qr-code/trunk/src/dotw.php
r2714714 r3213836 17 17 } 18 18 19 public static function getList( $caption = false) {19 public static function getList( $caption = false ) { 20 20 $ret = array(); 21 21 -
dynamic-qr-code/trunk/src/form/base.php
r2763042 r3213836 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 4 5 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP; 5 use SOSIDEE_DYNAMIC_QRCODE\SRC as SRC; 6 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOS_WP; 6 7 7 8 class Base extends \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA\Form 8 9 { 10 public static $FLD_HID; 11 9 12 private static $root = null; 10 13 private static $options = null; 11 14 12 protected $_database;15 //protected $_database; 13 16 14 17 public function __construct($name, $callback = null) { 15 18 parent::__construct( $name, $callback ); 16 17 $this->_database = $this->_plugin->database;18 19 19 } 20 20 … … 58 58 } 59 59 60 public static function get Options() {60 public static function getUrlList() { 61 61 if ( is_null(self::$options) ) { 62 self::$options = [ 63 '' => 'custom URL' 64 ,'Pages' => self::getPageList() 65 ,'Posts' => self::getPostList() 66 ]; 62 self::$options = [ '' => 'custom URL' ]; 63 if ( self::plugin()->hasFacebook() ) { 64 self::$options['Facebook '] = self::plugin()->addon->facebook::getOptions(); 65 } 66 if ( self::plugin()->hasInstagram() ) { 67 self::$options['Instagram '] = self::plugin()->addon->instagram::getOptions(); 68 } 69 if ( self::plugin()->hasLinkedIn() ) { 70 self::$options['LinkedIn '] = self::plugin()->addon->linkedin::getOptions(); 71 } 72 if ( self::plugin()->hasWhatsApp() ) { 73 self::$options['WhatsApp '] = self::plugin()->addon->whatsapp::getOptions(); 74 } 75 if ( self::plugin()->hasYouTube() ) { 76 self::$options['YouTube '] = self::plugin()->addon->youtube::getOptions(); 77 } 78 self::$options['Pages '] = self::getPageList(); 79 self::$options['Posts '] = self::getPostList(); 67 80 } 68 81 return self::$options; … … 70 83 71 84 public static function getDescription( $text, $paragraph = false ) { 72 $ret = SOS_WP\HtmlTag::get( 'span', [ 'html' => $text, 'style' => 'font-style:italic;' ] );85 $ret = SOS_WP\HtmlTag::get( 'span', [ 'html' => $text, 'style' => 'font-style:italic;' ] ); 73 86 if ( $paragraph ) { 74 $ret = SOS_WP\HtmlTag::get( 'p', [ 'html' => $ret ] );87 $ret = SOS_WP\HtmlTag::get( 'p', [ 'html' => $ret ] ); 75 88 } 76 89 return $ret; 77 90 } 78 91 79 private static $langs = null; 80 public function getLanguageList( $caption = '' ) { 81 if ( is_null(self::$langs) ) { 82 $items = $this->_plugin->loadAsset('language-codes.json'); 83 if ( is_array($items) ) { 84 for ( $n=0; $n<count($items); $n++ ) { 85 self::$langs[$items[$n]->alpha2] = $items[$n]->English; 86 } 87 } else { 88 sosidee_log('Json languages file could not be successfully loaded.'); 89 return ['' => '- sorry, cannot load language list -']; 90 } 91 } 92 if ( $caption != '' ) { 93 return ['' => $caption] + self::$langs; 94 } else { 95 return self::$langs; 96 } 92 private static function isPosted() { 93 return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) == 'POST'; 97 94 } 98 95 96 public static function checkPosted( $value ) { 97 $ret = false; 98 if ( self::isPosted() ) { 99 $config = self::plugin()->config; 100 //$config->formCheckMode->load(); 101 switch ( $config->formCheckMode->getValue() ) { 102 case CheckMode::METHOD: 103 $ret = true; 104 break; 105 case CheckMode::REFERER: 106 $ref = wp_get_raw_referer(); 107 $pid = url_to_postid($ref); 108 if ( $pid == get_the_ID() ) { 109 $ret = true; 110 } else { 111 sosidee_log("Hiding content: data posted from an invalid URL. Referer=$ref"); 112 } 113 break; 114 case CheckMode::FIELD: 115 if ( isset($_POST[self::$FLD_HID]) ) { 116 $hid = trim( $_POST[self::$FLD_HID] ); 117 if ( strcasecmp( $hid, $value ) == 0 ) { 118 $ret = true; 119 } else { 120 sosidee_log("Hiding content: hidden field value is {$hid} while {$value} was expected."); 121 } 122 } else { 123 sosidee_log("Hiding content: hidden field not found."); 124 } 125 break; 126 } 127 } else { 128 sosidee_log("Hiding content: invalid REQUEST_METHOD value."); 129 } 130 return $ret; 131 } 132 133 protected function getProMsg( $msg ) { 134 return $msg . ' ' . self::plugin()->pro(); 135 } 136 137 public static function getHiddenFieldTemplate( $id ) { 138 return SOS_WP\DATA\FormTag::get( 'input', [ 139 'type' => 'hidden' 140 ,'name' => self::$FLD_HID 141 ,'value' => $id 142 ]); 143 } 144 145 99 146 } -
dynamic-qr-code/trunk/src/form/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/src/form/logsearch.php
r2779336 r3213836 5 5 use SOSIDEE_DYNAMIC_QRCODE\SRC as SRC; 6 6 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA as DATA; 7 8 class LogSearch extends Base 7 use SOSIDEE_DYNAMIC_QRCODE\SRC\QrCode; 8 9 class LogSearch extends Log 9 10 { 11 12 private $status; 13 10 14 private $qid; 11 private $status;12 private $dtFrom;13 private $dtTo;14 15 public $logs;16 17 15 private $log_id; 18 16 17 protected $chkLang; 18 protected $chkGeo; 19 protected $chkDesc; 20 21 protected $chkOS; 22 19 23 public function __construct() { 20 parent::__construct( 'logSearch' , [$this, 'onSubmit']);24 parent::__construct( 'logSearch' ); 21 25 22 26 $this->qid = $this->addSelect('qid', '' ); … … 24 28 $this->status = $this->addSelect('status', SRC\LogStatus::NONE ); 25 29 $this->status->cached = true; 26 $this->dtFrom = $this->addDatePicker('from', 'now');27 $this->dtFrom->cached = true;28 $this->dtTo = $this->addDatePicker('up_to', 'now');29 $this->dtTo->cached = true;30 30 31 31 $this->log_id = $this->addHidden('delete_log_id', 0); 32 32 33 $this->logs = []; 33 $this->chkLang = $this->addCheckBox('show_lang'); 34 $this->chkGeo = $this->addCheckBox('show_geo'); 35 $this->chkDesc = $this->addCheckBox('show_desc'); 36 $this->chkOS = $this->addCheckBox('show_os'); 37 38 } 39 40 public function showLang() { 41 return self::plugin()->isPro && $this->chkLang->value; 42 } 43 public function showGeo() { 44 return self::plugin()->isPro && $this->chkGeo->value; 45 } 46 public function showDesc() { 47 return self::plugin()->isPro && $this->chkDesc->value; 48 } 49 public function showOS() { 50 return self::plugin()->isPro && $this->chkOS->value; 34 51 } 35 52 36 53 public function htmlQID() { 37 $options = $this->_plugin->loadQrCodeList('- any -'); 54 //$options = $this->loadQrCodeList(); 55 $options = QrCode::loadQrCodeList(); 38 56 $this->qid->html( ['options' => $options] ); 39 57 } … … 44 62 } 45 63 46 public function htmlFrom() {47 $this->dtFrom->html();48 }49 public function htmlTo() {50 $this->dtTo->html();51 }52 53 64 public function htmlLogId() { 54 65 $this->log_id->html(); 66 } 67 68 public function htmlShowLang() { 69 $this->chkLang->html( ['label' => 'Language'] ); 70 } 71 public function htmlShowGeo() { 72 $this->chkGeo->html( ['label' => 'Country'] ); 73 } 74 public function htmlShowDesc() { 75 $this->chkDesc->html( ['label' => 'Description'] ); 76 } 77 public function htmlShowOS() { 78 $this->chkOS->html( ['label' => 'Operative System'] ); 55 79 } 56 80 … … 73 97 74 98 public function htmlCancelAll() { 75 76 parent::htmlButton( 'clear', 'delete all logs', DATA\FormButton::STYLE_DANGER, null, "return self.confirm('Do you confirm to delete ALL the logs?');" ); 77 } 78 79 public function htmlDownload($logs, $code_shared, $mfa_enabled) { 80 99 parent::htmlButton( 'clear', 'delete ALL logs', DATA\FormButton::STYLE_DANGER, null, "return self.confirm('Do you confirm to delete ALL the logs present in the database?');" ); 100 } 101 102 public function htmlDownload( $logs, $mfa_enabled ) { 81 103 if ( count($logs) > 0 ) { 82 $folder = $this->_plugin->getTempFolder();104 $folder = self::plugin()->getTempFolder(); 83 105 if ($folder !== false) { 84 106 $lines = array(); 85 $headers =[ 86 'Date' 87 ,'Code' 88 ,'Status' 89 ]; 90 if ($code_shared) { 91 $headers[] = 'Qid'; 92 } 93 if ($mfa_enabled) { 107 $headers = $this->getCsvHeader( $logs[0] ); 108 if ( $mfa_enabled ) { 94 109 $headers[] = 'My FastAPP User Key'; 95 110 } 96 111 $lines[] = $headers; 97 for ( $n=0; $n<count($logs); $n++) {112 for ( $n=0; $n<count($logs); $n++ ) { 98 113 $log = $logs[$n]; 99 114 $row = [ 100 115 $log->creation_string 116 ,SRC\LogStatus::getDescription( $log->status ) 101 117 ,$log->code 102 , SRC\LogStatus::getDescription( $log->status)118 ,QrCode::getQID( $log->qrcode_id ) 103 119 ]; 104 if ($code_shared) { 105 $row[] = $log->qrcode_id; 106 } 107 if ($mfa_enabled) { 120 if ( isset($log->lang_desc) ) { 121 $row[] = $log->lang_desc; 122 } 123 if ( isset($log->country_desc) ) { 124 $row[] = $log->country_desc; 125 } 126 if ( isset($log->qrcode_desc) ) { 127 $row[] = $log->qrcode_desc; 128 } 129 if ( isset($log->os_desc) ) { 130 $row[] = $log->os_desc; 131 } 132 if ( $mfa_enabled ) { 108 133 $row[] = $log->user_key; 109 134 } … … 111 136 } 112 137 $file = 'log_' . uniqid() . '.csv'; 113 $path = $folder[' basedir'] . "/{$file}";138 $path = $folder['path'] . "/{$file}"; 114 139 if ( $this->saveCSV($path, $lines) ) { 115 $url = $folder[' baseurl'] . "/{$file}";140 $url = $folder['url'] . "/{$file}"; 116 141 $onclick = "javascript:window.open('{$url}', 'sosidee', 'popup=1');"; 117 142 } else { … … 120 145 121 146 } else { 122 $onclick = "alert('" . htmlentities( addslashes( 'A problem occurred.'), ENT_NOQUOTES ) . "')";147 $onclick = "alert('" . htmlentities( addslashes("A problem occurred."), ENT_NOQUOTES ) . "')"; 123 148 } 124 149 … … 135 160 } 136 161 137 /*138 private function loadQrCodeList() {139 $ret = [ 0 => '- any -' ];140 141 $results = $this->_database->loadQrCodeList();142 143 if ( is_array($results) ) {144 if ( count($results) > 0 ) {145 for ( $n=0; $n<count($results); $n++ ) {146 $ret[ $results[$n]->qrcode_id ] = $results[$n]->description;147 }148 }149 } else {150 self::msgErr( 'A problem occurred while reading the qr code list from the database.' );151 }152 return $ret;153 }154 */155 156 protected function initialize() {157 if ( !$this->_posted ) {158 if ( $this->_cache_timestamp instanceof \DateTime ) {159 $now = sosidee_current_datetime();160 if ( $this->_cache_timestamp->format('Ymd') != $now->format('Ymd') ) {161 $this->dtFrom->value = $now->format('Y-m-d');162 $this->dtTo->value = $now->format('Y-m-d');163 }164 }165 }166 }167 168 162 public function onSubmit() { 169 163 … … 175 169 176 170 if ( $id > 0 ) { 177 $result = $this->_database->deleteLog( $id );171 $result = self::database()->deleteLog( $id ); 178 172 if ( $result !== false ) { 179 self::msgOk( 'Log data have been deleted.');173 self::msgOk( "Log data have been deleted." ); 180 174 $this->loadLogs(); 181 175 } else { 182 self::msgErr( 'A problem occurred.');176 self::msgErr( "A problem occurred." ); 183 177 } 184 178 } else { … … 186 180 } 187 181 188 189 182 } else if ( $this->_action == 'clear' ) { 190 183 191 $result = $this->_database->clearLog();184 $result = self::database()->clearLog(); 192 185 if ( $result !== false ) { 193 self::msgOk( 'All logs have been deleted.');186 self::msgOk( "All logs have been deleted." ); 194 187 $this->loadLogs(); 195 188 } else { 196 self::msgErr( 'A problem occurred.');189 self::msgErr( "A problem occurred." ); 197 190 } 198 191 … … 201 194 202 195 public function loadLogs() { 203 $this->logs = [];204 205 $qid = intval( $this->qid->value );206 196 207 197 $filters = [ 208 'qrcode_id' => $qid198 'qrcode_id' => intval( $this->qid->value ) 209 199 ,'status' => $this->status->value 210 ,'from' => $this->dtFrom->getValueAsDate()211 ,'to' => $this->dtTo->getValueAsDate( true )212 200 ]; 213 201 214 $orders = [ 'creation' => 'DESC' ]; 215 216 $results = $this->_database->loadLogs( $filters, $orders ); 217 218 if ( is_array($results) ) { 219 if ( count($results) > 0 ) { 220 for ( $n=0; $n<count($results); $n++ ) { 221 $results[$n]->creation_string = sosidee_datetime_format( $results[$n]->creation ); 222 $results[$n]->status_icon = SRC\LogStatus::getStatusIcon( $results[$n]->status ); 223 } 224 if ( $this->_posted ) { 225 $this->saveCache(); 226 } 227 } else { 228 if ( $this->_posted ) { 229 self::msgInfo( 'No results match the search.' ); 230 } else { 231 self::msgInfo( "There's no data in the database." ); 232 } 233 } 234 $this->logs = $results; 235 } else { 236 self::msgErr( 'A problem occurred.' ); 237 } 238 } 239 240 241 242 public function saveCSV($path, $lines, $parameters = array()) { 243 $ret = false; 244 245 $delimiter = ','; 246 $enclosure = '"'; 247 $escape = "\\"; 248 $out_charset = 'Windows-1252'; 249 $in_charset = 'UTF-8'; 250 251 extract($parameters, EXTR_IF_EXISTS); 252 253 if ( ($handle = fopen($path, "w")) !== false ) { 254 $ret = true; 255 for ($i=0; $i<count($lines); $i++) { 256 $data = $lines[$i]; 257 for ($j=0; $j<count($data); $j++) { 258 $data[$j] = iconv( $in_charset, "$out_charset//TRANSLIT", $data[$j] ); 259 } 260 $ret = (fputcsv($handle, $data, $delimiter, $enclosure, $escape) !== false) && $ret; 261 } 262 fclose($handle); 263 } 264 265 return $ret; 266 } 267 202 parent::load( $filters ); 203 204 for ( $n=0; $n<count($this->logs); $n++ ) { 205 $this->logs[$n]->creation_string = sosidee_datetime_format( $this->logs[$n]->creation ); 206 $this->logs[$n]->status_icon = SRC\LogStatus::getStatusIcon( $this->logs[$n]->status ); 207 } 208 209 if ( count($this->logs)>0 ) { 210 if ( !self::plugin()->isPro ) { 211 $features = []; 212 if ( $this->chkGeo->value ) { 213 $features[] = 'Country'; 214 } 215 if ( $this->chkLang->value ) { 216 $features[] = 'Language'; 217 } 218 if ( $this->chkDesc->value ) { 219 $features[] = 'QR-Code Description'; 220 } 221 if ( $this->chkOS->value ) { 222 $features[] = 'Operative System'; 223 } 224 $count = count($features); 225 if ( $count > 0 ) { 226 $list = $features[0]; 227 if ( $count > 1 ) { 228 $allButLast = array_slice($features, 0, -1); 229 $list = implode(', ', $allButLast) . ' and ' . $features[$count - 1]; 230 } 231 $msg = $this->getProMsg($list . ' logs are available on'); 232 self::msgWarn($msg); 233 } 234 } 235 } 236 237 } 268 238 269 239 } -
dynamic-qr-code/trunk/src/form/qrcodeedit.php
r2815343 r3213836 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 4 5 use \SOSIDEE_DYNAMIC_QRCODE\SRC as SRC; 6 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA as DATA; 5 use SOSIDEE_DYNAMIC_QRCODE\SRC as SRC; 6 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP\DATA as DATA; 7 use SOSIDEE_DYNAMIC_QRCODE\SOS\Locale; 7 8 8 9 class QrCodeEdit extends Base … … 31 32 private $img_backcolor; 32 33 34 private $code_old; 33 35 public $code; 34 36 … … 56 58 $this->max_scan_tot = $this->addNumericBox('max_scan_tot'); 57 59 $this->url_finished = $this->addComboBox('url_finished', ''); 58 $description = self::getDescription( "mandatory field", true);60 $description = self::getDescription('mandatory field', true); 59 61 $this->description->description = $description; 60 62 $this->code->description = $description; … … 63 65 $this->url_cypher = $this->addComboBox('url_cypher', ''); 64 66 $this->only_mfa = $this->addCheckBox('only_mfa', false); 65 $this->device_os = $this->addSelect('device_os', SRC\OS:: NONE);67 $this->device_os = $this->addSelect('device_os', SRC\OS::UNKNOWN); 66 68 $this->device_lang = $this->addSelect('device_lang', ''); 67 69 68 $this->img_forecolor = $this->addColorPicker('img_forecolor', $this->_plugin->config->imgForeColor->getValue() ); 69 $this->img_backcolor = $this->addColorPicker('img_backcolor', $this->_plugin->config->imgBackColor->getValue() ); 70 $this->img_forecolor = $this->addColorPicker('img_forecolor', self::plugin()->config->imgForeColor->getValue() ); 71 $this->img_backcolor = $this->addColorPicker('img_backcolor', self::plugin()->config->imgBackColor->getValue() ); 72 73 $this->code_old = $this->addHidden('code_old', ''); 70 74 71 75 $this->showCypher = false; … … 92 96 $this->url_cypher->value = ''; 93 97 $this->only_mfa->value = false; 94 $this->device_os->value = SRC\OS:: NONE;98 $this->device_os->value = SRC\OS::UNKNOWN; 95 99 $this->device_lang->value = ''; 96 $this->img_forecolor->value = $this->_plugin->config->imgForeColor->value;97 $this->img_backcolor->value = $this->_plugin->config->imgBackColor->value;100 $this->img_forecolor->value = self::plugin()->config->imgForeColor->value; 101 $this->img_backcolor->value = self::plugin()->config->imgBackColor->value; 98 102 99 103 $this->showCypher = false; … … 109 113 $this->code->html( ['maxlength' => 255] ); 110 114 } 115 public function htmlCodeOld() { 116 $this->code_old->value = $this->code->value; 117 $this->code_old->html(); 118 } 111 119 public function htmlDescription() { 112 120 $this->description->html( ['maxlength' => 255] ); 113 121 } 114 122 public function htmlUrlRedirect() { 115 $options = Base::getOptions();123 $options = self::getUrlList(); 116 124 $this->url_redirect->html( [ 'options' => $options ] ); 117 125 } 118 126 public function htmlUrlInactive() { 119 $options = Base::getOptions();127 $options = self::getUrlList(); 120 128 $this->url_inactive->html( [ 'options' => $options ] ); 121 129 } 122 130 public function htmlUrlExpired() { 123 $options = Base::getOptions();131 $options = self::getUrlList(); 124 132 $this->url_expired->html( [ 'options' => $options ] ); 125 133 } … … 153 161 } 154 162 public function htmlUrlFinished() { 155 $options = Base::getOptions();163 $options = $this->getUrlList(); 156 164 $this->url_finished->html( [ 'options' => $options ] ); 157 165 } 158 166 public function htmlCurrentScan() { 159 167 if ( $this->id->value > 0 && $this->code->value != '' ) { 160 $current = $this->_database->countActiveLogs( $this->code->value );168 $current = self::database()->countActiveLogs( $this->code->value ); 161 169 if ( $current !== false ) { 162 170 DATA\FormTag::html( 'span', [ … … 173 181 } 174 182 public function htmlDeviceLang() { 175 $options = $this->getlanguageList('- any -');183 $options = Locale::getLanguages('- any -'); 176 184 $this->device_lang->html( [ 'options' => $options ] ); 177 185 } … … 188 196 public function htmlUrlCypher() { 189 197 if ( $this->cypher->value != '' ) { 190 $options = Base::getOptions();198 $options = $this->getUrlList(); 191 199 $this->url_cypher->html( [ 'options' => $options ] ); 192 200 } else { 193 201 DATA\FormTag::html( 'label', [ 194 'html' => ' - - - '202 'html' => ' - - - ' 195 203 ,'style' => 'padding:2px 4px 2px 4px;margin-left:1em;' 196 204 ]); … … 202 210 if ( $id > 0 ) { 203 211 DATA\FormTag::html( 'span', [ 204 'content' => "Q-{$id}"212 'content' => "Q-{$id}" 205 213 ,'style' => 'cursor:text;background-color:white;padding:2px 4px 2px 4px;' 206 214 ]); … … 211 219 $id = $this->id->value; 212 220 $code = !$cypher ? $this->code->value : base64_encode($this->cypher->value); 213 $content = $code != '' ? $this->_plugin->getApiUrl( $code, $cypher ) : ' - - - ';221 $content = $code != '' ? self::plugin()->getApiUrl( $code, $cypher ) : ' - - - '; 214 222 if ( $code != '' && $cypher ) { 215 223 $content = substr($content, 0, 80) . " ..."; 216 224 } 217 echo $this->_plugin->getCopyApiUrl2CBIcon( $id, $code, $cypher );225 echo SRC\Copy2CB::getApiUrlIcon( $id, $code, $cypher ); 218 226 echo ' '; 219 227 DATA\FormTag::html( 'label', [ … … 226 234 $id = $this->id->value; 227 235 if ( $id > 0 ) { 228 $text = $this->_plugin->getShortcode1Template( $id );229 echo $this->_plugin->getCopyShortcode2CBIcon( $id, 1 );236 $text = SRC\Shortcode::getTemplate1( $id ); 237 echo SRC\Copy2CB::getShortcodeIcon( $id, 1 ); 230 238 echo ' '; 231 239 DATA\FormTag::html( 'label', [ 232 'content' => $text240 'content' => $text 233 241 ,'style' => 'cursor:text;background-color:white;padding:2px 4px 2px 4px;' 234 242 ]); … … 240 248 if ( $id > 0 ) { 241 249 $standard = $this->cypher->value == ''; 242 $text = $this->_plugin->getShortcode2Template( $id, $standard );243 echo $this->_plugin->getCopyShortcode2CBIcon( $id, 2, $standard );250 $text = SRC\Shortcode::getTemplate2( $id, $standard ); 251 echo SRC\Copy2CB::getShortcodeIcon( $id, 2, $standard ); 244 252 echo ' '; 245 253 DATA\FormTag::html( 'label', [ 246 'content' => $text254 'content' => $text 247 255 ,'style' => 'cursor:text;background-color:white;padding:2px 4px 2px 4px;' 248 256 ]); … … 254 262 if ( $id > 0 ) { 255 263 if ( $anyQrHideEnabled || $this->cypher->value != '' ) { 256 echo $this->_plugin->getCopyHiddenField2CBIcon( $id );257 $text = $this->_plugin->getHiddenFieldTemplate( $id );264 echo SRC\Copy2CB::getHiddenFieldIcon( $id ); 265 $text = SRC\FORM\Base::getHiddenFieldTemplate( $id ); 258 266 } else { 259 echo $this->_plugin->getCopyHiddenField2CBIcon( -1 );267 echo SRC\Copy2CB::getHiddenFieldIcon( -1 ); 260 268 $text = ' - - - '; 261 269 } 262 270 echo ' '; 263 271 DATA\FormTag::html( 'label', [ 264 'content' => $text272 'content' => $text 265 273 ,'style' => 'cursor:text;background-color:white;padding:2px 4px 2px 4px;' 266 274 ]); … … 276 284 277 285 if ( $code != '' ) { 278 $url = $this->_plugin->getApiUrl( $code, $cypher );279 280 $size = $this->_plugin->config->imgSize->getValue();281 $pad = $this->_plugin->config->imgPad->getValue();286 $url = self::plugin()->getApiUrl( $code, $cypher ); 287 288 $size = self::plugin()->config->imgSize->getValue(); 289 $pad = self::plugin()->config->imgPad->getValue(); 282 290 283 291 $fore_color = SRC\QrCode::getColor( $this->img_forecolor->value ); … … 289 297 290 298 $img = DATA\FormTag::get( 'img', [ 291 'src' => $img_url299 'src' => $img_url 292 300 ,'alt' => 'click to download' 293 301 ,'style' => 'margin: 2px;' … … 297 305 echo '<div style="flex-basis: 100%; text-align: center; font-style: italic;">click the image to download it</div>'; 298 306 DATA\FormTag::html( 'a', [ 299 'href' => $img_url307 'href' => $img_url 300 308 ,'title' => 'click to download' 301 309 ,'download' => uniqid() … … 336 344 } 337 345 346 public function htmlDuplicate() { 347 $this->htmlButton( 'duplicate', 'save as new', 'color: #ffffff; background-color: #bf00ff; border-color: #a200d9;' ); 348 if ( !self::plugin()->hasDuplicate() ) { 349 echo ' ' . self::plugin()->pro('color: #bf00ff;', 'PRO version required'); 350 } 351 } 338 352 339 353 public function loadQrCode( $id ) { 340 354 if ( $id > 0 ) { 341 $qrcode= $this->_database->loadQrCode( $id );355 $qrcode= self::database()->loadQrCode( $id ); 342 356 if ( $qrcode !== false ) { 343 357 … … 374 388 375 389 public function htmlButtonLink( $id ) { 376 $url = $this->_plugin->pageQrCode->getUrl( [self::QS_ID => $id] );390 $url = self::plugin()->pageQrCode->getUrl( [self::QS_ID => $id] ); 377 391 if ( $id == 0 ) { 378 392 parent::htmlLinkButton( $url, 'create new' ); … … 394 408 public function onSubmit() { 395 409 396 if ( in_array($this->_action, [ 'save', 'generate_cypher', 'cancel_cypher', 'save_cypher' ]) ) {410 if ( in_array($this->_action, [ 'save', 'generate_cypher', 'cancel_cypher', 'save_cypher', 'duplicate' ]) ) { 397 411 $save = true; 398 412 … … 405 419 $this->code->value = trim( $this->code->value ); 406 420 if ( $this->code->value != '' ) { 407 $this->_plugin->config->load();408 if ( ! $this->_plugin->config->sharedCodeEnabled->value ) {421 self::plugin()->config->load(); 422 if ( !self::plugin()->config->sharedCodeEnabled->value ) { 409 423 $code = $this->code->value; 410 424 $id = intval($this->id->value); 411 $items = $this->_database->loadQrCodeByKey( $code );425 $items = self::database()->loadQrCodeByKey( $code ); 412 426 if ( is_array($items) ) { 413 427 for ($n=0; $n<count($items); $n++) { 414 428 if ($items[$n]->code == $code && $items[$n]->qrcode_id != $id) { 415 429 $save = false; 416 self::msgErr( "Code is already in use by another QR-Code, whereas it must be unique: you can disable this restriction <a href=\"{$this->_plugin->pageConfig->url}\">here</a>." ); 430 $url = self::plugin()->pageConfig->url; 431 self::msgErr( "Code is already in use by another QR-Code, whereas it must be unique: you can disable this restriction <a href=\"{$url}\">here</a>." ); 417 432 break; 418 433 } … … 431 446 $this->url_redirect->value = trim( $this->url_redirect->value ); 432 447 if ( $this->url_redirect->value == '' ) { 433 $save = false;434 self::msg Err( 'Redirect URL is empty.');448 //$save = false; 449 self::msgWarn( "Redirect URL is empty: the qr code won't work!" ); 435 450 } 436 451 … … 446 461 } 447 462 448 if ( $this->img_forecolor->value == $this->img_backcolor->value) {463 if ( $this->img_forecolor->value == $this->img_backcolor->value ) { 449 464 $save = false; 450 465 self::msgErr( 'Foreground and background colors cannot be equal.' ); 466 } 467 468 if ( $this->_action == 'duplicate' ) { 469 if ( !self::plugin()->hasDuplicate() ) { 470 $save = false; 471 $msg = $this->getProMsg('Duplication is available only in the PRO version'); 472 self::msgWarn($msg); 473 } 451 474 } 452 475 … … 461 484 } else if ( $this->_action == 'save_cypher' ) { 462 485 $this->showCypher = true; 486 } else if ( $this->_action == 'duplicate' ) { 487 if ( self::plugin()->hasDuplicate() ) { 488 $this->id->value = self::plugin()->addon::getQRCodeDuplicateId(); 489 } 463 490 } 464 491 465 if ( $this->_plugin->config->mfaEnabled->value == false ) {492 if ( self::plugin()->config->mfaEnabled->value == false ) { 466 493 $this->only_mfa->value = false; 467 494 } … … 491 518 ]; 492 519 493 $result = $this->_database->saveQrCode( $data, $this->id->value );520 $result = self::database()->saveQrCode( $data, $this->id->value ); 494 521 495 522 if ( $result !== false ) { 496 523 if ( $result === true ) { 497 524 self::msgOk( 'Data have been saved.' ); 525 if ($this->code_old->value != '' && $this->code_old->value != $this->code->value) { 526 self::msgWarn( "Image(s) changed because the qr code Key has been modified." ); 527 } 498 528 $this->loadQrCode( $this->id->value ); 499 529 } else { … … 517 547 518 548 if ( $id > 0 ) { 519 $result = $this->_database->deleteQrCode( $id );549 $result = self::database()->deleteQrCode( $id ); 520 550 if ( $result !== false ) { 521 551 $this->reset(); -
dynamic-qr-code/trunk/src/form/qrcodesearch.php
r2779336 r3213836 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 4 5 use \SOSIDEE_DYNAMIC_QRCODE\SRC as SRC;5 use SOSIDEE_DYNAMIC_QRCODE\SRC as SRC; 6 6 7 7 class QrCodeSearch extends Base … … 25 25 26 26 public function htmlButtonLink( $id = 0 ) { 27 $this->_plugin->formEditQrCode->htmlButtonLink( $id );27 self::plugin()->formEditQrCode->htmlButtonLink( $id ); 28 28 } 29 29 … … 46 46 ]; 47 47 48 $results = $this->_database->loadQrCodes( $filters );48 $results = self::database()->loadQrCodes( $filters ); 49 49 50 50 if ( is_array($results) ) { … … 52 52 for ( $n=0; $n<count($results); $n++ ) { 53 53 $results[$n]->creation_string = $results[$n]->creation->format( "Y/m/d H:i:s" ); 54 $results[$n]->url_api = $this->_plugin->getApiUrl( $results[$n]->code );54 $results[$n]->url_api = self::plugin()->getApiUrl( $results[$n]->code ); 55 55 $results[$n]->status_icon = SRC\QrCodeSearchStatus::getStatusIcon( !$results[$n]->disabled ); 56 56 } 57 57 } else { 58 if ( $this->status->value >0 ) {58 if ( $this->status->value != 0 ) { 59 59 self::msgInfo( 'No results match the search.' ); 60 60 } else { -
dynamic-qr-code/trunk/src/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/src/lib/index.html
r2684394 r3213836 1 <!DOCTYPE html><html ><head><title>no way</title></head><body>you weren't supposed to be here</body></html>1 <!DOCTYPE html><html lang="en"><head><title>no way</title></head><body>you weren't supposed to be here</body></html> -
dynamic-qr-code/trunk/src/lib/phpqrcode.php
r2997240 r3213836 1004 1004 $imgH = $h + 2*$outerFrame; 1005 1005 1006 $base_image = ImageCreate($imgW, $imgH);1006 $base_image = \ImageCreate($imgW, $imgH); 1007 1007 1008 1008 // convert a hexadecimal color code into decimal format (red = 255 0 0, green = 0 255 0, blue = 0 0 255) … … 1340 1340 } 1341 1341 } 1342 } ;1342 } 1343 1343 1344 1344 //########################################################################## … … 2907 2907 $this->ecc = $ecc; 2908 2908 } 2909 } ;2909 } 2910 2910 2911 2911 //########################################################################## … … 3000 3000 if($this->count < $this->dataLength) { 3001 3001 $row = $this->count % $this->blocks; 3002 $col = $this->count / $this->blocks; 3002 //$col = $this->count / $this->blocks; //sostituzione per evitare il messaggio PHP Deprecated: Implicit conversion from float to int loses precision 3003 $col = intval($this->count / $this->blocks); 3003 3004 if($col >= $this->rsblocks[0]->dataLength) { 3004 3005 $row += $this->b1; … … 3007 3008 } else if($this->count < $this->dataLength + $this->eccLength) { 3008 3009 $row = ($this->count - $this->dataLength) % $this->blocks; 3009 $col = ($this->count - $this->dataLength) / $this->blocks; 3010 //$col = ($this->count - $this->dataLength) / $this->blocks; //sostituzione per evitare il messaggio PHP Deprecated: Implicit conversion from float to int loses precision 3011 $col = intval(($this->count - $this->dataLength) / $this->blocks); 3010 3012 $ret = $this->rsblocks[$row]->ecc[$col]; 3011 3013 } else { … … 3270 3272 } 3271 3273 3272 } ;3274 } 3273 3275 3274 3276 //########################################################################## 3275 3277 3278 #[\AllowDynamicProperties] 3276 3279 class QRencode { 3277 3280 -
dynamic-qr-code/trunk/src/logstatus.php
r2763042 r3213836 21 21 $ret[self::ACTIVE] = self::getDescription(self::ACTIVE); 22 22 $ret[self::INACTIVE] = self::getDescription(self::INACTIVE); 23 $ret[self::DISABLED] = self::getDescription(self::DISABLED);24 23 $ret[self::EXPIRED] = self::getDescription(self::EXPIRED); 25 24 $ret[self::FINISHED] = self::getDescription(self::FINISHED); 25 $ret[self::DISABLED] = self::getDescription(self::DISABLED); 26 26 $ret[self::ERROR] = self::getDescription(self::ERROR); 27 27 … … 30 30 31 31 32 public static function getDescription( $value ) {33 $ret = '';32 public static function getDescription( $value, $default = '' ) { 33 $ret = $default; 34 34 switch ($value) { 35 35 case self::ACTIVE: -
dynamic-qr-code/trunk/src/os.php
r2763042 r3213836 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 4 5 use SOSIDEE_DYNAMIC_QRCODE\SOS\Mobile; 6 5 7 class OS 6 8 { 7 const NONE = 0; 9 10 const UNKNOWN = 0; 8 11 const ANDROID = 1; 9 12 const IOS = 2; 10 13 const OTHER = 3; 11 14 15 12 16 public static function isValid( $value ) { 13 if ( $value != self:: NONE) {17 if ( $value != self::UNKNOWN) { 14 18 if ( Mobile::android() ) { 15 19 return $value == self::ANDROID; … … 24 28 } 25 29 26 public static function getList( $caption = false) {30 public static function getList( $caption = false ) { 27 31 $ret = array(); 28 32 29 33 if ($caption !== false) { 30 $ret[self:: NONE] = $caption;34 $ret[self::UNKNOWN] = $caption; 31 35 } 32 36 $ret[self::ANDROID] = self::getDescription(self::ANDROID); … … 38 42 39 43 public static function getDescription( $value ) { 40 $ret = ' ';44 $ret = 'unknown'; 41 45 switch ($value) { 42 46 case self::ANDROID: -
dynamic-qr-code/trunk/src/otkey.php
r2753631 r3213836 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 4 5 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOSWP;5 use SOSIDEE_DYNAMIC_QRCODE\SOS\WP as SOSWP; 6 6 7 7 class OTKey 8 8 { 9 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\TBase; 9 10 10 11 const COOKIENAME = 'sos_dynqrcode_ot_key'; … … 23 24 24 25 public static function deleteCookie() { 25 returnSOSWP\Cookie::del( self::COOKIENAME );26 SOSWP\Cookie::del( self::COOKIENAME ); 26 27 } 27 28 29 public static function setJsCookieEraser() { 30 $cookie = self::COOKIENAME; 31 $js = "document.cookie = '{$cookie} =; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';"; 32 self::plugin()->addDeleteCookieScript( $js ); 33 } 28 34 29 35 } -
dynamic-qr-code/trunk/src/qrcode.php
r2779336 r3213836 3 3 defined( 'SOSIDEE_DYNAMIC_QRCODE' ) or die( 'you were not supposed to be here' ); 4 4 5 use SOSIDEE_DYNAMIC_QRCODE\S osPlugin;5 use SOSIDEE_DYNAMIC_QRCODE\SOS\Http\Request; 6 6 7 7 class QrCode 8 8 { 9 10 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\TBase; 11 use \SOSIDEE_DYNAMIC_QRCODE\SOS\WP\TMessage; 9 12 10 13 const CYPHER_LENGTH = 66; … … 15 18 const IMAGE_BACKGROUND = '#ffffff'; 16 19 17 private static function getDateTime($date, $time) { 20 const DATETIME_MODE_FROM = 1; 21 const DATETIME_MODE_TO = 2; 22 23 private static function getDateTime($date, $time, $mode) { 18 24 if ( is_null($date) && is_null($time)) { 19 25 return null; 20 26 } else { 21 27 if ( is_null($date) ) { 22 $date = sosidee_ server_datetime();28 $date = sosidee_current_datetime(); 23 29 } 24 30 if ( !is_null($time) ) { 25 31 $date = $date->setTime( $time->format('G'), intval($time->format('i')), intval($time->format('s')) ); 26 32 } else { 27 $date = $date->setTime( 0, 0, 0 ); 33 if ( $mode == self::DATETIME_MODE_FROM ) { 34 $date = $date->setTime( 0, 0, 0 ); 35 } else if ( $mode == self::DATETIME_MODE_TO ) { 36 $date = $date->setTime( 23, 59, 59 ); 37 } 28 38 } 29 39 return $date; … … 32 42 33 43 public static function getStatus( $item ) { 44 if ( $item->disabled ) { 45 return QrCodeStatus::DISABLED; 46 } 47 48 if ( $item->device_os != OS::UNKNOWN ) { 49 if ( !OS::isValid( $item->device_os ) ) { 50 return QrCodeStatus::DISABLED; 51 } 52 } 53 54 if ( !DotW::isValid($item->dotw) ) { 55 return QrCodeStatus::DISABLED; 56 } 57 58 $datetime_from = self::getDateTime( $item->date_from, $item->time_from, self::DATETIME_MODE_FROM); 59 $datetime_to = self::getDateTime( $item->date_to, $item->time_to, self::DATETIME_MODE_TO); 60 if ( !is_null($datetime_from) || !is_null($datetime_to) ) { 61 $now = sosidee_current_datetime(); 62 if ( !is_null($datetime_from) && $datetime_from > $now ) { 63 return QrCodeStatus::INACTIVE; 64 } else if ( !is_null($datetime_to) && $datetime_to < $now ) { 65 return QrCodeStatus::EXPIRED; 66 } 67 } 68 69 if ( $item->device_lang != '' ) { 70 $languages = Request::getLanguages(); 71 if ( is_array($languages) ) { 72 $found = false; 73 foreach ($languages as $lang) { 74 if ( $item->device_lang == $lang ) { 75 $found = true; 76 break; 77 } 78 } 79 if ( !$found ) { 80 return QrCodeStatus::DISABLED; 81 } 82 } else { 83 if ( !$item->browser ) { 84 return QrCodeStatus::DISABLED; 85 } 86 } 87 } 88 89 if ( $item->max_scan_tot > 0 ) { 90 self::plugin()->config->sharedCodeEnabled->load(); 91 $by_key = self::plugin()->config->sharedCodeEnabled->value; 92 if ( $by_key ) { 93 $current = self::database()->countActiveLogsByCode( $item->code ); 94 } else { 95 $current = self::database()->countActiveLogsById( $item->qrcode_id ); 96 } 97 if ( $current !== false ) { 98 if ( $current > $item->max_scan_tot ) { 99 return QrCodeStatus::FINISHED; 100 } 101 } else { 102 if ( $by_key ) { 103 sosidee_log("database.countActiveLogsByCode({$item->code}) returned false."); 104 } else { 105 sosidee_log("database.countActiveLogsById({$item->qrcode_id}) returned false."); 106 } 107 } 108 } 109 110 return QrCodeStatus::ACTIVE; 111 112 /* 34 113 $ret = QrCodeStatus::NONE; 35 114 36 115 if ( !$item->disabled ) { 37 if ( OS::isValid( $item->device_os ) ) {116 if ( OS::isValid( $item->device_os ) ) { 38 117 39 118 $datetime_from = self::getDateTime( $item->date_from, $item->time_from ); … … 60 139 61 140 if ( $ret == QrCodeStatus::ACTIVE && $item->max_scan_tot > 0 ) { 62 $plugin = SosPlugin::instance(); 63 $current = $plugin->database->countActiveLogs( $item->code ); 141 //$plugin = SosPlugin::instance(); 142 //$current = $plugin->database->countActiveLogs( $item->code ); 143 //$current = self::plugin()->database->countActiveLogs( $item->code ); 144 $current = self::plugin()->database->countActiveLogs( $item->qrcode_id ); 64 145 if ( $current !== false ) { 65 146 if ( $current > $item->max_scan_tot ) { … … 72 153 73 154 if ( $ret == QrCodeStatus::ACTIVE && $item->device_lang != '' ) { 74 $languages = Mobile::getLanguages(); 155 $languages = Request::getLanguages(); 156 //$languages = Mobile::getLanguages(); 75 157 if ( is_array($languages) ) { 76 158 $found = false; … … 94 176 } 95 177 return $ret; 178 */ 96 179 } 97 180 … … 134 217 private static function initializeLibrary() { 135 218 if ( !self::$initialized ) { 136 $plugin = SosPlugin::instance(); 137 $folder = $plugin->getTempFolder(); 138 self::$rootFolder = $folder['basedir']; 139 self::$rootUrl = $folder['baseurl']; 140 require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "phpqrcode.php" ); 141 self::$initialized = true; 219 $folder = self::plugin()->getTempFolder(); 220 self::$rootFolder = $folder['path']; 221 self::$rootUrl = $folder['url']; 222 require_once realpath(__DIR__ . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "phpqrcode.php" ); 223 self::$initialized = true; 142 224 } 143 225 } … … 146 228 self::initializeLibrary(); 147 229 $filename = "{$name}.png"; 148 $filepath = self::$rootFolder . DIRECTORY_SEPARATOR .$filename;230 $filepath = self::$rootFolder . $filename; 149 231 150 232 //$text = 'https://redirect.soslink.net/dynamic-qr-code/demo'; // only for the demo … … 158 240 } 159 241 160 return self::$rootUrl . "/" .$filename;242 return self::$rootUrl . $filename; 161 243 } 162 244 … … 204 286 205 287 public static function getNewCypher() { 206 $plugin = SosPlugin::instance(); 207 $length = $plugin->config->cypherLength->getValue(); 288 $length = self::plugin()->config->cypherLength->getValue(); 208 289 return bin2hex( random_bytes($length) ); 209 290 } … … 216 297 } 217 298 299 public static function loadQrCodeList( $caption = false, $include_cancelled = false ) { 300 $ret = []; 301 if ( $caption !== false ) { 302 $ret[0] = $caption; 303 } 304 305 $results = self::database()->loadQrCodeList( $include_cancelled ); 306 307 if ( is_array($results) ) { 308 if ( count($results) > 0 ) { 309 for ( $n=0; $n<count($results); $n++ ) { 310 $ret[ $results[$n]->qrcode_id ] = $results[$n]->description; 311 } 312 } 313 } else { 314 self::msgErr( 'A problem occurred while reading the qr code list from the database.' ); 315 } 316 return $ret; 317 } 318 218 319 } -
dynamic-qr-code/trunk/src/shortcode.php
r2779336 r3213836 84 84 } 85 85 86 public static function getTemplate1( $id ) { 87 $ret = '[' . self::TAG . ' ' . self::AUTH . "={$id}]"; 88 $ret .= 'content displayed to QR code scanners'; 89 $ret .= '[/' . self::TAG . ']'; 90 return $ret; 91 } 92 93 public static function getTemplate2( $id, $standard ) { 94 $ret = '[' . self::TAG . ' ' . self::DISPLAY . "={$id}"; 95 if ( $standard ) { 96 $ret .= ' ' . self::IMAGE . '="standard"'; 97 } 98 $ret .= ']'; 99 return $ret; 100 } 101 102 86 103 } -
dynamic-qr-code/trunk/upgradenotice.txt
r2815343 r3213836 1 This is a major upgrade. Please back up your site before proceeding with the update.
Note: See TracChangeset
for help on using the changeset viewer.