Example #1
0
 /**
  * 更新系统配置
  */
 public function post()
 {
     /* 允许上传的文件类型 */
     $allow_file_types = '|GIF|JPG|PNG|BMP|SWF|DOC|XLS|PPT|MID|WAV|ZIP|RAR|PDF|CHM|RM|TXT|CERT|';
     $arr = array();
     $res = $this->model->table('touch_shop_config')->field('id, value')->select();
     if (is_array($res)) {
         foreach ($res as $vo) {
             $arr[$vo['id']] = $vo['value'];
         }
     }
     foreach (I('value') as $key => $val) {
         if ($arr[$key] != $val) {
             $data['value'] = $val;
             $condition['id'] = $key;
             $this->model->table('touch_shop_config')->data($data)->where($condition)->update();
         }
     }
     /* 处理上传文件 */
     $file_var_list = array();
     $res = $this->model->table('touch_shop_config')->where("parent_id > 0 AND type = 'file'")->select();
     if (is_array($res)) {
         foreach ($res as $vo) {
             $file_var_list[$vo['code']] = $vo;
         }
     }
     foreach ($_FILES as $code => $file) {
         /* 判断用户是否选择了文件 */
         if (isset($file['error']) && $file['error'] == 0 || !isset($file['error']) && $file['tmp_name'] != 'none') {
             /* 检查上传的文件类型是否合法 */
             if (!check_file_type($file['tmp_name'], $file['name'], $allow_file_types)) {
                 $this->message(sprintf(L('msg_invalid_file'), $file['name']), NULL, 'error');
             } else {
                 if ($code == 'shop_logo') {
                     $info = get_template_info(C('template'));
                     $info['logo'] = empty($info['logo']) ? 'logo.png' : $info['logo'];
                     $file_name = str_replace('{$template}', C('template'), $file_var_list[$code]['store_dir']) . $info['logo'];
                 } elseif ($code == 'watermark') {
                     $name = explode('.', $file['name']);
                     $ext = array_pop($name);
                     $file_name = $file_var_list[$code]['store_dir'] . 'watermark.' . $ext;
                     if (file_exists($file_var_list[$code]['value'])) {
                         @unlink($file_var_list[$code]['value']);
                     }
                 } elseif ($code == 'no_picture') {
                     $name = explode('.', $file['name']);
                     $ext = array_pop($name);
                     $file_name = $file_var_list[$code]['store_dir'] . 'no_picture.' . $ext;
                     if (file_exists($file_var_list[$code]['value'])) {
                         @unlink($file_var_list[$code]['value']);
                     }
                 } else {
                     $file_name = $file_var_list[$code]['store_dir'] . $file['name'];
                 }
                 /* 判断是否上传成功 */
                 if (move_upload_file($file['tmp_name'], $file_name)) {
                     $data2['value'] = __ROOT__ . str_replace(array('./', '../'), '/', $file_name);
                     $this->model->table('touch_shop_config')->data($data2)->where("code = '{$code}'")->update();
                 } else {
                     $this->message(sprintf(L('msg_upload_failed'), $file['name'], $file_var_list[$code]['store_dir']), NULL, 'error');
                 }
             }
         }
     }
     /* 处理发票类型及税率 */
     $invoice_rate = I('invoice_rate');
     if (!empty($invoice_rate)) {
         foreach ($invoice_rate as $key => $rate) {
             $rate = round(floatval($rate), 2);
             if ($rate < 0) {
                 $rate = 0;
             }
             I('invoice_rate.' . $key, $rate);
         }
         $invoice = array('type' => I('invoice_type'), 'rate' => I('invoice_rate'));
         $data3['value'] = serialize($invoice);
         $this->model->table('touch_shop_config')->data($data3)->where("code = 'invoice_type'")->update();
     }
     /* 清除缓存 */
     clear_all_files();
     $site_info = site_info();
     $this->cloud->data($site_info)->act('post.record');
     $this->message(L('save_success'), url('index'));
 }
Example #2
0
 /**
  * 安装成功
  */
 public function success()
 {
     $appid = $this->appid();
     $config_file = './data/version.php';
     require $config_file;
     $content = "<?php\ndefine('APPNAME', '" . APPNAME . "');\ndefine('VERSION', '" . VERSION . "');\ndefine('RELEASE', '" . RELEASE . "');\ndefine('ECTOUCH_AUTH_KEY', '" . $appid . "');";
     @file_put_contents($config_file, $content);
     @fopen($this->lockFile, 'w');
     if (ECTOUCH_AUTH_KEY == '') {
         $site_info = site_info($appid);
         $this->cloud->data($site_info)->act('post.install');
     }
     //生成二维码
     $mobile_url = __URL__;
     //二维码内容
     $errorCorrectionLevel = 'L';
     // 纠错级别:L、M、Q、H
     $matrixPointSize = 7;
     // 点的大小:1到10
     $mobile_qr = 'data/cache/demo_qrcode.png';
     QRcode::png($mobile_url, ROOT_PATH . $mobile_qr, $errorCorrectionLevel, $matrixPointSize, 2);
     //二维码路径赋值
     $this->assign('mobile_qr', $mobile_url . '/' . $mobile_qr);
     $this->display('success');
     if (C('run_after_del')) {
         del_dir(BASE_PATH . 'apps/' . APP_NAME);
         if (is_dir('data/assets/' . APP_NAME)) {
             del_dir('data/assets/' . APP_NAME);
         }
     }
 }
Example #3
0
	<script type="text/javascript">
		var SITE_INFO = JSON.parse('<?php 
echo site_info();
?>
');
	</script>
		<?php 
wp_footer();
?>
	</body>
</html>