diff options
| -rwxr-xr-x | includes/functions_quotes.php | 195 | ||||
| -rwxr-xr-x | pages/quotes.php | 172 |
2 files changed, 170 insertions, 197 deletions
| diff --git a/includes/functions_quotes.php b/includes/functions_quotes.php deleted file mode 100755 index 7469152..0000000 --- a/includes/functions_quotes.php +++ /dev/null | |||
| @@ -1,195 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | /* | ||
| 3 | 444444444 | ||
| 4 | 4::::::::4 | ||
| 5 | 4:::::::::4 | ||
| 6 | 4::::44::::4 | ||
| 7 | 4::::4 4::::4 Four Island | ||
| 8 | 4::::4 4::::4 | ||
| 9 | 4::::4 4::::4 Written and maintained by Starla Insigna | ||
| 10 | 4::::444444::::444 | ||
| 11 | 4::::::::::::::::4 includes/functions_quotes.php | ||
| 12 | 4444444444:::::444 | ||
| 13 | 4::::4 Please do not use, reproduce or steal the | ||
| 14 | 4::::4 contents of this file without explicit | ||
| 15 | 4::::4 permission from Hatkirby. | ||
| 16 | 44::::::44 | ||
| 17 | 4::::::::4 | ||
| 18 | 4444444444 | ||
| 19 | */ | ||
| 20 | |||
| 21 | if (!defined('S_INCLUDE_FILE')) {define('S_INCLUDE_FILE',1);} | ||
| 22 | |||
| 23 | require('headerproc.php'); | ||
| 24 | |||
| 25 | function quote_generation($query, $origin, $page = 1, $quote_limit = 50, $page_limit = 10) | ||
| 26 | { | ||
| 27 | $template = new FITemplate('quotes/browse'); | ||
| 28 | if ($page != -1) | ||
| 29 | { | ||
| 30 | $template->adds_block('PAGENUMBERS',array('exi'=>1)); | ||
| 31 | page_numbers($template, $origin, $quote_limit, $page, $page_limit); | ||
| 32 | $up_lim = ($quote_limit * $page); | ||
| 33 | $low_lim = $up_lim - $quote_limit; | ||
| 34 | $query .= "LIMIT $low_lim,$quote_limit"; | ||
| 35 | } | ||
| 36 | $template->add('ORIGIN',$origin); | ||
| 37 | |||
| 38 | $getquotes2 = mysql_query($query); | ||
| 39 | $i=0; | ||
| 40 | while ($getquotes3[$i] = mysql_fetch_array($getquotes2)) | ||
| 41 | { | ||
| 42 | $template->adds_block('QUOTES',array( 'NUMBER' => $getquotes3[$i]['id'], | ||
| 43 | 'RATING' => $getquotes3[$i]['rating'], | ||
| 44 | 'QUOTE' => parseSmilies(nl2br(stripslashes($getquotes3[$i]['quote']))))); | ||
| 45 | |||
| 46 | $i++; | ||
| 47 | } | ||
| 48 | |||
| 49 | $template->display(); | ||
| 50 | } | ||
| 51 | |||
| 52 | function page_numbers($template, $origin, $quote_limit, $page_default, $page_limit) | ||
| 53 | { | ||
| 54 | $numrows = countRows('rash_quotes'); | ||
| 55 | $testrows = $numrows; | ||
| 56 | $pagenum = (($testrows + 1) / ($quote_limit > 0 ? $quote_limit : 1)); | ||
| 57 | |||
| 58 | if (($page_limit % 2)) | ||
| 59 | { | ||
| 60 | $page_limit++; | ||
| 61 | } | ||
| 62 | if (($page_limit < 2) || (!$page_limit)) | ||
| 63 | { | ||
| 64 | $page_limit = 5; | ||
| 65 | } | ||
| 66 | |||
| 67 | $pagebase = 0; | ||
| 68 | do | ||
| 69 | { | ||
| 70 | $pagebase++; | ||
| 71 | $page_limit -= 2; | ||
| 72 | } while ($page_limit > 1); | ||
| 73 | |||
| 74 | $template->add('LORIGIN',strtolower($origin)); | ||
| 75 | $template->add('MINUSTEN',(($page_default - 10) > 1) ? ($page_default - 10) : 1); | ||
| 76 | |||
| 77 | if ($page_default - $pagebase > 1) | ||
| 78 | { | ||
| 79 | $template->add('BDDD','...'); | ||
| 80 | } | ||
| 81 | |||
| 82 | $i = $page_default - $pagebase; | ||
| 83 | do | ||
| 84 | { | ||
| 85 | if ($i > 0) | ||
| 86 | { | ||
| 87 | $template->adds_block('BPAGES',array('PAGENUM' => $i)); | ||
| 88 | } | ||
| 89 | $i++; | ||
| 90 | } while ($i < $page_default); | ||
| 91 | |||
| 92 | $template->add('CURPAGE',$page_default); | ||
| 93 | |||
| 94 | $i = $page_default + 1; | ||
| 95 | do | ||
| 96 | { | ||
| 97 | if ($i <= $pagenum) | ||
| 98 | { | ||
| 99 | $template->adds_block('APAGES',array('PAGENUM' => $i)); | ||
| 100 | } | ||
| 101 | $i++; | ||
| 102 | } while ($i < ($page_default + $pagebase + 1)); | ||
| 103 | |||
| 104 | if (($page_default + $pagebase) < $pagenum) | ||
| 105 | { | ||
| 106 | $template->add('ADDD','...'); | ||
| 107 | } | ||
| 108 | |||
| 109 | $template->add('PLUSTEN',(($page_default + 10) < $pagenum) ? ($page_default + 10) : $pagenum); | ||
| 110 | $template->add('LASTPAGE',$pagenum); | ||
| 111 | } | ||
| 112 | |||
| 113 | function user_quote_status($where, $quote_num, $template) | ||
| 114 | { | ||
| 115 | $tracking_verdict = ip_track($where, $quote_num); | ||
| 116 | if ($where != 'flag') | ||
| 117 | { | ||
| 118 | switch ($tracking_verdict) | ||
| 119 | { | ||
| 120 | case 1: | ||
| 121 | $template->add('TRACKING',"Quote has been modified, and data of your action has been recorded in the database."); | ||
| 122 | break; | ||
| 123 | case 2: | ||
| 124 | $template->add('TRACKING',"Quote has been modified, your IP has been logged, and data of your action has been recorded in the database."); | ||
| 125 | break; | ||
| 126 | case 3: | ||
| 127 | $template->add('TRACKING',"You have already voted on this quote, please try again later."); | ||
| 128 | break; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | return $tracking_verdict; | ||
| 132 | } | ||
| 133 | |||
| 134 | function ip_track($where, $quote_num) | ||
| 135 | { | ||
| 136 | switch ($where) | ||
| 137 | { | ||
| 138 | case 'flag': | ||
| 139 | $where2 = 'vote'; | ||
| 140 | break; | ||
| 141 | case 'vote': | ||
| 142 | $where2 = 'flag'; | ||
| 143 | break; | ||
| 144 | } | ||
| 145 | |||
| 146 | $getip = "SELECT * FROM rash_tracking WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; | ||
| 147 | $getip2 = mysql_query($getip); | ||
| 148 | $getip3 = mysql_fetch_array($getip2); | ||
| 149 | |||
| 150 | if ($getip3['ip'] == $_SERVER['REMOTE_ADDR']) | ||
| 151 | { | ||
| 152 | $quote_array = explode(",", $getip3['quote_id']); | ||
| 153 | $quote_place = array_search($quote_num, $quote_array); | ||
| 154 | if (in_array($quote_num, $quote_array)) | ||
| 155 | { | ||
| 156 | $where_result = explode(",", $getip3[$where]); | ||
| 157 | if (!isset($where_result[$quote_place])) | ||
| 158 | { | ||
| 159 | $where_result[$quote_place] = 1; | ||
| 160 | $where_result = implode(",", $where_result); | ||
| 161 | $setip = "UPDATE rash_tracking SET " . $where . " = \"" . $where_result . "\" WHERE ip = \"" . $_SERVER['REMOTE_ADDR'] . "\""; | ||
| 162 | $setip2 = mysql_query($getip); | ||
| 163 | return 1; | ||
| 164 | } else { | ||
| 165 | return 3; | ||
| 166 | } | ||
| 167 | } else { | ||
| 168 | $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'] . "\""; | ||
| 169 | $setip2 = mysql_query($setip); | ||
| 170 | return 1; | ||
| 171 | } | ||
| 172 | } else { | ||
| 173 | $insip = "INSERT INTO rash_tracking (ip, quote_id, " . $where . ", " . $where2 . ") VALUES (\"" . $_SERVER['REMOTE_ADDR'] . "\", \"" . $quote_num . "\", 1, 0)"; | ||
| 174 | $insip2 = mysql_query($insip); | ||
| 175 | return 2; | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 179 | function verify_int($subject) | ||
| 180 | { | ||
| 181 | $ymax = strlen($subject); | ||
| 182 | $y = 0; | ||
| 183 | while($y < $ymax) | ||
| 184 | { | ||
| 185 | if ((is_int((int)($subject{$y})) && (int)($subject{$y})) || (int)($subject{$y}) === 0 ) | ||
| 186 | { | ||
| 187 | $y++; | ||
| 188 | } else { | ||
| 189 | return false; | ||
| 190 | } | ||
| 191 | } | ||
| 192 | return true; | ||
| 193 | } | ||
| 194 | |||
| 195 | ?> | ||
| 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 | ||
| 23 | require('headerproc.php'); | 23 | require('headerproc.php'); |
| 24 | 24 | ||
| 25 | include('includes/functions_quotes.php'); | ||
| 26 | |||
| 27 | $pageCategory = 'quotes'; | 25 | $pageCategory = 'quotes'; |
| 28 | 26 | ||
| 29 | if (isset($_GET['id'])) | 27 | if (isset($_GET['id'])) |
| @@ -141,4 +139,174 @@ if ((!isset($_GET['act'])) || ($_GET['act'] == 'latest')) | |||
| 141 | } | 139 | } |
| 142 | } | 140 | } |
| 143 | 141 | ||
| 142 | function 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 | |||
| 169 | function 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 | |||
| 230 | function 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 | |||
| 251 | function 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 | |||
| 296 | function 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 | ?> |
