Example #1
0
function modifyTopic()
{
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    if (empty($_POST['topic'])) {
        $message .= 'Please enter a topic.';
    } else {
        try {
            $stmt = $Dbc->prepare("UPDATE\n\tfaqTopics\nSET\n\tfaqTopics.topic = ?\nWHERE\n\tfaqTopics.topicId = ?\nLIMIT 1");
            $stmt->execute(array($_POST['topic'], $_POST['topicId']));
            $stmt = $Dbc->prepare("SELECT\n\tfaqTopics.topic AS 'newTopic'\nFROM\n\tfaqTopics\nWHERE\n\tfaqTopics.topicId = ?");
            $stmt->execute(array($_POST['topicId']));
            $message .= 'Saved';
            $success = MODE == 'modifyTopic' ? true : $success;
            $returnThis['buildFaqs'] = buildFaqs();
        } catch (PDOException $e) {
            error(__LINE__, '', '<pre>' . $e . '</pre>');
        }
    }
    if (MODE == 'modifyTopic') {
        returnData();
    }
}
Example #2
0
<?php

require_once '../../includes/siteAdmin.php';
$fileInfo = array('title' => 'FAQ Edit', 'fileName' => 'admin/faqEdit.php');
$debug->newFile($fileInfo['fileName']);
$buildPage = new Adrlist_BuildPage();
$buildPage->addIncludes('faqEditMethods.php');
$buildPage->addCss('faq.css');
$buildPage->addJs('faqEdit.js');
echo $buildPage->output(), '
<div class="layout" id="main">
	<div id="buildFaqs" class="break">
		', buildFaqs(), '
	</div>
</div>', $buildPage->buildFooter();
Example #3
0
<?php

require_once '../../includes/config.php';
$fileInfo = array('title' => 'FAQ', 'fileName' => 'faq/index.php');
$debug->newFile($fileInfo['fileName']);
$buildPage = new Adrlist_BuildPage();
$buildPage->addIncludes('faqMethods.php');
$buildPage->addCss('faq.css');
$buildPage->addJs(array('faq.js'));
$output = $buildPage->output() . '
<div class="break" id="buildFaqsHolder">
	' . buildFaqs() . '
</div>
' . $buildPage->buildFooter();
echo $output;
Example #4
0
<?php

$fileInfo = array('fileName' => 'includes/faqMethods.php');
$debug->newFile($fileInfo['fileName']);
$success = false;
if (MODE == 'buildFaqs') {
    buildFaqs();
} else {
    $debug->add('No matching mode in ' . $fileInfo['fileName'] . '.');
}
function buildFaqs()
{
    //This gets FAQs with and without searching.
    global $debug, $message, $success, $Dbc, $returnThis;
    $output = '';
    try {
        $faqQuery = "SELECT\n\tfaqs.faqId AS 'faqId',\n\tfaqs.q AS 'q',\n\tfaqs.a AS 'a',\n\tfaqTopics.topicId AS 'topicId',\n\tfaqTopics.topic AS 'topic'\nFROM\n\tfaqs\nJOIN\n\tfaqTopics ON faqTopics.topicId = faqs.topicId AND\n\tfaqs.hidden = '0'\n";
        if (empty($_POST['searchVal'])) {
            $search = false;
            $stmt = $Dbc->query($faqQuery . "\nORDER BY\n\tfaqTopics.topic");
            $faqCountStmt = $Dbc->query("SELECT COUNT(*) AS 'count' FROM faqs WHERE hidden = 0");
        } else {
            $search = true;
            $searchVal = '%' . trim($_POST['searchVal']) . '%';
            $faqSearchQuery = "\n AND (faqTopics.topic LIKE ? || faqs.q LIKE ? || faqs.a LIKE ?)\nGROUP BY\n\tfaqs.faqId";
            $stmt = $Dbc->prepare($faqQuery . $faqSearchQuery);
            $stmt->execute(array($searchVal, $searchVal, $searchVal));
            $faqCountStmt = $Dbc->prepare("SELECT COUNT(*) AS 'count' FROM faqs JOIN\n\tfaqTopics ON faqTopics.topicId = faqs.topicId AND\n\tfaqs.hidden = '0'" . $faqSearchQuery);
            $faqCountStmt->execute(array($searchVal, $searchVal, $searchVal));
        }
        $row = $faqCountStmt->fetch(PDO::FETCH_ASSOC);