вопрос
Всем добрый вечер. Установил модуль DLE Friends 1.5 на DLE 10.4
Проблема в следующем.
Когда включено кеширование новостей, в профиле пользователя отображаются все новости из кеша новостей.
Если удалить строчку для работы с кешем из модуля:
Тогда всё становится на свои места, но и кеширование модуля друзья в профиле не работает естественно.
Кто ни будь сталкивался с такой проблемой?
Код самого модуля:
Проблема в следующем.
Когда включено кеширование новостей, в профиле пользователя отображаются все новости из кеша новостей.
Если удалить строчку для работы с кешем из модуля:
if( $config['allow_cache'] != "yes" ) { $config['allow_cache'] = "yes"; $revert_cache = true; } else $revert_cache = false;
$best_friends = dle_cache( "user_friends_" . $row['user_id'], $config['skin'] );
Тогда всё становится на свои места, но и кеширование модуля друзья в профиле не работает естественно.
Кто ни будь сталкивался с такой проблемой?
Код самого модуля:
<?php
/*
=====================================================
DLE Friends v1.5 by Elegant Division (http://e-div.com)
---------------------------------------------------------------------------
e-mail: info@e-div.com
=====================================================
*/
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
// load module settings
require_once (ENGINE_DIR . '/data/friends_config.php');
############################################### Profile settings
// Friends settings - v1.5:
$friends_settings = explode( "||", $row['friends_settings'] );
// 0 = Получать уведомления о предложениях дружбы
// 1 = Получать личные сообщения только от друзей
if( $friends_settings[0] == "yes" ) $friends_info = "checked = \"checked\"";
else $friends_info = "";
$tpl->set( '{friends_info}', "<input type=\"checkbox\" id=\"friends_info\" name=\"friends_info\" value=\"1\" " . $friends_info . " />" );
if( $friends_settings[1] == "yes" ) $friends_pm = "checked = \"checked\"";
else $friends_pm = "";
$tpl->set( '{friends_pm}', "<input type=\"checkbox\" id=\"friends_pm\" name=\"friends_pm\" value=\"1\" " . $friends_pm . " />" );
// End of friends settings
if( $is_logged and $member_id['user_id'] != $row['user_id'] ) {
$my_fr_arr = explode( ',', $member_id['friends'] ); // my friends
$my_temp_arr = explode( ',', $member_id['friends_temp'] ); // my temporary list
$usr_temp_arr = explode( ',', $row['friends_temp'] ); // victim's temporary list
if( ! in_array( $row['user_id'], $my_fr_arr ) && ! in_array( $member_id['user_id'], $usr_temp_arr ) && ! in_array( $row['user_id'], $my_temp_arr ) ) {
$tpl->set( '{dofriends}', "<a id=\"dofriend\" href=\"#\" onclick=\"doFriends('" . $row['user_id'] . "', 'add', ''); return false;\" >" . $lang['fr_add'] . "</a>" );
} elseif( in_array( $row['user_id'], explode( ',', $member_id['friends'] ))) {
$tpl->set( '{dofriends}', "<a id=\"dofriend\" href=\"#\" onclick=\"doFriends('" . $row['user_id'] . "', 'delete', ''); return false;\" >" . $lang['fr_del_do'] . "</a>" );
} else $tpl->set( '{dofriends}', $lang['fr_req_sent'] );
} else $tpl->set( '{dofriends}', "" );
############################################### Random friends
// if module work
if( $friends_config['hide_friends'] ) {
// if friends exist
if( $row['friends'] ) {
// force cache
if( $config['allow_cache'] != "yes" ) { $config['allow_cache'] = "yes"; $revert_cache = true; } else $revert_cache = false;
$best_friends = dle_cache( "user_friends_" . $row['user_id'], $config['skin'] );
// if cache don't exist
if( $best_friends === FALSE ) {
$list = explode( ",", $row['friends'] );
foreach ( $list as $daten ) { $fav_list[] = "'" . $daten . "'"; }
$list = implode( ",", $fav_list );
$friends = "(" . $list . ")";
if( $friends_config['prof_usr'] ) $fr_limit = "limit 0," . $friends_config['prof_usr'];
$freinds_query = $db->query("SELECT name, foto FROM " . USERPREFIX . "_users WHERE user_id in {$friends} ORDER by RAND() " . $fr_limit . "");
while ($frq = $db->get_row($freinds_query)) {
$row['autor'] = $frq['name'];
include (ENGINE_DIR.'/modules/color_nik.php');
$name = stripslashes($frq['name']);
if( $config['allow_alt_url'] == "1" ) $name = "<a href=\"" . $config['http_home_url'] . "user/" . urlencode( $name ) . "/\">" . $color_gr . $name . $color_gr2 . "</a>";
else $name = "<a href=\"$PHP_SELF?subaction=userinfo&user=" . urlencode( $name ) . "\">" . $color_gr . $name . $color_gr2 . "</a>";
if( $friends_config['fr_style'] == "full" ) {
if( $frq['foto'] ) $friend_foto = "<img src=\"" . $config['http_home_url'] . "uploads/fotos/" . $frq['foto'] . "\" alt=\"\" />";
else $friend_foto = "<img src=\"{THEME}/images/noavatar.png\" alt=\"\" />";
$outfreind .= "<li>" . $friend_foto . $name . "</li>";
$best_friends = "<ul>" . $outfreind . "</ul>";
} else {
$outfreind .= $name . ", ";
$best_friends = "<div class=\"prof-list\">" . substr($outfreind, 0, -2) . "</div>";
}
}
$db->free();
create_cache( "user_friends_" . $row['user_id'], $best_friends, $config['skin'] );
}
// end of force cache
if( $revert_cache ) $config['allow_cache'] = "no";
$tpl->set( '{friends}', $best_friends );
$tpl->set( '[friends]', "" );
$tpl->set( '[/friends]', "" );
$tpl->set( '{friends-count}', count(explode("," ,$row['friends'])) );
if( $config['allow_alt_url'] == "1" ) {
$tpl->set( '[friends-link]', "<a href=\"" . $config['http_home_url'] . "friends/" . urlencode( $row['name'] ) . "\">" );
$tpl->set( '[/friends-link]', "</a>" );
} else {
$tpl->set( '[friends-link]', "<a href=\"$PHP_SELF?do=friends&user=" . urlencode( $row['name'] ) . "\">" );
$tpl->set( '[/friends-link]', "</a>" );
}
// if no friends
} else {
if( $member_id['user_id'] == $row['user_id'] ) $tpl->set( '{friends}', "<div id=\"no-friends\">" . $lang['fr_no_friends'] . "</div>" );
else $tpl->set( '{friends}', "<div id=\"no-friends\">" . str_replace('{user}', stripslashes( $row['name'] ), $lang['fr_user_no_friends']) . "</div>" );
$tpl->set( '[friends]', "" );
$tpl->set( '[/friends]', "" );
$tpl->set( '{friends-count}', "0" );
$tpl->set_block( "'\\[friends-link\\](.*?)\\[/friends-link\\]'si", "" );
}
// link to "temporary friends"
if( $row['friends_temp'] and $member_id['user_id'] == $row['user_id'] ) {
$tpl->set( '{requests-count}', count(explode("," ,$row['friends_temp'])) );
if( $config['allow_alt_url'] == "1" ) {
$tpl->set( '[requests]', "(<a href=\"" . $config['http_home_url'] . "friends/" . urlencode( $row['name'] ) . "/requests\">" );
$tpl->set( '[/requests]', "</a>)" );
} else {
$tpl->set( '[requests]', "(<a href=\"$PHP_SELF?do=friends&subaction=requests&user=" . urlencode( $row['name'] ) . "\">" );
$tpl->set( '[/requests]', "</a>)" );
}
} else $tpl->set_block( "'\\[requests\\](.*?)\\[/requests\\]'si", "" );
} else {
$tpl->set_block( "'\\[friends\\](.*?)\\[/friends\\]'si", "" );
$tpl->set( '{friends}', "" );
$tpl->set( '{friends-count}', "" );
}
####################rf53######################### Common friends
// количество общих друзей
if($is_logged AND $member_id['user_id'] != $row['user_id'] AND $member_id['friends'] AND $row['friends']) {
$common_count = intval( count( array_intersect( explode(",", $row['friends']), explode(",", $member_id['friends']))));
$tpl->set ( '{common-count}', $common_count );
if($common_count >= 1) {
$tpl->set( '[common]', "" );
$tpl->set( '[/common]', "" );
// if module work
if( $friends_config['common'] ) {
// force cache
if( $config['allow_cache'] != "yes" ) { $config['allow_cache'] = "yes"; $revert_cache = true; } else $revert_cache = false;
$common_friends = dle_cache( "user_common_" . $row['user_id'], $config['skin'] );
// if cache don't exist
if( $common_friends === FALSE ) {
$c_list = array_intersect( explode(",", $row['friends']), explode(",", $member_id['friends']));
foreach ( $c_list as $daten ) { $com_list[] = "'" . $daten . "'"; }
$c_list = implode( ",", $com_list );
$common_sql = "(" . $c_list . ")";
if( $friends_config['common_usr'] ) $common_limit = "limit 0," . $friends_config['common_usr'];
$common_query = $db->query("SELECT name, foto FROM " . USERPREFIX . "_users WHERE user_id in {$common_sql} ORDER by RAND() " . $common_limit . "");
while ($crq = $db->get_row($common_query)) {
$row['autor'] = $crq['name'];
include (ENGINE_DIR.'/modules/color_nik.php');
$name = stripslashes($crq['name']);
if( $config['allow_alt_url'] == "1" ) $name = "<a href=\"" . $config['http_home_url'] . "user/" . urlencode( $name ) . "/\">" . $color_gr . $name . $color_gr2 . "</a>";
else $name = "<a href=\"$PHP_SELF?subaction=userinfo&user=" . urlencode( $name ) . "\">" . $color_gr . $name . $color_gr2 . "</a>";
if( $friends_config['fr_style_cmn'] == "full" ) {
if( $crq['foto'] ) $friend_foto = "<img src=\"" . $config['http_home_url'] . "uploads/fotos/" . $crq['foto'] . "\" alt=\"\" />";
else $friend_foto = "<img src=\"{THEME}/images/noavatar.png\" alt=\"\" />";
$c_outfreind .= "<li>" . $friend_foto . $name . "</li>";
$common_friends = "<ul>" . $c_outfreind . "</ul>";
} else {
$c_outfreind .= $name . ", ";
$common_friends = "<div class=\"prof-list\">" . substr($c_outfreind, 0, -2) . "</div>";
}
}
$db->free();
create_cache( "user_common_" . $row['user_id'], $common_friends, $config['skin'] );
}
// end of force cache
if( $revert_cache ) $config['allow_cache'] = "no";
$tpl->set( '{common-friends}', $common_friends );
$tpl->set( '[common-friends]', "" );
$tpl->set( '[/common-friends]', "" );
if( $config['allow_alt_url'] == "1" ) {
$tpl->set( '[common-link]', "<a href=\"" . $config['http_home_url'] . "friends/" . urlencode( $row['name'] ) . "/common\">" );
$tpl->set( '[/common-link]', "</a>" );
} else {
$tpl->set( '[common-link]', "<a href=\"$PHP_SELF?do=friends&subaction=common&user=" . urlencode( $row['name'] ) . "\">" );
$tpl->set( '[/common-link]', "</a>" );
}
} else {
$tpl->set_block( "'\\[common-friends\\](.*?)\\[/common-friends\\]'si", "" );
$tpl->set_block( "'\\[common-link\\](.*?)\\[/common-link\\]'si", "" );
}
} else {
$tpl->set_block( "'\\[common-friends\\](.*?)\\[/common-friends\\]'si", "" );
$tpl->set_block( "'\\[common-link\\](.*?)\\[/common-link\\]'si", "" );
$tpl->set_block( "'\\[common\\](.*?)\\[/common\\]'si", "" );
}
} else {
$tpl->set_block( "'\\[common-friends\\](.*?)\\[/common-friends\\]'si", "" );
$tpl->set_block( "'\\[common-link\\](.*?)\\[/common-link\\]'si", "" );
$tpl->set_block( "'\\[common\\](.*?)\\[/common\\]'si", "" );
}
?>
Ответил: SX2
if( !$config['allow_cache'] ) { $config['allow_cache'] = 1; $revert_cache = true; } else $revert_cache = false;
$best_friends = dle_cache( "user_friends_" . $row['user_id'], $config['skin'] );