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

📄 project.inc.php

📁 Discuz功能源码(开源)
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

/*
	[Discuz!] (C)2001-2009 Comsenz Inc.
	This is NOT a freeware, use is subject to license terms

	$Id: project.inc.php 17038 2008-12-04 04:41:29Z tiger $
*/

if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
        exit('Access Denied');
}

if(!isfounder()) {
	cpheader();
	cpmsg('noaccess', '', 'error');
}

$query = $db->query("SELECT disabledactions FROM {$tablepre}adminactions WHERE admingid='$groupid'");
$dactionarray = ($dactionarray = unserialize($db->result($query, 0))) ? $dactionarray : array();
$allowforumsedit = !in_array('forums', $dactionarray) ? 1 : 0;
$allowusergroups = !in_array('groups_user', $dactionarray) ? 1 : 0;
$allowcreditwizard = !in_array('creditwizard', $dactionarray) ? 1 : 0;

if(empty($allowforumsedit) && empty($allowusergroups) && empty($allowcreditwizard)) {
	cpheader();
	cpmsg('action_noaccess', '', 'error');
}

if($operation == 'export' && $id) {

	$projectarray = $db->fetch_first("SELECT * FROM {$tablepre}projects WHERE id='$id'");
	if(!$projectarray) {
		cpheader();
		cpmsg('undefined_action', '', 'error');
	}

	if(($projectarray['type'] == 'forum' && empty($allowforumsedit)) || ($projectarray['type'] == 'group' && empty($allowusergroups)) || ($projectarray['type'] == 'extcredit' && empty($allowcreditwizard))) {
		cpheader();
		cpmsg('action_noaccess', '', 'error');
	}

	$projectarray['version'] = strip_tags($version);
	$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);

	$project_export = "# Discuz! Project Dump ($projectarray[type])\n".
		"# Version: Discuz! $version\n".
		"# Time: $time  \n".
		"# From: $bbname ($boardurl) \n".
		"#\n".
		"# Discuz! Community: http://www.Discuz.net\n".
		"# Please visit our website for latest news about Discuz!\n".
		"# --------------------------------------------------------\n\n\n".
		wordwrap(base64_encode(serialize($projectarray)), 60, "\n", 1);

	ob_end_clean();
	dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
	dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
	dheader('Cache-Control: no-cache, must-revalidate');
	dheader('Pragma: no-cache');
	dheader('Content-Encoding: none');
	dheader('Content-Length: '.strlen($project_export));
	dheader('Content-Disposition: attachment; filename=discuz_project_'.$projectarray['type'].'_'.$projectarray['name'].'.txt');
	dheader('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));

	echo $project_export;
	dexit();

}

cpheader();

if(!$operation) {

	if(!submitcheck('projectsubmit')) {

		$listarray = array();
		$projectlist = $typeadd = $selecttype = '';
		$page = max(1, intval($page));
		$start_limit = ($page - 1) * 10;

		$allowaction = array(
			'forum' => $allowforumsedit,
			'group' => $allowusergroups,
			'extcredit' => $allowcreditwizard,
		);

		if(!empty($type) && in_array($type, array('forum', 'group', 'extcredit'))) {

			foreach($allowaction as $key => $val) {
				if($type == $key && empty($val)) {
					cpmsg('action_noaccess', '', 'error');
				}
			}

			$typeadd = "WHERE type='$type'";
			$selecttype = '&amp;type='.$type;

		} else {

			$typeadd = $comma = '';
			foreach($allowaction as $key => $val) {
				if(!empty($val)) {
					$typeadd .= $comma."'$key'";
					$comma = ', ';
				}
			}
			$typeadd = 'WHERE type IN ('.$typeadd.')';

		}

		$projectnum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}projects $typeadd");

		$query = $db->query("SELECT id, name, type, description FROM {$tablepre}projects $typeadd LIMIT $start_limit, 10");
		while($list = $db->fetch_array($query)) {
			$list['name'] = dhtmlspecialchars($list['name']);
			$list['description'] = dhtmlspecialchars($list['description']);
			$projecttype = 'project_'.$list['type'].'_scheme';
			$projectlist .= showtablerow('', array('class="td25"', 'class="td24"', 'class="td26"', 'class="td24"', 'class="td23"'), array(
				"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$list[id]\">",
				"<input type=\"text\" class=\"txtnobd\" onblur=\"this.className='txtnobd'\" onfocus=\"this.className='txt'\" size=\"15\" name=\"name[$list[id]]\" value=\"$list[name]\">",
				"<input type=\"text\" class=\"txtnobd\" onblur=\"this.className='txtnobd'\" onfocus=\"this.className='txt'\" size=\"40\" name=\"description[$list[id]]\" value=\"$list[description]\">",
				$lang[$projecttype],
				"<a href=\"$BASESCRIPT?action=project&operation=export&id=$list[id]\" class=\"act\">".$lang['export']."</a> <a href=\"$BASESCRIPT?action=project&operation=apply&amp;projectid=$list[id]&amp;type=$list[type]\" class=\"act\">".$lang['apply']."</a>"
			), TRUE);
		}

		$multipage = multi($projectnum, 10, $page, "$BASESCRIPT?action=project$selecttype");
		shownav('tools', 'project_scheme');
		showsubmenu('project_scheme', array(
			$allowforumsedit ? array('project_forum_scheme', 'project&type=forum', $type == 'forum') : array(),
			$allowusergroups ? array('project_group_scheme', 'project&type=group', $type == 'group') : array(),
			$allowcreditwizard ? array('project_extcredit_scheme', 'project&type=extcredit', $type == 'extcredit') : array(),
			array('project_import_stick', 'project&operation=import', $operation == 'import')
		));
		showformheader('project');
		showtableheader();
		showsubtitle(array('', 'name', 'description', 'type', ''));
		echo $projectlist;
		showsubmit('projectsubmit', 'submit', 'del', '', $multipage);
		showtablefooter();
		showformfooter();

	} else {

		if(is_array($delete)) {
			$ids = $comma =	'';
			foreach($delete	as $id)	{
				$ids .=	"$comma'$id'";
				$comma = ',';
			}
			$db->query("DELETE FROM {$tablepre}projects WHERE id IN ($ids)");
		}

		if(is_array($name)) {
			foreach($name as $id =>	$val) {
				$db->query("UPDATE {$tablepre}projects SET name='$name[$id]', description='$description[$id]' WHERE id='$id'");
			}
		}

		cpmsg('project_update_forum', $BASESCRIPT.'?action=project', 'succeed');

	}

} elseif($operation == 'import') {

	if(!submitcheck('importsubmit')) {

		shownav('tools', 'project_scheme');
		showsubmenu('project_scheme', array(
			$allowforumsedit ? array('project_forum_scheme', 'project&type=forum', $type == 'forum') : array(),
			$allowusergroups ? array('project_group_scheme', 'project&type=group', $type == 'group') : array(),
			$allowcreditwizard ? array('project_extcredit_scheme', 'project&type=extcredit', $type == 'extcredit') : array(),
			array('project_import_stick', 'project&operation=import', $operation == 'import')
		));
		showformheader('project&operation=import', 'enctype');
		showtableheader('project_import_stick');
		showimportdata();
		showsubmit('importsubmit');
		showtablefooter();
		showformfooter();

	} else {

		$projectarray = getimportdata();

		if(strip_tags($projectarray['version']) != strip_tags($version)) {
			cpmsg('project_export_version_invalid', '', 'error');
		} else {
			$db->query("INSERT INTO {$tablepre}projects (name, type, description, value) VALUES ('$projectarray[name]', '$projectarray[type]', '$projectarray[description]', '$projectarray[value]')");
			cpmsg('project_import_succeed', $BASESCRIPT.'?action=project', 'succeed');
		}

	}

} elseif($operation == 'add') {

	$delfields = array(
		'forum'	=> array('fid', 'fup', 'type', 'name', 'status', 'displayorder', 'threads', 'posts', 'todayposts', 'lastpost', 'description', 'password', 'icon', 'redirect', 'moderators', 'rules', 'threadtypes'),
		'group'	=> array('groupid', 'radminid', 'type', 'system', 'grouptitle', 'creditshigher', 'creditslower', 'stars', 'color', 'groupavatar')
	);

	if(!submitcheck('addsubmit')) {
		shownav('tools', 'project_scheme_add');
		showsubmenu('project_scheme_add');

		if(!empty($projectid)) {
			$query = $db->query("SELECT name, description, value FROM {$tablepre}projects WHERE id='$projectid'");
			$project = $db->fetch_array($query);
		}

		if(($type == 'forum' && empty($allowforumsedit)) || ($type == 'group' && empty($allowusergroups)) || ($type == 'extcredit' && empty($allowcreditwizard))) {
			cpmsg('action_noaccess', '', 'error');
		}

		$allselected = 'selected';
		if($type == 'forum' || $type == 'group') {
			$listoption = '';
			$fieldarray = $type == 'forum' ? array_merge(fetch_table_struct('forums'), fetch_table_struct('forumfields')) : fetch_table_struct('usergroups');
			$listfields = array_diff($fieldarray, $delfields[$type]);
			foreach($listfields as $field) {
				$listoption .= '<option value="'.$field.'">'.$lang['project_option_'.$type.'_'.$field].'</option>';
			}
		} elseif($type == 'extcredit') {
			$value = unserialize($project['value']);
			$savemethod = $value['savemethod'];

⌨️ 快捷键说明

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