<?php
require './include/common.php';
include template('header');
if($isadmin){
?>
<table border=0 cellspacing=<?=BORDERWIDTH?> cellpadding=<?=TABLESPACE?> width=98% align=center bgcolor="<?=BORDERCOLOR?>">
<tr><td class="header">
<center>
八度空间虚拟股票交易所v3.0 (Build 0519) 安装程序
</center>
</td>
</tr>
<?if(empty($step)){?>
<tr><td bgcolor=<?=ALTBG2?>>
<center>
<br>
<br>
<input type=button value="全新安装" class="bginput" onclick="location.href='install_stock.php?step=install';">  <BR>
<br><br> <font color=red><b>注意事项:</b></font>全新安装适用于新用户,并不保留旧有版本的数据!
<br>
<br>
<input type=button value="旧版本升级" class="bginput" onclick="location.href='install_stock.php?step=upgrade';">  <BR>
<br><br> <font color=red><b>注意事项:</b></font>升级适用于1.x以上版本的虚拟股票插件,升级会新建八个数据表,并保留原有股票交易所的数据!<br>(不适合用于v2.5版本,v2.5版本用户只需上载覆盖所有文件即可。)
</center>
</td>
</tr>
</table>
<?}elseif($step=='install'){?>
<tr><td bgcolor=<?=ALTBG2?>>
<br> 安装注意事项:<br><br>
<li>安装会新建八个数据表。以防万一请先备份</li><br>
<li>安装完成后请进入后台,完成股票交易所的基本设置</li><br>
<li><font color=red>安装完成后,必定要删除install_stock.php</font></li><br><br>
点击按钮开始安装 <input type=button value="开始安装" class="bginputbegin" onclick="location.href='install_stock.php?step=doinstall&insertnew=0';">
</td>
</tr>
</table>
<?}elseif($step=='upgrade'){?>
<tr><td bgcolor=<?=ALTBG2?>>
<br> 升级注意事项:<br><br>
<li>升级会新建八个数据表。以防万一请先备份</li><br>
<li>升级完成后请进入后台,完成股票交易所的基本设置</li><br>
<li><font color=red>升级完成后,必定要删除install_stock.php</font></li><br><br>
点击按钮开始升级 <input type=button value="开始升级" class="bginputbegin" onclick="location.href='install_stock.php?step=doinstall&insertnew=1';">
</td>
</tr>
</table>
<?
}elseif($step=='doinstall'){
$db->query("DROP TABLE IF EXISTS cdb_ai;");
$db->query("CREATE TABLE cdb_ai (
id mediumint(8) unsigned NOT NULL auto_increment,
ainame varchar(50) NOT NULL default '',
cash double NOT NULL default '0',
fund double NOT NULL default '0',
stocktypenum int(10) NOT NULL default '0',
todaybuy int(10) NOT NULL default '0',
todaysale int(10) NOT NULL default '0',
totalbuy double NOT NULL default '0',
totalsale double NOT NULL default '0',
aid int(10) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=3 ;");
$db->query("insert into cdb_ai set ainame='炒股王',cash=1000000,fund=1000000,stocktypenum=0,todaybuy=0,todaysale=0,totalbuy=0,totalsale=0,aid=-1;");
$db->query("insert into cdb_ai set ainame='八度炒家',cash=1000000,fund=1000000,stocktypenum=0,todaybuy=0,todaysale=0,totalbuy=0,totalsale=0,aid=-2;");
$db->query("DROP TABLE IF EXISTS cdb_bighome;");
$db->query("CREATE TABLE cdb_bighome (
acc varchar(50) NOT NULL default '',
stockid int(10) NOT NULL default '0',
buymoney float NOT NULL default '0',
num double NOT NULL default '0',
averagemoney float NOT NULL default '0',
work varchar(50) NOT NULL default '',
buytime int(10) NOT NULL default '0',
saletime int(10) NOT NULL default '0',
uid int(10) NOT NULL default '0'
) TYPE=MyISAM;");
$db->query("DROP TABLE IF EXISTS cdb_client;");
$db->query("CREATE TABLE cdb_client (
id mediumint(8) unsigned NOT NULL auto_increment,
acc varchar(50) NOT NULL default '',
money bigint(100) NOT NULL default '0',
allmoney bigint(100) NOT NULL default '0',
ynlock int(6) NOT NULL default '0',
numtype int(10) NOT NULL default '0',
nowbuy int(100) NOT NULL default '0',
nowsell int(100) NOT NULL default '0',
opendate int(10) NOT NULL default '0',
lastdate int(10) NOT NULL default '0',
allbuy int(100) NOT NULL default '0',
allsell int(100) NOT NULL default '0',
style int(10) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=13 ;");
$db->query("DROP TABLE IF EXISTS cdb_gupiaoconfig;");
$db->query("CREATE TABLE cdb_gupiaoconfig (
id mediumint(8) unsigned NOT NULL auto_increment,
todaybuy int(100) NOT NULL default '0',
todaysale int(100) NOT NULL default '0',
todaytotal int(100) NOT NULL default '0',
todaydate int(10) NOT NULL default '0',
gupiao_setting varchar(100) NOT NULL default '',
pstock_setting varchar(100) NOT NULL default '',
kaihu_setting varchar(100) NOT NULL default '',
trade_setting varchar(100) NOT NULL default '',
stopreadme varchar(255) NOT NULL default '',
user_setting varchar(100) NOT NULL default '',
ai_setting varchar(100) NOT NULL default '',
custom_setting text NOT NULL,
stockmanager varchar(255) NOT NULL default '',
stockmright varchar(100) NOT NULL default '',
gpmax float NOT NULL default '0',
gpmin float NOT NULL default '0',
noticeshow int(11) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=2 ;");
$db->query("INSERT INTO cdb_gupiaoconfig (id, todaybuy, todaysale, todaytotal, todaydate, gupiao_setting, pstock_setting, kaihu_setting, trade_setting, stopreadme, user_setting, ai_setting, custom_setting, stockmanager, stockmright, gpmax, gpmin, noticeshow) VALUES (1, 18, 0, 7013853, 1112060180, '1,60,10,0,8||20,虚拟股票交易所,,,,,0.3,0.8,50,1,0,0,0,0,0', '1|1000000|1|50|255|5000||', '1|10|||500|1000', '1||1|1000|50|1.5|1|1|2|0.3|0.25|0.1|0.6|0.3|0.5|0.4|0|0.8', '股票交易所暂时休市!请下次再来。', '1|1|20000|20000|10|10|1|1', '0|0.3|八度炒家@炒股王', '虚拟股票交易所||<font color=red>实现论坛虚拟股市交易</font>', '', '0|1|1|1|1|1|0', '20', '1.5', 0);");
$db->query("DROP TABLE IF EXISTS cdb_personalstock;");
$db->query("CREATE TABLE cdb_personalstock (
stockid mediumint(8) unsigned NOT NULL auto_increment,
username varchar(50) NOT NULL default '',
uid int(10) NOT NULL default '0',
stockname varchar(50) NOT NULL default '',
price float NOT NULL default '0',
stocknum double NOT NULL default '0',
applydate int(10) NOT NULL default '0',
states int(10) NOT NULL default '0',
sexplain varchar(255) NOT NULL default '',
ltdimg varchar(200) NOT NULL default '',
on_cash double NOT NULL default '0',
PRIMARY KEY (stockid)
) TYPE=MyISAM AUTO_INCREMENT=1242 ;");
$db->query("DROP TABLE IF EXISTS cdb_rndevent;");
$db->query("CREATE TABLE cdb_rndevent (
id mediumint(8) unsigned NOT NULL auto_increment,
content varchar(255) NOT NULL default '',
addtime int(10) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=1224 ;");
$db->query("DROP TABLE IF EXISTS cdb_stock;");
$db->query("CREATE TABLE cdb_stock (
stockid mediumint(8) unsigned NOT NULL auto_increment,
work varchar(50) NOT NULL default '',
openmoney float NOT NULL default '0',
nowmoney float NOT NULL default '0',
datet int(10) NOT NULL default '0',
state varchar(50) NOT NULL default '',
buynum int(100) NOT NULL default '0',
sellnum int(100) NOT NULL default '0',
cid int(10) NOT NULL default '0',
usename varchar(50) NOT NULL default '',
uid int(10) NOT NULL default '0',
todaywave float NOT NULL default '0',
totalwave double NOT NULL default '0',
allnum double NOT NULL default '0',
leavenum double NOT NULL default '0',
buy int(100) NOT NULL default '0',
bargain float NOT NULL default '0',
sexplain varchar(255) NOT NULL default '',
tongji varchar(255) NOT NULL default '',
ltdimg varchar(200) NOT NULL default '',
unum float NOT NULL default '0',
lnum float NOT NULL default '0',
on_cash double NOT NULL default '0',
total_cash double NOT NULL default '0',
earn_cash double NOT NULL default '0',
totalnum int(100) NOT NULL default '0',
vend int(10) NOT NULL default '0',
PRIMARY KEY (stockid)
) TYPE=MyISAM AUTO_INCREMENT=55 ;");
$db->query("DROP TABLE IF EXISTS cdb_stocknews;");
$db->query("CREATE TABLE cdb_stocknews (
id mediumint(8) unsigned NOT NULL auto_increment,
title varchar(100) NOT NULL default '',
content varchar(255) NOT NULL default '',
color varchar(20) NOT NULL default '',
addtime int(10) NOT NULL default '0',
username varchar(255) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=5 ;");
$db->query("Delete from cdb_plugins where plug_key='stock'");
$db->query("INSERT INTO cdb_plugins (plug_title, plug_version, plug_author, plug_key, plug_stats, plug_cp, plug_tables, plug_license, plug_desc) VALUES ('八度空间虚拟股市', '2.5', '凡人', 'stock', 0, '', '', '八度空间虚拟股市v3.0 (Build 0519)', '实践论坛虚拟股票交易功能。(本插件自带后台设置,所以在插件管理中心无任何设置须要)');");
if($insertnew==1) {
$query=$db->query("select * from stock_client");
while($rs = $db->fetch_array($query))
{
$db->query("insert into cdb_client (id,acc,money,allmoney,ynlock,numtype,nowbuy,nowsell,opendate,lastdate,allbuy,allsell,style) values ($rs[id],'$rs[acc]',$rs[money],$rs[allmoney],$rs[ynlock],$rs[numtype],$rs[nowbuy],$rs[nowsell],$rs[opendate],$rs[lastdate],$rs[allbuy],$rs[allsell],0);");
}
$query=$db->query("select * from stock_bighome");
while($rs = $db->fetch_array($query))
{
if($rs[acc]==$discuz_user) {
$addmoney=$rs[num]*$rs[averagemoney];
$db->query("update cdb_client set money=money+$addmoney where acc='$discuz_user'");
}
else {
$db->query("insert into cdb_bighome (acc,stockid,buymoney,num,averagemoney,work,buytime,saletime,uid) values ('$rs[acc]',$rs[stockid],$rs[buymoney],$rs[num],$rs[averagemoney],'$rs[work]',$rs[buytime],$rs[saletime],$rs[uid]);");
}
}
$query=$db->query("select * from stock_rndevent");
while($rs = $db->fetch_array($query))
{
$db->query("insert into cdb_rndevent (id,content,addtime) values ($rs[id],'$rs[content]',$rs[addtime]);");
}
$query=$db->query("select id from stock_client where acc='$discuz_user'");
$mep = $db->fetch_array($query);
$meid = !empty($mep[id]) ? $mep[id] : '1';
$query=$db->query("select * from stock_stock");
while($rs = $db->fetch_array($query))
{
if($rs[allnum]>=$rs[leavenum]) {
$buy=$rs[allnum]-$rs[leavenum];
$totalnum=$rs[allnum]+intval($rs[allnum]/0.2);
$oncash=$rs[allnum]*$rs[nowmoney]/0.2;
$totalcash=$oncash+$rs[allnum]*$rs[nowmoney];
$db->query("insert into cdb_stock (stockid,work,openmoney,nowmoney,datet,state,buynum,sellnum,cid,usename,uid,todaywave,totalwave,allnum,leavenum,buy,bargain,sexplain,tongji,ltdimg,unum,lnum,on_cash,total_cash,earn_cash,totalnum,vend) values ($rs[stockid],'$rs[work]',$rs[openmoney],$rs[nowmoney],$rs[datet],'$rs[state]',$rs[buynum],$rs[sellnum],$rs[cid],'$discuz_user',$meid,$rs[todaywave],$rs[totalwave],$rs[allnum],$rs[leavenum],$buy,$buy,'$rs[sexplain]','$rs[tongji]','$rs[ltdimg]',$rs[unum],$rs[lnum],$oncash,$totalcash,0,$totalnum,0);");
}
elseif ($rs[allnum]<$rs[leavenum]) {
$allnum=$rs[leavenum];
$buy=0;
$totalnum=$allnum+intval($allnum/0.2);
$oncash=$allnum*$allnum/0.2;
$totalcash=$oncash+$allnum*$rs[nowmoney];
$db->query("insert into cdb_stock (stockid,work,openmoney,nowmoney,datet,state,buynum,sellnum,cid,usename,uid,todaywave,totalwave,allnum,leavenum,buy,bargain,sexplain,tongji,ltdimg,unum,lnum,on_cash,total_cash,earn_cash,totalnum,vend) values ($rs[stockid],'$rs[work]',$rs[openmoney],$rs[nowmoney],$rs[datet],'$rs[state]',$rs[buynum],$rs[sellnum],$rs[cid],'$discuz_user',$rs[uid],$rs[todaywave],$rs[totalwave],$allnum,$rs[leavenum],$buy,$buy,'$rs[sexplain]','$rs[tongji]','$rs[ltdimg]',$rs[unum],$rs[lnum],$oncash,$totalcash,0,$totalnum,0);");
}
}
$query=$db->query("select * from stock_stocknews");
while($rs = $db->fetch_array($query))
{
$db->query("insert into cdb_stocknews (id,title,content,color,addtime,username) values ($rs[id],'$rs[title]','$rs[content]','$rs[color]',$rs[addtime],'$rs[username]');");
}
}
/*else {
$timep=time();
$db->query("INSERT INTO cdb_stock set stockid='1', work='八度空间娱乐网', openmoney='10', nowmoney='10', datet='$timep', state='开', buynum='0', sellnum='0', cid='0', usename='$discuz_user', uid='1', totalwave='0', allnum='100000', buy='0', bargain='0', leavenum='100000', sexplain='八度空间娱乐网股份有限公司。', tongji='0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0', ltdimg='images/LtdImg/1.jpg', unum='10', lnum='10', on_cash='100000000', total_cash='100000000', earn_cash='0', totalnum='10100000', vend='0';");
}*/
?>
<tr><td bgcolor=<?=ALTBG2?>>
<center>
安装完成! <BR><b>请到论坛后台〉插件设置〉管理中心〉八度空间虚拟股市〉编辑,开启股市插件功能。</b>
<br>
八度空间虚拟股票交易所插件 v3.0 (Build 0519) For Discuz! 2.5F & 2.5SP1 数据表修改已完成,请检查论坛根目录下 install_stock.php,如果仍然存在,则<font color=#FF0000>立即删除</font>!
</center>
</td></tr>
</table>
<?
}
}else {
showmessage("你不是管理员");
}
include template('footer');
?>
怎么安装啊?
哪段是优化数据库?
哪段是导入插件?? |