Beispiel #1
0
function search_poll($items, $conn)
{
    global $set, $db, $apx, $user;
    require_once BASEDIR . getmodulepath('poll') . 'functions.php';
    $tagmatches = poll_match_tags($items);
    foreach ($items as $item) {
        $tagmatch = array_shift($tagmatches);
        $query = " ( " . iif($tagmatch, " id IN (" . implode(',', $tagmatch) . ") OR ") . " question LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a1 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a2 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a3 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a4 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a5 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a6 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a7 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a8 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a9 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a10 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a11 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a12 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a13 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a14 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a15 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a16 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a17 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a18 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a19 LIKE '%" . addslashes_like($item) . "%'";
        $query .= " OR a20 LIKE '%" . addslashes_like($item) . "%' )";
        $search[] = $query;
    }
    $searchstring = implode($conn, $search);
    //Aktuelle Umfrage
    require_once BASEDIR . getmodulepath('poll') . 'functions.php';
    $recent = poll_recent();
    //Ergebnisse
    $data = $db->fetch("SELECT id,question FROM " . PRE . "_poll WHERE ( searchable='1' AND '" . time() . "' BETWEEN starttime AND endtime " . section_filter() . " AND ( " . $searchstring . " ) ) ORDER BY starttime DESC");
    if (count($data)) {
        foreach ($data as $res) {
            ++$i;
            if ($res['id'] == $recent) {
                $link = mklink('poll.php?recent=1', 'poll,recent.html');
            } else {
                $link = mklink('poll.php?id=' . $res['id'], 'poll,' . $res['id'] . '.html');
            }
            $result[$i]['TITLE'] = strip_tags($res['question']);
            $result[$i]['LINK'] = $link;
        }
    }
    return $result;
}
Beispiel #2
0
function poll_small($id = false, $template = 'poll')
{
    global $set, $db, $apx, $user;
    $id = (int) $id;
    $tmpl = new tengine();
    $apx->lang->drop('poll', 'poll');
    $recent = poll_recent();
    if (!$id) {
        $id = $recent;
    }
    //Verwendete Variablen auslesen
    $parse = $tmpl->used_vars('functions/' . $template, 'poll');
    $pollinfo = $db->first("SELECT *,a1_c+a2_c+a3_c+a4_c+a5_c+a6_c+a7_c+a8_c+a9_c+a10_c+a11_c+a12_c+a13_c+a14_c+a15_c+a16_c+a17_c+a18_c+a19_c+a20_c AS total FROM " . PRE . "_poll WHERE ( id='" . $id . "' " . section_filter() . " ) LIMIT 1");
    if (!$pollinfo['id']) {
        return;
    }
    if ($user->info['userid']) {
        list($ipblock) = $db->first("SELECT ip FROM " . PRE . "_poll_iplog WHERE ( id='" . $id . "' AND userid='" . $user->info['userid'] . "' AND time>" . (time() - 24 * 3600) . " ) LIMIT 1");
    } else {
        list($ipblock) = $db->first("SELECT ip FROM " . PRE . "_poll_iplog WHERE ( id='" . $id . "' AND ip='" . ip2integer(get_remoteaddr()) . "' AND time>" . (time() - 24 * 3600) . " ) LIMIT 1");
    }
    //Ergebnisse zeigen
    if ($pollinfo['id'] != $recent && !$set['poll']['archvote'] || $_COOKIE[$set['main']['cookie_pre'] . '_voted'][$pollinfo['id']] == '1' || $ipblock || $pollinfo['starttime'] + $pollinfo['days'] * 24 * 3600 <= time()) {
        $result = poll_format_result($pollinfo);
        foreach ($result as $element) {
            ++$ri;
            $percent = round($element[1] / iif($pollinfo['total'], $pollinfo['total'], 1) * 100, $set['poll']['percentdigits']);
            $width = round($percent) . '%';
            $resdata[$ri]['ANSWER'] = $element[0];
            $resdata[$ri]['VOTES'] = $element[1];
            $resdata[$ri]['COLOR'] = $element[2];
            $resdata[$ri]['PERCENT'] = $percent . '%';
            $resdata[$ri]['WIDTH'] = $width;
        }
        if ($pollinfo['starttime'] + $pollinfo['days'] * 24 * 3600 <= time()) {
            $set_end = 1;
        }
        if ($_COOKIE[$set['main']['cookie_pre'] . '_voted'][$pollinfo['id']] == '1' || $ipblock) {
            $set_voted = 1;
        }
        $tmpl->assign('TOTALVOTES', $pollinfo['total']);
        $tmpl->assign('RESULT', $resdata);
        $tmpl->assign('SET_END', $set_end);
        $tmpl->assign('SET_VOTED', $set_voted);
    } else {
        for ($i = 1; $i <= 20; $i++) {
            if (!$pollinfo['a' . $i]) {
                continue;
            }
            if ($pollinfo['multiple']) {
                $box = '<input type="checkbox" name="vote[' . $i . ']" value="1" />';
            } else {
                $box = '<input type="radio" name="vote" value="' . $i . '" />';
            }
            $optdata[$i]['ANSWER'] = $pollinfo['a' . $i];
            $optdata[$i]['COLOR'] = $pollinfo['color' . $i];
            $optdata[$i]['BOX'] = $box;
        }
        $postto = mklink('poll.php?id=' . $pollinfo['id'], 'poll,' . $pollinfo['id'] . urlformat($pollinfo['question']) . '.html');
        $tmpl->assign('POSTTO', $postto);
        $tmpl->assign('OPTION', $optdata);
    }
    //Link: Ergebnis zeigen
    if ($pollinfo['id'] == $recent) {
        $resultlink = mklink('poll.php?recent=1&amp;result=1', 'poll,recent.html?result=1');
    } else {
        $resultlink = mklink('poll.php?id=' . $pollinfo['id'] . '&amp;result=1', 'poll,' . $pollinfo['id'] . urlformat($pollinfo['question']) . '.html?result=1');
    }
    //Tags
    if (in_array('TAG', $parse) || in_array('TAG_IDS', $parse) || in_array('KEYWORDS', $parse)) {
        list($tagdata, $tagids, $keywords) = poll_tags($res['id']);
    }
    //Kommentare
    if ($set['poll']['coms'] && $pollinfo['allowcoms'] && $apx->is_module('comments')) {
        require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
        $coms = new comments('poll', $id);
        $tmpl->assign('COMMENT_LINK', $coms->link($resultlink));
        $tmpl->assign('COMMENT_COUNT', $coms->count());
        $tmpl->assign('DISPLAY_COMMENTS', 1);
    }
    //Link zum Poll
    $pollink = mklink('poll.php?id=' . $pollinfo['id'], 'poll,' . $pollinfo['id'] . urlformat($pollinfo['question']) . '.html');
    //Ausgabe
    $tmpl->assign('LINK', $pollink);
    $tmpl->assign('LINK_RESULT', $resultlink);
    $tmpl->assign('ID', $pollinfo['id']);
    $tmpl->assign('QUESTION', $pollinfo['question']);
    $tmpl->assign('STARTTIME', $pollinfo['starttime']);
    $tmpl->assign('ENDTIME', $pollinfo['starttime'] + $pollinfo['days'] * 24 * 3600);
    //Tags
    $tmpl->assign('TAG_IDS', $tagids);
    $tmpl->assign('TAG', $tagdata);
    $tmpl->assign('KEYWORDS', $keywords);
    $tmpl->parse('functions/' . $template, 'poll');
}
Beispiel #3
0
|                  http://www.stylemotion.de                    |
|                                                               |
|---------------------------------------------------------------|
| THIS SOFTWARE IS NOT FREE! MAKE SURE YOU OWN A VALID LICENSE! |
| DO NOT REMOVE ANY COPYRIGHTS WITHOUT PERMISSION!              |
| SOFTWARE BELONGS TO ITS AUTHORS!                              |
\***************************************************************/
define('APXRUN', true);
////////////////////////////////////////////////////////////////////////////////////////////////////////
require 'lib/_start.php';
//////////////////////////////////////////////////////////// SYSTEMSTART ///
////////////////////////////////////////////////////////////////////////////////////////////////////////
require_once BASEDIR . getmodulepath('poll') . 'functions.php';
$apx->module('poll');
$apx->lang->drop('poll');
$recent = poll_recent();
$_REQUEST['id'] = (int) $_REQUEST['id'];
if ($_REQUEST['recent']) {
    $_REQUEST['id'] = $recent;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////// ARCHIV ANZEIGEN
if (!$_REQUEST['id']) {
    //Verwendete Variablen auslesen
    $parse = $apx->tmpl->used_vars('archive');
    headline($apx->lang->get('HEADLINE_ARCHIVE'), mklink('poll.php', 'poll.html'));
    titlebar($apx->lang->get('HEADLINE_ARCHIVE'));
    $data = $db->fetch("SELECT id,question,addtime,starttime,days,a1_c+a2_c+a3_c+a4_c+a5_c+a6_c+a7_c+a8_c+a9_c+a10_c+a11_c+a12_c+a13_c+a14_c+a15_c+a16_c+a17_c+a18_c+a19_c+a20_c AS total FROM " . PRE . "_poll WHERE ( ( '" . time() . "' BETWEEN starttime AND endtime ) " . iif(!$set['poll']['archall'], " AND ( id!='" . $recent . "' OR endtime<='" . time() . "' ) ") . " " . section_filter() . " ) ORDER BY starttime DESC");
    if (count($data)) {
        foreach ($data as $res) {
            ++$i;
            //Tags
Beispiel #4
0
function poll_showcomments($id)
{
    global $set, $db, $apx, $user;
    $id = (int) $id;
    if (!$id) {
        die('missing ID!');
    }
    $recent = poll_recent();
    $res = $db->first("SELECT id,allowcoms FROM " . PRE . "_poll WHERE ( id='" . $id . "' AND ( '" . time() . "' BETWEEN starttime AND endtime ) " . iif($apx->section_id(), " " . section_filter() . " ") . " ) LIMIT 1");
    if (!$apx->is_module('comments') || !$set['poll']['coms'] || !$res['allowcoms']) {
        return;
    }
    require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
    $coms = new comments('poll', $id);
    $coms->assign_comments();
    if ($recent != $res['id'] && !$set['poll']['archcoms']) {
        $apx->tmpl->assign('COMMENT_NOFORM', 1);
    }
    $apx->tmpl->parse('comments', 'comments');
    require 'lib/_end.php';
}