-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
83 lines (59 loc) · 2.1 KB
/
index.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
require_once "lib/init.php";
/*
* if we are creating a new scenario then give the 'player' some options,
* do some voodoo on the options, display and store scenario Otherwise
* print main page. natch
*
*/
if ($_REQUEST['create'] == "new"){
$smarty->display("headers.tpl");
$smarty->display("create.tpl");
$smarty->display("footers.tpl");
}elseif ($_REQUEST['create'] == "data"){
$sql="truncate table agents";
$result = $db->query($sql);
$sql="truncate table properties";
$result = $db->query($sql);
//now create a new one, start with just creating agents
//We have an array of names for our person!
$arrayofnames = file("names.txt");
while ($_REQUEST['num_agents']>0){
$sql="INSERT INTO agents SET name='" . $arrayofnames[array_rand($arrayofnames)]."'";
$result = $db->query($sql);
$_REQUEST['num_agents']--;
}
$sql="SELECT *,
agents.id as agent_id,
agents.name AS agent_name
FROM agents ";
$agents=$db->queryarray($sql);
$smarty->assign("agents",$agents);
$sql="SELECT terms.id as term_id, terms.term AS agent_type
FROM terms
LEFT JOIN term_classes ON term_classes.id = terms.term_class_id
WHERE term_classes.name = 'Agent'";
$agent_types=$db->queryarray($sql);
$smarty->assign("agent_types",$agent_types);
//we have agents now let user set what type they are
//then add all the voodoo
$smarty->display("headers.tpl");
$smarty->display("agents.tpl");
$smarty->display("footers.tpl");
}elseif($_REQUEST['create'] == "generate"){
// We want to show some agents - better make a collection object
$sql="SELECT * FROM term_classes";
$classes=$db->queryarray($sql);
$smarty->assign("classes",$classes);
$smarty->assign("agents",$agentman->agents);
$agentman->qualifyagents();
$smarty->display("headers.tpl");
$smarty->display("showcreated.tpl");
$smarty->display("footers.tpl");
}else{
$smarty->display("headers.tpl");
$smarty->display("index.tpl");
$smarty->display("footers.tpl");
}
//We have an array of names for our person!
?>