source: branches/feature-module-update/html/admin/system/rank.php @ 16582

Revision 16582, 3.0 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23require_once("../require.php");
24
25$conn = new SC_DbConn();
26
27// 認証可否の判定
28$objSess = new SC_Session();
29sfIsSuccess($objSess);
30
31// ランキングの変更
32if($_GET['move'] == 'up') {
33    // 正当な数値であった場合
34    if(sfIsInt($_GET['id'])){
35        lfRunkUp($conn, $_GET['id']);
36    } else {
37        // エラー処理
38        gfPrintLog("error id=".$_GET['id']);
39    }
40} else if($_GET['move'] == 'down') {
41    if(sfIsInt($_GET['id'])){
42        lfRunkDown($conn, $_GET['id']);
43    }  else {
44        // エラー処理
45        gfPrintLog("error id=".$_GET['id']);
46    }
47}
48
49// ページの表示
50$location = "Location: " . URL_SYSTEM_TOP . "?pageno=".$_GET['pageno'];
51header($location);
52
53// ランキングを上げる。
54function lfRunkUp($conn, $id) {
55    // 自身のランクを取得する。
56    $rank = $conn->getOne("SELECT rank FROM dtb_member WHERE member_id = ".$id);
57    // ランクの最大値を取得する。
58    $maxno = $conn->getOne("SELECT max(rank) FROM dtb_member");
59    // ランクが最大値よりも小さい場合に実行する。
60    if($rank < $maxno) {
61        // ランクがひとつ上のIDを取得する。
62        $sqlse = "SELECT member_id FROM dtb_member WHERE rank = ?";
63        $up_id = $conn->getOne($sqlse, $rank + 1);
64        // ランク入れ替えの実行
65        $conn->query("BEGIN");
66        $sqlup = "UPDATE dtb_member SET rank = ? WHERE member_id = ?";
67        $conn->query($sqlup, array($rank + 1, $id));
68        $conn->query($sqlup, array($rank, $up_id));
69        $conn->query("COMMIT");
70    }
71}
72
73// ランキングを下げる。
74function lfRunkDown($conn, $id) {
75    // 自身のランクを取得する。
76    $rank = $conn->getOne("SELECT rank FROM dtb_member WHERE member_id = ".$id);
77    // ランクの最小値を取得する。
78    $minno = $conn->getOne("SELECT min(rank) FROM dtb_member");
79    // ランクが最大値よりも大きい場合に実行する。
80    if($rank > $minno) {
81        // ランクがひとつ下のIDを取得する。
82        $sqlse = "SELECT member_id FROM dtb_member WHERE rank = ?";
83        $down_id = $conn->getOne($sqlse, $rank - 1);
84        // ランク入れ替えの実行
85        $conn->query("BEGIN");
86        $sqlup = "UPDATE dtb_member SET rank = ? WHERE member_id = ?";
87        $conn->query($sqlup, array($rank - 1, $id));
88        $conn->query($sqlup, array($rank, $down_id));
89        $conn->query("COMMIT");
90    }
91}   
92?>
Note: See TracBrowser for help on using the repository browser.