| [ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: main.php 2 2005-11-02 18:23:29Z skalpa $ 3 // ------------------------------------------------------------------------ // 4 // XOOPS - PHP Content Management System // 5 // Copyright (c) 2000 XOOPS.org // 6 // <http://www.xoops.org/> // 7 // ------------------------------------------------------------------------ // 8 // This program is free software; you can redistribute it and/or modify // 9 // it under the terms of the GNU General Public License as published by // 10 // the Free Software Foundation; either version 2 of the License, or // 11 // (at your option) any later version. // 12 // // 13 // You may not change or alter any portion of this comment or credits // 14 // of supporting developers from this source code or any supporting // 15 // source code which is considered copyrighted (c) material of the // 16 // original comment or credit authors. // 17 // // 18 // This program is distributed in the hope that it will be useful, // 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 21 // GNU General Public License for more details. // 22 // // 23 // You should have received a copy of the GNU General Public License // 24 // along with this program; if not, write to the Free Software // 25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 26 // ------------------------------------------------------------------------ // 27 // Author: Kazumi Ono (AKA onokazu) // 28 // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // 29 // Project: The XOOPS Project // 30 // ------------------------------------------------------------------------- // 31 /** 32 * Manage user rank. 33 * @copyright XOOPS Project 34 * @todo Fix register_globals! 35 **/ 36 37 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { 38 exit("Access Denied"); 39 } 40 41 $op = 'RankForumAdmin'; 42 43 if (isset($_GET['op'])) { 44 $op = $_GET['op']; 45 } elseif (isset($_POST['op'])) { 46 $op = $_POST['op']; 47 } 48 49 switch ($op) { 50 51 case "RankForumEdit": 52 $rank_id = isset($_GET['rank_id']) ? intval($_GET['rank_id']) : 0; 53 if ($rank_id > 0) { 54 include_once XOOPS_ROOT_PATH."/modules/system/admin/userrank/userrank.php"; 55 RankForumEdit($rank_id); 56 } 57 break; 58 59 case "RankForumDel": 60 $rank_id = isset($_GET['rank_id']) ? intval($_GET['rank_id']) : 0; 61 if ($rank_id > 0) { 62 xoops_cp_header(); 63 xoops_confirm(array('fct' => 'userrank', 'op' => 'RankForumDelGo', 'rank_id' => $rank_id), 'admin.php', _AM_WAYSYWTDTR); 64 xoops_cp_footer(); 65 } 66 break; 67 68 case "RankForumDelGo": 69 $rank_id = isset($_POST['rank_id']) ? intval($_POST['rank_id']) : 0; 70 if ($rank_id <= 0 | !$GLOBALS['xoopsSecurity']->check()) { 71 redirect_header("admin.php?fct=userrank", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 72 } 73 $db =& Database::getInstance(); 74 $sql = sprintf("DELETE FROM %s WHERE rank_id = %u", $db->prefix("ranks"), $rank_id); 75 $db->query($sql); 76 redirect_header("admin.php?fct=userrank&op=ForumAdmin",1,_AM_DBUPDATED); 77 break; 78 79 case "RankForumAdd": 80 if (!$GLOBALS['xoopsSecurity']->check()) { 81 redirect_header("admin.php?fct=userrank", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 82 } 83 $db =& Database::getInstance(); 84 $myts =& MyTextSanitizer::getInstance(); 85 $rank_special = isset($_POST['rank_special']) && intval($_POST['rank_special']) ? 1 : 0; 86 $rank_title = $myts->stripSlashesGPC($_POST['rank_title']); 87 $rank_image = ''; 88 include_once XOOPS_ROOT_PATH.'/class/uploader.php'; 89 $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120); 90 $uploader->setPrefix('rank'); 91 if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { 92 if ($uploader->upload()) { 93 $rank_image = $uploader->getSavedFileName(); 94 } 95 } 96 $newid = $db->genId($db->prefix("ranks")."_rank_id_seq"); 97 if ($rank_special == 1) { 98 $sql = "INSERT INTO ".$db->prefix("ranks")." (rank_id, rank_title, rank_min, rank_max, rank_special, rank_image) VALUES ($newid, ".$db->quoteString($rank_title).", -1, -1, 1, ".$db->quoteString($rank_image).")"; 99 } else { 100 $sql = "INSERT INTO ".$db->prefix("ranks")." (rank_id, rank_title, rank_min, rank_max, rank_special, rank_image) VALUES ($newid, ".$db->quoteString($rank_title).", ".intval($_POST['rank_min'])." , ".intval($_POST['rank_max'])." , 0, ".$db->quoteString($rank_image).")"; 101 } 102 if (!$db->query($sql)) { 103 xoops_cp_header(); 104 xoops_error('Failed storing rank data into the database'); 105 xoops_cp_footer(); 106 } else { 107 redirect_header("admin.php?fct=userrank&op=RankForumAdmin",1,_AM_DBUPDATED); 108 } 109 break; 110 111 case "RankForumSave": 112 $rank_id = isset($_POST['rank_id']) ? intval($_POST['rank_id']) : 0; 113 if ($rank_id <= 0 | !$GLOBALS['xoopsSecurity']->check()) { 114 redirect_header("admin.php?fct=userrank", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 115 } 116 $db =& Database::getInstance(); 117 $myts =& MyTextSanitizer::getInstance(); 118 $rank_special = isset($_POST['rank_special']) && intval($_POST['rank_special']) ? 1 : 0; 119 $rank_title = $myts->stripSlashesGPC($_POST['rank_title']); 120 $delete_old_image = false; 121 include_once XOOPS_ROOT_PATH.'/class/uploader.php'; 122 $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120); 123 $uploader->setPrefix('rank'); 124 if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { 125 if ($uploader->upload()) { 126 $rank_image = $uploader->getSavedFileName(); 127 $delete_old_image = true; 128 } 129 } 130 if ($rank_special > 0) { 131 $_POST['rank_min'] = $_POST['rank_max'] = -1; 132 } 133 $sql = "UPDATE ".$db->prefix("ranks")." SET rank_title = ".$db->quoteString($rank_title).", rank_min = ".intval($_POST['rank_min']).", rank_max = ".intval($_POST['rank_max']).", rank_special = ".$rank_special; 134 if ($delete_old_image) { 135 $sql .= ", rank_image = ".$db->quoteString($rank_image); 136 } 137 $sql .= " WHERE rank_id = ".$rank_id; 138 if (!$db->query($sql)) { 139 xoops_cp_header(); 140 xoops_error('Failed storing rank data into the database'); 141 xoops_cp_footer(); 142 } else { 143 if ($delete_old_image) { 144 $old_rank_path = str_replace("\\", "/", realpath(XOOPS_UPLOAD_PATH.'/'.trim($_POST['old_rank']))); 145 if (0 === strpos($old_rank_path, XOOPS_UPLOAD_PATH) && is_file($old_rank_path)) { 146 unlink($old_rank_path); 147 } 148 } 149 redirect_header("admin.php?fct=userrank&op=RankForumAdmin",1,_AM_DBUPDATED); 150 } 151 break; 152 153 default: 154 include_once XOOPS_ROOT_PATH."/modules/system/admin/userrank/userrank.php"; 155 RankForumAdmin(); 156 break; 157 } 158 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
|