コード例 #1
0
ファイル: KBMain.php プロジェクト: VBGAMER45/SMFMods
function KB()
{
    global $txt, $sourcedir, $scripturl, $modSettings, $context;
    if (empty($modSettings['kb_enabled'])) {
        redirectexit();
    }
    isAllowedTo('view_knowledge');
    KB_file_include(array('KBEditer', 'KBPerm', 'KBReport', 'KBApprove', 'KBSearch', 'KBEdit_Add', 'KBView_All', 'KBView', 'KBCats', 'KBMisc', 'KBMenu', 'KBSubs', 'KBRSS'));
    loadTemplate('KB');
    $context['linktree'][] = array('url' => $scripturl . '?action=kb', 'name' => $txt['knowledgebase']);
    //fix wysig
    KB_wysig_descript();
    //Are we jumping?
    KB_dojump();
    //Any headers?
    KB_doheaders();
    //Menu anyone?
    KB_Menu();
    if (isset($_REQUEST['comment_recount']) && allowedTo('manage_kb')) {
        KBrecountcomments();
    }
    if (isset($_REQUEST['article_recount']) && allowedTo('manage_kb')) {
        KBrecountItems();
    }
    if (isset($_REQUEST['cache_clean']) && allowedTo('manage_kb')) {
        KB_cleanCache();
    }
    //I am a robot
    if (empty($modSettings['kb_search_engines'])) {
        $context['robot_no_index'] = true;
    }
    $context['canonical_url'] = $scripturl . '?action=kb';
    //Put all the subactions into an array
    $subActions = array('main' => 'KB_main', 'cats' => 'KB_know', 'article' => 'KB_knowcont', 'catadd' => 'KB_catadd', 'listcat' => 'KB_catlist', 'addknow' => 'KB_addknow', 'del' => 'KB_del', 'permcat' => 'KB_perm', 'search' => 'KB_search', 'searchmain' => 'KB_searchmain', 'rate' => 'KB_rate', 'edit' => 'KB_edit', 'reporta' => 'KB_reporta', 'manage' => 'KB_manage', 'rss' => 'KB_rss', 'catup' => 'KB_movecat', 'catdown' => 'KB_movecat');
    // Default the sub-action'.
    $_REQUEST['area'] = isset($_REQUEST['area']) && isset($subActions[$_REQUEST['area']]) ? $_REQUEST['area'] : 'main';
    // Set title and default sub-action.
    $context['page_title'] = $txt['knowledgebase'];
    $context['sub_action'] = $_REQUEST['area'];
    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['area']]();
}
コード例 #2
0
ファイル: KBView.php プロジェクト: VBGAMER45/SMFMods
function KB_knowcont()
{
    global $smcFunc, $txt, $scripturl, $sourcedir, $boardurl, $modSettings, $user_info, $context;
    $context['sub_template'] = 'kb_knowcont';
    if (isset($_REQUEST['cont'])) {
        if (($listData = cache_get_data('kb_articles_listinfo' . $_GET['cont'] . '', 3600)) === null) {
            $params = array('table' => 'kb_articles AS a', 'call' => 'a.title,a.kbnid,a.id_cat,c.name', 'left_join' => '{db_prefix}kb_category AS c ON (a.id_cat = c.kbid)', 'where' => 'a.kbnid = {int:kbnid}');
            $data = array('kbnid' => (int) $_GET['cont']);
            $listData = KB_ListData($params, $data);
            cache_put_data('kb_articles_listinfo' . $_GET['cont'] . '', $listData, 3600);
        }
        $artname = $listData['title'];
        $aid = $listData['kbnid'];
        $cid = $listData['id_cat'];
        $cname = $listData['name'];
        if (!$aid) {
            fatal_error('' . $txt['kb_pinfi7'] . ' <strong>' . $_GET['cont'] . '</strong> ' . $txt['kb_jumpgo1'] . '', false);
        }
        $context['linktree'][] = array('url' => $scripturl . '?action=kb;area=cats;cat=' . $cid . '', 'name' => $cname);
        $context['linktree'][] = array('url' => $scripturl . '?action=kb;area=article;cont=' . $_GET['cont'] . '', 'name' => $artname);
        if (($context['know'] = cache_get_data('kb_articles' . $_GET['cont'] . '', 3600)) === null) {
            $result = $smcFunc['db_query']('', '
	            SELECT k.kbnid,k.content, k.source, k.title,k.id_cat,k.date,k.id_member,m.real_name, k.views, k.rate, k.approved
	            FROM {db_prefix}kb_articles AS k
		        LEFT JOIN {db_prefix}members AS m ON (k.id_member = m.id_member)
		        LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
	            WHERE kbnid = {int:kbnid}', array('kbnid' => (int) $_GET['cont']));
            $context['know'] = array();
            while ($row = $smcFunc['db_fetch_assoc']($result)) {
                $context['know'][] = array('content' => KB_parseTags($row['content'], $row['kbnid'], 3), 'title' => parse_bbc($row['title']), 'source' => parse_bbc($row['source']), 'kbnid' => $row['kbnid'], 'approved' => $row['approved'], 'views' => $row['views'], 'rate' => $row['rate'], 'date' => date('D d M Y', $row['date']), 'id_cat' => $row['id_cat'], 'id_member' => $row['id_member'], 'real_name' => $row['real_name']);
            }
            $smcFunc['db_free_result']($result);
            cache_put_data('kb_articles' . $_GET['cont'] . '', $context['know'], 3600);
        }
        $context['page_title'] = $context['know'][0]['title'];
        if ($context['know'][0]['approved'] == 0 && $context['know'][0]['id_member'] != $user_info['id'] && !allowedTo('manage_kb')) {
            fatal_lang_error('kb_articlwnot_approved', false);
        }
        KBisAllowedto($context['know'][0]['id_cat'], 'view');
        $context['kbimg'] = KB_getimages($_GET['cont']);
        if (!empty($modSettings['kb_ecom'])) {
            $context['kbcom'] = KB_getcomments($_GET['cont']);
            KB_showediter(!empty($_POST['description']) ? $_POST['description'] : '', 'description');
        }
        KB_dojprint();
        $query_params = array('table' => 'kb_articles', 'set' => 'views = views + 1', 'where' => 'kbnid = {int:kbnid}');
        $query_data = array('kbnid' => (int) $_GET['cont']);
        kb_UpdateData($query_params, $query_data);
    }
    if ($user_info['is_guest']) {
        require_once $sourcedir . '/Subs-Editor.php';
        $verificationOptions = array('id' => 'register');
        $context['visual_verification'] = create_control_verification($verificationOptions);
        $context['visual_verification_id'] = $verificationOptions['id'];
    }
    //comment
    if (isset($_REQUEST['comment'])) {
        if ($user_info['is_guest']) {
            require_once $sourcedir . '/Subs-Editor.php';
            $verificationOptions = array('id' => 'register');
            $context['visual_verification'] = create_control_verification($verificationOptions, true);
            if (is_array($context['visual_verification'])) {
                loadLanguage('Errors');
                foreach ($context['visual_verification'] as $error) {
                    fatal_error($txt['error_' . $error]);
                }
            }
        }
        isAllowedTo('com_kb');
        checkSession();
        $_POST['description'] = $smcFunc['htmlspecialchars']($_POST['description'], ENT_QUOTES);
        $_GET['arid'] = (int) $_GET['arid'];
        if (empty($_POST['description'])) {
            fatal_lang_error('knowledgebase_emtydesc', false);
        }
        $approved = allowedTo('auto_approvecom_kb') ? 1 : 0;
        $mes = '' . $txt['kb_log_text4'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $_GET['arid'] . '">' . $context['know'][0]['title'] . '</a></strong>';
        KB_log_actions('add_com', $_GET['arid'], $mes);
        $data = array('table' => 'kb_comments', 'cols' => array('id_article' => 'int', 'comment' => 'string', 'date' => 'int', 'id_member' => 'int', 'approved' => 'int'));
        $values = array($_GET['arid'], $_POST['description'], time(), $user_info['id'], $approved);
        $indexes = array('id_article');
        KB_InsertData($data, $values, $indexes);
        KBrecountcomments();
        KB_cleanCache();
        redirectexit('action=kb;area=article;cont=' . $_GET['arid'] . '');
    }
    if (isset($_REQUEST['commentdel'])) {
        isAllowedTo('comdel_kb');
        $mes = '' . $txt['kb_log_text3'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $_GET['cont'] . '">' . $context['know'][0]['title'] . '</a></strong>';
        KB_log_actions('del_com', $_GET['cont'], $mes);
        $query_params = array('table' => 'kb_comments', 'where' => 'id = {int:kbid}');
        $query_data = array('kbid' => (int) $_GET['arid']);
        KB_DeleteData($query_params, $query_data);
        KB_cleanCache();
        KBrecountcomments();
        redirectexit('action=kb;area=article;cont=' . $_GET['cont'] . '');
    }
    //approve
    if (isset($_REQUEST['approve'])) {
        checkSession('get');
        $query_params = array('table' => 'kb_articles', 'set' => 'approved = {int:one}', 'where' => 'kbnid = {int:kbnid}');
        $query_data = array('kbnid' => (int) $_REQUEST['aid'], 'one' => 1);
        kb_UpdateData($query_params, $query_data);
        $params = array('table' => 'kb_articles', 'call' => 'id_member, kbnid, title', 'where' => 'kbnid = {int:kbnid}');
        $data = array('kbnid' => (int) $_GET['aid']);
        $listData = KB_ListData($params, $data);
        $nameid = $listData['id_member'];
        $kid = $listData['kbnid'];
        $title = $listData['title'];
        $kbmes = '' . $txt['kb_aapprove1'] . ' [url=' . $scripturl . '?action=kb;area=article;cont=' . $kid . ']' . $txt['kb_aapprove2'] . '[/url] ' . $txt['kb_aapprove3'] . '';
        KB_sendpm($nameid, $txt['kb_aapprove6'], $kbmes);
        $mes = '' . $txt['kb_log_text2'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $kid . '">' . $title . '</a></strong>';
        KB_log_actions('app_article', $kid, $mes);
        KBrecountItems();
        KB_cleanCache();
        redirectexit('action=kb;area=article;cont=' . $_REQUEST['aid'] . '');
    }
    //unapprove
    if (isset($_REQUEST['unapprove']) && isset($_REQUEST['inap'])) {
        checkSession('get');
        $query_params = array('table' => 'kb_articles', 'set' => 'approved = {int:one}', 'where' => 'kbnid = {int:kbnid}');
        $query_data = array('kbnid' => (int) $_REQUEST['inap'], 'one' => 0);
        kb_UpdateData($query_params, $query_data);
        $params = array('table' => 'kb_articles', 'call' => 'id_member, kbnid, title', 'where' => 'kbnid = {int:kbnid}');
        $data = array('kbnid' => (int) $_GET['inap']);
        $listData = KB_ListData($params, $data);
        $nameid = $listData['id_member'];
        $kid = $listData['kbnid'];
        $title = $listData['title'];
        $kbmes = '' . $txt['kb_aapprove4'] . ' [url=' . $scripturl . '?action=kb;area=article;cont=' . $kid . ']' . $txt['kb_aapprove2'] . '[/url] ' . $txt['kb_aapprove3'] . '';
        KB_sendpm($nameid, $txt['kb_aapprove7'], $kbmes);
        $mes = '' . $txt['kb_log_text1'] . ' <strong><a href="' . $scripturl . '?action=kb;area=article;cont=' . $kid . '">' . $title . '</a></strong>';
        KB_log_actions('unapp_article', $kid, $mes);
        KBrecountItems();
        KB_cleanCache();
        redirectexit('action=kb;area=article;cont=' . $_REQUEST['inap'] . '');
    }
}
コード例 #3
0
ファイル: KBApprove.php プロジェクト: VBGAMER45/SMFMods
function KB_approvecom()
{
    global $scripturl, $sourcedir, $txt, $smcFunc, $context;
    isAllowedTo('manage_kb');
    $list_optionscom = array('id' => 'kb_knowcomappr', 'title' => $txt['kb_approvecom'], 'items_per_page' => 30, 'base_href' => $scripturl . '?action=kb;area=manage', 'default_sort_col' => 'id', 'start_var_name' => 'startcom', 'request_vars' => array('desc' => 'desccom', 'sort' => 'sortcom'), 'get_items' => array('function' => create_function('$start, $items_per_page, $sort', '
				global $smcFunc;
		
		    $request = $smcFunc[\'db_query\'](\'\', \'
			    SELECT c.id, c.id_article, m.id_member, c.date, m.real_name, c.comment
                FROM {db_prefix}kb_comments AS c
			    LEFT JOIN {db_prefix}members AS m  ON (c.id_member = m.id_member) 
			    WHERE approved = 0
                ORDER BY {raw:sort}
                LIMIT {int:start}, {int:per_page}\',
            array(
			  
			   \'sort\' => $sort,
			   \'start\' => $start,
			   \'per_page\' => $items_per_page,
            )
		 );
		$kbcn1 = array();
			while ($row = $smcFunc[\'db_fetch_assoc\']($request))
				
				   $kbcn1[] = $row;
				   
			$smcFunc[\'db_free_result\']($request);

		return $kbcn1;
			')), 'get_count' => array('function' => create_function('', '
				global $smcFunc;

				$request = $smcFunc[\'db_query\'](\'\', \'
					SELECT COUNT(*)
					FROM {db_prefix}kb_comments
					WHERE approved = 0 \',
			        array());
				
				list ($total_kbn) = $smcFunc[\'db_fetch_row\']($request);
				$smcFunc[\'db_free_result\']($request);

				return $total_kbn;
			')), 'no_items_label' => $txt['knowledgebasenone'], 'columns' => array('id' => array('header' => array('value' => $txt['kb_rlistcomment']), 'data' => array('function' => create_function('$row', '
					global $scripturl;
						return \'\'.$row[\'comment\'].\'\';
					'), 'style' => 'width: 20%; text-align: left;'), 'sort' => array('default' => 'id', 'reverse' => 'id DESC')), 'real_name' => array('header' => array('value' => $txt['knowledgebaseauthor']), 'data' => array('function' => create_function('$row', '
                        global $txt, $scripturl;
						if($row[\'id_member\'] != 0){
			              	return \'<a href="\'.$scripturl.\'?action=profile;u=\'.$row[\'id_member\'].\'">\'.$row[\'real_name\'].\'</a>\';
			            }      
			            else{
			              return $txt[\'guest_title\'];
			            }
					
					'), 'style' => 'width: 4%; text-align: center;'), 'sort' => array('default' => 'real_name', 'reverse' => 'real_name DESC')), 'date1' => array('header' => array('value' => $txt['knowledgebasecreated']), 'data' => array('function' => create_function('$row', '

						return \'<div class="smalltext">\'.timeformat($row[\'date\']).\'</div>\';
					'), 'style' => 'width: 5%; text-align: center;')), 'action' => array('header' => array('value' => '<input type="checkbox" name="all" class="input_check" onclick="invertAll(this, this.form);" />'), 'data' => array('function' => create_function('$row', '
                         global $sc,$scripturl;
						return \'<input type="checkbox" class="input_check" name="approve[]" value="\' . $row[\'id\'] . \'" />\';
					'), 'style' => 'width: 2%; text-align: center;'))), 'form' => array('href' => $scripturl . '?action=kb;area=manage', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
						
						<input type="submit" name="approve_com_sel" value="' . $txt['kb_app_aart'] . '" class="button_submit" onclick="return confirmSubmit();" />
						<input type="submit" name="approve_com_all" value="' . $txt['kb_app_art'] . '" class="button_submit" onclick="return confirmSubmit();" />
						<input type="submit" name="remove" value="' . $txt['kb_remove_log2'] . '" class="button_submit" onclick="return confirmSubmit();" />
						<input type="submit" name="removeall2" value="' . $txt['kb_remove_log1'] . '" class="button_submit" onclick="return confirmSubmit()" />')));
    require_once $sourcedir . '/Subs-List.php';
    createList($list_optionscom);
    if (isset($_POST['removeall2'])) {
        checkSession();
        $query_params = array('table' => 'kb_comments', 'where' => 'approved = {int:one}');
        $query_data = array('one' => 0);
        KB_DeleteData($query_params, $query_data);
        KB_cleanCache();
        redirectexit('action=kb;area=manage');
    }
    if (!empty($_POST['remove']) && isset($_POST['approve'])) {
        checkSession();
        $query_params = array('table' => 'kb_comments', 'where' => 'id IN ({array_string:delete_actions}) AND approved = {int:one}');
        $query_data = array('delete_actions' => array_unique($_POST['approve']), 'one' => 0);
        KB_DeleteData($query_params, $query_data);
        KB_cleanCache();
        redirectexit('action=kb;area=manage');
    }
    if (isset($_POST['approve_com_all'])) {
        checkSession();
        $query_params = array('table' => 'kb_comments', 'set' => 'approved = {int:one}', 'where' => '');
        $query_data = array('one' => 1);
        kb_UpdateData($query_params, $query_data);
        $mes = $txt['kb_app_acom'];
        KB_log_actions('app_com', 0, $mes);
        KBrecountcomments();
        KB_cleanCache();
        redirectexit('action=kb;area=manage');
    } elseif (!empty($_POST['approve_com_sel']) && isset($_POST['approve'])) {
        checkSession();
        $query_params = array('table' => 'kb_comments', 'set' => 'approved = {int:one}', 'where' => 'id IN ({array_string:delete_actions})');
        $query_data = array('delete_actions' => array_unique($_POST['approve']), 'one' => 1);
        kb_UpdateData($query_params, $query_data);
        $mes = $txt['kb_app_com'];
        KB_log_actions('app_com', 0, $mes);
        KBrecountcomments();
        KB_cleanCache();
        redirectexit('action=kb;area=manage');
    }
}