本文整理汇总了PHP中BxDolCmts::maintenance方法的典型用法代码示例。如果您正苦于以下问题:PHP BxDolCmts::maintenance方法的具体用法?PHP BxDolCmts::maintenance怎么用?PHP BxDolCmts::maintenance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BxDolCmts
的用法示例。
在下文中一共展示了BxDolCmts::maintenance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParam
function clean_database()
{
$db_clean_vkiss = (int) getParam("db_clean_vkiss");
$db_clean_profiles = (int) getParam("db_clean_profiles");
$db_clean_msg = (int) getParam("db_clean_msg");
$db_clean_visits = (int) getParam("db_clean_members_visits");
$db_clean_banners_info = (int) getParam("db_clean_banners_info");
$db_clean_mem_levels = (int) getParam("db_clean_mem_levels");
//clear from `sys_acl_levels_members`
if (db_res("DELETE FROM `sys_acl_levels_members` WHERE `DateExpires` < NOW() - INTERVAL {$db_clean_mem_levels} DAY")) {
db_res("OPTIMIZE TABLE `sys_acl_levels_members`");
}
//clear from `sys_banners_shows`
if (db_res("DELETE FROM `sys_banners_shows` WHERE `Date` < UNIX_TIMESTAMP( NOW() - INTERVAL {$db_clean_banners_info} DAY )")) {
db_res("OPTIMIZE TABLE `sys_banners_shows`");
}
//clear from `sys_banners_clicks`
if (db_res("DELETE FROM `sys_banners_clicks` WHERE `Date` < UNIX_TIMESTAMP( NOW() - INTERVAL {$db_clean_banners_info} DAY )")) {
db_res("OPTIMIZE TABLE `sys_banners_clicks`");
}
// clear from `sys_messages`
if (db_res("DELETE FROM `sys_messages` WHERE FIND_IN_SET('sender', `Trash`) AND FIND_IN_SET('recipient', `Trash`)")) {
db_res("OPTIMIZE TABLE `sys_messages`");
}
//clear from `sys_ip_members_visits`
if (db_res("DELETE FROM `sys_ip_members_visits` WHERE `DateTime` < NOW() - INTERVAL {$db_clean_visits} DAY")) {
db_res("OPTIMIZE TABLE `sys_ip_members_visits`");
}
// clear ban table
if (db_res("DELETE FROM `sys_admin_ban_list` WHERE `DateTime` + INTERVAL `Time` SECOND < NOW()")) {
db_res("OPTIMIZE TABLE `sys_admin_ban_list`");
}
// profile_delete
if ($db_clean_profiles > 0) {
$res = db_res("SELECT `ID` FROM `Profiles` WHERE (`DateLastNav` < NOW() - INTERVAL {$db_clean_profiles} DAY) AND (`Couple` > `ID` OR `Couple` = 0)");
if ($res) {
$db_clean_profiles_num = $res->rowCount();
while ($arr = $res->fetch()) {
profile_delete($arr['ID']);
}
db_res("OPTIMIZE TABLE `Profiles`");
}
}
if ($db_clean_vkiss > 0) {
$res = db_res("DELETE FROM `sys_greetings` WHERE `When` < NOW() - INTERVAL {$db_clean_vkiss} DAY");
if ($res) {
$db_clean_vkiss_num = db_affected_rows($res);
db_res("OPTIMIZE TABLE `sys_greetings`");
}
}
if ($db_clean_msg > 0) {
$res = db_res("DELETE FROM `sys_messages` WHERE `Date` < NOW() - INTERVAL {$db_clean_msg} DAY");
if ($res) {
$db_clean_msg_num = db_affected_rows($res);
db_res("OPTIMIZE TABLE `sys_messages`");
}
}
//--- Clean sessions ---//
bx_import('BxDolSession');
$oSession = BxDolSession::getInstance();
$iSessions = $oSession->oDb->deleteExpired();
// clean expired ip bans
bx_import('BxDolAdminIpBlockList');
$oBxDolAdminIpBlockList = new BxDolAdminIpBlockList();
$iIps = $oBxDolAdminIpBlockList->deleteExpired();
// clean old views
bx_import('BxDolViews');
$oBxViews = new BxDolViews('', 0);
$iDeletedViews = $oBxViews->maintenance();
// clean old votes
bx_import('BxDolVoting');
$oBxVotes = new BxDolVoting('', 0);
$iDeletedVotes = $oBxVotes->maintenance();
// clean comments ratings
bx_import('BxDolCmts');
$oBxCmts = new BxDolCmts('', 0);
$iDeletedCommentVotes = $oBxCmts->maintenance();
echo "\n- Database cleaning -\n";
echo "Deleted profiles: {$db_clean_profiles_num}\n";
echo "Deleted virtual kisses: {$db_clean_vkiss_num}\n";
echo "Deleted messages: {$db_clean_msg_num}\n";
echo "Deleted sessions: {$iSessions}\n";
echo "Deleted records from ip block list: {$iIps}\n";
echo "Deleted views: {$iDeletedViews}\n";
echo "Deleted votes: {$iDeletedVotes}\n";
echo "Deleted comment votes: {$iDeletedCommentVotes}\n";
}