/** * Process CMS tags into HTML for comments. */ function cms_tag_trackbacks($tag_attr, $tag_default) { global $db, $row, $block, $Current_weblog, $Weblogs, $Paths; if (strlen($Weblogs[$Current_weblog]['trackback_format']) > 1) { $format = $Weblogs[$Current_weblog]['trackback_format']; } else { $format = "%anchor%<p><strong>%title%</strong><br />%excerpt%<br /><small>Sent on %date%, via %url%</small></p>"; } // If %editlink% is not present, insert it right after %date%.. if (strpos($format, "%editlink%") == 0) { $format = str_replace("%date%", "%date% %editlink%", $format); } $content_code = get_attr_value('content_code', $tag_attr); $entrydate = $Weblogs[$Current_weblog]['fulldate_format']; if ($content_code == "") { $content_code = $row["code"]; } $output = '<a id="track"></a>'; $last_trackback = ""; if (isset($db->entry['trackbacks']) && count($db->entry['trackbacks']) > 0) { foreach ($db->entry['trackbacks'] as $count => $temp_row) { /** * this is a record we have to output in some form.. */ $temp_row['url'] = strip_tags($temp_row['url']); if (!ip_check_block($temp_row["ip"])) { /** * Make 'edit' and 'delete' links.. */ $editlink = get_edittrackbacklink($db->entry['code'], $count); /** * make link achnor */ $anchor = "<a id=\"" . safe_string($temp_row["name"], TRUE) . "-" . format_date($temp_row["date"], "%ye%%month%%day%%hour24%%minute%") . "\"></a>"; /** * substite all of the parameters into the comment, and add it to the output. */ $this_tag = $format; $this_tag = str_replace("%count%", $count + 1, $this_tag); $this_tag = str_replace("%even-odd%", $count % 2 ? 'even' : 'odd', $this_tag); $this_tag = str_replace("%ip%", $temp_row["ip"], $this_tag); $this_tag = str_replace("%date%", format_date($temp_row["date"], $entrydate), $this_tag); $this_tag = str_replace("%excerpt%", comment_format($temp_row["excerpt"]), $this_tag); $this_tag = str_replace("%title%", $temp_row["title"], $this_tag); $url = '<a href="' . $temp_row["url"] . '">' . stripslashes($temp_row["name"]) . '</a>'; $this_tag = str_replace("%url%", $url, $this_tag); $this_tag = str_replace("%anchor%", $anchor, $this_tag); $this_tag = str_replace("%editlink%", $editlink, $this_tag); $output .= $this_tag; } } } // make an array of strings with the notices to print $text = array($Weblogs[$Current_weblog]['trackbacks_text_0'], $Weblogs[$Current_weblog]['trackbacks_text_1'], $Weblogs[$Current_weblog]['trackbacks_text_2']); // $track_ind = sprintf("<p><b>%s:</b></p>", $text[min(2,count($db->entry['trackbacks']))]); // $track_ind = str_replace("%num%", lang('numbers', count($db->entry['trackbacks'])), $track_ind); // $track_ind = str_replace("%n%", count($db->entry['trackbacks']), $track_ind); $output = $output; return $output; }
function store_message($items, $form) { global $xoopsUser, $xoopsDB, $xoopsModuleConfig; $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; $store = $form['store']; if ($store == _DB_STORE_NONE) { $showaddr = true; // no store to need show address } else { $showaddr = get_attr_value(null, 'notify_with_email'); } $from = $email = ""; $attach = array(); $vals = array(); $rtext = ''; foreach ($items as $item) { if (empty($item['name'])) { continue; } $name = $item['name']; $val = $item['value']; $vals[$name] = $val; $opts =& $item['options']; switch ($item['type']) { case 'mail': if (empty($email)) { // save first email for contact $email = $vals[$name]; $mail_name = $name; if ($showaddr) { $from = $email; break; } continue 2; /* PHP switch catch continue! */ } break; case 'file': $val = $vals[$name]; if ($val) { $vals[$name] = "file=" . $val; $attach[] = $val; } break; case 'radio': case 'select': if (isset($opts[$val])) { $val = strip_tags($opts[$val]); } break; case 'checkbox': foreach ($val as $k => $v) { $val[$k] = isset($opts[$v]) ? strip_tags($opts[$v]) : $v; } $val = join(', ', $val); break; } if (!empty($val) && preg_match('/\\n/', $val)) { $val = "\n\t" . preg_replace('/\\n/', "\n\t", $val); } $rtext .= strip_tags($item['label']) . ": {$val}\n"; } // remove if not show/store email address in database if (!$showaddr && isset($mail_name)) { unset($vals[$mail_name]); } $text = serialize_text($vals); // store value $onepass = $uid == 0 ? cc_onetime_ticket($email) : ""; if ($form['priuid'] < 0) { $touid = empty($form['priuser']) ? 0 : $form['priuser']['uid']; } else { $touid = $form['priuid']; } $now = time(); $values = array('uid' => $uid, 'touid' => $touid, 'ctime' => $now, 'mtime' => $now, 'atime' => $now, 'fidref' => $form['formid'], 'email' => $xoopsDB->quoteString($email), 'onepass' => $xoopsDB->quoteString($onepass)); $parg = $onepass ? "&p=" . urlencode($onepass) : ""; if ($store == _DB_STORE_YES) { $values['body'] = $xoopsDB->quoteString($text); } if ($store != _DB_STORE_NONE) { $res = $xoopsDB->query("INSERT INTO " . CCMES . "(" . join(',', array_keys($values)) . ") VALUES (" . join(',', $values) . ")"); if ($res === false) { return array("Error in DATABASE insert"); } $id = $xoopsDB->getInsertID(); if (empty($id)) { return array("Internal Error in Store Message"); } } else { $id = 0; } $member_handler =& xoops_gethandler('member'); if ($touid) { $toUser = $member_handler->getUser($touid); $toUname = $toUser->getVar('uname'); } else { $toUser = false; $toUname = _MD_CONTACT_NOTYET; } $atext = ""; // reply sender $btext = ""; // to contact and monitors if (count($attach)) { $atext = $btext = "\n" . _MD_ATTACHMENT . "\n"; foreach ($attach as $i => $file) { move_attach_file('', $file, $id); $a = cc_attach_image($id, $file, true); $atext .= "{$a}{$parg}\n"; $btext .= "{$a}\n"; } rmdir(XOOPS_UPLOAD_PATH . cc_attach_path(0, '')); } $dirname = basename(dirname(__FILE__)); $uname = $xoopsUser ? $xoopsUser->getVar('uname') : $GLOBALS['xoopsConfig']['anonymous']; $tags = array('SUBJECT' => $form['title'], 'TO_USER' => $toUname, 'FROM_USER' => $uname, 'FROM_EMAIL' => $email, 'REMOTE_ADDR' => $_SERVER["REMOTE_ADDR"], 'HTTP_USER_AGENT' => $_SERVER["HTTP_USER_AGENT"], 'MSGID' => $id); foreach ($vals as $k => $v) { $tags[$k] = is_array($v) ? implode(', ', $v) : $v; } $tpl = get_attr_value(null, 'from_confirm_tpl', 'form_confirm.tpl'); $msgurl = XOOPS_URL . ($id ? "/modules/{$dirname}/message.php?id={$id}" : '/'); if ($email) { // reply automaticaly $tags['VALUES'] = "{$rtext}{$atext}"; $tags['MSG_URL'] = $store == _DB_STORE_NONE ? '' : "\n" . _MD_NOTIFY_URL . "\n{$msgurl}{$parg}"; cc_notify_mail($tpl, $tags, $email, $toUser ? $toUser->getVar('email') : ''); } $tags['VALUES'] = "{$rtext}{$btext}"; $tags['MSG_URL'] = $store == _DB_STORE_NONE ? '' : "\n" . _MD_NOTIFY_URL . "\n" . $msgurl; $notification_handler =& xoops_gethandler('notification'); $notification_handler->triggerEvent('global', 0, 'new', $tags); $notification_handler->triggerEvent('form', $form['formid'], 'new', $tags); // force subscribe sender and recipient if ($id) { $notification_handler->subscribe('message', $id, 'comment'); } if ($touid) { if ($id) { $notification_handler->subscribe('message', $id, 'comment', null, null, $touid); } cc_notify_mail(get_attr_value(null, 'charge_notify_tpl', $tpl), $tags, $toUser, $from); } elseif ($form['cgroup']) { // contact group notify $users = $member_handler->getUsersByGroup($form['cgroup'], true); cc_notify_mail(get_attr_value(null, 'group_notify_tpl', $tpl), $tags, $users, $from); } if ($id) { $msgurl .= $parg; } $redirect = get_attr_value(null, 'redirect'); if (!empty($redirect)) { $msgurl = preg_match('/^\\//', $redirect) ? XOOPS_URL . $redirect : $redirect; } redirect_header($msgurl, 3, _MD_CONTACT_DONE); exit; }
if ($mpos < 0 && $item['type'] == 'mail') { $mpos = $n; } $labels[] = $item['label']; } $contents = strip_tags(csv_str($labels)) . "\n"; while ($data = $xoopsDB->fetchArray($res)) { $values = unserialize_text($data['body']); if ($mpos >= 0) { array_splice($values, $mpos, 0, array($data['email'])); } $fixval = array($data['msgid'], formatTimestamp($data['mtime']), $msg_status[$data['status']], $xoopsUser->getUnameFromId($data['uid']), $xoopsUser->getUnameFromId($data['touid'])); $contents .= csv_str($fixval) . "," . csv_str($values) . "\n"; } if (function_exists("mb_convert_encoding")) { $charset = get_attr_value(null, 'export_charset'); if (!$charset) { $charset = _MD_EXPORT_CHARSET; } $contents = mb_convert_encoding($contents, $charset, _CHARSET); } else { $charset = _CHARSET; } $tm = formatTimestamp(time(), 'Ymd'); $file = "ccenter_form{$id}-{$range}-{$tm}.csv"; header('Content-Disposition:attachment;filename="' . $file . '"'); header("Content-type: text/csv; charset={$charset}"); header("Cache-Control: public"); header("Pragma: public"); echo $contents; exit;
function checkScript($checks, $confirm, $pattern) { global $xoopsTpl; $chks = array(); foreach ($checks as $name => $msg) { $pat = $pattern[$name]; $v = get_attr_value(null, $pat); if (!empty($v)) { $pat = $v; } $pat = htmlspecialchars(preg_replace('/([\\\\\\"])/', '\\\\$1', $pat)); $chks[$name] = array('message' => $msg, 'pattern' => $pat); } $tpl = new XoopsTpl(); $tpl->assign('item', array("type" => "javascript", "confirm" => $confirm, 'checks' => $chks)); return $tpl->fetch('db:' . _CC_WIDGET_TPL); }
function build_form($formid = 0) { global $xoopsDB, $xoopsUser, $myts, $fields, $xoopsConfig, $xoopsModuleConfig, $xoopsTpl; include_once dirname(dirname(__FILE__)) . "/language/" . $xoopsConfig['language'] . '/main.php'; if (isset($_POST['formid'])) { $data = array(); $fields[] = 'priuid'; $fields[] = 'cgroup'; foreach ($fields as $name) { $data[$name] = $myts->stripSlashesGPC($_POST[$name]); } $data['optvars'] = post_optvars(); $data['grpperm'] = $_POST['grpperm']; $formid = intval($_POST['formid']); // form preview get_attr_value($data['optvars']); // set default values $items = get_form_attribute($data['defs']); assign_form_widgets($items); if ($_POST['preview']) { echo "<h2>" . _PREVIEW . " : " . htmlspecialchars($data['title'], ENT_QUOTES) . "</h2>\n"; echo "<div class='preview'>\n"; $data['action'] = ''; $data['check_script'] = ""; $data['items'] =& $items; if (empty($xoopsTpl)) { $xoopsTpl = new XoopsTpl(); } $out = $xoopsTpl->fetch('db:' . render_form($data, 'form')); echo preg_replace('/type=["\']submit["\']/', 'type="submit" disabled="disabled"', $out); echo "</div>\n<hr size='5'/>\n"; } } elseif ($formid) { $res = $xoopsDB->query('SELECT * FROM ' . FORMS . " WHERE formid={$formid}"); $data = $xoopsDB->fetchArray($res); $data['grpperm'] = explode('|', trim($data['grpperm'], '|')); } else { $data = array('title' => '', 'description' => '', 'defs' => '', 'store' => 1, 'custom' => 0, 'weight' => 0, 'active' => 1, 'priuid' => $xoopsUser->getVar('uid'), 'cgroup' => XOOPS_GROUP_ADMIN, 'optvars' => '', 'grpperm' => array(XOOPS_GROUP_USERS)); } $form = new XoopsThemeForm($formid ? _AM_FORM_EDIT : _AM_FORM_NEW, 'myform', 'index.php'); $form->addElement(new XoopsFormHidden('formid', $formid)); $form->addElement(new XoopsFormText(_AM_FORM_TITLE, 'title', 35, 80, $data['title']), true); if (!empty($data['mtime'])) { $form->addElement(new XoopsFormLabel(_AM_FORM_MTIME, formatTimestamp($data['mtime']))); } $desc = new XoopsFormElementTray(_AM_FORM_DESCRIPTION, "<br/>"); $description = $data['description']; $editor = get_attr_value(null, 'use_fckeditor'); if ($editor) { $desc->addElement(new XoopsFormTextArea('', 'description', $description, 10, 60)); } else { $desc->addElement(new XoopsFormDhtmlTextArea('', 'description', $description, 10, 60)); } if (!$editor) { $button = new XoopsFormButton('', 'ins_tpl', _AM_INS_TEMPLATE); $button->setExtra("onClick=\"myform.description.value += defsToString();\""); $desc->addElement($button); } $error = check_form_tags($data['custom'], $data['defs'], $description); if ($error) { $desc->addElement(new XoopsFormLabel('', "<div style='color:red;'>{$error}</div>")); } $form->addElement($desc); $custom = new XoopsFormSelect(_AM_FORM_CUSTOM, 'custom', $data['custom']); $custom->setExtra(' onChange="myform.ins_tpl.disabled = (this.value==0||this.value==4);"'); $custom_type = unserialize_vars(_AM_CUSTOM_DESCRIPTION); if ($editor) { unset($custom_type[0]); } $custom->addOptionArray($custom_type); $form->addElement($custom); $grpperm = new XoopsFormSelectGroup(_AM_FORM_ACCEPT_GROUPS, 'grpperm', true, $data['grpperm'], 4, true); $grpperm->setDescription(_AM_FORM_ACCEPT_GROUPS_DESC); $form->addElement($grpperm); $defs_tray = new XoopsFormElementTray(_AM_FORM_DEFS); $defs_tray->addElement(new XoopsFormTextArea('', 'defs', $data['defs'], 10, 60)); $defs_tray->addElement(new XoopsFormLabel('', '<div id="itemhelper" style="display:none; white-space:nowrap;"> ' . _AM_FORM_LAB . ' <input name="xelab" size="10"> <input type="checkbox" name="xereq" title="' . _AM_FORM_REQ . '"> <select name="xetype"> <option value="text">text</option> <option value="checkbox">checkbox</option> <option value="radio">radio</option> <option value="textarea">textarea</option> <option value="select">select</option> <option value="const">const</option> <option value="hidden">hidden</option> <option value="mail">mail</option> <option value="file">file</option> </select> <input name="xeopt" size="30" /> <button onClick="return addFieldItem();">' . _AM_FORM_ADD . '</button> </div>')); $defs_tray->setDescription(_AM_FORM_DEFS_DESC); $form->addElement($defs_tray); $member_handler =& xoops_gethandler('member'); $groups = $member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!=')); $groups = $member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!=')); $options = array(); foreach ($groups as $k => $v) { $options[-$k] = sprintf(_CC_FORM_PRIM_GROUP, $v); } $options[0] = _AM_FORM_PRIM_NONE; $priuid = new MyFormSelect(_AM_FORM_PRIM_CONTACT, 'priuid', $data['priuid']); $priuid->addOptionArray($options); $priuid->addOptionUsers($data['cgroup']); $priuid->setDescription(_AM_FORM_PRIM_DESC); $form->addElement($priuid); $cgroup = new XoopsFormSelect('', 'cgroup', $data['cgroup']); $cgroup->setExtra(' onChange="setSelectUID(\'priuid\', 0);"'); $cgroup->addOption(0, _AM_FORM_CGROUP_NONE); $groups = $member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!=')); $cgroup->addOptionArray($groups); $cgroup_tray = new XoopsFormElementTray(_AM_FORM_CONTACT_GROUP); $cgroup_tray->addElement($cgroup); $cgroup_tray->addElement(new XoopsFormLabel('', '<noscript><input type="submit" name="chggrp" id="chggrp" value="' . _AM_CHANGE . '"/></noscript>')); $form->addElement($cgroup_tray); $store = new XoopsFormSelect(_AM_FORM_STORE, 'store', $data['store']); $store->addOptionArray(unserialize_vars(_CC_STORE_MODE, 1)); $form->addElement($store); $form->addElement(new XoopsFormRadioYN(_AM_FORM_ACTIVE, 'active', $data['active'])); $form->addElement(new XoopsFormText(_AM_FORM_WEIGHT, 'weight', 2, 8, $data['weight'])); $items = get_form_attribute(_CC_OPTDEFS, _AM_OPTVARS_LABEL, 'optvar'); $vars = unserialize_vars($data['optvars']); $others = ""; foreach ($items as $k => $item) { $name = $item['name']; if (isset($vars[$name])) { $items[$k]['default'] = $vars[$name]; unset($vars[$name]); } } $val = ""; foreach ($vars as $i => $v) { $val .= "{$i}={$v}\n"; } $items[$k]['default'] = $val; assign_form_widgets($items); $varform = ""; foreach ($items as $item) { $br = $item['type'] == "textarea" ? "<br/>" : ""; $class = $item['default'] ? ' class="changed"' : ''; $varform .= "<div><span{$class}>" . $item['label'] . "</span>: {$br}" . $item['input'] . "</div>"; } $ck = empty($data['optvars']) ? "" : " checked='checked'"; $optvars = new XoopsFormLabel(_AM_FORM_OPTIONS, "<script type='text/javascript'>document.write(\"<input type='checkbox' id='optshow' onChange='toggle(this);'{$ck}/> " . _AM_OPTVARS_SHOW . "\");</script><div id='optvars'" . ($ck ? '' : ' style="display:none;"') . ">{$varform}</div>"); $form->addElement($optvars); $submit = new XoopsFormElementTray(''); $submit->addElement(new XoopsFormButton('', 'formdefs', _SUBMIT, 'submit')); $submit->addElement(new XoopsFormButton('', 'preview', _PREVIEW, 'submit')); $form->addElement($submit); echo "<a name='form'></a><style>.changed {font-weight: bold;}</style>"; $form->display(); if ($editor) { $base = XOOPS_URL . "/common/fckeditor"; global $xoopsTpl; echo "<script type='text/javascript' src='{$base}/fckeditor.js'></script>\n"; $editor = "var ccFCKeditor = new FCKeditor('description', '100%', '350', '{$editor}');\nccFCKeditor.BasePath = '{$base}/';\nccFCKeditor.ReplaceTextarea();"; } echo '<script language="JavaScript">' . $priuid->renderSupportJS(false) . ' // display only JavaScript enable xoopsGetElementById("itemhelper").style.display = "block"; ' . $editor . ' function toggle(a) { xoopsGetElementById("optvars").style.display = a.checked?"block":"none"; } togle(xoopsGetElementById("optshow")); function addFieldItem() { var myform = window.document.myform; var item=myform.xelab.value; if (item == "") { alert("' . _AM_FORM_LABREQ . '"); myform.xelab.focus(); return false; } if (myform.xereq.checked) item += "*"; var ty = myform.xetype.value; var ov = myform.xeopt.value; item += ","+ty; if (ty != "text" && ty != "textarea" && ty != "file" && ty != "mail" && ov == "") { alert(ty+": ' . _AM_FORM_OPTREQ . '"); myform.xeopt.focus(); return false; } if (ov != "") item += ","+ov; opts = myform.defs; if (opts.value!="" && !opts.value.match(/[\\n\\r]$/)) item = "\\n"+item; opts.value += item; myform.xelab.value = ""; // clear old value myform.xeopt.value = ""; return false; // always return false } function defsToString() { value = window.document.myform.defs.value; ret = ""; lines = value.split("\\n"); conf = "' . _MD_CONF_LABEL . '"; for (i in lines) { lab = lines[i].replace(/,.*$/, ""); if (lab.match(/^\\s*#/)) { ret += "[desc]<div>"+lines[i].replace(/^\\s*#/, "")+"</div>[/desc]\\n"; } else if (lab != "") { ret += "<div>"+lab+": {"+lab.replace(/\\*?$/,"")+"}</div>\\n"; if (lines[i].match(/^[^,]+,\\s*mail/i)) { lab = conf.replace(/%s/, lab); ret += "[desc]<div>"+lab+": {"+lab.replace(/\\*?$/,"")+"}</div>[/desc]\\n"; } } } return "<form {FORM_ATTR}>\\n"+ret+ "<p>{SUBMIT} {BACK}</p>\\n</form>\\n{CHECK_SCRIPT}"; } fvalue = document.myform.custom.value; document.myform.ins_tpl.disabled = (fvalue==0 || fvalue==4); </script> '; }