This repository has been archived by the owner on Apr 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchtable.php
173 lines (151 loc) · 5.79 KB
/
searchtable.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
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
<?php
require_once("config.php");
require_once("library/adcdb.php");
require_once("library/lib.php");
global $cache_link_id_to_nice_url;
global $mode;
$mode = 1; // Links will be used from main pages
$query = "SELECT acts_shows.title, acts_shows.id AS showid, acts_shows_refs.ref AS url, MAX(acts_performances.enddate) as enddate, MIN(acts_performances.startdate) as startdate, (1000000 - ABS(to_days(MAX(acts_performances.enddate))-to_days(NOW()))) AS sindex, acts_shows.venid AS venid, acts_shows.venue AS venue FROM acts_shows LEFT JOIN acts_performances ON acts_shows.id=acts_performances.sid INNER JOIN acts_shows_refs ON acts_shows.primaryref = acts_shows_refs.refid WHERE acts_shows.authorizeid IS NOT NULL AND enddate<'2034-01-01' GROUP BY acts_shows.id";
$shows = sqlQuery($query, $adcdb) or die(SqlEr());
$query = "SELECT acts_people_data.name AS name, acts_people_data.id AS id, COUNT(DISTINCT(acts_shows_people_link.sid)) AS numshows, MIN(acts_performances.startdate) AS start, MAX(acts_performances.enddate) AS end, (TO_DAYS(MAX(acts_performances.enddate))-TO_DAYS(NOW()))/5+COUNT(DISTINCT(acts_shows_people_link.sid)) AS sindex FROM acts_people_data INNER JOIN acts_shows_people_link ON acts_shows_people_link.pid=acts_people_data.id INNER JOIN acts_shows ON acts_shows_people_link.sid = acts_shows.id INNER JOIN acts_performances ON acts_performances.sid=acts_shows.id WHERE acts_shows.authorizeid IS NOT NULL GROUP BY acts_shows_people_link.pid HAVING numshows > 0";
$people = sqlQuery($query, $adcdb) or die(SqlEr());
$query = "SELECT id,fulltitle FROM acts_pages WHERE mode = 'filtered' AND parentid != -1";
$infobase = sqlQuery($query, $adcdb) or die(SqlEr());
$query = "SELECT id,fulltitle FROM acts_pages WHERE mode != 'filtered' AND searchable = 1 AND parentid != -1";
$pages = sqlQuery($query, $adcdb) or die(SqlEr());
SqlQuery("DELETE FROM acts_search_cache WHERE obsolete = 1") or die(SqlEr());
SqlQuery("UPDATE acts_search_cache SET obsolete = 1") or die(SqlEr());
// SqlQuery("ALTER TABLE acts_search_cache ADD COLUMN (linkcode VARCHAR(2000))") or die(sqlEr());
$insertquery = "INSERT INTO acts_search_cache (keyword, text, type, url, linkcode, sindex) VALUES ";
$i=0;
while($row = mysql_fetch_assoc($shows)) {
$keyword = $row['title'];
$text = "";
if(strtotime($row['enddate'])>time() and strtotime($row['startdate'])>time())
{
$text.=datesByTerm($row['startdate'],$row['enddate']);
}
else if(strtotime($row['enddate'])>time())
{
$text.= "Finishes ".dateFormat(strtotime($row['enddate']));
}
else
{
$text.= date("M Y",strtotime($row['enddate']));
}
$text.= "<br/>".venueName($row);
$url = "/shows/".$row['url'];
$sindex = $row['sindex'];
if ($i > 0)
{
$insertquery .=" ,";
}
$i++;
$keyword = addslashes($keyword);
$url = addslashes($url);
$text = addslashes($text);
$linkcode = addslashes(startLink(104, array('showid'=>$row['showid'], 'PHPSESSID'=>'NOSET'), True));
$insertquery.= "('$keyword', '$text', 'show', '$url', '$linkcode', '$sindex')";
if ($i > 100)
{
echo htmlspecialchars($insertquery)."<br />";
SqlQuery($insertquery, $adcdb) or die(SqlEr());
$insertquery = "INSERT INTO acts_search_cache (keyword, text, type, url, linkcode, sindex) VALUES ";
$i=0;
}
}
while($row = mysql_fetch_assoc($people))
{
$keyword = $row['name'];
$text = "";
if(strtotime($row['end'])>strtotime("-6 months")) $text.= "Active (Shows: ".$row['numshows'].")";
else
{
$begin = date("M y",strtotime($row['start']));
$end = date("M y",strtotime($row['end']));
if($begin!=$end)
{
$text.= "was active ".$begin." - ".$end."<br/> (Shows: ".$row['numshows'].")";
}
else
{
$text.= "involved ".$end;
}
}
$url = "/person?person=".$row['id'];
$sindex = $row['sindex'];
if ($i > 0)
{
$insertquery .=" ,";
}
$i++;
$url = addslashes($url);
$keyword = addslashes($keyword);
$text = addslashes($text);
$linkcode = addslashes(startLink(105, array("person"=>$row['id'],"PHPSESSID"=>"NOSET"), True));
$insertquery.= "('$keyword', '$text', 'person', '$url', '$linkcode', '$sindex')";
if ($i > 100)
{
echo htmlspecialchars($insertquery)."<br />";
SqlQuery($insertquery, $adcdb) or die(SqlEr());
$insertquery = "INSERT INTO acts_search_cache (keyword, text, type, url, linkcode, sindex) VALUES ";
$i=0;
}
}
while($row = mysql_fetch_assoc($pages))
{
$keyword = $row['fulltitle'];
$text = "";
$sindex = 0;
if (!isset($cache_link_id_to_nice_url[$row['id']]))
continue;
$url = $cache_link_id_to_nice_url[$row['id']];
if ($i > 0)
{
$insertquery .=" ,";
}
$i++;
$url = addslashes($url);
$keyword = addslashes($keyword);
$text.='camdram.net'.$cache_link_id_to_nice_url[$row['id']];
$text = addslashes($text);
$linkcode = addslashes(startLink($row['id'], array("PHPSESSID"=>"NOSET"), True));
$insertquery.= "('$keyword', '$text', 'page', '$url', '$linkcode', '$sindex')";
if ($i > 100)
{
echo htmlspecialchars($insertquery)."<br />";
SqlQuery($insertquery, $adcdb) or die(SqlEr());
$insertquery = "INSERT INTO acts_search_cache (keyword, text, type, url, linkcode, sindex) VALUES ";
$i=0;
}
}
while($row = mysql_fetch_assoc($infobase))
{
$keyword = $row['fulltitle'];
$text = "";
$sindex = 0;
$url = $cache_link_id_to_nice_url[$row['id']];
if ($i > 0)
{
$insertquery .=" ,";
}
$i++;
$url = addslashes($url);
$keyword = addslashes($keyword);
$text = addslashes($text);
$text.="[infobase] camdram.net".$url;
$linkcode = addslashes(startLink($row['id'], array("PHPSESSID"=>"NOSET"), True));
$insertquery.= "('$keyword', '$text', 'infobase', '$url', '$linkcode', '$sindex')";
if ($i > 100)
{
echo htmlspecialchars($insertquery)."<br />";
SqlQuery($insertquery, $adcdb) or die(SqlEr());
$insertquery = "INSERT INTO acts_search_cache (keyword, text, type, url, linkcode, sindex) VALUES ";
$i=0;
}
}
if ($i > 0)
{
SqlQuery($insertquery, $adcdb) or die(SqlEr);
}
?>