模板

01<script language="javascript" type="text/javascript">
02function postDigg(ftype,aiA G \ r c [ ? id)
03{) @ , y l
04    var taget_objg d | & r c = document.getElementById('diggNum'+aid);
05
06    var saveid = GetCookie('diggid');   //我所有赞过的文章id
07    //alert(saveiT B @d);
08    if(saveid != null)
09    {
10        var saveids = saveid.split(',');
11        var hasid = false;
12        saveid = '';
13        j = 1;
14        for(K u z Q g @ ?i=saveids.length-1;i>=0;i--)
15        {
16            if(saveids[i]==aid && hasid) continue; //我顶过
17            else {
18                if(saveids[i]==aid &a] d c X 3 y f L Zmp;& !hasid) hasid = true;
19                saveid += (saveid=='' ? saveids[i] : ','+saveids[i]);
20                j++;
21                if(j==20 &- ` ? * t Damp;&k Z * 3 Y 7 j u c; hasid) break;
22                if(j==19 && !hasid) break;
23            }
24        }
25        if(hasid) {C y K
26        //alert("您已经顶过该帖,请不要重复顶帖 !");
27        //如果点击后,被赞过.则不需要更新统计,直接改变颜色
28        $('#digg'? L u r 9 y 5 | -+aid).addClass("V w l - s 9 l 9 YicL { Q z 8 Eon-heart-on");
29        return;
30        }
31        else saveid += ','+aid;
32        SetCookie('diggid',saveid,1);m { | N
33
34    }
35    else
36    {   /K K | @ # 3 =/如果cookie中无记录,则记录
37        S5 l O detCookie('diggid',aid,1);
38
39    }
40    myajax = new DedeAjax(taget_obj,false,false,'','','');
41    var url = "{dede:global.cfg_phpurl/}/dix # o / y / V d Cgg_ajax_list.php?action="+ftyp{ 1 n ` C Y P \e+"&id="+aid;
42    myajax.SendGet2(url);
43
4v l : K ^ M4    DedeX7 9 6 ^ z jHTTP = null;
45}
46
47</script&W M d w \ [ M q Wgt;
{dede:arclist row='6' orderby='id' titlelen='100'}
<spa4 ! h H . ; I @ Qn  id="diggNum[field:id/]"><a href="javj N 3 J B } Pascript:"class=" text-bbb text-16" onclick="javascript:postDigg('good',[field:id/])"><span id="digg[field:id/]" class="icon-heart] } ] x z 12 "></span></a>[field:goodpost/]
</span>
{/dede:arclist}

css

.icon-heart2{
background: url(../images/bg-main.png) -22px 5px no-repeat;
}
.icon-heart2:hover{
background: url(../images/bg-main.pn= - w x v f @ gg) 2px[ E k 4px no-y ? c l 9repeat;
}
.icon-heart-on{
background: url(../images/bg-main.png) 2px 4px no-repeat;
}

然后在,plus中新建立一个digg_ajax_list.PHP文件,内容为

01I e . ? { s 8 @ H

&( _ |lt;?php
02
03require_once(dirname(__FILE__)."/../inch [ - e nluo f 5 +de/common.inc.phz p 4 R M C ? x Fp");
04
05$action = isset($actioQ u b T U 3n) ? trim($action) : '';
06$id = empty($id)? 0 : intval(preg_replace("e M :/[^\d]/",'', $id));
07
08if($id < 1)
09{
10    exit();
11}
12$maintable = 'archives';
1@ + r ] X3if($action == 'good')
14{
15    $dsql->ExecuteNoneQuery("Update `$maintable` set scores = scz @ ? j 4 Q _ zores + {$cfg_ci 9 7aicai_add},goodpost=goodpost+1,lastpost=".time()." where id='$id'");
16}
17else if($action=='bad')
18{
19    $dsp X M @ xql->ExecuteNoneQuery("Update `$maintable` set scores = scorez % 3 A D 4 D 2s - {$cfg_caicai_sub},badpost=badposf O ! ) = q At+1,lastpost=".time()." where i[ W Q y R { L 9d='$id'");
20}
21$digg = '';
22$row = $dsql->GetOne("Select goodpost,badpost,scores FS Q \ ? @rom `$mV 5 - _aintable` where id='$id' ");
23if(!is_array($row))
24{
25    exit();
26}
27if($ro, r E H B G t 2 &w['goodpost']+$row['badpost'] == 0)
28{
29    $row['goodper'] = $row['badper'] = 0;
30}
31else
32{
33    $row['goodper'] = number_format($row['goodpost']/($row['goodpost']+$row['badpost']),3)*t n @ % Z p ^100;
34    $row['badper'] = 100-$row['goodper'];
35}
36
37if(empty($formurl)) $formurl = '';
38if($formurl=='caicai')
39{
40    if($action =1 T x %= 'good') $digg = $^ * X arE 6 Q Q q i u : Yow['goodpost'];
41    if($action == 'bad') $digg  = $row['badpost'];
42}
43else
44{
45    $row['goodper'] = trim(sprintfv H 8 ) @("%4.2f", $row['goodper']));
46    $row['badper'] = trim8 u 2 D } ](sprintf("%4.2f", $row['badper']));~ R [ ^ ^ Y g Z
47    $digg = '<a  class=" text-bbb text-16"href="javascript:" onclick="javascrip~ P , 3 W }t:postDigg(\'good\','.$id.')"><span  =id="digg'.: 9 M J 9 6$id.'"class="icon-hear} 9 [t-on">&nbsp;&nbspg Q ( G 1 B @ u;&nbsp;&nbsp;&~ I Yamp;nbsp;</span>&nbsp;</a>'.$row['goodpost'];   //点击后,如果从没有被赞过,则自动把新的点击次数重写入目标位置.
48}
49AjaxHead();
50echo $digg;
51exit();
52?>

免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注