mirror of
https://github.com/kokororin/typecho-plugin-Access.git
synced 2025-02-21 17:24:18 +08:00
增加刷数据库的函数 提供给日后更新数据用
This commit is contained in:
parent
8cdd62dcfe
commit
92f41b0fbd
@ -356,6 +356,33 @@ class Access_Core
|
||||
} catch (Exception $e) {} catch (Typecho_Db_Query_Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新刷数据库,当遇到一些算法变更时可能需要用到
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @throws Typecho_Plugin_Exception
|
||||
*/
|
||||
public static function rewriteLogs() {
|
||||
$db = Typecho_Db::get();
|
||||
$rows = $db->fetchAll($db->select()->from('table.access_log'));
|
||||
foreach ($rows as $row) {
|
||||
$ua = new Access_UA($row['ua']);
|
||||
$row['browser_id' ] = $ua->getBrowserID();
|
||||
$row['browser_version' ] = $ua->getBrowserVersion();
|
||||
$row['os_id' ] = $ua->getOSID();
|
||||
$row['os_version' ] = $ua->getOSVersion();
|
||||
$row['robot' ] = $ua->isRobot() ? 1 : 0;
|
||||
$row['robot_id' ] = $ua->getRobotID();
|
||||
$row['robot_version' ] = $ua->getRobotVersion();
|
||||
try {
|
||||
$db->query($db->update('table.access_log')->rows($row)->where('id = ?', $row['id']));
|
||||
} catch (Typecho_Db_Exception $e) {
|
||||
throw new Typecho_Plugin_Exception(_t('刷新数据库失败:%s。', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析archive对象
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user