作者:用户0h2eqqbg44 | 来源:互联网 | 2023-09-08 14:01
模板0102functionpostDigg(ftype,aid)03{04vartaget_objdocument.getElementById(diggNum+aid);050
模板
01 02function postDigg(ftype,aid) 03{04 var taget_obj = document.getElementById('diggNum'+aid); 05 06 var saveid = GetCOOKIE('diggid'); //所有赞过的文章id07 //alert(saveid);08 if(saveid != null) 09 {10 var saveids = saveid.split(','); 11 var hasid = false; 12 saveid = ''; 13 j = 1; 14 for(i=saveids.length-1;i>=0;i--) 15 {16 if(saveids[i]==aid && hasid) continue; //顶过 17 else { 18 if(saveids[i]==aid && !hasid) hasid = true; 19 saveid += (saveid=='' ? saveids[i] : ','+saveids[i]); 20 j++; 21 if(j==20 && hasid) break; 22 if(j==19 && !hasid) break; 23 } 24 } 25 if(hasid) {26 //alert("NI已经顶过该帖,请不要重复顶帖 !");27 //如果点击后,被赞过.则不需要更新统计,直接改变颜色28 $('#digg'+aid).addClass("icon-heart-on");29 return;30 } 31 else saveid += ','+aid; 32 SetCOOKIE('diggid',saveid,1); 33 34 } 35 else 36 { //如果COOKIE中无记录,则记录37 SetCOOKIE('diggid',aid,1);38 39 } 40 myajax = new DedeAjax(taget_obj,false,false,'','',''); 41 var url = "{dede:global.cfg_phpurl/}/digg_ajax_list.php?action="+ftype+"&id="+aid; 42 myajax.SendGet2(url);43 44 DedeXHTTP = null; 45} 46 47
{dede:arclist row='6' orderby='id' titlelen='100'}[field:goodpost/] {/dede:arclist}
css
.icon-heart2{ background: url(../images/bg-main.jpg) -22px 5px no-repeat;}.icon-heart2:hover{ background: url(../images/bg-main.jpg) 2px 4px no-repeat;}.icon-heart-on{ background: url(../images/bg-main.jpg) 2px 4px no-repeat;}
然后在,plus中新建立一个digg_ajax_list.PHP文件,内容为
01
ExecuteNoneQuery("Update `$maintable` set scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost=".time()." where id='$id'"); 20} 21$digg = ''; 22$row = $dsql->GetOne("Select goodpost,badpost,scores From `$maintable` where id='$id' "); 23if(!is_array($row)) 24{ 25 exit(); 26} 27if($row['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)*100; 34 $row['badper'] = 100-$row['goodper']; 35} 36 37if(empty($formurl)) $formurl = ''; 38if($formurl=='caicai') 39{ 40 if($action == 'good') $digg = $row['goodpost']; 41 if($action == 'bad') $digg = $row['badpost']; 42} 43else 44{ 45 $row['goodper'] = trim(sprintf("%4.2f", $row['goodper'])); 46 $row['badper'] = trim(sprintf("%4.2f", $row['badper'])); 47 $digg = ''.$row['goodpost']; //点击后,如果从没有被赞过,则自动把新的点击次数重写入目标位置.48} 49AjaxHead(); 50echo $digg; 51exit(); 52?>