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

📄 index.php

📁 本代码是为客户联系管理而做的系统
💻 PHP
字号:
<?php
// +-------------------------------------------------------------+
// | DeskPRO v [2.0.1 Production]
// | Copyright (C) 2001 - 2004 Headstart Solutions Limited
// | Supplied by WTN-WDYL
// | Nullified by WTN-WDYL
// | Distribution via WebForum, ForumRU and associated file dumps
// +-------------------------------------------------------------+
// | DESKPRO IS NOT FREE SOFTWARE
// +-------------------------------------------------------------+
// | License ID : Full Enterprise License =) ...
// | License Owner : WTN-WDYL Team
// +-------------------------------------------------------------+
// | $RCSfile: index.php,v $
// | $Date: 2004/02/10 01:34:26 $
// | $Revision: 1.23 $
// +-------------------------------------------------------------+
// | File Details:
// | - FAQ maintenance.
// +-------------------------------------------------------------+

error_reporting(E_ALL ^ E_NOTICE);

if ($_REQUEST['do'] == 'pdf') {
	define('PDF', '1');
}

include "./../global.php";

// default do
$_REQUEST['do'] = trim($_REQUEST['do']);
if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
	$_REQUEST['do'] = "navigate";
}

// globalise variables
$global = array	(
			array('catid')
);
rg($global);

include ("./faq_include.php");

if ($_REQUEST['do'] != 'pdf') {
	tech_nav('faq');
}

############################### PDF GENERATION ######################################

if ($_REQUEST['do'] == 'pdf') {
	if (!$_REQUEST['catid']) {
		$_REQUEST['catid'] = 0;
	}
	define('FPDF_FONTPATH','../../includes/fpdf/font/');
	require('../../includes/fpdf/fpdf.php');

	$pdf = new FPDF('P', 'mm', 'Letter');
	$pdf->Open();
	$pdf->AddPage();
	$pdf->SetTitle('Knowledge Base');
	$pdf->SetCreator('DeskPro v2.0');
	$pdf->SetFont('Times', 'B', 24);
	$pdf->Cell(0, 10, 'Knowledge Base', 0, 1, 'C');
	gen_pdf_faq($_REQUEST['categoryid']);
	$pdf->Output();
	exit;
}

############################### SQL UPDATE CATEGORIES ###############################

if ($_REQUEST['do'] == "edit_categories") {
	$categorycache = categorycache();

	// delete categories if empty, and reload cache
	if (is_array($_REQUEST['do_delete'])) {
		foreach ($_REQUEST['do_delete'] AS $key => $var) {
			$change = 1;
			$message .= delete_kbcategory($key);
			$categorycache = categorycache();
		}
	}

	foreach ($_REQUEST['do_category'] AS $key => $val) { // sort out parent
		if ($val != $categorycache[$key]['parent']) { // not same
			if ($val == $key) { // note self
				$message .= "<LI>You can set <b>" . $categorycache[$key]['name'] . "'s</b> parent to itself</LI>";
			} else { // can't move to own child
				if (@in_array($key, $categorycache[$val]['parentarray'])) {
					$message .= "<LI>You can not set <b>" . $categorycache[$key]['name'] . "'s</b> parent to one of its children</LI>";
				} else { // Update and reload cache
					$change = 1;
					$db->query("UPDATE faq_cats SET parent = '$val' WHERE id = '$key'");

					// reload category data
					$categorycache = categorycache();
				}
			}
		}
	}

	foreach ($_REQUEST['do_order'] AS $key => $var) { // sort out order
		$db->query("UPDATE faq_cats SET 
					show_order = '" . mysql_escape_string($var) . "' 
					WHERE id = '$key'
		");
	}
		
	if ($change) {
		update_parentlist();
		update_counters();
	}
		
	$_REQUEST['do'] = "navigate";
}

############################### SQL: UPDATE ARTICLES ###############################

if ($_REQUEST['do'] == "edit_articles") {

	// get articles to check for changes
	$db->query("SELECT category, id FROM faq_articles WHERE category = '$_REQUEST[catid]'");
	while ($result = $db->row_array()) {
		$temp_cache[$result[id]] = $result[category];
	}

	while (list ($key, $val) = each ($_REQUEST['do_order'])) {
		$query = "UPDATE faq_articles SET show_order = '$val'";

		// category
		if (!($_REQUEST['do_category'][$key])) {
			$_REQUEST['do_category'][$key] = 0;
		}
		
		// check for changed category
		if ($temp_cache[$key] != $_REQUEST[do_category][$key]) {
			$change = 1;
		}

		$query .= ", category = '" . $_REQUEST[do_category][$key] . "'";

		$query .= " WHERE id = '$key'";
		$db->query($query);
	}

	if (is_array($_REQUEST['do_delete'])) {
		while (list ($key, $value) = each ($_REQUEST['do_delete'])) {
			$message .= delete_kbarticle($key);	
			$change = 1;
		}
	}
		
	if ($change) {
		update_parentlist();
		update_counters();
	}

	$_REQUEST['do'] = "navigate";
}

############################### CREATE NAVIGATION ###############################

if ($_REQUEST['do'] == "navigate") {
	$catarray = faq_categoryjump();

	if (!$catid) {
		$catid = 0;
	}

	$parent = $categorycache[$catid]['parent'];
	while ($parent > 0) {
		$nav = " >> <a href=\"index.php?catid=" . $parent . "\">" . $categorycache[$parent]['name'] . "</a>" . $nav;
		$parent = $categorycache[$parent]['parent'];
	}

	$nav = "<a href=\"index.php\">Top</a>" . $nav;
	if ($catid != "0") {
		$nav .= " >> <a href=\"index.php?catid=$catid\">" . $categorycache[$catid]['name'] . "</a>";
	}

	$nav .= "&nbsp;&nbsp;&nbsp;[Generate PDF <A HREF=\"index.php?catid=$catid&do=pdf\">(These Topics)</A>&nbsp;&nbsp;<A HREF=\"index.php?catid=0&do=pdf\">(All Topics)</A>]";

	echo "<BR><B>$nav</b><br /><br />";

	if ($message) { // errors from updating
		echo table_border("<UL>$message");
		echo "<br />";
	}

	//////////////////// sub categories ////////////////////

	$db->query("SELECT * FROM faq_cats WHERE parent = '$catid' ORDER BY show_order");
	while ($cats = $db->row_array()) {
		$table[$i] = array(
			"<b>$cats[name] ($cats[articles] / $cats[totalarticles])</b>", 
			form_input($cats[id], $cats[show_order], '3', 'do_order'),
			iff($user['p_delete_k'], form_checkbox_single($cats[id], '1', '', 'do_delete'), ''),
			iff($user['p_edit_k'], form_select($cats[id], $catarray, 'do_category', $catid), ''),
			iff($user['p_edit_k'], "<a href=\"category.php?do=edit&catid=$cats[id]\">Edit</a>", "<FONT COLOR=\"GRAY\">Edit</FONT>"),
			"<a href=\"index.php?catid=$cats[id]\">View</a>"
		);
		$i++;
	}

	if (is_array($table)) {
		$columns = array('name', 'order', 'delete', 'move', 'edit', 'view');
		table_header('Subcategories', 'index.php', array('do' => 'edit_categories', 'catid' => $catid));
		table_content($columns, $table, $extra);
		table_footer('Update Categories');
	} else {
		echo table_border('<b><center>This category has no subcategories.</center></b>');
	}

	//////////////////// related categories ////////////////////

	if ($_REQUEST['catid'] != 0) {		// we don't have them for home category

		$db->query("
			SELECT faq_cats.*
			FROM faq_cats_related
			LEFT JOIN faq_cats ON (faq_cats_related.related_cat = faq_cats.id)
			WHERE show_cat = '$catid'
			ORDER BY name
		");

		while ($cats = $db->row_array()) {
			$cats[name] = str_replace(' ', '&nbsp;', $cats[name]);
			$relcats[] = "<A HREF=\"index.php?catid=$cats[id]\">$cats[name]</A>";
		}

		if (count($relcats)) {
			$relcats = join('&nbsp;&nbsp;', $relcats);
		} else {
			$relcats = '<I>This category has no related categories.';
		}

		table_header('Related Categories');
		table_content('', array($relcats));
		table_footer();

	}

	//////////////////// articles ////////////////////

	$catarray2 = $catarray;
	unset($catarray2[0]);
	unset($columns, $table, $extra);

			// select the articles
			$db->query("
			SELECT * FROM faq_articles
			WHERE category = '$catid'
			ORDER BY show_order
			");
		
	while ($article = $db->row_array()) {
		$table[] = array(
			"<b>$article[title]</b>", 
			form_input($article[id], $article[show_order], '3', 'do_order'),
			form_checkbox_single($article[id], '1', '', 'do_delete'),
			form_select($article[id], $catarray2, 'do_category', $catid),
			iff($article[to_validate], "<a href=\"validate.php?id=$article[id]\">Validate</a>", '<i>Validated</i>'),
			"<a href=\"view.php?do=view&articleid=$article[id]\">View</a>"
		);
	}

	if (is_array($table)) {

		$columns = array('Title', 'Order', 'Delete', 'Move', 'Validate', 'View');
		table_header('Articles in this Category', 'index.php', array('do' => 'edit_articles', 'catid' => $catid));
		table_content($columns, $table, $extra);
		table_footer('Update Articles');
	} elseif ($catid != '0') {
		echo table_border('<b><center>There are no articles in this category.</center></b>');
	}

	############################### END PAGE ###############################

	echo "<form method=\"post\" action=\"index.php\">" . form_select('catid', $catarray) . "&nbsp;&nbsp;&nbsp;<input type=\"submit\" name=\"submit\" value=\"Jump\"><br /><br />";
	if (count($catarray) > 1 AND $user['p_add_k']) {
		echo "<a href=\"view.php?do=add&catid=$catid\">Add New Article</a><br />";
	}
	echo "<a href=\"category.php?do=add\">Add New Category</a><br />";
	if(defined('DEVELOPERMODE')) {
		echo "<A HREF=\"actions.php?do=maintenance\">Run FAQ Maintenance Tasks</A><BR />\n";
	}

}

tech_footer();
?>

⌨️ 快捷键说明

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