Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Общие вопросы по PHP » Помогите доделать модуль icomm для версии dle 10.5?

Помогите доделать модуль icomm для версии dle 10.5?


     14.10.2015    Все вопросы » Общие вопросы по PHP    2529

вопрос
Помогите доделать старый модуль icomm для версии dle 10.5. После перехода с dle 10.3 на 10.5 перестал работать. До этого все нормально работало, были внесены небольшие правки, добавлен аватар, вырезались bb-коды, а сейчас аватар юзера не отображается. Все пользователи, которые были зарегистрированы ранее могут оставлять комментарии и аватар у них показывает, а у тех, кто зарегистрировался позже (уже на версии dle 10.5) - нет.

Заметил, что у новых юзеров добавляется такой путь к аватару: /uploads/fotos/http://сайт.ru/uploads/fotos/foto_202.jpg, что совсем лишнее в начале.

Когда, у старых все нормально. (обычный путь к изображению аватарки)

Прилагаю код:


<?php

if( !defined('DATALIFEENGINE') ) {
        die("Hacking attempt!");
}

$max_comm  = (is_numeric(trim($max_comm))) ? $max_comm : "5";

$is_change = false;

if( !$config['allow_cache'] ) {
        $config['allow_cache'] = 1;
        $is_change = true;
}

$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
$where = array ();

if( $allow_list[0] != "all" ) {
        $join = "LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id ";
      
        if( $config['allow_multi_category'] ) {
                $where[] = PREFIX . "_post.category regexp '[[:<:]](" . implode( '|', $allow_list ) . ")[[:>:]]'";
        } else {
                $where[] = PREFIX . "_post.category IN ('" . implode( "','", $allow_list ) . "')";
        }
} else {
        $join = "";
}

if( $config['allow_cmod'] ) {
        $where[] = PREFIX . "_comments.approve=1";
}

if( count( $where ) ) {
        $where = implode( " AND ", $where );
        $where = "WHERE " . $where;
} else {
        $where = "";
}


    $have_perm = 0;
    $row['date'] = strtotime( $row['date'] );

    if( $is_logged and (($member_id['name'] == $row['autor'] and $row['is_register'] and $user_group[$member_id['user_group']]['allow_editc']) or $member_id['user_group'] == '1' or $user_group[$member_id['user_group']]['edit_allc']) ) $have_perm = 1;

    if ( $user_group[$member_id['user_group']]['edit_limit'] AND (($row['date'] + ($user_group[$member_id['user_group']]['edit_limit'] * 60)) < $_TIME) ) {
        $have_perm = 0;
    }
    
    

$tpl->result['icomm'] = dle_cache("news_comm_iComm_", $config['skin']);

if( $tpl->result['icomm'] === false ) {
        $flag = ( $config['version_id'] < '9.6' ) ? "p.flag, " : "";
                

        $sql = $db->query("SELECT " . PREFIX . "_comments.id, post_id, " . PREFIX . "_comments.user_id, " . PREFIX . "_comments.date, " . PREFIX . "_comments.autor as autor, " . PREFIX . "_comments.email as gast_email, text, ip, is_register, name, " . USERPREFIX . "_users.email, news_num, " . USERPREFIX . "_users.comm_num, user_group, lastdate, reg_date, signature, foto, points, b, i, u, colorcode, fontstylecode, userstatuscode, reflection, fullname, land, " . USERPREFIX . "_users.xfields, " . PREFIX . "_post.title, " . PREFIX . "_post.date as newsdate, " . PREFIX . "_post.alt_name, " . PREFIX . "_post.category FROM " . PREFIX . "_comments LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_comments.user_id=" . USERPREFIX . "_users.user_id " . $where . " ORDER BY " . PREFIX . "_comments.date DESC LIMIT 0, " . $max_comm );

        $tpl->load_template('lastcomm.tpl');

        while ($row = $db->get_row($sql)) {
                $row['date'] = strtotime( $row['date'] );
                                $date = date( "d-m-Y, H:i", $row['date'] );
                $row['category'] = intval($row['category']);

                $on_page = FALSE;
                //if( $row['comm_num'] > $config['comm_nummers'] ) $on_page = 'page,1,' . ceil($row['comm_num'] / $config['comm_nummers']) . ',';

                if( $config['allow_alt_url'] ) {
                        if( $condition = $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
                                if( $row['category'] and $config['seo_type'] == 2 ) {
                                        $full_link = $config['http_home_url'] . get_url($row['category']) . "/" . $on_page . $row['post_id'] . "-" . $row['alt_name'] . ".html";
                                } else {
                                        $full_link = $config['http_home_url'] . $on_page . $row['post_id'] . "-" . $row['alt_name'] . ".html";
                                }
                        } else {
                                $full_link = $config['http_home_url'] . date("d-m-Y, H:i", $row['date']) . $on_page . $row['alt_name'] . ".html";
                        }
                } else {
                        $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['post_id'];
                }

                if( dle_strlen($row['text'], $config['charset']) > 270 ) $text = dle_substr($row['text'], 0, 270, $config['charset']) . "...";
                else $text = $row['text'];

                if( dle_strlen($row['title'], $config['charset']) > 50 ) $title = dle_substr($row['title'], 0, 50, $config['charset']) . "...";
                else $title = $row['title'];

                if( $row['is_register'] == 1 ) {
                        if( $config['allow_alt_url'] ) $go_page = $config['http_home_url'] . "user/" . urlencode($row['autor']) . "/";
                        else $go_page = "$PHP_SELF?subaction=userinfo&amp;user=" . urlencode($row['autor']);
                      
                        $author = "<a onclick=\"ShowProfile('" . urlencode($row['autor']) . "', '" . $go_page . "'); return false;\" href=\"" . $go_page . "\">" . $row['autor'] . "</a>";
                } else {
                        $author = "<a href=\"mailto:" . $row['email'] . "\">" . $row['autor'] . "</a>";
                }

                if( $config['allow_alt_url'] ) $user_url = $config['http_home_url'] . "user/" . urlencode($row['autor']) . "/";
                else $user_url = "$PHP_SELF?subaction=userinfo&amp;user=" . urlencode($row['autor']);

                if( $row['is_register'] != 1 ) $user_url = 'mailto:' . $row['email'];
              
                $tpl->copy_template = preg_replace("#\{date=(.+?)\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template);
              
                // images of post
                $row['short_story'] = stripslashes($row['short_story']);

                if( stripos( $tpl->copy_template, "{image-" ) !== false ) {

                        $images = array();
                        preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'], $media);
                        $data = preg_replace('/(img|src)("|\'|="|=\')(.*)/i', "$3", $media[0]);
      
                        foreach($data as $url) {
                                $info = pathinfo($url);
                                if( isset($info['extension']) ) {
                                        if( $info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
                                        $info['extension'] = strtolower($info['extension']);
                                        if( ($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png') ) array_push($images, $url);
                                }
                        }

                        if( count($images) ) {
                                $i_count = 0;
                                foreach($images as $url) {
                                        $i_count++;
                                        $tpl->copy_template = str_replace( '{image-' . $i_count . '}', $url, $tpl->copy_template );
                                        $tpl->copy_template = str_replace( '[image-' . $i_count . ']', "", $tpl->copy_template );
                                        $tpl->copy_template = str_replace( '[/image-'. $i_count . ']', "", $tpl->copy_template );
                                }
                        }

                        $tpl->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl->copy_template );
                        $tpl->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/noavatar.png", $tpl->copy_template );
      
                }
                // images of post
              
                $row['foto'] = ($row['foto'] == '') ? 'templates/' . $config['skin'] . '/icomm/noavatar.png' : 'uploads/fotos/' . $row['foto'];

                if( $row['comm_num'] ) {
                        $tpl->set('[comm]', "");
                        $tpl->set('[/comm]', "");
                } else {
                        $tpl->copy_template = preg_replace( "#\[comm\](.+?)\[/comm\]#is", "", $tpl->copy_template );
                }
              
                $tpl->set('{foto}', $config['http_home_url'] . $row['foto']);
                $tpl->set('{user_url}', $user_url);
                $tpl->set('{user_name}', $row['autor']);
                $tpl->set('{title}', stripslashes($title));
                $tpl->set('{text}', stripslashes($text));
                                
                                      if ( preg_match( "#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
                $count= intval($matches[1]);
                $text = str_replace( "</p><p>", " ", $text );
                $text = strip_tags( $text, "<br>" );
                $text = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $text ) ) ) ));
    
                if( $count AND dle_strlen( $text, $config['charset'] ) > $count ) {    
                    $text = dle_substr( $text, 0, $count, $config['charset'] );
        
                    if( ($temp_dmax = dle_strrpos($text, ' ', $config['charset'] )) ) $text= dle_substr( $text, 0, $temp_dmax, $config['charset'] );
                    
                }
    
                $tpl->set( $matches[0], $text );
    
        }
                                
                $tpl->set('{long_title}', stripslashes($row['title']));
                $tpl->set('{author}', $author);
                $tpl->set('{full_link}', $full_link);
                $tpl->set('{comm_num}', $row['comm_num']);

                $tpl->compile('icomm');

        }
        $tpl->clear();
        $db->free($sql);

        if( preg_match_all('/<!--dle_spoiler(.*?)<!--\/dle_spoiler-->/is', $tpl->result['icomm'], $spoilers) ) {
                foreach ($spoilers as $spoiler) {
                        $tpl->result['icomm'] = str_replace($spoiler, '<div class="quote">Для просмотра содержимого спойлера, перейдите к выбранному комментарию.</div>', $tpl->result['icomm']);
                }
        }
      
        if( !$tpl->result['icomm'] ) $tpl->result['icomm'] = '<div class="icomm_empty"><b>Нет комментариев</b></div>';
      
        create_cache("news_comm_iComm_", $tpl->result['icomm'], $config['skin']);
}

if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['icomm'] = preg_replace("'\[hide\](.*?)\[/hide\]'si", "\\1", $tpl->result['icomm']);
else $tpl->result['icomm'] = preg_replace("'\[hide\](.*?)\[/hide\]'si", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['icomm']);

echo $tpl->result['icomm'];

if( $is_change ) $config['allow_cache'] = false;

?>


P.s. - модуль хорош и может пригодиться многим. Выводит просто 5 комментариев без подгрузки и всплывающих окон.

4 комментария

CyberPsy
Юзер

CyberPsy - 14 октября 2015 13:00 -

Спасибо, Gameer, все работает, уже в который раз выручаешь!

The_Daniel
Юзер

The_Daniel - 15 октября 2015 13:24 -

хм сори не разобрался как сделать чтобы комменты выводились не в сплывающем окне а просто были видны списком в блоке

CyberPsy
Юзер

CyberPsy - 15 октября 2015 19:08 -

Это вопрос или утверждение?

Если вопрос, то нужно просто поменять стили, например аналогично тем, как выводятся последние комментарии в самом движке.

Если утверждение, то никто и не говорил, что не разобрался. Скорее просто не пробовал, а использовал те, что были.

upiter
Юзер

upiter - 2 июня 2016 09:15 -

у меня на сайте аватарки пользователей в модуле icomm 6 , вот так выводяться http://сайт/uploads/fotos/http://сайт/uploads/fotos/foto_8.jpg а вместо аватарки пустое поле.

Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх