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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
|
<? /*
LibreSSL - CAcert web application
Copyright (C) 2004-2011 CAcert Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
define('NULL_DATETIME', '0000-00-00 00:00:00');
define('THAWTE_REVOCATION_DATETIME', '2010-11-16 00:00:00');
function query_init ($query)
{
return mysql_query($query);
}
function query_getnextrow ($res)
{
$row1 = mysql_fetch_assoc($res);
return $row1;
}
function query_get_number_of_rows ($resultset)
{
return intval(mysql_num_rows($resultset));
}
function get_number_of_assurances ($userid)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
WHERE `method` = 'Face to Face Meeting' AND `from`='".intval($userid)."' and `deleted` = 0");
$row = query_getnextrow($res);
return intval($row['list']);
}
function get_number_of_ttpassurances ($userid)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
WHERE (`method`='Trusted Third Parties' or `method`='TTP-Assisted') AND `to`='".intval($userid)."' and `deleted` = 0");
$row = query_getnextrow($res);
return intval($row['list']);
}
function get_number_of_assurees ($userid)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
WHERE `method` = 'Face to Face Meeting' AND `to`='".intval($userid)."' and `deleted` = 0");
$row = query_getnextrow($res);
return intval($row['list']);
}
function get_top_assurer_position ($no_of_assurances)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
WHERE `method` = 'Face to Face Meeting' and `deleted` = 0
GROUP BY `from` HAVING count(*) > '".intval($no_of_assurances)."'");
return intval(query_get_number_of_rows($res)+1);
}
function get_top_assuree_position ($no_of_assurees)
{
$res = query_init ("SELECT count(*) AS `list` FROM `notary`
WHERE `method` = 'Face to Face Meeting' and `deleted` = 0
GROUP BY `to` HAVING count(*) > '".intval($no_of_assurees)."'");
return intval(query_get_number_of_rows($res)+1);
}
/**
* Get the list of assurances given by the user
* @param int $userid - id of the assurer
* @param int $log - if set to 1 also includes deleted assurances
* @return resource - a MySQL result set
*/
function get_given_assurances($userid, $log=0)
{
$deleted='';
if ($log == 0) {
$deleted = ' and `deleted` = 0 ';
}
$res = query_init("select * from `notary` where `from`='".intval($userid)."' and `from` != `to` $deleted order by `id` asc");
return $res;
}
/**
* Get the list of assurances received by the user
* @param int $userid - id of the assuree
* @param int $log - if set to 1 also includes deleted assurances
* @return resource - a MySQL result set
*/
function get_received_assurances($userid, $log=0)
{
$deleted='';
if ($log == 0) {
$deleted = ' and `deleted` = 0 ';
}
$res = query_init("select * from `notary` where `to`='".intval($userid)."' and `from` != `to` $deleted order by `id` asc ");
return $res;
}
function get_given_assurances_summary ($userid)
{
$res = query_init ("select count(*) as number,points,awarded,method from notary where `from`='".intval($userid)."' and `deleted` = 0 group by points,awarded,method");
return $res;
}
function get_received_assurances_summary ($userid)
{
$res = query_init ("select count(*) as number,points,awarded,method from notary where `to`='".intval($userid)."' and `deleted` = 0 group by points,awarded,method");
return $res;
}
function get_user ($userid)
{
$res = query_init ("select * from `users` where `id`='".intval($userid)."'");
return mysql_fetch_assoc($res);
}
function get_cats_state ($userid)
{
$res = query_init ("select * from `cats_passed` inner join `cats_variant` on `cats_passed`.`variant_id` = `cats_variant`.`id` and `cats_variant`.`type_id` = 1
WHERE `cats_passed`.`user_id` = '".intval($userid)."'");
return mysql_num_rows($res);
}
/**
* Calculate awarded points (corrects some issues like out of range points
* or points that were issued by means that have been deprecated)
*
* @param array $row - associative array containing the data from the
* `notary` table
* @return int - the awarded points for this assurance
*/
function calc_awarded($row)
{
// Back in the old days there was no `awarded` column => is now zero,
// there the `points` column contained that data
$points = max(intval($row['awarded']), intval($row['points']));
// Set negative points to zero, yes there are such things in the database
$points = max($points, 0);
switch ($row['method'])
{
// These programmes have been revoked
case 'Thawte Points Transfer': // revoke all Thawte-points (as per arbitration)
case 'CT Magazine - Germany': // revoke c't (only one test-entry)
case 'Temporary Increase': // revoke 'temporary increase' (Current usage breaks audit aspects, needs to be reimplemented)
$points = 0;
break;
case 'Administrative Increase': // ignore AI with 2 points or less (historical for experiance points, now other calculation)
if ($points <= 2) // maybe limit to 35/50 pts in the future?
$points = 0;
break;
// TTP assurances, limit to 35
case 'TTP-Assisted':
$points = min($points, 35);
break;
// TTP TOPUP, limit to 30
case 'TOPUP':
$points = min($points, 30);
// All these should be preserved for the time being
case 'Unknown': // to be revoked in the future? limit to max 50 pts?
case 'Trusted Third Parties': // to be revoked in the future? limit to max 35 pts?
case '': // to be revoked in the future? limit to max 50 pts?
case 'Face to Face Meeting': // normal assurances (and superassurances?), limit to 35/50 pts in the future?
break;
default: // should never happen ... ;-)
$points = 0;
}
return $points;
}
/**
* Calculate the experience points from a given Assurance
* @param array $row - [inout] associative array containing the data from
* the `notary` table, the keys 'experience' and 'calc_awarded' will be
* added
* @param int $sum_points - [inout] the sum of already counted assurance
* points the assurer issued
* @param int $sum_experience - [inout] the sum of already counted
* experience points that were awarded to the assurer
*/
function calc_experience(&$row, &$sum_points, &$sum_experience)
{
$row['calc_awarded'] = calc_awarded($row);
// Don't count revoked assurances even if we are displaying them
if ($row['deleted'] !== NULL_DATETIME) {
$row['experience'] = 0;
return;
}
$experience = 0;
if ($row['method'] == "Face to Face Meeting")
{
$experience = 2;
}
$sum_experience += $experience;
$row['experience'] = $experience;
$sum_points += $row['calc_awarded'];
}
/**
* Calculate the points received from a received Assurance
* @param array $row - [inout] associative array containing the data from
* the `notary` table, the keys 'experience' and 'calc_awarded' will be
* added
* @param int $sum_points - [inout] the sum of already counted assurance
* points the assuree received
* @param int $sum_experience - [inout] the sum of already counted
* experience points that were awarded to the assurer
*/
function calc_assurances(&$row, &$sum_points, &$sum_experience)
{
$row['calc_awarded'] = calc_awarded($row);
$experience = 0;
// High point values mean that some of them are experience points
if ($row['calc_awarded'] > 100)
{
$experience = $row['calc_awarded'] - 100; // needs to be fixed in the future (limit 50 pts and/or no experience if pts > 100)
$row['calc_awarded'] = 100;
}
switch ($row['method'])
{
case 'Thawte Points Transfer':
case 'CT Magazine - Germany':
case 'Temporary Increase': // Current usage of 'Temporary Increase' may break audit aspects, needs to be reimplemented
$experience = 0;
$row['deleted'] = THAWTE_REVOCATION_DATETIME;
break;
}
// Don't count revoked assurances even if we are displaying them
if ($row['deleted'] !== NULL_DATETIME) {
$row['experience'] = 0;
return;
}
$sum_experience += $experience;
$row['experience'] = $experience;
$sum_points += $row['calc_awarded'];
}
/**
* Generate a link to the support engineer page for the user with the name
* of the user as link text
* @param array $user - associative array containing the data from the
* `user` table
* @return string
*/
function show_user_link($user)
{
$name = trim($user['fname'].' '.$user['lname']);
$userid = intval($user['id']);
if($name == "")
{
if ($userid == 0) {
$name = _("System");
} else {
$name = _("Deleted account");
}
}
else
{
$name = "<a href='wot.php?id=9&userid=".$userid."'>".sanitizeHTML($name)."</a>";
}
return $name;
}
/**
* Generate a link to the support engineer page for the user with the email
* address as link text
* @param array $user - associative array containing the data from the
* `user` table
* @return string
*/
function show_email_link($user)
{
$email = trim($user['email']);
if($email != "") {
$email = "<a href='account.php?id=43&userid=".intval($user['id'])."'>".sanitizeHTML($email)."</a>";
}
return $email;
}
function get_assurer_ranking($userid,&$num_of_assurances,&$rank_of_assurer)
{
$num_of_assurances = get_number_of_assurances (intval($userid));
$rank_of_assurer = get_top_assurer_position($num_of_assurances);
}
function get_assuree_ranking($userid,&$num_of_assurees,&$rank_of_assuree)
{
$num_of_assurees = get_number_of_assurees (intval($userid));
$rank_of_assuree = get_top_assuree_position($num_of_assurees);
}
// ************* html table definitions ******************
function output_ranking($userid)
{
get_assurer_ranking($userid,$num_of_assurances,$rank_of_assurer);
get_assuree_ranking($userid,$num_of_assurees,$rank_of_assuree);
?>
<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
<tr>
<td class="title"><?=_("Assurer Ranking")?></td>
</tr>
<tr>
<td class="DataTD"><?=sprintf(_("You have made %s assurances which ranks you as the #%s top assurer."), intval($num_of_assurances), intval($rank_of_assurer) )?></td>
</tr>
<tr>
<td class="DataTD"><?=sprintf(_("You have received %s assurances which ranks you as the #%s top assuree."), intval($num_of_assurees), intval($rank_of_assuree) )?></td>
</tr>
</table>
<br/>
<?
}
/**
* Render header for the assurance table (same for given/received)
* @param string $title - The title for the table
* @param int $support - set to 1 if the output is for the support interface
* @param int $log - if set to 1 also includes deleted assurances
*/
function output_assurances_header($title, $support, $log)
{
if ($support == 1) {
$log = 1;
}
$colspan = 7;
if ($support == 1) {
$colspan += 2;
}
if ($log == 1) {
$colspan += 1;
}
?>
<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
<tr>
<td colspan="<?=$colspan?>" class="title"><?=$title?></td>
</tr>
<tr>
<td class="DataTD"><strong><?=_("ID")?></strong></td>
<td class="DataTD"><strong><?=_("Date")?></strong></td>
<?
if ($support == 1)
{
?>
<td class="DataTD"><strong><?=_("When")?></strong></td>
<td class="DataTD"><strong><?=_("Email")?></strong></td>
<?
}
?>
<td class="DataTD"><strong><?=_("Who")?></strong></td>
<td class="DataTD"><strong><?=_("Points")?></strong></td>
<td class="DataTD"><strong><?=_("Location")?></strong></td>
<td class="DataTD"><strong><?=_("Method")?></strong></td>
<td class="DataTD"><strong><?=_("Experience Points")?></strong></td>
<?
if ($log == 1)
{
?>
<td class="DataTD"><strong><?=_("Revoked")?></strong></td>
<?
}
?>
</tr>
<?
}
/**
* Render footer for the assurance table (same for given/received)
* @param string $points_txt - Description for sum of assurance points
* @param int $sumpoints - sum of assurance points
* @param string $experience_txt - Description for sum of experience points
* @param int $sumexperience - sum of experience points
* @param int $support - set to 1 if the output is for the support interface
* @param int $log - if set to 1 also includes deleted assurances
*/
function output_assurances_footer(
$points_txt,
$sumpoints,
$experience_txt,
$sumexperience,
$support,
$log)
{
?>
<tr>
<td colspan="<?=($support == 1) ? 5 : 3 ?>" class="DataTD"><strong><?=$points_txt?>:</strong></td>
<td class="DataTD"><?=intval($sumpoints)?></td>
<td class="DataTD"> </td>
<td class="DataTD"><strong><?=$experience_txt?>:</strong></td>
<td class="DataTD"><?=intval($sumexperience)?></td>
<?
if ($log == 1)
{
?>
<td class="DataTD"> </td>
<?
}
?>
</tr>
</table>
<br/>
<?
}
/**
* Render an assurance for a view
* @param array $assurance - associative array containing the data from the `notary` table
* @param int $userid - Id of the user whichs given/received assurances are displayed
* @param array $other_user - associative array containing the other users data from the `users` table
* @param int $support - set to 1 if the output is for the support interface
* @param string $ticketno - ticket number currently set in the support interface
* @param int $log - if set to 1 also includes deleted assurances
*/
function output_assurances_row(
$assurance,
$userid,
$other_user,
$support,
$ticketno,
$log)
{
$assuranceid = intval($assurance['id']);
$date = $assurance['date'];
$when = $assurance['when'];
$awarded = intval($assurance['calc_awarded']);
$points = intval($assurance['points']);
$location = $assurance['location'];
$method = $assurance['method'] ? _($assurance['method']) : '';
$experience = intval($assurance['experience']);
$revoked = $assurance['deleted'] !== NULL_DATETIME;
$email = show_email_link($other_user);
$name = show_user_link($other_user);
if ($support == 1) {
$log = 1;
}
$tdstyle="";
$emopen="";
$emclose="";
if ($awarded == $points)
{
if ($awarded == 0)
{
if ($when < "2006-09-01")
{
$tdstyle="style='background-color: #ffff80'";
$emopen="<em>";
$emclose="</em>";
}
}
}
?>
<tr>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$assuranceid?><?=$emclose?></td>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$date?><?=$emclose?></td>
<?
if ($support == 1)
{
?>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$when?><?=$emclose?></td>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$email?><?=$emclose?></td>
<?
}
?>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$name?><?=$emclose?></td>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$revoked ? sprintf("<strong style='color: red'>%s</strong>",_("Revoked")) : $awarded?><?=$emclose?></td>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$location?><?=$emclose?></td>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$method?><?=$emclose?></td>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><?=$experience?$experience:' '?><?=$emclose?></td>
<?
if ($log == 1)
{
if ($revoked == true)
{
?>
<td class="DataTD" <?=$tdstyle?>><?=$assurance['deleted']?></td>
<?
} elseif ($support == 1) {
?>
<td class="DataTD" <?=$tdstyle?>><?=$emopen?><a href="account.php?id=43&userid=<?=intval($userid)?>&assurance=<?=intval($assuranceid)?>&csrf=<?=make_csrf('admdelassurance')?>&ticketno=<?=sanitizeHTML($ticketno)?>" onclick="return confirm('<?=sprintf(_("Are you sure you want to revoke the assurance with ID "%s"?"),$assuranceid)?>');"><?=_("Revoke")?></a><?=$emclose?></td>
<?
} else {
?>
<td class="DataTD" <?=$tdstyle?>> </td>
<?
}
}
?>
</tr>
<?
}
function output_summary_header()
{
?>
<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
<tr>
<td colspan="4" class="title"><?=_("Summary of your Points")?></td>
</tr>
<tr>
<td class="DataTD"><strong><?=_("Description")?></strong></td>
<td class="DataTD"><strong><?=_("Points")?></strong></td>
<td class="DataTD"><strong><?=_("Countable Points")?></strong></td>
<td class="DataTD"><strong><?=_("Remark")?></strong></td>
</tr>
<?
}
function output_summary_footer()
{
?>
</table>
<br/>
<?
}
function output_summary_row($title,$points,$points_countable,$remark)
{
?>
<tr>
<td class="DataTD"><strong><?=$title?></strong></td>
<td class="DataTD"><?=$points?></td>
<td class="DataTD"><?=$points_countable?></td>
<td class="DataTD"><?=$remark?></td>
</tr>
<?
}
// ************* output given assurances ******************
/**
* Helper function to render assurances given by the user
* @param int $userid
* @param int& $sum_points - [out] sum of given points
* @param int& $sum_experience - [out] sum of experience points gained
* @param int $support - set to 1 if the output is for the support interface
* @param string $ticketno - the ticket number set in the support interface
* @param int $log - if set to 1 also includes deleted assurances
*/
function output_given_assurances_content(
$userid,
&$sum_points,
&$sum_experience,
$support,
$ticketno,
$log)
{
$sum_points = 0;
$sumexperience = 0;
$res = get_given_assurances(intval($userid), $log);
while($row = mysql_fetch_assoc($res))
{
$assuree = get_user(intval($row['to']));
calc_experience($row, $sum_points, $sum_experience);
output_assurances_row($row, $userid, $assuree, $support, $ticketno, $log);
}
}
// ************* output received assurances ******************
/**
* Helper function to render assurances received by the user
* @param int $userid
* @param int& $sum_points - [out] sum of received points
* @param int& $sum_experience - [out] sum of experience points the assurers gained
* @param int $support - set to 1 if the output is for the support interface
* @param string $ticketno - the ticket number set in the support interface
* @param int $log - if set to 1 also includes deleted assurances
*/
function output_received_assurances_content(
$userid,
&$sum_points,
&$sum_experience,
$support,
$ticketno,
$log)
{
$sum_points = 0;
$sumexperience = 0;
$res = get_received_assurances(intval($userid), $log);
while($row = mysql_fetch_assoc($res))
{
$fromuser = get_user(intval($row['from']));
calc_assurances($row, $sum_points, $sum_experience);
output_assurances_row($row, $userid, $fromuser, $support, $ticketno, $log);
}
}
// ************* output summary table ******************
function check_date_limit ($userid,$age)
{
$dob = date("Y-m-d", mktime(0,0,0,date("m"),date("d"),date("Y")-$age));
$res = query_init ("select id from `users` where `id`='".$userid."' and `dob` < '$dob'");
return intval(query_get_number_of_rows($res));
}
function max_points($userid)
{
return output_summary_content ($userid,0);
}
function output_summary_content($userid,$display_output)
{
$sum_points = 0;
$sum_experience = 0;
$sum_experience_other = 0;
$max_points = 100;
$max_experience = 50;
$experience_limit_reached_txt = _("Limit reached");
if (check_date_limit($userid,18) != 1)
{
$max_experience = 10;
$experience_limit_reached_txt = _("Limit given by PoJAM reached");
}
if (check_date_limit($userid,14) != 1)
{
$max_experience = 0;
$experience_limit_reached_txt = _("Limit given by PoJAM reached");
}
$res = get_received_assurances_summary($userid);
while($row = mysql_fetch_assoc($res))
{
$points = calc_awarded($row);
if ($points > $max_points) // limit to 100 points, above is experience (needs to be fixed)
{
$sum_experience_other = $sum_experience_other+($points-$max_points)*intval($row['number']);
$points = $max_points;
}
$sum_points += $points*intval($row['number']);
}
$res = get_given_assurances_summary($userid);
while($row = mysql_fetch_assoc($res))
{
switch ($row['method'])
{
case 'Face to Face Meeting': // count Face to Face only
$sum_experience += 2*intval($row['number']);
break;
}
}
if ($sum_points > $max_points)
{
$sum_points_countable = $max_points;
$remark_points = _("Limit reached");
}
else
{
$sum_points_countable = $sum_points;
$remark_points = " ";
}
if ($sum_experience > $max_experience)
{
$sum_experience_countable = $max_experience;
$remark_experience = $experience_limit_reached_txt;
}
else
{
$sum_experience_countable = $sum_experience;
$remark_experience = " ";
}
if ($sum_experience_countable + $sum_experience_other > $max_experience)
{
$sum_experience_other_countable = $max_experience-$sum_experience_countable;
$remark_experience_other = $experience_limit_reached_txt;
}
else
{
$sum_experience_other_countable = $sum_experience_other;
$remark_experience_other = " ";
}
if ($sum_points_countable < $max_points)
{
if ($sum_experience_countable != 0)
$remark_experience = _("Points on hold due to less assurance points");
$sum_experience_countable = 0;
if ($sum_experience_other_countable != 0)
$remark_experience_other = _("Points on hold due to less assurance points");
$sum_experience_other_countable = 0;
}
$issue_points = 0;
$cats_test_passed = get_cats_state ($userid);
if ($cats_test_passed == 0)
{
$issue_points_txt = "<strong style='color: red'>"._("You have to pass the CAcert Assurer Challenge (CATS-Test) to be an Assurer")."</strong>";
if ($sum_points_countable < $max_points)
{
$issue_points_txt = "<strong style='color: red'>";
$issue_points_txt .= sprintf(_("You need %s assurance points and the passed CATS-Test to be an Assurer"), intval($max_points));
$issue_points_txt .= "</strong>";
}
}
else
{
$experience_total = $sum_experience_countable+$sum_experience_other_countable;
$issue_points_txt = "";
if ($sum_points_countable == $max_points)
$issue_points = 10;
if ($experience_total >= 10)
$issue_points = 15;
if ($experience_total >= 20)
$issue_points = 20;
if ($experience_total >= 30)
$issue_points = 25;
if ($experience_total >= 40)
$issue_points = 30;
if ($experience_total >= 50)
$issue_points = 35;
if ($issue_points != 0)
$issue_points_txt = sprintf(_("You may issue up to %s points"),$issue_points);
}
if ($display_output)
{
output_summary_row (_("Assurance Points you received"),$sum_points,$sum_points_countable,$remark_points);
output_summary_row (_("Total Experience Points by Assurance"),$sum_experience,$sum_experience_countable,$remark_experience);
output_summary_row (_("Total Experience Points (other ways)"),$sum_experience_other,$sum_experience_other_countable,$remark_experience_other);
output_summary_row (_("Total Points")," ",$sum_points_countable + $sum_experience_countable + $sum_experience_other_countable,$issue_points_txt);
}
return $issue_points;
}
/**
* Render assurances given by the user
* @param int $userid
* @param int $support - set to 1 if the output is for the support interface
* @param string $ticketno - the ticket number set in the support interface
* @param int $log - if set to 1 also includes deleted assurances
*/
function output_given_assurances($userid, $support=0, $ticketno='', $log=0)
{
output_assurances_header(
_("Assurance Points You Issued"),
$support,
$log);
output_given_assurances_content(
$userid,
$sum_points,
$sum_experience,
$support,
$ticketno,
$log);
output_assurances_footer(
_("Total Points Issued"),
$sum_points,
_("Total Experience Points"),
$sum_experience,
$support,
$log);
}
/**
* Render assurances received by the user
* @param int $userid
* @param int $support - set to 1 if the output is for the support interface
* @param string $ticketno - the ticket number set in the support interface
* @param int $log - if set to 1 also includes deleted assurances
*/
function output_received_assurances($userid, $support=0, $ticketno='', $log=0)
{
output_assurances_header(
_("Assurance Points You Received"),
$support,
$log);
output_received_assurances_content(
$userid,
$sum_points,
$sum_experience,
$support,
$ticketno,
$log);
output_assurances_footer(
_("Total Points Received"),
$sum_points,
_("Total Experience Points"),
$sum_experience,
$support,
$log);
}
function output_summary($userid)
{
output_summary_header();
output_summary_content($userid,1);
output_summary_footer();
}
function output_end_of_page()
{
?>
<p>[ <a href='javascript:history.go(-1)'><?=_("Go Back")?></a> ]</p>
<?
}
//functions to do with recording user agreements
/**
* write_user_agreement()
* writes a new record to the table user_agreement
*
* @param mixed $memid
* @param mixed $document
* @param mixed $method
* @param mixed $comment
* @param integer $active
* @param integer $secmemid
* @return
*/
function write_user_agreement($memid, $document, $method, $comment, $active=1, $secmemid=0){
// write a new record to the table user_agreement
$query="insert into `user_agreements` set `memid`=".intval($memid).", `secmemid`=".intval($secmemid).
",`document`='".mysql_real_escape_string($document)."',`date`=NOW(), `active`=".intval($active).",`method`='".mysql_real_escape_string($method)."',`comment`='".mysql_real_escape_string($comment)."'" ;
$res = mysql_query($query);
}
/**
* get_user_agreement_status()
* returns 1 if the user has an entry for the given type in user_agreement, 0 if no entry is recorded
* @param mixed $memid
* @param string $type
* @return
*/
function get_user_agreement_status($memid, $type="CCA"){
$query="SELECT u.`document` FROM `user_agreements` u
WHERE u.`document` = '" . mysql_real_escape_string($type) . "' AND u.`memid`=" . intval($memid) ;
$res = mysql_query($query);
if(mysql_num_rows($res) <=0){
return 0;
}else{
return 1;
}
}
/**
* Get the first user_agreement entry of the requested type
* @param int $memid
* @param string $type - the type of user agreement, by default all
* agreements are listed
* @param int $active - whether to get active or passive agreements:
* 0 := passive
* 1 := active
* null := both
* @return array(string=>mixed) - an associative array containing
* 'document', 'date', 'method', 'comment', 'active'
*/
function get_first_user_agreement($memid, $type=null, $active=null){
$filter = '';
if (!is_null($type)) {
$filter .= " AND u.`document` = '".mysql_real_escape_string($type)."'";
}
if (!is_null($active)) {
$filter .= " AND u.`active` = ".intval($active);
}
$query="SELECT u.`document`, u.`date`, u.`method`, u.`comment`, u.`active` FROM `user_agreements` AS u
WHERE u.`memid`=".intval($memid)."
$filter
ORDER BY u.`date` LIMIT 1";
$res = mysql_query($query);
if(mysql_num_rows($res) >0){
$rec = mysql_fetch_assoc($res);
}else{
$rec=array();
}
return $rec;
}
/**
* Get the last user_agreement entry of the requested type
* @param int $memid
* @param string $type - the type of user agreement, by default all
* agreements are listed
* @param int $active - whether to get active or passive agreements:
* 0 := passive,
* 1 := active,
* null := both
* @return array(string=>mixed) - an associative array containing
* 'document', 'date', 'method', 'comment', 'active'
*/
function get_last_user_agreement($memid, $type=null, $active=null){
$filter = '';
if (!is_null($type)) {
$filter .= " AND u.`document` = '".mysql_real_escape_string($type)."'";
}
if (!is_null($active)) {
$filter .= " AND u.`active` = ".intval($active);
}
$query="SELECT u.`document`, u.`date`, u.`method`, u.`comment`, u.`active` FROM `user_agreements` AS u
WHERE u.`memid`=".intval($memid)."
$filter
ORDER BY u.`date` DESC LIMIT 1";
$res = mysql_query($query);
if(mysql_num_rows($res) >0){
$rec = mysql_fetch_assoc($res);
}else{
$rec=array();
}
return $rec;
}
/**
* Get the all user_agreement entries of the requested type
* @param int $memid
* @param string $type - the type of user agreement, by default all
* agreements are listed
* @param int $active - whether to get an active or passive agreements:
* 0 := passive,
* 1 := active,
* null := both
* @return resource - a mysql result set containing all agreements
*/
function get_user_agreements($memid, $type=null, $active=null){
$filter = '';
if (!is_null($type)) {
$filter .= " AND u.`document` = '".mysql_real_escape_string($type)."'";
}
if (!is_null($active)) {
$filter .= " AND u.`active` = ".intval($active);
}
$query="SELECT u.`document`, u.`date`, u.`method`, u.`comment`, u.`active` FROM `user_agreements` AS u
WHERE u.`memid`=".intval($memid)."
$filter
ORDER BY u.`date`";
return mysql_query($query);
}
/**
* delete_user_agreement()
* deletes all entries for a given type from user_agreement of a given user, if type is not given all
* @param mixed $memid
* @param string $type
* @return
*/
function delete_user_agreement($memid, $type=false){
if ($type === false) {
$filter = '';
} else {
$filter = " and `document` = '" . mysql_real_escape_string($type) . "'";
}
mysql_query("delete from `user_agreements` where `memid`=" . intval($memid) . $filter );
}
// functions for 6.php (assure somebody)
function AssureHead($confirmation,$checkname)
{
?>
<form method="post" action="wot.php">
<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper" width="600">
<tr>
<td colspan="2" class="title"><?=$confirmation?></td>
</tr>
<tr>
<td class="DataTD" colspan="2" align="left"><?=$checkname?></td>
</tr>
<?
}
function AssureTextLine($field1,$field2)
{
?>
<tr>
<td class="DataTD"><?=$field1.(empty($field1)?'':':')?></td>
<td class="DataTD"><?=$field2?></td>
</tr>
<?
}
function AssureBoxLine($type,$text,$checked)
{
?>
<tr>
<td class="DataTD"><input type="checkbox" name="<?=$type?>" value="1" <?=$checked?"checked":""?>></td>
<td class="DataTD"><?=$text?></td>
</tr>
<?
}
function AssureMethodLine($text,$methods,$remark)
{
if (count($methods) != 1) {
?>
<tr>
<td class="DataTD"><?=$text.(empty($text)?'':':')?></td>
<td class="DataTD">
<select name="method">
<?
foreach($methods as $val) {
?>
<option value="<?=$val?>"><?=$val?></option>
<?
}
?>
</select>
<br />
<?=$remark?>
</td>
</tr>
<?
} else {
?>
<input type="hidden" name="method" value="<?=$methods[0]?>" />
<?
}
}
function AssureInboxLine($type,$field,$value,$description)
{
?>
<tr>
<td class="DataTD"><?=$field.(empty($field)?'':':')?></td>
<td class="DataTD"><input type="text" name="<?=$type?>" value="<?=$value?>"><?=$description?></td>
</tr>
<?
}
function AssureFoot($oldid,$confirm)
{
?>
<tr>
<td class="DataTD" colspan="2">
<input type="submit" name="process" value="<?=$confirm?>" />
<input type="submit" name="cancel" value="<?=_("Cancel")?>" />
</td>
</tr>
</table>
<input type="hidden" name="pagehash" value="<?=$_SESSION['_config']['wothash']?>" />
<input type="hidden" name="oldid" value="<?=$oldid?>" />
</form>
<?
}
function account_email_delete($mailid){
//deletes an email entry from an acount
//revolkes all certifcates for that email address
//called from www/account.php if($process != "" && $oldid == 2)
//called from www/diputes.php if($type == "reallyemail") / if($action == "accept")
//called from account_delete
$mailid = intval($mailid);
revoke_all_client_cert($mailid);
$query = "update `email` set `deleted`=NOW() where `id`='$mailid'";
mysql_query($query);
}
function account_domain_delete($domainid){
//deletes an domain entry from an acount
//revolkes all certifcates for that domain address
//called from www/account.php if($process != "" && $oldid == 9)
//called from www/diputes.php if($type == "reallydomain") / if($action == "accept")
//called from account_delete
$domainid = intval($domainid);
revoke_all_server_cert($domainid);
mysql_query(
"update `domains`
set `deleted`=NOW()
where `id` = '$domainid'");
}
function account_delete($id, $arbno, $adminid){
//deletes an account following the deleted account routnie V3
// called from www/account.php if($oldid == 50 && $process != "")
//change password
$id = intval($id);
$arbno = mysql_real_escape_string($arbno);
$adminid = intval($adminid);
$pool = 'abcdefghijklmnopqrstuvwxyz';
$pool .= '0123456789!()ยง';
$pool .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
srand ((double)microtime()*1000000);
$password="";
for($index = 0; $index < 30; $index++)
{
$password .= substr($pool,(rand()%(strlen ($pool))), 1);
}
mysql_query("update `users` set `password`=sha1('".$password."') where `id`='".$id."'");
//create new mail for arbitration number
$query = "insert into `email` set `email`='".$arbno."@cacert.org',`memid`='".$id."',`created`=NOW(),`modified`=NOW(), `attempts`=-1";
mysql_query($query);
$emailid = mysql_insert_id();
//set new mail as default
$query = "update `users` set `email`='".$arbno."@cacert.org' where `id`='".$id."'";
mysql_query($query);
//delete all other email address
$query = "select `id` from `email` where `memid`='".$id."' and `id`!='".$emailid."'" ;
$res=mysql_query($query);
while($row = mysql_fetch_assoc($res)){
account_email_delete($row['id']);
}
//delete all domains
$query = "select `id` from `domains` where `memid`='".$id."'";
$res=mysql_query($query);
while($row = mysql_fetch_assoc($res)){
account_domain_delete($row['id']);
}
//clear alert settings
mysql_query(
"update `alerts` set
`general`='0',
`country`='0',
`regional`='0',
`radius`='0'
where `memid`='$id'");
//set default location
$query = "update `users` set `locid`='2256755', `regid`='243', `ccid`='12' where `id`='".$id."'";
mysql_query($query);
//clear listings
$query = "update `users` set `listme`=' ',`contactinfo`=' ' where `id`='".$id."'";
mysql_query($query);
//set lanuage to default
//set default language
mysql_query("update `users` set `language`='en_AU' where `id`='".$id."'");
//delete secondary langugaes
mysql_query("delete from `addlang` where `userid`='".$id."'");
//change secret questions
for($i=1;$i<=5;$i++){
$q="";
$a="";
for($index = 0; $index < 30; $index++)
{
$q .= substr($pool,(rand()%(strlen ($pool))), 1);
$a .= substr($pool,(rand()%(strlen ($pool))), 1);
}
$query = "update `users` set `Q$i`='$q', `A$i`='$a' where `id`='".$id."'";
mysql_query($query);
}
//change personal information to arbitration number and DOB=1900-01-01
$query = "update `users` set `fname`='".$arbno."',
`mname`='".$arbno."',
`lname`='".$arbno."',
`suffix`='".$arbno."',
`dob`='1900-01-01'
where `id`='".$id."'";
mysql_query($query);
//clear all admin and board flags
mysql_query(
"update `users` set
`assurer`='0',
`assurer_blocked`='0',
`codesign`='0',
`orgadmin`='0',
`ttpadmin`='0',
`locadmin`='0',
`admin`='0',
`adadmin`='0',
`tverify`='0',
`board`='0'
where `id`='$id'");
//block account
mysql_query("update `users` set `locked`='1' where `id`='$id'"); //, `deleted`=Now()
}
function check_email_exists($email){
// called from includes/account.php if($process != "" && $oldid == 1)
// called from includes/account.php if($oldid == 50 && $process != "")
$email = mysql_real_escape_string($email);
$query = "select 1 from `email` where `email`='$email' and `deleted`=0";
$res = mysql_query($query);
return mysql_num_rows($res) > 0;
}
function check_gpg_cert_running($uid,$cca=0){
//if $cca =0 if just expired, =1 if CCA retention +3 month should be obeyed
// called from includes/account.php if($oldid == 50 && $process != "")
$uid = intval($uid);
if (0==$cca) {
$query = "select 1 from `gpg` where `memid`='$uid' and `expire`>NOW()";
}else{
$query = "select 1 from `gpg` where `memid`='$uid' and `expire`>(NOW()-90*86400)";
}
$res = mysql_query($query);
return mysql_num_rows($res) > 0;
}
function check_client_cert_running($uid,$cca=0){
//if $cca =0 if just expired, =1 if CCA retention +3 month should be obeyed
// called from includes/account.php if($oldid == 50 && $process != "")
$uid = intval($uid);
if (0==$cca) {
$query1 = "select 1 from `emailcerts` where `memid`='$uid' and `expire`>NOW() and `revoked`<`created`";
$query2 = "select 1 from `emailcerts` where `memid`='$uid' and `revoked`>NOW()";
}else{
$query1 = "select 1 from `emailcerts` where `memid`='$uid' and `expire`>(NOW()-90*86400) and `revoked`<`created`";
$query2 = "select 1 from `emailcerts` where `memid`='$uid' and `revoked`>(NOW()-90*86400)";
}
$res = mysql_query($query1);
$r1 = mysql_num_rows($res)>0;
$res = mysql_query($query2);
$r2 = mysql_num_rows($res)>0;
return !!($r1 || $r2);
}
function check_server_cert_running($uid,$cca=0){
//if $cca =0 if just expired, =1 if CCA retention +3 month should be obeyed
// called from includes/account.php if($oldid == 50 && $process != "")
$uid = intval($uid);
if (0==$cca) {
$query1 = "
select 1 from `domaincerts` join `domains`
on `domaincerts`.`domid` = `domains`.`id`
where `domains`.`memid` = '$uid'
and `domaincerts`.`expire` > NOW()
and `domaincerts`.`revoked` < `domaincerts`.`created`";
$query2 = "
select 1 from `domaincerts` join `domains`
on `domaincerts`.`domid` = `domains`.`id`
where `domains`.`memid` = '$uid'
and `revoked`>NOW()";
}else{
$query1 = "
select 1 from `domaincerts` join `domains`
on `domaincerts`.`domid` = `domains`.`id`
where `domains`.`memid` = '$uid'
and `expire`>(NOW()-90*86400)
and `revoked`<`created`";
$query2 = "
select 1 from `domaincerts` join `domains`
on `domaincerts`.`domid` = `domains`.`id`
where `domains`.`memid` = '$uid'
and `revoked`>(NOW()-90*86400)";
}
$res = mysql_query($query1);
$r1 = mysql_num_rows($res)>0;
$res = mysql_query($query2);
$r2 = mysql_num_rows($res)>0;
return !!($r1 || $r2);
}
function check_is_orgadmin($uid){
// called from includes/account.php if($oldid == 50 && $process != "")
$uid = intval($uid);
$query = "select 1 from `org` where `memid`='$uid' and `deleted`=0";
$res = mysql_query($query);
return mysql_num_rows($res) > 0;
}
// revokation of certificates
function revoke_all_client_cert($mailid){
//revokes all client certificates for an email address
$mailid = intval($mailid);
$query = "select `emailcerts`.`id`
from `emaillink`,`emailcerts` where
`emaillink`.`emailid`='$mailid' and `emaillink`.`emailcertsid`=`emailcerts`.`id` and `emailcerts`.`revoked`=0
group by `emailcerts`.`id`";
$dres = mysql_query($query);
while($drow = mysql_fetch_assoc($dres)){
mysql_query("update `emailcerts` set `revoked`='1970-01-01 10:00:01', `disablelogin`=1 where `id`='".$drow['id']."'");
}
}
function revoke_all_server_cert($domainid){
//revokes all server certs for an domain
$domainid = intval($domainid);
$query =
"select `domaincerts`.`id`
from `domaincerts`
where `domaincerts`.`domid` = '$domainid'
union distinct
select `domaincerts`.`id`
from `domaincerts`, `domlink`
where `domaincerts`.`id` = `domlink`.`certid`
and `domlink`.`domid` = '$domainid'";
$dres = mysql_query($query);
while($drow = mysql_fetch_assoc($dres))
{
mysql_query(
"update `domaincerts`
set `revoked`='1970-01-01 10:00:01'
where `id` = '".$drow['id']."'
and `revoked` = 0");
}
}
function revoke_all_private_cert($uid){
//revokes all certificates linked to a personal accounts
//gpg revokation needs to be added to a later point
$uid=intval($uid);
$query = "select `id` from `email` where `memid`='".$uid."'";
$res=mysql_query($query);
while($row = mysql_fetch_assoc($res)){
revoke_all_client_cert($row['id']);
}
$query = "select `id` from `domains` where `memid`='".$uid."'";
$res=mysql_query($query);
while($row = mysql_fetch_assoc($res)){
revoke_all_server_cert($row['id']);
}
}
/**
* check_date_format()
* checks if the date is entered in the right date format YYYY-MM-DD and
* if the date is after the 1st January of the given year
*
* @param mixed $date
* @param integer $year
* @return
*/
function check_date_format($date, $year=2000){
if (!strpos($date,'-')) {
return FALSE;
}
$arr=explode('-',$date);
if ((count($arr)!=3)) {
return FALSE;
}
if (intval($arr[0])<=$year) {
return FALSE;
}
if (intval($arr[1])>12 or intval($arr[1])<=0) {
return FALSE;
}
if (intval($arr[2])>31 or intval($arr[2])<=0) {
return FALSE;
}
return checkdate( intval($arr[1]), intval($arr[2]), intval($arr[0]));
}
/**
* check_date_difference()
* returns false if the date is larger then today + time diffrence
*
* @param mixed $date
* @param integer $diff
* @return
*/
function check_date_difference($date, $diff=1){
return (strtotime($date)<=time()+$diff*86400);
}
/**
* Write some information to the adminlog
*
* @param int $uid - id of the user account
* @param int $adminid - id of the admin
* @param string $type - the operation that was performed on the user account
* @param string $info - the ticket / arbitration number or other information
* @return bool - true := success, false := error
*/
function write_se_log($uid, $adminid, $type, $info){
//records all support engineer actions changing a user account
$uid = intval($uid);
$adminid = intval($adminid);
$type = mysql_real_escape_string($type);
$info = mysql_real_escape_string($info);
$query="insert into `adminlog` (`when`, `uid`, `adminid`,`type`,`information`) values
(Now(), $uid, $adminid, '$type', '$info')";
return mysql_query($query);
}
/**
* Check if the entered information is a valid ticket or arbitration number
* @param string $ticketno
* @return bool
*/
function valid_ticket_number($ticketno){
//a arbitration case
//d dispute action
//s support case
//m board motion
$pattern='/[adsmADSM]\d{8}\.\d+/';
if (preg_match($pattern, $ticketno)) {
return true;
}
return false;
}
// function for handling account/43.php
/**
* Get all data of an account given by the id from the `users` table
* @param int $userid - account id
* @param int $deleted - states if deleted data should be visible , default = 0 - not visible
* @return resource - a mysql result set
*/
function get_user_data($userid, $deleted=0){
$userid = intval($userid);
$filter='';
if (0==$deleted) {
$filter .=' and `users`.`deleted`=0';
}
$query = "select * from `users` where `users`.`id`='$userid' ".$filter;
return mysql_query($query);
}
/**
* Get the alert settings for a user
* @param int $userid for the requested account
* @return array - associative array
*/
function get_alerts($userid){
return mysql_fetch_assoc(mysql_query("select * from `alerts` where `memid`='".intval($userid)."'"));
}
/**
* Get all email addresses linked to the account
* @param int $userid
* @param string $exclude - if given the email address will be excluded
* @param int $deleted - states if deleted data should be visible, default = 0 - not visible
* @return resource - a mysql result set
*/
function get_email_addresses($userid, $exclude, $deleted=0){
//should be entered in account/2.php
$userid = intval($userid);
$filter='';
if (0==$deleted) {
$filter .= ' and `deleted`=0';
}
if ($exclude) {
$filter .= " and `email`!='".mysql_real_escape_string($exclude)."'";
}
$query = "select * from `email` where `memid`='".$userid."' and `hash`='' ".$filter." order by `created`";
return mysql_query($query);
}
/**
* Get all domains linked to the account
* @param int $userid
* @param int $deleted - states if deleted data should be visible, default = 0 - not visible
* @return resource - a mysql result set
*/
function get_domains($userid, $deleted=0){
//should be entered in account/9.php
$userid = intval($userid);
$filter='';
if (0==$deleted) {
$filter .= ' and `deleted`=0';
}
$query = "select * from `domains` where `memid`='".$userid."' and `hash`=''".$filter." order by `created`";
return mysql_query($query);
}
/**
* Get all training results for the account
* @param int $userid
* @return resource - a mysql result set
*/
function get_training_results($userid){
//should be entered in account/55.php
$userid = intval($userid);
$query = "SELECT `CP`.`pass_date`, `CT`.`type_text`, `CV`.`test_text` ".
" FROM `cats_passed` AS CP, `cats_variant` AS CV, `cats_type` AS CT ".
" WHERE `CP`.`variant_id`=`CV`.`id` AND `CV`.`type_id`=`CT`.`id` AND `CP`.`user_id` ='".$userid."'".
" ORDER BY `CP`.`pass_date`";
return mysql_query($query);
}
/**
* Get all SE log entries for the account
* @param int $userid
* @return resource - a mysql result set
*/
function get_se_log($userid){
$userid = intval($userid);
$query = "SELECT `adminlog`.`when`, `adminlog`.`type`, `adminlog`.`information`, `users`.`fname`, `users`.`lname`
FROM `adminlog`, `users`
WHERE `adminlog`.`adminid` = `users`.`id` and `adminlog`.`uid`=".$userid."
ORDER BY `adminlog`.`when`";
return mysql_query($query);
}
/**
* Get all client certificates linked to the account
* @param int $userid
* @param int $viewall - states if expired certs should be visible, default = 0 - not visible
* @return resource - a mysql result set
*/
function get_client_certs($userid, $viewall=0){
//add to account/5.php
$userid = intval($userid);
$query = "select UNIX_TIMESTAMP(`emailcerts`.`created`) as `created`,
UNIX_TIMESTAMP(`emailcerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
UNIX_TIMESTAMP(`emailcerts`.`expire`) as `expired`,
`emailcerts`.`expire`,
`emailcerts`.`revoked` as `revoke`,
UNIX_TIMESTAMP(`emailcerts`.`revoked`) as `revoked`,
`emailcerts`.`id`,
`emailcerts`.`CN`,
`emailcerts`.`serial`,
`emailcerts`.`disablelogin`,
`emailcerts`.`description`
from `emailcerts`
where `emailcerts`.`memid`='".$userid."'";
if($viewall == 0)
{
$query .= " AND `emailcerts`.`revoked`=0 AND `emailcerts`.`renewed`=0";
$query .= " HAVING `timeleft` > 0";
}
$query .= " ORDER BY `emailcerts`.`modified` desc";
return mysql_query($query);
}
/**
* Get all server certs linked to the account
* @param int $userid
* @param int $viewall - states if expired certs should be visible, default = 0 - not visible
* @return resource - a mysql result set
*/
function get_server_certs($userid, $viewall=0){
//add to account/12.php
$userid = intval($userid);
$query = "select UNIX_TIMESTAMP(`domaincerts`.`created`) as `created`,
UNIX_TIMESTAMP(`domaincerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
UNIX_TIMESTAMP(`domaincerts`.`expire`) as `expired`,
`domaincerts`.`expire`,
`domaincerts`.`revoked` as `revoke`,
UNIX_TIMESTAMP(`revoked`) as `revoked`,
`domaincerts`.`CN`,
`domaincerts`.`serial`,
`domaincerts`.`id`,
`domaincerts`.`description`
from `domaincerts`,`domains`
where `domains`.`memid`='".$userid."' and `domaincerts`.`domid`=`domains`.`id`";
if($viewall == 0)
{
$query .= " AND `domaincerts`.`revoked`=0 AND `domaincerts`.`renewed`=0";
$query .= " HAVING `timeleft` > 0";
}
$query .= " ORDER BY `domaincerts`.`modified` desc";
return mysql_query($query);
}
/**
* Get all gpg certs linked to the account
* @param int $userid
* @param int $viewall - states if expired certs should be visible, default = 0 - not visible
* @return resource - a mysql result set
*/
function get_gpg_certs($userid, $viewall=0){
//add to gpg/2.php
$userid = intval($userid);
$query = $query = "select UNIX_TIMESTAMP(`issued`) as `issued`,
UNIX_TIMESTAMP(`expire`) - UNIX_TIMESTAMP() as `timeleft`,
UNIX_TIMESTAMP(`expire`) as `expired`,
`expire`, `id`, `level`, `email`, `keyid`, `description`
from `gpg` where `memid`='".$userid."'";
if ($viewall == 0) {
$query .= " HAVING `timeleft` > 0";
}
$query .= " ORDER BY `issued` desc";
return mysql_query($query);
}
/**
* Show the table header to the email table for the admin log
*/
function output_log_email_header(){
?>
<tr>
<td class="DataTD bold"><?= _("Email, primary bold") ?></td>
<td class="DataTD bold"><?= _("Created") ?></td>
<td class="DataTD bold"><?= _("Deleted") ?></td>
</tr>
<?
}
/**
* Show all email data for the admin log
* @param array $row - associative array containing the column data
* @param string $primary - if given the primary address is highlighted
*/
function output_log_email($row, $primary){
$style = '';
if ($row['deleted'] !== NULL_DATETIME) {
$style = ' deletedemailaddress';
} elseif ($primary == $row['email']) {
$style = ' primaryemailaddress';
}
?>
<tr>
<td class="DataTD<?=$style?>"><?=$row['email']?></td>
<td class="DataTD<?=$style?>"><?=$row['created']?></td>
<td class="DataTD<?=$style?>"><?=$row['deleted']?></td>
</tr>
<?
}
/**
* Show the table header to the domains table for the admin log
*/
function output_log_domains_header(){
?>
<tr>
<td class="DataTD bold"><?= _("Domain") ?></td>
<td class="DataTD bold"><?= _("Created") ?></td>
<td class="DataTD bold"><?= _("Deleted") ?></td>
</tr>
<?
}
/**
* Show the domain data for the admin log
* @param array $row - associative array containing the column data
*/
function output_log_domains($row){
$italic='';
if ($row['deleted'] !== NULL_DATETIME) {
$italic=' italic';
}
?>
<tr>
<td class="DataTD<?=$italic?>"><?=$row['domain']?></td>
<td class="DataTD<?=$italic?>"><?=$row['created']?></td>
<td class="DataTD<?=$italic?>"><?=$row['deleted']?></td>
</tr>
<?
}
/**
* Show the table header to the user agreement table for the admin log
*/
function output_log_agreement_header(){
?>
<tr>
<td class="DataTD bold"><?= _("Agreement") ?></td>
<td class="DataTD bold"><?= _("Date") ?></td>
<td class="DataTD bold"><?= _("Method") ?></td>
<td class="DataTD bold"><?= _("Active ") ?></td>
</tr>
<?
}
/**
* Show the agreement data for the admin log
* @param array $row - associative array containing the column data
*/
function output_log_agreement($row){
?>
<tr>
<td class="DataTD" ><?=$row['document']?></td>
<td class="DataTD" ><?=$row['date']?></td>
<td class="DataTD" ><?=$row['method']?></td>
<td class="DataTD"><?= ($row['active']==0)? _('passive'):_('active')?></td>
</tr>
<?
}
/**
* Show the table header to the training table
*/
function output_log_training_header(){
//should be entered in account/55.php
?>
<tr>
<td class="DataTD bold"><?= _("Agreement") ?></td>
<td class="DataTD bold"><?= _("Test") ?></td>
<td class="DataTD bold"><?= _("Variant") ?></td>
</tr>
<?
}
/**
* Show the training data
* @param array $row - associative array containing the column data
*/
function output_log_training($row){
//should be entered in account/55.php
?>
<tr>
<td class="DataTD"><?=$row['pass_date']?></td>
<td class="DataTD"><?=$row['type_text']?></td>
<td class="DataTD"><?=$row['test_text']?></td>
</tr>
<?
}
/**
* Show the table header to the SE log table for the admin log
* @param int $support - if support = 1 more information is visible
*/
function output_log_se_header($support=0){
?>
<tr>
<td class="DataTD bold"><?= _("Date") ?></td>
<td class="DataTD bold"><?= _("Type") ?></td>
<?
if (1 == $support) {
?>
<td class="DataTD bold"><?= _("Information") ?></td>
<td class="DataTD bold"><?= _("Admin") ?></td>
<?
}
?>
</tr>
<?
}
/**
* Show the SE log data for the admin log
* @param array $row - associative array containing the column data
* @param int $support - if support = 1 more information is visible
*/
function output_log_se($row, $support=0){
//should be entered in account/55.php
?>
<tr>
<td class="DataTD"><?=$row['when']?></td>
<td class="DataTD"><?=$row['type']?></td>
<?
if (1 == $support) {
?>
<td class="DataTD"><?=$row['information']?></td>
<td class="DataTD"><?=$row['fname'].' '.$row['lname']?></td>
<?
}
?>
</tr>
<?
}
/**
* Shows the table header to the client cert table
* @param int $support - if support = 1 some columns ar not visible
* @param bool $readonly - whether elements to modify data should be hidden, default is `true`
*/
function output_client_cert_header($support=0, $readonly=true){
//should be added to account/5.php
?>
<tr>
<?
if (!$readonly) {
?>
<td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
<?
}
?>
<td class="DataTD"><?=_("Status")?></td>
<td class="DataTD"><?=_("Email Address")?></td>
<td class="DataTD"><?=_("SerialNumber")?></td>
<td class="DataTD"><?=_("Revoked")?></td>
<td class="DataTD"><?=_("Expires")?></td>
<td class="DataTD"><?=_("Login")?></td>
<?
if (1 != $support) {
?>
<td colspan="2" class="DataTD"><?=_("Comment *")?></td>
<?
}
?>
</tr>
<?
}
/**
* Show the client cert data
* @param array $row - associative array containing the column data
* @param int $support - if support = 1 some columns are not visible
* @param bool $readonly - whether elements to modify data should be hidden, default is `true`
*/
function output_client_cert($row, $support=0, $readonly=true){
//should be entered in account/5.php
$verified="";
if ($row['timeleft'] > 0) {
$verified = _("Valid");
} else {
$verified = _("Expired");
}
if ($row['expired'] == 0) {
$verified = _("Pending");
}
if ($row['revoked'] == 0) {
$row['revoke'] = _("Not Revoked");
} else {
$verified = _("Revoked");
}
?>
<tr>
<?
if (!$readonly) {
if ($verified === _("Pending")) {
?>
<td class="DataTD">
<input type="checkbox" name="delid[]" value="<?=intval($row['id'])?>">
</td>
<?
} elseif ($verified === _("Revoked")) {
?>
<td class="DataTD"> </td>
<?
} else {
?>
<td class="DataTD">
<input type="checkbox" name="revokeid[]" value="<?=intval($row['id'])?>">
</td>
<?
}
}
?>
<td class="DataTD"><?=$verified?></td>
<?
if ($verified === _("Pending")) {
?>
<td class="DataTD"><?=(trim($row['CN'])=="" ? _("empty") : htmlspecialchars($row['CN']))?></td>
<?
} else {
?>
<td class="DataTD">
<a href="account.php?id=6&cert=<?=intval($row['id'])?>">
<?=(trim($row['CN'])=="" ? _("empty") : htmlspecialchars($row['CN']))?>
</a>
</td>
<?
}
?>
<td class="DataTD"><?=$row['serial']?></td>
<td class="DataTD"><?=$row['revoke']?></td>
<td class="DataTD"><?=$row['expire']?></td>
<td class="DataTD">
<input type="checkbox" name="disablelogin_<?=intval($row['id'])?>" value="1" <?=$row['disablelogin']?"":"checked='checked'"?> <?=$readonly?'disabled="disabled"':''?>/>
<input type="hidden" name="cert_<?=intval($row['id'])?>" value="1" />
</td>
<?
if (1 != $support) {
?>
<td class="DataTD">
<input name="comment_<?=intval($row['id'])?>" type="text" value="<?=htmlspecialchars($row['description'])?>" />
</td>
<?
if (!$readonly) {
?>
<td class="DataTD">
<input type="checkbox" name="check_comment_<?=intval($row['id'])?>" />
</td>
<?
}
}
?>
</tr>
<?
}
/**
* Show the table header to the server cert table
* @param int $support - if support = 1 some columns ar not visible
* @param bool $readonly - whether elements to modify data should be hidden, default is `true`
*/
function output_server_certs_header($support=0, $readonly=true){
//should be entered in account/12.php
?>
<tr>
<?
if (!$readonly) {
?>
<td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
<?
}
?>
<td class="DataTD"><?=_("Status")?></td>
<td class="DataTD"><?=_("CommonName")?></td>
<td class="DataTD"><?=_("SerialNumber")?></td>
<td class="DataTD"><?=_("Revoked")?></td>
<td class="DataTD"><?=_("Expires")?></td>
<?
if (1 != $support) {
?>
<td colspan="2" class="DataTD"><?=_("Comment *")?></td>
<?
}
?>
</tr>
<?
}
/**
* Show the server cert data
* @param array $row - associative array containing the column data
* @param int $support - if support = 1 some columns are not visible
* @param bool $readonly - whether elements to modify data should be hidden, default is `true`
*/
function output_server_certs($row, $support=0, $readonly=true){
//should be entered in account/12.php
$verified="";
if ($row['timeleft'] > 0) {
$verified = _("Valid");
} else {
$verified = _("Expired");
}
if ($row['expired'] == 0) {
$verified = _("Pending");
}
if ($row['revoked'] == 0) {
$row['revoke'] = _("Not Revoked");
} else {
$verified = _("Revoked");
}
?>
<tr>
<?
if (!$readonly) {
if ($verified === _("Pending")) {
?>
<td class="DataTD">
<input type="checkbox" name="delid[]" value="<?=intval($row['id'])?>"/>
</td>
<?
} elseif($verified === _("Revoked")) {
?>
<td class="DataTD"> </td>
<?
} else {
?>
<td class="DataTD">
<input type="checkbox" name="revokeid[]" value="<?=intval($row['id'])?>"/>
</td>
<?
}
}
?>
<td class="DataTD"><?=$verified?></td>
<?
if ($verified === _("Pending")) {
?>
<td class="DataTD"><?=htmlspecialchars($row['CN'])?></td>
<?
} else {
?>
<td class="DataTD">
<a href="account.php?id=15&cert=<?=intval($row['id'])?>">
<?=htmlspecialchars($row['CN'])?>
</a>
</td>
<?
}
?>
<td class="DataTD"><?=$row['serial']?></td>
<td class="DataTD"><?=$row['revoke']?></td>
<td class="DataTD"><?=$row['expire']?></td>
<?
if (1 != $support) {
?>
<td class="DataTD">
<input name="comment_<?=intval($row['id'])?>" type="text" value="<?=htmlspecialchars($row['description'])?>" />
</td>
<?
if (!$readonly) {
?>
<td class="DataTD">
<input type="checkbox" name="check_comment_<?=intval($row['id'])?>" />
</td>
<?
}
}
?>
</tr>
<?
}
/**
* Show the table header to the gpg cert table
* @param int $support - if support = 1 some columns ar not visible
* @param bool $readonly - whether elements to modify data should be hidden, default is `true`
*/
function output_gpg_certs_header($support=0, $readonly=true){
// $readonly is currently ignored but kept for consistency
?>
<tr>
<td class="DataTD"><?=_("Status")?></td>
<td class="DataTD"><?=_("Email Address")?></td>
<td class="DataTD"><?=_("Expires")?></td>
<td class="DataTD"><?=_("Key ID")?></td>
<?
if (1 != $support) {
?>
<td colspan="2" class="DataTD"><?=_("Comment *")?></td>
<?
}
?>
</tr>
<?
}
/**
* Show the gpg cert data
* @param array $row - associative array containing the column data
* @param int $support - if support = 1 some columns are not visible
* @param bool $readonly - whether elements to modify data should be hidden, default is `true`
*/
function output_gpg_certs($row, $support=0, $readonly=true){
//should be entered in account/55.php
$verified="";
if ($row['timeleft'] > 0) {
$verified = _("Valid");
} else {
$verified = _("Expired");
}
if ($row['expired'] == 0) {
$verified = _("Pending");
}
?>
<tr>
<td class="DataTD"><?=$verified?></td>
<?
if($verified == _("Pending")) {
?>
<td class="DataTD"><?=htmlspecialchars($row['email'])?></td>
<?
} else {
?>
<td class="DataTD">
<a href="gpg.php?id=3&cert=<?=intval($row['id'])?>">
<?=htmlspecialchars($row['email'])?>
</a>
</td>
<?
}
?>
<td class="DataTD"><?=$row['expire']?></td>
<?
if($verified == _("Pending")) {
?>
<td class="DataTD"><?=htmlspecialchars($row['keyid'])?></td>
<?
} else {
?>
<td class="DataTD">
<a href="gpg.php?id=3&cert=<?=intval($row['id'])?>">
<?=htmlspecialchars($row['keyid'])?>
</a>
</td>
<?
}
if (1 != $support) {
?>
<td class="DataTD">
<input name="comment_<?=intval($row['id'])?>" type="text" value="<?=htmlspecialchars($row['description'])?>" />
</td>
<?
if (!$readonly) {
?>
<td class="DataTD">
<input type="checkbox" name="check_comment_<?=intval($row['id'])?>" />
</td>
<?
}
}
?>
</tr>
<?
}
|