function dbGetAndStoreMacroPattern(&$session)
{
    $session->trace(TC_Db2, 'dbGetAndStoreMacroPattern:');
    $theme = $session->fUserTheme;
    $pattern = dbGetParam($session, $theme, Th_MacroPattern);
    if (empty($pattern)) {
        $row = dbFirstRecord($session, 'select name from ' . dbTable($session, T_Macro) . ' where theme=' . Theme_All . ' or theme=' . ($theme + 0) . ' order by name');
        $last_var = null;
        $open_parenthesis = false;
        while ($row) {
            $pos = strpos($row[0], ':');
            if ($pos <= 0) {
                $val = $row[0];
                $var = null;
            } else {
                $var = substr($row[0], 0, $pos + 1);
                $val = substr($row[0], $pos + 1);
            }
            $session->trace(TC_Db3, 'dbGetAndStoreMacroPattern-2: ' . $pos . ' ' . $var . ' / ' . $val);
            if ($var != $last_var) {
                $session->trace(TC_Db2, 'dbGetAndStoreMacroPattern-3: ');
                if ($open_parenthesis) {
                    $session->trace(TC_Db2, 'dbGetAndStoreMacroPattern-4: ');
                    $pattern .= ')';
                    $open_parenthesis = false;
                }
                $last_var = $var;
                if (!empty($var)) {
                    $session->trace(TC_Db2, 'dbGetAndStoreMacroPattern-5: ' . $pattern);
                    $val = $var . '(' . $val;
                    $open_parenthesis = true;
                }
            }
            $new = '|' . $val;
            if (getPos($pattern, $new . '|') < 0) {
                $pattern .= $new;
            }
            $row = dbNextRecord($session);
        }
        if ($open_parenthesis) {
            $pattern .= ')';
        }
        $id = dbSingleValue($session, 'select id from ' . dbTable($session, T_Param) . ' where theme=' . (0 + $theme) . ' and pos=' . Th_MacroPattern);
        if ($id > 0) {
            dbUpdateRaw($session, T_Param, $id, 'text=' . dbSqlString($session, $pattern));
            $session->trace(TC_Db1, "dbGetAndStoreMacroPattern: Id: {$id} Th: {$theme} P: {$pattern}");
        }
    }
    return $pattern;
}
Exemple #2
0
function baseThread(&$session)
{
    global $thread_id, $posting_id, $page_no;
    $session->trace(TC_Gui1, 'baseThread');
    if (empty($thread_id)) {
        if (empty($posting_id)) {
            $thread_id = 1;
        } else {
            $thread_id = dbSingleValue($session, 'select top from ' . dbTable($session, T_Posting) . " where id={$posting_id}");
            if (empty($thread_id)) {
                $thread_id = $posting_id;
            }
        }
    }
    if (!isset($page_no)) {
        $page_no = isset($posting_id) ? dbPageOfPosting($session, $thread_id, $posting_id) : 1;
    }
    $id_list = dbIdListOfThreadPage($session, $thread_id, $page_no);
    $thread = dbGetRecordById($session, T_Posting, $thread_id, 'author,subject,text,createdat,changedby,changedat,calls,forum');
    dbThreadInfo($session, $thread_id, $answers, $pages, $last);
    $thread_date = dbSqlDateToText($session, $thread[3]);
    $forum = dbGetRecordById($session, T_Forum, $thread[7], 'name');
    guiStandardHeader($session, 'Thema: ' . $thread[1], Th_ThreadHeader, Th_ThreadBodyStart);
    guiParagraph($session, $thread[0] . ', ' . $thread_date . ', ' . (0 + $answers) . ' Antwort' . ($answers == 1 ? ', ' : 'en, ') . $pages . ' Seite' . ($pages == 1 ? '' : 'n'), true);
    echo '<table width="100%" border="0"><tr><td>';
    echo 'Forum: ';
    guiInternLink($session, P_Forum . '?forum_id=' . $thread[7], $forum[0]);
    if ($pages > 1) {
        echo '</td><td style="text-align: right">';
        guiPageLinks($session, P_Thread . '?action=' . A_ShowThread . '&thread_id=' . $thread_id, $page_no, $pages);
    }
    echo "</td></tr></table>\n";
    dbUpdateRaw($session, T_Posting, $thread_id, 'calls=calls+1');
    echo '<table width="100%" border="0">' . "\n";
    // Autor Thema-Text
    foreach ($id_list as $ii => $id) {
        # echo "alle Postings: $ii / $id<br>";
        if ($id == $thread_id) {
            $posting = $thread;
        } else {
            $posting = dbGetRecordById($session, T_Posting, $id, 'author,subject,text,createdat,changedby,changedat');
        }
        dbGetAuthorInfo($session, $posting[0], $author_link, $postings, $avatar, $ranking);
        echo '<tr><td style="vertical-align:top">';
        guiLine(1);
        echo $thread[0] . '<br/>' . ($postings + 0) . ' Beitr&auml;ge<br/>' . $ranking;
        if (!empty($avatar)) {
            echo '<br/>' . $avatar;
        }
        echo '</td><td>';
        guiLine(1);
        if ($id == $thread_id) {
            guiHeadline($session, 3, 'Thema: ' . $posting[1]);
        } else {
            guiHeadline($session, 3, 'Antwort ' . ($ii + $session->fUserPostingsPerPage * ($page_no - 1)) . ': ' . $posting[1]);
        }
        echo 'Geschrieben am ' . dbSqlDateToText($session, $posting[3]);
        if (strcmp($posting[5], $posting[3]) != 0) {
            echo ' Letzte &Auml;nderung: ' . dbSqlDateToText($session, $posting[5]);
            if (!empty($posting[4]) && strcmp($posting[4], $posting[0]) != 0) {
                echo ' von ' . $posting[5];
            }
        }
        echo '<br/>';
        wikiToHTML($session, $posting[2]);
        echo '<p>';
        guiInternLink($session, P_Thread . '?action=' . A_Answer . "&thread_id={$thread_id}&reference_id={$id}", 'Antworten');
        if (strcmp($posting[0], $session->fUserName) == 0) {
            echo ' ';
            guiInternLink($session, P_Thread . '?action=' . A_ChangeThread . "&thread_id={$thread_id}&posting_id={$id}", 'Ändern');
            echo "</p>\n";
        }
        echo "</td><tr>\n";
    }
    echo "</table>\n";
    guiStandardBodyEnd($session, Th_ThreadBodyEnd);
}
Exemple #3
0
function admForumAnswer(&$session)
{
    global $forum_id, $forum_name, $forum_description, $forum_changeid, $forum_load, $forum_insert, $forum_change;
    $message = null;
    $mode = C_New;
    if (isset($forum_load)) {
        if (empty($forum_changeid) || !IsInt($forum_changeid)) {
            $message = '+++ keine Id angegeben';
        } else {
            list($forum_name, $forum_description, $dummy) = dbGetRecordById($session, T_Forum, $forum_changeid, 'name,description,readgroup,writegroup,admingroup');
            $forum_id = $forum_changeid;
            $forum_changeid = null;
            $mode = C_Change;
        }
    } elseif (isset($forum_insert)) {
        if (empty($forum_name)) {
            $message = '+++ kein Name angegeben';
        } elseif (empty($forum_description)) {
            $message = '+++ keine Beschreibung angegeben';
        } elseif (dbSingleValue($session, 'select count(id) from ' . dbTable($session, T_Forum) . ' where name=' . dbSqlString($session, $forum_name)) > 0) {
            $message = '+++ Forum mit diesem Namen existiert schon';
        } else {
            $id = dbInsert($session, T_Forum, 'name,description,readgroup,writegroup,admingroup', dbSqlString($session, $forum_name) . ',' . dbSqlString($session, $forum_description) . ',1,1,1');
            $forum_name = $forum_description = null;
            $message = 'Forum wurde unter der Id ' . $id . ' eingetragen';
            $mode = C_New;
        }
    } elseif (isset($forum_change)) {
        if (dbSingleValue($session, 'select count(id) from ' . dbTable($session, T_Forum) . ' where name=' . dbSqlString($session, $forum_name) . " and id<>{$forum_id}") > 0) {
            $message = '+++ Forum mit diesem Namen existiert schon';
        } else {
            dbUpdateRaw($session, T_Forum, $forum_id, 'name=' . dbSqlString($session, $forum_name) . ',description=' . dbSqlString($session, $forum_description));
            $message = "Forum {$forum_name} wurde geändert";
            $forum_id = $forum_name = $forum_description = $forum_changeid = null;
            $mode = C_New;
        }
    }
    admForum($session, $message, $mode);
}
Exemple #4
0
function admOptionsAnswer(&$session)
{
    $session->trace(TC_Gui1, 'admOptionsAnswer');
    $message = null;
    if (isset($_POST['opt_save'])) {
        if ($_POST['opt_basarname'] == $session->getMacro(TM_BasarName)) {
            $message = 'Basarname wurde nicht gespeichert, da gleich.' . tagNewline();
        } else {
            $id = dbSingleValue($session, 'select id from ' . dbTable($session, T_Macro) . ' where theme=' . Theme_All . ' and name=' . dbSqlString($session, TM_BasarName));
            dbUpdateRaw($session, T_Macro, $id, 'value=' . dbSqlString($session, $_POST['opt_basarname']));
            $message = 'Basarname wurde geändert.' . tagNewline();
        }
        if ($_POST['opt_webmaster'] == $session->getMacro(TM_Webmaster)) {
            $message .= 'Webmaster wurde nicht gespeichert, da gleich.' . tagNewline();
        } else {
            $id = dbSingleValue($session, 'select id from ' . dbTable($session, T_Macro) . ' where theme=' . Theme_All . ' and name=' . dbSqlString($session, TM_Webmaster));
            dbUpdateRaw($session, T_Macro, $id, 'value=' . dbSqlString($session, $_POST['opt_webmaster']));
            $message .= 'Webmaster wurde geändert.' . tagNewline();
        }
    } elseif (isset($_POST['opt_upload'])) {
        $message = guiUploadFileAnswer($session, 'opt_upload', PATH_DELIM . 'pic' . PATH_DELIM, 'logo.png');
    }
    admOptions($session, $message);
}