diff --git a/module/common/model.php b/module/common/model.php index 0ecce502d4..3be1666700 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -144,8 +144,7 @@ class commonModel extends model if(stripos($method, 'downnotify') !== false) return true; } - if($module == 'misc' and $method == 'showqrcode') return true; - if($module == 'misc' and $method == 'deleteqrcode') return true; + if($module == 'misc' and $method == 'qrcode') return true; if($module == 'misc' and $method == 'about') return true; if($module == 'misc' and $method == 'checkupdate') return true; return false; @@ -514,7 +513,7 @@ class commonModel extends model public static function printQRCodeLink($color = '') { global $lang; - if(extension_loaded('gd')) echo html::a(helper::createLink('misc', 'showQRCode'), $lang->user->mobileLogin, '', "class='qrCode $color'"); + if(extension_loaded('gd')) echo html::a(helper::createLink('misc', 'qrCode'), $lang->user->mobileLogin, '', "class='qrCode $color'"); } /** diff --git a/module/misc/control.php b/module/misc/control.php index 5059841efa..18784b945b 100644 --- a/module/misc/control.php +++ b/module/misc/control.php @@ -121,43 +121,21 @@ class misc extends control } /** - * Show qr code for mobile login. + * Create qrcode for mobile login. * + * @param string $mode template|qrcode * @access public * @return void */ - public function showQRCode() + public function qrCode($mode = 'template') { + if($mode == 'template') die($this->display()); + $ciqrcode = $this->app->loadClass('ciqrcode'); - $loginAPI = common::getSysURL() . $this->config->webRoot; - if($this->config->requestType == "GET") $loginAPI .= "?m=user&f=login&"; - if($this->config->requestType == "PATH_INFO") $loginAPI .= "user-login?"; - if($this->loadModel('user')->isLogon()) $loginAPI .= "account={$this->app->user->account}&password={$this->app->user->password}"; + if($this->loadModel('user')->isLogon()) $loginAPI .= "?sid=" . session_ID(); - $qrImageName = md5($loginAPI) . '.png'; - $qrWebPath = common::getSysURL() . $this->config->webRoot . "data/$qrImageName"; - $savePath = $this->app->getAppRoot() . "www/data/"; - - $params['data'] = $loginAPI; - $params['level'] = 'L'; - $params['size'] = 10; - $params['savename'] = $savePath . $qrImageName; - $this->session->set('qrImage', $params['savename']); - $ciqrcode->generate($params); - - $this->view->qrWebPath = $qrWebPath; - $this->display(); - } - - /** - * Delete qr code. - * - * @access public - * @return void - */ - public function deleteQRCode() - { - @unlink($this->session->qrImage); + header("Content-Type: image/png"); + die($ciqrcode->generate(array('data' => $loginAPI, 'size' => 8))); } } diff --git a/www/js/my.full.js b/www/js/my.full.js index 5e8e417496..e1472074f1 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -471,7 +471,7 @@ function setAbout() */ function setQRCode() { - if($('a.qrCode').size()) $("a.qrCode").colorbox({width:500, height:500, iframe:true, transition:'none', scrolling:false, onCleanup:function(){$.get(createLink('misc', 'deleteQRCode'))}}); + if($('a.qrCode').size()) $("a.qrCode").colorbox({width:400, height:400, iframe:true, transition:'none', scrolling:false}); } /**