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

$your_vote = $attachments['_'. $post_id][$i]['rating'] ? $attachments['_'. $post_id][$i]['rating'] : '';
$thanked = $attachments['_'. $post_id][$i]['thanked'] ? $attachments['_'. $post_id][$i]['thanked'] : '';
empty() должно помочь.

PHP:
$your_vote = (!empty($attachments['_'. $post_id][$i]['rating'])) ? $attachments['_'. $post_id][$i]['rating'] : '';
$thanked = (!empty($attachments['_'. $post_id][$i]['thanked'])) ? $attachments['_'. $post_id][$i]['thanked'] : '';
 
Подскажите пожалуйста, как сделать чтобы пользователь не мог за свой релиз голосовать (сам себе спасибы накручивать)?

Делал мод со звездами (4 страница), все работает хорошо но не могу понять как как пользователю запретить голосовать за себя.
 
Извиняюсь писал поздно ночью :) Имел ввиду звездочки самому себе не ставить.
 
Ок это-то понятно. Куда её запихать я понять не могу...

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 id=Id_post then $result['error'] = true; ?
 
Я краб! Отставить панику :) Крабику очень тяжело ролик на мышки крутить :) Не увидел функцию:

function rate() {

Там она сплошным текстом, я привык что функции выделяют пустой строкой :)

З.Ы. Вот я закрабил-то... :(
 
Немного изменил мод, может кому надо..
Удаляем 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
Code:
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>';
    }


Почему появляется 2 списка ? 56656.webp
 
Что за ошибка
Fatal error: Call to undefined function append_sid() in /var/www/user148/data/www/reseler.vkristalle.ru/attach_mod/displaying_torrent.php on line 157
Вот сам код:
Code:
. append_sid("rate.php?a=" . $attach_id . "&v=" . $r ) .'\');" />'
 
Back
Top