我面临很大的挑战。我有函数where()
,该函数可跟踪用户在网站上的访问位置,并获取脚本文件名,并提供描述并插入数据库。
该脚本一直有效,直到最近,并且在从MySQL 5.6.40
到5.6.47
的最近一次小更新之后,仍未意识到此功能的失败。
我不确定这是否与它有任何关系,但是几天后我发现它不再起作用了。
我们的职能:
function where($scriptname = "index", $userid, $update=1){ if (!is_valid_id($userid)) die; if (preg_match("/details.php/i", $scriptname)) $where = "Browsing File Details (ID $_GET[id])"; elseif (preg_match("/files.php/i", $scriptname)) $where = "Browsing Files"; elseif (preg_match("/account-info.php/i", $scriptname)) $where = "Browsing Account Info (ID $_GET[id])"; elseif (preg_match("/upload.php/i", $scriptname)) $where = "Uploading File"; elseif (preg_match("/account.php/i", $scriptname)) $where = "Browsing User Control Panel"; elseif (preg_match("/search.php/i", $scriptname)) $where = "Searching For Files"; elseif (preg_match("/forums.php/i", $scriptname)) $where = "Viewing Forums"; elseif (preg_match("/index.php/i", $scriptname)) $where = "Browsing Homepage"; elseif (preg_match("/mailbox.php/i", $scriptname)) $where = "Viewing Messages"; elseif (preg_match("/comments.php/i", $scriptname)) $where = "Viewing Comments"; elseif (preg_match("/recover.php/i", $scriptname)) $where = "Recovering Account"; elseif (preg_match("/bookmarks.php/i", $scriptname)) $where = "Viewing Bookmarks"; elseif (preg_match("/getfile.php/i", $scriptname)) $where = "Downloaded File (ID $_GET[id])"; elseif (preg_match("/faq.php/i", $scriptname)) $where = "Reading FAQ Page"; elseif (preg_match("/friends.php/i", $scriptname)) $where = "Viewing Friends"; elseif (preg_match("/admin.php/i", $scriptname)) $where = "Managing Admin Panel"; else $where = "Unknown Location"; if ($update) { // Worked until a few days ago. No site changes were made prior for quite some time. //$query = sprintf("UPDATE users SET page=".sqlesc($where)." WHERE id ='%s'", mysql_real_escape_string($userid)); // Now using line below, which does insert into row if I use my own variable. $query = "UPDATE users SET last_access='" . get_date_time() . "', page=" . sqlesc($where) . " WHERE id=" . $userid; $result = SQL_Query_exec($query); } return $where; }
现在,我已经尝试使用以下代码将其范围缩小到导致它的原因。当前,以上函数仅插入
未知位置
对于数据库,无论查看什么页面。
我明白了这一点:
$stringtest = "This inserts into database!"; $query = "UPDATE users SET last_access='" . get_date_time() . "', page=" . sqlesc($stringtest) . " WHERE id=" . $userid;
这很好,但是没有通过任何
$where
条件。
我尝试过使用各种正则表达式来匹配文件名,但无济于事。
知道我在做什么错吗?
提前感谢!
我面临很大的挑战。我有我的功能where(),它跟踪用户在网站上的访问位置,并获取脚本文件名,并提供描述并插入数据库中。 ...