function _ff_getListField_gettopic($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE; global $_FF_CONF, $_SYSTEM, $LANG_GF02, $LANG_GF03; USES_lib_html2text(); $dt = new Date('now', $_USER['tzid']); $retval = ''; switch ($fieldname) { case 'author': $retval = $A['name']; break; case 'date': $dt->setTimestamp($fieldvalue); $retval = $dt->format($_FF_CONF['default_Datetime_format'], true); break; case 'lastupdated': $dt->setTimestamp($fieldvalue); $retval = $dt->format($_FF_CONF['default_Datetime_format'], true); break; case 'subject': $testText = FF_formatTextBlock($A['comment'], 'text', 'text', $A['status']); $testText = strip_tags($testText); $html2txt = new html2text($testText, false); $testText = trim($html2txt->get_text()); $lastpostinfogll = htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...')), ENT_QUOTES, COM_getEncodingt()); $retval = '<span class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" title="' . $A['subject'] . '::' . $lastpostinfogll . '">' . $fieldvalue . '</span>'; break; case 'select': $retval = '[ <a href="#" onclick="insert_topic(\'' . $A['id'] . '\'); return false;">' . $LANG_GF03['select'] . '</a> ]'; break; default: $retval = $fieldvalue; break; } return $retval; }
public function parse($p1, $p2 = '', $fulltag) { global $_CONF, $_TABLES, $_USER, $LANG01; USES_lib_comments(); $retval = ''; $skip = 0; $dt = new Date('now', $_USER['tzid']); // topic = specific topic or 'all' // display = how many stories to display, if 0, then all // meta = show meta data (i.e.; who when etc) // titleLink - make title a hot link // featured - 0 = show all, 1 = only featured, 2 = all except featured // frontpage - 1 = show only items marked for frontpage - 0 = show all // cols - number of columns to show // template - the template name $topic = $p1; if ($topic == 'all') { $topic = ''; } $uniqueID = md5($p1 . $p2); $display = 10; // display 10 articles $meta = 0; // do not display meta data $titleLink = 0; // do not use links in title $featured = 0; // 0 = show all, 1 = only featured, 2 = all except featured $frontpage = 0; // only show items marked for frontpage $cols = 3; // number of columns $truncate = 0; // maximum number of characters to include in story text $template = 'headlines.thtml'; $px = explode(' ', trim($p2)); if (is_array($px)) { foreach ($px as $part) { if (substr($part, 0, 8) == 'display:') { $a = explode(':', $part); $display = $a[1]; $skip++; } elseif (substr($part, 0, 5) == 'meta:') { $a = explode(':', $part); $meta = $a[1]; $skip++; } elseif (substr($part, 0, 10) == 'titlelink:') { $a = explode(':', $part); $titleLink = $a[1]; $skip++; } elseif (substr($part, 0, 9) == 'featured:') { $a = explode(':', $part); $featured = $a[1]; $skip++; } elseif (substr($part, 0, 10) == 'frontpage:') { $a = explode(':', $part); $frontpage = (int) $a[1]; $skip++; } elseif (substr($part, 0, 5) == 'cols:') { $a = explode(':', $part); $cols = $a[1]; $skip++; } elseif (substr($part, 0, 9) == 'template:') { $a = explode(':', $part); $template = $a[1]; $skip++; } elseif (substr($part, 0, 9) == 'truncate:') { $a = explode(':', $part); $truncate = (int) $a[1]; $skip++; } else { break; } } if ($skip != 0) { if (count($px) > $skip) { for ($i = 0; $i < $skip; $i++) { array_shift($px); } $caption = trim(implode(' ', $px)); } else { $caption = ''; } } } else { $caption = trim($p2); } if ($display < 0) { $display = 3; } $hash = CACHE_security_hash(); $instance_id = 'whatsnew_headlines_' . $uniqueID . '_' . $hash . '_' . $_USER['theme']; if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) { return $cache; } $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1"); $sql = " (date <= NOW()) AND (draft_flag = 0)"; if (empty($topic)) { $sql .= COM_getLangSQL('tid', 'AND', 's'); } // if a topic was provided only select those stories. if (!empty($topic)) { $sql .= " AND s.tid = '" . DB_escapeString($topic) . "' "; } if ($featured == 1) { $sql .= " AND s.featured = 1 "; } else { if ($featured == 2) { $sql .= " AND s.featured = 0 "; } } if ($frontpage == 1) { $sql .= " AND frontpage = 1 "; } if ($topic != $archivetid) { $sql .= " AND s.tid != '{$archivetid}' "; } $sql .= COM_getPermSQL('AND', 0, 2, 's'); $sql .= COM_getTopicSQL('AND', 0, 's') . ' '; $userfields = 'u.uid, u.username, u.fullname'; if ($_CONF['allow_user_photo'] == 1) { $userfields .= ', u.photo'; if ($_CONF['use_gravatar']) { $userfields .= ', u.email'; } } $orderBy = ' date DESC '; $headlinesSQL = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . $userfields . ", t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, " . "{$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND" . $sql . "ORDER BY featured DESC," . $orderBy; if ($display > 0) { $headlinesSQL .= " LIMIT " . $display; } $result = DB_query($headlinesSQL); $numRows = DB_numRows($result); if ($numRows < $cols) { $cols = $numRows; } if ($cols > 6) { $cols = 6; } if ($numRows > 0) { $T = new Template($_CONF['path'] . 'system/autotags/'); $T->set_file('page', $template); $T->set_var('columns', $cols); $T->set_block('page', 'headlines', 'hl'); $newstories = array(); while ($A = DB_fetchArray($result)) { $T->unset_var('readmore_url'); $T->unset_var('lang_readmore'); if ($A['attribution_author'] != '') { $author = $A['attribution_author']; } else { $author = $A['username']; } $title = COM_undoSpecialChars($A['title']); $title = str_replace(' ', ' ', $title); $subtitle = COM_undoSpecialChars($A['subtitle']); if ($A['story_image'] != '') { $story_image = $_CONF['site_url'] . $A['story_image']; } else { $story_image = ''; } $A['introtext'] = STORY_renderImages($A['sid'], $A['introtext']); if (!empty($A['bodytext'])) { $closingP = strrpos($A['introtext'], "</p>"); if ($closingP !== FALSE) { $text = substr($A['introtext'], 0, $closingP); $A['introtext'] = $text; } // adds the read more link $T->set_var('readmore_url', COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid'])); $T->set_var('lang_readmore', $LANG01['continue_reading']); } if ($truncate > 0) { $A['introtext'] = $this->truncateHTML($A['introtext'], $truncate, '...'); } $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $A['tid']; $dt->setTimestamp($A['unixdate']); if ($A['commentcode'] >= 0) { $cmtLinkArray = CMT_getCommentLinkWithCount('article', $A['sid'], $_CONF['site_url'] . '/article.php?story=' . $A['sid'], $A['comments'], 1); $T->set_var(array('lang_comments' => '', 'comments_count' => $cmtLinkArray['comment_count'], 'comments_url' => $cmtLinkArray['url'], 'comments_url_extra' => $cmtLinkArray['url_extra'])); } else { $T->unset_var('lang_comments'); $T->unset_var('comments_count'); $T->unset_var('comments_url'); $T->unset_var('comments_url_extra'); } $T->set_var(array('titlelink' => $titleLink ? TRUE : '', 'meta' => $meta ? TRUE : '', 'lang_by' => $LANG01[95], 'lang_posted_in' => $LANG01['posted_in'], 'story_topic_url' => $topicurl, 'title' => $title, 'subtitle' => $subtitle, 'story_image' => $story_image, 'text' => PLG_replaceTags($A['introtext']), 'date' => $A['date'], 'time' => $dt->format('Y-m-d', true) . 'T' . $dt->format('H:i:s', true), 'topic' => $A['topic'], 'tid' => $A['tid'], 'author' => $author, 'author_id' => $A['uid'], 'sid' => $A['sid'], 'short_date' => $dt->format($_CONF['shortdate'], true), 'date_only' => $dt->format($_CONF['dateonly'], true), 'date' => $dt->format($dt->getUserFormat(), true), 'url' => COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']), 'attribution_url' => $A['attribution_url'], 'attribution_name' => $A['attribution_name'])); $T->parse('hl', 'headlines', true); } $retval = $T->finish($T->parse('output', 'page')); CACHE_create_instance($instance_id, $retval, 0); } return $retval; }
/** * returns field data for the user administration panel list * */ function USER_getListField($fieldname, $fieldvalue, $A, $icon_arr, $token) { global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE; $retval = ''; $dt = new Date('now', $_USER['tzid']); switch ($fieldname) { case 'edit': $attr['title'] = $LANG_ADMIN['edit']; $retval = COM_createLink($icon_arr['edit'], "{$_CONF['site_admin_url']}/user.php?edit=x&uid={$A['uid']}", $attr); break; case 'username': $attr['title'] = $LANG28[108]; $url = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid']; $retval = COM_createLink($icon_arr['user'], $url, $attr); $retval .= ' '; $attr['style'] = 'vertical-align:top;'; $retval .= COM_createLink($fieldvalue, $url, $attr); break; case 'fullname': $photoico = ''; if (!empty($A['photo'])) { $photoico = " <img src=\"{$_CONF['layout_url']}/images/smallcamera." . $_IMAGE_TYPE . '" alt="{$LANG04[77]}"' . '/>'; } else { $photoico = ''; } $retval = COM_truncate($fieldvalue, 24, ' ...', true) . $photoico; break; case 'status': $status = $A['status']; switch ($status) { case 0: $retval = $LANG28[42]; break; case 1: $retval = $LANG28[14]; break; case 2: $retval = $LANG28[106]; break; case 3: $retval = $LANG28[45]; break; case 4: $retval = $LANG28[107]; break; } break; case 'lastlogin': if ($fieldvalue < 1) { // if the user never logged in, show the registration date $dt->setTimestamp(strtotime($A['regdate'])); $regdate = $dt->format($_CONF['shortdate'], true); $retval = "{$LANG28[36]} ({$LANG28[53]}: {$regdate})"; } else { $dt->setTimestamp($fieldvalue); $retval = $dt->format($_CONF['shortdate'], true); } break; case 'lastlogin_short': if ($fieldvalue < 1) { // if the user never logged in, show the registration date $dt->setTimestamp(strtotime($A['regdate'])); $regdate = $dt->format($_CONF['shortdate'], true); $retval = "({$LANG28[36]})"; } else { $dt->setTimestamp($fieldvalue); $retval = $dt->format($_CONF['shortdate'], true); } break; case 'online_days': if ($fieldvalue < 0) { // users that never logged in, would have a negative online days $retval = "N/A"; } else { $retval = $fieldvalue; } break; case 'phantom_date': case 'offline_months': $retval = COM_numberFormat(round($fieldvalue / 2592000)); break; case 'online_hours': $retval = COM_numberFormat(round($fieldvalue / 3600, 3)); break; case 'regdate': $dt->setTimestamp(strtotime($fieldvalue)); $retval = $dt->format($_CONF['shortdate'], true); break; case $_TABLES['users'] . '.uid': $retval = $A['uid']; break; case 'email': $url = 'mailto:' . $fieldvalue; $attr['title'] = $LANG28[111]; $retval = COM_createLink($icon_arr['mail'], $url, $attr); $retval .= ' '; $attr['title'] = $LANG28[99]; $url = $_CONF['site_admin_url'] . '/mail.php?uid=' . $A['uid']; $attr['style'] = 'vertical-align:top;'; $retval .= COM_createLink($fieldvalue, $url, $attr); break; case 'delete': $retval = ''; $attr['title'] = $LANG_ADMIN['delete']; $attr['onclick'] = 'return doubleconfirm(\'' . $LANG28[104] . '\',\'' . $LANG28[109] . '\');'; $retval .= COM_createLink($icon_arr['delete'], $_CONF['site_admin_url'] . '/user.php' . '?delete=x&uid=' . $A['uid'] . '&' . CSRF_TOKEN . '=' . $token, $attr); break; default: $retval = $fieldvalue; break; } if (isset($A['status']) && $A['status'] == USER_ACCOUNT_DISABLED) { if ($fieldname != 'edit' && $fieldname != 'username') { $retval = sprintf('<span class="strike" title="%s">%s</span>', $LANG28[42], $retval); } } return $retval; }
function _ff_getListField_forum($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE; global $_FF_CONF, $_SYSTEM, $LANG_GF02; if (!isset($A['status'])) { $A['status'] = 0; } USES_lib_html2text(); $retval = ''; $dt = new Date('now', $_USER['tzid']); switch ($fieldname) { case 'date': case 'lastupdated': $dt->setTimestamp($fieldvalue); $retval = $dt->format($_FF_CONF['default_Datetime_format'], true); break; case 'subject': $testText = FF_formatTextBlock($A['comment'], 'text', 'text', $A['status']); $testText = strip_tags($testText); $html2txt = new html2text($testText, false); $testText = trim($html2txt->get_text()); $lastpostinfogll = @htmlspecialchars(preg_replace('#\\r?\\n#', '<br>', strip_tags(substr($testText, 0, $_FF_CONF['contentinfo_numchars']) . '...')), ENT_QUOTES, COM_getEncodingt()); $retval = '<a class="' . COM_getTooltipStyle() . '" style="text-decoration:none;" href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . ($A['pid'] == 0 ? $A['id'] : $A['pid']) . '&topic=' . $A['id'] . '#' . $A['id'] . '" title="' . $A['subject'] . '::' . $lastpostinfogll . '" rel="nofollow">' . $fieldvalue . '</a>'; break; case 'bookmark': $bm_icon_on = '<img src="' . _ff_getImage('star_on_sm') . '" title="' . $LANG_GF02['msg204'] . '" alt=""/>'; $retval = '<span id="forumbookmark' . $A['topic_id'] . '"><a href="#" onclick="ajax_toggleForumBookmark(' . $A['topic_id'] . ');return false;">' . $bm_icon_on . '</a></span>'; break; case 'replies': case 'views': if ($fieldvalue != '') { $retval = $fieldvalue; } else { $retval = '0'; } break; default: $retval = $fieldvalue; break; } return $retval; }
function _displayVersionData() { global $_CONF, $_USER, $LANG_UPGRADE, $LANG01, $LANG_FILECHECK, $LANG_ADMIN, $_PLUGIN_INFO; $retval = ''; $upToDate = 0; $classCounter = 0; $pluginInfo = ''; list($upToDate, $pluginsUpToDate, $pluginData) = _checkVersion(); $T = new Template($_CONF['path_layout'] . 'admin'); $T->set_file('page', 'vercheck.thtml'); $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/vercheck.php', 'text' => $LANG_UPGRADE['recheck']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home'])); $retval .= COM_startBlock($LANG_UPGRADE['title'], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= ADMIN_createMenu($menu_arr, $LANG_UPGRADE['desc'], $_CONF['layout_url'] . '/images/icons/versioncheck.png'); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); switch ($upToDate) { case 0: $alertIcon = $_CONF['layout_url'] . '/images/alert.png'; $statusMsg = $LANG_UPGRADE['upgrade_title']; $statusText = sprintf($LANG_UPGRADE['upgrade'], $pluginData['glfusioncms']['installed_version'], $pluginData['glfusioncms']['latest_version']); break; case 1: $alertIcon = $_CONF['layout_url'] . '/images/check.png'; $statusMsg = $LANG_UPGRADE['uptodate_title']; $statusText = $LANG_UPGRADE['uptodate']; break; case 2: $alertIcon = $_CONF['layout_url'] . '/images/alert.png'; $statusMsg = $LANG_UPGRADE['unknown_title']; $statusText = sprintf($LANG_UPGRADE['unknown'], $pluginData['glfusioncms']['installed_version']); break; default: $alertIcon = $_CONF['layout_url'] . '/images/alert.png'; $statusMsg = $LANG_UPGRADE['error_title']; $statusText = $LANG_UPGRADE['error']; break; } $T->set_var(array('alerticon' => $alertIcon, 'statusmsg' => $statusMsg, 'statustext' => $statusText)); if ($pluginsUpToDate != -1) { $pluginInfo .= '<div style="margin-top:10px;"><h3>' . $LANG_UPGRADE['plugin_title'] . '</h3>'; $dt = new Date('now', $_USER['tzid']); $data_arr = array(); $text_arr = array(); $header_arr = array(array('text' => $LANG_UPGRADE['plugin'], 'field' => 'display_name'), array('text' => $LANG_UPGRADE['installed_version'], 'field' => 'installed_version'), array('text' => $LANG_UPGRADE['latest_version'], 'field' => 'latest_version'), array('text' => $LANG_UPGRADE['notes'], 'field' => 'notes')); asort($pluginData); foreach ($pluginData as $plugin) { if ($plugin['plugin'] == 'glfusioncms') { continue; } $dt->setTimestamp($plugin['release_date']); if ($plugin['latest_version'] == 0) { $upToDate = -1; } else { $upToDate = _upToDate($plugin['latest_version'], $plugin['installed_version']); } switch ($upToDate) { case 0: $notes = sprintf($LANG_UPGRADE['was_released'], $plugin['latest_version'], $dt->format("M d, Y", true)); $class = "notok"; if (strlen($plugin['url']) > 0) { $latest_version = '<a href="' . $plugin['url'] . '" target="_blank">' . $plugin['latest_version'] . '</a>'; } else { $latest_version = $plugin['latest_version']; } break; case 1: $notes = $LANG_UPGRADE['plugin_uptodate']; $class = "yes"; $latest_version = $plugin['latest_version']; break; case 2: $notes = $LANG_UPGRADE['plugin_newer']; $class = "yes"; $latest_version = $plugin['latest_version']; break; default: $notes = $LANG_UPGRADE['no_data']; $class = "ok"; $latest_version = '???'; break; } $data_arr[] = array('display_name' => $plugin['display_name'], 'installed_version' => $plugin['installed_version'], 'latest_version' => '<span class="' . $class . '">' . $latest_version . '</span>', 'url' => $plugin['url'], 'notes' => $notes, 'release_date' => $plugin['release_date'], 'update_available' => $upToDate); } $pluginInfo .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr); $pluginInfo .= '</div>'; } $T->parse('output', 'page'); $retval .= $T->finish($T->get_var('output')); $retval .= $pluginInfo; return $retval; }
} $displaypageslink .= ' '; } } // Check if user is an anonymous poster if ($record['uid'] > 1) { $showuserlink = '<span class="replypagination">'; $showuserlink .= '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $record['uid'] . '">' . $record['name']; $showuserlink .= '</a></span>'; } else { $showuserlink = $record['name']; } if ($record['last_reply_rec'] > 0) { $lastreply['date'] = $record['lastupdated']; $lastreply['name'] = $record['lpname']; $dt->setTimestamp($lastreply['date']); $lastdate1 = $dt->format('m/d/Y', true); if ($dt->isToday()) { $lasttime = $dt->format('H:i a', true); $lastdate = $LANG_GF01['TODAY'] . $lasttime; } elseif ($_FF_CONF['allow_user_dateformat']) { $lastdate = $dt->format($dt->getUserFormat(), true); } else { $lastdate = $dt->format('M/d/y H:i a', true); } } else { $dt->setTimestamp($record['lastupdated']); $lastdate = $dt->format('M/d/y H:i a', true); $lastreply = $record; } $dt->setTimestamp($record['date']);
function getTemplateArrayCalendar($o_minDay, $s_date, $period) { // today $today = new Date(getDateFromTimestamp(time())); $tsToday = $today->getTimestamp(); // date asked for statistics $dateAsked = new Date($s_date); // used for going througt the month $date = new Date($s_date); $month = $date->getMonth(); $year = $date->getYear(); $prefixDay = $year . "-" . $month . "-"; $date->setDate($prefixDay . '01'); $week = $date->getWeek(); $day = 1; $ts = $date->getTimestamp(); while ($date->getMonth() == $month) { // day exists in stats, isn't it too old or in the future ? if ($date->getTimestamp() >= $o_minDay->getTimestamp() && $date->getTimestamp() <= $tsToday) { $exists = 1; } else { $exists = 0; } // day selected for stats view ? if ($period == DB_ARCHIVES_PERIOD_DAY && $date->getDay() == $dateAsked->getDay() || $period == DB_ARCHIVES_PERIOD_WEEK && $date->getWeek() == $dateAsked->getWeek() || $period == DB_ARCHIVES_PERIOD_MONTH || $period == DB_ARCHIVES_PERIOD_YEAR) { $selected = 1; } else { $selected = 0; } $weekNo = $date->getWeek() - $week; if (defined('MONDAY_FIRST') && MONDAY_FIRST == 'no' && date("w", $ts) == 0) { $weekNo += 1; } $dayOfWeek = (int) (!defined('MONDAY_FIRST') || MONDAY_FIRST == 'yes' ? date("w", $ts) == 0 ? 6 : date("w", $ts) - 1 : date("w", $ts)); $return[$weekNo][$dayOfWeek] = array('day' => substr($date->getDay(), 0, 1) === '0' ? substr($date->getDay(), 1, 2) : $date->getDay(), 'date' => $date->get(), 'exists' => $exists, 'selected' => $selected); $date->addDays(1); //these 2 lines useless? to check $ts = $date->getTimeStamp(); $date->setTimestamp($ts); } foreach ($return as $key => $r) { $row =& $return[$key]; for ($i = 0; $i < 7; $i++) { if (!isset($row[$i])) { $row[$i] = "-"; } } ksort($row); } return $return; }
$p->set_var('file_size', PrettySize($size)); } else { $p->set_var('file_size', 'Remote'); } } $p->set_var('homepage_url', $homepage); $p->set_var('LANG_HOMEPAGE', _MD_HOMEPAGE); $p->set_var('homepage', $homepage); if ($comments) { USES_lib_comments(); $commentCount = DB_count($_TABLES['comments'], 'sid', "fileid_{$lid}"); $recentPostMessage = _MD_COMMENTSWANTED; if ($commentCount > 0) { $result4 = DB_query("SELECT cid, UNIX_TIMESTAMP(date) AS day,username FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = 'fileid_{$lid}' ORDER BY date desc LIMIT 1"); $C = DB_fetchArray($result4); $dt->setTimestamp($C['day']); $recentPostMessage = $LANG01[27] . ': ' . $dt->format($_CONF['daytime'], true) . ' ' . $LANG01[104] . ' ' . $C['username']; } else { $commentCount = 0; } $comment_link = CMT_getCommentLinkWithCount('filemgmt', $lid, $_CONF['site_url'] . '/filemgmt/index.php?id=' . $lid, $commentCount, 1); $p->set_var('comment_link', $comment_link['link_with_count']); $p->set_var('show_comments', 'true'); } else { $p->set_var('show_comments', 'none'); $p->unset_var('show_comments'); } $p->set_var('LANG_DOWNLOAD', _MD_DOWNLOAD); $p->set_var('LANG_FILELINK', _MD_FILELINK); $p->set_var('LANG_RATETHISFILE', _MD_RATETHISFILE); $p->set_var('LANG_REPORTBROKEN', _MD_REPORTBROKEN);
/** * Creates older stuff block * * Creates the olderstuff block for display. * Actually updates the olderstuff record in the blocks table. * @return void */ function COM_olderStuff() { global $_TABLES, $_CONF; $sql = "SELECT sid,tid,title,comments,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE (perm_anon = 2) AND (frontpage = 1) AND (date <= NOW()) AND (draft_flag = 0)" . COM_getTopicSQL('AND', 1) . " ORDER BY featured DESC, date DESC LIMIT {$_CONF['limitnews']}, {$_CONF['limitnews']}"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $dateonly = $_CONF['dateonly']; if (empty($dateonly)) { $dateonly = 'd-M'; // fallback: day - abbrev. month name } $day = 'noday'; $string = ''; $dt = new Date(); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); $dt->setTimestamp($A['day']); $daycheck = $dt->format("z", true); if ($day != $daycheck) { if ($day != 'noday') { $daylist = COM_makeList($oldnews, 'list-older-stories'); $daylist = str_replace(array("\r", "\n"), '', $daylist); $string .= $daylist; // . '<br/>'; } $day2 = $dt->format($_CONF['dateonly'], true); $string .= '<h3>' . $dt->format('l', true) . ' <small>' . $day2 . '</small></h3>' . LB; $oldnews = array(); $day = $daycheck; } $oldnews_url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']); $oldnews[] = COM_createLink(COM_truncate($A['title'], $_CONF['title_trim_length'], '...'), $oldnews_url, array('title' => htmlspecialchars($A['title'], ENT_COMPAT, COM_getEncodingt()))) . ' (' . COM_numberFormat($A['comments']) . ')'; } if (!empty($oldnews)) { $daylist = COM_makeList($oldnews, 'list-older-stories'); $daylist = str_replace(array("\r", "\n"), '', $daylist); $string .= $daylist; $string = DB_escapeString($string); DB_query("UPDATE {$_TABLES['blocks']} SET content = '{$string}' WHERE name = 'older_stories'"); } } }
function plugin_subscription_email_format_comment($category, $track_id, $post_id, $uid) { global $_CONF, $_USER, $_TABLES, $LANG01, $LANG03, $LANG04; $dt = new Date('now', $_USER['tzid']); $permalink = 'Not defined'; $filter = sanitizer::getInstance(); $AllowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_comment']); $filter->setAllowedelements($AllowedElements); $filter->setNamespace('glfusion', 'comment'); $post_id = COM_applyFilter($post_id, true); $result = DB_query("SELECT * FROM {$_TABLES['comments']} WHERE cid={$post_id}"); if (DB_numRows($result) > 0) { $A = DB_fetchArray($result); $itemInfo = PLG_getItemInfo($A['type'], $track_id, 'url,title'); $permalink = $itemInfo['url']; if (empty($permalink)) { $permalink = $_CONF['site_url']; } if ($A['uid'] > 1) { $name = COM_getDisplayName($A['uid']); } else { $name = $filter->sanitizeUsername($A['name']); $name = $filter->censor($name); } $name = @htmlspecialchars($name, ENT_QUOTES, COM_getEncodingt()); $A['title'] = COM_checkWords($A['title']); $A['title'] = @htmlspecialchars($A['title'], ENT_QUOTES, COM_getEncodingt()); //and finally: format the actual text of the comment, but check only the text, not sig or edit $text = str_replace('<!-- COMMENTSIG --><div class="comment-sig">', '', $A['comment']); $text = str_replace('</div><!-- /COMMENTSIG -->', '', $text); $text = str_replace('<div class="comment-edit">', '', $text); $text = str_replace('</div><!-- /COMMENTEDIT -->', '', $text); $A['comment'] = $text; if (preg_match('/<.*>/', $text) == 0) { $A['comment'] = nl2br($A['comment']); } $A['comment'] = $filter->_replaceTags($A['comment']); $notifymsg = sprintf($LANG03[46], '<a href="' . $_CONF['site_url'] . '/comment.php?mode=unsubscribe&sid=' . htmlentities($track_id) . '&type=' . $A['type'] . '" rel="nofollow">' . $LANG01['unsubscribe'] . '</a>'); $dt->setTimestamp(strtotime($A['date'])); $date = $dt->format('F d Y @ h:i a'); $T = new Template($_CONF['path_layout'] . 'comment'); $T->set_file(array('htmlemail' => 'notifymessage_html.thtml', 'textemail' => 'notifymessage_text.thtml')); $T->set_var(array('post_subject' => $A['title'], 'post_date' => $date, 'post_name' => $name, 'post_comment' => $A['comment'], 'notify_msg' => $notifymsg, 'site_name' => $_CONF['site_name'], 'online_version' => sprintf($LANG01['view_online'], $permalink), 'permalink' => $permalink)); $T->parse('htmloutput', 'htmlemail'); $message = $T->finish($T->get_var('htmloutput')); $T->parse('textoutput', 'textemail'); $msgText = $T->finish($T->get_var('textoutput')); $html2txt = new html2text($msgText, false); $messageText = $html2txt->get_text(); return array($message, $messageText, array()); } return false; }
/** * Display a yearly calendar. * Dates that have events scheduled are highlighted. * * @param integer $year Year to display, default is current year * @param integer $month Starting month * @param integer $day Starting day * @param integer $cat Category to show * @param integer $cal Calendar to show * @return string HTML for calendar page */ function EVLIST_yearview($year = 0, $month = 0, $day = 0, $cat = 0, $cal = 0, $opt = '') { global $_CONF, $_EV_CONF, $LANG_MONTH, $_SYSTEM; EVLIST_setViewSession('year', $year, $month, $day); $retval = ''; // Default to the current year if ($year == 0) { $year = date('Y'); } if ($month == 0) { $month = date('m'); } if ($day == 0) { $day = date('d'); } $cat = (int) $cat; $cal = (int) $cal; // Get all the dates in the year $starting_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, $year)); $ending_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, $year + 1)); $calendarView = Date_Calc::getCalendarYear($year, '%Y-%m-%d'); $daynames = EVLIST_getDayNames(1); $events = EVLIST_getEvents($starting_date, $ending_date, array('cat' => $cat, 'cal' => $cal)); // A date object to handle formatting $dt = new Date('now', $_CONF['timezone']); $T = new Template(EVLIST_PI_PATH . '/templates/yearview'); $tpl = 'yearview'; if ($opt == 'print') { $tpl .= '_print'; } elseif ($_EV_CONF['cal_tmpl'] == 'json') { $tpl .= '_json'; } $T->set_file(array('yearview' => $tpl . '.thtml')); $count = 0; $T->set_block('yearview', 'month', 'mBlock'); foreach ($calendarView as $monthnum => $monthdata) { $monthnum_str = sprintf("%02d", $monthnum + 1); $count++; if (($count - 1) % 4 == 0) { $T->set_var('st_row', 'true'); } else { $T->clear_var('st_row'); } $M = new Template($_CONF['path'] . 'plugins/evlist/templates/yearview'); $M->set_file(array('smallmonth' => 'smallmonth.thtml')); $M->set_var('thisyear', $year); $M->set_var('month', $monthnum + 1); $M->set_var('monthname', $LANG_MONTH[$monthnum + 1]); $M->set_block('smallmonth', 'daynames', 'nBlock'); for ($i = 0; $i < 7; $i++) { $M->set_var('dayname', $daynames[$i]); $M->parse('nBlock', 'daynames', true); } $M->set_block('smallmonth', 'week', 'wBlock'); foreach ($monthdata as $weeknum => $weekdata) { list($weekYear, $weekMonth, $weekDay) = explode('-', $weekdata[0]); $M->set_var(array('weekyear' => $weekYear, 'weekmonth' => $weekMonth, 'weekday' => $weekDay, 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal)); $M->set_block('smallmonth', 'day', 'dBlock'); foreach ($weekdata as $daynum => $daydata) { list($y, $m, $d) = explode('-', $daydata); $M->clear_var('no_day_link'); if ($daydata == $_EV_CONF['_today']) { $dayclass = 'today'; } elseif ($m == $monthnum_str) { $dayclass = 'on'; } else { $M->set_var('no_day_link', 'true'); $dayclass = 'off'; } if (isset($events[$daydata])) { // Create the mootip hover text $popup = ''; $daylinkclass = $dayclass == 'off' ? 'nolink-events' : 'day-events'; foreach ($events[$daydata] as $event) { // Separate events by a newline if more than one if (!empty($popup)) { if ($_SYSTEM['framework'] == 'uikit') { // HTML break for UIkit tooltip $popup .= '<br />'; } $popup .= LB; } // Don't show a time for all-day events if ($event['allday'] == 0) { $dt->setTimestamp(strtotime($event['rp_date_start'] . ' ' . $event['rp_time_start1'])); // Time is a localized string, not a timestamp, so // don't adjust for the timezone $popup .= $dt->format($_CONF['timeonly'], false) . ': '; } $popup .= htmlentities($event['title']); } $M->set_var('popup', $popup); } else { $daylinkclass = 'day-noevents'; $M->clear_var('popup'); } $M->set_var(array('daylinkclass' => $daylinkclass, 'dayclass' => $dayclass, 'day' => substr($daydata, 8, 2), 'pi_url' => EVLIST_URL, 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal)); $M->parse('dBlock', 'day', true); } $M->parse('wBlock', 'week', true); $M->clear_var('dBlock'); } $M->parse('onemonth', 'smallmonth'); $T->set_var('month', $M->finish($M->get_var('onemonth'))); if ($count % 4 == 0) { $T->set_var('end_row', 'true'); } else { $T->clear_var('end_row'); } $T->parse('mBlock', 'month', true); } $T->set_var(array('pi_url' => EVLIST_URL, 'thisyear' => $year, 'prevyear' => $year - 1, 'nextyear' => $year + 1, 'cal_header' => EVLIST_calHeader($year, $month, $day, 'year', $cat, $cal), 'cal_footer' => EVLIST_calFooter($calendars_used), 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal)); $T->parse('output', 'yearview'); return $T->finish($T->get_var('output')); }
/** * Export tickets to a CSV file for a single occurrence * * @param integer $rp_id Repeat ID * @return string CSV file containing all tickets */ public static function ExportTickets($rp_id = '') { global $_CONF, $LANG_EVLIST; $retval = ''; // get the tickets, paid and unpaid. Need event id and uid. $tickets = self::GetTickets($ev_id, $rp_id, $uid); USES_evlist_class_repeat(); USES_evlist_class_tickettype(); $Rp = new evRepeat($rp_id); $header = array($LANG_EVLIST['ticket_num'], $LANG_EVLIST['rsvp_date'], $LANG_EVLIST['name'], $LANG_EVLIST['fee'], $LANG_EVLIST['paid'], $LANG_EVLIST['date_used'], $LANG_EVLIST['waitlisted']); $retval .= '"' . implode('","', $header) . '"' . "\n"; //$tic_types = array(); $counter = 0; $dt_tick = new Date('now', $_CONF['timezone']); $dt_used = new Date('now', $_CONF['timezone']); foreach ($tickets as $tic_id => $ticket) { $counter++; $dt_tick->setTimestamp($ticket->dt); $dt_used->setTimestamp($ticket->used); $values = array($tic_id, $dt_tick->toMySQL(), str_replace('"', "'", COM_getDisplayName($ticket->uid)), $ticket->fee, $ticket->paid, $ticket->used > $ticket->dt ? $dt_used->toMySQL() : '', $counter > $Rp->Event->options['max_rsvp'] ? 'Yes' : 'No'); $retval .= '"' . implode('","', $values) . '"' . "\n"; } return $retval; }
$sql .= "WHERE (a.uid = " . (int) $showuser . ") AND b.grp_id IN ({$grouplist}) "; $sql .= "ORDER BY a.date DESC LIMIT {$_FF_CONF['show_last_post_count']}"; $result = DB_query($sql); $nrows = DB_numRows($result); $displayrecs = 0; for ($i = 1; $i <= $nrows; $i++) { $P = DB_fetchArray($result); $userlogtime = DB_getItem($_TABLES['ff_log'], "time", "uid=" . (int) $_USER['uid'] . " AND topic=" . (int) $P['id']); if ($userlogtime == NULL or $P['lastupdated'] > $userlogtime) { if ($_FF_CONF['use_censor']) { $P['subject'] = COM_checkWords($P['subject']); $P['comment'] = COM_checkWords($P['comment']); } $topic_id = $P['id']; $displayrecs++; $dt->setTimestamp($P['date']); $firstdate = $dt->format($_FF_CONF['default_Datetime_format'], true); $dt->setTimestamp($P['lastupdated']); $lastdate = $dt->format($_FF_CONF['default_Datetime_format'], true); if ($P['uid'] > 1) { $topicinfo = "{$LANG_GF01['STARTEDBY']} " . COM_getDisplayName($P['uid']) . ', '; } else { $topicinfo = "{$LANG_GF01['STARTEDBY']} {$P['name']},"; } $topicinfo .= "{$firstdate}<br/>{$LANG_GF01['VIEWS']}:{$P['views']}, {$LANG_GF01['REPLIES']}:{$P['replies']}<br/>"; if (empty($P['last_reply_rec']) || $P['last_reply_rec'] < 1) { $lastid = $P['id']; $testText = FF_formatTextBlock($P['comment'], 'text', 'text', $P['status']); $testText = strip_tags($testText); $html2txt = new html2text($testText, false); $testText = trim($html2txt->get_text());
/** * View the current order summary * * @param boolean $final Indicates that this order is final. * @param string $tpl "print" for a printable template * @return string HTML for order view */ public function View($final = false, $tpl = '') { global $_PP_CONF, $_USER, $LANG_PP, $LANG_ADMIN, $_TABLES, $_CONF, $_SYSTEM; USES_paypal_class_product(); // canView should be handled by the caller if (!$this->canView()) { return ''; } $T = new Template(PAYPAL_PI_PATH . '/templates'); if ($tpl == 'print') { $tpltype = '.print'; } else { $tpltype = $_SYSTEM['framework'] == 'uikit' ? '.uikit' : ''; } $T->set_file('order', "order{$tpltype}.thtml"); $isAdmin = SEC_hasRights('paypal.admin') ? true : false; foreach ($this->_addr_fields as $fldname) { $T->set_var($fldname, $this->{$fldname}); } $T->set_block('order', 'ItemRow', 'iRow'); // Get the workflows so we sho the relevant info. if (!isset($_PP_CONF['workflows']) || !is_array($_PP_CONF['workflows'])) { USES_paypal_class_workflow(); ppWorkflow::Load(); } foreach ($_PP_CONF['workflows'] as $key => $value) { $T->set_var('have_' . $value, 'true'); } $this->no_shipping = 1; // no shipping unless physical item ordered $subtotal = 0; foreach ($this->items as $key => $item) { $P = new Product($item['product_id']); $item_options = ''; $opt = json_decode($item['options_text'], true); if ($opt) { foreach ($opt as $opt_str) { $item_options .= " -- {$opt_str}<br />\n"; } } $item_total = $item['price'] * $item['quantity']; $subtotal += $item_total; $T->set_var(array('item_id' => htmlspecialchars($item['product_id']), 'item_descrip' => htmlspecialchars($item['description']), 'item_price' => COM_numberFormat($item['price'], 2), 'item_quantity' => (int) $item['quantity'], 'item_total' => COM_numberFormat($item_total, 2), 'item_options' => $item_options, 'is_admin' => $isAdmin ? 'true' : '', 'is_file' => $P->file != '' ? 'true' : '')); $T->parse('iRow', 'ItemRow', true); if ($item['data']['prod_type'] == PP_PROD_PHYSICAL) { $this->no_shipping = 0; } } $dt = new Date($this->order_date, $_CONF['timezone']); $total = $subtotal + $this->shipping + $this->handling + $this->tax; $T->set_var(array('pi_url' => PAYPAL_URL, 'is_admin' => $isAdmin ? 'true' : '', 'pi_admin_url' => PAYPAL_ADMIN_URL, 'total' => sprintf('%6.2f', $total), 'not_final' => $final ? '' : 'true', 'order_date' => $dt->format($_PP_CONF['datetime_fmt'], true), 'order_date_tip' => $dt->format($_PP_CONF['datetime_fmt'], false), 'order_number' => $this->order_id, 'shipping' => COM_numberFormat($this->shipping, 2), 'handling' => COM_numberFormat($this->handling, 2), 'tax' => COM_numberFormat($this->tax, 2), 'subtotal' => COM_numberFormat($subtotal, 2), 'have_billto' => 'true', 'have_shipto' => 'true', 'order_instr' => htmlspecialchars($this->instructions), 'shop_name' => $_PP_CONF['shop_name'], 'shop_addr' => $_PP_CONF['shop_addr'])); if ($isAdmin) { USES_paypal_class_orderstatus(); $T->set_var(array('purch_name' => COM_getDisplayName($this->uid), 'purch_uid' => $this->uid, 'stat_update' => ppOrderStatus::Selection($this->order_id, 1, $this->status), 'status' => $this->status)); $sql = "SELECT * FROM {$_TABLES['paypal.order_log']} WHERE order_id = '" . DB_escapeString($this->order_id) . "'"; $res = DB_query($sql); $T->set_block('order', 'LogMessages', 'Log'); while ($L = DB_fetchArray($res, false)) { $dt->setTimestamp(strtotime($L['ts'])); $T->set_var(array('log_username' => $L['username'], 'log_msg' => $L['message'], 'log_ts' => $dt->format($_PP_CONF['datetime_fmt'], true), 'log_ts_tip' => $dt->format($_PP_CONF['datetime_fmt'], false))); $T->parse('Log', 'LogMessages', true); } } $status = $this->status; if ($this->pmt_method != '') { //if ($status & PP_STATUS_PAID) { if (USES_paypal_gateway($this->pmt_method)) { $gw = new $this->pmt_method(); $pmt_method = $gw->Description(); } else { $pmt_method = $this->pmt_method; } $T->set_var(array('pmt_method' => $pmt_method, 'pmt_txn_id' => $this->pmt_txn_id)); } $T->parse('output', 'order'); $form = $T->finish($T->get_var('output')); return $form; }
/** * Get an individual field for the history screen. * * @param string $fieldname Name of field (from the array, not the db) * @param mixed $fieldvalue Value of the field * @param array $A Array of all fields from the database * @param array $icon_arr System icon array (not used) * @param object $EntryList This entry list object * @return string HTML for field display in the table */ function PAYPAL_getPurchaseHistoryField($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_PP_CONF, $LANG_PP, $_USER; static $dt = NULL; if ($dt === NULL) { $dt = new Date('now', $_USER['tzid']); } $retval = ''; switch ($fieldname) { case 'order_date': $dt->setTimestamp(strtotime($fieldvalue)); $retval = '<span title="' . $dt->format($_PP_CONF['datetime_fmt'], false) . '">' . $dt->format($_PP_CONF['datetime_fmt'], true) . '</span>'; break; case 'name': list($item_id, $item_opts) = PAYPAL_explode_opts($A['product_id']); if (is_numeric($item_id)) { // One of our catalog items, so link to it $retval = COM_createLink($fieldvalue, PAYPAL_URL . '/index.php?detail=x&id=' . $item_id); } else { // Probably came from a plugin, just show the product name $retval = htmlspecialchars($A['product_id'], ENT_QUOTES, COM_getEncodingt()); } break; case 'username': if ($A['isAdmin']) { $retval = COM_createLink($fieldvalue, PAYPAL_ADMIN_URL . '/index.php?orderhist=x&uid=' . $A['uid']); } else { $retval = COM_createLink($fieldvalue, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid']); } break; case 'quantity': $retval = '<div class="alignright">' . $fieldvalue . "</div>"; break; case 'txn_id': $base_url = $A['isAdmin'] ? PAYPAL_ADMIN_URL : PAYPAL_URL; // Admins get a link to the transaction log, regular users just // get the ID to check against their Paypal account. if ($A['isAdmin'] == 1) { $retval = COM_createLink($fieldvalue, $base_url . '/index.php?ipnlog=x&op=single&txn_id=' . $fieldvalue); } else { $retval = $fieldvalue; } break; case 'prod_type': // Return the plain-language product type description //$retval = $LANG_PP['prod_types'][$fieldvalue]; $retval = $LANG_PP['prod_types'][$A['prod_type']]; //if ($fieldvalue == PP_PROD_DOWNLOAD && $A['exptime'] > time() ) { if ($A['file'] != '' && $A['exptime'] > time()) { $retval = COM_createLink($retval, PAYPAL_URL . "/download.php?id={$A['product_id']}"); } break; case 'short_description': // If this is a plugin item, there should be a description recorded // in the purchase file. If not, just take it from the product // table. if (!empty($A['description'])) { $retval = $A['description']; } else { $retval = $fieldvalue; } break; case 'status': if ($A['isAdmin'] && is_array($LANG_PP['orderstatus'])) { $retval = ppOrderStatus::Selection($A['order_id'], 0, $fieldvalue); } elseif (isset($LANG_PP['orderstatus'][$fieldvalue])) { $retval = $LANG_PP['orderstatus'][$fieldvalue]; } else { $retval = 'Unknown'; } break; case 'order_id': $base_url = $A['isAdmin'] ? PAYPAL_ADMIN_URL : PAYPAL_URL; $retval = COM_createLink($fieldvalue, $base_url . '/index.php?order=' . $fieldvalue, array('data-uk-tooltip' => '', 'title' => 'View', 'class' => 'gl_mootip')); $retval .= ' <a href="' . PAYPAL_URL . '/index.php?printorder=' . $fieldvalue . '" target="_blank" class="uk-icon-mini uk-icon-print gl_mootip" title="Print" data-uk-tooltip>'; if (!$_PP_CONF['_is_uikit']) { $retval .= '(print)'; } $retval .= '</a>'; break; default: $retval = htmlspecialchars($fieldvalue, ENT_QUOTES, COM_getEncodingt()); break; } return $retval; }
function PAGE_getListField($fieldname, $fieldvalue, $A, $icon_arr, $token) { global $_CONF, $_USER, $LANG_ADMIN, $LANG_STATIC, $LANG_ACCESS, $_TABLES; $retval = ''; $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); $enabled = $A['sp_status'] == 1 ? true : false; $dt = new Date('now', $_USER['tzid']); switch ($fieldname) { case 'edit': if ($access == 3) { $attr['title'] = $LANG_ADMIN['edit']; $retval = COM_createLink($icon_arr['edit'], $_CONF['site_admin_url'] . '/plugins/staticpages/index.php' . '?edit=x&sp_id=' . $A['sp_id'], $attr); } else { $retval = $icon_arr['blank']; } break; case 'copy': if ($access >= 2) { $attr['title'] = $LANG_ADMIN['copy']; $retval = COM_createLink($icon_arr['copy'], $_CONF['site_admin_url'] . '/plugins/staticpages/index.php' . '?clone=x&sp_id=' . $A['sp_id'], $attr); } else { $retval = $icon_arr['blank']; } break; case "sp_title": $sp_title = $A['sp_title']; if ($enabled) { $url = COM_buildUrl($_CONF['site_url'] . '/page.php?page=' . $A['sp_id']); $retval = COM_createLink($sp_title, $url, array('title' => $LANG_STATIC['title_display'])); } else { $retval = '<span class="disabledfield">' . $sp_title . '</span>'; } break; case 'access': if ($access == 3) { $privs = $LANG_ACCESS['edit']; } else { $privs = $LANG_ACCESS['readonly']; } $retval = $enabled ? $privs : '<span class="disabledfield">' . $privs . '</span>'; break; case "sp_uid": $owner = COM_getDisplayName($A['sp_uid']); $retval = $enabled ? $owner : '<span class="disabledfield">' . $owner . '</span>'; break; case "sp_centerblock": if ($A['sp_centerblock']) { switch ($A['sp_where']) { case '1': $where = $LANG_STATIC['centerblock_top']; break; case '2': $where = $LANG_STATIC['centerblock_feat']; break; case '3': $where = $LANG_STATIC['centerblock_bottom']; break; default: $where = $LANG_STATIC['centerblock_entire']; break; } } else { $where = $LANG_STATIC['centerblock_no']; } $retval = $enabled ? $where : '<span class="disabledfield">' . $where . '</span>'; break; case "unixdate": $dt->setTimestamp($A['unixdate']); $datetime = $dt->format($_CONF['daytime'], true); $retval = $enabled ? $datetime : '<span class="disabledfield">' . $datetime . '</span>'; break; case 'delete': if ($access == 3) { $attr['title'] = $LANG_ADMIN['delete']; $attr['onclick'] = "return confirm('" . $LANG_STATIC['delete_confirm'] . "');"; $retval = COM_createLink($icon_arr['delete'], $_CONF['site_admin_url'] . '/plugins/staticpages/index.php' . '?delete=x&sp_id=' . $A['sp_id'] . '&' . CSRF_TOKEN . '=' . $token, $attr); } else { $retval = $icon_arr['blank']; } break; case 'sp_status': if ($access == 3) { if ($enabled) { $switch = ' checked="checked"'; $title = 'title="' . $LANG_ADMIN['disable'] . '" '; } else { $title = 'title="' . $LANG_ADMIN['enable'] . '" '; $switch = ''; } $retval = '<input class="sp-enabler" type="checkbox" name="enabledstaticpages[' . $A['sp_id'] . ']" ' . $title . 'onclick="submit()" value="1"' . $switch . '/>'; $retval .= '<input type="hidden" name="sp_idarray[' . $A['sp_id'] . ']" value="1" />'; } else { $retval = $enabled ? $LANG_ACCESS['yes'] : $LANG_ACCESS['No']; } break; default: $retval = $enabled ? $fieldvalue : '<span class="disabledfield">' . $fieldvalue . '</span>'; break; } return $retval; }
function gfm_getoutput($id) { global $_TABLES, $LANG_GF01, $LANG_GF02, $_CONF, $_FF_CONF, $_USER; $dt = new Date('now', $_USER['tzid']); $id = COM_applyFilter($id, true); $result = DB_query("SELECT * FROM {$_TABLES['ff_topic']} WHERE id=" . (int) $id); $A = DB_fetchArray($result); if ($A['pid'] == 0) { $pid = $id; } else { $pid = $A['pid']; } $permalink = $_CONF['site_url'] . '/forum/viewtopic.php?topic=' . $id . '#' . $id; $A['name'] = COM_checkWords($A['name']); $A['name'] = @htmlspecialchars($A['name'], ENT_QUOTES, COM_getEncodingt()); $A['subject'] = COM_checkWords($A['subject']); $A['subject'] = @htmlspecialchars($A["subject"], ENT_QUOTES, COM_getEncodingt()); $A['comment'] = _ff_FormatForEmail($A['comment'], $A['postmode']); $notifymsg = sprintf($LANG_GF02['msg27'], '<a href="' . $_CONF['site_url'] . '/forum/notify.php">' . $_CONF['site_url'] . '/forum/notify.php</a>'); $dt->setTimestamp($A['date']); $date = $dt->format('F d Y @ h:i a'); if ($A['pid'] == '0') { $postid = $A['id']; } else { $postid = $A['pid']; } $T = new Template($_CONF['path'] . 'plugins/forum/templates'); $T->set_file('email', 'notifymessage.thtml'); $T->set_var(array('post_id' => $postid, 'topic_id' => $A['id'], 'post_subject' => $A['subject'], 'post_date' => $date, 'post_name' => $A['name'], 'post_comment' => $A['comment'], 'notify_msg' => $notifymsg, 'site_name' => $_CONF['site_name'], 'online_version' => sprintf($LANG_GF02['view_online'], $permalink), 'permalink' => $permalink)); $T->parse('output', 'email'); $message = $T->finish($T->get_var('output')); $T = new Template($_CONF['path'] . 'plugins/forum/templates'); $T->set_file('email', 'notifymessage_text.thtml'); $T->set_var(array('post_id' => $postid, 'topic_id' => $A['id'], 'post_subject' => $A['subject'], 'post_date' => $date, 'post_name' => $A['name'], 'post_comment' => $A['comment'], 'notify_msg' => $notifymsg, 'site_name' => $_CONF['site_name'], 'online_version' => sprintf($LANG_GF02['view_online'], $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $postid . '&lastpost=true#' . $A['id']))); $T->parse('output', 'email'); $msgText = $T->finish($T->get_var('output')); $html2txt = new html2text($msgText, false); $messageText = $html2txt->get_text(); return array($message, $messageText); }
function _fm_getListField_forum($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_USER, $_TABLES, $LANG_ADMIN, $LANG04, $LANG28, $_IMAGE_TYPE; global $_FF_CONF, $_SYSTEM, $LANG_GF02; $retval = ''; $dt = new Date('now', $_USER['tzid']); switch ($fieldname) { case 'date': $dt->setTimestamp($fieldvalue); $retval = $dt->format('M d, Y', true); break; case 'size': if (!empty($fieldvalue) && $fieldvalue > 0) { $kb = $fieldvalue / 1024; $mb = $kb / 1024; $retval = COM_numberFormat($kb) . ' kb'; } else { $retval = 'Remote'; } break; case 'edit': $attr['title'] = $LANG_ADMIN['edit']; $retval = COM_createLink($icon_arr['edit'], $_CONF['site_admin_url'] . '/plugins/filemgmt/index.php?lid=' . $A['lid'] . '&op=modDownload', $attr); break; default: $retval = $fieldvalue; break; } return $retval; }
/** * Email story to a friend * * @param string $sid id of story to email * @param string $to name of person / friend to email * @param string $toemail friend's email address * @param string $from name of person sending the email * @param string $fromemail sender's email address * @param string $shortmsg short intro text to send with the story * @return string Meta refresh * * Modification History * * Date Author Description * ---- ------ ----------- * 4/17/01 Tony Bibbs Code now allows anonymous users to send email * and it allows user to input a message as well * Thanks to Yngve Wassvik Bergheim for some of * this code * */ function mailstory($sid, $to, $toemail, $from, $fromemail, $shortmsg, $html = 0) { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG08; $dt = new Date('now', $_USER['tzid']); $storyurl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid); if ($_CONF['url_rewrite']) { $retURL = $storyurl . '?msg=85'; } else { $retURL = $storyurl . '&msg=85'; } // check for correct $_CONF permission if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { echo COM_refresh($retURL); exit; } // check if emailing of stories is disabled if ($_CONF['hideemailicon'] == 1) { echo COM_refresh($retURL); exit; } // check mail speedlimit COM_clearSpeedlimit($_CONF['speedlimit'], 'mail'); if (COM_checkSpeedlimit('mail') > 0) { echo COM_refresh($retURL); exit; } $filter = sanitizer::getInstance(); if ($html) { $filter->setPostmode('html'); } else { $filter->setPostmode('text'); } $allowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_default']); $filter->setAllowedElements($allowedElements); $filter->setCensorData(true); $filter->setReplaceTags(true); $filter->setNamespace('glfusion', 'mail_story'); $sql = "SELECT uid,title,introtext,bodytext,commentcode,UNIX_TIMESTAMP(date) AS day,postmode FROM {$_TABLES['stories']} WHERE sid = '" . DB_escapeString($sid) . "'" . COM_getTopicSql('AND') . COM_getPermSql('AND'); $result = DB_query($sql); if (DB_numRows($result) == 0) { return COM_refresh($_CONF['site_url'] . '/index.php'); } $A = DB_fetchArray($result); $mailtext = sprintf($LANG08[23], $from, $fromemail) . LB; if (strlen($shortmsg) > 0) { if ($html) { $shortmsg = $filter->filterHTML($shortmsg); } $mailtext .= LB . sprintf($LANG08[28], $from) . $shortmsg . LB; } // just to make sure this isn't an attempt at spamming users ... $result = PLG_checkforSpam($mailtext, $_CONF['spamx']); if ($result > 0) { COM_updateSpeedlimit('mail'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } $dt->setTimestamp($A['day']); if ($html) { $mailtext .= '<p>------------------------------------------------------------</p>' . '<p>' . COM_undoSpecialChars($A['title']) . '</p>' . '<p>' . $dt->format($_CONF['date'], true) . '</p>'; } else { $mailtext .= '------------------------------------------------------------' . LB . LB . COM_undoSpecialChars($A['title']) . LB . $dt->format($_CONF['date'], true) . LB; } if ($_CONF['contributedbyline'] == 1) { $author = COM_getDisplayName($A['uid']); $mailtext .= $LANG01[1] . ' ' . $author . LB; } if ($html) { $mailtext .= '<p>' . $filter->displayText($A['introtext']) . '<br />' . $filter->displayText($A['bodytext']) . '</p>' . '<p>------------------------------------------------------------</p>'; } else { $mailtext .= $filter->displayText($A['introtext']) . LB . $filter->displayText($A['bodytext']) . LB . LB . '------------------------------------------------------------' . LB; } if ($A['commentcode'] == 0) { // comments allowed $mailtext .= $LANG08[24] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid . '#comments'); } else { // comments not allowed - just add the story's URL $mailtext .= $LANG08[33] . LB . COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid); } $mailto = array(); $mailfrom = array(); $mailto = COM_formatEmailAddress($to, $toemail); $mailfrom = COM_formatEmailAddress($from, $fromemail); $subject = COM_undoSpecialChars(strip_tags('Re: ' . $A['title'])); $rc = COM_mail($mailto, $subject, $mailtext, $mailfrom, $html); COM_updateSpeedlimit('mail'); if ($rc) { if ($_CONF['url_rewrite']) { $retval = COM_refresh($storyurl . '?msg=27'); } else { $retval = COM_refresh($storyurl . '&msg=27'); } } else { // Increment numemails counter for story DB_query("UPDATE {$_TABLES['stories']} SET numemails = numemails + 1 WHERE sid = '" . DB_escapeString($sid) . "'"); if ($_CONF['url_rewrite']) { $retval = COM_refresh($storyurl . '?msg=26'); } else { $retval = COM_refresh($storyurl . '&msg=26'); } } echo COM_refresh($retval); exit; }
/** * Organizes events by hour, and separates all-day events. * * @param array $events Array of all events * @param string $today Current date, YYYY-MM-DD. Optional. * @return array Array of 2 arrays, allday and hourly */ function EVLIST_getDayViewData($events, $today = '') { global $_CONF; // If no date/time passed used current timestamp if (empty($today)) { $today = $_EV_CONF['_today']; } $hourlydata = array(0 => array(), 1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array(), 13 => array(), 14 => array(), 15 => array(), 16 => array(), 17 => array(), 18 => array(), 19 => array(), 20 => array(), 21 => array(), 22 => array(), 23 => array()); $alldaydata = array(); USES_class_date(); // Events are keyed by hour, so read through each hour foreach ($events as $date => $E) { // Now read each event contained in each hour foreach ($E as $id => $A) { // remove serialized data, not needed for display and interferes // with json encoding. unset($A['rec_data']); unset($A['options']); if ($A['allday'] == 1 || $A['rp_date_start'] < $today && $A['rp_date_end'] > $today) { // This is an allday event, or spans days $alldaydata[] = $A; } else { // This is an event with start/end times. For non-recurring // events, see if it actually starts before or after today // and adjust the times accordingly. if ($A['rp_date_start'] < $today) { list($hr, $min, $sec) = explode(':', $A['rp_time_start1']); $hr = '00'; $A['rp_times_start1'] = implode(':', array($hr, $min, $sec)); //} else { // $starthour = date('G', strtotime($A['rp_date_start'] . // ' ' . $A['rp_time_start^1'])); } if ($A['rp_date_end'] > $today) { list($hr, $min, $sec) = explode(':', $A['rp_time_end1']); $hr = '23'; $A['rp_times_end1'] = implode(':', array($hr, $min, $sec)); //} else { // $endhour = date('G', strtotime($A['rp_date_end'] . // ' ' . $A['rp_time_end1'])); } $dtStart = new Date(strtotime($A['rp_date_start'] . ' ' . $A['rp_time_start1'])); $dtEnd = new Date(strtotime($A['rp_date_end'] . ' ' . $A['rp_time_end1'])); //if (date('i', strtotime($A['rp_date_end'] . ' ' . // $A['rp_time_end1'])) == '00') { // $endhour = $endhour - 1; //} // Save the start & end times in separate variables. // This way we can add $A to a different hour if it's a split. //if (!isset($hourlydata[$starthour])) // $hourlydata[$starthour] = array(); // Set localized, formatted start and end time fields $starthour = $dtStart->format('G', false); // array index $time_start = $dtStart->format($_CONF['timeonly'], false); $time_end = $dtEnd->format($_CONF['timeonly'], false); $hourlydata[(int) $starthour][] = array('starthour' => $starthour, 'time_start' => $time_start, 'time_end' => $time_end, 'data' => $A); if ($A['split'] == 1 && $A['rp_time_end2'] > $A['rp_time_start2']) { // This is a split event, second half occurs later today. // Events spanning multiple days can't be split, so we // know that the start and end times are on the same day. //$starthour = date('G', strtotime($A['rp_date_start'] . // ' ' . $A['rp_time_start2'])); $dtStart->setTimestamp(strtotime($event['rp_date_start'] . ' ' . $event['rp_time_start2'])); $starthour = $dtStart->format('G', false); $time_start = $dtStart->format($_CONF['timeonly'], false); $dtEnd->setTimestamp(strtotime($event['rp_date_start'] . ' ' . $event['rp_time_end2'])); $time_end = $dtEnd->format($_CONF['timeonly'], false); $hourlydata[(int) $starthour][] = array('starthour' => $starthour, 'time_start' => $time_start, 'time_end' => $time_end, 'data' => $A); } } } } return array($alldaydata, $hourlydata); }
/** * Email story to a friend * * @param string $sid id of story to email * @param string $to name of person / friend to email * @param string $toemail friend's email address * @param string $from name of person sending the email * @param string $fromemail sender's email address * @param string $shortmsg short intro text to send with the story * @return string Meta refresh * * Modification History * * Date Author Description * ---- ------ ----------- * 4/17/01 Tony Bibbs Code now allows anonymous users to send email * and it allows user to input a message as well * Thanks to Yngve Wassvik Bergheim for some of * this code * */ function mailstory($sid, $to, $toemail, $from, $fromemail, $shortmsg, $html = 0) { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG08; $dt = new Date('now', $_USER['tzid']); $storyurl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid); if ($_CONF['url_rewrite']) { $retURL = $storyurl . '?msg=85'; } else { $retURL = $storyurl . '&msg=85'; } // check for correct $_CONF permission if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { echo COM_refresh($retURL); exit; } // check if emailing of stories is disabled if ($_CONF['hideemailicon'] == 1) { echo COM_refresh($retURL); exit; } // check mail speedlimit COM_clearSpeedlimit($_CONF['speedlimit'], 'mail'); if (COM_checkSpeedlimit('mail') > 0) { echo COM_refresh($retURL); exit; } $filter = sanitizer::getInstance(); if ($html) { $filter->setPostmode('html'); } else { $filter->setPostmode('text'); } $allowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_default']); $filter->setAllowedElements($allowedElements); $filter->setCensorData(true); $filter->setReplaceTags(true); $filter->setNamespace('glfusion', 'mail_story'); $sql = "SELECT uid,title,introtext,bodytext,story_image,commentcode,UNIX_TIMESTAMP(date) AS day,postmode FROM {$_TABLES['stories']} WHERE sid = '" . DB_escapeString($sid) . "'" . COM_getTopicSql('AND') . COM_getPermSql('AND'); $result = DB_query($sql); if (DB_numRows($result) == 0) { return COM_refresh($_CONF['site_url'] . '/index.php'); } $A = DB_fetchArray($result); $result = PLG_checkforSpam($shortmsg, $_CONF['spamx']); if ($result > 0) { COM_updateSpeedlimit('mail'); COM_displayMessageAndAbort($result, 'spamx', 403, 'Forbidden'); } USES_lib_html2text(); $T = new Template($_CONF['path_layout'] . 'email/'); $T->set_file(array('html_msg' => 'mailstory_html.thtml', 'text_msg' => 'mailstory_text.thtml')); // filter any HTML from the short message $shortmsg = $filter->filterHTML($shortmsg); $html2txt = new html2text($shortmsg, false); $shortmsg_text = $html2txt->get_text(); $story_body = COM_truncateHTML($A['introtext'], 512); $html2txt = new html2text($story_body, false); $story_body_text = $html2txt->get_text(); $dt->setTimestamp($A['day']); $story_date = $dt->format($_CONF['date'], true); $story_title = COM_undoSpecialChars($A['title']); $story_url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid); if ($_CONF['contributedbyline'] == 1) { $author = COM_getDisplayName($A['uid']); } else { $author = ''; } if ($A['story_image'] != '') { $story_image = $_CONF['site_url'] . $A['story_image']; } else { $story_image = ''; } $T->set_var(array('shortmsg_html' => $shortmsg, 'shortmsg_text' => $shortmsg_text, 'story_title' => $story_title, 'story_date' => $story_date, 'story_url' => $story_url, 'author' => $author, 'story_image' => $story_image, 'story_body_html' => $story_body, 'story_body_text' => $story_body_text, 'lang_by' => $LANG01[1], 'site_name' => $_CONF['site_name'], 'from_name' => $from, 'disclaimer' => sprintf($LANG08[23], $from, $fromemail))); $T->parse('message_body_html', 'html_msg'); $message_body_html = $T->finish($T->get_var('message_body_html')); $T->parse('message_body_text', 'text_msg'); $message_body_text = $T->finish($T->get_var('message_body_text')); $msgData = array('htmlmessage' => $message_body_html, 'textmessage' => $message_body_text, 'subject' => $story_title, 'from' => array('email' => $_CONF['site_mail'], 'name' => $from), 'to' => array('email' => $toemail, 'name' => $to)); $mailto = array(); $mailfrom = array(); $mailto = COM_formatEmailAddress($to, $toemail); $mailfrom = COM_formatEmailAddress($from, $fromemail); $subject = COM_undoSpecialChars(strip_tags('Re: ' . $A['title'])); $rc = COM_mail($mailto, $msgData['subject'], $msgData['htmlmessage'], $mailfrom, true, 0, '', $msgData['textmessage']); COM_updateSpeedlimit('mail'); if ($rc) { if ($_CONF['url_rewrite']) { $retval = COM_refresh($storyurl . '?msg=27'); } else { $retval = COM_refresh($storyurl . '&msg=27'); } } else { // Increment numemails counter for story DB_query("UPDATE {$_TABLES['stories']} SET numemails = numemails + 1 WHERE sid = '" . DB_escapeString($sid) . "'"); if ($_CONF['url_rewrite']) { $retval = COM_refresh($storyurl . '?msg=26'); } else { $retval = COM_refresh($storyurl . '&msg=26'); } } echo COM_refresh($retval); exit; }
/** * CallBack function for the ListFactory class * * This function gets called by the ListFactory class and formats * each row accordingly for example pulling usernames from the * users table and displaying a link to their profile. * * @author Sami Barakat <s.m.barakat AT gmail DOT com> * @access public * @param array $row An array of plain data to format * @return array A reformatted version of the input array * */ function searchFormatCallBack($preSort, $row) { global $_CONF, $_USER; $dt = new Date('now', $_USER['tzid']); if ($preSort) { $row[SQL_TITLE] = is_array($row[SQL_TITLE]) ? implode($_CONF['search_separator'], $row[SQL_TITLE]) : $row[SQL_TITLE]; if (is_numeric($row['uid'])) { if (empty($this->_names[$row['uid']])) { $this->_names[$row['uid']] = htmlspecialchars(COM_getDisplayName($row['uid'])); if ($row['uid'] != 1) { $this->_names[$row['uid']] = COM_createLink($this->_names[$row['uid']], $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $row['uid']); } } $row['uid'] = $this->_names[$row['uid']]; } } else { $row[SQL_TITLE] = COM_createLink($row[SQL_TITLE], $this->_searchURL . '&type=' . $row[SQL_NAME] . '&mode=search'); $row['url'] = ($row['url'][0] == '/' ? $_CONF['site_url'] : '') . $row['url']; if ($this->_url_rewrite[$row[SQL_NAME]]) { $row['url'] = COM_buildUrl($row['url']); } if ($row['title'] == '') { $row['title'] = $row[SQL_TITLE]; } $row['title'] = $row['title']; // $this->_shortenText($this->_query, $row['title'], 6); $row['title'] = str_replace('$', '$', $row['title']); $row['title'] = COM_createLink($row['title'], $row['url']); if ($row['description'] == '') { $row['description'] = $_CONF['search_no_data']; } else { $row['description'] = $row['description']; } if ($row['description'] != $_CONF['search_no_data']) { $row['description'] = $this->_shortenText($this->_query, $row['description'], $this->_wordlength); } $dt->setTimestamp($row['date']); $row['date'] = $dt->format($_CONF['daytime'], true); $row['hits'] = COM_NumberFormat($row['hits']) . ' '; // simple solution to a silly problem! } return $row; }
/** * Display month view * * @param ref &$template reference of the template * @param string $dir_topic current topic * @param int $year year to display * @param int $month month to display * @return string list of articles for the given month * */ function DIR_displayMonth(&$template, $dir_topic, $year, $month) { global $_CONF, $_USER, $_TABLES, $LANG_MONTH, $LANG_DIR; $retval = ''; $dt = new Date('now', $_USER['tzid']); $start = sprintf('%04d-%02d-01 00:00:00', $year, $month); $lastday = DIR_lastDayOfMonth($month, $year); $end = sprintf('%04d-%02d-%02d 23:59:59', $year, $month, $lastday); $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS day,DATE_FORMAT(date, '%e') AS mday FROM {$_TABLES['stories']} WHERE (date >= '{$start}') AND (date <= '{$end}') AND (draft_flag = 0) AND (date <= NOW())"; if ($dir_topic != 'all') { $sql .= " AND (tid = '" . DB_escapeString($dir_topic) . "')"; } $sql .= COM_getTopicSql('AND') . COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " ORDER BY date ASC"; $result = DB_query($sql); $numrows = DB_numRows($result); if ($numrows > 0) { $entries = array(); $mday = 0; for ($i = 0; $i < $numrows; $i++) { $A = DB_fetchArray($result); if ($mday != $A['mday']) { if (count($entries) > 0) { $retval .= COM_makeList($entries); $entries = array(); } $dt->setTimestamp($A['day']); $day = $dt->format($_CONF['shortdate'], true); $template->set_var('section_title', $day); $retval .= $template->parse('title', 'section-title') . LB; $mday = $A['mday']; } $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']); $entries[] = COM_createLink($A['title'], $url); } if (count($entries) > 0) { $retval .= COM_makeList($entries); } } else { $retval .= $template->parse('message', 'no-articles') . LB; } $retval .= LB; return $retval; }