Ejemplo n.º 1
0
function eguide_dlimit_check($eid, $exid, $poster)
{
    global $xoopsUser, $xoopsModule, $xoopsTpl;
    $tpl = is_object($xoopsTpl);
    if (!is_object($xoopsUser)) {
        // need login in this plugin
        if ($tpl) {
            $xoopsTpl->assign('message', _MD_RESERV_NEEDLOGIN);
        }
        return false;
    }
    // need points for order
    $limit = eguide_form_options('max_register_in_day', 1);
    $nrec = eguide_dlimit_condition($eid, $exid);
    if ($limit == 0 || $nrec < $limit) {
        // check more condition
        $rmax = eguide_form_options('max_register_in_future', 0);
        if ($rmax == 0) {
            return true;
        }
        if (eguide_dlimit_rsvcount($eid, $exid) < $rmax) {
            return true;
        }
        if ($tpl) {
            $xoopsTpl->assign('message', sprintf(_PI_EGUIDE_DLIMIT_FULL_OF_FUTURE, $rmax));
        }
    } else {
        if ($tpl) {
            $xoopsTpl->assign('message', sprintf(_PI_EGUIDE_DLIMIT_FULL_OF_DAY, $limit));
        }
    }
    return false;
}
Ejemplo n.º 2
0
 $start = param('start');
 $max_list = $xoopsModuleConfig['max_list'];
 $nav = new XoopsPageNav($total, $max_list, $start, "start", "eid={$eid}" . ($exid ? "&exid={$exid}" : '') . ($s ? "search={$s}" : ''));
 $xoopsTpl->assign('users_total', $total);
 if ($total > $max_list) {
     $xoopsTpl->assign('navigation', $nav->renderNav());
 }
 $res = $xoopsDB->query("SELECT uid,{$cols} {$cond}", $max_list, $start);
 $users = array();
 if (empty($s)) {
     $users[] = array('uid' => -1, 'uname' => $GLOBALS['xoopsConfig']['anonymous']);
 }
 while ($user = $xoopsDB->fetchArray($res)) {
     $users[] = $user;
 }
 $labels = eguide_form_options('users_search_labels', '');
 $lang = array('uname' => _MD_UNAME, 'email' => _MD_EMAIL);
 $cols = explode(',', $cols);
 $labels = $labels ? explode(',', $labels) : array();
 for ($i = 0; $i < count($cols); $i++) {
     $col = $cols[$i];
     if (isset($labels[$i])) {
         $lang[$col] = $labels[$i];
     } else {
         if (!isset($lang[$col])) {
             $lang[$col] = $col;
         }
     }
 }
 $xoopsTpl->assign('columns', $cols);
 $xoopsTpl->assign('users', $users);
Ejemplo n.º 3
0
function assign_module_css()
{
    global $xoopsTpl;
    $css = htmlspecialchars(eguide_form_options('module_css', HEADER_CSS));
    $header = $xoopsTpl->get_template_vars('xoops_module_header');
    if ($css && !preg_match('/' . preg_quote($css, '/') . '/', $header)) {
        $header .= '<link rel="stylesheet" type="text/css" media="all" href="' . $css . '" />';
        $xoopsTpl->assign('xoops_module_header', $header);
    }
}
Ejemplo n.º 4
0
function check_prev_order($data, $vals, &$errs, $force = false)
{
    global $xoopsModuleConfig, $xoopsDB, $xoopsUser;
    $eid = $data['eid'];
    $exid = intval($data['exid']);
    // stopping if multiple event but no have exid (missing?)
    if (!empty($data) && empty($data['exid'])) {
        $result = $xoopsDB->query('SELECT exid FROM ' . EXTBL . " WHERE eidref={$eid}");
        if ($xoopsDB->getRowsNum($result) > 0) {
            $errs[] = _MD_RESERV_STOP;
        }
    }
    // stop reservation or limit over
    if (empty($data['reservation']) || empty($data['past_register']) && $data['edate'] - $data['closetime'] < time()) {
        if (empty($errs)) {
            $errs[] = _MD_RESERV_STOP;
        }
    }
    // order duplicate check
    $mo = $xoopsModuleConfig['member_only'];
    if ($force || $mo == ACCEPT_EMAIL || $mo == ACCEPT_BOTH && !is_object($xoopsUser)) {
        $email = param('email', '');
        if (!($force && empty($email))) {
            if (!preg_match('/^[\\w\\-_\\.]+@[\\w\\-_\\.]+$/', $email)) {
                $errs[] = _MD_EMAIL . ": " . htmlspecialchars($email) . " - " . _MD_MAIL_ERR;
            }
            if (eguide_form_options('email_repeat_check')) {
                $conf = param('email_conf', '');
                if ($email !== $conf) {
                    $errs[] = _MD_MAIL_CONF_ERR;
                }
            }
            $ml = strtolower($email);
            $result = $xoopsDB->query('SELECT rvid FROM ' . RVTBL . " WHERE eid={$eid} AND exid={$exid} AND email=" . $xoopsDB->quoteString($ml));
        } else {
            $result = false;
        }
    } else {
        if (!is_object($xoopsUser)) {
            redirect_header($_SERVER['HTTP_REFERER'], 2);
        }
        $result = $xoopsDB->query('SELECT rvid FROM ' . RVTBL . " WHERE eid={$eid} AND exid={$exid} AND uid=" . $xoopsUser->getVar('uid'));
        $email = $xoopsUser->getVar('uname');
        $ml = '';
    }
    if ($result && $xoopsDB->getRowsNum($result)) {
        $errs[] = _MD_EMAIL . ": " . htmlspecialchars($email) . " - " . _MD_DUP_ERR;
    }
    // checking is there any seat?
    $num = 1;
    // how many orders?
    $nlab = eguide_form_options('label_persons');
    if ($nlab && isset($vals[$nlab])) {
        $num = intval($vals[$nlab]);
        if ($num < 1) {
            $num = 1;
        }
    }
    if ($data['strict']) {
        if ($data['persons'] <= $data['reserved']) {
            $errs[] = _MD_RESERV_FULL;
        } elseif ($data['persons'] < $data['reserved'] + $num) {
            $errs[] = sprintf($nlab . _MD_RESERV_TOMATCH, $num, $data['persons'] - $data['reserved']);
        }
    }
    return $errs;
}
Ejemplo n.º 5
0
 $input_status = $adm ? select_list('status', $ev_stats, $data['status']) : '';
 if (empty($data['before'])) {
     $data['before'] = time_to_str($data['closetime']);
 }
 edit_eventdata($data);
 $data['optfield'] = htmlspecialchars($data['optfield']);
 $xoopsTpl->assign($data);
 class myFormDhtmlTextArea extends XoopsFormDhtmlTextArea
 {
     function _renderSmileys()
     {
     }
 }
 $summary = isset($data['summary']) ? $data['summary'] : '';
 $textarea = new myFormDhtmlTextArea('', 'summary', $summary, 10, 60);
 $nlab = eguide_form_options('label_persons');
 if ($nlab) {
     $nlab = sprintf(_MD_RESERV_LABEL_DESC, $nlab);
 }
 $edate = $data['edate'];
 $xoopsTpl->assign(array('input_edate' => datefield('edate', $edate), 'input_edatetime' => timefield('edate', $edate), 'edatetime' => formatTimestamp($edate, 'H:i'), 'input_expire' => $input_expire, 'input_category' => $input_category, 'input_extent' => $input_extent, 'input_status' => $input_status, 'extent_sets' => $extent_sets, 'label_desc' => $nlab, 'summary_textarea' => $textarea->render(), 'input_style' => select_list('style', $edit_style, $data['style']), 'edata' => $data));
 if ($data['optvars']) {
     $optvars = unserialize_vars($data['optvars']);
     $xoopsTpl->assign('optvars', $optvars);
     foreach (explode("\n", _EG_OPTDEFS) as $item) {
         list($fname) = explode("=", $item);
         unset($optvars[$fname]);
     }
     $others = "";
     foreach ($optvars as $k => $v) {
         $others .= "{$k}={$v}\n";
Ejemplo n.º 6
0
 if (empty($errs)) {
     srand();
     $data['confirm'] = $conf = rand(10000, 99999);
     $uid = 'NULL';
     if (is_object($xoopsUser)) {
         if (empty($ml) || strtolower($xoopsUser->getVar('email')) == $ml) {
             $uid = $xoopsUser->getVar('uid');
         }
     }
     $ml = $xoopsDB->quoteString($email);
     $accept = $data['autoaccept'];
     $xoopsDB->query('INSERT INTO ' . RVTBL . "\n\t(eid, exid, uid, rdate, email, info, status, confirm)\nVALUES ({$eid},{$exid},{$uid},{$now},{$ml}, " . $xoopsDB->quoteString($value) . ",{$accept},'{$conf}')");
     $data['rvid'] = $rvid = $xoopsDB->getInsertId();
     $evurl = EGUIDE_URL . "/event.php?eid={$eid}" . ($exid ? "&sub={$exid}" : "");
     if (order_notify($data, $email, $value)) {
         $url = eguide_form_options('redirect', '');
         if (!empty($url)) {
             $sec = 3;
             if (preg_match('/^(\\d+);/', $url, $d)) {
                 $sec = $d[1];
                 $url = preg_replace('/^(\\d+);\\s*/', '', $url);
             }
             $url = str_replace(array('{X_EID}', '{X_SUB}', '{X_RVID}'), array($eid, $exid, $rvid), $url);
             $xoopsTpl->assign('xoops_module_header', sprintf('<meta http-equiv="Refresh" content="%u; url=%s" />', $sec, htmlspecialchars($url)));
             assign_module_css();
         }
         echo "<div class='evform'>\n";
         echo "<p><a href='{$evurl}' class='evhead'>" . eventdate($data['edate']) . " &nbsp; " . htmlspecialchars($data['title']) . "</a></p>";
         echo "<h3>" . _MD_RESERVATION . "</h3>\n";
         echo "<p><b>" . _MD_RESERV_ACCEPT . "</b></p>";
         if ($value) {
Ejemplo n.º 7
0
    // fallback
    return include_once $nlang;
}
// register plugin functions
function eguide_plugin_register($name)
{
    global $hooked_function;
    foreach (array('check', 'reserve', 'cancel') as $act) {
        $func = 'eguide_' . $name . '_' . $act;
        if (function_exists($func)) {
            $hooked_function[$act][] = $func;
        }
    }
}
if ($xoopsModuleConfig['use_plugins'] && is_dir($dir)) {
    $plugins = eguide_form_options('eguide_plugins', '');
    if ($plugins) {
        foreach (explode(',', $plugins) as $name) {
            $file = "{$name}.php";
            if (include "{$dir}/{$file}") {
                eguide_plugin_language($file);
                eguide_plugin_register($name);
            }
        }
    } else {
        // search module control plugins
        $dh = opendir($dir);
        while ($file = readdir($dh)) {
            if (preg_match('/^([\\w\\d]+)\\.php$/', $file, $d)) {
                $name = $d[1];
                $module_handler =& xoops_gethandler('module');
Ejemplo n.º 8
0
function summary_csv()
{
    global $xoopsDB;
    function _q($x)
    {
        return '"' . preg_replace('/"/', '""', $x) . '"';
    }
    $file = "eguide_summary_" . formatTimestamp(time(), "Ymd") . ".csv";
    $charset = eguide_form_options('export_charset', _MD_EXPORT_CHARSET);
    header("Content-Type: text/plain; Charset=" . $charset);
    header('Content-Disposition:attachment;filename="' . $file . '"');
    $result = $xoopsDB->query('SELECT e.eid,if(x.exid,x.exid,0) exid, IF(exdate,exdate,edate) exdate,title,uid,status,persons,IF(x.reserved,x.reserved,o.reserved) reserved FROM ' . EGTBL . ' e LEFT JOIN ' . OPTBL . ' o ON e.eid=o.eid LEFT JOIN ' . EXTBL . " x ON e.eid=eidref ORDER BY exdate DESC,e.eid DESC");
    $out = '"' . join('","', array("ID", "", _MD_EXTENT_DATE, _AM_TITLE, _AM_POSTER, _MD_RESERV_PERSONS, _AM_RESERVATION)) . "\"\n";
    while ($data = $xoopsDB->fetchArray($result)) {
        $date = eventdate($data['exdate']);
        $poster = XoopsUser::getUnameFromId($data['uid']);
        $exid = $data['exid'] ? $data['exid'] : '';
        $out .= join(',', array($data['eid'], $exid, _q($date), _q($data['title']), _q($poster), $data['persons'], $data['reserved'])) . "\n";
    }
    if ($charset != _CHARSET) {
        if (function_exists("mb_convert_encoding")) {
            $out = mb_convert_encoding($out, $charset, _CHARSET);
        } elseif (function_exists("iconv")) {
            $out = iconv($charset, _CHARSET, $out);
        }
    }
    echo $out;
    exit;
}
Ejemplo n.º 9
0
                    $outs[$v] = true;
                }
            }
            break;
        } elseif (preg_match('/^\\d+$/', $k)) {
            // present position
            if (isset($temp[$k])) {
                $outs[$temp[$k]] = true;
            }
        } elseif ($k == '' || in_array($k, $temp)) {
            // present name
            $outs[$k] = true;
        }
    }
}
$nfield = eguide_form_options('excel_max_cols', count($outs) + 1);
$outs = array_keys($outs);
$blank = array();
$nbsp = array("value" => "", "type" => "String");
for ($i = 0; $i < $nfield; $i++) {
    $blank[] = $nbsp;
}
while ($data = $xoopsDB->fetchArray($result)) {
    $edate = $data['edate'];
    $tab = formatTimestamp($edate, 'md');
    $n = 1;
    while (isset($sheets[$tab]) && count($sheets[$tab]['rows']) >= $max_sect) {
        $n++;
        $tab = formatTimestamp($edate, 'md') . "({$n})";
    }
    if (empty($sheets[$tab])) {
Ejemplo n.º 10
0
    // body
    while ($a = $xoopsDB->fetchArray($result)) {
        $row = unserialize_text($a['info']);
        $row[_MD_EMAIL] = $a['email'];
        $row[_MD_ORDER_DATE] = formatTimestamp($a['rdate']);
        $row[_MD_UNAME] = display_username($a['uid']);
        $row[_MD_RVID] = $a['rvid'];
        $temp = array();
        foreach ($outs as $k) {
            $v = $row[$k];
            $temp[] = '"' . preg_replace('/\\"/', '""', $v) . '"';
        }
        $out .= join(',', $temp) . "\n";
    }
    $file = "eguide_" . formatTimestamp(time(), "Ymd") . ".csv";
    $charset = eguide_form_options('export_charset', _MD_EXPORT_CHARSET);
    header("Content-Type: text/plain; Charset=" . $charset);
    header('Content-Disposition:attachment;filename="' . $file . '"');
    if ($charset != _CHARSET) {
        if (function_exists("mb_convert_encoding")) {
            $out = mb_convert_encoding($out, $charset, _CHARSET);
        } elseif (function_exists("iconv")) {
            $out = iconv(_CHARSET, $charset, $out);
        }
    }
    echo $out;
    exit;
}
include XOOPS_ROOT_PATH . "/header.php";
assign_module_css();
if (count($extents) > 1) {