From 0e05e6c061dfc98b40348cacaec864cffd358b3a Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 8 Jun 2021 02:01:35 +0800 Subject: [PATCH] details.php add magic --- public/common.js | 22 ++++++- public/details.php | 126 ++++++++++++++++++++++++++++++++++++++++ public/magic.php | 29 +++++++++ public/styles/boli.png | Bin 0 -> 1379 bytes public/styles/huise.png | Bin 0 -> 1132 bytes 5 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 public/magic.php create mode 100644 public/styles/boli.png create mode 100644 public/styles/huise.png diff --git a/public/common.js b/public/common.js index e8ba65d4..66baa26d 100644 --- a/public/common.js +++ b/public/common.js @@ -91,6 +91,26 @@ function unpreview(obj){ document.getElementById("previewbutton").style.display = 'block'; } +function saveMagicValue(torrentid,value) +{ + var list=ajax.posts('magic.php','value='+value +'&id='+torrentid); +// document.getElementById("thanksbutton").innerHTML = document.getElementById("thanksadded").innerHTML; + document.getElementById("magic_add").value += value; + document.getElementById("magic_add").style.display = ''; + document.getElementById("listNumber").style.display = 'none'; + document.getElementById("current_user_magic").style.display = ''; + var sumAll = document.getElementById("spanSumAll").innerHTML; + document.getElementById("spanSumAll").innerHTML = sumAll*1 + value; + if(document.getElementById("count_user_spa")){ + var userAll = document.getElementById("count_user_spa").innerHTML; + document.getElementById("count_user_spa").innerHTML = userAll*1 + 1; + } + + //document.getElementById("listNumber").innerHTML = ""; + +// document.getElementById("addcuruser").innerHTML = document.getElementById("curuser").innerHTML; +} + // java_klappe.js function klappe(id) @@ -383,4 +403,4 @@ function NewRow(anchor,up){ } function DelRow(anchor){ anchor.parentNode.parentNode.parentNode.parentNode.deleteRow(anchor.parentNode.parentNode.rowIndex); -} \ No newline at end of file +} diff --git a/public/details.php b/public/details.php index f90c7471..408fd168 100644 --- a/public/details.php +++ b/public/details.php @@ -403,6 +403,132 @@ echo $scronload; echo ""; } + //Add 魔力值奖励功能 + if(isset($magic_value_bonus)){ + $bonus_array = $magic_value_bonus; + }else{ + $bonus_array = '50 , 100 , 200 , 500, 1000'; + } + echo ' + '; + $magic_value_button = ''; + + if ($CURUSER['id'] <> $row['owner']) { + $arr_temp = explode(',',$bonus_array); + $bonus_has = $CURUSER['seedbonus']; + if(intval($bonus_has) < intval($arr_temp[0])){ + $error_bonus_message = $lang_details['magic_have_no_enough_bonus_value']; + $button_name = ""; + $magic_value_button .= $button_name; + }else{ + foreach($arr_temp as $key => $each_temp){ + $each_temp = intval($each_temp); + if ($each_temp > 0 && $each_temp <= $bonus_has) { + $button_name = $magic_value_button.$key; + $magic_button_id = 'magic_value_'.$key; + $each_temp_font = ''.('+'.$each_temp).''; + $error_bonus_message = $lang_details['magic_have_no_enough_bonus_value']; + $button_name = "
  • ".$each_temp_font."
  • "; + + $magic_value_button .= $button_name; + } + } + } + } + + $span_description = $lang_details['span_description_have_given']; + $span = ' '; + $whether_have_give_value = 0; + $give_value = array(); + $no_give = ""; + $add_value =""; + + $tempresult = sql_query ("SELECT count( DISTINCT `userid` ) as count FROM magic WHERE torrentid=".sqlesc($id)); + $count_user = mysql_fetch_array($tempresult); + $count_user_number = $count_user['count']; + + $give_value_sql = sql_query("SELECT userid,value FROM magic WHERE torrentid=".sqlesc($id)." ORDER BY id DESC"); + + $give_value_count = get_row_count("magic", "WHERE torrentid=".sqlesc($id)); + $give_value_all = mysql_num_rows($give_value_sql); + $sum_value = 0; + if ($give_value_all) { + while($rows_t = mysql_fetch_array($give_value_sql)) { + $give_value_userid = $rows_t["userid"]; + $sum_value += $rows_t["value"]*1; + if ($give_value_userid == $CURUSER['id']) { + $whether_have_give_value = 1; + $add_value = $rows_t["value"]; + } + $give_value[] = get_username($give_value_userid)." "; + } + }else $no_give = $lang_details['text_no_magic_added']; + + if(intval($bonus_has) < intval($arr_temp[0])){ + + }else if ($whether_have_give_value == 0 ) { + $magic_value_button = ''; + } else { + $add_value = str_replace("Number",$add_value,$lang_details['magic_value_number']); + $magic_value_button =""; + //$give_value = get_username($CURUSER['id'])." ".$give_value; + } + + $show_list = null; + $show_all = null; + $show_list_new_number = 6; + $other_user_str = null; + $other_user_span = null; + if(count($give_value) > 0){ + $count_user_span = ''.$count_user_number.''; + $magic_newest_record = ''. $lang_details['magic_newest_record'].''; + $show_list_description ='('. $magic_newest_record.$lang_details['magic_sum_user_give_number'].')'; + $show_list_description = str_replace('Number',$count_user_span,$show_list_description); + $output = array_slice($give_value, 0, $show_list_new_number); + foreach($output as $eachOutput){ + $show_list .= $eachOutput.' '; + } + //other user list + if(count($give_value) > $show_list_new_number){ + $show_list .= ' ...... '; + $show_all_description = '['.$lang_details['magic_show_all_description'].']'; + $show_all = ''.$show_all_description.''.'
    '; + $other_user_list = array_slice($give_value, $show_list_new_number, count($give_value)); + foreach($other_user_list as $each){ + $other_user_str .= $each.' '; + } + $other_user_span = ''; + } + }else{ + $show_list_description = null; + $haveGotBonus = $no_give; + } + $current_user_magic = " "; + $haveGotBonus = $lang_details['magic_haveGotBonus'].' '; + $spanSumAll = ''.$sum_value.''; + $haveGotBonus = str_replace('Number',$spanSumAll,$haveGotBonus); + $firstLine = '
    '.$magic_value_button.$span.$haveGotBonus.$show_all.'
    '; + $otherLine = '
    '.$current_user_magic.$show_list.$other_user_span.$show_list_description.'
    '; + tr($lang_details['magic_value_award'],$firstLine.$otherLine,1); + //End 魔力值奖励功能 + // ------------- start thanked-by block--------------// $torrentid = $id; diff --git a/public/magic.php b/public/magic.php new file mode 100644 index 00000000..6933aee3 --- /dev/null +++ b/public/magic.php @@ -0,0 +1,29 @@ + $CURUSER['seedbonus']) stderr('Error','You do not have such bonus!'); +$tsql = sql_query("SELECT owner FROM torrents WHERE id = $torrentid") or sqlerr(__FILE__,__LINE__); +$arr = mysql_fetch_assoc($tsql); +if (!$arr) stderr("Error", "Invalid torrent id!"); + +$torrentowner = $arr['owner']; +if($torrentowner == $userid) stderr('Error', 'You are giving magic to yourself.'); +$tsql = sql_query("SELECT COUNT(*) FROM magic WHERE torrentid=$torrentid and userid=$userid") or sqlerr(__FILE__,__LINE__); +$trows = mysql_fetch_assoc($tsql); +$t_ab = $trows[0]; +if ($t_ab != 0) stderr("Error", "You already gave the magic value!"); + +if (isset($userid) && isset($torrentid)&& isset($value)) { + sql_query("INSERT INTO magic (torrentid, userid,value) VALUES ($torrentid, $userid, $value)") or sqlerr(__FILE__,__LINE__); + KPS("-",$value,$CURUSER['id']);//selete + KPS("+",$value,$torrentowner);//add to the owner +} diff --git a/public/styles/boli.png b/public/styles/boli.png new file mode 100644 index 0000000000000000000000000000000000000000..4f88a1a17c1d0fc1ecce5834bedb66ac632b2080 GIT binary patch literal 1379 zcmV-p1)TbcP)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ=*-1n}RCwBA{Qv(y13D0>ozD!U0)aRLh*f}C3y3)x z1_nHZ;)6iE>_cd< z8IjpQ&f72FncjZ;&UpFRYo@)o9y8y4^I;uOsto9%`^fqL0toIAXe>;yRFul{(pLUs zBrEavFHrIyQ2O70h^qhp=@$)*P=X2MAE1wzfox_bM#gm)ZnDfdcIh)vHUj9G-7xh4 z0fg+4Ilj6o2`SbFzyADZ`2Pp!`o9oQfIaY^zW#v64A2jZOfZiCeZ=B?Ray+$_C#2dM{rU-X`ELkj_zUs_Q2rk@Jq?gYz-*9bSbzj8 zki!P_(P^M(x_2G_0+iANdgduW0I>i)Aq3aM|4$(P^$!#ypx6LmMo^s4 z)f1>5VuZ#DFh+m@%nFPZHlTA16lDHHnCbAYICZ5Rs4Na3fLMS;et@ASpAaA4uP=Z8 z|NjAu22gDLf#nT4#{{NF{)0U79~3K~q{YJY|35oW=nqiDQ(yBB&?8a6$Y=rxAdp95 zt<;tNd&Mhj5T+d$+0)(ba600M}G zo1IO8hnxGy7hqcY4vY<8(qaH5t-t?iU(}MCXF#4|`40|chQH8Uq$D8<4E7uL00G1z z%**{B6br!E`2QVHto063ojlNm6q8G%_BTmT60@`B1D6@UO@`OV18 zu>bXUhPS`|GJF80sjtAy0g4%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