⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.php

📁 讲的是网络编程
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php// $Id: main.php 1029 2007-09-09 03:49:25Z phppp $//  ------------------------------------------------------------------------ ////                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");} else {    $op = 'list';    if (isset($_POST)) {        foreach ( $_POST as $k => $v ) {            ${$k} = $v;        }    }    if (isset($_GET['op'])) {        $op = trim($_GET['op']);        $id = $moddir = $file = $type = $tplset = null;        if (isset($_GET['id'])) {            $id = intval($_GET['id']);        }        if (isset($_GET['moddir'])) {            $moddir = trim($_GET['moddir']);        }        if (isset($_GET['file'])) {            $file = trim($_GET['file']);        }        if (isset($_GET['type'])) {            $type = trim($_GET['type']);        }        if (isset($_GET['tplset'])) {            $tplset = trim($_GET['tplset']);        }    }    if ($op == 'edittpl_go') {        if (isset($previewtpl)) {            $op = 'previewtpl';        }    }    switch ($op) {    case 'list':        $tplset_handler =& xoops_gethandler('tplset');        $tplsets =& $tplset_handler->getObjects();        xoops_cp_header();        echo '<h4 style="text-align:left">'._MD_TPLMAIN.'</h4>';        $installed = array();        $tpltpl_handler =& xoops_gethandler('tplfile');        $installed_mods = $tpltpl_handler->getModuleTplCount('default');        $tcount = count($tplsets);        echo '<table width="100%" cellspacing="1" class="outer"><tr align="center"><th width="25%">'._MD_THMSETNAME.'</th><th>'._MD_CREATED.'</th><th>'._MD_TEMPLATES.'</th><th>'._MD_ACTION.'</th><th>&nbsp;</th></tr>';        $class = 'even';        for ($i = 0; $i < $tcount; $i++) {            $tplsetname = $tplsets[$i]->getVar('tplset_name');            $installed_themes[] = $tplsetname;            $class = ($class == 'even') ? 'odd' : 'even';            echo '<tr class="'.$class.'" align="center"><td class="head">'.$tplsetname.'<br /><br /><span style="font-weight:normal;">'.$tplsets[$i]->getVar('tplset_desc').'</span></td><td>'.formatTimestamp($tplsets[$i]->getVar('tplset_created'), 's').'</td><td align="left"><ul>';            $tplstats = $tpltpl_handler->getModuleTplCount($tplsetname);            if (count($tplstats) > 0) {                $module_handler =& xoops_gethandler('module');                echo '<ul>';                foreach ($tplstats as $moddir => $filecount) {                    $module =& $module_handler->getByDirname($moddir);                    if (is_object($module)) {                        if ($installed_mods[$moddir] > $filecount) {                            $filecount = '<span style="color:#ff0000;">'.$filecount.'</span>';                        }                    echo '<li>'.$module->getVar('name').' [<a href="admin.php?fct=tplsets&amp;op=listtpl&amp;tplset='.$tplsetname.'&amp;moddir='.$moddir.'">'._LIST.'</a> (<b>'.$filecount.'</b>)]</li>';                    }                    unset($module);                }                $not_installed = array_diff(array_keys($installed_mods), array_keys($tplstats));            } else {                $not_installed =& array_keys($installed_mods);            }            foreach ($not_installed as $ni) {                $module =& $module_handler->getByDirname($ni);                echo '<li>'.$module->getVar('name').' [<a href="admin.php?fct=tplsets&amp;op=listtpl&amp;tplset='.$tplsetname.'&amp;moddir='.$ni.'">'._LIST.'</a> (<span style="color:#ff0000; font-weight: bold;">0</span>)] [<a href="admin.php?fct=tplsets&amp;op=generatemod&amp;tplset='.$tplsetname.'&amp;moddir='.$ni.'">'._MD_GENERATE.'</a>]</li>';            }            echo '</ul></td><td>';            echo '[<a href="admin.php?fct=tplsets&amp;op=download&amp;method=tar&amp;tplset='.$tplsetname.'">'._MD_DOWNLOAD.'</a>]<br />[<a href="admin.php?fct=tplsets&amp;op=clone&amp;tplset='.$tplsetname.'">'._CLONE.'</a>]';            if ($tplsetname != 'default' && $tplsetname != $xoopsConfig['template_set']) {                echo '<br />[<a href="admin.php?fct=tplsets&amp;op=delete&amp;tplset='.$tplsetname.'">'._DELETE.'</a>]';            }            echo '</td>';            if ($tplsetname == $xoopsConfig['template_set']) {                echo '<td><img src="'.XOOPS_URL.'/modules/system/images/check.gif" alt="'._MD_DEFAULTTHEME.'" /></td>';            } else {                echo '<td>&nbsp;</td>';            }            echo '</tr>';        }        echo '</table><br />';        include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';        $form = new XoopsThemeForm(_MD_UPLOADTAR, 'tplupload_form', 'admin.php', 'post', true);        $form->setExtra('enctype="multipart/form-data"');        $form->addElement(new XoopsFormFile(_MD_CHOOSETAR.'<br /><span style="color:#ff0000;">'._MD_ONLYTAR.'</span>', 'tpl_upload', 1000000));        $form->addElement(new XoopsFormText(_MD_NTHEMENAME.'<br /><span style="font-weight:normal;">'._MD_ENTERTH.'</span>', 'tplset_name', 20, 50));        $form->addElement(new XoopsFormHidden('op', 'uploadtar_go'));        $form->addElement(new XoopsFormHidden('fct', 'tplsets'));        $form->addElement(new XoopsFormButton('', 'upload_button', _MD_UPLOAD, 'submit'));        $form->display();        xoops_cp_footer();        break;    case 'listtpl':        $tplset = trim($_GET['tplset']);        if ($tplset == '') {            redirect_header('admin.php?fct=tplsets',1);        }        if ($moddir == '') {            redirect_header('admin.php?fct=tplsets',1);        }        xoops_cp_header();        $module_handler =& xoops_gethandler('module');        $module =& $module_handler->getByDirname($moddir);        $modname = $module->getVar('name');        echo '<a href="admin.php?fct=tplsets">'. _MD_TPLMAIN .'</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;'.$tplset.'<br /><br />';        echo '<h4>'.$modname.'</h4><form action="admin.php" method="post" enctype="multipart/form-data"><table width="100%" class="outer" cellspacing="1"><tr><th width="40%">'._MD_FILENAME.'</th><th>'._MD_LASTMOD.'</th>';        if ($tplset != 'default') {            echo '<th>'._MD_LASTIMP.'</th><th colspan="2">'._MD_ACTION.'</th></tr>';        } else {            echo '<th>'._MD_ACTION.'</th></tr>';        }        $tpltpl_handler =& xoops_gethandler('tplfile');        // get files that are already installed        $templates =& $tpltpl_handler->find($tplset, 'module', null, $moddir);        $inst_files = array();        $tcount = count($templates);        for ($i = 0; $i < $tcount; $i++) {            if ($i % 2 == 0) {                $class = 'even';            } else {                $class = 'odd';            }            $last_modified = $templates[$i]->getVar('tpl_lastmodified');            $last_imported = $templates[$i]->getVar('tpl_lastimported');            $last_imported_f = ($last_imported > 0) ? formatTimestamp($last_imported, 'l') : '';            echo  '<tr class="'.$class.'"><td class="head">'.$templates[$i]->getVar('tpl_file').'<br /><br /><span style="font-weight:normal;">'.$templates[$i]->getVar('tpl_desc').'</span></td><td>'.formatTimestamp($last_modified, 'l').'</td>';            $filename = $templates[$i]->getVar('tpl_file');            if ($tplset != 'default') {                $physical_file = XOOPS_THEME_PATH.'/'.$tplset.'/templates/'.$moddir.'/'.$filename;                if (file_exists($physical_file)) {                    $mtime = filemtime($physical_file);                    if ($last_imported < $mtime) {                        if ($mtime > $last_modified) {                            $bg = '#ff9999';                        } elseif($mtime > $last_imported) {                            $bg = '#99ff99';                        }                        echo '<td style="background-color:'.$bg.';">'.$last_imported_f.' [<a href="admin.php?fct=tplsets&amp;tplset='.$tplset.'&amp;moddir='.$moddir.'&amp;op=importtpl&amp;id='.$templates[$i]->getVar('tpl_id').'">'._MD_IMPORT.'</a>]';                    } else {                        echo '<td>'.$last_imported_f;                    }                } else {                    echo '<td>'.$last_imported_f;                }                echo '</td><td>[<a href="admin.php?fct=tplsets&amp;op=edittpl&amp;id='.$templates[$i]->getVar('tpl_id').'">'._EDIT.'</a>] [<a href="admin.php?fct=tplsets&amp;op=deletetpl&amp;id='.$templates[$i]->getVar('tpl_id').'">'._DELETE.'</a>] [<a href="admin.php?fct=tplsets&amp;op=downloadtpl&amp;id='.$templates[$i]->getVar('tpl_id').'">'._MD_DOWNLOAD.'</a>]</td><td align="right"><input type="file" name="'.$filename.'" id="'.$filename.'" /><input type="hidden" name="xoops_upload_file[]" id="xoops_upload_file[]" value="'.$filename.'" /><input type="hidden" name="old_template['.$filename.']" value="'.$templates[$i]->getVar('tpl_id').'" /></td>';            } else {                echo '<td>[<a href="admin.php?fct=tplsets&amp;op=edittpl&amp;id='.$templates[$i]->getVar('tpl_id').'">'._MD_VIEW.'</a>] [<a href="admin.php?fct=tplsets&amp;op=downloadtpl&amp;id='.$templates[$i]->getVar('tpl_id').'">'._MD_DOWNLOAD.'</a>]</td>';            }            echo '</tr>'."\n";            $inst_files[] = $filename;        }        if ($tplset != 'default') {            include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';            // get difference between already installed files and the files under modules directory. which will be recognized as files that are not installed            $notinst_files = array_diff(XoopsLists::getFileListAsArray(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/templates/'), $inst_files);            foreach ($notinst_files as $nfile) {                if ($nfile != 'index.html') {                    echo  '<tr><td style="background-color:#FFFF99; padding: 5px;">'.$nfile.'</td><td style="background-color:#FFFF99; padding: 5px;">&nbsp;</td><td style="background-color:#FFFF99; padding: 5px;">';                    $physical_file = XOOPS_THEME_PATH.'/'.$tplset.'/templates/'.$moddir.'/'.$nfile;                    if (file_exists($physical_file)) {                        echo '[<a href="admin.php?fct=tplsets&amp;moddir='.$moddir.'&amp;tplset='.$tplset.'&amp;op=importtpl&amp;file='.urlencode($nfile).'">'._MD_IMPORT.'</a>]';                    } else {                        echo '&nbsp;';                    }                    echo '</td><td style="background-color:#FFFF99; padding: 5px;">[<a href="admin.php?fct=tplsets&amp;moddir='.$moddir.'&amp;tplset='.$tplset.'&amp;op=generatetpl&amp;type=module&amp;file='.urlencode($nfile).'">'._MD_GENERATE.'</a>]</td><td style="background-color:#FFFF99; padding: 5px; text-align:right;"><input type="file" name="'.$nfile.'" id="'.$nfile.'" /><input type="hidden" name="xoops_upload_file[]" id="xoops_upload_file[]" value="'.$nfile.'" /></td></tr>'."\n";                }            }        }        echo '</table><br /><table width="100%" class="outer" cellspacing="1"><tr><th width="40%">'._MD_FILENAME.'</th><th>'._MD_LASTMOD.'</th>';        if ($tplset != 'default') {            echo '<th>'._MD_LASTIMP.'</th><th colspan="2">'._MD_ACTION.'</th></tr>';        } else {            echo '<th>'._MD_ACTION.'</th></tr>';        }        $btemplates =& $tpltpl_handler->find($tplset, 'block', null, $moddir);        $binst_files = array();        $btcount = count($btemplates);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -