-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartBusiness.php
More file actions
48 lines (35 loc) · 1.05 KB
/
Copy pathStartBusiness.php
File metadata and controls
48 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
//-1:無法取得SerialNumbers
//-2:已經開始營業
require_once("session.php");
$se=new session();
if(!$SerialNumbers=$se->get_value("SerialNumbers"))
{
echo "-1";
exit();
}
require_once("connect_mysql_class.php");
require_once("mysql_inc.php");
$db=new DB();
$db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']);
$query="SELECT * FROM ".$SerialNumbers." WHERE State !='DIE' ";
$db->query($query);
if($db->get_num_rows()!=0)
{
echo "-2";
exit;
}
/*產生新的Item的key*/
$word ='abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789';//樣本
$len = strlen($word);
$item_id="";
for($i=0;$i<10;$i++)
{
$item_id.=$word[rand() % $len];
}
$query="INSERT INTO `".$SerialNumbers."`(`ID`,`Name`,`State`,`Value`,`Now_Value`) VALUES ('".$item_id."','TYPE2','STOP','0','0')";
$db->query($query);
$data=array("Num int PRIMARY KEY AUTO_INCREMENT","ItemID varchar(30)","CustomID varchar(30)","GroupID int(255) DEFAULT 0","Life int(255) DEFAULT 0","Quantity int(255)");
$db->create_table("Type2".$item_id,$data);
echo '1';
?>