summary refs log tree commit diff stats
path: root/pages
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2008-12-21 10:00:50 -0500
committerStarla Insigna <hatkirby@fourisland.com>2008-12-21 10:00:50 -0500
commit828e3c4114241e3f0ca3dc481cc2daafc7cfc462 (patch)
treefe2a60547f032794b33cc545d2d51e10501e1db2 /pages
parentd2f5be11cca19c8ea159bb5add21322d4331ea51 (diff)
downloadfourisland-828e3c4114241e3f0ca3dc481cc2daafc7cfc462.tar.gz
fourisland-828e3c4114241e3f0ca3dc481cc2daafc7cfc462.tar.bz2
fourisland-828e3c4114241e3f0ca3dc481cc2daafc7cfc462.zip
Relocated includes/functions_quotes.php
As the functions defined in functions_quotes.php are only used in the
quotes.php module, there is no reason to have them located in a seperate
include file.
Diffstat (limited to 'pages')
-rwxr-xr-xpages/quotes.php172
1 files changed, 170 insertions, 2 deletions
diff --git a/pages/quotes.php b/pages/quotes.php index 55d12d9..d957722 100755 --- a/pages/quotes.php +++ b/pages/quotes.php
@@ -22,8 +22,6 @@ if (!defined('S_INCLUDE_FILE')) {define('S_INCLUDE_FILE',1);}
22 22
23require('headerproc.php'); 23require('headerproc.php');
24 24
25include('includes/functions_quotes.php');
26
27$pageCategory = 'quotes'; 25$pageCategory = 'quotes';
28 26
29if (isset($_GET['id'])) 27if (isset($_GET['id']))
@@ -141,4 +139,174 @@ if ((!isset($_GET['act'])) || ($_GET['act'] == 'latest'))
141 } 139 }
142} 140}
143 141
142function quote_generation($query, $origin, $page = 1, $quote_limit = 50, $page_limit = 10)
143{
144 $template = new FITemplate('quotes/browse');
145 if ($page != -1)
146 {
147 $template->adds_block('PAGENUMBERS',array('exi'=>1));
148 page_numbers($template, $origin, $quote_limit, $page, $page_limit);
149 $up_lim = ($quote_limit * $page);
150 $low_lim = $up_lim - $quote_limit;
151 $query .= "LIMIT $low_lim,$quote_limit";
152 }
153 $template->add('ORIGIN',$origin);
154
155 $getquotes2 = mysql_query($query);
156 $i=0;
157 while ($getquotes3[$i] = mysql_fetch_array($getquotes2))
158 {
159 $template->adds_block('QUOTES',array( 'NUMBER' => $getquotes3[$i]['id'],
160 'RATING' => $getquotes3[$i]['rating'],
161 'QUOTE' => parseSmilies(nl2br(stripslashes($getquotes3[$i]['quote'])))));
162
163 $i++;
164 }
165
166 $template->display();
167}
168
169function page_numbers($template, $origin, $quote_limit, $page_default, $page_limit)
170{
171 $numrows = countRows('rash_quotes');
172 $testrows = $numrows;
173 $pagenum = (($testrows + 1) / ($quote_limit > 0 ? $quote_limit : 1));
174
175 if (($page_limit % 2))
176 {
177 $page_limit++;
178 }
179 if (($page_limit < 2) || (!$page_limit))
180 {
181 $page_limit = 5;
182 }
183
184 $pagebase = 0;
185 do
186 {
187 $pagebase++;
188 $page_limit -= 2;
189 } while ($page_limit > 1);
190
191 $template->add('LORIGIN',strtolower($origin));
192 $template->add('MINUSTEN',(($page_default - 10) > 1) ? ($page_default - 10) : 1);
193
194 if ($page_default - $pagebase > 1)
195 {
196 $template->add('BDDD','...');
197 }
198
199 $i = $page_default - $pagebase;
200 do
201 {
202 if ($i > 0)
203 {
204 $template->adds_block('BPAGES',array('PAGENUM' => $i));
205 }
206 $i++;
207 } while ($i < $page_default);
208
209 $template->add('CURPAGE',$page_default);
210
211 $i = $page_default + 1;
212 do
213 {
214 if ($i <= $pagenum)
215 {
216 $template->adds_block('APAGES',array('PAGENUM' => $i));
217 }
218 $i++;
219 } while ($i < ($page_default + $pagebase + 1));
220
221 if (($page_default + $pagebase) < $pagenum)
222 {
223 $template->add('ADDD','...');
224 }
225
226 $template->add('PLUSTEN',(($page_default + 10) < $pagenum) ? ($page_default + 10) : $pagenum);
227 $template->add('LASTPAGE',$pagenum);
228}
229
230function user_quote_status($where, $quote_num, $template)
231{
232 $tracking_verdict = ip_track($where, $quote_num);
233 if ($where != 'flag')
234 {
235 switch ($tracking_verdict)
236 {
237 case 1:
238 $template->add('TRACKING',"Quote has been modified, and data of your action has been recorded in the database.");
239 break;
240 case 2:
241 $template->add('TRACKING',"Quote has been modified, your IP has been logged, and data of your action has been recorded in the database.");
242 break;
243 case 3:
244 $template->add('TRACKING',"You have already voted on this quote, please try again later.");
245 break;
246 }
247 }
248 return $tracking_verdict;
249}
250
251function ip_track($where, $quote_num)
252{
253 switch ($where)
254 {
255 case 'flag':
256 $where2 = 'vote';
257 break;
258 case 'vote':
259 $where2 = 'flag';
260 break;
261 }
262
263 $getip = "SELECT * FROM rash_tracking WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\"";
264 $getip2 = mysql_query($getip);
265 $getip3 = mysql_fetch_array($getip2);
266
267 if ($getip3['ip'] == $_SERVER['REMOTE_ADDR'])
268 {
269 $quote_array = explode(",", $getip3['quote_id']);
270 $quote_place = array_search($quote_num, $quote_array);
271 if (in_array($quote_num, $quote_array))
272 {
273 $where_result = explode(",", $getip3[$where]);
274 if (!isset($where_result[$quote_place]))
275 {
276 $where_result[$quote_place] = 1;
277 $where_result = implode(",", $where_result);
278 $setip = "UPDATE rash_tracking SET " . $where . " = \"" . $where_result . "\" WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\"";
279 $setip2 = mysql_query($getip);
280 return 1;
281 } else {
282 return 3;
283 }
284 } else {
285 $setip = "UPDATE rash_tracking SET " . $where . " = CONCAT(" . $where . ",\",1\"), " . $where2 . " = CONCAT(" . $where2 . ",\",0\"), quote_id = CONCAT(quote_id,\"," . $quote_num . "\") WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\"";
286 $setip2 = mysql_query($setip);
287 return 1;
288 }
289 } else {
290 $insip = "INSERT INTO rash_tracking (ip, quote_id, " . $where . ", " . $where2 . ") VALUES (\"" . $_SERVER['REMOTE_ADDR'] . "\", \"" . $quote_num . "\", 1, 0)";
291 $insip2 = mysql_query($insip);
292 return 2;
293 }
294}
295
296function verify_int($subject)
297{
298 $ymax = strlen($subject);
299 $y = 0;
300 while($y < $ymax)
301 {
302 if ((is_int((int)($subject{$y})) && (int)($subject{$y})) || (int)($subject{$y}) === 0 )
303 {
304 $y++;
305 } else {
306 return false;
307 }
308 }
309 return true;
310}
311
144?> 312?>