예제 #1
0
if (isset($_CONF['mail_settings']['password'])) {
    unset($_CONF['mail_settings']['password']);
}
$display = "<html>\n<head><title>Configuration Settings</title></head>\n<body>\n";
$n = 0;
$display .= '<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border: thin black solid;">';
foreach ($_CONF as $option => $value) {
    $display .= '<tr';
    if ($n % 2 == 0) {
        $display .= ' style="background-color: ' . $highlight_on . '">';
    } else {
        $display .= ' style="background-color: ' . $highlight_off . '">';
    }
    $display .= '<td style="border: thin black solid; padding: 2px;"><strong>$_CONF[\'<a href="' . $docs . $option . '">' . $option . '</a>\']</strong></td>';
    if (is_array($value)) {
        ob_start();
        print_r($value);
        $value = COM_nl2br(ob_get_clean());
    } elseif (is_bool($value)) {
        $value = $value === false ? 'false' : 'true';
    } elseif (MBYTE_eregi('[a-z]+html', $option)) {
        $value = htmlentities($value);
    } elseif (!isset($value)) {
        $value = '&nbsp;';
    }
    $display .= '<td style="border: thin black solid; padding: 2px;"><strong>' . $value . '</strong></td>';
    $display .= '</tr>';
    $n++;
}
$display .= "</table>\n</body>\n</html>";
echo $display;
예제 #2
0
/**
* Allows user to edit a personal calendar event
*
* @param    array   $A  Record to display
* @return   string      HTML for event editor
*
*/
function editpersonalevent($A)
{
    global $_CONF, $_CAJP_CONF, $LANG_CALJP_1;
    $ja = $_CONF['language'] == 'japanese_utf-8';
    $cal_templates = COM_newTemplate($_CONF['path'] . 'plugins/calendarjp/templates/');
    $cal_templates->set_file('form', 'editpersonalevent' . ($ja ? '_ja' : '') . '.thtml');
    $cal_templates->set_var('lang_title', $LANG_CALJP_1[28]);
    $title = stripslashes($A['title']);
    $title = str_replace('{', '&#123;', $title);
    $title = str_replace('}', '&#125;', $title);
    $title = str_replace('"', '&quot;', $title);
    $cal_templates->set_var('event_title', $title);
    $cal_templates->set_var('lang_eventtype', $LANG_CALJP_1[37]);
    $type_options = CALENDARJP_eventTypeList($A['event_type']);
    $cal_templates->set_var('type_options', $type_options);
    // Handle start date/time
    $cal_templates->set_var('lang_startdate', $LANG_CALJP_1[21]);
    $cal_templates->set_var('lang_starttime', $LANG_CALJP_1[30]);
    $A['startdate'] = $A['datestart'] . ' ' . $A['timestart'];
    $start_month = date('n', strtotime($A['startdate']));
    $month_options = CALENDARJP_getMonthFormOptions($start_month);
    $cal_templates->set_var('startmonth_options', $month_options);
    $start_day = date('j', strtotime($A['startdate']));
    $day_options = COM_getDayFormOptions($start_day);
    $cal_templates->set_var('startday_options', $day_options);
    $start_year = date('Y', strtotime($A['startdate']));
    $year_options = COM_getYearFormOptions($start_year);
    $cal_templates->set_var('startyear_options', $year_options);
    if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) {
        $start_hour = date('H', strtotime($A['startdate']));
        $hour_options = COM_getHourFormOptions($start_hour, 24);
        $cal_templates->set_var('starthour_options', $hour_options);
    } else {
        $start_hour = date('g', strtotime($A['startdate']));
        $hour_options = COM_getHourFormOptions($start_hour);
        $cal_templates->set_var('starthour_options', $hour_options);
    }
    $startmin = intval(date('i', strtotime($A['startdate'])) / 15) * 15;
    $cal_templates->set_var('startminute_options', COM_getMinuteFormOptions($startmin, 15));
    $ampm = date('a', strtotime($A['startdate']));
    $cal_templates->set_var('startampm_selection', CALENDARJP_getAmPmFormSelection('startampm_selection', $ampm));
    // Handle end date/time
    $cal_templates->set_var('lang_enddate', $LANG_CALJP_1[18]);
    $cal_templates->set_var('lang_endtime', $LANG_CALJP_1[29]);
    $A['enddate'] = $A['dateend'] . ' ' . $A['timeend'];
    $end_month = date('n', strtotime($A['enddate']));
    $month_options = CALENDARJP_getMonthFormOptions($end_month);
    $cal_templates->set_var('endmonth_options', $month_options);
    $end_day = date('j', strtotime($A['enddate']));
    $day_options = COM_getDayFormOptions($end_day);
    $cal_templates->set_var('endday_options', $day_options);
    $end_year = date('Y', strtotime($A['enddate']));
    $year_options = COM_getYearFormOptions($end_year);
    $cal_templates->set_var('endyear_options', $year_options);
    if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) {
        $end_hour = date('H', strtotime($A['enddate']));
        $hour_options = COM_getHourFormOptions($end_hour, 24);
        $cal_templates->set_var('endhour_options', $hour_options);
    } else {
        $end_hour = date('g', strtotime($A['enddate']));
        $hour_options = COM_getHourFormOptions($end_hour);
        $cal_templates->set_var('endhour_options', $hour_options);
    }
    $endmin = intval(date('i', strtotime($A['enddate'])) / 15) * 15;
    $cal_templates->set_var('endminute_options', COM_getMinuteFormOptions($endmin, 15));
    $ampm = date('a', strtotime($A['enddate']));
    $cal_templates->set_var('endampm_selection', CALENDARJP_getAmPmFormSelection('endampm_selection', $ampm));
    $cal_templates->set_var('lang_alldayevent', $LANG_CALJP_1[31]);
    if ($A['allday'] == 1) {
        $cal_templates->set_var('allday_checked', 'checked="checked"');
    } else {
        $cal_templates->set_var('allday_checked', '');
    }
    $cal_templates->set_var('lang_tail_year', $LANG_CALJP_1['tail_year']);
    $cal_templates->set_var('lang_tail_month', $LANG_CALJP_1['tail_month']);
    $cal_templates->set_var('lang_tail_day', $LANG_CALJP_1['tail_day']);
    $cal_templates->set_var('lang_location', $LANG_CALJP_1[39]);
    $cal_templates->set_var('event_location', stripslashes($A['location']));
    $cal_templates->set_var('lang_addressline1', $LANG_CALJP_1[32]);
    $cal_templates->set_var('event_address1', stripslashes($A['address1']));
    $cal_templates->set_var('lang_addressline2', $LANG_CALJP_1[33]);
    $cal_templates->set_var('event_address2', stripslashes($A['address2']));
    $cal_templates->set_var('lang_city', $LANG_CALJP_1[34]);
    $cal_templates->set_var('event_city', stripslashes($A['city']));
    $cal_templates->set_var('lang_state', $LANG_CALJP_1[35]);
    $cal_templates->set_var('state_options', '');
    $cal_templates->set_var('event_state', stripslashes($A['state']));
    $cal_templates->set_var('lang_zipcode', $LANG_CALJP_1[36]);
    $cal_templates->set_var('event_zipcode', $A['zipcode']);
    $cal_templates->set_var('lang_link', $LANG_CALJP_1[43]);
    $cal_templates->set_var('event_url', $A['url']);
    $cal_templates->set_var('lang_description', $LANG_CALJP_1[5]);
    $cal_templates->set_var('event_description', COM_nl2br(stripslashes($A['description'])));
    $cal_templates->set_var('lang_htmlnotallowed', $LANG_CALJP_1[44]);
    $cal_templates->set_var('lang_submit', $LANG_CALJP_1[45]);
    $cal_templates->set_var('lang_delete', $LANG_CALJP_1[51]);
    $cal_templates->set_var('eid', $A['eid']);
    $cal_templates->set_var('uid', $A['uid']);
    if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) {
        $cal_templates->set_var('hour_mode', 24);
    } else {
        $cal_templates->set_var('hour_mode', 12);
    }
    $cal_templates->set_var('gltoken_name', CSRF_TOKEN);
    $cal_templates->set_var('gltoken', SEC_createToken());
    return $cal_templates->parse('output', 'form');
}
예제 #3
0
 /**
  * Returns text ready for display.
  *
  * @param   string  $text         Text to prepare for display
  * @param   string  $postmode     Indicates if text is html, adveditor, wikitext or plaintext
  * @param   int     $version      version of GLText engine
  * @return  string  Escaped String
  * @access  public
  *
  */
 public static function getDisplayText($text, $postmode, $version)
 {
     if ($version == GLTEXT_FIRST_VERSION) {
         // first version
         if ($postmode == 'plaintext') {
             $text = COM_nl2br($text);
         }
         if ($postmode == 'wikitext') {
             $text = self::_editUnescape($text, $postmode);
             $text = self::renderWikiText($text);
         }
     } else {
         // latest version
         if ($postmode == 'html' || $postmode == 'adveditor') {
             // Get rid of any newline characters
             $text = str_replace("\n", '', $text);
             $text = self::_handleSpecialTag_callback($text, array('[code]', '[/code]', '<pre><code>', '</code></pre>'), '_escapeSPChars');
             $text = self::_handleSpecialTag_callback($text, array('[raw]', '[/raw]', '<!--raw--><span class="raw">', '</span><!--/raw-->'), '_escapeSPChars');
         }
         if ($postmode == 'plaintext') {
             $text = htmlspecialchars($text, ENT_QUOTES, COM_getEncodingt());
             $text = COM_makeClickableLinks($text);
             $text = COM_nl2br($text);
         }
         if ($postmode == 'wikitext') {
             $text = self::_editUnescape($text, $postmode);
             $text = self::renderWikiText($text);
             //              $text = self::_htmLawed($text, 'story.edit');
         }
         $text = COM_checkWords($text);
     }
     $text = PLG_replaceTags(self::_displayEscape($text));
     return $text;
 }
예제 #4
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_CONF, $_LI_CONF, $LANG_ADMIN, $LANG_LINKS, $LANG_DIRECTION, $_IMAGE_TYPE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $actualUrl = stripslashes($A['url']);
    $title = stripslashes($A['title']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $actualUrl);
    $template->set_var('link_actual_url_encoded', rawurlencode($actualUrl));
    $template->set_var('link_name', $title);
    $template->set_var('link_name_encoded', rawurlencode($title));
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $template->set_var('link_description', PLG_replaceTags(COM_nl2br(stripslashes($A['description']))));
    $attr = array('title' => $actualUrl);
    if (substr($actualUrl, 0, strlen($_CONF['site_url'])) != $_CONF['site_url']) {
        $class = 'ext-link';
        if (!empty($LANG_DIRECTION) && $LANG_DIRECTION == 'rtl') {
            $class .= '-rtl';
        }
        $attr['class'] = $class;
        if ($_LI_CONF['new_window']) {
            $attr['target'] = '_blank';
        }
    }
    $html = COM_createLink($title, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?mode=edit&amp;lid=' . $A['lid'];
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
}
예제 #5
0
/**
* Formats a Geeklog block
*
* This shows a single block and is typically called from
* COM_showBlocks OR from plugin code
*
* @param        array     $A          Block Record
* @param        boolean   $noboxes    Set to true if userpref is no blocks
* @return       string    HTML Formated block
*
*/
function COM_formatBlock($A, $noboxes = false)
{
    global $_CONF, $_TABLES, $LANG21;
    $retval = '';
    $lang = COM_getLanguageId();
    if (!empty($lang)) {
        $blocksql['mssql'] = "SELECT bid, is_enabled, name, type, title, tid, blockorder, cast(content as text) as content, ";
        $blocksql['mssql'] .= "rdfurl, rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id, ";
        $blocksql['mssql'] .= "group_id, perm_owner, perm_group, perm_members, perm_anon, allow_autotags,UNIX_TIMESTAMP(rdfupdated) AS date ";
        $blocksql['mysql'] = "SELECT *,UNIX_TIMESTAMP(rdfupdated) AS date ";
        $blocksql['pgsql'] = 'SELECT *, date_part(\'epoch\', rdfupdated) AS date ';
        $commonsql = "FROM {$_TABLES['blocks']} WHERE name = '" . $A['name'] . '_' . $lang . "'";
        $blocksql['mysql'] .= $commonsql;
        $blocksql['mssql'] .= $commonsql;
        $blocksql['pgsql'] .= $commonsql;
        $result = DB_query($blocksql);
        if (DB_numRows($result) == 1) {
            // overwrite with data for language-specific block
            $A = DB_fetchArray($result);
        }
    }
    if (array_key_exists('onleft', $A)) {
        if ($A['onleft'] == 1) {
            $position = 'left';
        } else {
            $position = 'right';
        }
    } else {
        $position = '';
    }
    if ($A['type'] == 'portal') {
        if (COM_rdfCheck($A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit'])) {
            $A['content'] = DB_getItem($_TABLES['blocks'], 'content', "bid = '{$A['bid']}'");
        }
    }
    if ($A['type'] == 'gldefault') {
        $retval .= COM_showBlock($A['name'], $A['help'], $A['title'], $position);
    } else {
        // The only time cache_time would not be set if for dynamic blocks (they can handle their own caching if needed)
        // Don't Cache default blocks either
        if (isset($A['cache_time']) and ($A['cache_time'] > 0 or $A['cache_time'] == -1)) {
            $cacheInstance = 'block__' . $A['bid'] . '__' . CACHE_security_hash() . '__' . $_CONF['theme'];
            $retval = CACHE_check_instance($cacheInstance);
            if ($retval and $A['cache_time'] == -1) {
                return $retval;
            } elseif ($retval and $A['cache_time'] > 0) {
                $lu = CACHE_get_instance_update($cacheInstance);
                $now = time();
                if ($now - $lu < $A['cache_time']) {
                    return $retval;
                } else {
                    $retval = '';
                }
            }
        }
    }
    if ($A['type'] == 'phpblock' && !$noboxes) {
        if (!($A['name'] == 'whosonline_block' and DB_getItem($_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0)) {
            $function = $A['phpblockfn'];
            $matches = array();
            if (preg_match('/^(phpblock_\\w*)\\((.*)\\)$/', $function, $matches) == 1) {
                $function = $matches[1];
                $args = $matches[2];
            }
            $blkheader = COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position));
            $blkfooter = COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position));
            if (function_exists($function)) {
                if (isset($args)) {
                    $fretval = $function($A, $args);
                } else {
                    $fretval = $function();
                }
                if (!empty($fretval)) {
                    $retval .= $blkheader;
                    $retval .= $fretval;
                    $retval .= $blkfooter;
                }
            } else {
                // show error message
                $retval .= $blkheader;
                $retval .= sprintf($LANG21[31], $function);
                $retval .= $blkfooter;
            }
        }
    }
    if (!empty($A['content']) && trim($A['content']) != '' && !$noboxes) {
        $blockcontent = stripslashes($A['content']);
        // Hack: If the block content starts with a '<' assume it
        // contains HTML and do not call COM_nl2br() which would only add
        // unwanted <br> tags.
        if (substr(trim($blockcontent), 0, 1) != '<') {
            $blockcontent = COM_nl2br($blockcontent);
        }
        // autotags are only(!) allowed in normal blocks
        if ($A['allow_autotags'] == 1 && $A['type'] == 'normal') {
            $blockcontent = PLG_replaceTags($blockcontent);
        }
        $blockcontent = str_replace(array('<?', '?>'), '', $blockcontent);
        $retval .= COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position)) . $blockcontent . LB . COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position));
    }
    // Cache only if enabled and not gldefault or dynamic
    if (isset($A['cache_time']) and ($A['cache_time'] > 0 or $A['cache_time'] == -1) and $A['type'] != 'gldefault') {
        CACHE_create_instance($cacheInstance, $retval);
    }
    return $retval;
}
예제 #6
0
/**
 * Filters comment text and appends necessary tags (sig and/or edit)
 *
 * @copyright Jared Wenerd 2008
 * @author Jared Wenerd, wenerd87 AT gmail DOT com
 * @param string  $comment  comment text
 * @param string  $postmode ('html', 'plaintext', ...)
 * @param string  $type     Type of item (article, polls, etc.)
 * @param boolean $edit     if true append edit tag
 * @param int     $cid      commentid if editing comment (for proper sig)
 * @return string of comment text
 */
function CMT_prepareText($comment, $postmode, $type, $edit = false, $cid = null)
{
    global $_USER, $_TABLES, $LANG03, $_CONF;
    // Remove any autotags the user doesn't have permission to use
    $comment = PLG_replaceTags($comment, '', true);
    if ($postmode == 'html') {
        $html_perm = $type == 'article' ? 'story.edit' : "{$type}.edit";
        $comment = COM_checkWords(COM_checkHTML(COM_stripslashes($comment), $html_perm));
    } else {
        // plaintext
        $comment = htmlspecialchars(COM_checkWords(COM_stripslashes($comment)));
        $newcomment = COM_makeClickableLinks($comment);
        if (strcmp($comment, $newcomment) != 0) {
            $comment = COM_nl2br($newcomment);
        }
    }
    if ($edit) {
        $comment .= '<div class="comment-edit">' . $LANG03[30] . ' ' . strftime($_CONF['date'], time()) . ' ' . $LANG03[31] . ' ' . $_USER['username'] . '</div><!-- /COMMENTEDIT -->';
        $text = $comment;
    }
    if (empty($_USER['uid'])) {
        $uid = 1;
    } elseif ($edit && is_numeric($cid)) {
        //if comment moderator
        $uid = DB_getItem($_TABLES['comments'], 'uid', "cid = '{$cid}'");
    } else {
        $uid = $_USER['uid'];
    }
    $sig = '';
    if ($uid > 1) {
        $sig = DB_getItem($_TABLES['users'], 'sig', "uid = '{$uid}'");
        if (!empty($sig)) {
            $comment .= '<!-- COMMENTSIG --><div class="comment-sig">';
            if ($postmode == 'html') {
                $comment .= '---<br' . XHTML . '>' . COM_nl2br($sig);
            } else {
                $comment .= '---' . LB . $sig;
            }
            $comment .= '</div><!-- /COMMENTSIG -->';
        }
    }
    return $comment;
}
예제 #7
0
/**
* Get content for a feed that holds all stories.
*
* @param    boolean  $frontpage_only true: only articles shown on the frontpage
* @param    string   $limit    number of entries or number of stories
* @param    string   $link     link to homepage
* @param    string   $update   list of story ids
* @param    int      $contentLength Length of summary to allow.
* @param    int      $fid       the id of the feed being fetched
* @return   array              content of the feed
*
*/
function SYND_getFeedContentAll($frontpage_only, $limit, &$link, &$update, $contentLength, $feedType, $feedVersion, $fid)
{
    global $_TABLES, $_CONF, $LANG01;
    $link = $_CONF['site_url'];
    $where = '';
    if (!empty($limit)) {
        if (substr($limit, -1) == 'h') {
            $limitsql = '';
            $hours = substr($limit, 0, -1);
            $where = " AND date >= DATE_SUB(NOW(),INTERVAL {$hours} HOUR)";
        } else {
            $limitsql = ' LIMIT ' . $limit;
        }
    } else {
        $limitsql = ' LIMIT 10';
    }
    // get list of topics that anonymous users have access to
    $topics = array();
    $tresult = DB_query("SELECT tid,topic FROM {$_TABLES['topics']}" . COM_getPermSQL('WHERE', 1));
    $tnumrows = DB_numRows($tresult);
    if ($tnumrows == 0) {
        // no public topics
        $update = '';
        return array();
    }
    $tlist = '';
    for ($i = 1; $i <= $tnumrows; $i++) {
        $T = DB_fetchArray($tresult);
        $tlist .= "'" . $T['tid'] . "'";
        if ($i < $tnumrows) {
            $tlist .= ',';
        }
        $topics[$T['tid']] = stripslashes($T['topic']);
    }
    if (!empty($tlist)) {
        $where .= " AND (ta.tid IN ({$tlist}))";
    }
    if ($frontpage_only) {
        $where .= ' AND frontpage = 1';
    }
    $sql = "SELECT sid,ta.tid,uid,title,introtext,bodytext,postmode,UNIX_TIMESTAMP(date) AS modified,commentcode,trackbackcode\n        FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n        WHERE draft_flag = 0 AND date <= NOW() AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1 {$where} AND perm_anon > 0\n        GROUP BY sid,ta.tid\n        ORDER BY date DESC {$limitsql}";
    $result = DB_query($sql);
    $content = array();
    $sids = array();
    $nrows = DB_numRows($result);
    for ($i = 1; $i <= $nrows; $i++) {
        $row = DB_fetchArray($result);
        $sids[] = $row['sid'];
        $storytitle = stripslashes($row['title']);
        $fulltext = stripslashes($row['introtext'] . "\n" . $row['bodytext']);
        $fulltext = PLG_replaceTags($fulltext);
        $storytext = $contentLength == 1 ? $fulltext : COM_truncateHTML($fulltext, $contentLength, ' ...');
        $fulltext = trim($fulltext);
        $fulltext = str_replace(array("\r\n", "\r"), "\n", $fulltext);
        if ($row['postmode'] == 'plaintext') {
            if (!empty($storytext)) {
                $storytext = COM_nl2br($storytext);
            }
            if (!empty($fulltext)) {
                $fulltext = COM_nl2br($fulltext);
            }
        }
        $storylink = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $row['sid']);
        $extensionTags = PLG_getFeedElementExtensions('article', $row['sid'], $feedType, $feedVersion, $fid, $frontpage_only ? '::frontpage' : '::all');
        if ($_CONF['trackback_enabled'] && $feedType == 'RSS' && $row['trackbackcode'] >= 0) {
            $trbUrl = TRB_makeTrackbackUrl($row['sid']);
            $extensionTags['trackbacktag'] = '<trackback:ping>' . htmlspecialchars($trbUrl) . '</trackback:ping>';
        }
        $article = array('title' => $storytitle, 'summary' => $storytext, 'text' => $fulltext, 'link' => $storylink, 'uid' => $row['uid'], 'author' => COM_getDisplayName($row['uid']), 'date' => $row['modified'], 'format' => $row['postmode'], 'topic' => $topics[$row['tid']], 'extensions' => $extensionTags);
        if ($row['commentcode'] >= 0) {
            $article['commenturl'] = $storylink . '#comments';
        }
        $content[] = $article;
    }
    $update = implode(',', $sids);
    return $content;
}
예제 #8
0
/**
 * Shows a profile for a user
 * This grabs the user profile for a given user and displays it
 *
 * @param    int     $uid     User ID of profile to get
 * @param    boolean $preview whether being called as preview from My Account
 * @param    int     $msg     Message to display (if != 0)
 * @param    string  $plugin  optional plugin name for message
 * @return   string              HTML for user profile page
 */
function USER_showProfile($uid, $preview = false, $msg = 0, $plugin = '')
{
    global $_CONF, $_TABLES, $_USER, $_IMAGE_TYPE, $LANG01, $LANG04, $LANG09, $LANG28, $LANG_LOGIN, $LANG_ADMIN;
    $retval = '';
    if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['profileloginrequired'] == 1)) {
        $retval .= SEC_loginRequiredForm();
        $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG_LOGIN[1]));
        return $retval;
    }
    $result = DB_query("SELECT {$_TABLES['users']}.uid,username,fullname,regdate,homepage,about,location,pgpkey,photo,email,status FROM {$_TABLES['userinfo']},{$_TABLES['users']} WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid AND {$_TABLES['users']}.uid = {$uid}");
    $numRows = DB_numRows($result);
    if ($numRows == 0) {
        // no such user
        COM_handle404();
    }
    $A = DB_fetchArray($result);
    if ($A['status'] == USER_ACCOUNT_DISABLED && !SEC_hasRights('user.edit')) {
        COM_displayMessageAndAbort(30, '', 403, 'Forbidden');
    }
    if ($A['status'] != USER_ACCOUNT_ACTIVE && !SEC_hasRights('user.edit')) {
        COM_handle404();
    }
    $display_name = COM_getDisplayName($uid, $A['username'], $A['fullname']);
    $display_name = htmlspecialchars($display_name);
    if (!$preview) {
        if ($msg > 0) {
            $retval .= COM_showMessage($msg, $plugin);
        }
    }
    // format date/time to user preference
    $currentTime = COM_getUserDateTimeFormat($A['regdate']);
    $A['regdate'] = $currentTime[0];
    $user_templates = COM_newTemplate($_CONF['path_layout'] . 'users');
    $user_templates->set_file(array('profile' => 'profile.thtml', 'email' => 'email.thtml', 'row' => 'commentrow.thtml', 'strow' => 'storyrow.thtml'));
    $user_templates->set_var('start_block_userprofile', COM_startBlock($LANG04[1] . ' ' . $display_name));
    $user_templates->set_var('end_block', COM_endBlock());
    $user_templates->set_var('lang_username', $LANG04[2]);
    if ($_CONF['show_fullname'] == 1) {
        if (empty($A['fullname'])) {
            $userName = $A['username'];
            $fullName = '';
        } else {
            $userName = $A['fullname'];
            $fullName = $A['username'];
        }
    } else {
        $userName = $A['username'];
        $fullName = $A['fullname'];
    }
    $userName = htmlspecialchars($userName);
    $fullName = htmlspecialchars($fullName);
    if ($A['status'] == USER_ACCOUNT_DISABLED) {
        $userName = sprintf('<s title="%s">%s</s>', $LANG28[42], $userName);
        if (!empty($fullName)) {
            $fullName = sprintf('<s title="%s">%s</s>', $LANG28[42], $fullName);
        }
    }
    $user_templates->set_var('username', $userName);
    $user_templates->set_var('user_fullname', $fullName);
    if ($preview) {
        $user_templates->set_var('edit_icon', '');
        $user_templates->set_var('edit_link', '');
        $user_templates->set_var('user_edit', '');
    } elseif (!COM_isAnonUser() && $_USER['uid'] == $uid) {
        $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[48] . '" title="' . $LANG01[48] . '"' . XHTML . '>';
        $edit_link_url = COM_createLink($edit_icon, $_CONF['site_url'] . '/usersettings.php');
        $user_templates->set_var('edit_icon', $edit_icon);
        $user_templates->set_var('edit_link', $edit_link_url);
        $user_templates->set_var('user_edit', $edit_link_url);
    } elseif (SEC_hasRights('user.edit')) {
        $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG_ADMIN['edit'] . '" title="' . $LANG_ADMIN['edit'] . '"' . XHTML . '>';
        $edit_link_url = COM_createLink($edit_icon, "{$_CONF['site_admin_url']}/user.php?mode=edit&amp;uid={$A['uid']}");
        $user_templates->set_var('edit_icon', $edit_icon);
        $user_templates->set_var('edit_link', $edit_link_url);
        $user_templates->set_var('user_edit', $edit_link_url);
    }
    if (isset($A['photo']) && empty($A['photo'])) {
        $A['photo'] = '(none)';
        // user does not have a photo
    }
    $photo = USER_getPhoto($uid, $A['photo'], $A['email'], -1);
    $user_templates->set_var('user_photo', $photo);
    $user_templates->set_var('lang_membersince', $LANG04[67]);
    $user_templates->set_var('user_regdate', $A['regdate']);
    $user_templates->set_var('lang_email', $LANG04[5]);
    $user_templates->set_var('user_id', $uid);
    $user_templates->set_var('uid', $uid);
    if ($A['email'] != '') {
        $user_templates->set_var('lang_sendemail', $LANG04[81]);
        $user_templates->parse('email_option', 'email', true);
    } else {
        $user_templates->set_var('email_option', '');
    }
    $user_templates->set_var('lang_homepage', $LANG04[6]);
    $user_templates->set_var('user_homepage', COM_killJS($A['homepage']));
    $user_templates->set_var('lang_location', $LANG04[106]);
    $user_templates->set_var('user_location', strip_tags($A['location']));
    $user_templates->set_var('lang_bio', $LANG04[7]);
    $user_templates->set_var('user_bio', COM_nl2br(stripslashes($A['about'])));
    $user_templates->set_var('lang_pgpkey', $LANG04[8]);
    $user_templates->set_var('user_pgp', COM_nl2br($A['pgpkey']));
    $user_templates->set_var('start_block_last10stories', COM_startBlock($LANG04[82] . ' ' . $display_name));
    $user_templates->set_var('start_block_last10comments', COM_startBlock($LANG04[10] . ' ' . $display_name));
    $user_templates->set_var('start_block_postingstats', COM_startBlock($LANG04[83] . ' ' . $display_name));
    $user_templates->set_var('lang_title', $LANG09[16]);
    $user_templates->set_var('lang_date', $LANG09[17]);
    // for alternative layouts: use these as headlines instead of block titles
    $user_templates->set_var('headline_last10stories', $LANG04[82]);
    $user_templates->set_var('headline_last10comments', $LANG04[10]);
    $user_templates->set_var('headline_postingstats', $LANG04[83]);
    $tids = TOPIC_getList(0, true, false);
    $topics = "'" . implode("','", $tids) . "'";
    // list of last 10 stories by this user
    if (count($tids) > 0) {
        $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate\n            FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n            WHERE (uid = {$uid}) AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND') . "\n            AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1\n            ORDER BY unixdate DESC LIMIT 10";
        $result = DB_query($sql);
        $numRows = DB_numRows($result);
    } else {
        $numRows = 0;
    }
    if ($numRows > 0) {
        for ($i = 0; $i < $numRows; $i++) {
            $C = DB_fetchArray($result);
            $user_templates->set_var('cssid', $i % 2 + 1);
            $user_templates->set_var('row_number', $i + 1 . '.');
            $articleUrl = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $C['sid']);
            $user_templates->set_var('article_url', $articleUrl);
            $C['title'] = str_replace('$', '&#36;', $C['title']);
            $user_templates->set_var('story_title', COM_createLink(stripslashes($C['title']), $articleUrl, array('class' => 'b')));
            $storyTime = COM_getUserDateTimeFormat($C['unixdate']);
            $user_templates->set_var('story_date', $storyTime[0]);
            $user_templates->parse('story_row', 'strow', true);
        }
    } else {
        $story_row = $LANG01[37];
        if ($_CONF['supported_version_theme'] == '1.8.1') {
            $story_row = '<tr><td>' . $story_row . '</td></tr>';
        }
        $user_templates->set_var('story_row', $story_row);
    }
    // list of last 10 comments by this user
    $new_plugin_comments = PLG_getWhatsNewComment('', 10, $uid);
    if (!empty($new_plugin_comments)) {
        // Sort array by element lastdate newest to oldest
        foreach ($new_plugin_comments as $k => $v) {
            $b[$k] = strtolower($v['unixdate']);
        }
        arsort($b);
        foreach ($b as $key => $val) {
            $temp[] = $new_plugin_comments[$key];
        }
        $new_plugin_comments = $temp;
        $i = 0;
        foreach ($new_plugin_comments as $C) {
            $i = $i + 1;
            $user_templates->set_var('cssid', $i % 2);
            $user_templates->set_var('row_number', $i . '.');
            $C['title'] = str_replace('$', '&#36;', $C['title']);
            $comment_url = $_CONF['site_url'] . '/comment.php?mode=view&amp;cid=' . $C['cid'];
            $user_templates->set_var('comment_title', COM_createLink(stripslashes($C['title']), $comment_url, array('class' => 'b')));
            $commentTime = COM_getUserDateTimeFormat($C['unixdate']);
            $user_templates->set_var('comment_date', $commentTime[0]);
            $user_templates->parse('comment_row', 'row', true);
            if ($i == 10) {
                break;
            }
        }
    } else {
        $comment_row = $LANG01[29];
        if ($_CONF['supported_version_theme'] == '1.8.1') {
            $comment_row = '<tr><td>' . $comment_row . '</td></tr>';
        }
        $user_templates->set_var('comment_row', $comment_row);
    }
    // posting stats for this user
    $user_templates->set_var('lang_number_stories', $LANG04[84]);
    $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (uid = {$uid}) AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL('AND');
    $result = DB_query($sql);
    $N = DB_fetchArray($result);
    $user_templates->set_var('number_stories', COM_numberFormat($N['count']));
    $user_templates->set_var('lang_number_comments', $LANG04[85]);
    $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['comments']} WHERE (uid = {$uid})";
    $result = DB_query($sql);
    $N = DB_fetchArray($result);
    $user_templates->set_var('number_comments', COM_numberFormat($N['count']));
    $user_templates->set_var('lang_all_postings_by', $LANG04[86] . ' ' . $display_name);
    // Call custom registration function if enabled and exists
    if ($_CONF['custom_registration'] && function_exists('CUSTOM_userDisplay')) {
        $user_templates->set_var('customfields', CUSTOM_userDisplay($uid));
    }
    PLG_profileVariablesDisplay($uid, $user_templates);
    $user_templates->parse('output', 'profile');
    $retval .= $user_templates->finish($user_templates->get_var('output'));
    $retval .= PLG_profileBlocksDisplay($uid);
    if (!$preview) {
        $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG04[1] . ' ' . $display_name));
    }
    return $retval;
}
예제 #9
0
    unset($_CONF['mail_settings']['password']);
}
$display = "<html>\n<head><title>Configuration Settings</title></head>\n<body>\n";
$n = 0;
$display .= '<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border: thin black solid;">';
foreach ($_CONF as $option => $value) {
    $display .= '<tr';
    if ($n % 2 == 0) {
        $display .= ' style="background-color: ' . $highlight_on . '">';
    } else {
        $display .= ' style="background-color: ' . $highlight_off . '">';
    }
    $display .= '<td style="border: thin black solid; padding: 2px;"><strong>$_CONF[\'<a href="' . $docs . $option . '">' . $option . '</a>\']</strong></td>';
    if (is_array($value)) {
        ob_start();
        print_r($value);
        $value = COM_nl2br(ob_get_contents());
        ob_end_clean();
    } elseif (is_bool($value)) {
        $value = $value === false ? 'false' : 'true';
    } elseif (MBYTE_eregi('[a-z]+html', $option)) {
        $value = htmlentities($value);
    } elseif (!isset($value)) {
        $value = '&nbsp;';
    }
    $display .= '<td style="border: thin black solid; padding: 2px;"><strong>' . $value . '</strong></td>';
    $display .= '</tr>';
    $n++;
}
$display .= "</table>\n</body>\n</html>";
echo $display;
예제 #10
0
/**
 * Formats a Geeklog block
 * This shows a single block and is typically called from
 * COM_showBlocks OR from plugin code
 *
 * @param        array   $A          Block Record
 * @param        boolean $noBoxes    Set to true if userpref is no blocks
 * @param        boolean $noPosition Set to true if you don't want to use the left or right side footer and header of
 *                                   block
 * @return       string              HTML Formatted block
 */
function COM_formatBlock($A, $noBoxes = false, $noPosition = false)
{
    global $_CONF, $_TABLES, $LANG21, $_DEVICE;
    $retval = '';
    $lang = COM_getLanguageId();
    if (!empty($lang)) {
        $blockSql['mysql'] = "SELECT *,UNIX_TIMESTAMP(rdfupdated) AS date ";
        $blockSql['pgsql'] = "SELECT *, date_part('epoch', rdfupdated) AS date ";
        $commonSql = "FROM {$_TABLES['blocks']} WHERE name = '" . $A['name'] . '_' . $lang . "'";
        $blockSql['mysql'] .= $commonSql;
        $blockSql['pgsql'] .= $commonSql;
        $result = DB_query($blockSql);
        if (DB_numRows($result) == 1) {
            // overwrite with data for language-specific block
            $A = DB_fetchArray($result);
        }
    }
    // Make sure block can be used by specific device
    // If no device column found then bypass compare check (could happen with dynamic blocks that do not pass device)
    if (!isset($A['device']) || $_DEVICE->compare($A['device'])) {
        if (array_key_exists('onleft', $A) && !$noPosition) {
            $position = $A['onleft'] == 1 ? 'left' : 'right';
        } else {
            $position = '';
        }
        if ($A['type'] === 'portal') {
            if (COM_rdfCheck($A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit'])) {
                $A['content'] = DB_getItem($_TABLES['blocks'], 'content', "bid = '{$A['bid']}'");
            }
        }
        if ($A['type'] === 'gldefault') {
            $retval .= COM_showBlock($A['name'], $A['help'], $A['title'], $position);
        } else {
            // The only time cache_time would not be set if for dynamic blocks (they can handle their own caching if needed)
            // Don't Cache default blocks either
            if (isset($A['cache_time']) && ($A['cache_time'] > 0 || $A['cache_time'] == -1)) {
                $cacheInstance = 'block__' . $A['bid'] . '__' . CACHE_security_hash() . '__' . $_CONF['theme'];
                $retval = CACHE_check_instance($cacheInstance);
                if ($retval && $A['cache_time'] == -1) {
                    return $retval;
                } elseif ($retval && $A['cache_time'] > 0) {
                    $lu = CACHE_get_instance_update($cacheInstance);
                    $now = time();
                    if ($now - $lu < $A['cache_time']) {
                        return $retval;
                    } else {
                        $retval = '';
                    }
                }
            }
        }
        if ($A['type'] === 'phpblock' && !$noBoxes) {
            if (!($A['name'] === 'whosonline_block' && DB_getItem($_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0)) {
                $function = $A['phpblockfn'];
                $matches = array();
                if (preg_match('/^(phpblock_\\w*)\\((.*)\\)$/', $function, $matches) == 1) {
                    $function = $matches[1];
                    $args = $matches[2];
                }
                $blockHeader = COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position));
                $blockFooter = COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position));
                if (function_exists($function)) {
                    if (isset($args)) {
                        $fRetval = $function($A, $args);
                    } else {
                        $fRetval = $function();
                    }
                    if (!empty($fRetval)) {
                        $retval .= $blockHeader;
                        $retval .= $fRetval;
                        $retval .= $blockFooter;
                    }
                } else {
                    // show error message
                    $retval .= $blockHeader;
                    $retval .= sprintf($LANG21[31], $function);
                    $retval .= $blockFooter;
                }
            }
        }
        if (!empty($A['content']) && trim($A['content']) != '' && !$noBoxes) {
            $blockContent = stripslashes($A['content']);
            // Hack: If the block content starts with a '<' assume it
            // contains HTML and do not call COM_nl2br() which would only add
            // unwanted <br> tags.
            if (substr(trim($blockContent), 0, 1) != '<') {
                $blockContent = COM_nl2br($blockContent);
            }
            // autotags are only(!) allowed in normal blocks
            if ($A['allow_autotags'] == 1 && $A['type'] === 'normal') {
                $blockContent = PLG_replaceTags($blockContent);
            }
            $blockContent = str_replace(array('<?', '?>'), '', $blockContent);
            $retval .= COM_startBlock($A['title'], $A['help'], COM_getBlockTemplate($A['name'], 'header', $position)) . $blockContent . LB . COM_endBlock(COM_getBlockTemplate($A['name'], 'footer', $position));
        }
        // Cache only if enabled and not gldefault or dynamic
        if (isset($A['cache_time']) && ($A['cache_time'] > 0 || $A['cache_time'] == -1) && $A['type'] !== 'gldefault') {
            CACHE_create_instance($cacheInstance, $retval);
        }
    }
    return $retval;
}