blocksadmin.inc.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 613 行 · 第 1/2 页
PHP
613 行
<?php// $Id: main.php,v 1.12 2004/01/06 09:36:20 okazu Exp $// ------------------------------------------------------------------------ //// XOOPS - PHP Content Management System //// Copyright (c) 2000 XOOPS.org //// <http://www.xoops.org/> //// ------------------------------------------------------------------------ //// This program is free software; you can redistribute it and/or modify //// it under the terms of the GNU General Public License as published by //// the Free Software Foundation; either version 2 of the License, or //// (at your option) any later version. //// //// You may not change or alter any portion of this comment or credits //// of supporting developers from this source code or any supporting //// source code which is considered copyrighted (c) material of the //// original comment or credit authors. //// //// This program is distributed in the hope that it will be useful, //// but WITHOUT ANY WARRANTY; without even the implied warranty of //// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //// GNU General Public License for more details. //// //// You should have received a copy of the GNU General Public License //// along with this program; if not, write to the Free Software //// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //// ------------------------------------------------------------------------ //// Author: Kazumi Ono (AKA onokazu) //// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //// Project: The XOOPS Project //// ------------------------------------------------------------------------- //if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { exit('Access Denied');}include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php';include XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blocksadmin.php';$op = 'list';if ( !empty($_POST['op']) ) { $op = $_POST['op']; }if ( !empty($_POST['bid']) ) { $bid = intval($_POST['bid']); }if ( isset($_GET['op']) ) { if ($_GET['op'] == 'edit' || $_GET['op'] == 'delete' || $_GET['op'] == 'delete_ok' || $_GET['op'] == 'clone' /* || $_GET['op'] == 'previewpopup'*/) { $op = $_GET['op']; $bid = isset($_GET['bid']) ? intval($_GET['bid']) : 0; }}if (isset($_POST['previewblock'])) { //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { // exit('Invalid Referer'); //} if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) { redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); } if( empty( $bid ) ) die( 'Invalid bid.' ) ; if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } xoops_cp_header(); include_once XOOPS_ROOT_PATH.'/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->xoops_setCaching(0); $block['bid'] = $bid; if ($op == 'clone_ok') { $block['form_title'] = _AM_CLONEBLOCK; $block['submit_button'] = _CLONE; $myblock = new XoopsBlock(); $myblock->setVar('block_type', 'C'); } else { $op = 'update' ; $block['form_title'] = _AM_EDITBLOCK; $block['submit_button'] = _SUBMIT; $myblock = new XoopsBlock($bid); $block['name'] = $myblock->getVar('name'); } $myts =& MyTextSanitizer::getInstance(); $myblock->setVar('title', $myts->stripSlashesGPC($btitle)); $myblock->setVar('content', $myts->stripSlashesGPC($bcontent));// $dummyhtml = '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" /><meta http-equiv="content-language" content="'._LANGCODE.'" /><title>'.$xoopsConfig['sitename'].'</title><link rel="stylesheet" type="text/css" media="all" href="'.getcss($xoopsConfig['theme_set']).'" /></head><body><table><tr><th>'.$myblock->getVar('title').'</th></tr><tr><td>'.$myblock->getContent('S', $bctype).'</td></tr></table></body></html>'; /* $dummyfile = '_dummyfile_'.time().'.html'; $fp = fopen(XOOPS_CACHE_PATH.'/'.$dummyfile, 'w'); fwrite($fp, $dummyhtml); fclose($fp);*/ $block['edit_form'] = false; $block['template'] = ''; $block['op'] = $op; $block['side'] = $bside; $block['weight'] = $bweight; $block['visible'] = $bvisible; $block['title'] = $myblock->getVar('title', 'E'); $block['content'] = $myblock->getVar('content','n'); $block['modules'] =& $bmodule; $block['ctype'] = isset($bctype) ? $bctype : $myblock->getVar('c_type'); $block['is_custom'] = true; $block['cachetime'] = intval($bcachetime); echo '<a href="myblocksadmin.php">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '.$block['form_title'].'<br /><br />'; include dirname(__FILE__).'/../admin/myblockform.php'; //GIJ //echo '<a href="admin.php?fct=blocksadmin">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '.$block['form_title'].'<br /><br />'; //include XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blockform.php'; $xoopsGTicket->addTicketXoopsFormElement( $form , __LINE__ , 1800 , 'myblocksadmin' ) ; //GIJ $form->display(); $original_level = error_reporting( E_ALL ) ; echo " <table width='100%' class='outer' cellspacing='1'> <tr> <th>".$myblock->getVar('title')."</th> </tr> <tr> <td class='odd'>".$myblock->getContent('S', $bctype)."</td> </tr> </table>\n" ; error_reporting( $original_level ) ; xoops_cp_footer(); /* echo '<script type="text/javascript"> preview_window = openWithSelfMain("'.XOOPS_URL.'/modules/system/admin.php?fct=blocksadmin&op=previewpopup&file='.$dummyfile.'", "popup", 250, 200); </script>';*/ exit();}/* if ($op == 'previewpopup') { if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { exit('Invalid Referer'); } $file = str_replace('..', '', XOOPS_CACHE_PATH.'/'.trim($_GET['file'])); if (file_exists($file)) { include $file; @unlink($file); } exit();} *//* if ( $op == "list" ) { xoops_cp_header(); list_blocks(); xoops_cp_footer(); exit();} */if ( $op == 'order' ) { //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { // exit('Invalid Referer'); //} if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) { redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); } if ( !empty($_POST['side']) ) { $side = $_POST['side']; }// if ( !empty($_POST['weight']) ) { $weight = $_POST['weight']; } if ( !empty($_POST['visible']) ) { $visible = $_POST['visible']; }// if ( !empty($_POST['oldside']) ) { $oldside = $_POST['oldside']; }// if ( !empty($_POST['oldweight']) ) { $oldweight = $_POST['oldweight']; }// if ( !empty($_POST['oldvisible']) ) { $oldvisible = $_POST['oldvisible']; } if ( !empty($_POST['bid']) ) { $bid = $_POST['bid']; } else { $bid = array(); } // GIJ start foreach (array_keys($bid) as $i) { if( $side[$i] < 0 ) { $visible[$i] = 0 ; $side[$i] = -1 ; } else { $visible[$i] = 1 ; } $bmodule = (isset($_POST['bmodule'][$i]) && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : array(-1) ; myblocksadmin_update_block($i, $side[$i], $_POST['weight'][$i], $visible[$i], $_POST['title'][$i], null , null , $_POST['bcachetime'][$i], $bmodule, array());// if ( $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] || $oldside[$i] != $side[$i] )// order_block($bid[$i], $weight[$i], $visible[$i], $side[$i]); } $query4redirect = '?dirname=' . urlencode( strip_tags( substr( $_POST['query4redirect'] , 9 ) ) ) ; redirect_header("myblocksadmin.php$query4redirect",1,_AM_DBUPDATED); // GIJ end exit();}if ( $op == 'order2' ) { if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) { redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); } if( isset( $_POST['addblock'] ) && is_array( $_POST['addblock'] ) ) { // addblock foreach( $_POST['addblock'] as $bid => $val ) { myblocksadmin_update_blockinstance( 0, 0, 0, 0, '', null , null , 0, array(), array(), intval( $bid ) ); } } else { // else change order if ( !empty($_POST['side']) ) { $side = $_POST['side']; } if ( !empty($_POST['visible']) ) { $visible = $_POST['visible']; } if ( !empty($_POST['id']) ) { $id = $_POST['id']; } else { $id = array(); } foreach (array_keys($id) as $i) { // separate side and visible if( $side[$i] < 0 ) { $visible[$i] = 0 ; $side[$i] = -1 ; // for not to destroy the original position } else { $visible[$i] = 1 ; } $bmodule = (isset($_POST['bmodule'][$i]) && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : array(-1) ; myblocksadmin_update_blockinstance($i, $side[$i], $_POST['weight'][$i], $visible[$i], $_POST['title'][$i], null , null , $_POST['bcachetime'][$i], $bmodule, array()); } } $query4redirect = '?dirname=' . urlencode( strip_tags( substr( $_POST['query4redirect'] , 9 ) ) ) ; redirect_header("myblocksadmin.php$query4redirect",1,_MD_AM_DBUPDATED); exit;}/* if ( $op == 'save' ) { if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { exit('Invalid Referer'); } if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) { redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); } if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } save_block($bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bmodule, $bcachetime); exit();} */if ( $op == 'update' ) { //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { // exit('Invalid Referer'); //} if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) { redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); }/* if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } if ( !empty($_POST['options']) ) { $options = $_POST['options']; } else { $options = array(); } update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options);*/ $bcachetime = isset($_POST['bcachetime']) ? intval($_POST['bcachetime']) : 0; $options = isset($_POST['options']) ? $_POST['options'] : array(); $bcontent = isset($_POST['bcontent']) ? $_POST['bcontent'] : ''; $bctype = isset($_POST['bctype']) ? $_POST['bctype'] : ''; $bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : array(-1) ; // GIJ + $msg = myblocksadmin_update_block($_POST['bid'], $_POST['bside'], $_POST['bweight'], $_POST['bvisible'], $_POST['btitle'], $bcontent, $bctype, $bcachetime, $bmodule, $options); // GIJ ! redirect_header('myblocksadmin.php',1,$msg);}if ( $op == 'delete_ok' ) { //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { // exit('Invalid Referer'); //} if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) { redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); } // delete_block_ok($bid); GIJ imported from blocksadmin.php $myblock = new XoopsBlock($bid); if ( $myblock->getVar('block_type') != 'D' && $myblock->getVar('block_type') != 'C' ) { redirect_header('myblocksadmin.php',4,'Invalid block'); exit(); } $myblock->delete(); if ($myblock->getVar('template') != '' && ! defined('XOOPS_ORETEKI') ) { $tplfile_handler =& xoops_gethandler('tplfile'); $btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); if (count($btemplate) > 0) { $tplman->delete($btemplate[0]); } } redirect_header('myblocksadmin.php',1,_AM_DBUPDATED); exit(); // end of delete_block_ok() GIJ exit();}if ( $op == 'delete' ) { xoops_cp_header();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?