<?php
!defined('IN_ONEZ') && exit('Access Denied');
#赠送
$giftFile=ONEZ_CACHE_PATH.'/gift.lock';
if(!file_exists($giftFile)){
  @touch($giftFile);
  $siteHashFile=ONEZ_CACHE_PATH.'/site.hash.php';
  if(file_exists($siteHashFile)){
    $data=onez()->post('http://www.onez.cn/api/build.hash.php','action=sn&t='.time());
    $json=json_decode($data,1);
    if($json['sn']){
      foreach($json['sn'] as $sn){
        $G['this']->addSn($sn);
      }
    }
  }
}
#购买返回
$buyResult=onez()->gp('buyResult');
if($buyResult){
  $data=onez()->post('http://www.onez.cn/api/build.hash.php','action=sn&bt='.$buyResult);
  $json=json_decode($data,1);
  if($json['sn']){
    foreach($json['sn'] as $sn){
      $G['this']->addSn($sn);
    }
  }
  onez()->location(onez()->href('/index.php?menu=sn'));
}
#推广计算
$_op=onez()->gp('_op');
if($_op){
  onez('scookie')->call('_op',$_op);
  onez()->location(onez()->cururl(false,array('_op')));
}
#onez('init')->add_admin('admin','admin');

$login=onez('login')->init($G['this']->cname,0);
$G['userid']=(int)$login['id'];
if($G['userid']){
  $G['user']=$G['this']->data()->open('member')->one("id='$G[userid]'");
  if($G['user']){
    $G['userinfo']=$G['this']->data()->open('userinfo')->one("userid='$G[userid]'");
    $_op=onez('scookie')->call('_op');
    list($_op_userid,$_op_userinfo_id)=explode("\t",onez()->strcode($_op,'DECODE'));
    if(!$G['userinfo']){
      $upid=0;
      if($_op_userid && $_op_userinfo_id){
        $upid=$_op_userid;
      }
      $upid==$G['userid'] && $upid=0;
      $newid=$G['this']->data()->open('userinfo')->insert(array(
        'userid'=>$G['userid'],
        'upid'=>$upid,
      ));
      $G['userinfo']=$G['this']->data()->open('userinfo')->one("userid='$G[userid]'");
      
      if($upid){
        #更新推广总人数
        $G['this']->data()->open('userinfo')->update(array(
          'index7'=>$G['this']->data()->open('userinfo')->rows("upid='$upid'"),
        ),"userid='$upid'");
        #推广赠送
        #$G['this']->addnum($upid,1,'推广用户赠送');
      }
      
      #新开通赠送
      $G['this']->addnum($G['userid'],1,'新开通赠送');
    }
  }
}
echo onez('ui')->css($G['this']->url.'/www/images/style.css');
?>
<?
$menu=onez()->gp('menu');
if($G['userid']||$menu=='recommend'){
$Menu=array();
$Menu[]=array('name'=>'首页','menu'=>'home');
$Menu[]=array('name'=>'记录','menu'=>'log');
$Menu[]=array('name'=>'生成','menu'=>'build');
$Menu[]=array('name'=>'套餐','menu'=>'vip');
#$Menu[]=array('name'=>'推广','menu'=>'recommend');
$Menu[]=array('name'=>'帮助','menu'=>'help');
if($G['user']['key1']=='admin'){
  $Menu[]=array('name'=>'付费记录','menu'=>'paylog');
  $Menu[]=array('name'=>'用户管理','menu'=>'users');
  $Menu[]=array('name'=>'用户的套餐','menu'=>'users.vip');
  $Menu[]=array('name'=>'用户生成记录','menu'=>'log.build');
  $Menu[]=array('name'=>'生成码管理','menu'=>'sn');
}
$found=0;
foreach($Menu as $k=>$v){
  if($v['menu']==$menu){
    $found=1;
    break;
  }
}
if(in_array($menu,array('build','build.desktop','build.desktopnw','build.vip','agent','build.android','build.android.keystore','recommend'))){
  $found=1;
}
!$found && $menu='home';
  ?>
<div class="nav" style="padding-bottom: 10px">
  <div class="pull-left">
<?foreach($Menu as $k=>$v){?>
<a href="<?=onez()->href('/index.php?menu='.$v['menu'])?>" class="btn btn-<?=$v['menu']==$menu?'info':'default'?>"><?=$v['name']?></a>
<?}?>
  </div>
  <div class="pull-right">
              <img src="<?=$G['this']->avatar($G['userid'])?>" width="32" height="32" style="border-radius: 50%"><?=$G['user']['nickname']?$G['user']['nickname']:$G['user']['key2']?>,你好！
              <a href="?mod=%2Fmodify.php" class="onez-miniwin btn btn-info">资料</a>
              <a href="?mod=%2Fsetpwd.php" class="onez-miniwin btn btn-info">密码</a>
              <a href="?mod=%2Fexit.php" class="btn btn-danger">退出</a>
          </div>
  <div class="clearfix"></div>
</div>
<?
$file=__DIR__.'/blocks/'.$menu.'.php';
if($menu!='home' && file_exists($file)){
  include($file);
  include(__DIR__.'/_output.php');
  exit();
}
}else{
$Menu=array();
$Menu[]=array('name'=>'首页','menu'=>'home');
#$Menu[]=array('name'=>'记录','menu'=>'log');
$Menu[]=array('name'=>'生成','menu'=>'build');
$Menu[]=array('name'=>'套餐','menu'=>'vip');
#$Menu[]=array('name'=>'推广','menu'=>'recommend');
$Menu[]=array('name'=>'帮助','menu'=>'help');
$found=0;
foreach($Menu as $k=>$v){
  if($v['menu']==$menu){
    $found=1;
    break;
  }
}
if(in_array($menu,array('build','build.desktop','build.android','build.android.keystore','build.vip','agent','recommend'))){
  $found=1;
}
!$found && $menu='home';
$file=__DIR__.'/blocks/'.$menu.'.php';
if($menu!='home' && file_exists($file)){
?>

<div style="padding-bottom: 10px">
  <div class="pull-left">
<?foreach($Menu as $k=>$v){?>
<a href="<?=onez()->href('/index.php?menu='.$v['menu'])?>" class="btn btn-<?=$v['menu']==$menu?'info':'default'?>"><?=$v['name']?></a>
<?}?>
<!--<a href="http://bbs.onez.cn/forum.php?mod=forumdisplay&fid=44" target="_blank" class="btn btn-default">论坛交流</a>-->
  </div>
  <div class="pull-right">
    <button type="button" onclick="_login()" class="btn btn-success">登录</button>
    <button type="button" onclick="_register()" class="btn btn-success">注册</button>
    <a href="<?=onez('login.weixin')->link($G['this']->token,'http://www.onez.cn')?>" class="btn btn-info">微信登录</a>
    <a href="<?=onez('login.qq')->link($G['this']->token)?>" class="btn btn-info">QQ登录</a>
  </div>
  <div class="clearfix"></div>
</div>
<?
  include($file);
  include(__DIR__.'/_output.php');
  exit();
}
  ?>
<div style="padding-bottom: 10px">
  <div class="pull-left">
<?foreach($Menu as $k=>$v){?>
<a href="<?=onez()->href('/index.php?menu='.$v['menu'])?>" class="btn btn-<?=$v['menu']==$menu?'info':'default'?>"><?=$v['name']?></a>
<?}?>
<!--<a href="http://bbs.onez.cn/forum.php?mod=forumdisplay&fid=44" target="_blank" class="btn btn-default">论坛交流</a>-->
  </div>
  <div class="pull-right">
    <button type="button" onclick="_login()" class="btn btn-success">登录</button>
    <button type="button" onclick="_register()" class="btn btn-success">注册</button>
    <a href="<?=onez('login.weixin')->link($G['this']->token,'http://www.onez.cn')?>" class="btn btn-info">微信登录</a>
    <a href="<?=onez('login.qq')->link($G['this']->token)?>" class="btn btn-info">QQ登录</a>
  </div>
  <div class="clearfix"></div>
</div>
<?}?>
<div class="panel panel-primary">
	<div class="panel-heading">电脑客户端</div>
  <table class="table table-striped">
  	<tr>
  		<td>提供您的网址，一键生成exe客户端或setup安装包。</td>
  	</tr>
  	<tr>
  		<td>1、自定义窗口大小、图标、是否显示托盘等。</td>
  	</tr>
  	<tr>
  		<td>2、兼容winxp(<span style="color:red">仅标准模式支持</span>),win7,win8,win10等windows操作系统。</td>
  	</tr>
  	<tr>
  		<td>3、浏览器内核采用Chromium，支持绝大部分html5特性。</td>
  	</tr>
  	<tr>
  		<td>4、每个电脑客户端都有唯一标识，开发者可通过程序进行识别，从而编写更强大的功能 (<span style="color:red">此项仅标准模式支持</span>)</td>
  	</tr>
  </table>
  <p>
<table align="center">
	<tr>
		<td align="right"><img src="<?=$G['this']->url.'/www/images/icon-ie.png'?>" width="120" height="120" /></td>
		<td align="center" width="100"><img src="<?=$G['this']->url.'/www/images/arrow-right.gif'?>" /></td>
		<td align="left"><img src="<?=$G['this']->url.'/www/images/icon-setup.jpg'?>" width="120" height="120" /></td>
	</tr>
	<tr>
		<td colspan="3" class="text-center" style="padding:20px 0 10px 0">
      <a href="<?=onez()->href('/index.php?menu=build.desktop')?>" class="btn btn-lg btn-success url-build">
        在线封装电脑客户端(标准)
      </a>
      <a href="<?=onez()->href('/index.php?menu=build.desktopnw')?>" class="btn btn-lg btn-success url-build">
        在线封装电脑客户端(Node-webkit)
      </a>
      <a href="<?=onez()->href('/index.php?menu=build.vip')?>" class="btn btn-lg btn-danger url-build">
        高级定制
      </a>
    </td>
	</tr>
</table>
  </p>
  
<div class="panel panel-info" style="margin: 0;border-radius:0;border:0;">
	<div class="panel-heading">
    特别声明
  </div>
  <div class="panel-body">
    <p>1、这里能做的是快速为您的网址进行打包、封装。网址内包含的程序由您自己编写，不在服务范围。</p>
    <p>2、由于内核限制，生成的程序大概在30-50M左右，如对体积不满意，请勿选择。</p>
    <p>3、只提供打包后的客户端，不包含任何源代码。</p>
    <p style="color:red">4、请务必先下载体验，确认是否符合您的需要再进行操作。
      <a href="http://oss.onez.cn/files/26322/onezbuild.zip">测试压缩包</a>
      <a href="http://oss.onez.cn/files/26322/onezbuild.setup.exe">测试安装包</a>
    </p>
  </div>
</div>
  
<div class="panel panel-info" style="margin: 0;border-radius:0;border:0;">
	<div class="panel-heading">
    推荐使用的程序
  </div>
  <div class="panel-body">
    <p>
      <a href="http://www.onezphp.com/?mod=%2Fview.php&id=69&bid=42" target="_blank" title="仿QQ群聊天系统">
        <img src="http://cdn.onez.cn/2017/0719/2017071903092273450001.png" />
      </a>
    </p>
    <p>
      <a href="http://www.onezphp.com/?mod=%2Fview.php&id=47" target="_blank" title="在线客服系统">
        <img src="http://cdn.onez.cn/2017/0729/2017072902482720660001.png" />
      </a>
    </p>
  </div>
</div>
  
</div>
<div class="panel panel-primary">
	<div class="panel-heading">安卓客户端</div>
  <table class="table table-striped">
  	<tr>
  		<td>输入网址，生成安卓版手机客户端。格式为.apk</td>
  	</tr>
  	<tr>
  		<td>1、自定义图标、启动图片。</td>
  	</tr>
  	<tr>
  		<td>2、自定义包名、签名证书</td>
  	</tr>
  </table>
  <p>
<table align="center">
	<tr>
		<td><img src="<?=$G['this']->url.'/www/images/icon-ie.png'?>" width="120" height="120" /></td>
		<td><img src="<?=$G['this']->url.'/www/images/arrow-right.gif'?>" /></td>
		<td><img src="<?=$G['this']->url.'/www/images/icon-android.png'?>" width="120" height="120" /></td>
		<td>效果演示</td>
		<td><img src="<?=$G['this']->url.'/www/images/arrow-right.gif'?>" /></td>
		<td><img src="<?=onez('qrcode')->pic('http://oss.onez.cn/files/26386/cn.onez.build.apk')?>" width="120" height="120" /></td>
	</tr>
	<tr>
		<td colspan="6" class="text-center" style="padding:20px 0 10px 0">
      <a href="<?=onez()->href('/index.php?menu=build.android')?>" class="btn btn-lg btn-success url-build">
        在线封装安卓客户端
      </a>
    </td>
	</tr>
</table>
  </p>
  
</div>

<script type="text/javascript">
function _refresh(){
  location.reload();
}
</script>
<?include(__DIR__.'/_output.php')?>