Repository navigation
Expand file tree
/
Copy pathftr_projector_cfg.php
More file actions
167 lines (138 loc) · 3.99 KB
/
Copy pathftr_projector_cfg.php
File metadata and controls
167 lines (138 loc) · 3.99 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
echo "<html>";
echo "<head>";
echo "<title>AutoNet\\ FTR Configuration</title>";
echo "</head>";
echo "<body bgcolor=#009999 lang=EN-US style='tab-interval:.5in'>";
echo "<P fontsize=15 align=center>";
echo " AutoNet\\ FTR Information </p>";
echo "<br>";
echo "<p align=center><font size=48 color=NAVY> FTR Configuration";
$host="127.0.0.1";
$user="root";
$password="rezasql";
# Connect to MySQL server
$conn = mysql_connect($host,$user,$password)
or die(mysql_error());
# Select the database
mysql_select_db("", $conn)
or die(mysql_error());
# Send SQL query
$sql="select ftr_id,bld_newname,new_name,24p,48p from ftr order by 2,1 ";
// echo "<R> $sql<BR>";
$result = mysql_query($sql)
or die(mysql_error());
while ($row=mysql_fetch_assoc($result)) {
projector($row['ftr_id'],$row['bld_newname'],$row['24p'],$row['48p'],$row['new_name']);
}
function projector($ftr_id,$bld,$v24p,$v48p,$name) {
$host="127.0.0.1";
$user="root";
$password="rezasql";
# Connect to MySQL server
$conn = mysql_connect($host,$user,$password)
or die(mysql_error());
# Select the database
mysql_select_db("", $conn)
or die(mysql_error());
# Send SQL query
$sql= "select ip from bld_ip where bld='".$bld."'";
$result = mysql_query($sql)
or die(mysql_error());
$row=mysql_fetch_assoc($result);
$ip=$row['ip'];
$ip2nd=substr($ip,3,3);
$sql=" select @rownum:=@rownum+1 as row, src_roomid as src from ( select src_roomid from portmapping ";
$sql=$sql." where src_type='FTR' and dst_bld='".$bld."' group by src_roomid order by src_roomid) e, (SELECT @rownum:=0) r" ;
$result = mysql_query($sql)
or die(mysql_error());
echo "</font></font><p>";
echo "<BR> Our FTR ID is : $ftr_id";
$ftr_row=0;
while ($row=mysql_fetch_assoc($result)) {
// echo "<BR> Internal calc : FTR_ID: ".$row['src'] . " ROW: ".$row['row'];
if ($row['src']==$ftr_id) $ftr_row=$row['row'];
}// while
$p=$ftr_row;
echo "<BR> Internal calc : P is $p";
echo "<BR><font size=48 color=NAVY>Building: $bld FTR $name<BR></font></p>";
echo "</font></font><p>";
echo "conf t";
echo "<BR>";
//*******************PORT - VLAN Assignment*********************
$vlan_id=200+$p;
echo "vlan $vlan_id name VIDEO_APPS by port";
echo "<BR>";
$sw=$v24p+$v48p;
if ($v24p>0) echo "tagged eth $sw/1/23";
else echo "tagged eth $sw/1/47";
echo "<BR>";
echo "router-interface ve $vlan_id";
echo "<BR>";
echo "!";
echo "<BR>";
echo "interface ve $vlan_id";
echo "<BR>";
echo "port-name [IP interface VIDEO_APPS Vlan $vlan_id]";
echo "<BR>";
echo "ip address 10.".$ip2nd.".".$vlan_id.".1 255.255.255.0";
echo "<BR>";
echo "ip ospf area 10.$ip2nd.0.0";
echo "<BR>";
echo "ip helper-address 1 10.90.192.100";
echo "<BR>";
echo "<BR>";
echo "!";
echo "<BR>";
$vlan_id=220+$p;
echo "vlan $vlan_id name EDUCATION_EQP by port";
echo "<BR>";
$sw=$v24p+$v48p;
if ($v24p>0) echo "tagged eth $sw/1/23";
else echo "tagged eth $sw/1/47";
echo "<BR>";
echo "router-interface ve $vlan_id";
echo "<BR>";
echo "!";
echo "<BR>";
echo "<BR>";
echo "interface ve $vlan_id";
echo "<BR>";
echo "port-name [IP interface EDUCATION_EQP Vlan $vlan_id]";
echo "<BR>";
echo "ip address 10.".$ip2nd.".".$vlan_id.".1 255.255.255.0";
echo "<BR>";
echo "ip ospf area 10.$ip2nd.0.0";
echo "<BR>";
echo "ip helper-address 1 10.90.192.100";
echo "<BR>";
echo "<BR>";
echo "!";
echo "<BR>";
$vlan_id=240+$p;
echo "vlan $vlan_id name FREE by port";
echo "<BR>";
$sw=$v24p+$v48p;
if ($v24p>0) echo "tagged eth $sw/1/23";
else echo "tagged eth $sw/1/47";
echo "<BR>";
echo "router-interface ve $vlan_id";
echo "<BR>";
echo "!";
echo "<BR>";
echo "<BR>";
echo "interface ve $vlan_id";
echo "<BR>";
echo "port-name [IP interface FREE Vlan $vlan_id]";
echo "<BR>";
echo "ip address 10.".$ip2nd.".".$vlan_id.".1 255.255.255.0";
echo "<BR>";
echo "ip ospf area 10.$ip2nd.0.0";
echo "<BR>";
echo "ip helper-address 1 10.90.192.100";
echo "<BR>";
echo "<BR>";
echo "!";
echo "<BR>";
} // function
?>