翼享吧 关注:164贴子:2,250
  • 3回复贴,共1

【技术转】五步打造你个性化的Nexusphp PT站

取消只看楼主收藏回复

国内使用Nexusphp建立的PT站越来越多,风格大都雷同(正如yofeng同学所说的审美疲劳......),如何把Nexusphp快速配置成你喜欢的界面、风格,本人在这里抛砖引玉,希望大家在这里开放的讨论、共享使用Nexusphp建站心得,OK,Let's doing...
第一步:为用户等级追加标识
方法:以简体中文为例,打开nexusphp.v1.5.beta4.2010XXXX\lang\chs\lang_functions.php修改257-266行下列设置(如果要其他语种也需要,则每种语言包都要配置):
修改前:
-------------------------------------------
'text_peasant' => "Peasant",
'text_user' => "User",
'text_power_user' => "Power User",
'text_elite_user' => "Elite User",
'text_crazy_user' => "Crazy User",
'text_insane_user' => "Insane User",
'text_veteran_user' => "Veteran User",
'text_extreme_user' => "Extreme User",
'text_ultimate_user' => "Ultimate User",
'text_nexus_master' => "Nexus Master",
============================
'text_peasant' => "(堕落者)Peasant",
'text_user' => "(穷人)User",
'text_power_user' => "(百姓)Power User",
'text_elite_user' => "(小康)Elite User",
'text_crazy_user' => "(大康)Crazy User",
'text_insane_user' => "(中产)Insane User",
'text_veteran_user' => "(富商)Veteran User",
'text_extreme_user' => "(银行家)Extreme User",
'text_ultimate_user' => "(豪门)Ultimate User",
'text_nexus_master' => "(贵族)Nexus Master",
--------------------------------------------
注意:Web服务器需要重启http生效!

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
第二步:关闭搜索箱
应用此风格的有CHDbits、TCCF、Pig2Pig等
为什么要关闭?Nexusphp的搜索箱功能十分强大,不过对用户来说并不是每次都要使用的,且所占版面较大(个人觉得也是版面看起来雷同的一大因素),由于在后台和数据库中无相关配置项,故需要对程序进行修改:
打开主目录下的torrents.php文件,查找874-876行,来到这里:
<td class="colhead" align="center" colspan="2"><a href="javascript: klappe_news('searchboxmain')"><img class="minus" src="pic/trans.gif" id="picsearchboxmain" alt="Show/Hide" /><?php echo $lang_torrents['text_search_box'] ?></a></td>
</tr></tbody>
<tbody id="ksearchboxmain">
将 class="minus" 改成 class="plus"
在 <tbody id="ksearchboxmain">中追加<tbody id="ksearchboxmain" style="display:none">
完成后,代码变为:
<td class="colhead" align="center" colspan="2"><a href="javascript: klappe_news('searchboxmain')"><img class="plus" src="pic/trans.gif" id="picsearchboxmain" alt="Show/Hide" /><?php echo $lang_torrents['text_search_box'] ?></a></td>
</tr></tbody>
<tbody id="ksearchboxmain" style="display:none">



IP属地:湖北1楼2013-02-23 18:37回复

    ---------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------
    第三步: 增加种子类别快速搜索功能
    应用此风格的有HDcity、高清第一等
    Nexusphp种子在高亮模式下本来就有此功能,不过大多数站点缺省模式下并不流行种子高亮显示方式(本人所了解的有HDStar及部分刚运营的PT站),通过颜色来判断种子类别还是有难度的!最流行的还是以字符和图标显示(可以通过配置数据库user表来预置),但在这两种模式下恰恰没有快速搜索的字符按钮,不过我们可以通过修改代码来增加它:
    打开主目录下的torrents.php文件,查找1075-1077行,来到这里
    if ($count) {
    print($pagertop);
    if ($sectiontype == $browsecatmode)
    在上面中第二行与第三行之间插入“print("<p align=\"center\"> ".$lang_functions['text_promoted_torrents_note']."</p>\n");” //这一句是完全引用作者在高亮模式下内建的语句!
    修改后代码如下:
    if ($count) {
    print($pagertop);
    print("<p align=\"center\"> ".$lang_functions['text_promoted_torrents_note']."</p>\n"); //此处是在搜索箱下部位置插入,你也可以选择在其他位置插入!
    if ($sectiontype == $browsecatmode)
    torrenttable($res, "torrents");

    ---------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------
    第四步:改变置顶种子格子颜色
    应用此风格的有CHDbits、皇后等
    改变颜色有助于用户更醒目、更直观的区分置顶帖(当然方法有很多,看个人喜好,部分PT站使用“置顶”字符,CHDbits还更换了置顶标识),前些时间看到有人评价皇后的置顶种子颜色很“媚”,决定自己也改一改:
    打开主目录/include/functions.php,查找3021-3023行,来到这里:
    $id = $row["id"];
    $sphighlight = get_torrent_bg_color($row['sp_state']);
    print("<tr" . $sphighlight . ">\n");
    修改程序为(用下面五行替换上面3行):
    $id = $row["id"];
    if ($row['pos_state'] == 'sticky' && $CURUSER['appendsticky'] == 'yes') {
    $sphighlight = " class='twoupfree_bg'";
    }
    else $sphighlight = get_torrent_bg_color($row['sp_state']);
    print("<tr" . $sphighlight . ">\n");
    注意:上面$sphighlight = " class='twoupfree_bg'"; 中的class='twoupfree_bg'是赋予置顶种子格子的显示颜色,属性在风格目录下的theme.css文件中定义,可以根据下面sample自行添加,然后替换上面代码中的“'twoupfree_bg'”(注意每种风格都要添加),如果嫌麻烦就直接借用种子类型的一种,本例选择了twoupfree_bg,即与2X上传颜色相同。
    .free{color:#f0cc00}
    .twoup{color:#aaaaaa}
    .twoupfree{color:#99cc66}
    .halfdown{color:#7c7ff6}
    .twouphalfdown{color:#7ad6ea}
    .thirtypercent{color:#70328d}
    .free_bg{background-color:#ffff99}
    .twoup_bg{background-color:#dddddd}
    .twoupfree_bg{background-color:#ccff99}
    .halfdown_bg{background-color:#cccdf8}
    .twouphalfdown_bg{background-color: #96dbea}
    .thirtypercentdown_bg{background-color:#ddc3ea}
    注:在黑色风格下无效。


    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------


    IP属地:湖北2楼2013-02-23 18:37
    回复
      }
      case 4:
      {
      if ($showtimeleft && (($expiretwoupfree_torrent && $promotionTimeType == 0) || $promotionTimeType == 2))
      {
      if ($promotionTimeType == 2) {
      $futuretime = strtotime($promotionUntil);
      } else {
      $futuretime = strtotime($added) + $expiretwoupfree_torrent * 86400;
      }
      $timeout = gettime(date("Y-m-d H:i:s", $futuretime), false, false, true, false, true);
      if ($timeout)
      $onmouseover_sub = " (<font color='#00CC66'>".$lang_functions['text_will_end_in'].$timeout."</font>".")"; //2XFree 显示为青色,可以更改它
      else $promotion = 1;
      }
      break;
      }
      case 5:
      {
      if ($showtimeleft && (($expirehalfleech_torrent && $promotionTimeType == 0) || $promotionTimeType == 2))
      {
      if ($promotionTimeType == 2) {
      $futuretime = strtotime($promotionUntil);
      } else {
      $futuretime = strtotime($added) + $expirehalfleech_torrent * 86400;
      }
      $timeout = gettime(date("Y-m-d H:i:s", $futuretime), false, false, true, false, true);
      if ($timeout)
      $onmouseover_sub = " (".$lang_functions['text_will_end_in'].$timeout.")";
      else $promotion = 1;
      }
      break;
      }
      case 6:
      {
      if ($showtimeleft && (($expiretwouphalfleech_torrent && $promotionTimeType == 0) || $promotionTimeType == 2))
      {
      if ($promotionTimeType == 2) {
      $futuretime = strtotime($promotionUntil);
      } else {
      $futuretime = strtotime($added) + $expiretwouphalfleech_torrent * 86400;
      }
      $timeout = gettime(date("Y-m-d H:i:s", $futuretime), false, false, true, false, true);
      if ($timeout)
      $onmouseover_sub = " (".$lang_functions['text_will_end_in'].$timeout.")";
      else $promotion = 1;
      }
      break;
      }
      case 7:
      {
      if ($showtimeleft && (($expirethirtypercentleech_torrent && $promotionTimeType == 0) || $promotionTimeType == 2))
      {
      if ($promotionTimeType == 2) {
      $futuretime = strtotime($promotionUntil);
      } else {
      $futuretime = strtotime($added) + $expirethirtypercentleech_torrent * 86400;
      }
      $timeout = gettime(date("Y-m-d H:i:s", $futuretime), false, false, true, false, true);
      if ($timeout)
      $onmouseover_sub = " (".$lang_functions['text_will_end_in'].$timeout.")";
      else $promotion = 1;
      }
      break;
      }
      }
      }
      if (($CURUSER['appendpromotion'] == 'word' && $forcemode == "" ) || $forcemode == 'word'){
      if(($promotion==2 && get_global_sp_state() == 1) || get_global_sp_state() == 2){
      $sp_torrent_sub = $onmouseover_sub;
      }
      elseif(($promotion==3 && get_global_sp_state() == 1) || get_global_sp_state() == 3){
      $sp_torrent_sub = $onmouseover_sub;
      }
      elseif(($promotion==4 && get_global_sp_state() == 1) || get_global_sp_state() == 4){


      IP属地:湖北4楼2013-02-23 18:40
      回复
        $sp_torrent_sub = $onmouseover_sub;
        }
        elseif(($promotion==5 && get_global_sp_state() == 1) || get_global_sp_state() == 5){
        $sp_torrent_sub = $onmouseover_sub;
        }
        elseif(($promotion==6 && get_global_sp_state() == 1) || get_global_sp_state() == 6){
        $sp_torrent_sub = $onmouseover_sub;
        }
        elseif(($promotion==7 && get_global_sp_state() == 1) || get_global_sp_state() == 7){
        $sp_torrent_sub = $onmouseover_sub;
        }
        }
        elseif (($CURUSER['appendpromotion'] == 'icon' && $forcemode == "") || $forcemode == 'icon'){
        if(($promotion==2 && get_global_sp_state() == 1) || get_global_sp_state() == 2)
        $sp_torrent_sub = $onmouseover_sub;
        elseif(($promotion==3 && get_global_sp_state() == 1) || get_global_sp_state() == 3)
        $sp_torrent_sub = $onmouseover_sub;
        elseif(($promotion==4 && get_global_sp_state() == 1) || get_global_sp_state() == 4)
        $sp_torrent_sub = $onmouseover_sub;
        elseif(($promotion==5 && get_global_sp_state() == 1) || get_global_sp_state() == 5)
        $sp_torrent_sub = $onmouseover_sub;
        elseif(($promotion==6 && get_global_sp_state() == 1) || get_global_sp_state() == 6)
        $sp_torrent_sub = $onmouseover_sub;
        elseif(($promotion==7 && get_global_sp_state() == 1) || get_global_sp_state() == 7)
        $sp_torrent_sub = $onmouseover_sub;
        }
        return $sp_torrent_sub;
        }
        ---------------------
        Step2:功能调用
        $banned_torrent = ($row["banned"] == 'yes' ? " (".$lang_functions['text_banned'].")" : "");
        print($banned_torrent.$picked_torrent.$sp_torrent);
        两行之间擦汗如代码:$sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row["added"], $row['promotion_time_type'], $row['promotion_until']); //调用新的函数,获取过期时间
        最后一行修改为:print($banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub); //在主标题上附加显示过期提示
        修改后的代码:
        ------------
        $banned_torrent = ($row["banned"] == 'yes' ? " (".$lang_functions['text_banned'].")" : "");
        $sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row["added"], $row['promotion_time_type'], $row['promotion_until']);
        print($banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub);
        ------------




        IP属地:湖北5楼2013-02-23 18:40
        回复