mirror of
https://github.com/Mibew/java.git
synced 2025-01-23 01:50:34 +03:00
Split chatsitevisitor table into chatsitevisitor and visitedpage
This commit is contained in:
parent
856123de48
commit
12b0883686
@ -119,7 +119,6 @@ $dbtables = array(
|
||||
"firsttime" => "datetime NOT NULL DEFAULT 0",
|
||||
"lasttime" => "datetime NOT NULL DEFAULT 0",
|
||||
"entry" => "text NOT NULL",
|
||||
"path" => "text NOT NULL",
|
||||
"details" => "text NOT NULL",
|
||||
"invited" => "tinyint(1) NOT NULL DEFAULT 0",
|
||||
"invitationtime" => "datetime",
|
||||
@ -128,6 +127,13 @@ $dbtables = array(
|
||||
"chats" => "INT NOT NULL DEFAULT 0",
|
||||
"threadid" => "INT references ${mysqlprefix}chatthread(threadid) on delete set null"
|
||||
),
|
||||
|
||||
"${mysqlprefix}visitedpage" => array(
|
||||
"pageid" => "INT NOT NULL auto_increment PRIMARY KEY",
|
||||
"address" => "varchar(1024)",
|
||||
"visittime" => "datetime NOT NULL DEFAULT 0",
|
||||
"visitorid" => "INT",
|
||||
),
|
||||
);
|
||||
|
||||
$dbtables_indexes = array(
|
||||
@ -136,6 +142,9 @@ $dbtables_indexes = array(
|
||||
),
|
||||
"${mysqlprefix}chatsitevisitor" => array(
|
||||
"threadid" => "threadid"
|
||||
),
|
||||
"${mysqlprefix}visitedpage" => array(
|
||||
"visitorid" => "visitorid"
|
||||
)
|
||||
);
|
||||
|
||||
@ -150,6 +159,7 @@ $dbtables_can_update = array(
|
||||
"${mysqlprefix}chatgroupoperator" => array(),
|
||||
"${mysqlprefix}chatresponses" => array(),
|
||||
"${mysqlprefix}chatsitevisitor" => array(),
|
||||
"${mysqlprefix}visitedpage" => array(),
|
||||
);
|
||||
|
||||
function show_install_err($text)
|
||||
|
@ -168,6 +168,11 @@ if ($act == "silentcreateall") {
|
||||
if ($res && mysql_num_rows($res) == 0) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}chatsitevisitor ADD INDEX (threadid)", $link);
|
||||
}
|
||||
|
||||
$res = mysql_query("select null from information_schema.statistics where table_schema = '$mysqldb' and table_name = '${mysqlprefix}visitedpage' and index_name = 'visitorid'", $link);
|
||||
if ($res && mysql_num_rows($res) == 0) {
|
||||
runsql("ALTER TABLE ${mysqlprefix}visitedpage ADD INDEX (visitorid)", $link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ function track_visitor($visitorid, $entry, $referer, $link)
|
||||
return $visitor;
|
||||
}
|
||||
else {
|
||||
perform_query(sprintf("update ${mysqlprefix}chatsitevisitor set lasttime = CURRENT_TIMESTAMP, path = '%s' where visitorid=" . $visitor['visitorid'],
|
||||
db_escape_string(track_build_path($referer, $visitor['path']))), $link);
|
||||
perform_query("update ${mysqlprefix}chatsitevisitor set lasttime = CURRENT_TIMESTAMP where visitorid=" . $visitor['visitorid'], $link);
|
||||
track_visit_page($visitor['visitorid'], $referer, $link);
|
||||
return $visitor['visitorid'];
|
||||
}
|
||||
}
|
||||
@ -44,13 +44,16 @@ function track_visitor_start($entry, $referer, $link)
|
||||
|
||||
$visitor = visitor_from_request();
|
||||
|
||||
perform_query(sprintf("insert into ${mysqlprefix}chatsitevisitor (userid, username, firsttime, lasttime, entry, path, details) values ('%s', '%s', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '%s', '%s', '%s')",
|
||||
perform_query(sprintf("insert into ${mysqlprefix}chatsitevisitor (userid, username, firsttime, lasttime, entry, details) values ('%s', '%s', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '%s', '%s')",
|
||||
db_escape_string($visitor['id']),
|
||||
db_escape_string($visitor['name']),
|
||||
db_escape_string($entry),
|
||||
db_escape_string(track_build_path($referer, '')),
|
||||
db_escape_string(track_build_details())), $link);
|
||||
|
||||
if ($id) {
|
||||
track_visit_page($id, $referer, $link);
|
||||
}
|
||||
|
||||
$id = db_insert_id($link);
|
||||
return $id ? $id : 0;
|
||||
}
|
||||
@ -75,33 +78,34 @@ function track_get_visitor_by_threadid($threadid, $link)
|
||||
return $visitor;
|
||||
}
|
||||
|
||||
|
||||
function track_build_path($referer, $path)
|
||||
function track_visit_page($visitorid, $page, $link)
|
||||
{
|
||||
if ($path !== '') {
|
||||
$path = unserialize($path);
|
||||
krsort($path);
|
||||
global $mysqlprefix;
|
||||
|
||||
list($lasttime, $lastpage) = each($path);
|
||||
|
||||
if ($referer != $lastpage) {
|
||||
$path[time()] = $referer;
|
||||
if (empty($page)) {
|
||||
return;
|
||||
}
|
||||
$lastpage = select_one_row(sprintf("select address from ${mysqlprefix}visitedpage where visitorid = '%s' order by visittime desc limit 1",
|
||||
db_escape_string($visitorid)), $link);
|
||||
if ( $lastpage['address'] != $page ) {
|
||||
perform_query(sprintf("insert into ${mysqlprefix}visitedpage (visitorid, address, visittime) values ('%s', '%s', CURRENT_TIMESTAMP)",
|
||||
db_escape_string($visitorid),
|
||||
db_escape_string($page)), $link);
|
||||
}
|
||||
else {
|
||||
$path[time()] = $referer;
|
||||
}
|
||||
|
||||
$path = serialize($path);
|
||||
return $path;
|
||||
}
|
||||
|
||||
function track_retrieve_path($visitor)
|
||||
function track_get_path($visitor, $link)
|
||||
{
|
||||
return unserialize($visitor['path']);
|
||||
global $mysqlprefix;
|
||||
$query_result = perform_query(sprintf("select address, UNIX_TIMESTAMP(visittime) as visittime from ${mysqlprefix}visitedpage where visitorid = '%s'",
|
||||
db_escape_string($visitor['visitorid'])), $link);
|
||||
$result = array();
|
||||
while( $page = db_fetch_assoc($query_result) ){
|
||||
$result[$page['visittime']] = $page['address'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function track_build_details()
|
||||
{
|
||||
$result = array(
|
||||
|
@ -53,10 +53,9 @@ else {
|
||||
die("Wrong visitor!");
|
||||
}
|
||||
}
|
||||
$path = track_get_path($visitor, $link);
|
||||
close_connection($link);
|
||||
|
||||
$path = track_retrieve_path($visitor);
|
||||
|
||||
$page['entry'] = htmlspecialchars($visitor['entry']);
|
||||
$page['history'] = array();
|
||||
ksort($path);
|
||||
|
Loading…
Reference in New Issue
Block a user