-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind.php
More file actions
263 lines (247 loc) · 12.2 KB
/
Copy pathfind.php
File metadata and controls
263 lines (247 loc) · 12.2 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
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
<?php
/*
* Property of Writale
* All rights reserved
* Writale © 2013
*/
require_once realpath(dirname(__FILE__) . "/class/init.php");
require_once realpath(dirname(__FILE__) . "/control/session/saved.php");
require_once realpath(dirname(__FILE__) . "/control/general/cache.php");
if(isset($_GET['q']) && isset($_GET['ref']) && isset($_GET['s_n'])) {
if($_GET['s_n'] == $_SESSION['search_nonce']) {
$_SESSION['needle'] = $_GET['q'];
header("location: ${_protocol}${_SERVER['HTTP_HOST']}/find");
exit();
}
}
unset($_SESSION['search_nonce']);
if(isset($_SESSION['needle'])) {
$q = $_SESSION['needle'];
unset($_SESSION['needle']);
}
else if(isset($ht)){
$q = '#'.$ht;
}
else {
$q = '';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title> <?php if(isset($ht)) echo '#'.$ht; else echo 'Search Writale'; ?> </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Writale is a simple, powerful way to read and build social stories." />
<link rel="shortcut icon" type="image/x-icon" href="//<?php echo $_SERVER['HTTP_HOST'] ?>/resource/image/icon/favicon.ico" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/universal.css'; ?>" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/strydlg.css'; ?>" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/srh-0600-28022014.css'; ?>" />
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/common.js"></script>
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/feedact.js"></script>
</head>
<body class="search-body">
<?php
include realpath(dirname(__FILE__) . '/control/decorator/userpanel.php');
?>
<div id="general-outer-container">
<?php require realpath(dirname(__FILE__) . '/control/decorator/sidebar.php') ?>
<div id="general-middle-container">
<?php require realpath(dirname(__FILE__) . '/control/decorator/openstorypanel.php'); ?>
<div id="general-central-outline">
<div class="search-container">
<div class="inline" id="search-box">
<input type="text" id="search" value="<?php echo $q; ?>" />
</div>
<div class="button-std inline" id="search-button">
<img
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABjUlEQVQ4T7WUyytFURSH7y2E8kqSMOMv8IiJAZl4xchAMmKARJkYUEomoiQDUylRZCAjeWTkmYkZIyMz8hgJ3++2zu047XMG17Xra5+7917fWXvvs248luYWT7MvFiUs42XNUA5vcAE38BWVhEuYS8ACDEFGIPiK34NwGyYNCiU7hnoL+KZ/hhzItrEP+jY4dUmDwlUWDdvCA/oxeAC9aBRmTfxEXw2vQalfWMrkI2TCPnQ6MuhhbNfGJ+kXo4T9TK7bgirLzLUrbbUJjqAlSjjF5Dy8QKHLZGNL9BNwb9v+tdS/ZZ3RCnxCAejwXW2DwT44h4aoDOuY1LemNg7LDlsFY3eQD7pAJRGaobK9hBrLTlns+VZX8rwFjTam7JRlqFATtXAG3jd3yPM1FEMv5PmidTnt8O43uipFN7cJJcG3O36fmDR53mG1XMTCEWgF1bKqRXW8BjPQ5ZOrsjogIU3l3yaLuB2TeN4BHhLfcCpCxamatqEb5mDaM6cqVLwuTqWo8062vwj9nv8T/gBEPT8Viu/b3QAAAABJRU5ErkJggg=="
alt="Search" />
</div>
</div>
<div id="search-result-pane">
<div class="tiny-error" id="search-error"></div>
<div class="inline-top" id="search-result-container">
<div id="clear-placeholder">
Search Writale for stories, genres and people.
</div>
<div id="search-result">
</div>
<div id="loader-search">
<img
src="<?php echo $_protocol.$_SERVER['HTTP_HOST'].'/resource/image/misc/ajax-loader.gif'; ?>"
alt="" />
</div>
</div>
<div class="inline-top" id="search-detail">
<div id="search-detail-title">
Your previous searches
</div>
<div id="previous-search-result">
<?php
try {
$res = $_mysql->query("SELECT keyword FROM search WHERE userid='".$_SESSION['uid']."' ORDER BY RAND() LIMIT 8");
if($res->num_rows == 0)
echo 'None';
else {
while($row = $res->fetch_row()) {
echo '<a href="#">'.Filter::filterLength($row[0],20).'</a>';
}
}
} catch (Exception $ex) {
Util::__errorSummary(WRITALE_ERR_GEN,$ex);
}
?>
</div>
</div>
</div>
<?php require realpath(dirname(__FILE__) . '/control/decorator/pagefooter.php'); ?>
</div>
</div>
<div class="sidebar-right">
<div id="popular-searches">
<div id="popular-searches-text">
Popular searches
</div>
<div id="popular-searches-result">
<?php
try {
$res = FebQuery::getPopularSearches ();
if($res->num_rows == 0)
echo 'Nothing to show';
else {
while($row = $res->fetch_row()) {
echo '<a class="pale-blue-link bold" href="#">'.$row[0].'</a>';
}
}
} catch (Exception $ex) {
Util::__errorSummary(WRITALE_ERR_GEN, $ex);
}
?>
</div>
</div>
</div>
<span class="stretch"></span>
</div>
<?php
include realpath(dirname(__FILE__) . '/control/decorator/openstory.php');
include realpath(dirname(__FILE__) . '/control/decorator/utilbottom.php');
include realpath(dirname(__FILE__) . '/control/decorator/savedutil.php');
?>
<script>
(function () {
var find = (function () {
var
searchBox = _gAny('search'),
searchButton = _gAny('search-button'),
nError = _gAny('search-error'),
nResContainer = _gAny('search-result'),
nPlaceHolder = _gAny('clear-placeholder'),
nLoader = _gAny('loader-search'),
nPopSearches = _gAny('popular-searches-result'),
nPrevSearches = _gAny('previous-search-result'),
iOffset,
sQuery = searchBox.value.trim();
function init () {
searchBox.focus();
addEvent.call(searchButton, 'click', processQuery,false);
addEvent.call(searchBox,'keypress', function (e) {
var iKey;
iKey = e.which || e.keyCode;
if(iKey === 13)
processQuery ();
},false);
processPreviousSearch ();
processPopularSearches ();
if(sQuery.length !== 0) {
util.simulateClick(searchButton);
}
}
function processPreviousSearch () {
var node = util.firstChild(nPrevSearches);
while(node) {
addEvent.call(node,'click', function (e) {
util.stopDefault(e);
searchBox.value = this.innerHTML.trim();
util.simulateClick(searchButton);
},false);
node = util.nextSibling(node);
}
}
function processPopularSearches () {
var node = util.firstChild(nPopSearches);
while(node) {
addEvent.call(node,'click', function (e) {
util.stopDefault(e);
searchBox.value = this.innerHTML.trim();
util.simulateClick(searchButton);
},false);
node = util.nextSibling (node);
}
}
function processQuery () {
var sArg;
sQuery = searchBox.value.trim();
nResContainer.innerHTML = '';
nResContainer.style.visibility = 'hidden';
if(sQuery.length === 0)
util.genError(nError, "Your search query is empty.");
else {
fade(nLoader,1,20,false,true);
iOffset = 0;
removeEvent.call(this,'click',processQuery,false);
sArg = '?fnd=1&tofnd='+encodeURIComponent(sQuery)+'&ofst='+iOffset;
wxhr.sendGenericRequest(sArg,afterFinding,'/process/findresponse');
}
}
function afterFinding (res) {
var temp, nShowMore;
fade(nLoader,0,20,false,true);
addEvent.call(searchButton, 'click', processQuery,false);
fade(nResContainer,1);
if(res == -1)
util.genError(nError, "Something's Wrong. Please try later!");
else if(res == -2) {
nResContainer.innerHTML =
'<div class="s-failed">No results were found for <span class="bold">'+
sQuery
+'</span>.</div>';
}
else if(res == 2) {
if(!_gAny('no-more')) {
temp = $.createElement('div');
temp.className = 's-failed bold';
temp.id = 'no-more';
temp.innerHTML = 'Sorry! No more results.';
nResContainer.appendChild(temp);
}
}
else {
iOffset += 10;
fade(nError,0);
fade(nPlaceHolder,0);
temp = $.createElement('div');
temp.innerHTML = res;
while(temp.firstChild) {
nResContainer.appendChild(temp.firstChild);
}
if(nShowMore = _gAny('search-see-more'))
addEvent.call(nShowMore,'click', showMore,false);
}
}
function showMore () {
var
sArg = '?fnd=1&tofnd='+encodeURIComponent(sQuery)+'&ofst='+iOffset;
fade(nLoader,1,20,false,true);
this.parentNode.removeChild(this);
wxhr.sendGenericRequest(sArg,afterFinding,'/process/findresponse');
}
return {
init : init
};
})();
find.init();
})();
</script>
</body>
</html>