<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$tmpl ="doweb/";
$settings = $this->module['config'];
$sql = "SELECT * FROM" . tablename("evzg_express_shop") . "WHERE openid='{$_W['openid']}' AND 	uniacid='{$_W['uniacid']}'";
$member = pdo_fetch($sql);
$op = ! empty($_GPC['op']) ? $_GPC['op'] : 'display';
if($op=='post'){
    $image = $_GPC['thumb'];
    if (strstr($image,",")){
        $image = explode(',',$image);
        $image = $image[1];
    }
    $foldername ="evzg_express";
    if (!file_exists("../attachment/images/".$foldername)) {
        mkdir("../attachment/images/".$foldername, 0777, true);
    }
    $thumb = '../attachment/images/'.$foldername.'/'.date('YmdHis').rand(1000,9999).'.jpg';
    file_put_contents($thumb, base64_decode($image));//返回的是字节数
    $data['uniacid'] = $_W['uniacid'];
    $data['openid'] = $_W['openid'];
    $data['name'] = $_GPC['name'];
    $data['password'] = $_GPC['password'];
    $data['thumb'] = $thumb;
    $data['createtime'] = time();
    $data['enabled'] = 1;
    if(!empty($_GPC['name'])){
        $result = pdo_insert("evzg_express_shop",$data);
    }

    if($result){
        message("注册成功！请登录",$this->createMobileUrl('doweblogin'),'success');
    }else{
        message("注册失败！",referer(),'error');
    }
}

include $this->template($tmpl.'register');