| version 1.46, 2007/12/03 16:24:58 |
version 1.47, 2008/05/01 14:37:50 |
|
|
| * http://platon.sk/projects/Metafox/ |
* http://platon.sk/projects/Metafox/ |
| */ |
*/ |
| |
|
| /* $Platon: Metafox/db.inc.php,v 1.45 2007-12-02 11:47:44 nepto Exp $ */ |
/* $Platon: Metafox/db.inc.php,v 1.46 2007-12-03 16:24:58 nepto Exp $ */ |
| |
|
| /* |
/* |
| * updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002 |
* updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002 |
| Line 28 require_once 'cfgldr.inc.php'; |
|
| Line 28 require_once 'cfgldr.inc.php'; |
|
| require_once 'functions.inc.php'; |
require_once 'functions.inc.php'; |
| require_once 'db-core/db-core.inc.php'; |
require_once 'db-core/db-core.inc.php'; |
| |
|
| |
function ezin_get_remote_addr($include_remote_host = false) /* {{{ */ |
| |
{ |
| |
$ret = array(); |
| |
foreach (array(($include_remote_host ? 'REMOTE_HOST' : 'REMOTE_ADDR'), |
| |
'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP') as $key) { |
| |
if (isset($_SERVER[$key]) && strlen($_SERVER[$key]) > 0) { |
| |
$ret[] = trim(stripslashes($_SERVER[$key])); |
| |
} |
| |
} |
| |
$ret = array_unique($ret); |
| |
$ret = join(' / ', $ret); |
| |
return $ret; |
| |
} /* }}} */ |
| |
|
| /* |
/* |
| * VALIDATION FUNCTIONS |
* VALIDATION FUNCTIONS |
| */ |
*/ |
| Line 958 function ezin_update_counts($author_id, |
|
| Line 972 function ezin_update_counts($author_id, |
|
| $author_id = intval($author_id); |
$author_id = intval($author_id); |
| $section_id = intval($section_id); |
$section_id = intval($section_id); |
| $article_id = intval($article_id); |
$article_id = intval($article_id); |
| $remote_addr = ezin_db_escape($_SERVER['REMOTE_ADDR']); |
$remote_addr = ezin_get_remote_addr(); |
| |
$remote_addr = ezin_db_escape($remote_addr); |
| $type_ids = array(); |
$type_ids = array(); |
| $all_type_ids = array(); |
$all_type_ids = array(); |
| if ($author_id > 0) { |
if ($author_id > 0) { |
| Line 1178 function ezin_save_message($data) /* {{{ |
|
| Line 1193 function ezin_save_message($data) /* {{{ |
|
| $data['parent'] = 0; |
$data['parent'] = 0; |
| } |
} |
| |
|
| $data['ip'] = array(); |
$data['ip'] = ezin_get_remote_addr(true); |
| foreach (array('REMOTE_HOST', 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR') as $key) { |
|
| if (isset($_SERVER[$key]) && strlen($_SERVER[$key]) > 0) { |
|
| $data['ip'][] = $_SERVER[$key]; |
|
| } |
|
| } |
|
| $data['ip'] = join(' / ', $data['ip']); |
|
| $data = ezin_db_escape($data); |
$data = ezin_db_escape($data); |
| |
|
| $query = sprintf('INSERT INTO %s' |
$query = sprintf('INSERT INTO %s' |
| Line 1215 function ezin_check_message_flood() /* { |
|
| Line 1224 function ezin_check_message_flood() /* { |
|
| if ($timeout <= 0) |
if ($timeout <= 0) |
| return 0; // no flood |
return 0; // no flood |
| |
|
| |
$ip = ezin_get_remote_addr(); |
| |
|
| $query = 'SELECT count(*) ' |
$query = 'SELECT count(*) ' |
| .' FROM ' . $ezin_sys['db']['tables']['messages'] |
.' FROM ' . $ezin_sys['db']['tables']['messages'] |
| .' WHERE ip LIKE "'.ezin_db_escape($_SERVER['REMOTE_ADDR']).'%"' |
.' WHERE ip LIKE "'.ezin_db_escape($ip).'%"' |
| .' AND UNIX_TIMESTAMP(SYSDATE()) - UNIX_TIMESTAMP(datetime)' |
.' AND UNIX_TIMESTAMP(SYSDATE()) - UNIX_TIMESTAMP(datetime)' |
| .' <= '.$timeout; |
.' <= '.$timeout; |
| |
|
| Line 1393 function ezin_save_feedback($section_id, |
|
| Line 1404 function ezin_save_feedback($section_id, |
|
| global $ezin_sys; |
global $ezin_sys; |
| global $ezin_db_handle; |
global $ezin_db_handle; |
| |
|
| $ip = array(); |
$ip = ezin_get_remote_addr(true); |
| foreach (array('REMOTE_HOST', 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR') as $key) { |
|
| if (isset($_SERVER[$key]) && strlen($_SERVER[$key]) > 0) { |
|
| $ip[] = $_SERVER[$key]; |
|
| } |
|
| } |
|
| $ip = stripslashes(join(' / ', $ip)); |
|
| $ua = stripslashes(@$_SERVER['HTTP_USER_AGENT']); |
$ua = stripslashes(@$_SERVER['HTTP_USER_AGENT']); |
| |
|
| $query = sprintf('INSERT INTO %s (id,datetime,section_id,ip,user_agent)' |
$query = sprintf('INSERT INTO %s (id,datetime,section_id,ip,user_agent)' |
| Line 1438 function ezin_save_email($section_id, $e |
|
| Line 1443 function ezin_save_email($section_id, $e |
|
| global $ezin_sys; |
global $ezin_sys; |
| global $ezin_db_handle; |
global $ezin_db_handle; |
| |
|
| $ip = array(); |
$ip = ezin_get_remote_addr(true); |
| foreach (array('REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR') as $key) { |
|
| isset($_SERVER[$key]) && $ip[] = $_SERVER[$key]; |
|
| } |
|
| $ip = stripslashes(join(' / ', $ip)); |
|
| $ua = stripslashes(@$_SERVER['HTTP_USER_AGENT']); |
$ua = stripslashes(@$_SERVER['HTTP_USER_AGENT']); |
| |
|
| $query = sprintf('INSERT INTO %s (email,id,dt_added,section_id,ip,user_agent)' |
$query = sprintf('INSERT INTO %s (email,id,dt_added,section_id,ip,user_agent)' |