Спасибо за раздачу и оценка релиза

Lion18

Пользователь
PHP:
[28-Nov-2011 16:21:15] PHP Notice:  Undefined index: rating in /var/www/btclub.org/attach_mod/displaying_torrent.php on line 69
[28-Nov-2011 16:21:15] PHP Notice:  Undefined index: thanked in /var/www/btclub.org/attach_mod/displaying_torrent.php on line 71
 
 $your_vote = $attachments['_'. $post_id][$i]['rating'];
 $thanked = $attachments['_'. $post_id][$i]['thanked'];
Не кто не сталкивался?
 

DarkMod

Легенда
InKomen, Ты у себя так же сделал?!
Lion18, верно говорит Zenden,
У меня он уже стоит 2 месяца, и проблем не каких, Ну и кое че переделал
 

Maksim

Пользователь
как исправить Parse error: syntax error, unexpected ',' in C:\WebServers\home\localhost\forum\attach_mod\includes\functions_attach.php on line 454

PHP:
/**
* get all attachments from a post (could be an post array too)
*/
function get_attachments_from_post($post_id_array)
{
global $attach_config;
, $userdata                            \\ВОТ ЭТА СТРОЧКА
$attachments = array();

//Thanks mod
$user_id = $userdata['user_id'];
//End

if (!is_array($post_id_array))
{
if (empty($post_id_array))
{
return $attachments;
}
 

DarkMod

Легенда
Maksim,
Синтаксическая ошибка: синтаксическая ошибка, неожиданная ',' в C:\WebServers\home\localhost\forum\attach_mod\includes\functions_attach.php on line 454
найти
PHP:
global $attach_config;
, $userdata
заменить
PHP:
global $attach_config, $userdata;
 

volkodav2000

Пользователь
Немного изменил мод, может кому надо..
Удаляем thanks.php, rate.php, ajax.js
в ajax.php добавляем
PHP:
function thank() {
        global $userdata, $lang;
        $mode      = (string) $this->request['m'];
        $attach_id = (int) $this->request['a'];
        if(is_numeric($attach_id)) {
            $result = array('attach_id' => $attach_id, 'error' => false);
            // Thank!
            if($mode == 'thank') {

                $sql = "INSERT INTO ". BB_ATTACHMENTS_RATING ." (attach_id,user_id,thanked) VALUES ("
                    . $attach_id .",". $userdata['user_id'] .",1)on duplicate key update thanked=1";

                if( DB()->sql_query($sql) ) {
                    $sql = "select sum(thanked) as c from ". BB_ATTACHMENTS_RATING ." where attach_id=". $attach_id;

                    if( $res = DB()->sql_query($sql) ) {
                        if ($row = DB()->sql_fetchrow($res)) {
                            $result['thanked'] = $row['c'];
                            $result['mode'] = $mode;
                            $result['list_button']=' &nbsp; (<span id="VL'.$attach_id.'"><a href="#torrent" onClick="thank(\'list\','.$attach_id.');">'. $lang['THANK_LIST'] .'</a></span>)';
                            $sql = "UPDATE ". BB_ATTACHMENTS_DESC ." SET thanks=". $row['c'] ." where attach_id=". $attach_id;
                            DB()->sql_query($sql);
                        }
                        else {
                            $result['error'] = true;
                        }
                    }
                    else {
                        $result['error'] = true;
                    }
                }
                else {
                    $result['error'] = true;
                }
            }
            // Thanks list
            elseif($mode == 'list')
            {
                $sql = DB()->fetch_rowset("SELECT u.user_id, u.username, u.user_rank FROM ". BB_ATTACHMENTS_RATING ." r join ". BB_USERS ." u on u.user_id=r.user_id where r.thanked=1 and r.attach_id=". $attach_id);

                $html = '';
                foreach    ($sql as $row)
                {
                    if( $html ) $html .= ', ';
                    $html .= profile_url($row);
                }
                $result['list'] = $html;
                $result['mode'] = $mode;
            }
            else {
                $result['error'] = true;
            }
        }
        else {
            $result['error'] = true;
        }
        $this->response['message'] = $result;
    }
    function rate() {
        global $userdata, $lang;
        $attach_id = (int) $this->request['a'];
        $rating = (int) $this->request['v'];

        $result['error'] = false;

        if(is_numeric($rating) && is_numeric($attach_id) && $rating>=1 && $rating<=5) {

            $sql = "insert into ". BB_ATTACHMENTS_RATING ."(attach_id,user_id,rating)values("
                . $attach_id .",". $userdata['user_id'] .",". $rating .")on duplicate key update rating=values(rating)";
            if(DB()->sql_query($sql)) {
                $sql = "select sum(rating) as r, count(*) as c from ". BB_ATTACHMENTS_RATING ." where rating>0 and attach_id=". $attach_id;
                if($res = DB()->sql_query($sql)) {
                    if ($row = DB()->sql_fetchrow($res)) {
                        $result['attach_id'] = $attach_id;
                        $result['rating'] = round($row['r']/$row['c'],1);
                        $result['rating_count'] = $row['c'];
                        $result['your_rating'] = $lang['YOUR_VOTE'] .' '. $lang['RATING_'.$rating] .' '. $lang['VOTE_COUNTED'];
                        $sql = "update ". BB_ATTACHMENTS_DESC ." set rating_sum=". $row['r'] .", rating_count=". $row['c'] ." where attach_id=". $attach_id;
                        DB()->sql_query($sql);
                    }
                    else {
                        $result['error'] = true;
                    }
                }
                else {
                    $result['error'] = true;
                }
            }
            else {
                $result['error'] = true;
            }
        }
        else {
            $result['error'] = true;
        }
        $this->response['message'] = $result;
    }
ну и
PHP:
      'thank'            => array('user'),
        'rate'              => array('user'),
ajax.js
Код:
say_thank = function (mode,attach_id) {
    ajax.exec({
        action: 'thank',
        a : attach_id,
        m : mode
    })
}
ajax.callback.thank = function (data) {
    var json = data.message;
    if(json['error'] === true) {
        return false;
    }
    if(json['mode']=='list') {
        $('#VL' + json['attach_id'] ).html('' + json['list']);
    }
    if(json['mode']=='thank') {
        $('#VT' + json['attach_id'] ).html('' + json['thanked']);
        $('#VB' + json['attach_id'] ).html('' + json['list_button']);

    }
}
rate = function (attach_id,rating) {
    ajax.exec({
        action: 'rate',
        a: attach_id,
        v: rating
    })
}
ajax.callback.rate = function (data) {
    var json = data.message;
    if(json['error'] === true) {
        return false;
    }
    $('#VD' + json['attach_id'] ).html('' + json['your_rating']);
    $('#VR' + json['attach_id'] ).html('' + json['rating']);
    $('#VC' + json['attach_id'] ).html('' + json['rating_count']);
}
displaying_torrent.php
PHP:
            //Thanks mod
            'RATING'          => '<span id="VR'.$attach_id.'">'. ($rating_sum ? round($rating_sum/$rating_count,1) : '-') .'</span>',
            'RATING_VOTES'    => '<span id="VC'.$attach_id.'">'. $rating_count .'</span>',
            'THANKED'        => '<span id="VT'.$attach_id.'">'. $thanks .'</span>'
            . ($thanked || ($userdata['user_id'] == $poster_id) ? '' : '<span id="VB'.$attach_id.'">'. '&nbsp; <img src="images/sps.gif" onClick="say_thank(\'thank\',' . $attach_id.');" alt="'. $lang['THANKS'] .'" style="cursor:pointer" /></span>')
            . ($thanks > 0 ? ' &nbsp; (<span id="VL'.$attach_id.'"><a href="#torrent" onClick="say_thank(\'list\','.$attach_id.');">'. $lang['THANK_LIST'] .'</a></span>)' : ''),
            'YOUR_VOTE'        => $your_vote > 0 ? $lang['RATING_'.$your_vote] : '',
            'DO_VOTE'          => $userdata['user_id'] == ANONYMOUS ? '' : ('<span id="VD'.$attach_id.'">'. $rate_html .'</span>'),
            //Thanks mod End
и
PHP:
    $rate_html = '';
    for ($r = 5; $r >= 1; $r-- ) {
        $rate_html .= '<input type="radio" name="rate'.$attach_id.'" value="'.$r.'" onClick="rate('.$attach_id.','.$r.');" />'
      . '<span onClick="rate('.$attach_id.','.$r.');">' . $lang['RATING_'.$r] . '</span>';
    }
 
Сверху