[ 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 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { 33 exit("Access Denied"); 34 } 35 include_once XOOPS_ROOT_PATH."/modules/system/admin/smilies/smilies.php"; 36 $op ='SmilesAdmin'; 37 38 if (!empty($_GET['op'])) { 39 $op = $_GET['op']; 40 } elseif (!empty($_POST['op'])) { 41 $op = $_POST['op']; 42 } 43 44 switch($op) { 45 case "SmilesUpdate": 46 if (!$GLOBALS['xoopsSecurity']->check()) { 47 redirect_header('admin.php?fct=smilies', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 48 } 49 $count = (!empty($_POST['smile_id']) && is_array($_POST['smile_id'])) ? count($_POST['smile_id']) : 0; 50 $db =& Database::getInstance(); 51 for ($i = 0; $i < $count; $i++) { 52 $smile_id = intval($_POST['smile_id'][$i]); 53 if (empty($smile_id)) { 54 continue; 55 } 56 $smile_display = empty($_POST['smile_display'][$i]) ? 0 : 1; 57 if (isset($_POST['old_display'][$i]) && $_POST['old_display'][$i] != $smile_display[$i]) { 58 $db->query('UPDATE '.$db->prefix('smiles').' SET display='.$smile_display.' WHERE id ='.$smile_id); 59 } 60 } 61 redirect_header('admin.php?fct=smilies',2,_AM_DBUPDATED); 62 break; 63 64 case "SmilesAdd": 65 if (!$GLOBALS['xoopsSecurity']->check()) { 66 redirect_header('admin.php?fct=smilies', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 67 } 68 $db =& Database::getInstance(); 69 $myts =& MyTextSanitizer::getInstance(); 70 include_once XOOPS_ROOT_PATH.'/class/uploader.php'; 71 $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120); 72 $uploader->setPrefix('smil'); 73 if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { 74 if (!$uploader->upload()) { 75 $err = $uploader->getErrors(); 76 } else { 77 $smile_url = $uploader->getSavedFileName(); 78 $smile_code = $myts->stripSlashesGPC($_POST['smile_code']); 79 $smile_desc = $myts->stripSlashesGPC($_POST['smile_desc']); 80 $smile_display = intval($_POST['smile_display']) > 0 ? 1 : 0; 81 $newid = $db->genId($db->prefix('smilies')."_id_seq"); 82 $sql = sprintf("INSERT INTO %s (id, code, smile_url, emotion, display) VALUES (%d, %s, %s, %s, %d)", $db->prefix('smiles'), $newid, $db->quoteString($smile_code), $db->quoteString($smile_url), $db->quoteString($smile_desc), $smile_display); 83 if (!$db->query($sql)) { 84 $err = 'Failed storing smiley data into the database'; 85 } 86 } 87 } else { 88 $err = $uploader->getErrors(); 89 } 90 if (!isset($err)) { 91 redirect_header('admin.php?fct=smilies&op=SmilesAdmin',2,_AM_DBUPDATED); 92 } else { 93 xoops_cp_header(); 94 xoops_error($err); 95 xoops_cp_footer(); 96 } 97 break; 98 99 case "SmilesEdit": 100 $id = isset($_GET['id']) ? intval($_GET['id']) : 0; 101 if ($id > 0) { 102 SmilesEdit($id); 103 } 104 break; 105 106 case "SmilesSave": 107 $id = isset($_POST['id']) ? intval($_POST['id']) : 0; 108 if ($id <= 0 | !$GLOBALS['xoopsSecurity']->check()) { 109 redirect_header('admin.php?fct=smilies', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 110 } 111 $myts =& MyTextSanitizer::getInstance(); 112 $smile_code = $myts->stripSlashesGPC($_POST['smile_code']); 113 $smile_desc = $myts->stripSlashesGPC($_POST['smile_desc']); 114 $smile_display = intval($_POST['smile_display']) > 0 ? 1 : 0; 115 $db =& Database::getInstance(); 116 if ($_FILES['smile_url']['name'] != "") { 117 include_once XOOPS_ROOT_PATH.'/class/uploader.php'; 118 $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120); 119 $uploader->setPrefix('smil'); 120 if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { 121 if (!$uploader->upload()) { 122 $err = $uploader->getErrors(); 123 } else { 124 $smile_url = $uploader->getSavedFileName(); 125 if (!$db->query(sprintf("UPDATE %s SET code = %s, smile_url = %s, emotion = %s, display = %d WHERE id = %d", $db->prefix('smiles'), $db->quoteString($smile_code), $db->quoteString($smile_url), $db->quoteString($smile_desc), $smile_display, $id))) { 126 $err = 'Failed storing smiley data into the database'; 127 } else { 128 $oldsmile_path = str_replace("\\", "/", realpath(XOOPS_UPLOAD_PATH.'/'.trim($_POST['old_smile']))); 129 if (0 === strpos($oldsmile_path, XOOPS_UPLOAD_PATH) && is_file($oldsmile_path)) { 130 unlink($oldsmile_path); 131 } 132 } 133 } 134 } else { 135 $err = $uploader->getErrors(); 136 } 137 } else { 138 $sql = sprintf("UPDATE %s SET code = %s, emotion = %s, display = %d WHERE id = %d", $db->prefix('smiles'), $db->quoteString($smile_code), $db->quoteString($smile_desc), $smile_display, $id); 139 if (!$db->query($sql)) { 140 $err = 'Failed storing smiley data into the database'; 141 } 142 } 143 if (!isset($err)) { 144 redirect_header('admin.php?fct=smilies&op=SmilesAdmin',2,_AM_DBUPDATED); 145 } else { 146 xoops_cp_header(); 147 xoops_error($err); 148 xoops_cp_footer(); 149 exit(); 150 } 151 break; 152 153 case "SmilesDel": 154 $id = isset($_GET['id']) ? intval($_GET['id']) : 0; 155 if ($id > 0) { 156 xoops_cp_header(); 157 xoops_confirm(array('fct' => 'smilies', 'op' => 'SmilesDelOk', 'id' => $id), 'admin.php', _AM_WAYSYWTDTS); 158 xoops_cp_footer(); 159 } 160 break; 161 162 case "SmilesDelOk": 163 $id = isset($_POST['id']) ? intval($_POST['id']) : 0; 164 if ($id <= 0 | !$GLOBALS['xoopsSecurity']->check()) { 165 redirect_header('admin.php?fct=smilies', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 166 } 167 $db =& Database::getInstance(); 168 $sql = sprintf("DELETE FROM %s WHERE id = %u", $db->prefix('smiles'), $id); 169 $db->query($sql); 170 redirect_header("admin.php?fct=smilies&op=SmilesAdmin",2,_AM_DBUPDATED); 171 break; 172 173 case "SmilesAdmin": 174 default: 175 SmilesAdmin(); 176 break; 177 } 178 ?>
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 |
![]() |