PageRenderTime 62ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/system/core/core.input.php

https://github.com/danboy/Croissierd
PHP | 828 lines | 603 code | 118 blank | 107 comment | 129 complexity | 6334a3133e420eec2b7d49bc778dc28f MD5 | raw file
  1. <?php
  2. /*
  3. =====================================================
  4. ExpressionEngine - by EllisLab
  5. -----------------------------------------------------
  6. http://expressionengine.com/
  7. -----------------------------------------------------
  8. Copyright (c) 2003 - 2010 EllisLab, Inc.
  9. =====================================================
  10. THIS IS COPYRIGHTED SOFTWARE
  11. PLEASE READ THE LICENSE AGREEMENT
  12. http://expressionengine.com/docs/license.html
  13. =====================================================
  14. File: core.input.php
  15. -----------------------------------------------------
  16. Purpose: This class fetches all input data from
  17. the super-global arrays (GET, POST, SERVER, COOKIE).
  18. =====================================================
  19. */
  20. if ( ! defined('EXT'))
  21. {
  22. exit('Invalid file request');
  23. }
  24. class Input {
  25. var $AGENT = ''; // The current user's browser data
  26. var $IP = ''; // The current user's IP address
  27. var $SID = ''; // Session ID extracted from the URI segments
  28. var $URI = ''; // The full URI query string: /weblog/comments/124/
  29. var $QSTR = ''; // Only the query segment of the URI: 124
  30. var $Pages_QSTR = ''; // For a Pages request, this contains the Entry ID for the Page
  31. var $SEGS = array(); // The segments of the query string in an array
  32. var $trim_input = TRUE;
  33. var $global_vars = array(); // The global vars from path.php
  34. var $whitelisted = 'n'; // Is this request whitelisted
  35. var $blacklisted = 'n'; // Is this request blacklisted.
  36. // These are reserved words that have special meaning when they are the first
  37. // segment of a URI string. Template groups can not be named any of these words
  38. var $reserved = array('css', 'trackback');
  39. var $make_safe = array('RET', 'XSS', 'URI', 'ACT');
  40. /** -----------------------------------
  41. /** Constructor
  42. /** -----------------------------------*/
  43. function Input()
  44. {
  45. global $REGX;
  46. $this->AGENT = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? '' : $REGX->xss_clean($_SERVER['HTTP_USER_AGENT']);
  47. $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
  48. }
  49. /* END */
  50. /** -----------------------------------
  51. /** Fetch incomming GET/POST/IP data
  52. /** -----------------------------------*/
  53. // All data is filtered for security
  54. function fetch_input_data()
  55. {
  56. global $PREFS, $REGX;
  57. /** -----------------------------------
  58. /** Fetch and pre-process Global Vars
  59. /** -----------------------------------*/
  60. if (is_array($this->global_vars) AND count($this->global_vars) > 0)
  61. {
  62. foreach($this->global_vars as $key => $val)
  63. {
  64. $this->global_vars[$this->clean_input_keys($key)] = $REGX->xss_clean($this->sanitize($this->clean_input_data($val)));
  65. }
  66. }
  67. /** -----------------------------------
  68. /** Fetch and pre-process GET data
  69. /** -----------------------------------*/
  70. if (is_array($_GET) AND count($_GET) > 0)
  71. {
  72. foreach($_GET as $key => $val)
  73. {
  74. $_GET[$this->clean_input_keys($key)] = $REGX->xss_clean($this->sanitize($this->clean_input_data($val)));
  75. }
  76. }
  77. /** -----------------------------------
  78. /** Fetch and pre-process POST data
  79. /** -----------------------------------*/
  80. if (is_array($_POST) AND count($_POST) > 0)
  81. {
  82. foreach($_POST as $key => $val)
  83. {
  84. if (is_array($val))
  85. {
  86. // Added this to deal with multi-select lists, as these are sent as a multi-dimensional array
  87. foreach($val as $k => $v)
  88. {
  89. $_POST[$this->clean_input_keys($key.'_'.$k)] = $this->clean_input_data($v);
  90. $_POST[$this->clean_input_keys($key)][$this->clean_input_keys($k)] = $this->clean_input_data($v);
  91. }
  92. }
  93. else
  94. {
  95. if (in_array($key, $this->make_safe))
  96. {
  97. $val = $REGX->xss_clean($this->sanitize($val));
  98. }
  99. $_POST[$this->clean_input_keys($key)] = $this->clean_input_data($val);
  100. }
  101. }
  102. }
  103. /** -----------------------------------
  104. /** Fetch and pre-process COOKIE data
  105. /** -----------------------------------*/
  106. if (is_array($_COOKIE) AND count($_COOKIE) > 0)
  107. {
  108. // Also get rid of specially treated cookies that might be set by a server
  109. // or silly application, that are of no use to a CI application anyway
  110. // but that when present will trip our 'Disallowed Key Characters' alarm
  111. // http://www.ietf.org/rfc/rfc2109.txt
  112. // note that the key names below are single quoted strings, and are not PHP variables
  113. unset($_COOKIE['$Version']);
  114. unset($_COOKIE['$Path']);
  115. unset($_COOKIE['$Domain']);
  116. foreach($_COOKIE as $key => $val)
  117. {
  118. $_COOKIE[$this->clean_input_keys($key)] = $REGX->xss_clean($this->clean_input_data($val));
  119. }
  120. }
  121. /** -----------------------------------
  122. /** Fetch the IP address
  123. /** -----------------------------------*/
  124. $CIP = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
  125. $RIP = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
  126. $FIP = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
  127. /* -------------------------------------------
  128. /* Hidden Configuration Variable
  129. /* - proxy_ips => List of proxies that may forward the ip address
  130. /* -------------------------------------------*/
  131. if ($PREFS->ini('proxy_ips') !== FALSE && $FIP && $RIP)
  132. {
  133. $proxies = preg_split('/[\s,]/', $PREFS->ini('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY);
  134. $proxies = is_array($proxies) ? $proxies : array($proxies);
  135. $this->IP = in_array($RIP, $proxies) ? $FIP : $RIP;
  136. }
  137. else
  138. {
  139. if ($CIP && $RIP) $this->IP = $CIP;
  140. elseif ($RIP) $this->IP = $RIP;
  141. elseif ($CIP) $this->IP = $CIP;
  142. elseif ($FIP) $this->IP = $FIP;
  143. }
  144. if (strstr($this->IP, ','))
  145. {
  146. $x = explode(',', $this->IP);
  147. $this->IP = trim(end($x));
  148. }
  149. if ( ! $REGX->valid_ip($this->IP))
  150. {
  151. $this->IP = '0.0.0.0';
  152. }
  153. unset($CIP);
  154. unset($RIP);
  155. unset($FIP);
  156. }
  157. /* END */
  158. /** -----------------------------------
  159. /** Filter GET data for security
  160. /** -----------------------------------*/
  161. function filter_get_data($request_type = 'PAGE')
  162. {
  163. global $FNS, $SESS;
  164. $filter_keys = TRUE;
  165. if (isset($_GET['BK']) AND isset($_GET['weblog_id']) AND isset($_GET['title']) AND isset($_GET['tb_url']) AND $SESS->userdata['admin_sess'] == 1 AND $request_type == 'CP')
  166. {
  167. if (in_array($this->GBL('weblog_id'), $FNS->fetch_assigned_weblogs()))
  168. {
  169. $filter_keys = FALSE;
  170. }
  171. }
  172. if (isset($_GET))
  173. {
  174. foreach($_GET as $key => $val)
  175. {
  176. if ($filter_keys == TRUE)
  177. {
  178. if (is_array($val))
  179. {
  180. exit('Invalid GET Data - Array');
  181. }
  182. elseif (preg_match("#(;|\?|exec\s*\(|system\s*\(|passthru\s*\(|cmd\s*\(|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $val))
  183. {
  184. exit('Invalid GET Data');
  185. }
  186. }
  187. }
  188. }
  189. }
  190. /* END */
  191. /** --------------------------------------
  192. /** Convert programatic characters to entities
  193. /** --------------------------------------*/
  194. function sanitize($str)
  195. {
  196. $bad = array('$', '(', ')', '%28', '%29');
  197. $good = array('&#36;', '&#40;', '&#41;', '&#40;', '&#41;');
  198. return str_replace($bad, $good, $str);
  199. }
  200. /* END */
  201. /** --------------------------------------
  202. /** Parse URI segments
  203. /** --------------------------------------*/
  204. function parse_uri($uri = '')
  205. {
  206. global $REGX;
  207. if ($uri != '')
  208. {
  209. // Don't use a reference on this or it messes up the CSS files
  210. $uri = $REGX->xss_clean($this->sanitize($REGX->trim_slashes($uri)));
  211. /** --------------------------------------
  212. /** Does URI contain a session ID?
  213. /** --------------------------------------*/
  214. // If so, trim it off and rebuild the URI
  215. if (substr($uri, 0, 2) == 'S=')
  216. {
  217. $ex = explode('/', $uri);
  218. $this->SID = substr($ex['0'], 2);
  219. $uri = '';
  220. if (count($ex) > 1)
  221. {
  222. for ($i = 1; $i < count($ex); $i++)
  223. {
  224. $uri .= $ex[$i].'/';
  225. }
  226. $uri = substr($uri, 0, -1);
  227. }
  228. }
  229. if ($uri != '')
  230. {
  231. $x = 0;
  232. $ex = explode("/", $uri);
  233. /** ---------------------------------------
  234. /** Maximum Number of Segments Check
  235. /** ---------------------------------------*/
  236. // Safety Check: If the URL contains more than 10 segments
  237. // we'll show an error message
  238. if (count($ex) > 10)
  239. {
  240. exit("Error: The URL contains too many segments.");
  241. }
  242. /** ---------------------------------------
  243. /** Is the first URI segment reserved?
  244. /** ---------------------------------------*/
  245. // Reserved segments are treated as Action requests so we'll
  246. // assign them as $_GET variables. We do this becuase these
  247. // reserved words are actually Action requests that don't come to
  248. // us as normal GET/POST requests.
  249. if (in_array($ex['0'], $this->reserved))
  250. {
  251. $_GET['ACT'] = $ex['0'];
  252. for ($i = 1; $i < count($ex); $i++)
  253. {
  254. $_GET['ACT_'.$i] = $ex[$i];
  255. }
  256. $x = 1;
  257. }
  258. /** ---------------------------------------
  259. /** Parse URI segments
  260. /** ---------------------------------------*/
  261. $n = 1;
  262. $uri = '';
  263. for ($i = $x; $i < count($ex); $i++)
  264. {
  265. // nothing naughty
  266. if (strpos($ex[$i], '=') !== FALSE && preg_match('#.*(\042|\047).+\s*=.*#i', $ex[$i]))
  267. {
  268. $ex[$i] = str_replace(array('"', "'", ' ', '='), '', $ex[$i]);
  269. }
  270. $this->SEGS[$n] = $ex[$i];
  271. $uri .= $ex[$i].'/';
  272. $n++;
  273. }
  274. $uri = substr($uri, 0, -1);
  275. // Does the URI contain the css request?
  276. // If so, assign it as a GET variable.
  277. // This only happens when the "force query string"
  278. // preference is set.
  279. if (substr($uri, 0, 4) == 'css=')
  280. {
  281. $_GET['css'] = substr($uri, 4);
  282. }
  283. // Reassign the full URI
  284. $this->URI = '/'.$uri.'/';
  285. }
  286. }
  287. }
  288. /* END */
  289. /** -----------------------------------------
  290. /** Parse out the $IN->QSTR variable
  291. /** -----------------------------------------*/
  292. function parse_qstr()
  293. {
  294. global $REGX;
  295. if ( ! $this->fetch_uri_segment(2))
  296. {
  297. $this->QSTR = 'index';
  298. }
  299. elseif ( ! $this->fetch_uri_segment(3))
  300. {
  301. $this->QSTR = $this->fetch_uri_segment(2);
  302. }
  303. else
  304. {
  305. $this->QSTR = preg_replace("|".'/'.preg_quote($this->fetch_uri_segment(1)).'/'.preg_quote($this->fetch_uri_segment(2))."|", '', $this->URI);
  306. }
  307. $this->QSTR = $REGX->trim_slashes($this->QSTR);
  308. }
  309. /* END */
  310. /** -----------------------------------------
  311. /** Clean global input data
  312. /** -----------------------------------------*/
  313. function clean_input_data($str)
  314. {
  315. if (is_array($str))
  316. {
  317. $new_array = array();
  318. foreach ($str as $key => $val)
  319. {
  320. $new_array[$this->clean_input_keys($key)] = $this->clean_input_data($val);
  321. }
  322. return $new_array;
  323. }
  324. $str = preg_replace("/(\015\012)|(\015)|(\012)/", "\n", $str);
  325. if ($this->trim_input == TRUE)
  326. {
  327. $str = str_replace("\t", ' ', $str);
  328. $str = trim($str);
  329. }
  330. if ( ! get_magic_quotes_gpc())
  331. {
  332. $str = addslashes($str);
  333. }
  334. return $str;
  335. }
  336. /* END */
  337. /** -------------------------------------
  338. /** Clean global input keys
  339. /** -------------------------------------*/
  340. // To prevent malicious users from trying to exploit keys
  341. // we make sure that keys are only named with alpha-numeric text
  342. function clean_input_keys($str)
  343. {
  344. if ( ! preg_match("#^[a-z0-9\:\_\/\-]+$#i", $str))
  345. {
  346. exit('Disallowed Key Characters');
  347. }
  348. if ( ! get_magic_quotes_gpc())
  349. {
  350. $str = addslashes($str);
  351. }
  352. return $str;
  353. }
  354. /* END */
  355. /** --------------------------------------------------
  356. /** Fetch a URI segment
  357. /** --------------------------------------------------*/
  358. function fetch_uri_segment($n = '')
  359. {
  360. return ( ! isset($this->SEGS[$n])) ? FALSE : $this->SEGS[$n];
  361. }
  362. /* END */
  363. /** --------------------------------------------------
  364. /** Retrieve Get/Post/Server/Cookie variables
  365. /** --------------------------------------------------*/
  366. function GBL($which, $type = 'GP')
  367. {
  368. global $PREFS;
  369. $allowed_types = array('GP', 'GET', 'POST', 'SERVER', 'COOKIE');
  370. if ( ! in_array($type, $allowed_types))
  371. return false;
  372. switch($type)
  373. {
  374. case 'GP' :
  375. if ( ! isset($_POST[$which]) )
  376. {
  377. if ( ! isset($_GET[$which]) )
  378. {
  379. return FALSE;
  380. }
  381. else
  382. return $_GET[$which];
  383. }
  384. else
  385. return $_POST[$which];
  386. break;
  387. case 'GET' : return ( ! isset($_GET[$which]) ) ? FALSE : $_GET[$which];
  388. break;
  389. case 'POST' : return ( ! isset($_POST[$which]) ) ? FALSE : $_POST[$which];
  390. break;
  391. case 'SERVER' : return ( ! isset($_SERVER[$which]) ) ? FALSE : $_SERVER[$which];
  392. break;
  393. case 'COOKIE' :
  394. $prefix = ( ! $PREFS->ini('cookie_prefix')) ? 'exp_' : $PREFS->ini('cookie_prefix').'_';
  395. return ( ! isset($_COOKIE[$prefix.$which]) ) ? FALSE : stripslashes($_COOKIE[$prefix.$which]);
  396. break;
  397. }
  398. }
  399. /* END */
  400. /** -------------------------------------
  401. /** Blacklist Checkers - Added EE 1.2
  402. /** -------------------------------------*/
  403. function check_blacklist()
  404. {
  405. global $DB, $REGX, $PREFS;
  406. /** ---------------------------
  407. /** Check the Referrer Too
  408. /** ---------------------------*/
  409. if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '')
  410. {
  411. $test_ref = $REGX->xss_clean($_SERVER['HTTP_REFERER']);
  412. if ( ! preg_match("#^http://\w+\.\w+\.\w*#", $test_ref))
  413. {
  414. if (substr($test_ref, 0, 7) == 'http://' AND substr($test_ref, 0, 11) != 'http://www.')
  415. {
  416. $test_ref = preg_replace("#^http://(.+?)#", "http://www.\\1", $test_ref);
  417. }
  418. }
  419. $_POST['HTTP_REFERER'] = $test_ref;
  420. }
  421. if (sizeof($_POST) == 0 OR ! $DB->table_exists('exp_blacklisted'))
  422. {
  423. unset($_POST['HTTP_REFERER']);
  424. return true;
  425. }
  426. /** ----------------------------
  427. /** Whitelisted Items
  428. /** ----------------------------*/
  429. $whitelisted_ip = array();
  430. $whitelisted_url = array();
  431. $whitelisted_agent = array();
  432. if ($DB->table_exists('exp_whitelisted'))
  433. {
  434. $results = $DB->query("SELECT whitelisted_type, whitelisted_value FROM exp_whitelisted
  435. WHERE whitelisted_value != ''");
  436. if ($results->num_rows > 0)
  437. {
  438. foreach($results->result as $row)
  439. {
  440. if ($row['whitelisted_type'] == 'url')
  441. {
  442. $whitelisted_url = explode('|', $row['whitelisted_value']);
  443. }
  444. elseif($row['whitelisted_type'] == 'ip')
  445. {
  446. $whitelisted_ip = explode('|', $row['whitelisted_value']);
  447. }
  448. elseif($row['whitelisted_type'] == 'agent')
  449. {
  450. $whitelisted_agent = explode('|', $row['whitelisted_value']);
  451. }
  452. }
  453. }
  454. }
  455. if ($PREFS->ini('cookie_domain') !== FALSE && $PREFS->ini('cookie_domain') != '')
  456. {
  457. $whitelisted_url[] = $PREFS->ini('cookie_domain');
  458. }
  459. $site_url = $PREFS->ini('site_url');
  460. $whitelisted_url[] = $site_url;
  461. if ( ! preg_match("#^http://\w+\.\w+\.\w*#", $site_url))
  462. {
  463. if (substr($site_url, 0, 7) == 'http://' AND substr($site_url, 0, 11) != 'http://www.')
  464. {
  465. $whitelisted_url[] = preg_replace("#^http://(.+?)#", "http://www.\\1", $site_url);
  466. }
  467. }
  468. /** -----------------------------
  469. /** Domain Names Array
  470. /** -----------------------------*/
  471. $domains = array('net','com','org','info', 'name','biz','us','de', 'uk');
  472. /** -----------------------------
  473. /** Blacklisted Checking
  474. /** -----------------------------*/
  475. $query = $DB->query("SELECT blacklisted_type, blacklisted_value FROM exp_blacklisted");
  476. if ($query->num_rows == 0)
  477. {
  478. unset($_POST['HTTP_REFERER']);
  479. return true;
  480. }
  481. foreach($query->result as $row)
  482. {
  483. if ($row['blacklisted_type'] == 'url' && $row['blacklisted_value'] != '' && $this->whitelisted != 'y')
  484. {
  485. $blacklist_values = explode('|', $row['blacklisted_value']);
  486. if ( ! is_array($blacklist_values) OR sizeof($blacklist_values) == 0)
  487. {
  488. continue;
  489. }
  490. foreach ($_POST as $key => $value)
  491. {
  492. // Smallest URL Possible
  493. // Or no external links
  494. if (is_array($value) OR strlen($value) < 8)
  495. {
  496. continue;
  497. }
  498. // Convert Entities Before Testing
  499. $value = $REGX->_html_entity_decode($value);
  500. $value .= ' ';
  501. // Clear period from the end of URLs
  502. $value = preg_replace("#(^|\s|\()((http://|http(s?)://|www\.)\w+[^\s\)]+)\.([\s\)])#i", "\\1\\2{{PERIOD}}\\4", $value);
  503. if (preg_match_all("/([f|ht]+tp(s?):\/\/[a-z0-9@%_.~#\/\-\?&=]+.)".
  504. "|(www.[a-z0-9@%_.~#\-\?&]+.)".
  505. "|([a-z0-9@%_~#\-\?&]*\.(".implode('|', $domains)."))/si", $value, $matches))
  506. {
  507. for($i = 0; $i < sizeof($matches['0']); $i++)
  508. {
  509. if ($key == 'HTTP_REFERER' OR $key == 'url')
  510. {
  511. $matches['0'][$i] = $value;
  512. }
  513. foreach($blacklist_values as $bad_url)
  514. {
  515. if ($bad_url != '' && stristr($matches['0'][$i], $bad_url) !== false)
  516. {
  517. $bad = 'y';
  518. /** --------------------------------------
  519. /** Check Bad Against Whitelist - URLs
  520. /** --------------------------------------*/
  521. if ( is_array($whitelisted_url) && sizeof($whitelisted_url) > 0)
  522. {
  523. $parts = explode('?',$matches['0'][$i]);
  524. foreach($whitelisted_url as $pure)
  525. {
  526. if ($pure != '' && stristr($parts['0'], $pure) !== false)
  527. {
  528. $bad = 'n';
  529. $this->whitelisted = 'y';
  530. break;
  531. }
  532. }
  533. }
  534. /** --------------------------------------
  535. /** Check Bad Against Whitelist - IPs
  536. /** --------------------------------------*/
  537. if ( is_array($whitelisted_ip) && sizeof($whitelisted_ip) > 0)
  538. {
  539. foreach($whitelisted_ip as $pure)
  540. {
  541. if ($pure != '' && strpos($this->IP, $pure) !== false)
  542. {
  543. $bad = 'n';
  544. $this->whitelisted = 'y';
  545. break;
  546. }
  547. }
  548. }
  549. if ($bad == 'y')
  550. {
  551. if ($key == 'HTTP_REFERER')
  552. {
  553. $this->blacklisted = 'y';
  554. }
  555. else
  556. {
  557. exit('Action Denied: Blacklisted Item Found'."\n<br/>".$matches['0'][$i]);
  558. }
  559. }
  560. else
  561. {
  562. break; // Free to move on
  563. }
  564. }
  565. }
  566. }
  567. }
  568. }
  569. }
  570. elseif($row['blacklisted_type'] == 'ip' && $row['blacklisted_value'] != '' && $this->whitelisted != 'y')
  571. {
  572. $blacklist_values = explode('|', $row['blacklisted_value']);
  573. if ( ! is_array($blacklist_values) OR sizeof($blacklist_values) == 0)
  574. {
  575. continue;
  576. }
  577. foreach($blacklist_values as $bad_ip)
  578. {
  579. if ($bad_ip != '' && stristr($this->IP, $bad_ip) !== false)
  580. {
  581. $bad = 'y';
  582. if ( is_array($whitelisted_ip) && sizeof($whitelisted_ip) > 0)
  583. {
  584. foreach($whitelisted_ip as $pure)
  585. {
  586. if ($pure != '' && strpos($this->IP, $pure) !== false)
  587. {
  588. $bad = 'n';
  589. $this->whitelisted = 'y';
  590. break;
  591. }
  592. }
  593. }
  594. if ($bad == 'y')
  595. {
  596. $this->blacklisted = 'y';
  597. break;
  598. }
  599. else
  600. {
  601. unset($_POST['HTTP_REFERER']);
  602. return true; // whitelisted, so end
  603. }
  604. }
  605. }
  606. }
  607. elseif($row['blacklisted_type'] == 'agent' && $row['blacklisted_value'] != '' && $this->AGENT != '' && $this->whitelisted != 'y')
  608. {
  609. $blacklist_values = explode('|', $row['blacklisted_value']);
  610. if ( ! is_array($blacklist_values) OR sizeof($blacklist_values) == 0)
  611. {
  612. continue;
  613. }
  614. foreach($blacklist_values as $bad_agent)
  615. {
  616. if ($bad_agent != '' && stristr($this->AGENT, $bad_agent) !== false)
  617. {
  618. $bad = 'y';
  619. if ( is_array($whitelisted_ip) && sizeof($whitelisted_ip) > 0)
  620. {
  621. foreach($whitelisted_ip as $pure)
  622. {
  623. if ($pure != '' && strpos($this->AGENT, $pure) !== false)
  624. {
  625. $bad = 'n';
  626. $this->whitelisted = 'y';
  627. break;
  628. }
  629. }
  630. }
  631. if ( is_array($whitelisted_agent) && sizeof($whitelisted_agent) > 0)
  632. {
  633. foreach($whitelisted_agent as $pure)
  634. {
  635. if ($pure != '' && strpos($this->agent, $pure) !== false)
  636. {
  637. $bad = 'n';
  638. $this->whitelisted = 'y';
  639. break;
  640. }
  641. }
  642. }
  643. if ($bad == 'y')
  644. {
  645. $this->blacklisted = 'y';
  646. }
  647. else
  648. {
  649. unset($_POST['HTTP_REFERER']);
  650. return true; // whitelisted, so end
  651. }
  652. }
  653. }
  654. }
  655. }
  656. unset($_POST['HTTP_REFERER']);
  657. return true;
  658. }
  659. /* END */
  660. }
  661. // END CLASS
  662. ?>