示例#1
0
/**
* Adds an event to the user's calendar
*
* The user has asked that an event be added to their personal
* calendar.  Show a confirmation screen.
*
* @param    string  $eid    event ID to add to user's calendar
* @return   string          HTML for confirmation form
*
*/
function adduserevent($eid)
{
    global $_CONF, $_TABLES, $LANG_CALJP_1;
    $retval = '';
    $eventsql = "SELECT * FROM {$_TABLES['eventsjp']} WHERE eid='{$eid}'" . COM_getPermSql('AND');
    $result = DB_query($eventsql);
    $nrows = DB_numRows($result);
    if ($nrows == 1) {
        $retval .= COM_startBlock(sprintf($LANG_CALJP_1[11], COM_getDisplayName()));
        $A = DB_fetchArray($result);
        $cal_template = COM_newTemplate($_CONF['path'] . 'plugins/calendarjp/templates/');
        $cal_template->set_file(array('addevent' => 'addevent.thtml'));
        $cal_template->set_var('intro_msg', $LANG_CALJP_1[8]);
        $cal_template->set_var('lang_event', $LANG_CALJP_1[12]);
        $event_title = stripslashes($A['title']);
        if (!empty($A['url']) && $A['url'] != 'http://') {
            $event_title_and_url = COM_createLink($event_title, $A['url'], array('class' => 'url'));
            $cal_template->set_var('event_url', $A['url']);
            $cal_template->set_var('event_begin_anchortag', '<a href="' . $A['url'] . '" class="url">');
            $cal_template->set_var('event_end_anchortag', '</a>');
        } else {
            $event_title_and_url = $event_title;
            $cal_template->set_var('event_url', '');
            $cal_template->set_var('event_begin_anchortag', '');
            $cal_template->set_var('event_end_anchortag', '');
        }
        $cal_template->set_var('event_title', $event_title_and_url);
        $cal_template->set_var('event_title_only', $event_title);
        $cal_template->set_var('lang_starts', $LANG_CALJP_1[13]);
        $cal_template->set_var('lang_ends', $LANG_CALJP_1[14]);
        $thestart = COM_getUserDateTimeFormat($A['datestart'] . ' ' . $A['timestart']);
        $theend = COM_getUserDateTimeFormat($A['dateend'] . ' ' . $A['timeend']);
        if ($A['allday'] == 0) {
            $cal_template->set_var('event_start', $thestart[0]);
            $cal_template->set_var('event_end', $theend[0]);
        } else {
            $cal_template->set_var('event_start', strftime($_CONF['shortdate'], $thestart[1]));
            $cal_template->set_var('event_end', strftime($_CONF['shortdate'], $theend[1]));
        }
        $cal_template->set_var('lang_where', $LANG_CALJP_1[4]);
        $location = stripslashes($A['location']) . '<br' . XHTML . '>' . stripslashes($A['address1']) . '<br' . XHTML . '>' . stripslashes($A['address2']) . '<br' . XHTML . '>' . stripslashes($A['city']) . ', ' . stripslashes($A['state']) . ' ' . $A['zipcode'];
        $cal_template->set_var('event_location', $location);
        $cal_template->set_var('lang_description', $LANG_CALJP_1[5]);
        $description = stripslashes($A['description']);
        if (empty($A['postmode']) || $A['postmode'] == 'plaintext') {
            $description = COM_nl2br($description);
        }
        $cal_template->set_var('event_description', PLG_replaceTags($description));
        $cal_template->set_var('event_id', $eid);
        $cal_template->set_var('lang_addtomycalendar', $LANG_CALJP_1[9]);
        $cal_template->set_var('gltoken_name', CSRF_TOKEN);
        $cal_template->set_var('gltoken', SEC_createToken());
        $cal_template->parse('output', 'addevent');
        $retval .= $cal_template->finish($cal_template->get_var('output'));
        $retval .= COM_endBlock();
    } else {
        $retval .= COM_showMessage(23);
    }
    return $retval;
}
示例#2
0
function HELLO_getListField_hello($fieldname, $fieldvalue, $A, $icon_arr)
{
    global $_CONF;
    switch ($fieldname) {
        case 'see_hello':
            $retval = '';
            $retval .= COM_createLink($icon_arr['list'], "{$_CONF['site_admin_url']}/plugins/hello/read_email.php?mode=edit&amp;hello_id={$A['hello_id']}");
            break;
        case 'creation':
            $creation = COM_getUserDateTimeFormat(strtotime($A['creation']));
            $retval .= $creation[0];
            break;
        default:
            $retval = stripslashes($fieldvalue);
            break;
    }
    return $retval;
}
示例#3
0
function phpblock_shoutblock()
{
    global $_TABLES, $_USER, $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $PHP_SELF, $REMOTE_ADDR, $LANG01, $_CONF;
    $shout_out = "";
    $wrap_width = 20;
    $max_stories = 5;
    $welcome = "Welcome to shoutbox.<p>";
    $shout_out .= $welcome;
    if ($HTTP_POST_VARS["shout_submit"]) {
        $shout_name = addslashes(COM_checkWords(strip_tags($HTTP_POST_VARS["shout_name"])));
        $shout_message = addslashes(COM_checkWords(strip_tags($HTTP_POST_VARS["shout_message"])));
        $result = DB_query("INSERT INTO shoutbox (name,message,time)" . "VALUES (\"{$shout_name}\", \"{$shout_message}\",now() )");
    }
    $count = DB_query("select count(*) as count from shoutbox");
    $A = DB_fetchArray($count);
    $shout_out .= '<b>' . $A['count'] . '</b> shouts already<p>';
    $result = DB_query("select * from shoutbox order by id desc limit {$max_stories}");
    $nrows = DB_numrows($result);
    for ($i = 1; $i <= $nrows; $i++) {
        $A = DB_fetchArray($result);
        $shout_out .= '<b>' . $A['name'] . '</b>';
        $thetime = COM_getUserDateTimeFormat($A['time']);
        $shout_time = $thetime[0];
        $shout_out .= '<i> on ' . $shout_time . '</i><br>';
        $shout_out .= wordwrap($A['message'], $wrap_width, "<br>", 1) . '<br><br>';
    }
    $shout_out .= "\n<form name='shoutform' action='{$PHP_SELF}' method='post'>";
    if (!empty($_USER['uid'])) {
        $shout_out .= '<b>Name: ' . $_USER['username'] . '</b><br>';
        $shout_out .= '<input type="hidden" value="' . $_USER['username'] . '"';
    } else {
        $shout_out .= '<b>Name: Anonymous</b><br>';
        $shout_out .= '<input type="hidden" value="Anonymous"';
    }
    $shout_out .= ' name="shout_name"><b>Message:</b>';
    $shout_out .= "\n<input type='text' value='Your Message' name='shout_message' size=20 maxlength='100'><br>";
    $shout_out .= "\n<input type='submit' name='shout_submit' value='Shout it!'>";
    $shout_out .= "\n</form>";
    return $shout_out;
}
示例#4
0
 /**
  * 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.
  *
  * @param array $row An array of plain data to format
  * @return array A reformatted version of the input array
  *
  */
 public function searchFormatCallback($preSort, $row)
 {
     global $_CONF, $LANG09;
     if ($preSort) {
         if (is_array($row[LF_SOURCE_TITLE])) {
             $row[LF_SOURCE_TITLE] = implode($_CONF['search_separator'], $row[LF_SOURCE_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&amp;uid=' . $row['uid']);
                 }
             }
             $row['uid'] = $this->_names[$row['uid']];
         }
     } else {
         $row[LF_SOURCE_TITLE] = COM_createLink($row[LF_SOURCE_TITLE], $this->_searchURL . '&amp;type=' . $row[LF_SOURCE_NAME] . '&amp;mode=search');
         if ($row['url'] != '#') {
             $row['url'] = ($row['url'][0] == '/' ? $_CONF['site_url'] : '') . $row['url'];
             if (isset($this->_url_rewrite[$row[LF_SOURCE_NAME]]) && $this->_url_rewrite[$row[LF_SOURCE_NAME]]) {
                 $row['url'] = COM_buildUrl($row['url']);
             }
             if (isset($this->_append_query[$row[LF_SOURCE_NAME]]) && $this->_append_query[$row[LF_SOURCE_NAME]]) {
                 if (!empty($this->_query)) {
                     $row['url'] .= (strpos($row['url'], '?') ? '&amp;' : '?') . 'query=' . urlencode($this->_query);
                 }
             }
         }
         $row['title'] = $this->_shortenText($this->_query, $row['title'], 8);
         $row['title'] = stripslashes(str_replace('$', '&#36;', $row['title']));
         $row['title'] = COM_createLink($row['title'], $row['url']);
         if ($row['description'] == 'LF_NULL') {
             $row['description'] = '<i>' . $LANG09[70] . '</i>';
         } elseif ($row['description'] != '<i>' . $LANG09[70] . '</i>') {
             $row['description'] = stripslashes($this->_shortenText($this->_query, PLG_replaceTags($row['description']), $this->_wordlength));
         }
         if ($row['date'] != 'LF_NULL') {
             $dt = COM_getUserDateTimeFormat(intval($row['date']));
             $row['date'] = $dt[0];
         }
         if ($row['hits'] != 'LF_NULL') {
             $row['hits'] = COM_NumberFormat($row['hits']) . ' ';
             // simple solution to a silly problem!
         }
     }
     return $row;
 }
示例#5
0
     $csscode = 1;
     for ($i = 1; $i <= $nrows; $i++) {
         $P = DB_fetchArray($result);
         $fres = DB_query("SELECT grp_id,rating_view FROM {$_TABLES['ff_forums']} WHERE forum_id=" . (int) $P['forum']);
         list($forumgrpid, $view_rating) = DB_fetchArray($fres);
         $groupname = DB_getItem($_TABLES['groups'], 'grp_name', "grp_id=" . (int) $forumgrpid);
         if (SEC_inGroup($groupname)) {
             if ($_FF_CONF['enable_user_rating_system'] && !COM_isAnonUser()) {
                 if ($view_rating > $user_rating) {
                     continue;
                 }
             }
             if ($_FF_CONF['use_censor']) {
                 $P['subject'] = COM_checkWords($P['subject']);
             }
             $postdate = COM_getUserDateTimeFormat($P['date']);
             $link = '<a href="' . $_CONF['site_url'] . '/forum/viewtopic.php?forum=' . $P['forum'] . '&amp;showtopic=' . $P['id'] . '&amp;highlight=' . htmlentities($html_query, ENT_QUOTES, COM_getEncodingt()) . '">';
             $report->set_var(array('post_start_ahref' => $link, 'post_subject' => $P['subject'], 'post_end_ahref' => '</a>', 'post_date' => $postdate[0], 'post_replies' => $P['replies'], 'post_views' => $P['views'], 'csscode' => $csscode));
             $report->parse('rrow', 'reportrow', true);
             if ($csscode == 2) {
                 $csscode = 1;
             } else {
                 $csscode++;
             }
         }
     }
 }
 if ($forum == 0) {
     $link = '<p><a href="' . $_CONF['site_url'] . '/forum/index.php">' . $LANG_GF02['msg175'] . '</a></p>';
     $report->set_var('bottomlink', $link);
 } else {
示例#6
0
/**
* Shows a profile for a user
*
* This grabs the user profile for a given user and displays it
*
* @return   string          HTML for user profile page
*
*/
function userprofile()
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG04, $LANG09, $LANG28, $LANG_LOGIN;
    // @param    int     $user   User ID of profile to get
    // @param    int     $msg    Message to display (if != 0)
    // @param    string  $plugin optional plugin name for message
    $retval = '';
    if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['profileloginrequired'] == 1)) {
        $retval .= SEC_loginRequiredForm();
        return $retval;
    }
    if (isset($_GET['uid'])) {
        $user = COM_applyFilter($_GET['uid'], true);
        if (!is_numeric($user) || $user < 2) {
            echo COM_refresh($_CONF['site_url'] . '/index.php');
        }
    } else {
        if (isset($_GET['username'])) {
            $username = $_GET['username'];
            if (!USER_validateUsername($username, 1)) {
                echo COM_refresh($_CONF['site_url'] . '/index.php');
            }
            if (empty($username) || $username == '') {
                echo COM_refresh($_CONF['site_url'] . '/index.php');
            }
            $username = DB_escapeString($username);
            $user = DB_getItem($_TABLES['users'], 'uid', "username = '******'");
            if ($user < 2) {
                echo COM_refresh($_CONF['site_url'] . '/index.php');
            }
        } else {
            echo COM_refresh($_CONF['site_url'] . '/index.php');
        }
    }
    $msg = 0;
    if (isset($_GET['msg'])) {
        $msg = COM_applyFilter($_GET['msg'], true);
    }
    $plugin = '';
    if ($msg > 0 && isset($_GET['plugin'])) {
        $plugin = COM_applyFilter($_GET['plugin']);
    }
    $result = DB_query("SELECT {$_TABLES['users']}.uid,username,fullname,regdate,lastlogin,homepage,about,location,pgpkey,photo,email,status,emailfromadmin,emailfromuser,showonline FROM {$_TABLES['userinfo']},{$_TABLES['userprefs']},{$_TABLES['users']} WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid AND {$_TABLES['userinfo']}.uid = {$_TABLES['userprefs']}.uid AND {$_TABLES['users']}.uid = " . (int) $user);
    $nrows = DB_numRows($result);
    if ($nrows == 0) {
        // no such user
        echo COM_refresh($_CONF['site_url'] . '/index.php');
    }
    $A = DB_fetchArray($result);
    if ($A['status'] == USER_ACCOUNT_DISABLED && !SEC_hasRights('user.edit')) {
        COM_displayMessageAndAbort(30, '', 403, 'Forbidden');
    }
    $display_name = @htmlspecialchars(COM_getDisplayName($user, $A['username'], $A['fullname']), ENT_COMPAT, COM_getEncodingt());
    if ($msg > 0) {
        $retval .= COM_showMessage($msg, $plugin, '', 0, 'info');
    }
    // format date/time to user preference
    $curtime = COM_getUserDateTimeFormat($A['regdate']);
    $A['regdate'] = $curtime[0];
    $user_templates = new Template($_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('layout_url', $_CONF['layout_url']);
    $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]);
    $user_templates->set_var('tooltip', COM_getTooltipStyle());
    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 = '';
    }
    $username = @htmlspecialchars($username, ENT_COMPAT, COM_getEncodingt());
    $fullname = @htmlspecialchars($fullname, ENT_COMPAT, COM_getEncodingt());
    if ($A['status'] == USER_ACCOUNT_DISABLED) {
        $username = sprintf('%s - %s', $username, $LANG28[42]);
        if (!empty($fullname)) {
            $fullname = sprintf('% - %s', $fullname, $LANG28[42]);
        }
    }
    $user_templates->set_var('username', $username);
    $user_templates->set_var('user_fullname', $fullname);
    if (SEC_hasRights('user.edit') || isset($_USER['uid']) && $_USER['uid'] == $A['uid']) {
        global $_IMAGE_TYPE, $LANG_ADMIN;
        $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG_ADMIN['edit'] . '" title="' . $LANG_ADMIN['edit'] . '" />';
        if ($_USER['uid'] == $A['uid']) {
            $edit_url = "{$_CONF['site_url']}/usersettings.php";
        } else {
            $edit_url = "{$_CONF['site_admin_url']}/user.php?edit=x&amp;uid={$A['uid']}";
        }
        $edit_link_url = COM_createLink($edit_icon, $edit_url);
        $user_templates->set_var('edit_icon', $edit_icon);
        $user_templates->set_var('edit_link', $edit_link_url);
        $user_templates->set_var('user_edit', $edit_url);
    } else {
        $user_templates->set_var('user_edit', '');
    }
    if (isset($A['photo']) && empty($A['photo'])) {
        $A['photo'] = '(none)';
        // user does not have a photo
    }
    $lastlogin = $A['lastlogin'];
    $lasttime = COM_getUserDateTimeFormat($lastlogin);
    $photo = USER_getPhoto($user, $A['photo'], $A['email'], -1, 0);
    $user_templates->set_var('user_photo', $photo);
    $user_templates->set_var('lang_membersince', $LANG04[67]);
    $user_templates->set_var('user_regdate', $A['regdate']);
    if ($_CONF['lastlogin'] && $A['showonline']) {
        $user_templates->set_var('lang_lastlogin', $LANG28[35]);
        if (!empty($lastlogin)) {
            $user_templates->set_var('user_lastlogin', $lasttime[0]);
        } else {
            $user_templates->set_var('user_lastlogin', $LANG28[36]);
        }
    }
    if ($A['showonline']) {
        if (DB_count($_TABLES['sessions'], 'uid', (int) $user)) {
            $user_templates->set_var('online', 'online');
        }
    }
    $user_templates->set_var('lang_email', $LANG04[5]);
    $user_templates->set_var('user_id', $user);
    if ($A['email'] == '' || $A['emailfromuser'] == 0) {
        $user_templates->set_var('email_option', '');
    } else {
        $user_templates->set_var('lang_sendemail', $LANG04[81]);
        $user_templates->parse('email_option', 'email', true);
    }
    $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_online', $LANG04[160]);
    $user_templates->set_var('lang_bio', $LANG04[7]);
    $user_templates->set_var('user_bio', nl2br($A['about']));
    $user_templates->set_var('follow_me', SOC_getFollowMeIcons($user, 'follow_user_profile.thtml'));
    $user_templates->set_var('lang_pgpkey', $LANG04[8]);
    $user_templates->set_var('user_pgp', nl2br($A['pgpkey']));
    $user_templates->set_var('start_block_last10stories', COM_startBlock($LANG04[82] . ' ' . $display_name));
    if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') {
        $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] . ' ' . $display_name);
    if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') {
        $user_templates->set_var('headline_last10comments', $LANG04[10] . ' ' . $display_name);
    }
    $user_templates->set_var('headline_postingstats', $LANG04[83] . ' ' . $display_name);
    $result = DB_query("SELECT tid FROM {$_TABLES['topics']}" . COM_getPermSQL());
    $nrows = DB_numRows($result);
    $tids = array();
    for ($i = 0; $i < $nrows; $i++) {
        $T = DB_fetchArray($result);
        $tids[] = $T['tid'];
    }
    $topics = "'" . implode("','", $tids) . "'";
    // list of last 10 stories by this user
    if (sizeof($tids) > 0) {
        $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} WHERE (uid = '" . (int) $user . "') AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND');
        $sql .= " ORDER BY unixdate DESC LIMIT 10";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
    } else {
        $nrows = 0;
    }
    if ($nrows > 0) {
        for ($i = 0; $i < $nrows; $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($C['title'], $articleUrl, array('class' => '')));
            $storytime = COM_getUserDateTimeFormat($C['unixdate']);
            $user_templates->set_var('story_date', $storytime[0]);
            $user_templates->parse('story_row', 'strow', true);
        }
    } else {
        $user_templates->set_var('story_row', '<tr><td>' . $LANG01[37] . '</td></tr>');
    }
    if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') {
        // list of last 10 comments by this user
        $sidArray = array();
        if (sizeof($tids) > 0) {
            // first, get a list of all stories the current visitor has access to
            $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND');
            $result = DB_query($sql);
            $numsids = DB_numRows($result);
            for ($i = 1; $i <= $numsids; $i++) {
                $S = DB_fetchArray($result);
                $sidArray[] = $S['sid'];
            }
        }
        $sidList = implode("', '", $sidArray);
        $sidList = "'{$sidList}'";
        // then, find all comments by the user in those stories
        $sql = "SELECT sid,title,cid,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['comments']} WHERE (uid = '" . (int) $user . "') GROUP BY sid,title,cid,UNIX_TIMESTAMP(date)";
        // SQL NOTE:  Using a HAVING clause is usually faster than a where if the
        // field is part of the select
        // if (!empty ($sidList)) {
        //     $sql .= " AND (sid in ($sidList))";
        // }
        if (!empty($sidList)) {
            $sql .= " HAVING sid in ({$sidList})";
        }
        $sql .= " ORDER BY unixdate DESC LIMIT 10";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        if ($nrows > 0) {
            for ($i = 0; $i < $nrows; $i++) {
                $C = DB_fetchArray($result);
                $user_templates->set_var('cssid', $i % 2 + 1);
                $user_templates->set_var('row_number', $i + 1 . '.');
                $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($C['title'], $comment_url, array('class' => '')));
                $commenttime = COM_getUserDateTimeFormat($C['unixdate']);
                $user_templates->set_var('comment_date', $commenttime[0]);
                $user_templates->parse('comment_row', 'row', true);
            }
        } else {
            $user_templates->set_var('comment_row', '<tr><td>' . $LANG01[29] . '</td></tr>');
        }
    }
    // posting stats for this user
    $user_templates->set_var('lang_number_stories', $LANG04[84]);
    $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (uid = " . (int) $user . ") 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']));
    if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') {
        $user_templates->set_var('lang_number_comments', $LANG04[85]);
        $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['comments']} WHERE (uid = " . (int) $user . ")";
        if (!empty($sidList)) {
            $sql .= " AND (sid in ({$sidList}))";
        }
        $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);
    }
    // hook to the profile icon display
    $profileIcons = PLG_profileIconDisplay($user);
    if (is_array($profileIcons) && count($profileIcons) > 0) {
        $user_templates->set_block('profile', 'profileicon', 'pi');
        for ($x = 0; $x < count($profileIcons); $x++) {
            if (isset($profileIcons[$x]['url']) && $profileIcons[$x]['url'] != '' && isset($profileIcons[$x]['icon']) && $profileIcons[$x]['icon'] != '') {
                $user_templates->set_var('profile_icon_url', $profileIcons[$x]['url']);
                $user_templates->set_var('profile_icon_icon', $profileIcons[$x]['icon']);
                $user_templates->set_var('profile_icon_text', $profileIcons[$x]['text']);
                $user_templates->parse('pi', 'profileicon', true);
            }
        }
    }
    // Call custom registration function if enabled and exists
    if ($_CONF['custom_registration'] && function_exists('CUSTOM_userDisplay')) {
        $user_templates->set_var('customfields', CUSTOM_userDisplay($user));
    }
    PLG_profileVariablesDisplay($user, $user_templates);
    $user_templates->parse('output', 'profile');
    $retval .= $user_templates->finish($user_templates->get_var('output'));
    $retval .= PLG_profileBlocksDisplay($user);
    return $retval;
}
示例#7
0
/**
 * This function creates an Ad Form
 *
 * Creates an Form for an Ad using the supplied defaults (if specified).
 *
 * @param array $ad array of values describing an Ad
 * @return string HTML string of Ad form
 */
function CLASSIFIEDS_getAdForm($ad = array(), $copy = false)
{
    global $_CONF, $_CLASSIFIEDS_CONF, $LANG_CLASSIFIEDS_2, $LANG_CLASSIFIEDS_ADMIN, $_TABLES, $LANG24, $LANG_ADMIN, $_USER;
    if ($_USER['uid'] < 2) {
        return CLASSIFIEDS_loginRequiredForm();
    }
    if (!SEC_hasRights('classifieds.publish')) {
        //Give publish rights to logged-in users if there is no group with this feature
        $ft_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'classifieds.publish'");
        $grp_id = DB_getItem($_TABLES['access'], 'acc_grp_id', "acc_ft_id = {$ft_id}");
        //COM_errorLog('Classifieds feature: ' . $ft_id . ' | Group: ' . $grp_id );
        if ($grp_id == '') {
            // Give access
        } else {
            // Display message
            return $LANG_CLASSIFIEDS_2['access_reserved'] . ' <strong>"' . DB_getItem($_TABLES['groups'], 'grp_name', "grp_id = {$grp_id}") . '"</strong>';
        }
    }
    $active = true;
    if ($ad != '') {
        $created = COM_getUserDateTimeFormat($A['created']);
        $active_days = (time() - $created['1']) / (24 * 3600);
        if ($active_days > $_CLASSIFIEDS_CONF['active_days']) {
            $active = false;
        }
        if ((SEC_hasAccess2($ad) != 3 || $ad['deleted'] == 1 || $active == false) && !SEC_hasRights('classifieds.admin')) {
            echo COM_refresh($_CLASSIFIEDS_CONF['site_url'] . "/index.php?error=0");
            exit;
        }
    }
    //Display form
    $ad['clid'] == '' ? $retval = COM_startBlock($LANG_CLASSIFIEDS_2['insert_new_ad']) : ($retval = COM_startBlock($LANG_CLASSIFIEDS_2['edit_label'] . ' ' . $ad['title']));
    $template = new Template($_CONF['path'] . 'plugins/classifieds/templates');
    $template->set_file(array('ad' => 'ad_form.thtml'));
    $template->set_var('site_url', $_CLASSIFIEDS_CONF['site_url']);
    $template->set_var('xhtml', XHTML);
    $template->set_var('gltoken_name', CSRF_TOKEN);
    $template->set_var('gltoken', SEC_createToken());
    if (is_numeric($ad['clid'])) {
        $template->set_var('clid', '<input type="hidden" name="clid" value="' . $ad['clid'] . '" />');
    } else {
        $template->set_var('clid', '');
    }
    //Your Ad
    $template->set_var('your_ad', $LANG_CLASSIFIEDS_2['your_ad']);
    //category
    $categories = '';
    $template->set_var('category_label', $LANG_CLASSIFIEDS_2['category']);
    $categories .= '<option value="0">' . $LANG_CLASSIFIEDS_2['choose_category'] . '</option>';
    $categories .= CLASSIFIEDS_adOptionList($_TABLES['cl_cat'], 'cid,category,pid', $ad['catid'], 'catorder', "catdeleted=0");
    $template->set_var('categories', $categories);
    //type
    $template->set_var('type_label', $LANG_CLASSIFIEDS_2['type']);
    if ($ad['type'] == '1') {
        $template->set_var('type_d', ' selected');
        $template->set_var('type_o', '');
    } elseif ($ad['type'] == '0') {
        $template->set_var('type_d', '');
        $template->set_var('type_o', ' selected');
    } else {
        $template->set_var('type_d', '');
        $template->set_var('type_o', '');
    }
    $choosetype = '<option value="-1">' . $LANG_CLASSIFIEDS_2['choose_type'] . '</option>';
    $template->set_var('choose_type', $choosetype);
    $template->set_var('offer', $LANG_CLASSIFIEDS_2['offer']);
    $template->set_var('demand', $LANG_CLASSIFIEDS_2['demand']);
    //title
    $template->set_var('title_label', $LANG_CLASSIFIEDS_2['title']);
    $template->set_var('title', $ad['title']);
    $template->set_var('currency', $_CLASSIFIEDS_CONF['currency']);
    //text
    $template->set_var('text_label', $LANG_CLASSIFIEDS_2['text']);
    $template->set_var('text', $ad['text']);
    //Price
    $template->set_var('price_label', $LANG_CLASSIFIEDS_2['price']);
    $template->set_var('price', number_format(floatval($ad['price']), $_CONF['decimal_count']));
    //images
    $template->set_var('images', $LANG_CLASSIFIEDS_2['images']);
    $fileinputs = '';
    $saved_images = '';
    if ($_CLASSIFIEDS_CONF['max_images_per_ad'] > 0) {
        if ($ad['clid'] != '') {
            $icount = DB_count($_TABLES['cl_pic'], 'pi_pid', $ad['clid']);
            if ($icount > 0) {
                $result_pics = DB_query("SELECT * FROM {$_TABLES['cl_pic']} WHERE pi_pid = '" . $ad['clid'] . "'");
                for ($z = 1; $z <= $icount; $z++) {
                    $I = DB_fetchArray($result_pics);
                    $saved_images .= '<div><p>' . $z . ') ' . '<a class="lightbox" href="' . $_CLASSIFIEDS_CONF['site_url'] . '/timthumb.php?src=' . $_CLASSIFIEDS_CONF['url_images'] . $I['pi_filename'] . '&amp;w=640"><img src="' . $_CLASSIFIEDS_CONF['site_url'] . '/timthumb.php?src=' . $_CLASSIFIEDS_CONF['url_images'] . $I['pi_filename'] . '&amp;w=' . $size . '&amp;h=' . $size . '" align="top" alt="' . $A['title'] . '" /></a>' . '&nbsp;&nbsp;&nbsp;' . $LANG_ADMIN['delete'] . ': <input type="checkbox" name="delete[' . $I['pi_img_num'] . ']"' . XHTML . '><br' . XHTML . '></p></div>';
                }
            }
        }
        $newallowed = $_CLASSIFIEDS_CONF['max_images_per_ad'] - $icount;
        for ($z = $icount + 1; $z <= $_CLASSIFIEDS_CONF['max_images_per_ad']; $z++) {
            $fileinputs .= $z . ') <input type="file" dir="ltr" name="file' . $z . '"' . XHTML . '> ';
            if ($z < $_CLASSIFIEDS_CONF['max_images_per_ad']) {
                $fileinputs .= '<br' . XHTML . '>';
            }
        }
    }
    $template->set_var('saved_images', $saved_images);
    $template->set_var('image_form_elements', $fileinputs);
    //your details
    if (!is_numeric($ad['clid'])) {
        $data = DB_query("SELECT *\n            FROM {$_TABLES['cl_users']} \n\t\t\tWHERE user_id = {$_USER['uid']}\n\t\t");
        $user_data = DB_fetchArray($data, true);
        $ad['status'] = $user_data['status'];
        $ad['tel'] = $user_data['tel'];
        $ad['postcode'] = $user_data['postcode'];
        $ad['city'] = $user_data['city'];
        $ad['siren'] = $user_data['siren'];
    }
    $template->set_var('your_details', $LANG_CLASSIFIEDS_2['your_details']);
    $template->set_var('status_label', $LANG_CLASSIFIEDS_2['status']);
    $template->set_var('private', $LANG_CLASSIFIEDS_2['private']);
    $template->set_var('professional', $LANG_CLASSIFIEDS_2['professional']);
    if ($ad['status'] == '1') {
        $template->set_var('pro_yes', ' selected');
        $template->set_var('pro_no', '');
    } elseif ($ad['status'] == '0') {
        $template->set_var('pro_yes', '');
        $template->set_var('pro_no', ' selected');
    } else {
        $template->set_var('pro_no', '');
        $template->set_var('pro_yes', '');
    }
    $choose_status = '<option value="-1">' . $LANG_CLASSIFIEDS_2['choose_status'] . '</option>';
    $template->set_var('choose_status', $choose_status);
    $template->set_var('siren_label', $LANG_CLASSIFIEDS_2['siren']);
    $template->set_var('siren', $ad['siren']);
    $template->set_var('tel_label', $LANG_CLASSIFIEDS_2['tel']);
    $template->set_var('tel', $ad['tel']);
    $template->set_var('hide_tel_label', $LANG_CLASSIFIEDS_2['hide_tel']);
    $template->set_var('hide_tel', $ad['hide_tel']);
    if ($ad['hide_tel'] == '1') {
        $template->set_var('tel_ckecked', ' checked="checked"');
    } else {
        $template->set_var('tel_ckecked', '');
    }
    $template->set_var('postcode_label', $LANG_CLASSIFIEDS_2['postcode']);
    $template->set_var('postcode', $ad['postcode']);
    $template->set_var('city_label', $LANG_CLASSIFIEDS_2['city']);
    $template->set_var('city', $ad['city']);
    //submit
    $template->set_var('save_button', $LANG_CLASSIFIEDS_2['save_button']);
    $template->set_var('delete_button', $LANG_CLASSIFIEDS_2['delete_button']);
    $template->set_var('validate_button', $LANG_CLASSIFIEDS_2['validate_button']);
    $template->set_var('required_field', $LANG_CLASSIFIEDS_2['required_field']);
    //Admin options
    if (SEC_hasRights('classifieds.admin')) {
        $admin_select = LB . '<select name="op">' . LB;
        if (!$copy) {
            $admin_select .= '<option value="save" selected="selected">' . $LANG_CLASSIFIEDS_2['save_button'] . '</option>' . LB;
            if ($ad['clid'] != '') {
                $admin_select .= '<option value="delete">' . $LANG_CLASSIFIEDS_2['delete_button'] . '</option>' . LB;
            }
        }
        if (function_exists('CLASSIFIEDS_getBonusAdminButton') && $ad['clid'] != '') {
            $admin_select .= CLASSIFIEDS_getBonusAdminButton();
        }
        $admin_select .= LB . '</select>' . LB;
        $template->set_var('admin_options', $admin_select);
        $datecreated = COM_getUserDateTimeFormat($ad['created']);
        $datemodified = COM_getUserDateTimeFormat($ad['modified']);
        $template->set_var('created', '<p>' . $LANG_CLASSIFIEDS_ADMIN['created'] . $LANG_CLASSIFIEDS_1['double_point'] . ' ' . $datecreated[0] . '</p>');
        $template->set_var('modified', '<p>' . $LANG_CLASSIFIEDS_ADMIN['modified'] . $LANG_CLASSIFIEDS_1['double_point'] . ' ' . $datemodified[0] . '</p>');
    } else {
        $template->set_var('admin_options', '');
        $template->set_var('created', '');
        $template->set_var('modified', '');
    }
    $retval .= $template->parse('output', 'ad');
    $retval .= COM_endBlock();
    return $retval;
}
示例#8
0
/**
* Shows a profile for a user
*
* This grabs the user profile for a given user and displays it
*
* @param    int     $user   User ID of profile to get
* @param    int     $msg    Message to display (if != 0)
* @return   string          HTML for user profile page
*
*/
function userprofile($user, $msg = 0)
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG04, $LANG09, $LANG_LOGIN;
    $retval = '';
    if (empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['profileloginrequired'] == 1)) {
        $retval .= COM_siteHeader('menu');
        $retval .= COM_startBlock($LANG_LOGIN[1], '', COM_getBlockTemplate('_msg_block', 'header'));
        $login = new Template($_CONF['path_layout'] . 'submit');
        $login->set_file(array('login' => 'submitloginrequired.thtml'));
        $login->set_var('xhtml', XHTML);
        $login->set_var('login_message', $LANG_LOGIN[2]);
        $login->set_var('site_url', $_CONF['site_url']);
        $login->set_var('site_admin_url', $_CONF['site_admin_url']);
        $login->set_var('layout_url', $_CONF['layout_url']);
        $login->set_var('lang_login', $LANG_LOGIN[3]);
        $login->set_var('lang_newuser', $LANG_LOGIN[4]);
        $login->parse('output', 'login');
        $retval .= $login->finish($login->get_var('output'));
        $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
        $retval .= COM_siteFooter();
        return $retval;
    }
    $result = DB_query("SELECT {$_TABLES['users']}.uid,username,fullname,regdate,homepage,about,location,pgpkey,photo,email FROM {$_TABLES['userinfo']},{$_TABLES['users']} WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid AND {$_TABLES['users']}.uid = {$user}");
    $nrows = DB_numRows($result);
    if ($nrows == 0) {
        // no such user
        return COM_refresh($_CONF['site_url'] . '/index.php');
    }
    $A = DB_fetchArray($result);
    $display_name = COM_getDisplayName($user, $A['username'], $A['fullname']);
    // format date/time to user preference
    $curtime = COM_getUserDateTimeFormat($A['regdate']);
    $A['regdate'] = $curtime[0];
    $user_templates = new Template($_CONF['path_layout'] . 'users');
    $user_templates->set_file(array('profile' => 'profile.thtml', 'row' => 'commentrow.thtml', 'strow' => 'storyrow.thtml'));
    $user_templates->set_var('xhtml', XHTML);
    $user_templates->set_var('site_url', $_CONF['site_url']);
    $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) {
        $user_templates->set_var('username', $A['fullname']);
        $user_templates->set_var('user_fullname', $A['username']);
    } else {
        $user_templates->set_var('username', $A['username']);
        $user_templates->set_var('user_fullname', $A['fullname']);
    }
    if (SEC_hasRights('user.edit')) {
        global $_IMAGE_TYPE, $LANG_ADMIN;
        $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_link', $edit_link_url);
    }
    $photo = USER_getPhoto($user, $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', $user);
    $user_templates->set_var('lang_sendemail', $LANG04[81]);
    $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', nl2br(stripslashes($A['about'])));
    $user_templates->set_var('lang_pgpkey', $LANG04[8]);
    $user_templates->set_var('user_pgp', 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]);
    $result = DB_query("SELECT tid FROM {$_TABLES['topics']}" . COM_getPermSQL());
    $nrows = DB_numRows($result);
    $tids = array();
    for ($i = 0; $i < $nrows; $i++) {
        $T = DB_fetchArray($result);
        $tids[] = $T['tid'];
    }
    $topics = "'" . implode("','", $tids) . "'";
    // list of last 10 stories by this user
    if (count($tids) > 0) {
        $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} WHERE (uid = {$user}) AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND');
        $sql .= " ORDER BY unixdate DESC LIMIT 10";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
    } else {
        $nrows = 0;
    }
    if ($nrows > 0) {
        for ($i = 0; $i < $nrows; $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 {
        $user_templates->set_var('story_row', '<tr><td>' . $LANG01[37] . '</td></tr>');
    }
    // list of last 10 comments by this user
    $sidArray = array();
    if (count($tids) > 0) {
        // first, get a list of all stories the current visitor has access to
        $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND');
        $result = DB_query($sql);
        $numsids = DB_numRows($result);
        for ($i = 1; $i <= $numsids; $i++) {
            $S = DB_fetchArray($result);
            $sidArray[] = $S['sid'];
        }
    }
    $sidList = implode("', '", $sidArray);
    $sidList = "'{$sidList}'";
    // then, find all comments by the user in those stories
    $sql = "SELECT sid,title,cid,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['comments']} WHERE (uid = {$user}) GROUP BY sid,title,cid,UNIX_TIMESTAMP(date)";
    // SQL NOTE:  Using a HAVING clause is usually faster than a where if the
    // field is part of the select
    // if (!empty ($sidList)) {
    //     $sql .= " AND (sid in ($sidList))";
    // }
    if (!empty($sidList)) {
        $sql .= " HAVING sid in ({$sidList})";
    }
    $sql .= " ORDER BY unixdate DESC LIMIT 10";
    $result = DB_query($sql);
    $nrows = DB_numRows($result);
    if ($nrows > 0) {
        for ($i = 0; $i < $nrows; $i++) {
            $C = DB_fetchArray($result);
            $user_templates->set_var('cssid', $i % 2 + 1);
            $user_templates->set_var('row_number', $i + 1 . '.');
            $comment_url = $_CONF['site_url'] . '/comment.php?mode=view&amp;cid=' . $C['cid'];
            $C['title'] = str_replace('$', '&#36;', $C['title']);
            $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);
        }
    } else {
        $user_templates->set_var('comment_row', '<tr><td>' . $LANG01[29] . '</td></tr>');
    }
    // posting stats for this user
    $user_templates->set_var('lang_number_stories', $LANG04[84]);
    $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (uid = {$user}) 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 = {$user})";
    if (!empty($sidList)) {
        $sql .= " AND (sid in ({$sidList}))";
    }
    $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($user));
    }
    PLG_profileVariablesDisplay($user, $user_templates);
    $user_templates->parse('output', 'profile');
    $retval .= $user_templates->finish($user_templates->get_var('output'));
    $retval .= PLG_profileBlocksDisplay($user);
    return $retval;
}
示例#9
0
/**
* This function used to send out reminders to users to access the site or account may be deleted
*
* @return   string          HTML with success or error message
*
*/
function USER_sendReminders()
{
    global $_CONF, $_TABLES, $LANG04, $LANG28;
    $msg = '';
    $user_list = array();
    if (isset($_POST['delitem'])) {
        $user_list = $_POST['delitem'];
    }
    $nusers = count($user_list);
    if (count($user_list) == 0) {
        $msg = $LANG28[79] . '<br/>';
    } else {
        $c = 0;
        if (isset($_POST['delitem']) and is_array($_POST['delitem'])) {
            foreach ($_POST['delitem'] as $delitem) {
                $uid = COM_applyFilter($delitem);
                $useremail = DB_getItem($_TABLES['users'], 'email', "uid = '{$uid}'");
                $username = DB_getItem($_TABLES['users'], 'username', "uid = '{$uid}'");
                $lastlogin = DB_getItem($_TABLES['userinfo'], 'lastlogin', "uid = '{$uid}'");
                $lasttime = COM_getUserDateTimeFormat($lastlogin);
                if (file_exists($_CONF['path_data'] . 'reminder_email.txt')) {
                    $template = new Template($_CONF['path_data']);
                    $template->set_file(array('mail' => 'reminder_email.txt'));
                    $template->set_var('site_url', $_CONF['site_url']);
                    $template->set_var('site_name', $_CONF['site_name']);
                    $template->set_var('site_slogan', $_CONF['site_slogan']);
                    $template->set_var('lang_username', $LANG04[2]);
                    $template->set_var('username', $username);
                    $template->set_var('name', COM_getDisplayName($uid));
                    $template->set_var('lastlogin', $lasttime[0]);
                    $template->parse('output', 'mail');
                    $mailtext = $template->get_var('output');
                } else {
                    if ($lastlogin == 0) {
                        $mailtext = $LANG28[83] . "\n\n";
                    } else {
                        $mailtext = sprintf($LANG28[82], $lasttime[0]) . "\n\n";
                    }
                    $mailtext .= sprintf($LANG28[84], $username) . "\n";
                    $mailtext .= sprintf($LANG28[85], $_CONF['site_url'] . '/users.php?mode=getpassword') . "\n\n";
                }
                $subject = sprintf($LANG28[81], $_CONF['site_name']);
                if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) {
                    $mailfrom = $_CONF['noreply_mail'];
                    global $LANG_LOGIN;
                    $mailtext .= LB . LB . $LANG04[159];
                } else {
                    $mailfrom = $_CONF['site_mail'];
                }
                $to = array();
                $to = COM_formatEmailAddress($username, $useremail);
                $from = array();
                $from = COM_formatEmailAddress('', $mailfrom);
                if (COM_mail($to, $subject, $mailtext, $from)) {
                    DB_query("UPDATE {$_TABLES['users']} SET num_reminders=num_reminders+1 WHERE uid={$uid}");
                    $c++;
                } else {
                    COM_errorLog("Error attempting to send account reminder to user: {$username} ({$uid})");
                }
            }
        }
        COM_numberFormat($c);
        // just in case we have more than 999)..
        $msg .= "{$LANG28[80]}: {$c}<br/>\n";
    }
    return $msg;
}
示例#10
0
function fncEdit($id, $edt_flg, $msg = '', $errmsg = "", $mode = "edit")
{
    $pi_name = "userbox";
    global $_CONF;
    global $_TABLES;
    global $LANG_ADMIN;
    global $MESSAGE;
    global $LANG_ACCESS;
    global $_USER;
    global $LANG28;
    global $_SCRIPTS;
    global $_USERBOX_CONF;
    global $LANG_USERBOX_ADMIN;
    global $LANG_USERBOX;
    $retval = '';
    $delflg = false;
    $addition_def = DATABOX_getadditiondef($pi_name);
    //メッセージ表示
    if (!empty($msg)) {
        $retval .= COM_showMessage($msg, $pi_name);
        $retval .= $errmsg;
        // clean 'em up
        $code = COM_applyFilter($_POST['code']);
        //@@@@@
        $title = COM_applyFilter($_POST['title']);
        //@@@@@
        $username = COM_applyFilter($_POST['username']);
        //@@@@@
        $fullname = COM_applyFilter($_POST['fullname']);
        //@@@@@
        $page_title = COM_applyFilter($_POST['page_title']);
        $description = $_POST['description'];
        //COM_applyFilter($_POST['description']);
        $defaulttemplatesdirectory = COM_applyFilter($_POST['defaulttemplatesdirectory']);
        //@@@@@@
        $draft_flag = COM_applyFilter($_POST['draft_flag'], true);
        $hits = COM_applyFilter($_POST['hits'], true);
        $comments = COM_applyFilter($_POST['comments'], true);
        $commentcode = COM_applyFilter($_POST['commentcode'], true);
        $trackbackcode = COM_applyFilter($_POST['trackbackcode'], true);
        $cache_time = COM_applyFilter($_POST['cache_time'], true);
        //@@@@@
        $comment_expire_flag = COM_applyFilter($_POST['comment_expire_flag'], true);
        if ($comment_expire_flag === 0) {
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $comment_expire_year = date('Y', $w);
            $comment_expire_month = date('m', $w);
            $comment_expire_day = date('d', $w);
            $comment_expire_hour = 0;
            $comment_expire_minute = 0;
        } else {
            $comment_expire_month = COM_applyFilter($_POST['comment_expire_month'], true);
            $comment_expire_day = COM_applyFilter($_POST['comment_expire_day'], true);
            $comment_expire_year = COM_applyFilter($_POST['comment_expire_year'], true);
            $comment_expire_hour = COM_applyFilter($_POST['comment_expire_hour'], true);
            $comment_expire_minute = COM_applyFilter($_POST['comment_expire_minute'], true);
        }
        $meta_description = COM_applyFilter($_POST['meta_description']);
        $meta_keywords = COM_applyFilter($_POST['meta_keywords']);
        $language_id = COM_applyFilter($_POST['language_id']);
        $category = $_POST['category'];
        $additionfields = $_POST['afield'];
        $additionfields_fnm = $_POST['afield_fnm'];
        //@@@@@
        $additionfields_del = $_POST['afield_del'];
        $additionfields_date = array();
        $additionfields_alt = $_POST['afield_alt'];
        $additionfields = DATABOX_cleanaddtiondatas($additionfields, $addition_def, $additionfields_fnm, $additionfields_del, $additionfields_date, $additionfields_alt, false);
        $owner_id = COM_applyFilter($_POST['owner_id'], true);
        $group_id = COM_applyFilter($_POST['group_id'], true);
        //
        $array['perm_owner'] = $_POST['perm_owner'];
        $array['perm_group'] = $_POST['perm_group'];
        $array['perm_members'] = $_POST['perm_members'];
        $array['perm_anon'] = $_POST['perm_anon'];
        if (is_array($array['perm_owner']) || is_array($array['perm_group']) || is_array($array['perm_members']) || is_array($array['perm_anon'])) {
            list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($array['perm_owner'], $array['perm_group'], $array['perm_members'], $array['perm_anon']);
        } else {
            $perm_owner = $array['perm_owner'];
            $perm_group = $array['perm_group'];
            $perm_members = $array['perm_members'];
            $perm_anon = $array['perm_anon'];
        }
        //編集日
        $modified_autoupdate = COM_applyFilter($_POST['modified_autoupdate'], true);
        $modified_month = COM_applyFilter($_POST['modified_month'], true);
        $modified_day = COM_applyFilter($_POST['modified_day'], true);
        $modified_year = COM_applyFilter($_POST['modified_year'], true);
        $modified_hour = COM_applyFilter($_POST['modified_hour'], true);
        $modified_minute = COM_applyFilter($_POST['modified_minute'], true);
        //公開日
        $released_month = COM_applyFilter($_POST['released_month'], true);
        $released_day = COM_applyFilter($_POST['released_day'], true);
        $released_year = COM_applyFilter($_POST['released_year'], true);
        $released_hour = COM_applyFilter($_POST['released_hour'], true);
        $released_minute = COM_applyFilter($_POST['released_minute'], true);
        //公開終了日
        $expired_available = COM_applyFilter($_POST['expired_available'], true);
        $expired_flag = COM_applyFilter($_POST['expired_flag'], true);
        if ($expired_flag === 0) {
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $expired_year = date('Y', $w);
            $expired_month = date('m', $w);
            $expired_day = date('d', $w);
            $expired_hour = 0;
            $expired_minute = 0;
        } else {
            $expired_month = COM_applyFilter($_POST['expired_month'], true);
            $expired_day = COM_applyFilter($_POST['expired_day'], true);
            $expired_year = COM_applyFilter($_POST['expired_year'], true);
            $expired_hour = COM_applyFilter($_POST['expired_hour'], true);
            $expired_minute = COM_applyFilter($_POST['expired_minute'], true);
        }
        //作成日付
        $created = COM_applyFilter($_POST['created']);
        $created_un = COM_applyFilter($_POST['created_un']);
        $orderno = COM_applyFilter($_POST['orderno']);
        $uuid = $_USER['uid'];
        $udatetime = COM_applyFilter($_POST['udatetime']);
        //"";
        $fieldset_id = COM_applyFilter($_POST['fieldset'], true);
        //"";
        $fieldset_name = COM_applyFilter($_POST['fieldset_name']);
        //"";
    } else {
        $sql = "SELECT ";
        $sql .= " t.*";
        $sql .= " ,t2.name AS fieldset_name" . LB;
        $sql .= " ,t1.username";
        $sql .= " ,t1.fullname";
        $sql .= " ,UNIX_TIMESTAMP(t.modified) AS modified_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.released) AS released_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.comment_expire) AS comment_expire_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.expired) AS expired_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.udatetime) AS udatetime_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.created) AS created_un" . LB;
        $sql .= " FROM ";
        $sql .= $_TABLES['USERBOX_base'] . " AS t";
        $sql .= "," . $_TABLES['users'] . " AS t1";
        $sql .= "," . $_TABLES['USERBOX_def_fieldset'] . " AS t2 " . LB;
        $sql .= " WHERE ";
        $sql .= " t.id = {$id}";
        $sql .= " AND t.id = t1.uid";
        $sql .= " AND t.fieldset_id = t2.fieldset_id" . LB;
        $result = DB_query($sql);
        $A = DB_fetchArray($result);
        $fieldset_id = COM_stripslashes($A['fieldset_id']);
        $fieldset_name = COM_stripslashes($A['fieldset_name']);
        $code = COM_stripslashes($A['code']);
        //@@@@@
        $title = COM_stripslashes($A['title']);
        //@@@@@
        $username = COM_stripslashes($A['username']);
        //@@@@@
        $fullname = COM_stripslashes($A['fullname']);
        //@@@@@
        $page_title = COM_stripslashes($A['page_title']);
        $description = COM_stripslashes($A['description']);
        $defaulttemplatesdirectory = COM_stripslashes($A['defaulttemplatesdirectory']);
        $hits = COM_stripslashes($A['hits']);
        $comments = COM_stripslashes($A['comments']);
        $comment_expire = COM_stripslashes($A['comment_expire']);
        if ($comment_expire === "0000-00-00 00:00:00") {
            $comment_expire_flag = 0;
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $comment_expire_year = date('Y', $w);
            $comment_expire_month = date('m', $w);
            $comment_expire_day = date('d', $w);
            $comment_expire_hour = 0;
            $comment_expire_minute = 0;
        } else {
            $comment_expire_flag = 1;
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['comment_expire_un']));
            $comment_expire = $wary[1];
            $comment_expire_year = date('Y', $comment_expire);
            $comment_expire_month = date('m', $comment_expire);
            $comment_expire_day = date('d', $comment_expire);
            $comment_expire_hour = date('H', $comment_expire);
            $comment_expire_minute = date('i', $comment_expire);
        }
        $commentcode = COM_stripslashes($A['commentcode']);
        $trackbackcode = COM_stripslashes($A['trackbackcode']);
        $cache_time = COM_stripslashes($A['cache_time']);
        $meta_description = COM_stripslashes($A['meta_description']);
        $meta_keywords = COM_stripslashes($A['meta_keywords']);
        $language_id = COM_stripslashes($A['language_id']);
        $owner_id = COM_stripslashes($A['owner_id']);
        $group_id = COM_stripslashes($A['group_id']);
        $perm_owner = COM_stripslashes($A['perm_owner']);
        $perm_group = COM_stripslashes($A['perm_group']);
        $perm_members = COM_stripslashes($A['perm_members']);
        $perm_anon = COM_stripslashes($A['perm_anon']);
        $category = DATABOX_getdatas("category_id", $_TABLES['USERBOX_category'], "id = {$id}");
        $additionfields = DATABOX_getadditiondatas($id, $pi_name);
        $additionfields_fnm = array();
        //@@@@@
        $additionfields_del = array();
        $additionfields_date = "";
        $draft_flag = COM_stripslashes($A['draft_flag']);
        //編集日
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['modified_un']));
        $modified = $wary[1];
        //$modified = strtotime(COM_stripslashes($A['modified']));
        $modified_month = date('m', $modified);
        $modified_day = date('d', $modified);
        $modified_year = date('Y', $modified);
        $modified_hour = date('H', $modified);
        $modified_minute = date('i', $modified);
        //公開日
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['released_un']));
        $released = $wary[1];
        //$released = strtotime(COM_stripslashes($A['released']));
        $released_month = date('m', $released);
        $released_day = date('d', $released);
        $released_year = date('Y', $released);
        $released_hour = date('H', $released);
        $released_minute = date('i', $released);
        //公開終了日
        $expired = COM_stripslashes($A['expired']);
        if ($expired === "0000-00-00 00:00:00") {
            $expired_flag = 0;
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $expired_year = date('Y', $w);
            $expired_month = date('m', $w);
            $expired_day = date('d', $w);
            $expired_hour = 0;
            $expired_minute = 0;
        } else {
            $expired_flag = 1;
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['expired_un']));
            $expired = $wary[1];
            $expired_year = date('Y', $expired);
            $expired_month = date('m', $expired);
            $expired_day = date('d', $expired);
            $expired_hour = date('H', $expired);
            $expired_minute = date('i', $expired);
        }
        //作成日付
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['created_un']));
        $created = $wary[0];
        $created_un = $wary[1];
        $orderno = COM_stripslashes($A['orderno']);
        $uuid = COM_stripslashes($A['uuid']);
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['udatetime_un']));
        $udatetime = $wary[0];
        if ($edt_flg == FALSE) {
            $delflg = true;
        }
    }
    //template フォルダ
    $tmplfld = DATABOX_templatePath('admin', 'default', $pi_name);
    $templates = new Template($tmplfld);
    $templates->set_file(array('editor' => 'profile_editor.thtml', 'row' => 'row.thtml', 'col' => "profile_col_detail.thtml"));
    // Add JavaScript geeklog >=2.1.0
    // Loads jQuery UI datepicker and timepicker-addon
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.slider');
    //    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.button');
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon-i18n');
    //    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-slideraccess');
    $_SCRIPTS->setJavaScriptFile('datetimepicker', '/javascript/datetimepicker.js');
    $_SCRIPTS->setJavaScriptFile('datepicker', '/javascript/datepicker.js');
    $langCode = COM_getLangIso639Code();
    $toolTip = $MESSAGE[118];
    $imgUrl = $_CONF['site_url'] . '/images/calendar.png';
    $_SCRIPTS->setJavaScript("jQuery(function () {" . "  geeklog.hour_mode = {$_CONF['hour_mode']};" . "  geeklog.datetimepicker.set('comment_expire', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('modified', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('released', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('expired', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE);
    //--
    if ($_CONF['meta_tags'] > 0 && $_USERBOX_CONF['meta_tags'] > 0) {
        $templates->set_var('hide_meta', '');
    } else {
        $templates->set_var('hide_meta', ' style="display:none;"');
    }
    $templates->set_var('maxlength_description', $_USERBOX_CONF['maxlength_description']);
    $templates->set_var('maxlength_meta_description', $_USERBOX_CONF['maxlength_meta_description']);
    $templates->set_var('maxlength_meta_keywords', $_USERBOX_CONF['maxlength_meta_keywords']);
    $templates->set_var('about_thispage', $LANG_USERBOX_ADMIN['about_admin_profile']);
    $templates->set_var('lang_must', $LANG_USERBOX_ADMIN['must']);
    $templates->set_var('site_url', $_CONF['site_url']);
    $templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $templates->set_var('lang_ref', $LANG_USERBOX_ADMIN['ref']);
    $templates->set_var('lang_view', $LANG_USERBOX_ADMIN['view']);
    $token = SEC_createToken();
    $retval .= SEC_getTokenExpiryNotice($token);
    $templates->set_var('gltoken_name', CSRF_TOKEN);
    $templates->set_var('gltoken', $token);
    $templates->set_var('xhtml', XHTML);
    $templates->set_var('script', THIS_SCRIPT);
    $templates->set_var('dateformat', $_USERBOX_CONF['dateformat']);
    //ビューリンク@@@@@
    $url = $_CONF['site_url'] . "/userbox/profile.php";
    $url .= "?";
    if ($_USERBOX_CONF['datacode']) {
        $url .= "code=" . $A['username'];
        $url .= "&m=code";
    } else {
        $url .= "id=" . $A['id'];
        $url .= "&m=id";
    }
    $url = COM_buildUrl($url);
    $view = COM_createLink($LANG_USERBOX['view'], $url);
    $templates->set_var('view', $view);
    //
    $templates->set_var('lang_link_admin', $LANG_USERBOX_ADMIN['link_admin']);
    $templates->set_var('lang_link_admin_top', $LANG_USERBOX_ADMIN['link_admin_top']);
    $templates->set_var('lang_link_public', $LANG_USERBOX_ADMIN['link_public']);
    $templates->set_var('lang_link_list', $LANG_USERBOX_ADMIN['link_list']);
    $templates->set_var('lang_link_detail', $LANG_USERBOX_ADMIN['link_detail']);
    //fieldset_id
    $templates->set_var('lang_fieldset', $LANG_USERBOX_ADMIN['fieldset']);
    $templates->set_var('fieldset_id', $fieldset_id);
    $templates->set_var('fieldset_name', $fieldset_name);
    //id
    $templates->set_var('lang_id', $LANG_USERBOX_ADMIN['id']);
    //@@@@@ $templates->set_var('help_id', $LANG_USERBOX_ADMIN['help']);
    $templates->set_var('id', $id);
    //下書
    $templates->set_var('lang_draft', $LANG_USERBOX_ADMIN['draft']);
    if ($draft_flag == 1) {
        $templates->set_var('draft_flag', "checked=checked");
    } else {
        $templates->set_var('draft_flag', "");
    }
    //
    $templates->set_var('lang_field', $LANG_USERBOX_ADMIN['field']);
    $templates->set_var('lang_fields', $LANG_USERBOX_ADMIN['fields']);
    $templates->set_var('lang_content', $LANG_USERBOX_ADMIN['content']);
    $templates->set_var('lang_templatesetvar', $LANG_USERBOX_ADMIN['templatesetvar']);
    //基本項目
    $templates->set_var('lang_basicfields', $LANG_USERBOX_ADMIN['basicfields']);
    //コード&タイトル&説明&テンプレートセット値@@@@@
    $templates->set_var('lang_code', $LANG_USERBOX_ADMIN['code']);
    if ($_USERBOX_CONF['datacode']) {
        $templates->set_var('lang_must_code', $LANG_USERBOX_ADMIN['must']);
    } else {
        $templates->set_var('lang_must_code', "");
    }
    $templates->set_var('code', $code);
    $templates->set_var('lang_title', $LANG_USERBOX_ADMIN['title']);
    $templates->set_var('title', $title);
    //$LANG28 = array(
    //    2 => 'ユーザID',
    //    3 => 'ユーザ名', username
    //    4 => '氏名', fullname
    $templates->set_var('lang_uid', $LANG28['2']);
    $templates->set_var('lang_username', $LANG28['3']);
    $templates->set_var('username', $username);
    $templates->set_var('lang_fullname', $LANG28['4']);
    $templates->set_var('fullname', $fullname);
    //
    $templates->set_var('lang_page_title', $LANG_USERBOX_ADMIN['page_title']);
    $templates->set_var('page_title', $page_title);
    $templates->set_var('lang_description', $LANG_USERBOX_ADMIN['description']);
    $templates->set_var('description', $description);
    $templates->set_var('lang_defaulttemplatesdirectory', $LANG_USERBOX_ADMIN['defaulttemplatesdirectory']);
    $templates->set_var('defaulttemplatesdirectory', $defaulttemplatesdirectory);
    $select_defaulttemplatesdirectory = fnctemplatesdirectory($defaulttemplatesdirectory);
    $templates->set_var('select_defaulttemplatesdirectory', $select_defaulttemplatesdirectory);
    //@@@@@
    //meta_description
    $templates->set_var('lang_meta_description', $LANG_USERBOX_ADMIN['meta_description']);
    $templates->set_var('meta_description', $meta_description);
    //meta_keywords
    $templates->set_var('lang_meta_keywords', $LANG_USERBOX_ADMIN['meta_keywords']);
    $templates->set_var('meta_keywords', $meta_keywords);
    //language_id
    if (is_array($_CONF['languages'])) {
        $templates->set_var('hide_language_id', '');
        $select_language_id = DATABOX_getoptionlist("language_id", $language_id, 0, $pi_name, "", 0);
    } else {
        $templates->set_var('hide_language_id', ' style="display:none;"');
        $select_language_id = "";
    }
    $templates->set_var('lang_language_id', $LANG_USERBOX_ADMIN['language_id']);
    $templates->set_var('language_id', $language_id);
    $templates->set_var('select_language_id', $select_language_id);
    //@@@@@
    //hits
    $templates->set_var('lang_hits', $LANG_USERBOX_ADMIN['hits']);
    $templates->set_var('hits', $hits);
    //comments
    $templates->set_var('lang_comments', $LANG_USERBOX_ADMIN['comments']);
    $templates->set_var('comments', $comments);
    //commentcode
    $templates->set_var('lang_commentcode', $LANG_USERBOX_ADMIN['commentcode']);
    $templates->set_var('commentcode', $commentcode);
    $optionlist_commentcode = COM_optionList($_TABLES['commentcodes'], 'code,name', $commentcode);
    $templates->set_var('optionlist_commentcode', $optionlist_commentcode);
    //trackbackcode
    $templates->set_var('lang_trackbackcode', $LANG_USERBOX_ADMIN['trackbackcode']);
    $templates->set_var('trackbackcode', $trackbackcode);
    $optionlist_trackbackcode = COM_optionList($_TABLES['trackbackcodes'], 'code,name', $trackbackcode);
    $templates->set_var('optionlist_trackbackcode', $optionlist_trackbackcode);
    $templates->set_var('lang_cache_time', $LANG_USERBOX_ADMIN['cache_time']);
    $templates->set_var('lang_cache_time_desc', $LANG_USERBOX_ADMIN['cache_time_desc']);
    $templates->set_var('cache_time', $cache_time);
    //comment_expire
    $templates->set_var('lang_enabled', $LANG_USERBOX_ADMIN['enabled']);
    if ($comment_expire_flag === 0) {
        $templates->set_var('show_comment_expire', 'false');
        $templates->set_var('is_checked_comment_expire', '');
    } else {
        $templates->set_var('show_comment_expire', 'true');
        $templates->set_var('is_checked_comment_expire', 'checked="checked"');
    }
    $templates->set_var('lang_comment_expire', $LANG_USERBOX_ADMIN['comment_expire']);
    $w = COM_convertDate2Timestamp($comment_expire_year . "-" . $comment_expire_month . "-" . $comment_expire_day, $comment_expire_hour . ":" . $comment_expire_minute . "::00");
    $datetime_comment_expire = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "comment_expire");
    $templates->set_var('datetime_comment_expire', $datetime_comment_expire);
    //編集日
    $templates->set_var('lang_modified_autoupdate', $LANG_USERBOX_ADMIN['modified_autoupdate']);
    $templates->set_var('lang_modified', $LANG_USERBOX_ADMIN['modified']);
    $w = COM_convertDate2Timestamp($modified_year . "-" . $modified_month . "-" . $modified_day, $modified_hour . ":" . $modified_minute . "::00");
    $datetime_modified = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "modified");
    $templates->set_var('datetime_modified', $datetime_modified);
    //公開日
    $templates->set_var('lang_released', $LANG_USERBOX_ADMIN['released']);
    $w = COM_convertDate2Timestamp($released_year . "-" . $released_month . "-" . $released_day, $released_hour . ":" . $released_minute . "::00");
    $datetime_released = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "released");
    $templates->set_var('datetime_released', $datetime_released);
    //公開終了日
    $templates->set_var('lang_expired', $LANG_USERBOX_ADMIN['expired']);
    //if ($expired=="0000-00-00 00:00:00"){
    if ($expired_flag == 0) {
        $templates->set_var('show_expired', 'false');
        $templates->set_var('is_checked_expired', '');
    } else {
        $templates->set_var('show_expired', 'true');
        $templates->set_var('is_checked_expired', 'checked="expired"');
    }
    $templates->set_var('lang_expired', $LANG_USERBOX_ADMIN['expired']);
    $w = COM_convertDate2Timestamp($expired_year . "-" . $expired_month . "-" . $expired_day, $expired_hour . ":" . $expired_minute . "::00");
    $datetime_expired = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "expired");
    $templates->set_var('datetime_expired', $datetime_expired);
    //順序
    $templates->set_var('lang_orderno', $LANG_USERBOX_ADMIN['orderno']);
    $templates->set_var('orderno', $orderno);
    //koko
    //カテゴリ
    $templates->set_var('lang_category', $LANG_USERBOX_ADMIN['category']);
    $checklist_category = DATABOX_getcategoriesinp($category, $fieldset_id, $pi_name);
    $templates->set_var('checklist_category', $checklist_category);
    //追加項目
    $templates->set_var('lang_additionfields', $LANG_USERBOX_ADMIN['additionfields']);
    $rt = DATABOX_getaddtionfieldsEdit($additionfields, $addition_def, $templates, 9999, $pi_name, $additionfields_fnm, $additionfields_del, $fieldset_id, $additionfields_date);
    //保存日時
    $templates->set_var('lang_udatetime', $LANG_USERBOX_ADMIN['udatetime']);
    $templates->set_var('udatetime', $udatetime);
    $templates->set_var('lang_uuid', $LANG_USERBOX_ADMIN['uuid']);
    $templates->set_var('uuid', $uuid);
    //作成日付
    $templates->set_var('lang_created', $LANG_USERBOX_ADMIN['created']);
    $templates->set_var('created', $created);
    $templates->set_var('created_un', $created_un);
    //アクセス権
    $templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $owner_name = COM_getDisplayName($owner_id);
    $templates->set_var('owner_name', $owner_name);
    $templates->set_var('owner_id', $owner_id);
    $templates->set_var('lang_group', $LANG_ACCESS['group']);
    $templates->set_var('group_dropdown', SEC_getGroupDropdown($group_id, 3));
    $templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $templates->set_var('permissions_editor', SEC_getPermissionsHTML($perm_owner, $perm_group, $perm_members, $perm_anon));
    $templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    // SAVE、CANCEL ボタン
    $templates->set_var('lang_save', $LANG_ADMIN['save']);
    $templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $templates->set_var('lang_preview', $LANG_ADMIN['preview']);
    //delete_option
    //$delflg=false;//@@@@@ 削除不可
    if ($delflg) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
    }
    //
    $templates->parse('output', 'editor');
    $retval .= $templates->finish($templates->get_var('output'));
    return $retval;
}
示例#11
0
function showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1)
{
    global $CONF_FORUM, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02, $LANG_GF09;
    global $highlight;
    global $oldPost;
    $oldPost = 0;
    //$mytimer = new timerobject();
    //$mytimer->setPercision(2);
    //$mytimer->startTimer();
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time1: $intervalTime");
    if (!class_exists('StringParser')) {
        require_once $CONF_FORUM['path_include'] . 'bbcode/stringparser_bbcode.class.php';
    }
    $topictemplate = COM_newTemplate(CTL_plugin_templatePath('forum'));
    $topictemplate->set_file(array('topictemplate' => 'topic.thtml', 'forum_icons' => 'forum_icons.thtml', 'forum_links' => 'forum_links.thtml'));
    $topictemplate->set_block('topictemplate', 'block_user_information');
    $topictemplate->set_block('topictemplate', 'block_anon_user_information');
    $topictemplate->set_block('topictemplate', 'location');
    $topictemplate->set_block('topictemplate', 'ip_address');
    $topictemplate->set_block('topictemplate', 'anon_ip_address');
    $topictemplate->set_block('topictemplate', 'user_signature');
    $topictemplate->set_block('topictemplate', 'mod_functions');
    $blocks = array('block_user_name', 'block_anon_user_name', 'block_user_information', 'block_anon_user_information', 'user_signature', 'mod_functions');
    foreach ($blocks as $block) {
        $topictemplate->set_block('topictemplate', $block);
    }
    $topictemplate->set_block('forum_icons', 'topiclocked_icon');
    $topictemplate->set_block('forum_icons', 'mood_icon');
    $blocks = array('profile_link', 'pm_link', 'email_link', 'website_link', 'quotetopic_link', 'edittopic_link');
    foreach ($blocks as $block) {
        $topictemplate->set_block('forum_links', $block);
    }
    // if preview, only stripslashes is gpc=on, else assume from db so strip
    if ($mode == 'preview') {
        $showtopic['subject'] = COM_stripslashes($showtopic['subject']);
    } else {
        $showtopic['subject'] = stripslashes($showtopic['subject']);
    }
    $min_height = 50;
    // Base minimum  height of topic - will increase if avatar or sig is used
    $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
    $sql = "SELECT u.*, ui.location FROM {$_TABLES['users']} u, {$_TABLES['userinfo']} ui \n    \t\tWHERE u.uid = ui.uid \n    \t\tAND u.uid = '{$showtopic['uid']}'";
    $userQuery = DB_query($sql);
    if ($showtopic['uid'] > 1 and DB_numRows($userQuery) == 1) {
        $userarray = DB_fetchArray($userQuery);
        $username = COM_getDisplayName($showtopic['uid']);
        $userlink = "<a href=\"{$_CONF['site_url']}/users.php?mode=profile&amp;uid={$showtopic['uid']}\" ";
        $userlink .= "class=\"authorname {$onetwo}\"><b>{$username}</b></a>";
        $uservalid = true;
        $postcount = DB_query("SELECT * FROM {$_TABLES['forum_topic']} WHERE uid='{$showtopic['uid']}'");
        $posts = DB_numRows($postcount);
        // STARS CODE
        if (SEC_inGroup(1, $showtopic['uid'])) {
            $user_level = showrank(7, $LANG_GF01['admin']);
            $user_levelname = $LANG_GF01['admin'];
        } else {
            if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) {
                $user_level = showrank(6, $LANG_GF01['moderator']);
                $user_levelname = $LANG_GF01['moderator'];
            } else {
                if ($posts < $CONF_FORUM['level2']) {
                    $user_level = showrank(1, $CONF_FORUM['level1name']);
                    $user_levelname = $CONF_FORUM['level1name'];
                } elseif ($posts >= $CONF_FORUM['level2'] && $posts < $CONF_FORUM['level3']) {
                    $user_level = showrank(2, $CONF_FORUM['level2name']);
                    $user_levelname = $CONF_FORUM['level2name'];
                } elseif ($posts >= $CONF_FORUM['level3'] && $posts < $CONF_FORUM['level4']) {
                    $user_level = showrank(3, $CONF_FORUM['level3name']);
                    $user_levelname = $CONF_FORUM['level3name'];
                } elseif ($posts >= $CONF_FORUM['level4'] && $posts < $CONF_FORUM['level5']) {
                    $user_level = showrank(4, $CONF_FORUM['level4name']);
                    $user_levelname = $CONF_FORUM['level4name'];
                } elseif ($posts > $CONF_FORUM['level5']) {
                    $user_level = showrank(5, $CONF_FORUM['level5name']);
                    $user_levelname = $CONF_FORUM['level5name'];
                }
            }
        }
        // Still allow photo to be showen for users
        if ($showtopic['uid'] > 1 and ($userarray['photo'] != "" or !empty($_CONF['default_photo']))) {
            $avatar = USER_getPhoto($showtopic['uid'], '', '', $CONF_FORUM['avatar_width']);
            $min_height = $min_height + 50;
        } else {
            $avatar = '';
        }
        $regdate = $LANG_GF01['REGISTERED'] . ': ' . strftime($_CONF['shortdate'], strtotime($userarray['regdate'])) . '<br' . XHTML . '>';
        $numposts = $LANG_GF01['POSTS'] . ': ' . $posts;
        if (DB_count($_TABLES['sessions'], 'uid', $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid={$showtopic['uid']}") == 1) {
            $avatar .= '<br' . XHTML . '>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['ONLINE'];
        } else {
            $avatar .= '<br' . XHTML . '>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['OFFLINE'];
        }
        if ($userarray['sig'] != '') {
            $sig = $userarray['sig'];
            $min_height = $min_height + 30;
        } else {
            $sig = '';
        }
    } else {
        $uservalid = false;
        $userlink = urldecode($showtopic['name']);
    }
    if ($CONF_FORUM['show_moods'] && $showtopic['mood'] != "") {
        $topictemplate->set_var('moodicon', gf_getImage($showtopic['mood'], 'moods'));
        $topictemplate->set_var('moodicontext', $showtopic['mood']);
        $topictemplate->parse('mood_icon', 'mood_icon');
        $min_height = $min_height + 30;
    } else {
        $topictemplate->set_var('mood_icon', '');
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time3: $intervalTime");
    // Handle Pre ver 2.5 quoting and New Line Formatting - consider adding this to a migrate function
    if ($CONF_FORUM['pre2.5_mode']) {
        // try to determine if we have an old post...
        if (strstr($showtopic['comment'], '<pre class="forumCode">') !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "[code]<code>") !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "<pre>") !== false) {
            $oldPost = 1;
        }
        if (stristr($showtopic['comment'], '[code') == false || stristr($showtopic['comment'], '[code]<code>') == true) {
            if (strstr($showtopic['comment'], "<pre>") !== false) {
                $oldPost = 1;
            }
            $showtopic['comment'] = str_replace('<pre>', '[code]', $showtopic['comment']);
            $showtopic['comment'] = str_replace('</pre>', '[/code]', $showtopic['comment']);
        }
        $showtopic['comment'] = str_ireplace("[code]<code>", '[code]', $showtopic['comment']);
        $showtopic['comment'] = str_ireplace("</code>[/code]", '[/code]', $showtopic['comment']);
        $showtopic['comment'] = str_replace(array("<br />\r\n", "<br />\n\r", "<br />\r", "<br />\n", "<br>\r\n", "<br>\n\r", "<br>\r", "<br>\n"), '<br' . XHTML . '>', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=\\s(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        /* Reformat code blocks - version 2.3.3 and prior */
        $showtopic['comment'] = str_replace('<pre class="forumCode">', '[code]', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        if ($oldPost) {
            if (strstr($showtopic['comment'], "\\'") !== false) {
                $showtopic['comment'] = stripslashes($showtopic['comment']);
            }
        }
    }
    $showtopic['comment'] = gf_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode);
    $showtopic['subject'] = gf_formatTextBlock($showtopic['subject'], 'text', $mode);
    if ($CONF_FORUM['show_subject_length'] > 0 and strlen($showtopic['subject']) > $CONF_FORUM['show_subject_length']) {
        $showtopic['subject'] = COM_truncate("{$showtopic['subject']}", $CONF_FORUM['show_subject_length'], '...');
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time2: $intervalTime");
    if ($mode != 'preview' && $uservalid && !COM_isAnonUser() && $_USER['uid'] == $showtopic['uid']) {
        /* Check if user can still edit this post - within allowed edit timeframe */
        $editAllowed = false;
        if ($CONF_FORUM['allowed_editwindow'] > 0) {
            $t1 = $showtopic['date'];
            $t2 = $CONF_FORUM['allowed_editwindow'];
            if (time() - $t2 < $t1) {
                $editAllowed = true;
            }
        } else {
            $editAllowed = true;
        }
        if ($editAllowed) {
            $editlink = "{$_CONF['site_url']}/forum/createtopic.php?method=edit&amp;forum={$showtopic['forum']}&amp;id={$showtopic['id']}&amp;editid={$showtopic['id']}&amp;page={$page}";
            $editlinktext = $LANG_GF09['edit'];
            $topictemplate->set_var('editlink', $editlink);
            $topictemplate->set_var('editlinktext', $editlinktext);
            $topictemplate->set_var('LANG_edit', $LANG_GF01['EDITICON']);
            $topictemplate->parse('edittopic_link', 'edittopic_link');
        }
    }
    if ($highlight != '') {
        $showtopic['subject'] = str_replace("{$highlight}", "<span class=\"highlight\">{$highlight}</span>", $showtopic['subject']);
        $showtopic['comment'] = str_replace("{$highlight}", "<span class=\"highlight\">{$highlight}</span>", $showtopic['comment']);
    }
    if (!isset($showtopic['pid'])) {
        $showtopic['pid'] = 0;
    }
    if ($showtopic['pid'] == 0) {
        $replytopicid = $showtopic['id'];
        $is_lockedtopic = $showtopic['locked'];
        $views = $showtopic['views'];
        $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views));
        if ($is_lockedtopic) {
            $topictemplate->parse('topiclocked_icon', 'topiclocked_icon');
        }
    } else {
        $replytopicid = $showtopic['pid'];
        $is_lockedtopic = DB_getItem($_TABLES['forum_topic'], 'locked', "id={$showtopic['pid']}");
        $topictemplate->set_var('read_msg', '');
    }
    if ($CONF_FORUM['allow_user_dateformat']) {
        $date = COM_getUserDateTimeFormat($showtopic['date']);
        $topictemplate->set_var('posted_date', $date[0]);
    } else {
        $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
        $topictemplate->set_var('posted_date', $date);
    }
    if ($mode != 'preview') {
        if ($is_lockedtopic == 0) {
            $is_readonly = DB_getItem($_TABLES['forum_forums'], 'is_readonly', 'forum_id=' . $showtopic['forum']);
            if ($is_readonly == 0 or forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_edit')) {
                $quotelink = "{$_CONF['site_url']}/forum/createtopic.php?method=postreply&amp;forum={$showtopic['forum']}&amp;id={$replytopicid}&amp;quoteid={$showtopic['id']}";
                $quotelinktext = $LANG_GF09['quote'];
                $topictemplate->set_var('quotelink', $quotelink);
                $topictemplate->set_var('quotelinktext', $quotelinktext);
                $topictemplate->set_var('LANG_quote', $LANG_GF01['QUOTEICON']);
                $topictemplate->parse('quotetopic_link', 'quotetopic_link');
            }
        }
        $topictemplate->set_var('topic_post_id', $showtopic['id']);
        if ($showtopic['uid'] > 1 && $uservalid) {
            $profile_link = "{$_CONF['site_url']}/users.php?mode=profile&amp;uid={$showtopic['uid']}";
            $profile_linktext = $LANG_GF09['profile'];
            $topictemplate->set_var('profilelink', $profile_link);
            $topictemplate->set_var('profilelinktext', $profile_linktext);
            $topictemplate->set_var('LANG_profile', $LANG_GF01['ProfileLink']);
            $topictemplate->parse('profile_link', 'profile_link');
            if ($CONF_FORUM['use_pm_plugin']) {
                $pmusernmame = COM_getDisplayName($showtopic['uid']);
                $pmplugin_link = forumPLG_getPMlink($pmusernmame);
                if ($pmplugin_link != '') {
                    $pm_link = $pmplugin_link;
                    $pm_linktext = $LANG_GF09['pm'];
                    $topictemplate->set_var('pmlink', $pm_link);
                    $topictemplate->set_var('pmlinktext', $pm_linktext);
                    $topictemplate->set_var('LANG_pm', $LANG_GF01['PMLink']);
                    $topictemplate->parse('pm_link', 'pm_link');
                }
            }
        }
        if ($userarray['email'] != '' && $showtopic["uid"] > 1) {
            $email_link = "{$_CONF['site_url']}/profiles.php?uid={$showtopic['uid']}";
            $email_linktext = $LANG_GF09['email'];
            $topictemplate->set_var('emaillink', $email_link);
            $topictemplate->set_var('emaillinktext', $email_linktext);
            $topictemplate->set_var('LANG_email', $LANG_GF01['EmailLink']);
            $topictemplate->parse('email_link', 'email_link');
        }
        if ($userarray['homepage'] != '') {
            $homepage = trim($userarray['homepage']);
            if (strtolower(substr($homepage, 0, 4)) != 'http') {
                $homepage = 'http://' . $homepage;
            }
            $homepagetext = $LANG_GF09['website'];
            $topictemplate->set_var('websitelink', $homepage);
            $topictemplate->set_var('websitelinktext', $homepagetext);
            $topictemplate->set_var('LANG_website', $LANG_GF01['WebsiteLink']);
            $topictemplate->parse('website_link', 'website_link');
        }
        if ($userarray['location'] != '' && $showtopic["uid"] > 1) {
            $topictemplate->set_var('user_location', $userarray['location']);
            $topictemplate->parse('location', 'location');
        }
    } else {
        if (isset($_GET['onlytopic']) and $_GET['onlytopic'] != 1) {
            $topictemplate->set_var('posted_date', '');
            $topictemplate->set_var('preview_topic_subject', $showtopic['subject']);
        } else {
            $topictemplate->set_var('preview_topic_subject', '');
        }
        $topictemplate->set_var('read_msg', '');
        $topictemplate->set_var('topiclocked_icon', '');
        $topictemplate->set_var('preview_mode', 'none');
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time4: $intervalTime");
    $showtopic['comment'] = str_replace('{', '&#123;', $showtopic['comment']);
    $showtopic['comment'] = str_replace('}', '&#125;', $showtopic['comment']);
    // Temporary correspondence. You should cope in more roots.
    $showtopic['comment'] = str_replace(array("<br />", "<br>"), '<br' . XHTML . '>', $showtopic['comment']);
    $topictemplate->set_var('layout_url', $CONF_FORUM['layout_url']);
    $topictemplate->set_var('csscode', $onetwo);
    $topictemplate->set_var('postmode', $showtopic['postmode']);
    $topictemplate->set_var('userlink', $userlink);
    $topictemplate->set_var('lang_forum', $LANG_GF01['FORUM']);
    $topictemplate->set_var('user_levelname', $user_levelname);
    $topictemplate->set_var('user_level', $user_level);
    $topictemplate->set_var('avatar', $avatar);
    $topictemplate->set_var('regdate', $regdate);
    $topictemplate->set_var('numposts', $numposts);
    if (forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_ban')) {
        $topictemplate->set_var('ip', $showtopic['ip']);
        if ($showtopic['uid'] == 1) {
            $topictemplate->parse('ip_address', 'anon_ip_address');
        } else {
            $topictemplate->parse('ip_address', 'ip_address');
        }
    } else {
        $topictemplate->set_var('ip_address', '');
    }
    $topictemplate->set_var('imgset', $CONF_FORUM['imgset']);
    $topictemplate->set_var('topic_subject', $showtopic['subject']);
    $topictemplate->set_var('LANG_ON2', $LANG_GF01['ON2']);
    if ($mode != 'preview') {
        $mod_functions = forum_getmodFunctions($showtopic);
        if (!empty($mod_functions)) {
            $topictemplate->set_var('mod_functions', $mod_functions);
            $topictemplate->parse('mod_functions', 'mod_functions');
        } else {
            $topictemplate->set_var('mod_functions', '');
        }
    }
    $topictemplate->set_var('topic_comment', $showtopic['comment']);
    $topictemplate->set_var('comment_minheight', "min-height:{$min_height}px");
    if (trim($sig) != '') {
        $topictemplate->set_var('sig', PLG_replaceTags($sig));
        $topictemplate->set_var('show_sig', '');
        $topictemplate->parse('user_signature', 'user_signature');
    } else {
        $topictemplate->set_var('sig', '');
        $topictemplate->set_var('show_sig', 'none');
        $topictemplate->set_var('user_signature', '');
    }
    $topictemplate->set_var('forumid', $showtopic['forum']);
    $topictemplate->set_var('topic_id', $showtopic['id']);
    $topictemplate->set_var('member_badge', forumPLG_getMemberBadge($showtopic['uid']));
    if ($uservalid) {
        $topictemplate->parse('user_name', 'block_user_name');
        $topictemplate->parse('user_information', 'block_user_information');
    } else {
        $topictemplate->parse('user_name', 'block_anon_user_name');
        $topictemplate->parse('user_information', 'block_anon_user_information');
    }
    $topictemplate->parse('output', 'topictemplate');
    $retval = $topictemplate->finish($topictemplate->get_var('output'));
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time5: $intervalTime");
    return $retval;
}
示例#12
0
文件: index.php 项目: ivywe/forum
         $lastdate = COM_getUserDateTimeFormat($lastreply['date']);
         $lastdate = $lastdate[0];
     } else {
         $lastdate = strftime($CONF_FORUM['default_Datetime_format'], $lastreply['date']);
     }
 } else {
     $lastdate = strftime($CONF_FORUM['default_Datetime_format'], $record['lastupdated']);
     $lastreply = $record;
 }
 $firstdate1 = strftime($format1, $record['date']);
 if ($firstdate1 == date($format2)) {
     $firsttime = strftime($format3, $record['date']);
     $firstdate = $LANG_GF01['TODAY'] . $firsttime;
 } elseif (isset($CONF_FORUM['use_userdate_format']) && $CONF_FORUM['use_userdate_format']) {
     // FIXME: why would it not be set?
     $firstdate = COM_getUserDateTimeFormat($record['date']);
     $firstdate = $firstdate[0];
 } else {
     $firstdate = strftime($CONF_FORUM['default_Datetime_format'], $record['date']);
 }
 if (!COM_isAnonUser()) {
     // Determine if there are new topics since last visit for this user.
     // If topic has been updated or is new - then the user will not have record for this parent topic in the log table
     if (DB_getItem($_TABLES['forum_log'], 'COUNT(*)', "uid='{$_USER['uid']}' AND topic='{$record['id']}' AND time > 0") == 0) {
         if ($record['sticky'] == 1) {
             $folderimg = "stickynew_icon";
         } elseif ($record['locked'] == 1) {
             $folderimg = "lockednew_icon";
         } else {
             $folderimg = "normalnew_icon";
         }
示例#13
0
function MONITOR_getListField_images($fieldname, $fieldvalue, $A, $icon_arr)
{
    global $_CONF;
    switch ($fieldname) {
        case 'date':
            $retval = '<small style="white-space: nowrap;">#' . $A['cid'] . ' - ';
            $creation = COM_getUserDateTimeFormat(strtotime($fieldvalue));
            $retval .= $creation[0] . '</small>';
            break;
            //Images
        //Images
        case 'ai_filename':
            if (!is_file($_CONF['path_images'] . 'articles/' . $fieldvalue)) {
                $image = $_CONF['site_url'] . '/admin/plugins/monitor/images/unavailable.png';
            } else {
                $image = $_CONF['site_url'] . '/images/articles/' . $A['ai_filename'];
            }
            $retval = '<div style="float:left;margin:10px 20px 10px 5px; "><a href="' . $_CONF['site_url'] . '/images/articles/' . $fieldvalue . '" target="_blank"><img src="' . $_CONF['site_url'] . '/admin/plugins/monitor/images.php?src=' . $image . '&amp;w=100&amp;h=100&amp;a=t" align="top" alt="' . stripslashes($fieldvalue) . '" /></a></div><p><strong>' . stripslashes($fieldvalue) . '</strong><br' . XHTML . '>';
            $retval .= '#' . $A['ai_img_num'] . ' ';
            $creation = COM_getUserDateTimeFormat(strtotime($A['date']));
            $retval .= $creation[0] . '<br' . XHTML . '><a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['ai_sid'] . '" target="_blank">' . stripslashes($A['title']) . '</a></p>';
            break;
        case 'title_image':
            $retval = stripslashes($fieldvalue);
            break;
        case 'uid':
            if ($fieldvalue >= 2) {
                $retval = COM_createLink($A['username'], $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['uid']);
                $retval = '<p style="white-space: nowrap;">' . $retval . '</span></p>';
            } else {
                $retval = '<p style="white-space: nowrap;">' . $A['username'] . '</p>';
            }
            break;
        default:
            $retval = stripslashes($fieldvalue);
            break;
    }
    return $retval;
}
示例#14
0
/**
* Prepare for optimizing tables
*
* @return   string  HTML form
*
*/
function optimize()
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_DB_BACKUP;
    $retval = '';
    $lastrun = DB_getItem($_TABLES['vars'], 'UNIX_TIMESTAMP(value)', "name = 'lastoptimizeddb'");
    $retval .= COM_startBlock($LANG_DB_BACKUP['optimize_title']);
    $retval .= '<p>' . $LANG_DB_BACKUP['optimize_explain'] . '</p>' . LB;
    if (!empty($lastrun)) {
        $last = COM_getUserDateTimeFormat($lastrun);
        $retval .= '<p>' . $LANG_DB_BACKUP['last_optimization'] . ': ' . $last[0] . '</p>' . LB;
    }
    $retval .= '<p>' . $LANG_DB_BACKUP['optimization_patience'] . '</p>' . LB;
    $retval .= miniform_DoOrCancel($LANG_DB_BACKUP['optimize_button'], 'dooptimize');
    $retval .= COM_endBlock();
    return $retval;
}
示例#15
0
/**
* Create and return the HTML document
*
* @param    string  $content        Main content for the page
* @param    array   $information    An array defining variables to be used when creating the output
*                       string  'what'          If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned
*                       string  'pagetitle'     Optional content for the page's <title>
*                       string  'breadcrumbs'   Optional content for the page's breadcrumb
*                       string  'headercode'    Optional code to go into the page's <head>
*                       boolean 'rightblock'    Whether or not to show blocks on right hand side default is no (-1)
*                       array   'custom'        An array defining custom function to be used to format Rightblocks
* @see      function COM_siteHeader
* @see      function COM_siteFooter
* @return   string              Formated HTML document
*
*/
function COM_createHTMLDocument(&$content = '', $information = array())
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE, $_SCRIPTS, $_PAGE_TIMER, $relLinks;
    // Retrieve required variables from information array
    if (isset($information['what'])) {
        $what = $information['what'];
    } else {
        $what = 'menu';
    }
    if (isset($information['pagetitle'])) {
        $pagetitle = $information['pagetitle'];
    } else {
        $pagetitle = '';
    }
    if (isset($information['headercode'])) {
        $headercode = $information['headercode'];
    } else {
        $headercode = '';
    }
    if (isset($information['breadcrumbs'])) {
        $breadcrumbs = $information['breadcrumbs'];
    } else {
        $breadcrumbs = '';
    }
    if (isset($information['rightblock'])) {
        $rightblock = $information['rightblock'];
    } else {
        $rightblock = -1;
    }
    if (isset($information['custom'])) {
        $custom = $information['custom'];
    } else {
        $custom = '';
    }
    // If the theme does not support the CSS layout then call the legacy functions (Geeklog 1.8.1 and older).
    if ($_CONF['supported_version_theme'] == '1.8.1') {
        return COM_siteHeader($what, $pagetitle, $headercode) . $content . COM_siteFooter($rightblock, $custom);
    }
    // If the theme implemented this for us then call their version instead.
    $function = $_CONF['theme'] . '_createHTMLDocument';
    if (function_exists($function)) {
        return $function($content, $information);
    }
    // If we reach here then either we have the default theme OR
    // the current theme only needs the default variable substitutions
    switch ($_CONF['doctype']) {
        case 'html401transitional':
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
            break;
        case 'html401strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
            break;
        case 'xhtml10transitional':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
            break;
        case 'xhtml10strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            break;
        case 'html5':
        case 'xhtml5':
            $doctype = '<!DOCTYPE html>';
            break;
        default:
            // fallback: HTML 4.01 Transitional w/o system identifier
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
            break;
    }
    // send out the charset header
    header('Content-Type: text/html; charset=' . COM_getCharset());
    if (!empty($_CONF['frame_options'])) {
        header('X-FRAME-OPTIONS: ' . $_CONF['frame_options']);
    }
    $header = COM_newTemplate($_CONF['path_layout']);
    $header->set_file(array('header' => 'header.thtml', 'menunavigation' => 'menunavigation.thtml', 'leftblocks' => 'leftblocks.thtml', 'rightblocks' => 'rightblocks.thtml'));
    $blocks = array('menuitem', 'menuitem_last', 'menuitem_none');
    foreach ($blocks as $block) {
        $header->set_block('menunavigation', $block);
    }
    $header->parse('menu_elements', 'menunavigation', true);
    $header->set_var('doctype', $doctype . LB);
    if (XHTML == '') {
        $header->set_var('xmlns', '');
    } else {
        $header->set_var('xmlns', ' xmlns="http://www.w3.org/1999/xhtml"');
    }
    $feed_url = array();
    if ($_CONF['backend'] == 1) {
        $baseurl = SYND_getFeedUrl();
        $sql = 'SELECT format, filename, title, language FROM ' . $_TABLES['syndication'] . " WHERE (header_tid = 'all')";
        if (!empty($topic)) {
            $sql .= " OR (header_tid = '" . DB_escapeString($topic) . "')";
        }
        $result = DB_query($sql);
        $numRows = DB_numRows($result);
        for ($i = 0; $i < $numRows; $i++) {
            $A = DB_fetchArray($result);
            if (!empty($A['filename'])) {
                $format_type = SYND_getMimeType($A['format']);
                $format_name = SYND_getFeedType($A['format']);
                $feed_title = $format_name . ' Feed: ' . $A['title'];
                $feed_url[] = '<link rel="alternate" type="' . $format_type . '" hreflang="' . $A['language'] . '" href="' . $baseurl . $A['filename'] . '" title="' . htmlspecialchars($feed_title) . '"' . XHTML . '>';
            }
        }
    }
    $header->set_var('feed_url', implode(LB, $feed_url));
    // for backward compatibility only - use {feed_url} instead
    $feed = SYND_getDefaultFeedUrl();
    if (COM_onFrontpage()) {
        $relLinks['canonical'] = '<link rel="canonical" href="' . $_CONF['site_url'] . '/"' . XHTML . '>';
    } else {
        $relLinks['home'] = '<link rel="home" href="' . $_CONF['site_url'] . '/" title="' . $LANG01[90] . '"' . XHTML . '>';
    }
    $loggedInUser = !COM_isAnonUser();
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['searchloginrequired'] == 0) {
        if (substr($_SERVER['PHP_SELF'], -strlen('/search.php')) != '/search.php' || isset($_GET['mode'])) {
            $relLinks['search'] = '<link rel="search" href="' . $_CONF['site_url'] . '/search.php" title="' . $LANG01[75] . '"' . XHTML . '>';
        }
    }
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['directoryloginrequired'] == 0) {
        if (strpos($_SERVER['PHP_SELF'], '/article.php') !== false) {
            $relLinks['contents'] = '<link rel="contents" href="' . $_CONF['site_url'] . '/directory.php" title="' . $LANG01[117] . '"' . XHTML . '>';
        }
    }
    if (!$_CONF['disable_webservices']) {
        $relLinks['service'] = '<link rel="service" ' . 'type="application/atomsvc+xml" ' . 'href="' . $_CONF['site_url'] . '/webservices/atom/?introspection" ' . 'title="' . $LANG01[130] . '"' . XHTML . '>';
    }
    // TBD: add a plugin API and a lib-custom.php function
    $header->set_var('rel_links', implode(LB, $relLinks));
    $pagetitle_siteslogan = false;
    if (empty($pagetitle)) {
        if (empty($topic)) {
            $pagetitle = $_CONF['site_slogan'];
            $pagetitle_siteslogan = true;
        } else {
            $pagetitle = stripslashes(DB_getItem($_TABLES['topics'], 'topic', "tid = '{$topic}'"));
        }
    }
    if (!empty($pagetitle)) {
        $header->set_var('page_site_splitter', ' - ');
    } else {
        $header->set_var('page_site_splitter', '');
    }
    $header->set_var('page_title', $pagetitle);
    $header->set_var('site_name', $_CONF['site_name']);
    if (COM_onFrontpage() or $pagetitle_siteslogan) {
        $title_and_name = $_CONF['site_name'];
        if (!empty($pagetitle)) {
            $title_and_name .= ' - ' . $pagetitle;
        }
    } else {
        $title_and_name = '';
        if (!empty($pagetitle)) {
            $title_and_name = $pagetitle . ' - ';
        }
        $title_and_name .= $_CONF['site_name'];
    }
    $header->set_var('page_title_and_site_name', $title_and_name);
    COM_setLangIdAndAttribute($header);
    $header->set_var('background_image', $_CONF['layout_url'] . '/images/bg.' . $_IMAGE_TYPE);
    $msg = rtrim($LANG01[67]) . ' ' . $_CONF['site_name'];
    if (!empty($_USER['username'])) {
        $msg .= ', ' . COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']);
    }
    $curtime = COM_getUserDateTimeFormat();
    $header->set_var('welcome_msg', $msg);
    $header->set_var('datetime', $curtime[0]);
    $header->set_var('site_logo', $_CONF['layout_url'] . '/images/logo.' . $_IMAGE_TYPE);
    $header->set_var('theme', $_CONF['theme']);
    $header->set_var('datetime_html5', strftime('%FT%T', $curtime[1]));
    $header->set_var('charset', COM_getCharset());
    $header->set_var('direction', $LANG_DIRECTION);
    $template_vars = array('rdf_file' => $feed, 'rss_url' => $feed, 'site_mail' => "mailto:{$_CONF['site_mail']}", 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'button_home' => $LANG_BUTTONS[1], 'button_contact' => $LANG_BUTTONS[2], 'button_contribute' => $LANG_BUTTONS[3], 'button_sitestats' => $LANG_BUTTONS[7], 'button_personalize' => $LANG_BUTTONS[8], 'button_search' => $LANG_BUTTONS[9], 'button_advsearch' => $LANG_BUTTONS[10], 'button_directory' => $LANG_BUTTONS[11]);
    $header->set_var($template_vars);
    // Get plugin menu options
    $plugin_menu = PLG_getMenuItems();
    if ($_COM_VERBOSE) {
        COM_errorLog('num plugin menu items in header = ' . count($plugin_menu), 1);
    }
    // Now add nested template for menu items
    COM_renderMenu($header, $plugin_menu);
    if (count($plugin_menu) == 0) {
        $header->parse('plg_menu_elements', 'menuitem_none', true);
    } else {
        $count_plugin_menu = count($plugin_menu);
        for ($i = 1; $i <= $count_plugin_menu; $i++) {
            $header->set_var('menuitem_url', current($plugin_menu));
            $header->set_var('menuitem_text', key($plugin_menu));
            if ($i == $count_plugin_menu) {
                $header->parse('plg_menu_elements', 'menuitem_last', true);
            } else {
                $header->parse('plg_menu_elements', 'menuitem', true);
            }
            next($plugin_menu);
        }
    }
    // Call to plugins to set template variables in the header
    PLG_templateSetVars('header', $header);
    if ($_CONF['left_blocks_in_footer'] == 1) {
        $header->set_var('left_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $lblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $lblocks = $function($what[1], 'left');
            } else {
                $lblocks = COM_showBlocks('left', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $lblocks = COM_showBlocks('left', $topic);
            }
        }
        if (empty($lblocks)) {
            $header->set_var('left_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $lblocks);
            $header->parse('left_blocks', 'leftblocks', true);
            $header->set_var('geeklog_blocks', '');
        }
    }
    if ($_CONF['right_blocks_in_footer'] == 1) {
        $header->set_var('right_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $rblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $rblocks = $function($what[1], 'right');
            } else {
                $rblocks = COM_showBlocks('right', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $rblocks = COM_showBlocks('right', $topic);
            }
        }
        if (empty($rblocks)) {
            $header->set_var('right_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $rblocks, true);
            $header->parse('right_blocks', 'rightblocks', true);
        }
    }
    // Set last topic session variable
    if ($topic == TOPIC_ALL_OPTION) {
        $topic = '';
        // Do not save 'all' option. Nothing is the same thing
    }
    SESS_setVariable('topic', $topic);
    // Call any plugin that may want to include extra Meta tags
    // or Javascript functions
    $headercode .= PLG_getHeaderCode();
    // Meta Tags
    // 0 = Disabled, 1 = Enabled, 2 = Enabled but default just for homepage
    if ($_CONF['meta_tags'] > 0) {
        $meta_description = '';
        $meta_keywords = '';
        $no_meta_description = 1;
        $no_meta_keywords = 1;
        //Find out if the meta tag description or keywords already exist in the headercode
        if ($headercode != '') {
            $pattern = '/<meta ([^>]*)name="([^"\'>]*)"([^>]*)/im';
            if (preg_match_all($pattern, $headercode, $matches, PREG_SET_ORDER)) {
                // Loop through all meta tags looking for description and keywords
                for ($i = 0; $i < count($matches) && ($no_meta_description == 1 || $no_meta_keywords == 1); $i++) {
                    $str_matches = strtolower($matches[$i][0]);
                    $pos = strpos($str_matches, 'name=');
                    if (!(is_bool($pos) && !$pos)) {
                        $name = trim(substr($str_matches, $pos + 5), '"');
                        $pos = strpos($name, '"');
                        $name = substr($name, 0, $pos);
                        if (strcasecmp("description", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_description = 0;
                            }
                        }
                        if (strcasecmp("keywords", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_keywords = 0;
                            }
                        }
                    }
                }
            }
        }
        if (COM_onFrontpage() && $_CONF['meta_tags'] == 2) {
            // Display default meta tags only on home page
            if ($no_meta_description) {
                $meta_description = $_CONF['meta_description'];
            }
            if ($no_meta_keywords) {
                $meta_keywords = $_CONF['meta_keywords'];
            }
        } else {
            if ($_CONF['meta_tags'] == 1) {
                // Display default meta tags anywhere there are no tags
                if ($no_meta_description) {
                    $meta_description = $_CONF['meta_description'];
                }
                if ($no_meta_keywords) {
                    $meta_keywords = $_CONF['meta_keywords'];
                }
            }
        }
        if ($no_meta_description or $no_meta_keywords) {
            $headercode .= COM_createMetaTags($meta_description, $meta_keywords);
        }
    }
    $header->set_var('breadcrumb_trail', $breadcrumbs);
    COM_hit();
    // Set template directory
    $footer = COM_newTemplate($_CONF['path_layout']);
    // Set template file
    $footer->set_file(array('footer' => 'footer.thtml', 'rightblocks' => 'rightblocks.thtml', 'leftblocks' => 'leftblocks.thtml'));
    $year = date('Y');
    $copyrightyear = $year;
    if (!empty($_CONF['copyrightyear'])) {
        $copyrightyear = $_CONF['copyrightyear'];
    }
    if (!empty($_CONF['owner_name'])) {
        $copyrightname = $_CONF['owner_name'];
    } else {
        $copyrightname = $_CONF['site_name'];
    }
    $footer->set_var('copyright_notice', '&nbsp;' . $LANG01[93] . ' &copy; ' . $copyrightyear . ' ' . $copyrightname . '<br' . XHTML . '>&nbsp;' . $LANG01[94]);
    $footer->set_var('copyright_msg', $LANG01[93] . ' &copy; ' . $copyrightyear . ' ' . $_CONF['site_name']);
    $footer->set_var('current_year', $year);
    $footer->set_var('lang_copyright', $LANG01[93]);
    $footer->set_var('trademark_msg', $LANG01[94]);
    $footer->set_var('powered_by', $LANG01[95]);
    $footer->set_var('geeklog_url', 'http://www.geeklog.net/');
    $footer->set_var('geeklog_version', VERSION);
    $footer->set_var($template_vars);
    /* Right blocks. Argh. Don't talk to me about right blocks...
     * Right blocks will be displayed if Right_blocks_in_footer is set [1],
     * AND (this function has been asked to show them (first param) OR the
     * show_right_blocks conf variable has been set to override what the code
     * wants to do.
     *
     * If $custom sets an array (containing functionname and first argument)
     * then this is used instead of the default (COM_showBlocks) to render
     * the right blocks (and left).
     *
     * [1] - if it isn't, they'll be in the header already.
     *
     */
    $displayRightBlocks = true;
    if ($_CONF['right_blocks_in_footer'] == 1) {
        if ($rightblock < 0 || !$rightblock) {
            if (isset($_CONF['show_right_blocks'])) {
                $displayRightBlocks = $_CONF['show_right_blocks'];
            } else {
                $displayRightBlocks = false;
            }
        } else {
            $displayRightBlocks = true;
        }
    } else {
        $displayRightBlocks = false;
    }
    if ($displayRightBlocks) {
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function.
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($custom)) {
            $function = $custom['0'];
            if (function_exists($function)) {
                $rblocks = $function($custom['1'], 'right');
            } else {
                $rblocks = COM_showBlocks('right', $topic);
            }
        } else {
            $rblocks = COM_showBlocks('right', $topic);
        }
        if (empty($rblocks)) {
            $footer->set_var('geeklog_blocks', '');
            $footer->set_var('right_blocks', '');
        } else {
            $footer->set_var('geeklog_blocks', $rblocks);
            $footer->parse('right_blocks', 'rightblocks', true);
            $footer->set_var('geeklog_blocks', '');
        }
    } else {
        $footer->set_var('geeklog_blocks', '');
        $footer->set_var('right_blocks', '');
    }
    if ($_CONF['left_blocks_in_footer'] == 1) {
        $lblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($custom)) {
            $function = $custom[0];
            if (function_exists($function)) {
                $lblocks = $function($custom[1], 'left');
            }
        } else {
            if ($what != 'none') {
                $lblocks = COM_showBlocks('left', $topic);
            }
        }
        if (empty($lblocks)) {
            $footer->set_var('left_blocks', '');
            $footer->set_var('geeklog_blocks', '');
        } else {
            $footer->set_var('geeklog_blocks', $lblocks);
            $footer->parse('left_blocks', 'leftblocks', true);
            $footer->set_var('geeklog_blocks', '');
        }
    }
    // Global centerspan variable set in index.php
    if (isset($GLOBALS['centerspan'])) {
        $footer->set_var('centerblockfooter-span', '</td></tr></table>');
    }
    $exectime = $_PAGE_TIMER->stopTimer();
    $exectext = $LANG01[91] . ' ' . $exectime . ' ' . $LANG01[92];
    $footer->set_var('execution_time', $exectime);
    $footer->set_var('execution_textandtime', $exectext);
    /* Check leftblocks and rightblocks */
    $layout_columns = 'left-center-right';
    $emptylblocks = empty($lblocks);
    $emptyrblocks = empty($rblocks);
    if (!$emptylblocks && $emptyrblocks) {
        $layout_columns = 'left-center';
    }
    if ($emptylblocks && !$emptyrblocks) {
        $layout_columns = 'center-right';
    }
    if ($emptylblocks && $emptyrblocks) {
        $layout_columns = 'center';
    }
    $header->set_var('layout_columns', $layout_columns);
    // All blocks, autotags, template files, etc, now have been rendered (since can be done in footer) so all scripts and css should be set now
    $headercode = $_SCRIPTS->getHeader() . $headercode;
    $header->set_var('plg_headercode', $headercode);
    $retval_header = $header->finish($header->parse('index_header', 'header'));
    // Call to plugins to set template variables in the footer
    PLG_templateSetVars('footer', $footer);
    // Call any plugin that may want to include extra JavaScript functions
    $plugin_footercode = PLG_getFooterCode();
    // Retrieve any JavaScript libraries, variables and functions
    $footercode = $_SCRIPTS->getFooter();
    // $_SCRIPTS code should be placed before plugin_footer_code but plugin_footer_code should still be allowed to set $_SCRIPTS
    $footercode .= $plugin_footercode;
    $footer->set_var('plg_footercode', $footercode);
    // Actually parse the template and make variable substitutions
    $footer->parse('index_footer', 'footer');
    return $retval_header . $content . $footer->finish($footer->get_var('index_footer'));
}
示例#16
0
/**
* Displays the static page form
*
* @param    array   $A      Data to display
* @param    string  $error  Error message to display
*
*/
function PAGE_form($A, $error = false)
{
    global $_CONF, $_TABLES, $_USER, $_GROUPS, $_SP_CONF, $action, $sp_id, $LANG21, $LANG_STATIC, $LANG_ACCESS, $LANG_ADMIN, $LANG24, $LANG_postmodes, $MESSAGE;
    USES_lib_admin();
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/staticpages/index.php', 'text' => $LANG_STATIC['page_list']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $template_path = staticpages_templatePath('admin');
    if (!empty($sp_id) && ($action == 'edit' || $action == 'clone')) {
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['staticpages Admin'])) {
            $A['group_id'] = $_GROUPS['staticpages Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('staticpages.edit');
        }
        SEC_setDefaultPermissions($A, $_SP_CONF['default_permissions']);
        $access = 3;
    }
    $retval = '';
    if (empty($A['owner_id'])) {
        $error = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header'));
        $error .= $LANG_STATIC['deny_msg'];
        $error .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
    }
    if ($error) {
        $retval .= $error . '<br/><br/>';
    } else {
        $sp_template = new Template($template_path);
        $sp_template->set_file('form', 'editor.thtml');
        $sp_template->set_var('lang_mode', $LANG24[3]);
        $sp_template->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $A['commentcode']));
        $ownername = COM_getDisplayName($A['owner_id']);
        $sp_template->set_var(array('sp_search_checked' => $A['sp_search'] == 1 ? ' checked="checked"' : '', 'sp_status_checked' => $A['sp_status'] == 1 ? ' checked="checked"' : '', 'lang_accessrights' => $LANG_ACCESS['accessrights'], 'lang_owner' => $LANG_ACCESS['owner'], 'owner_username' => DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"), 'owner_name' => $ownername, 'owner' => $ownername, 'owner_id' => $A['owner_id'], 'lang_group' => $LANG_ACCESS['group'], 'group_dropdown' => SEC_getGroupDropdown($A['group_id'], $access), 'permissions_editor' => SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']), 'lang_permissions' => $LANG_ACCESS['permissions'], 'lang_perm_key' => $LANG_ACCESS['permissionskey'], 'permissions_msg' => $LANG_ACCESS['permmsg'], 'start_block_editor' => COM_startBlock($LANG_STATIC['staticpages'] . ' :: ' . $LANG_STATIC['staticpageeditor'], '', COM_getBlockTemplate('_admin_block', 'header')), 'lang_save' => $LANG_ADMIN['save'], 'lang_cancel' => $LANG_ADMIN['cancel'], 'lang_preview' => $LANG_ADMIN['preview'], 'lang_editor' => $LANG_STATIC['staticpageeditor'], 'lang_attributes' => $LANG_STATIC['attributes']));
        if (SEC_hasRights('staticpages.delete') && $action != 'clone' && !empty($A['sp_old_id'])) {
            $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s/>';
            $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
            $sp_template->set_var('delete_option', sprintf($delbutton, $jsconfirm));
            $sp_template->set_var('delete_button', true);
            $sp_template->set_var('lang_delete_confirm', $MESSAGE[76]);
            $sp_template->set_var('lang_delete', $LANG_ADMIN['delete']);
            $sp_template->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        } else {
            $sp_template->set_var('delete_option', '');
        }
        $sp_template->set_var('lang_writtenby', $LANG_STATIC['writtenby']);
        $sp_template->set_var('username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['sp_uid']}"));
        $authorname = COM_getDisplayName($A['sp_uid']);
        $sp_template->set_var('name', $authorname);
        $sp_template->set_var('author', $authorname);
        $sp_template->set_var('lang_url', $LANG_STATIC['url']);
        $sp_template->set_var('lang_id', $LANG_STATIC['id']);
        $sp_template->set_var('sp_uid', $A['sp_uid']);
        $sp_template->set_var('sp_id', $A['sp_id']);
        $sp_template->set_var('sp_old_id', $A['sp_old_id']);
        $sp_template->set_var('example_url', COM_buildURL($_CONF['site_url'] . '/page.php?page=' . $A['sp_id']));
        $sp_template->set_var('lang_centerblock', $LANG_STATIC['centerblock']);
        $sp_template->set_var('lang_centerblock_help', $LANG_ADMIN['help_url']);
        $sp_template->set_var('lang_centerblock_include', $LANG21[51]);
        $sp_template->set_var('lang_centerblock_desc', $LANG21[52]);
        $sp_template->set_var('centerblock_help', $A['sp_help']);
        $sp_template->set_var('lang_centerblock_msg', $LANG_STATIC['centerblock_msg']);
        if (isset($A['sp_centerblock']) && $A['sp_centerblock'] == 1) {
            $sp_template->set_var('centerblock_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('centerblock_checked', '');
        }
        $sp_template->set_var('lang_topic', $LANG_STATIC['topic']);
        $sp_template->set_var('lang_position', $LANG_STATIC['position']);
        $current_topic = '';
        if (isset($A['sp_tid'])) {
            $current_topic = $A['sp_tid'];
        }
        if (empty($current_topic)) {
            $current_topic = 'none';
        }
        $topics = COM_topicList('tid,topic', $current_topic, 1, true);
        $alltopics = '<option value="all"';
        if ($current_topic == 'all') {
            $alltopics .= ' selected="selected"';
        }
        $alltopics .= '>' . $LANG_STATIC['all_topics'] . '</option>' . LB;
        $allnhp = '<option value="allnhp"';
        if ($current_topic == 'allnhp') {
            $allnhp .= ' selected="selected"';
        }
        $allnhp .= '>' . $LANG_STATIC['allnhp_topics'] . '</option>' . LB;
        $notopic = '<option value="none"';
        if ($current_topic == 'none') {
            $notopic .= ' selected="selected"';
        }
        $notopic .= '>' . $LANG_STATIC['no_topic'] . '</option>' . LB;
        $sp_template->set_var('topic_selection', '<select name="sp_tid">' . $alltopics . $allnhp . $notopic . $topics . '</select>');
        $position = '<select name="sp_where">';
        $position .= '<option value="1"';
        if ($A['sp_where'] == 1) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_top'] . '</option>';
        $position .= '<option value="2"';
        if ($A['sp_where'] == 2) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_feat'] . '</option>';
        $position .= '<option value="3"';
        if ($A['sp_where'] == 3) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_bottom'] . '</option>';
        $position .= '<option value="0"';
        if ($A['sp_where'] == 0) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_entire'] . '</option>';
        $position .= '<option value="4"';
        if ($A['sp_where'] == 4) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_nonews'] . '</option>';
        $position .= '</select>';
        $sp_template->set_var('pos_selection', $position);
        if ($_SP_CONF['allow_php'] == 1 && SEC_hasRights('staticpages.PHP')) {
            if (!isset($A['sp_php'])) {
                $A['sp_php'] = 0;
            }
            $selection = '<select name="sp_php">' . LB;
            $selection .= '<option value="0"';
            if ($A['sp_php'] <= 0 || $A['sp_php'] > 2) {
                $selection .= ' selected="selected"';
            }
            $selection .= '>' . $LANG_STATIC['select_php_none'] . '</option>' . LB;
            $selection .= '<option value="1"';
            if ($A['sp_php'] == 1) {
                $selection .= ' selected="selected"';
            }
            $selection .= '>' . $LANG_STATIC['select_php_return'] . '</option>' . LB;
            $selection .= '<option value="2"';
            if ($A['sp_php'] == 2) {
                $selection .= ' selected="selected"';
            }
            $selection .= '>' . $LANG_STATIC['select_php_free'] . '</option>' . LB;
            $selection .= '</select>';
            $sp_template->set_var('php_selector', $selection);
            $sp_template->set_var('php_warn', $LANG_STATIC['php_warn']);
        } else {
            $sp_template->set_var('php_selector', '');
            $sp_template->set_var('php_warn', $LANG_STATIC['php_not_activated']);
        }
        $sp_template->set_var('php_msg', $LANG_STATIC['php_msg']);
        // old variables (for the 1.3-type checkbox)
        $sp_template->set_var('php_checked', '');
        $sp_template->set_var('php_type', 'hidden');
        if (isset($A['sp_nf']) && $A['sp_nf'] == 1) {
            $sp_template->set_var('exit_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('exit_checked', '');
        }
        $sp_template->set_var('exit_msg', $LANG_STATIC['exit_msg']);
        $sp_template->set_var('exit_info', $LANG_STATIC['exit_info']);
        if (isset($A['sp_inblock']) && $A['sp_inblock'] == 1) {
            $sp_template->set_var('inblock_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('inblock_checked', '');
        }
        $sp_template->set_var('inblock_msg', $LANG_STATIC['inblock_msg']);
        $sp_template->set_var('inblock_info', $LANG_STATIC['inblock_info']);
        $curtime = COM_getUserDateTimeFormat($A['unixdate']);
        $sp_template->set_var('lang_lastupdated', $LANG_STATIC['date']);
        $sp_template->set_var('sp_formateddate', $curtime[0]);
        $sp_template->set_var('sp_date', $curtime[1]);
        $sp_template->set_var('lang_title', $LANG_STATIC['title']);
        $title = '';
        if (isset($A['sp_title'])) {
            $title = htmlspecialchars($A['sp_title']);
        }
        $sp_template->set_var('sp_title', $title);
        $sp_template->set_var('lang_addtomenu', $LANG_STATIC['addtomenu']);
        if (isset($A['sp_onmenu']) && $A['sp_onmenu'] == 1) {
            $sp_template->set_var('onmenu_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('onmenu_checked', '');
        }
        $sp_template->set_var('lang_label', $LANG_STATIC['label']);
        if (isset($A['sp_label'])) {
            $sp_template->set_var('sp_label', $A['sp_label']);
        } else {
            $sp_template->set_var('sp_label', '');
        }
        $sp_template->set_var('lang_pageformat', $LANG_STATIC['pageformat']);
        $sp_template->set_var('lang_blankpage', $LANG_STATIC['blankpage']);
        $sp_template->set_var('lang_noblocks', $LANG_STATIC['noblocks']);
        $sp_template->set_var('lang_leftblocks', $LANG_STATIC['leftblocks']);
        $sp_template->set_var('lang_rightblocks', $LANG_STATIC['rightblocks']);
        $sp_template->set_var('lang_leftrightblocks', $LANG_STATIC['leftrightblocks']);
        if (!isset($A['sp_format'])) {
            $A['sp_format'] = '';
        }
        if ($A['sp_format'] == 'noblocks') {
            $sp_template->set_var('noblock_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('noblock_selected', '');
        }
        if ($A['sp_format'] == 'leftblocks') {
            $sp_template->set_var('leftblocks_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('leftblocks_selected', '');
        }
        if ($A['sp_format'] == 'rightblocks') {
            $sp_template->set_var('rightblocks_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('rightblocks_selected', '');
        }
        if ($A['sp_format'] == 'blankpage') {
            $sp_template->set_var('blankpage_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('blankpage_selected', '');
        }
        if ($A['sp_format'] == 'allblocks' or empty($A['sp_format'])) {
            $sp_template->set_var('allblocks_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('allblocks_selected', '');
        }
        $sp_template->set_var('lang_content', $LANG_STATIC['content']);
        $content = '';
        if (isset($A['sp_content'])) {
            $content = htmlspecialchars($A['sp_content']);
        }
        $sp_template->set_var('sp_content', $content);
        if ($_SP_CONF['filter_html'] == 1) {
            $sp_template->set_var('lang_allowedhtml', COM_allowedHTML(SEC_getUserPermissions(), false, 'staticpages', 'page'));
        } else {
            $sp_template->set_var('lang_allowedhtml', $LANG_STATIC['all_html_allowed']);
        }
        $sp_template->set_var('lang_hits', $LANG_STATIC['hits']);
        if (empty($A['sp_hits'])) {
            $sp_template->set_var('sp_hits', '0');
            $sp_template->set_var('sp_hits_formatted', '0');
        } else {
            $sp_template->set_var('sp_hits', $A['sp_hits']);
            $sp_template->set_var('sp_hits_formatted', COM_numberFormat($A['sp_hits']));
        }
        $sp_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
        $sp_template->set_var('owner_dropdown', COM_buildOwnerList('owner_id', $A['owner_id']));
        $sp_template->set_var('writtenby_dropdown', COM_buildOwnerList('sp_uid', $A['sp_uid']));
        $sp_template->set_var('gltoken_name', CSRF_TOKEN);
        $sp_template->set_var('gltoken', SEC_createToken());
        $sp_template->set_var('admin_menu', ADMIN_createMenu($menu_arr, $LANG_STATIC['instructions_edit'], plugin_geticon_staticpages()));
        PLG_templateSetVars('sp_editor', $sp_template);
        $retval .= $sp_template->parse('output', 'form');
    }
    return $retval;
}
示例#17
0
function nexdocsrv_filedetails($fid, $reportmode = '')
{
    global $_CONF, $_TABLES, $_FMCONF, $LANG_FM02, $LANG_nexfile, $actionurl;
    $tagcloud = new nexfileTagCloud();
    $page = new Template($_CONF['path_layout'] . 'nexfile');
    $page->set_file(array('page' => 'filedetail.thtml', 'versions' => 'filedetail_versions.thtml'));
    if ($reportmode == 'approvals') {
        $sql = "SELECT file.cid,file.title,file.fname,file.date,file.version,file.size, ";
        $sql .= "file.description,file.submitter,file.status,file.version_note as notes,tags ";
        $sql .= "FROM {$_TABLES['nxfile_filesubmissions']} file ";
        $sql .= "WHERE file.id={$fid} ";
    } else {
        $sql = "SELECT file.cid, file.title, file.fname, file.date, file.version, file.size, ";
        $sql .= "detail.description, file.submitter, file.status, v.notes, '' as tags ";
        $sql .= "FROM {$_TABLES['nxfile_files']} file ";
        $sql .= "LEFT JOIN {$_TABLES['nxfile_filedetail']} detail ON file.fid=detail.fid ";
        $sql .= "LEFT JOIN {$_TABLES['nxfile_fileversions']} v ON v.fid=file.fid ";
        $sql .= "WHERE file.fid={$fid} ORDER BY v.version DESC LIMIT 1";
    }
    $query = DB_query($sql);
    if (DB_numRows($query) > 0) {
        list($cid, $title, $fname, $date, $curVersion, $size, $description, $submitter, $status, $curVerNotes, $tags) = DB_fetchARRAY($query);
        if ($reportmode != 'approvals') {
            $tags = $tagcloud->get_itemtags($fid);
        }
        $shortdate = strftime($_CONF['shortdate'], $date);
        $size = fm_formatFileSize($size);
        $pos = strrpos($fname, '.') + 1;
        $ext = strtolower(substr($fname, $pos));
        if (array_key_exists($ext, $_FMCONF['iconlib'])) {
            $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib'][$ext]);
        } else {
            $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib']['none']);
        }
        /* @TODO: Find out why status is not 0 and it's looking for a version */
        //if ($status == 0) {
        $author = DB_getItem($_TABLES['users'], "username", "uid={$submitter}");
        $fullname = DB_getItem($_TABLES['users'], "fullname", "uid={$submitter}");
        //} else {
        //    $curAuthorUid = DB_getItem($_TABLES['nxfile_fileversions'], "uid", "fid='$fid' AND version='$curVersion'");
        //    $author = DB_getItem($_TABLES['users'], "username", "uid='$curAuthorUid'");
        //    $fullname = DB_getItem($_TABLES['users'], "fullname", "uid=$curAuthorUid");
        //}
        $catname = DB_getItem($_TABLES['nxfile_categories'], "name", "cid={$cid}");
        $page->set_var('site_url', $_CONF['site_url']);
        $page->set_var('layout_url', $_CONF['layout_url']);
        $page->set_var('action_url', $actionurl);
        $page->set_var('imgset', "{$_CONF['site_url']}/nexfile/images");
        $page->set_var('heading', $heading);
        $page->set_var('fid', $fid);
        $page->set_var('shortdate', $shortdate);
        $page->set_var('fname', $fname);
        $page->set_var('current_version', '(V' . $curVersion . ')');
        $page->set_var('filetitle', $title);
        $page->set_var('author', "{$fullname}&nbsp;&nbsp;&nbsp;({$author})");
        $page->set_var('description', nl2br($description));
        $page->set_var('tags', $tags);
        $page->set_var('catname', $catname);
        $page->set_var('fileicon', $icon);
        $page->set_var('size', $size);
        $page->set_var('LANG_TAGS', 'Tags');
        $page->set_var('LANG_SIZE', $LANG_FM02['SIZE']);
        $page->set_var('LANG_AUTHOR', $LANG_FM02['AUTHOR']);
        $page->set_var('LANG_CAT', $LANG_FM02['CAT']);
        $page->set_var('LANG_DESCRIPTION', $LANG_FM02['DESCRIPTION']);
        $page->set_var('LANG_VERSION_NOTE', $LANG_FM02['VERSION_NOTE']);
        $page->set_var('LANG_DOWNLOAD', $LANG_FM02['DOWNLOAD']);
        $page->set_var('LANG_DOWNLOAD_MESSAGE', $LANG_nexfile['msg61']);
        $page->set_var('LANG_LINK_MESSAGE', $LANG_nexfile['msg65']);
        $page->set_var('LANG_LASTUPDATED', $LANG_nexfile['msg62']);
        $page->set_var('current_ver_note', nl2br($curVerNotes));
        if ($status == unapprovedstatus) {
            $statUser = DB_getItem($_TABLES['users'], "username", "uid={$submitter}");
            $page->set_var('status_image', '<img src="' . $_FMCONF['imagesurl'] . 'padlock.gif">');
            $page->set_var('statusmessage', '* ' . $LANG_nexfile['msg43']);
        } elseif ($status == lockedstatus) {
            $statUserUid = DB_getItem($_TABLES['nxfile_files'], "status_changedby_uid", "fid={$fid}");
            $statUser = DB_getItem($_TABLES['users'], "username", "uid={$statUserUid}");
            $page->set_var('status_image', '<img src="' . $_FMCONF['imagesurl'] . 'padlock.gif">');
            $page->set_var('statusmessage', '* ' . sprintf($LANG_nexfile['msg08'], $statUser));
            $page->set_var('LANG_DOWNLOAD_MESSAGE', sprintf($LANG_nexfile['msg08'], $statUser));
            $page->set_var('disable_download', 'onClick="return false;"');
        } else {
            $page->set_var('show_statusmsg', 'none');
            $page->set_var('status_image', '&nbsp;');
            $page->set_var('statusmessage', '&nbsp;');
        }
        $query = DB_query("SELECT fname,version,notes,size,date,uid\r\n                    FROM {$_TABLES['nxfile_fileversions']}\r\n                    WHERE fid={$fid} AND version < {$curVersion} ORDER by version DESC");
        $cssid = 1;
        while (list($fname, $file_version, $ver_note, $ver_size, $ver_date, $submitter) = DB_fetchARRAY($query)) {
            $ver_shortdate = strftime($_CONF['shortdate'], $ver_date);
            $ver_longdate = COM_getUserDateTimeFormat($ver_date);
            $ver_longdate = $longdate[0];
            $ver_author = DB_getItem($_TABLES['users'], "username", "uid={$submitter}");
            $ver_size = intval($ver_size);
            if ($ver_size / 1000000 > 1) {
                $ver_size = round($ver_size / 1048576, 2) . " MB";
            } elseif ($ver_size / 1000 > 1) {
                $ver_size = round($ver_size / 1024, 2) . " KB";
            } else {
                $ver_size = round($ver_size, 2) . $LANG_FM02['BYTES'];
            }
            $pos = strrpos($fname, '.') + 1;
            $ext = strtolower(substr($fname, $pos));
            if (array_key_exists($ext, $_FMCONF['iconlib'])) {
                $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib'][$ext]);
            } else {
                $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib']['none']);
            }
            $page->set_var('vname', $fname);
            $page->set_var('ver_shortdate', $ver_shortdate);
            $page->set_var('ver_author', $ver_author);
            $page->set_var('ver_size', $ver_size);
            $page->set_var('ver_fileicon', $icon);
            $page->set_var('file_versionnum', '(V' . $file_version . ')');
            $page->set_var('file_version', $file_version);
            $page->set_var('edit_version_note', $ver_note);
            $page->set_var('version_note', nl2br($ver_note));
            if (fm_getPermission($cid, 'admin')) {
                $page->set_var('link_edit', '<a href="' . $_SERVER['PHP_SELF'] . '?op=editfile&fid=' . $fid . '&version=' . $file_version . '">' . $LANG_FM02['EDIT'] . '</a>');
                $page->set_var('link_delete', '<a href="' . $_SERVER['PHP_SELF'] . '?op=deletefile&fid=' . $fid . '&version=' . $file_version . '">' . $LANG_FM02['DELETE'] . '</a>');
            }
            $page->set_var('cssid', $cssid);
            $cssid = $cssid == 1 ? 2 : 1;
            $page->parse('version_records', 'versions', true);
        }
        $page->parse('output', 'page');
        $retval = $page->finish($page->get_var('output'));
    } else {
        $retval = "<p class=\"pluginAlert\">Error: nexdocsrv_filedetails({$fid}) - No file found.</p>";
    }
    return $retval;
}
示例#18
0
文件: markers.php 项目: ivywe/maps
/**
 * This function creates a map Form
 *
 * Creates a Form for a map using the supplied defaults (if specified).
 *
 * @param array $map array of values describing a map
 * @return string HTML string of map form
 */
function getUserMarkerForm($marker = array())
{
    global $_CONF, $_TABLES, $_MAPS_CONF, $LANG_MAPS_1, $LANG_configselects, $LANG_ACCESS, $_USER, $_GROUPS, $_SCRIPTS;
    $display = COM_startBlock('<h1>' . $LANG_MAPS_1['marker_edit'] . ' ' . $marker['name'] . '</h1>');
    $map_options = MAPS_recurseMaps($marker['mid']);
    if ($map_options == '') {
        $display .= COM_startBlock($LANG_MAPS_1['error'], '', 'blockheader-message.thtml');
        $display .= $LANG_MAPS_1['maps_empty'];
        $display .= COM_endBlock('blockfooter-message.thtml');
    } else {
        $template = new Template($_CONF['path'] . 'plugins/maps/templates');
        $template->set_file(array('map' => 'marker_user_form.thtml'));
        $template->set_var('site_url', $_MAPS_CONF['site_url']);
        $template->set_var('xhtml', XHTML);
        $template->set_var('goog_api_key', $_MAPS_CONF['google_api_key']);
        $template->set_var('go', $LANG_MAPS_1['go']);
        $template->set_var('edit_marker_text', $LANG_MAPS_1['edit_marker_text']);
        if (isset($marker['mkid'])) {
            $template->set_var('default_address', $marker['address']);
        } else {
            $template->set_var('default_address', '1600 Amphitheatre Pky, Mountain View, CA');
        }
        $template->set_var('yes', $LANG_MAPS_1['yes']);
        $template->set_var('no', $LANG_MAPS_1['no']);
        $template->set_var('arrow', '<img src="' . $_MAPS_CONF['site_url'] . '/images/arrow.png" alt=""align="absmiddle">&nbsp;');
        //informations
        $template->set_var('informations', $LANG_MAPS_1['informations']);
        $template->set_var('name_label', $LANG_MAPS_1['marker_name_label']);
        $template->set_var('name', stripslashes($marker['name']));
        $template->set_var('address_label', $LANG_MAPS_1['address_label']);
        $template->set_var('address', stripslashes($marker['address']));
        $template->set_var('empty_for_geo', $LANG_MAPS_1['empty_for_geo']);
        $template->set_var('lat', $LANG_MAPS_1['lat']);
        $template->set_var('lat_value', $marker['lat']);
        $template->set_var('lng', $LANG_MAPS_1['lng']);
        $template->set_var('lng_value', $marker['lng']);
        $template->set_var('select_marker_map', $LANG_MAPS_1['select_marker_map']);
        $template->set_var('mid_label', $LANG_MAPS_1['name_label']);
        $template->set_var('mid', $marker['mid']);
        $template->set_var('map_options', $map_options);
        $template->set_var('created_label', $LANG_MAPS_1['marker_created']);
        $template->set_var('modified_label', $LANG_MAPS_1['modified']);
        $datecreated = COM_getUserDateTimeFormat($marker['created']);
        $datemodified = COM_getUserDateTimeFormat($marker['modified']);
        $template->set_var('created', $datecreated[0]);
        $template->set_var('modified', $datemodified[0]);
        $template->set_var('required_field', $LANG_MAPS_1['required_field']);
        //marker
        $template->set_var('marker_customisation', $LANG_MAPS_1['marker_customisation']);
        $template->set_var('mk_default', $LANG_MAPS_1['mk_default']);
        if ($marker['mk_default'] == 0) {
            $template->set_var('mk_default_yes', '');
            $template->set_var('mk_default_no', ' selected');
        } else {
            $template->set_var('mk_default_yes', ' selected');
            $template->set_var('mk_default_no', '');
        }
        //icon
        $sql = "SELECT * FROM {$_TABLES['maps_map_icons']} WHERE 1=1";
        $result = DB_query($sql, 0);
        $radio = '<p>' . $LANG_MAPS_1['choose_icon'] . '</p>';
        $marker['mk_icon'] == 0 ? $checked = ' checked="checked"' : ($checked = '');
        $radio .= '<input type="radio" name="mk_icon" value="0"' . $checked . '>' . $LANG_MAPS_1['no_icon'] . '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
        while ($icon = DB_fetchArray($result, false)) {
            $marker['mk_icon'] == $icon['icon_id'] ? $checked = ' checked="checked"' : ($checked = '');
            $radio .= '<input type="radio" name="mk_icon" value="' . $icon['icon_id'] . '"' . $checked . '> <img src="' . $_MAPS_CONF['images_icons_url'] . $icon['icon_image'] . '" alt="' . $icon['icon_image'] . '">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
        }
        $radio .= '<hr' . XHTML . '>';
        $template->set_var('icon', $radio);
        $template->set_var('primary_color_label', $LANG_MAPS_1['primary_color_label']);
        $template->set_var('primary_color', $marker['mk_pcolor']);
        $template->set_var('stroke_color_label', $LANG_MAPS_1['stroke_color_label']);
        $template->set_var('stroke_color', $marker['mk_scolor']);
        $template->set_var('label_label', $LANG_MAPS_1['label']);
        $template->set_var('label', $marker['mk_label']);
        $template->set_var('label_color_label', $LANG_MAPS_1['label_color']);
        if ($marker['mk_label_color'] == '') {
            $marker['label_color'] = $_MAPS_CONF['label_color'];
        }
        if ($marker['mk_label_color'] == 1) {
            $template->set_var('label_color_white', ' selected');
            $template->set_var('label_color_black', '');
        } else {
            $template->set_var('label_color_white', '');
            $template->set_var('label_color_black', ' selected');
        }
        $template->set_var('black', $LANG_MAPS_1['black']);
        $template->set_var('white', $LANG_MAPS_1['white']);
        //Genaral settings
        $template->set_var('general_settings', $LANG_MAPS_1['general_settings']);
        //payed
        $template->set_var('payed', $LANG_MAPS_1['payed']);
        if ($marker['payed'] == '') {
            $marker['payed'] = $_MAPS_CONF['payed'];
        }
        if ($marker['payed'] == 1) {
            $template->set_var('payed_yes', ' selected');
            $template->set_var('payed_no', '');
        } else {
            $template->set_var('payed_yes', '');
            $template->set_var('payed_no', ' selected');
        }
        //active
        $template->set_var('active', $LANG_MAPS_1['marker_active']);
        if ($marker['active'] == '') {
            $marker['active'] = $_MAPS_CONF['map_active'];
        }
        if ($marker['active'] == 1) {
            $template->set_var('active_yes', ' selected');
            $template->set_var('active_no', '');
        } else {
            $template->set_var('active_yes', '');
            $template->set_var('active_no', ' selected');
        }
        //hidden
        $template->set_var('hidden', $LANG_MAPS_1['marker_hidden']);
        if ($marker['hidden'] == '') {
            $marker['hidden'] = $_MAPS_CONF['map_hidden'];
        }
        if ($marker['hidden'] == 1) {
            $template->set_var('hidden_yes', ' selected');
            $template->set_var('hidden_no', '');
        } else {
            $template->set_var('hidden_yes', '');
            $template->set_var('hidden_no', ' selected');
        }
        //validity
        $template->set_var('validity', $marker['validity']);
        $template->set_var('marker_validity', $LANG_MAPS_1['marker_validity']);
        if ($marker['validity'] == '') {
            $marker['validity'] = $_MAPS_CONF['map_hidden'];
        }
        if ($marker['validity'] == 1) {
            $template->set_var('validity_yes', ' selected');
            $template->set_var('validity_no', '');
            $template->set_var('disabled', '');
        } else {
            $template->set_var('validity_yes', '');
            $template->set_var('validity_no', ' selected');
            $template->set_var('disabled', ' disabled');
        }
        $template->set_var('from_label', $LANG_MAPS_1['from']);
        if ($marker['validity_start'] != '') {
            $datefrom = date("m/d/Y", strtotime($marker['validity_start']));
            $template->set_var('from', $datefrom);
        } else {
            $datefrom = date("m/d/Y");
            $template->set_var('from', $datefrom);
        }
        $template->set_var('to_label', $LANG_MAPS_1['to']);
        if ($marker['validity_end'] != '') {
            $dateto = date("m/d/Y", strtotime($marker['validity_end']));
            $template->set_var('to', $dateto);
        } else {
            $dateto = date("m/d/Y");
            $template->set_var('to', $dateto);
        }
        //note
        $template->set_var('remark_label', $LANG_MAPS_1['remark']);
        $template->set_var('remark', stripslashes($marker['remark']));
        //Tab presentation
        $template->set_var('presentation_tab', $LANG_MAPS_1['presentation_tab']);
        $template->set_var('description_label', $LANG_MAPS_1['description_label']);
        $template->set_var('description', stripslashes($marker['description']));
        $template->set_var('street_label', $LANG_MAPS_1['street_label']);
        if ($_MAPS_CONF['street'] == 1) {
            $template->set_var('street', '<input type="text" name="street" value="' . stripslashes($marker['street']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('street', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('code_label', $LANG_MAPS_1['code_label']);
        if ($_MAPS_CONF['code'] == 1) {
            $template->set_var('code', '<input type="text" name="code" value="' . $marker['code'] . '" size="10" maxlength="10">');
        } else {
            $template->set_var('code', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('city_label', $LANG_MAPS_1['city_label']);
        if ($_MAPS_CONF['city'] == 1) {
            $template->set_var('city', '<input type="text" name="city" value="' . stripslashes($marker['city']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('city', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('state_label', $LANG_MAPS_1['state_label']);
        if ($_MAPS_CONF['state'] == 1) {
            $template->set_var('state', '<input type="text" name="state" value="' . stripslashes($marker['state']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('state', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('country_label', $LANG_MAPS_1['country_label']);
        if ($_MAPS_CONF['country'] == 1) {
            $template->set_var('country', '<input type="text" name="country" value="' . stripslashes($marker['country']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('country', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('tel_label', $LANG_MAPS_1['tel_label']);
        if ($_MAPS_CONF['tel'] == 1) {
            $template->set_var('tel', '<input type="text" name="tel" value="' . $marker['tel'] . '" size="20" maxlength="20">');
        } else {
            $template->set_var('tel', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('fax_label', $LANG_MAPS_1['fax_label']);
        if ($_MAPS_CONF['fax'] == 1) {
            $template->set_var('fax', '<input type="text" name="fax" value="' . $marker['fax'] . '" size="20" maxlength="20">');
        } else {
            $template->set_var('fax', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('web_label', $LANG_MAPS_1['web_label']);
        if ($_MAPS_CONF['web'] == 1) {
            $template->set_var('web', '<input type="text" name="web" value="' . stripslashes($marker['web']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('web', $LANG_MAPS_1['not_use_see_config']);
        }
        //Tab ressources
        $template->set_var('ressources_tab', $LANG_MAPS_1['ressources_tab']);
        $template->set_var('max_char', $LANG_MAPS_1['max_char']);
        $arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        $ressources = '';
        foreach ($arr as &$value) {
            if ($_MAPS_CONF['item_' . $value] == '') {
                $template->set_var('item_' . $value . '_label', '');
                $template->set_var('item_' . $value, '');
                $ressources .= '';
            } else {
                $template->set_var('item_' . $value . '_label', $_MAPS_CONF['item_' . $value]);
                $template->set_var('item_' . $value, $marker['item_' . $value]);
                $ressources .= '<p>' . $_MAPS_CONF['item_' . $value] . ' <input type"text" name="item_' . $value . '" size="80" maxlength="255" value="' . $marker['item_' . $value] . '"></p>';
            }
        }
        if ($ressources == '') {
            $ressources = $LANG_MAPS_1['empty_ressources'];
        }
        $template->set_var('ressources', $ressources);
        // Permissions
        if ($marker['perm_owner'] == '') {
            SEC_setDefaultPermissions($marker, $_MAPS_CONF['default_permissions']);
        }
        $template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
        $template->set_var('lang_owner', $LANG_ACCESS['owner']);
        if ($marker['owner_id'] == '') {
            $marker['owner_id'] = $_USER['uid'];
        }
        $ownername = COM_getDisplayName($marker['owner_id']);
        $template->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$marker['owner_id']}"));
        $template->set_var('owner_name', $ownername);
        $template->set_var('owner', $ownername);
        $template->set_var('owner_id', $marker['owner_id']);
        if ($marker['group_id'] == '') {
            $marker['group_id'] = $_GROUPS['Maps Admin'];
        }
        $template->set_var('lang_group', $LANG_ACCESS['group']);
        //Todo make group = maps.admin
        $access = 3;
        $template->set_var('group_dropdown', SEC_getGroupDropdown($marker['group_id'], $access));
        $template->set_var('permissions_editor', SEC_getPermissionsHTML($marker['perm_owner'], $marker['perm_group'], $marker['perm_members'], $marker['perm_anon']));
        $template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
        $template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
        $template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
        $template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
        //Form validation
        $template->set_var('submission', $marker['submission']);
        $template->set_var('save_button', $LANG_MAPS_1['save_button']);
        $template->set_var('delete_button', $LANG_MAPS_1['delete_button']);
        $template->set_var('ok_button', $LANG_MAPS_1['ok_button']);
        $template->set_var('mkid', '<input type="hidden" name="mkid" value="' . $marker['mkid'] . '" />');
        $display .= $template->parse('output', 'map');
    }
    $display .= COM_endBlock();
    $_SCRIPTS->setJavaScriptLibrary('jquery');
    $_SCRIPTS->setJavaScriptFile('maps_simplecolor', '/' . $_MAPS_CONF['maps_folder'] . '/js/simple-color.js');
    $js = LB . '<script  type="text/javascript" src= "https://maps.googleapis.com/maps/api/js?key=' . $_MAPS_CONF['google_api_key'] . '&sensor=false"> </script>
    <script type="text/javascript">
	jQuery(document).ready(
        function()
        {
            jQuery("#primary_color").simpleColor({
				cellWidth: 9,
				cellHeight: 9,
				border: \'1px solid #333333\',
				displayColorCode: true
		    });
            jQuery("#stroke_color").simpleColor({
				cellWidth: 9,
				cellHeight: 9,
				border: \'1px solid #333333\',
				displayColorCode: true
		    });
			$( "#from" ).datepicker();
		    $( "#to" ).datepicker();
        });
		
		function changeValidity()
		{
		  if (document.getElementById(\'validity\').value == 0){
			 $("#from").prop(\'disabled\', true);
			 $("#to").prop(\'disabled\', true);

		  }
		  else {
			$("#from").prop(\'disabled\', false);
			$("#to").prop(\'disabled\', false);
		  }
		}

		jQuery(function() {
			jQuery(\'#from\').datepicker({
				altFormat:\'m/d/Y\'
			});
			jQuery(\'#to\').datepicker({
				altFormat:\'m/d/Y\',
			});
		});
		
		
		var geocoder = new google.maps.Geocoder();
		var map;

		function initializeGMap() {
			
			var mapOptions = {
			  center: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
			  zoom: 10,
			  mapTypeId: google.maps.MapTypeId.ROADMAP
			};
			
			map = new google.maps.Map(document.getElementById("map_canvas"),
				mapOptions);
				
			var marker = new google.maps.Marker({
			  map: map,
			  position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
			  title: "' . $marker['name'] . '",
			  draggable:true,
              animation: google.maps.Animation.DROP,
			});
			
			google.maps.event.addDomListener(marker, "dragend", function(evt) {
				document.getElementById(\'lat\').value = evt.latLng.lat().toFixed(6);
				document.getElementById(\'lng\').value = evt.latLng.lng().toFixed(6);
				//showInfoWindowHtml(marker);
			});
			
		}
		
		google.maps.event.addDomListener(window, \'load\', initializeGMap);
		
		function showInfoWindowHtml (marker) {
		  var latlng= marker.getLatLng();
		  var lat=latlng.lat();
		  var lng=latlng.lng();
		  //marker.openInfoWindowHtml(\'<p>{lat} \' + lat.toString() + \'</p><p>{lng} \' + lng.toString());
		  document.getElementById(\'lat\').value = lat;
		  document.getElementById(\'lng\').value = lng;
		}

		function codeAddress() {
		  var address = document.getElementById(\'geoaddress\').value;
		  geocoder.geocode( { \'address\': address}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
			  map.setCenter(results[0].geometry.location);
			  var marker = new google.maps.Marker({
				  map: map,
				  position: results[0].geometry.location
			  });
			  document.getElementById(\'lat\').value = results[0].geometry.location.lat(); 
              document.getElementById(\'lng\').value = results[0].geometry.location.lng(); 
			} else {
			  alert(\'Geocode was not successful for the following reason: \' + status);
			}
		  });
		}

		function limitText(limitField, limitCount, limitNum)
		{
			if (limitField.value.length > limitNum) {
				limitField.value = limitField.value.substring(0, limitNum);
			} else {
				limitCount.value = limitNum - limitField.value.length;
			}
		}

		function copyText()
		{
			var t1 = document.getElementById(\'geoaddress\').value;
			document.getElementById(\'address\').value = t1;
		}
		</script>' . LB . LB;
    $_SCRIPTS->setJavaScript($js, false);
    $_SCRIPTS->setJavaScriptFile('ui_core', '/javascript/jquery_ui/jquery.ui.core.min.js');
    $_SCRIPTS->setJavaScriptFile('datepicker', '/javascript/jquery_ui/jquery.ui.datepicker.min.js');
    return $display;
}
示例#19
0
/**
* Format one trackback comment for display
*
* Note: $excerpt is not truncated - this should have been done elsewhere
*
* @param    string      $url        URL of the trackback comment
* @param    string      $title      title of the comment (set to $url if empty)
* @param    string      $blog       name of the blog that sent the comment
* @param    string      $excerpt    excerpt from the comment
* @param    timestamp   $date       date and time when the comment was sent
* @param    boolean     $delete_option  whether to display a link to delete the trackback comment
* @param    string      $cid        id of this trackback comment
* @param    string      $ipaddress  IP address the comment was sent from
* @param    string      $token      security token
* @return   string                  HTML of the formatted trackback comment
*
*/
function TRB_formatComment($url, $title = '', $blog = '', $excerpt = '', $date = 0, $delete_option = false, $cid = '', $ipaddress = '', $token = '')
{
    global $_CONF, $LANG01, $LANG_TRB, $MESSAGE;
    if (empty($title)) {
        $title = $url;
    }
    if ($date == 0) {
        $date = time();
    }
    $curtime = COM_getUserDateTimeFormat($date);
    $template = COM_newTemplate($_CONF['path_layout'] . 'trackback');
    $template->set_file(array('comment' => 'formattedcomment.thtml'));
    $template->set_var('lang_from', $LANG_TRB['from']);
    $template->set_var('lang_tracked_on', $LANG_TRB['tracked_on']);
    $template->set_var('lang_readmore', $LANG_TRB['read_more']);
    $anchor = '<a href="' . $url . '">';
    $readmore = COM_createLink($LANG_TRB['read_more'], $url);
    $template->set_var('readmore_link', $readmore);
    $template->set_var('start_readmore_anchortag', $anchor);
    $template->set_var('end_readmore_anchortag', '</a>');
    $template->set_var('trackback_url', $url);
    $template->set_var('trackback_title', $title);
    $template->set_var('trackback_blog_name', $blog);
    $template->set_var('trackback_date', $curtime[0]);
    if (empty($blog)) {
        $template->set_var('trackback_from_blog_name', '');
    } else {
        $template->set_var('trackback_from_blog_name', $LANG_TRB['from'] . ' ' . $blog);
    }
    if (empty($excerpt)) {
        $template->set_var('trackback_excerpt', '');
        $template->set_var('trackback_excerpt_readmore', '');
        $template->set_var('excerpt_br', '');
    } else {
        $template->set_var('trackback_excerpt', $excerpt);
        $template->set_var('trackback_excerpt_readmore', $excerpt . ' ' . $readmore);
        $template->set_var('excerpt_br', '<br' . XHTML . '>');
    }
    $deloption = '';
    if ($delete_option) {
        $deloption .= '[ ';
        $deloption .= COM_createLink($LANG01[28], $_CONF['site_admin_url'] . '/trackback.php?mode=delete&amp;cid=' . $cid . '&amp;' . CSRF_TOKEN . '=' . $token, array('onclick' => "return confirm('{$MESSAGE[76]}');"));
        if (!empty($ipaddress)) {
            if (empty($_CONF['ip_lookup'])) {
                $deloption .= ' | ' . $ipaddress;
            } else {
                $iplookup = str_replace('*', $ipaddress, $_CONF['ip_lookup']);
                $deloption .= ' | ' . COM_createLink($ipaddress, $iplookup);
            }
        }
        $deloption .= ' ]';
    }
    $template->set_var('delete_option', $deloption);
    $template->parse('output', 'comment');
    return $template->finish($template->get_var('output'));
}
示例#20
0
/**
* Displays the static page editor form
*
* @param    array   $A      Data to display
* @return   string          HTML for the static page editor
*
*/
function staticpageeditor_form($A)
{
    global $_CONF, $_TABLES, $_USER, $_GROUPS, $_SP_CONF, $mode, $sp_id, $LANG21, $LANG_STATIC, $LANG_ACCESS, $LANG_ADMIN, $LANG01, $LANG24, $LANG_postmodes, $MESSAGE, $_IMAGE_TYPE, $_SCRIPTS;
    if (!empty($sp_id) && $mode == 'edit') {
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        if ($mode != 'clone') {
            $A['sp_inblock'] = $_SP_CONF['in_block'];
        }
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['Static Page Admin'])) {
            $A['group_id'] = $_GROUPS['Static Page Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('staticpages.edit');
        }
        SEC_setDefaultPermissions($A, $_SP_CONF['default_permissions']);
        $access = 3;
        if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
            $A['advanced_editor_mode'] = 1;
        }
    }
    $retval = '';
    $sp_template = COM_newTemplate(CTL_plugin_templatePath('staticpages', 'admin'));
    if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
        $sp_template->set_file('form', 'editor_advanced.thtml');
        // Shouldn't really have to check if anonymous user but who knows...
        if (COM_isAnonUser()) {
            $link_message = "";
        } else {
            $link_message = $LANG01[138];
        }
        $sp_template->set_var('noscript', COM_getNoScript(false, '', $link_message));
        // Setup Advanced Editor
        COM_setupAdvancedEditor('/staticpages/adveditor.js', 'staticpages.edit');
        $sp_template->set_var('lang_expandhelp', $LANG24[67]);
        $sp_template->set_var('lang_reducehelp', $LANG24[68]);
        $sp_template->set_var('lang_toolbar', $LANG24[70]);
        $sp_template->set_var('toolbar1', $LANG24[71]);
        $sp_template->set_var('toolbar2', $LANG24[72]);
        $sp_template->set_var('toolbar3', $LANG24[73]);
        $sp_template->set_var('toolbar4', $LANG24[74]);
        $sp_template->set_var('toolbar5', $LANG24[75]);
        $sp_template->set_var('lang_nojavascript', $LANG24[77]);
        $sp_template->set_var('lang_postmode', $LANG24[4]);
        if (isset($A['postmode']) && $A['postmode'] == 'adveditor') {
            $sp_template->set_var('show_adveditor', '');
            $sp_template->set_var('show_htmleditor', 'none');
        } else {
            $sp_template->set_var('show_adveditor', 'none');
            $sp_template->set_var('show_htmleditor', '');
        }
        $post_options = '<option value="html" selected="selected">' . $LANG_postmodes['html'] . '</option>';
        if (isset($A['postmode']) && $A['postmode'] == 'adveditor') {
            $post_options .= '<option value="adveditor" selected="selected">' . $LANG24[86] . '</option>';
        } else {
            $post_options .= '<option value="adveditor">' . $LANG24[86] . '</option>';
        }
        $sp_template->set_var('post_options', $post_options);
        $sp_template->set_var('change_editormode', 'onchange="change_editmode(this);"');
    } else {
        $sp_template->set_file('form', 'editor.thtml');
    }
    // Add JavaScript
    if ($_CONF['titletoid']) {
        $_SCRIPTS->setJavaScriptFile('title_2_id', '/javascript/title_2_id.js');
        $sp_template->set_var('titletoid', true);
    }
    $sp_template->set_var('lang_mode', $LANG24[3]);
    $sp_template->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $A['commentcode']));
    $sp_template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $sp_template->set_var('lang_owner', $LANG_ACCESS['owner']);
    $owner_name = COM_getDisplayName($A['owner_id']);
    $owner_username = DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}");
    $sp_template->set_var('owner_id', $A['owner_id']);
    $sp_template->set_var('owner', $owner_name);
    $sp_template->set_var('owner_name', $owner_name);
    $sp_template->set_var('owner_username', $owner_username);
    if ($A['owner_id'] > 1) {
        $profile_link = $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['owner_id'];
        $sp_template->set_var('start_owner_anchortag', '<a href="' . $profile_link . '">');
        $sp_template->set_var('end_owner_anchortag', '</a>');
        $sp_template->set_var('owner_link', COM_createLink($owner_name, $profile_link));
        $photo = '';
        if ($_CONF['allow_user_photo']) {
            $photo = DB_getItem($_TABLES['users'], 'photo', "uid = {$A['owner_id']}");
            if (!empty($photo)) {
                $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>';
                $sp_template->set_var('camera_icon', COM_createLink($camera_icon, $profile_link));
            }
        }
        if (empty($photo)) {
            $sp_template->set_var('camera_icon', '');
        }
    } else {
        $sp_template->set_var('start_owner_anchortag', '');
        $sp_template->set_var('end_owner_anchortag', '');
        $sp_template->set_var('owner_link', $owner_name);
    }
    $sp_template->set_var('lang_group', $LANG_ACCESS['group']);
    $sp_template->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $sp_template->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $sp_template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $sp_template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $sp_template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $sp_template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $token = SEC_createToken();
    $start_block = COM_startBlock($LANG_STATIC['staticpageeditor'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $start_block .= SEC_getTokenExpiryNotice($token);
    $sp_template->set_var('start_block_editor', $start_block);
    $sp_template->set_var('lang_save', $LANG_ADMIN['save']);
    $sp_template->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $sp_template->set_var('lang_preview', $LANG_ADMIN['preview']);
    if (SEC_hasRights('staticpages.delete') && $mode != 'clone' && !empty($A['sp_old_id'])) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $sp_template->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $sp_template->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
    } else {
        $sp_template->set_var('delete_option', '');
    }
    $sp_template->set_var('lang_writtenby', $LANG_STATIC['writtenby']);
    $sp_template->set_var('username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $authorname = COM_getDisplayName($A['owner_id']);
    $sp_template->set_var('name', $authorname);
    $sp_template->set_var('author', $authorname);
    $sp_template->set_var('lang_url', $LANG_STATIC['url']);
    $sp_template->set_var('lang_id', $LANG_STATIC['id']);
    $sp_template->set_var('sp_uid', $A['owner_id']);
    $sp_template->set_var('sp_id', $A['sp_id']);
    $sp_template->set_var('sp_old_id', $A['sp_old_id']);
    $sp_template->set_var('example_url', COM_buildURL($_CONF['site_url'] . '/staticpages/index.php?page=' . $A['sp_id']));
    $sp_template->set_var('lang_centerblock', $LANG_STATIC['centerblock']);
    $sp_template->set_var('lang_centerblock_help', $LANG_ADMIN['help_url']);
    $sp_template->set_var('lang_centerblock_include', $LANG21[51]);
    $sp_template->set_var('lang_centerblock_desc', $LANG21[52]);
    $sp_template->set_var('centerblock_help', $A['sp_help']);
    $sp_template->set_var('lang_centerblock_msg', $LANG_STATIC['centerblock_msg']);
    if (isset($A['sp_centerblock']) && $A['sp_centerblock'] == 1) {
        $sp_template->set_var('centerblock_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('centerblock_checked', '');
    }
    $sp_template->set_var('lang_position', $LANG_STATIC['position']);
    $position = '<select name="sp_where">';
    $position .= '<option value="1"';
    if ($A['sp_where'] == 1) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_top'] . '</option>';
    $position .= '<option value="2"';
    if ($A['sp_where'] == 2) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_feat'] . '</option>';
    $position .= '<option value="3"';
    if ($A['sp_where'] == 3) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_bottom'] . '</option>';
    $position .= '<option value="0"';
    if ($A['sp_where'] == 0) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_entire'] . '</option>';
    $position .= '</select>';
    $sp_template->set_var('pos_selection', $position);
    if ($_SP_CONF['allow_php'] == 1 && SEC_hasRights('staticpages.PHP')) {
        if (!isset($A['sp_php'])) {
            $A['sp_php'] = 0;
        }
        $selection = '<select name="sp_php">' . LB;
        $selection .= '<option value="0"';
        if ($A['sp_php'] <= 0 || $A['sp_php'] > 2) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_none'] . '</option>' . LB;
        $selection .= '<option value="1"';
        if ($A['sp_php'] == 1) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_return'] . '</option>' . LB;
        $selection .= '<option value="2"';
        if ($A['sp_php'] == 2) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_free'] . '</option>' . LB;
        $selection .= '</select>';
        $sp_template->set_var('php_selector', $selection);
        $sp_template->set_var('php_warn', $LANG_STATIC['php_warn']);
    } else {
        $sp_template->set_var('php_selector', '');
        $sp_template->set_var('php_warn', $LANG_STATIC['php_not_activated']);
    }
    $sp_template->set_var('php_msg', $LANG_STATIC['php_msg']);
    // old variables (for the 1.3-type checkbox)
    $sp_template->set_var('php_checked', '');
    $sp_template->set_var('php_type', 'hidden');
    if (isset($A['sp_nf']) && $A['sp_nf'] == 1) {
        $sp_template->set_var('exit_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('exit_checked', '');
    }
    $sp_template->set_var('exit_msg', $LANG_STATIC['exit_msg']);
    $sp_template->set_var('exit_info', $LANG_STATIC['exit_info']);
    if ($A['sp_inblock'] == 1) {
        $sp_template->set_var('inblock_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('inblock_checked', '');
    }
    $sp_template->set_var('inblock_msg', $LANG_STATIC['inblock_msg']);
    $sp_template->set_var('inblock_info', $LANG_STATIC['inblock_info']);
    if ($A['draft_flag'] == 1) {
        $sp_template->set_var('draft_flag_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('draft_flag_checked', '');
    }
    $sp_template->set_var('lang_draft', $LANG_STATIC['draft']);
    $sp_template->set_var('lang_cache_time', $LANG_STATIC['cache_time']);
    $sp_template->set_var('lang_cache_time_desc', $LANG_STATIC['cache_time_desc']);
    $sp_template->set_var('cache_time', $A['cache_time']);
    $curtime = COM_getUserDateTimeFormat($A['unixdate']);
    $sp_template->set_var('lang_lastupdated', $LANG_STATIC['date']);
    $sp_template->set_var('sp_formateddate', $curtime[0]);
    $sp_template->set_var('sp_date', $curtime[1]);
    $sp_template->set_var('lang_title', $LANG_STATIC['title']);
    $sp_template->set_var('lang_page_title', $LANG_STATIC['page_title']);
    $title = '';
    $page_title = '';
    if (isset($A['sp_title'])) {
        $title = htmlspecialchars(stripslashes($A['sp_title']));
    }
    if (isset($A['sp_page_title'])) {
        $page_title = htmlspecialchars(stripslashes($A['sp_page_title']));
    }
    $sp_template->set_var('sp_title', $title);
    $sp_template->set_var('sp_page_title', $page_title);
    $sp_template->set_var('lang_topic', $LANG_STATIC['topic']);
    if ($mode != 'clone') {
        // want to use default topic selection if new staticpage so pass in blank id
        $topic_sp_id = $A['sp_id'];
        if (empty($sp_id) && $mode == 'edit') {
            // means new
            $topic_sp_id = '';
        }
        $sp_template->set_var('topic_selection', TOPIC_getTopicSelectionControl('staticpages', $topic_sp_id, true, false, true));
    } else {
        $sp_template->set_var('topic_selection', TOPIC_getTopicSelectionControl('staticpages', $A['clone_sp_id'], true, false, true));
    }
    $sp_template->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $sp_template->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    if (!empty($A['meta_description'])) {
        $sp_template->set_var('meta_description', $A['meta_description']);
    }
    if (!empty($A['meta_keywords'])) {
        $sp_template->set_var('meta_keywords', $A['meta_keywords']);
    }
    if ($_CONF['meta_tags'] > 0 && $_SP_CONF['meta_tags'] > 0) {
        $sp_template->set_var('hide_meta', '');
    } else {
        $sp_template->set_var('hide_meta', ' style="display:none;"');
    }
    if ($A['template_flag'] == 1) {
        $sp_template->set_var('template_flag_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('template_flag_checked', '');
    }
    $sp_template->set_var('lang_template', $LANG_STATIC['template']);
    $sp_template->set_var('lang_template_flag_msg', $LANG_STATIC['template_msg']);
    $template_list = templatelist($A['template_id']);
    $template_none = '<option value=""';
    if ($A['template_id'] == "") {
        $template_none .= ' selected="selected"';
    }
    $template_none .= '>' . $LANG_STATIC['none'] . '</option>';
    $sp_template->set_var('use_template_selection', '<select name="template_id">' . $template_none . $template_list . '</select>');
    $sp_template->set_var('lang_use_template', $LANG_STATIC['use_template']);
    $sp_template->set_var('lang_use_template_msg', $LANG_STATIC['use_template_msg']);
    $sp_template->set_var('lang_addtomenu', $LANG_STATIC['addtomenu']);
    if (isset($A['sp_onmenu']) && $A['sp_onmenu'] == 1) {
        $sp_template->set_var('onmenu_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('onmenu_checked', '');
    }
    $sp_template->set_var('lang_label', $LANG_STATIC['label']);
    if (isset($A['sp_label'])) {
        $sp_template->set_var('sp_label', $A['sp_label']);
    } else {
        $sp_template->set_var('sp_label', '');
    }
    $sp_template->set_var('lang_pageformat', $LANG_STATIC['pageformat']);
    $sp_template->set_var('lang_blankpage', $LANG_STATIC['blankpage']);
    $sp_template->set_var('lang_noblocks', $LANG_STATIC['noblocks']);
    $sp_template->set_var('lang_leftblocks', $LANG_STATIC['leftblocks']);
    $sp_template->set_var('lang_leftrightblocks', $LANG_STATIC['leftrightblocks']);
    if (!isset($A['sp_format'])) {
        $A['sp_format'] = '';
    }
    if ($A['sp_format'] == 'noblocks') {
        $sp_template->set_var('noblock_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('noblock_selected', '');
    }
    if ($A['sp_format'] == 'leftblocks') {
        $sp_template->set_var('leftblocks_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('leftblocks_selected', '');
    }
    if ($A['sp_format'] == 'blankpage') {
        $sp_template->set_var('blankpage_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('blankpage_selected', '');
    }
    if ($A['sp_format'] == 'allblocks' or empty($A['sp_format'])) {
        $sp_template->set_var('allblocks_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('allblocks_selected', '');
    }
    $sp_template->set_var('lang_content', $LANG_STATIC['content']);
    $content = '';
    if (isset($A['sp_content'])) {
        $content = htmlspecialchars(stripslashes($A['sp_content']));
        $content = str_replace(array('{', '}'), array('&#123;', '&#125;'), $content);
    }
    $sp_template->set_var('sp_content', $content);
    $allowed = COM_allowedHTML('staticpages.edit', false, $_SP_CONF['filter_html']) . COM_allowedAutotags();
    $sp_template->set_var('lang_allowedhtml', $allowed);
    $sp_template->set_var('lang_allowed_html', $allowed);
    $sp_template->set_var('lang_hits', $LANG_STATIC['hits']);
    if (empty($A['sp_hits'])) {
        $sp_template->set_var('sp_hits', '0');
        $sp_template->set_var('sp_hits_formatted', '0');
    } else {
        $sp_template->set_var('sp_hits', $A['sp_hits']);
        $sp_template->set_var('sp_hits_formatted', COM_numberFormat($A['sp_hits']));
    }
    $sp_template->set_var('lang_comments', $LANG_STATIC['comments']);
    if ($A['commentcode'] == -1) {
        $sp_template->set_var('sp_comments', $LANG_ADMIN['na']);
    } else {
        $num_comments = DB_count($_TABLES['comments'], array('sid', 'type'), array(DB_escapeString($A['sp_id']), 'staticpages'));
        $sp_template->set_var('sp_comments', COM_numberFormat($num_comments));
    }
    $sp_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $sp_template->set_var('gltoken_name', CSRF_TOKEN);
    $sp_template->set_var('gltoken', $token);
    $sp_template->parse('output', 'form');
    $retval .= $sp_template->finish($sp_template->get_var('output'));
    return $retval;
}
示例#21
0
/**
* Prepare for optimizing tables
*
* @return   string  HTML form
*
*/
function DBADMIN_optimize()
{
    global $_CONF, $_TABLES, $LANG01, $LANG_ADMIN, $LANG_DB_BACKUP, $_IMAGE_TYPE;
    $retval = '';
    $lastrun = DB_getItem($_TABLES['vars'], 'UNIX_TIMESTAMP(value)', "name = 'lastoptimizeddb'");
    $T = COM_newTemplate($_CONF['path_layout'] . 'admin/dbadmin');
    $T->set_file('page', 'dbconvert.thtml');
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/database.php', 'text' => $LANG_DB_BACKUP['database_admin']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $T->set_var('start_block', COM_startBlock($LANG_DB_BACKUP['database_admin'], '', COM_getBlockTemplate('_admin_block', 'header')));
    $T->set_var('admin_menu', ADMIN_createMenu($menu_arr, "", $_CONF['layout_url'] . '/images/icons/database.' . $_IMAGE_TYPE));
    $T->set_var('lang_title', $LANG_DB_BACKUP['optimize_title']);
    $T->set_var('lang_conversion_instructions', $LANG_DB_BACKUP['optimize_explain']);
    $T->set_var('lang_conversion_status', $LANG_DB_BACKUP['optimization_message']);
    if (!empty($lastrun)) {
        $last = COM_getUserDateTimeFormat($lastrun);
        $T->set_var('lang_last_optimization', $LANG_DB_BACKUP['last_optimization']);
        $T->set_var('last_optimization', $last[0]);
    }
    $T->set_var('security_token', SEC_createToken());
    $T->set_var('security_token_name', CSRF_TOKEN);
    $T->set_var(array('lang_convert' => $LANG_DB_BACKUP['optimize_button'], 'lang_cancel' => $LANG_ADMIN['cancel'], 'lang_ok' => $LANG01['ok'], 'lang_converting' => $LANG_DB_BACKUP['optimizing'], 'lang_success' => $LANG_DB_BACKUP['optimize_success'], 'lang_ajax_status' => $LANG_DB_BACKUP['optimization_status'], 'to_engine' => 'all', 'action' => "dooptimize", 'mode' => "optimize"));
    $T->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $T->parse('output', 'page');
    $retval .= $T->finish($T->get_var('output'));
    return $retval;
}
示例#22
0
function showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1)
{
    global $CONF_FORUM, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02;
    global $fromblock, $highlight;
    global $oldPost, $forumfiles;
    $oldPost = 0;
    //$mytimer = new timerobject();
    //$mytimer->setPercision(2);
    //$mytimer->startTimer();
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time1: $intervalTime");
    if (!class_exists('StringParser')) {
        require_once $_CONF['path_html'] . 'forum/include/bbcode/stringparser_bbcode.class.php';
    }
    $topictemplate = new Template($_CONF['path_layout'] . 'forum/layout');
    $topictemplate->set_file(array('topictemplate' => 'topic.thtml', 'profile' => 'links/profile.thtml', 'pm' => 'links/pm.thtml', 'email' => 'links/email.thtml', 'website' => 'links/website.thtml', 'quote' => 'links/quotetopic.thtml', 'edit' => 'links/edittopic.thtml'));
    // if preview, only stripslashes is gpc=on, else assume from db so strip
    if ($mode == 'preview') {
        $showtopic['subject'] = COM_stripslashes($showtopic['subject']);
        $topictemplate->set_var('show_topicrow1', 'none');
        $topictemplate->set_var('show_topicrule', 'none');
        $topictemplate->set_var('lang_postpreview', $LANG_GF01['PREVIEW_HEADER']);
    } else {
        $showtopic['subject'] = stripslashes($showtopic['subject']);
        $topictemplate->set_var('show_topicrow2', 'none');
    }
    $min_height = 50;
    // Base minimum  height of topic - will increase if avatar or sig is used
    $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
    $userQuery = DB_query("SELECT * FROM {$_TABLES['users']} WHERE uid='{$showtopic['uid']}'");
    if ($showtopic['uid'] > 1 and DB_numRows($userQuery) == 1) {
        $userarray = DB_fetchArray($userQuery);
        $username = COM_getDisplayName($showtopic['uid']);
        $userlink = "<a href=\"{$_CONF['site_url']}/users.php?mode=profile&amp;uid={$showtopic['uid']}\" ";
        $userlink .= "class=\"authorname {$onetwo}\"><b>{$username}</b></a>";
        $uservalid = true;
        $postcount = DB_query("SELECT * FROM {$_TABLES['gf_topic']} WHERE uid='{$showtopic['uid']}'");
        $posts = DB_numRows($postcount);
        // STARS CODE
        $starimage = "<IMG SRC=\"%s\" ALT=\"{$LANG_GF01['FORUM']} %s\" TITLE=\"{$LANG_GF01['FORUM']} %s\">";
        if ($posts < $CONF_FORUM['level2']) {
            $user_level = sprintf($starimage, gf_getImage('rank1', 'ranks'), $CONF_FORUM['level1name'], $CONF_FORUM['level1name']);
            $user_levelname = $CONF_FORUM['level1name'];
        } elseif ($posts >= $CONF_FORUM['level2'] && $posts < $CONF_FORUM['level3']) {
            $user_level = sprintf($starimage, gf_getImage('rank2', 'ranks'), $CONF_FORUM['level2name'], $CONF_FORUM['level2name']);
            $user_levelname = $CONF_FORUM['level2name'];
        } elseif ($posts >= $CONF_FORUM['level3'] && $posts < $CONF_FORUM['level4']) {
            $user_level = sprintf($starimage, gf_getImage('rank3', 'ranks'), $CONF_FORUM['level3name'], $CONF_FORUM['level3name']);
            $user_levelname = $CONF_FORUM['level3name'];
        } elseif ($posts >= $CONF_FORUM['level4'] && $posts < $CONF_FORUM['level5']) {
            $user_level = sprintf($starimage, gf_getImage('rank4', 'ranks'), $CONF_FORUM['level4name'], $CONF_FORUM['level4name']);
            $user_levelname = $CONF_FORUM['level4name'];
        } elseif ($posts > $CONF_FORUM['level5']) {
            $user_level = sprintf($starimage, gf_getImage('rank5', 'ranks'), $CONF_FORUM['level5name'], $CONF_FORUM['level5name']);
            $user_levelname = $CONF_FORUM['level5name'];
        }
        if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) {
            $user_level = sprintf($starimage, gf_getImage('rank_mod', 'ranks'), $LANG_GF01['moderator'], $LANG_GF01['moderator']);
            $user_levelname = $LANG_GF01['moderator'];
        }
        if (SEC_inGroup(1, $showtopic['uid'])) {
            $user_level = sprintf($starimage, gf_getImage('rank_admin', 'ranks'), $LANG_GF01['admin'], $LANG_GF01['admin']);
            $user_levelname = $LANG_GF01['admin'];
        }
        if ($userarray['photo'] != "") {
            $avatar = USER_getPhoto($showtopic['uid'], '', '', $CONF_FORUM['avatar_width']);
            $min_height = $min_height + 50;
        }
        $regdate = $LANG_GF01['REGISTERED'] . ': ' . strftime('%m/%d/%y', strtotime($userarray['regdate'])) . '<br>';
        $numposts = $LANG_GF01['POSTS'] . ': ' . $posts;
        if (DB_count($_TABLES['sessions'], 'uid', $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid={$showtopic['uid']}") == 1) {
            $avatar .= '<br>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['ONLINE'];
        } else {
            $avatar .= '<br>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['OFFLINE'];
        }
        if ($userarray['sig'] != '') {
            $sig = '<hr width="95%" size="1" style="color=:black; text-align:left; margin-left:0; margin-bottom:5;padding:0" noshade>';
            $sig .= '<B>' . $userarray['sig'] . '</B>';
            $min_height = $min_height + 30;
        }
    } else {
        $uservalid = false;
        $userlink = '<b>' . $showtopic['name'] . '</b>';
        $userlink = '<font size="-2">' . $LANG_GF01['ANON'] . '</font>' . $showtopic['name'];
    }
    if ($CONF_FORUM['show_moods'] && $showtopic['mood'] != "") {
        $moodimage = '<img align="absmiddle" src="' . gf_getImage($showtopic['mood'], 'moods') . '" title="' . $showtopic['mood'] . '"><br>';
        $min_height = $min_height + 30;
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time3: $intervalTime");
    // Handle Pre ver 2.5 quoting and New Line Formatting - consider adding this to a migrate function
    if ($CONF_FORUM['pre2.5_mode']) {
        // try to determine if we have an old post...
        if (strstr($showtopic['comment'], '<pre class="forumCode">') !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "[code]<code>") !== false) {
            $oldPost = 1;
        }
        if (strstr($showtopic['comment'], "<pre>") !== false) {
            $oldPost = 1;
        }
        if (stristr($showtopic['comment'], '[code') == false || stristr($showtopic['comment'], '[code]<code>') == true) {
            if (strstr($showtopic['comment'], "<pre>") !== false) {
                $oldPost = 1;
            }
            $showtopic['comment'] = str_replace('<pre>', '[code]', $showtopic['comment']);
            $showtopic['comment'] = str_replace('</pre>', '[/code]', $showtopic['comment']);
        }
        $showtopic['comment'] = str_ireplace("[code]<code>", '[code]', $showtopic['comment']);
        $showtopic['comment'] = str_ireplace("</code>[/code]", '[/code]', $showtopic['comment']);
        $showtopic['comment'] = str_replace(array("<br />\r\n", "<br />\n\r", "<br />\r", "<br />\n"), '<br />', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=\\s(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        /* Reformat code blocks - version 2.3.3 and prior */
        $showtopic['comment'] = str_replace('<pre class="forumCode">', '[code]', $showtopic['comment']);
        $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']);
        if ($oldPost) {
            if (strstr($showtopic['comment'], "\\'") !== false) {
                $showtopic['comment'] = stripslashes($showtopic['comment']);
            }
        }
    }
    // Check and see if there are now no [file] bbcode tags in content and reset the show_inline value
    // This is needed in case user had used the file bbcode tag and then removed it
    if ($mode == 'preview' and strpos($showtopic['comment'], '[file]') === false) {
        $usql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 ";
        if (isset($_POST['uniqueid']) and $_POST['uniqueid'] > 0) {
            // User is previewing a new post
            $usql .= "WHERE topic_id = {$_POST['uniqueid']} AND tempfile=1 ";
        } else {
            if (isset($showtopic['id'])) {
                $usql .= "WHERE topic_id = {$showtopic['id']} ";
            }
        }
        DB_query($usql);
    }
    $showtopic['comment'] = gf_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode);
    $showtopic['subject'] = gf_formatTextBlock($showtopic['subject'], 'text', $mode);
    if (strlen($showtopic['subject']) > $CONF_FORUM['show_subject_length']) {
        $showtopic['subject'] = substr("{$showtopic['subject']}", 0, $CONF_FORUM['show_subject_length']);
        $showtopic['subject'] .= "...";
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time2: $intervalTime");
    if ($mode != 'preview' && $uservalid && $_USER['uid'] > 1 && $_USER['uid'] == $showtopic['uid']) {
        /* Check if user can still edit this post - within allowed edit timeframe */
        $editAllowed = false;
        if ($CONF_FORUM['allowed_editwindow'] > 0) {
            $t1 = $showtopic['date'];
            $t2 = $CONF_FORUM['allowed_editwindow'];
            if (time() - $t2 < $t1) {
                $editAllowed = true;
            }
        } else {
            $editAllowed = true;
        }
        if ($editAllowed) {
            $editlink = "{$_CONF['site_url']}/forum/createtopic.php?method=edit&forum={$showtopic['forum']}&id={$showtopic['id']}&editid={$showtopic['id']}&amp;page={$page}";
            $editlinkimg = '<img src="' . gf_getImage('edit_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['EDITICON'] . '" TITLE="' . $LANG_GF01['EDITICON'] . '">';
            $topictemplate->set_var('editlink', $editlink);
            $topictemplate->set_var('editlinkimg', $editlinkimg);
            $topictemplate->set_var('LANG_edit', $LANG_GF01['EDITICON']);
            $topictemplate->parse('edittopic_link', 'edit');
        }
    }
    if ($highlight != '') {
        $showtopic['subject'] = str_replace("{$highlight}", "<font class=highlight>{$highlight}</font>", $showtopic['subject']);
        $showtopic['comment'] = str_replace("{$highlight}", "<font class=highlight>{$highlight}</font>", $showtopic['comment']);
    }
    if ($showtopic['pid'] == 0) {
        $replytopicid = $showtopic['id'];
        $is_lockedtopic = $showtopic['locked'];
        $views = $showtopic['views'];
        $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views));
        if ($is_lockedtopic) {
            $topictemplate->set_var('locked_icon', '<img src="' . gf_getImage('padlock') . '" TITLE="' . $LANG_GF02['msg114'] . '">');
        }
    } else {
        $replytopicid = $showtopic['pid'];
        $is_lockedtopic = DB_getItem($_TABLES['gf_topic'], 'locked', "id={$showtopic['pid']}");
        $topictemplate->set_var('read_msg', '');
    }
    // Bookmark feature
    if ($_USER['uid'] > 1) {
        if (DB_count($_TABLES['gf_bookmarks'], array('uid', 'topic_id'), array($_USER['uid'], $showtopic['id']))) {
            $topictemplate->set_var('bookmark_icon', '<img src="' . gf_getImage('star_on_sm') . '" TITLE="' . $LANG_GF02['msg204'] . '">');
        } else {
            $topictemplate->set_var('bookmark_icon', '<img src="' . gf_getImage('star_off_sm') . '" TITLE="' . $LANG_GF02['msg203'] . '">');
        }
    }
    if ($CONF_FORUM['allow_user_dateformat']) {
        $date = COM_getUserDateTimeFormat($showtopic['date']);
        $topictemplate->set_var('posted_date', $date[0]);
    } else {
        $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']);
        $topictemplate->set_var('posted_date', $date);
    }
    if ($mode != 'preview') {
        if ($is_lockedtopic == 0) {
            $is_readonly = DB_getItem($_TABLES['gf_forums'], 'is_readonly', 'forum_id=' . $showtopic['forum']);
            if ($is_readonly == 0 or forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_edit')) {
                $quotelink = "{$_CONF['site_url']}/forum/createtopic.php?method=postreply&forum={$showtopic['forum']}&id={$replytopicid}&quoteid={$showtopic['id']}";
                $quotelinkimg = '<img src="' . gf_getImage('quote_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['QUOTEICON'] . '" TITLE="' . $LANG_GF01['QUOTEICON'] . '">';
                $topictemplate->set_var('quotelink', $quotelink);
                $topictemplate->set_var('quotelinkimg', $quotelinkimg);
                $topictemplate->set_var('LANG_quote', $LANG_GF01['QUOTEICON']);
                $topictemplate->parse('quotetopic_link', 'quote');
            }
        }
        //$topictemplate->set_var ('topic_post_link_begin', '<a name="'.$showtopic['id'].'">');
        //$topictemplate->set_var ('topic_post_link_end', '</a>');
        $mod_functions = forum_getmodFunctions($showtopic);
        if ($showtopic['uid'] > 1 && $uservalid) {
            $profile_link = "{$_CONF['site_url']}/users.php?mode=profile&uid={$showtopic['uid']}";
            $profile_linkimg = '<img src="' . gf_getImage('profile_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['ProfileLink'] . '" TITLE="' . $LANG_GF01['ProfileLink'] . '">';
            $topictemplate->set_var('profilelink', $profile_link);
            $topictemplate->set_var('profilelinkimg', $profile_linkimg);
            $topictemplate->set_var('LANG_profile', $LANG_GF01['ProfileLink']);
            $topictemplate->parse('profile_link', 'profile');
            if ($CONF_FORUM['use_pm_plugin']) {
                $pmusernmame = COM_getDisplayName($showtopic['uid']);
                $pmplugin_link = forumPLG_getPMlink($pmusernmame);
                if ($pmplugin_link != '') {
                    $pm_link = $pmplugin_link;
                    $pm_linkimg = '<img src="' . gf_getImage('pm_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['PMLink'] . '" TITLE="' . $LANG_GF01['PMLink'] . '">';
                    $topictemplate->set_var('pmlink', $pm_link);
                    $topictemplate->set_var('pmlinkimg', $pm_linkimg);
                    $topictemplate->set_var('LANG_pm', $LANG_GF01['PMLink']);
                    $topictemplate->parse('pm_link', 'pm');
                }
            }
        }
        if ($userarray['email'] != '' && $showtopic["uid"] > 1) {
            $email_link = "{$_CONF['site_url']}/profiles.php?uid={$showtopic['uid']}";
            $email_linkimg = '<img src="' . gf_getImage('email_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['EmailLink'] . '" TITLE="' . $LANG_GF01['EmailLink'] . '">';
            $topictemplate->set_var('emaillink', $email_link);
            $topictemplate->set_var('emaillinkimg', $email_linkimg);
            $topictemplate->set_var('LANG_email', $LANG_GF01['EmailLink']);
            $topictemplate->parse('email_link', 'email');
        }
        if ($userarray['homepage'] != '') {
            $homepage = $userarray['homepage'];
            if (!eregi("http", $homepage)) {
                $homepage = 'http://' . $homepage;
            }
            $homepageimg = '<img src="' . gf_getImage('website_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['WebsiteLink'] . '" TITLE="' . $LANG_GF01['WebsiteLink'] . '">';
            $topictemplate->set_var('websitelink', $homepage);
            $topictemplate->set_var('websitelinkimg', $homepageimg);
            $topictemplate->set_var('LANG_website', $LANG_GF01['WebsiteLink']);
            $topictemplate->parse('website_link', 'website');
        }
        if ($fromblock != "") {
            $back2 = $LANG_GF01['back2parent'];
        } else {
            $back2 = $LANG_GF01['back2top'];
        }
        $backlink = '<center><a href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $replytopicid . '">' . $back2 . '</a></center>';
    } else {
        if ($_GET['onlytopic'] != 1) {
            $topictemplate->set_var('posted_date', '');
            $topictemplate->set_var('preview_topic_subject', $showtopic['subject']);
        } else {
            $topictemplate->set_var('preview_topic_subject', '');
        }
        $topictemplate->set_var('read_msg', '');
        $topictemplate->set_var('locked_icon', '');
        $topictemplate->set_var('preview_mode', 'none');
        // Check and see if there are no [file] bbcode tags in content and reset the show_inline value
        // This is needed in case user had used the file bbcode tag and then removed it
        $imagerecs = '';
        if (is_array($forumfiles)) {
            $imagerecs = implode(',', $forumfiles);
        }
        if (!empty($_POST['uniqueid'])) {
            $sql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 WHERE topic_id={$_POST['uniqueid']} ";
            if ($imagerecs != '') {
                $sql .= "AND id NOT IN ({$imagerecs})";
            }
            DB_query($sql);
        } else {
            if (isset($_POST['id'])) {
                $sql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 WHERE topic_id={$_POST['id']} ";
                if ($imagerecs != '') {
                    $sql .= "AND id NOT IN ({$imagerecs})";
                }
                DB_query($sql);
            }
        }
    }
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time4: $intervalTime");
    $showtopic['comment'] = str_replace('{', '&#123;', $showtopic['comment']);
    $showtopic['comment'] = str_replace('}', '&#125;', $showtopic['comment']);
    $uniqueid = COM_applyFilter($_POST['uniqueid'], true);
    if ($showtopic['id'] > 0) {
        $topictemplate->set_var('attachments', gf_showattachments($showtopic['id']));
    } elseif ($uniqueid > 0) {
        $topictemplate->set_var('attachments', gf_showattachments($uniqueid));
    }
    $topictemplate->set_var('layout_url', $_CONF['layout_url']);
    $topictemplate->set_var('csscode', $onetwo);
    $topictemplate->set_var('postmode', $showtopic['postmode']);
    $topictemplate->set_var('userlink', $userlink);
    $topictemplate->set_var('lang_forum', $LANG_GF01['FORUM']);
    $topictemplate->set_var('user_levelname', $user_levelname);
    $topictemplate->set_var('user_level', $user_level);
    $topictemplate->set_var('magical_image', $moodimage);
    $topictemplate->set_var('avatar', $avatar);
    $topictemplate->set_var('regdate', $regdate);
    $topictemplate->set_var('numposts', $numposts);
    $topictemplate->set_var('location', $location);
    $topictemplate->set_var('site_url', $_CONF['site_url']);
    $topictemplate->set_var('imgset', $CONF_FORUM['imgset']);
    $topictemplate->set_var('topic_subject', $showtopic['subject']);
    $topictemplate->set_var('LANG_ON2', $LANG_GF01['ON2']);
    $topictemplate->set_var('mod_functions', $mod_functions);
    $topictemplate->set_var('topic_comment', $showtopic['comment']);
    $topictemplate->set_var('comment_minheight', "min-height:{$min_height}px");
    if (trim($sig) != '') {
        $topictemplate->set_var('sig', PLG_replaceTags($sig));
        $topictemplate->set_var('show_sig', '');
    } else {
        $topictemplate->set_var('sig', '');
        $topictemplate->set_var('show_sig', 'none');
    }
    $topictemplate->set_var('forumid', $showtopic['forum']);
    $topictemplate->set_var('topic_id', $showtopic['id']);
    $topictemplate->set_var('back_link', $backlink);
    $topictemplate->set_var('member_badge', forumPLG_getMemberBadge($showtopic['uid']));
    $topictemplate->parse('output', 'topictemplate');
    $retval .= $topictemplate->finish($topictemplate->get_var('output'));
    //$intervalTime = $mytimer->stopTimer();
    //COM_errorLog("Show Topic Display Time5: $intervalTime");
    return $retval;
}
示例#23
0
/**
* Shows story editor
*
* Displays the story entry form
*
* @param    string      $sid            ID of story to edit
* @param    string      $mode           'preview', 'edit', 'editsubmission', 'clone'
* @param    string      $errormsg       a message to display on top of the page
* @return   string      HTML for story editor
*
*/
function storyeditor($sid = '', $mode = '', $errormsg = '')
{
    global $_CONF, $_TABLES, $_USER, $LANG24, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS, $LANG_DIRECTION, $LANG_MONTH, $LANG_WEEK;
    $display = '';
    if (!isset($_CONF['hour_mode'])) {
        $_CONF['hour_mode'] = 12;
    }
    if (!empty($errormsg)) {
        $display .= COM_showMessageText($errormsg, $LANG24[25]);
    }
    $story = new Story();
    if ($mode == 'preview') {
        // Handle Magic GPC Garbage:
        while (list($key, $value) = each($_POST)) {
            if (!is_array($value)) {
                $_POST[$key] = COM_stripslashes($value);
            } else {
                while (list($subkey, $subvalue) = each($value)) {
                    $value[$subkey] = COM_stripslashes($subvalue);
                }
            }
        }
        $result = $story->loadFromArgsArray($_POST);
        if ($_CONF['maximagesperarticle'] > 0) {
            $errors = $story->checkAttachedImages();
            if (count($errors) > 0) {
                $msg = $LANG24[55] . LB . '<ul>' . LB;
                foreach ($errors as $err) {
                    $msg .= '<li>' . $err . '</li>' . LB;
                }
                $msg .= '</ul>' . LB;
                $display .= COM_showMessageText($msg, $LANG24[54]);
            }
        }
    } else {
        $result = $story->loadFromDatabase($sid, $mode);
    }
    if ($result == STORY_PERMISSION_DENIED || $result == STORY_NO_ACCESS_PARAMS) {
        $display .= COM_showMessageText($LANG24[42], $LANG_ACCESS['accessdenied']);
        COM_accessLog("User {$_USER['username']} tried to illegally access story {$sid}.");
        return $display;
    } elseif ($result == STORY_EDIT_DENIED || $result == STORY_EXISTING_NO_EDIT_PERMISSION) {
        $display .= COM_showMessageText($LANG24[41], $LANG_ACCESS['accessdenied']);
        $display .= STORY_renderArticle($story, 'p');
        COM_accessLog("User {$_USER['username']} tried to illegally edit story {$sid}.");
        return $display;
    } elseif ($result == STORY_INVALID_SID) {
        if ($mode == 'editsubmission') {
            // that submission doesn't seem to be there any more (may have been
            // handled by another Admin) - take us back to the moderation page
            return COM_refresh($_CONF['site_admin_url'] . '/moderation.php');
        } else {
            return COM_refresh($_CONF['site_admin_url'] . '/story.php');
        }
    } elseif ($result == STORY_DUPLICATE_SID) {
        $display .= COM_showMessageText($LANG24[24]);
    }
    // Load HTML templates
    $story_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/story');
    if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
        $story_templates->set_file(array('editor' => 'storyeditor_advanced.thtml'));
        $advanced_editormode = true;
        $story_templates->set_var('change_editormode', 'onchange="change_editmode(this);"');
        require_once $_CONF['path_system'] . 'classes/navbar.class.php';
        $story_templates->set_var('show_preview', 'none');
        $story_templates->set_var('lang_expandhelp', $LANG24[67]);
        $story_templates->set_var('lang_reducehelp', $LANG24[68]);
        $story_templates->set_var('lang_publishdate', $LANG24[69]);
        $story_templates->set_var('lang_toolbar', $LANG24[70]);
        $story_templates->set_var('toolbar1', $LANG24[71]);
        $story_templates->set_var('toolbar2', $LANG24[72]);
        $story_templates->set_var('toolbar3', $LANG24[73]);
        $story_templates->set_var('toolbar4', $LANG24[74]);
        $story_templates->set_var('toolbar5', $LANG24[75]);
        if ($story->EditElements('advanced_editor_mode') == 1 or $story->EditElements('postmode') == 'adveditor') {
            $story_templates->set_var('show_texteditor', 'none');
            $story_templates->set_var('show_htmleditor', '');
        } else {
            $story_templates->set_var('show_texteditor', '');
            $story_templates->set_var('show_htmleditor', 'none');
        }
    } else {
        $story_templates->set_file(array('editor' => 'storyeditor.thtml'));
        $advanced_editormode = false;
    }
    $story_templates->set_var('hour_mode', $_CONF['hour_mode']);
    if ($story->hasContent()) {
        $previewContent = STORY_renderArticle($story, 'p');
        if ($advanced_editormode and $previewContent != '') {
            $story_templates->set_var('preview_content', $previewContent);
        } elseif ($previewContent != '') {
            $display .= COM_startBlock($LANG24[26], '', COM_getBlockTemplate('_admin_block', 'header'));
            $display .= $previewContent;
            $display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
        }
    }
    if ($advanced_editormode) {
        $navbar = new navbar();
        if (!empty($previewContent)) {
            $navbar->add_menuitem($LANG24[79], 'showhideEditorDiv("preview",0);return false;', true);
            $navbar->add_menuitem($LANG24[80], 'showhideEditorDiv("editor",1);return false;', true);
            $navbar->add_menuitem($LANG24[81], 'showhideEditorDiv("publish",2);return false;', true);
            $navbar->add_menuitem($LANG24[82], 'showhideEditorDiv("images",3);return false;', true);
            $navbar->add_menuitem($LANG24[83], 'showhideEditorDiv("archive",4);return false;', true);
            $navbar->add_menuitem($LANG24[84], 'showhideEditorDiv("perms",5);return false;', true);
            $navbar->add_menuitem($LANG24[85], 'showhideEditorDiv("all",6);return false;', true);
        } else {
            $navbar->add_menuitem($LANG24[80], 'showhideEditorDiv("editor",0);return false;', true);
            $navbar->add_menuitem($LANG24[81], 'showhideEditorDiv("publish",1);return false;', true);
            $navbar->add_menuitem($LANG24[82], 'showhideEditorDiv("images",2);return false;', true);
            $navbar->add_menuitem($LANG24[83], 'showhideEditorDiv("archive",3);return false;', true);
            $navbar->add_menuitem($LANG24[84], 'showhideEditorDiv("perms",4);return false;', true);
            $navbar->add_menuitem($LANG24[85], 'showhideEditorDiv("all",5);return false;', true);
        }
        if ($mode == 'preview') {
            $story_templates->set_var('show_preview', '');
            $story_templates->set_var('show_htmleditor', 'none');
            $story_templates->set_var('show_texteditor', 'none');
            $story_templates->set_var('show_submitoptions', 'none');
            $navbar->set_selected($LANG24[79]);
        } else {
            $navbar->set_selected($LANG24[80]);
        }
        $story_templates->set_var('navbar', $navbar->generate());
    }
    $oldsid = $story->EditElements('originalSid');
    if (!empty($oldsid) && $mode != 'clone') {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $story_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $story_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
    }
    if ($mode == 'editsubmission' || $story->type == 'submission') {
        $story_templates->set_var('submission_option', '<input type="hidden" name="type" value="submission"' . XHTML . '>');
    }
    $story_templates->set_var('lang_author', $LANG24[7]);
    $storyauthor = COM_getDisplayName($story->EditElements('uid'));
    $story_templates->set_var('story_author', $storyauthor);
    $story_templates->set_var('author', $storyauthor);
    $story_templates->set_var('story_uid', $story->EditElements('uid'));
    // user access info
    $story_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $story_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($story->EditElements('owner_id'));
    $story_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', 'uid = ' . $story->EditElements('owner_id')));
    $story_templates->set_var('owner_name', $ownername);
    $story_templates->set_var('owner', $ownername);
    $story_templates->set_var('owner_id', $story->EditElements('owner_id'));
    $story_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $story_templates->set_var('group_dropdown', SEC_getGroupDropdown($story->EditElements('group_id'), 3));
    $story_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $story_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $story_templates->set_var('permissions_editor', SEC_getPermissionsHTML($story->EditElements('perm_owner'), $story->EditElements('perm_group'), $story->EditElements('perm_members'), $story->EditElements('perm_anon')));
    $story_templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $story_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $curtime = COM_getUserDateTimeFormat($story->EditElements('date'));
    $story_templates->set_var('lang_date', $LANG24[15]);
    $story_templates->set_var('publish_second', $story->EditElements('publish_second'));
    $publish_ampm = '';
    $publish_hour = $story->EditElements('publish_hour');
    if ($publish_hour >= 12) {
        if ($publish_hour > 12) {
            $publish_hour = $publish_hour - 12;
        }
        $ampm = 'pm';
    } else {
        $ampm = 'am';
    }
    $ampm_select = COM_getAmPmFormSelection('publish_ampm', $ampm);
    $story_templates->set_var('publishampm_selection', $ampm_select);
    $month_options = COM_getMonthFormOptions($story->EditElements('publish_month'));
    $story_templates->set_var('publish_month_options', $month_options);
    $day_options = COM_getDayFormOptions($story->EditElements('publish_day'));
    $story_templates->set_var('publish_day_options', $day_options);
    $year_options = COM_getYearFormOptions($story->EditElements('publish_year'));
    $story_templates->set_var('publish_year_options', $year_options);
    if ($_CONF['hour_mode'] == 24) {
        $hour_options = COM_getHourFormOptions($story->EditElements('publish_hour'), 24);
    } else {
        $hour_options = COM_getHourFormOptions($publish_hour);
    }
    $story_templates->set_var('publish_hour_options', $hour_options);
    $minute_options = COM_getMinuteFormOptions($story->EditElements('publish_minute'));
    $story_templates->set_var('publish_minute_options', $minute_options);
    $story_templates->set_var('publish_date_explanation', $LANG24[46]);
    $story_templates->set_var('story_unixstamp', $story->EditElements('unixdate'));
    $story_templates->set_var('expire_second', $story->EditElements('expire_second'));
    $expire_ampm = '';
    $expire_hour = $story->EditElements('expire_hour');
    if ($expire_hour >= 12) {
        if ($expire_hour > 12) {
            $expire_hour = $expire_hour - 12;
        }
        $ampm = 'pm';
    } else {
        $ampm = 'am';
    }
    $ampm_select = COM_getAmPmFormSelection('expire_ampm', $ampm);
    if (empty($ampm_select)) {
        // have a hidden field to 24 hour mode to prevent JavaScript errors
        $ampm_select = '<input type="hidden" name="expire_ampm" value=""' . XHTML . '>';
    }
    $story_templates->set_var('expireampm_selection', $ampm_select);
    $month_options = COM_getMonthFormOptions($story->EditElements('expire_month'));
    $story_templates->set_var('expire_month_options', $month_options);
    $day_options = COM_getDayFormOptions($story->EditElements('expire_day'));
    $story_templates->set_var('expire_day_options', $day_options);
    $year_options = COM_getYearFormOptions($story->EditElements('expire_year'));
    $story_templates->set_var('expire_year_options', $year_options);
    if ($_CONF['hour_mode'] == 24) {
        $hour_options = COM_getHourFormOptions($story->EditElements('expire_hour'), 24);
    } else {
        $hour_options = COM_getHourFormOptions($expire_hour);
    }
    $story_templates->set_var('expire_hour_options', $hour_options);
    $minute_options = COM_getMinuteFormOptions($story->EditElements('expire_minute'));
    $story_templates->set_var('expire_minute_options', $minute_options);
    $story_templates->set_var('expire_date_explanation', $LANG24[46]);
    $story_templates->set_var('story_unixstamp', $story->EditElements('expirestamp'));
    $atopic = DB_getItem($_TABLES['topics'], 'tid', "archive_flag = 1");
    $have_archive_topic = empty($atopic) ? false : true;
    if ($story->EditElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE) {
        $story_templates->set_var('is_checked2', 'checked="checked"');
        $story_templates->set_var('is_checked3', 'checked="checked"');
        $js_showarchivedisabled = 'false';
        $have_archive_topic = true;
        // force display of auto archive option
    } elseif ($story->EditElements('statuscode') == STORY_DELETE_ON_EXPIRE) {
        $story_templates->set_var('is_checked2', 'checked="checked"');
        $story_templates->set_var('is_checked4', 'checked="checked"');
        if (!$have_archive_topic) {
            $story_templates->set_var('is_checked3', 'style="display:none;"');
        }
        $js_showarchivedisabled = 'false';
    } else {
        if (!$have_archive_topic) {
            $story_templates->set_var('is_checked3', 'style="display:none;"');
        }
        $js_showarchivedisabled = 'true';
    }
    $story_templates->set_var('lang_archivetitle', $LANG24[58]);
    $story_templates->set_var('lang_option', $LANG24[59]);
    $story_templates->set_var('lang_enabled', $LANG_ADMIN['enabled']);
    $story_templates->set_var('lang_story_stats', $LANG24[87]);
    if ($have_archive_topic) {
        $story_templates->set_var('lang_optionarchive', $LANG24[61]);
    } else {
        $story_templates->set_var('lang_optionarchive', '');
    }
    $story_templates->set_var('lang_optiondelete', $LANG24[62]);
    $story_templates->set_var('lang_title', $LANG_ADMIN['title']);
    $story_templates->set_var('story_title', $story->EditElements('title'));
    $story_templates->set_var('lang_page_title', $LANG_ADMIN['page_title']);
    $story_templates->set_var('page_title', $story->EditElements('page_title'));
    $story_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $story_templates->set_var('meta_description', $story->EditElements('meta_description'));
    $story_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    $story_templates->set_var('meta_keywords', $story->EditElements('meta_keywords'));
    if ($_CONF['meta_tags'] > 0) {
        $story_templates->set_var('hide_meta', '');
    } else {
        $story_templates->set_var('hide_meta', ' style="display:none;"');
    }
    $story_templates->set_var('lang_topic', $LANG_ADMIN['topic']);
    if ($mode == 'preview') {
        $tlist = TOPIC_getTopicSelectionControl('article', '', false, true, true);
    } else {
        $tlist = TOPIC_getTopicSelectionControl('article', $oldsid, false, true, true);
    }
    if (empty($tlist)) {
        $display .= COM_showMessage(101);
        return $display;
    }
    $story_templates->set_var('topic_selection', $tlist);
    $story_templates->set_var('lang_show_topic_icon', $LANG24[56]);
    if ($story->EditElements('show_topic_icon') == 1) {
        $story_templates->set_var('show_topic_icon_checked', 'checked="checked"');
    } else {
        $story_templates->set_var('show_topic_icon_checked', '');
    }
    $story_templates->set_var('lang_cachetime', $LANG24['cache_time']);
    $story_templates->set_var('lang_cachetime_desc', $LANG24['cache_time_desc']);
    $story_templates->set_var('cache_time', $story->EditElements('cache_time'));
    $story_templates->set_var('lang_draft', $LANG24[34]);
    if ($story->EditElements('draft_flag')) {
        $story_templates->set_var('is_checked', 'checked="checked"');
    }
    $story_templates->set_var('lang_mode', $LANG24[3]);
    $story_templates->set_var('status_options', COM_optionList($_TABLES['statuscodes'], 'code,name', $story->EditElements('statuscode')));
    $story_templates->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $story->EditElements('commentcode')));
    $story_templates->set_var('trackback_options', COM_optionList($_TABLES['trackbackcodes'], 'code,name', $story->EditElements('trackbackcode')));
    // comment expire
    $story_templates->set_var('lang_cmt_disable', $LANG24[63]);
    if ($story->EditElements('cmt_close')) {
        $story_templates->set_var('is_checked5', 'checked="checked"');
        $js_showcmtclosedisabled = 'false';
    } else {
        $js_showcmtclosedisabled = 'true';
    }
    $month_options = COM_getMonthFormOptions($story->EditElements('cmt_close_month'));
    $story_templates->set_var('cmt_close_month_options', $month_options);
    $day_options = COM_getDayFormOptions($story->EditElements('cmt_close_day'));
    $story_templates->set_var('cmt_close_day_options', $day_options);
    // ensure that the year dropdown includes the close year
    $endtm = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
    $yoffset = date('Y', $endtm) - date('Y');
    $close_year = $story->EditElements('cmt_close_year');
    if ($yoffset < -1) {
        $year_options = COM_getYearFormOptions($close_year, $yoffset);
    } elseif ($yoffset > 5) {
        $year_options = COM_getYearFormOptions($close_year, -1, $yoffset);
    } else {
        $year_options = COM_getYearFormOptions($close_year);
    }
    $story_templates->set_var('cmt_close_year_options', $year_options);
    $cmt_close_ampm = '';
    $cmt_close_hour = $story->EditElements('cmt_close_hour');
    //correct hour
    if ($cmt_close_hour >= 12) {
        if ($cmt_close_hour > 12) {
            $cmt_close_hour = $cmt_close_hour - 12;
        }
        $ampm = 'pm';
    } else {
        $ampm = 'am';
    }
    $ampm_select = COM_getAmPmFormSelection('cmt_close_ampm', $ampm);
    if (empty($ampm_select)) {
        // have a hidden field to 24 hour mode to prevent JavaScript errors
        $ampm_select = '<input type="hidden" name="cmt_close_ampm" value=""' . XHTML . '>';
    }
    $story_templates->set_var('cmt_close_ampm_selection', $ampm_select);
    if ($_CONF['hour_mode'] == 24) {
        $hour_options = COM_getHourFormOptions($story->EditElements('cmt_close_hour'), 24);
    } else {
        $hour_options = COM_getHourFormOptions($cmt_close_hour);
    }
    $story_templates->set_var('cmt_close_hour_options', $hour_options);
    $minute_options = COM_getMinuteFormOptions($story->EditElements('cmt_close_minute'));
    $story_templates->set_var('cmt_close_minute_options', $minute_options);
    $story_templates->set_var('cmt_close_second', $story->EditElements('cmt_close_second'));
    if ($_CONF['onlyrootfeatures'] == 1 && SEC_inGroup('Root') or $_CONF['onlyrootfeatures'] !== 1) {
        $featured_options = "<select name=\"featured\">" . LB . COM_optionList($_TABLES['featurecodes'], 'code,name', $story->EditElements('featured')) . "</select>" . LB;
    } else {
        $featured_options = "<input type=\"hidden\" name=\"featured\" value=\"0\"" . XHTML . ">";
    }
    $story_templates->set_var('featured_options', $featured_options);
    $story_templates->set_var('frontpage_options', COM_optionList($_TABLES['frontpagecodes'], 'code,name', $story->EditElements('frontpage')));
    $story_templates->set_var('story_introtext', $story->EditElements('introtext'));
    $story_templates->set_var('story_bodytext', $story->EditElements('bodytext'));
    $story_templates->set_var('lang_introtext', $LANG24[16]);
    $story_templates->set_var('lang_bodytext', $LANG24[17]);
    $story_templates->set_var('lang_postmode', $LANG24[4]);
    $story_templates->set_var('lang_publishoptions', $LANG24[76]);
    $story_templates->set_var('noscript', COM_getNoScript(false, $LANG24[77], sprintf($LANG24[78], $_CONF['site_admin_url'], $sid)));
    $postmode = $story->EditElements('postmode');
    if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
        if ($story->EditElements('advanced_editor_mode') == 1 or $story->EditElements('postmode') == 'adveditor') {
            $postmode = '';
        }
    }
    $post_options = COM_optionList($_TABLES['postmodes'], 'code,name', $postmode);
    $postmode_list = 'plaintext,html';
    // If Advanced Mode - add post option and set default if editing story created with Advanced Editor
    if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
        $postmode_list .= ',adveditor';
        if ($story->EditElements('advanced_editor_mode') == 1 or $story->EditElements('postmode') == 'adveditor') {
            $post_options .= '<option value="adveditor" selected="selected">' . $LANG24[86] . '</option>';
        } else {
            $post_options .= '<option value="adveditor">' . $LANG24[86] . '</option>';
        }
    }
    if ($_CONF['wikitext_editor']) {
        $postmode_list .= ',wikitext';
        if ($story->EditElements('postmode') == 'wikitext') {
            $post_options .= '<option value="wikitext" selected="selected">' . $LANG24[88] . '</option>';
        } else {
            $post_options .= '<option value="wikitext">' . $LANG24[88] . '</option>';
        }
    }
    $story_templates->set_var('post_options', $post_options);
    $postmode_array = explode(',', $postmode_list);
    $allowed_html = '';
    foreach ($postmode_array as $pm) {
        $allowed_html .= COM_allowedHTML('story.edit', false, 1, $pm);
    }
    $allowed_tags = array('code', 'raw');
    if ($_CONF['allow_page_breaks'] == 1) {
        $allowed_tags = array_merge($allowed_tags, array('page_break'));
    }
    $allowed_html .= COM_allowedAutotags(false, $allowed_tags);
    $story_templates->set_var('lang_allowed_html', $allowed_html);
    $fileinputs = '';
    $saved_images = '';
    if ($_CONF['maximagesperarticle'] > 0) {
        $story_templates->set_var('lang_images', $LANG24[47]);
        $icount = DB_count($_TABLES['article_images'], 'ai_sid', $story->getSid());
        if ($icount > 0) {
            $result_articles = DB_query("SELECT * FROM {$_TABLES['article_images']} WHERE ai_sid = '" . $story->getSid() . "'");
            for ($z = 1; $z <= $icount; $z++) {
                $I = DB_fetchArray($result_articles);
                $saved_images .= $z . ') ' . COM_createLink($I['ai_filename'], $_CONF['site_url'] . '/images/articles/' . $I['ai_filename']) . '&nbsp;&nbsp;&nbsp;' . $LANG_ADMIN['delete'] . ': <input type="checkbox" name="delete[' . $I['ai_img_num'] . ']"' . XHTML . '><br' . XHTML . '>';
            }
        }
        $newallowed = $_CONF['maximagesperarticle'] - $icount;
        for ($z = $icount + 1; $z <= $_CONF['maximagesperarticle']; $z++) {
            $fileinputs .= $z . ') <input type="file" dir="ltr" name="file' . $z . '"' . XHTML . '>';
            if ($z < $_CONF['maximagesperarticle']) {
                $fileinputs .= '<br' . XHTML . '>';
            }
        }
        $fileinputs .= '<br' . XHTML . '>' . $LANG24[51];
        if ($_CONF['allow_user_scaling'] == 1) {
            $fileinputs .= $LANG24[27];
        }
        $fileinputs .= $LANG24[28] . '<br' . XHTML . '>';
    }
    // Add JavaScript
    $_SCRIPTS->setJavaScriptFile('story_editor', '/javascript/story_editor.js');
    if ($_CONF['titletoid']) {
        $_SCRIPTS->setJavaScriptFile('title_2_id', '/javascript/title_2_id.js');
        $story_templates->set_var('titletoid', true);
    }
    $_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.js');
    // Loads jQuery UI datepicker and timepicker-addon
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.slider');
    //    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.button');
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon-i18n');
    //    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-slideraccess');
    $_SCRIPTS->setJavaScriptFile('datetimepicker', '/javascript/datetimepicker.js');
    $langCode = COM_getLangIso639Code();
    $toolTip = $MESSAGE[118];
    $imgUrl = $_CONF['site_url'] . '/images/calendar.png';
    $_SCRIPTS->setJavaScript("jQuery(function () {" . "  geeklog.hour_mode = {$_CONF['hour_mode']};" . "  geeklog.datetimepicker.set('publish', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('expire', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('cmt_close', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE);
    // Setup Advanced Editor
    COM_setupAdvancedEditor('/javascript/storyeditor_adveditor.js');
    $story_templates->set_var('saved_images', $saved_images);
    $story_templates->set_var('image_form_elements', $fileinputs);
    $story_templates->set_var('lang_hits', $LANG24[18]);
    $story_templates->set_var('story_hits', $story->EditElements('hits'));
    $story_templates->set_var('lang_comments', $LANG24[19]);
    $story_templates->set_var('story_comments', $story->EditElements('comments'));
    $story_templates->set_var('lang_trackbacks', $LANG24[29]);
    $story_templates->set_var('story_trackbacks', $story->EditElements('trackbacks'));
    $story_templates->set_var('lang_emails', $LANG24[39]);
    $story_templates->set_var('story_emails', $story->EditElements('numemails'));
    if ($mode == 'clone') {
        $story_templates->set_var('story_id', COM_makesid());
    } else {
        $story_templates->set_var('story_id', $story->getSid());
        $story_templates->set_var('old_story_id', $story->EditElements('originalSid'));
    }
    $story_templates->set_var('lang_sid', $LANG24[12]);
    $story_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $story_templates->set_var('lang_preview', $LANG_ADMIN['preview']);
    $story_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $story_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
    $story_templates->set_var('gltoken_name', CSRF_TOKEN);
    $token = SEC_createToken();
    $story_templates->set_var('gltoken', $token);
    $story_templates->parse('output', 'editor');
    $display .= COM_startBlock($LANG24[5], '', COM_getBlockTemplate('_admin_block', 'header'));
    $display .= SEC_getTokenExpiryNotice($token, $LANG24[91]);
    $display .= $story_templates->finish($story_templates->get_var('output'));
    $display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $display;
}
示例#24
0
/**
* Returns the site header
*
* This loads the proper templates, does variable substitution and returns the
* HTML for the site header with or without blocks depending on the value of $what
*
* Programming Note:
*
* The two functions COM_siteHeader and COM_siteFooter provide the framework for
* page display in Geeklog.  COM_siteHeader controls the display of the Header
* and left blocks and COM_siteFooter controls the dsiplay of the right blocks
* and the footer.  You use them like a sandwich.  Thus the following code will
* display a Geeklog page with both right and left blocks displayed.
*
* <code>
* <?php
* require_once 'lib-common.php';
* // Change to COM_siteHeader('none') to not display left blocks
* $display .= COM_siteHeader();
* $display .= "Here is your html for display";
* // Change to COM_siteFooter() to not display right blocks
* $display .= COM_siteFooter(true);
* echo $display;
* ? >
* </code>
*
* Note that the default for the header is to display the left blocks and the
* default of the footer is to not display the right blocks.
*
* This sandwich produces code like this (greatly simplified)
* <code>
* // COM_siteHeader
* <table><tr><td colspan="3">Header</td></tr>
* <tr><td>Left Blocks</td><td>
*
* // Your HTML goes here
* Here is your html for display
*
* // COM_siteFooter
* </td><td>Right Blocks</td></tr>
* <tr><td colspan="3">Footer</td></table>
* </code>
*
* @param    string  $what       If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned
* @param    string  $pagetitle  optional content for the page's <title>
* @param    string  $headercode optional code to go into the page's <head>
* @return   string              Formatted HTML containing the site header
* @see function COM_siteFooter
*
*/
function COM_siteHeader($what = 'menu', $pagetitle = '', $headercode = '')
{
    global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_BUTTONS, $LANG_DIRECTION, $_IMAGE_TYPE, $topic, $_COM_VERBOSE, $_SCRIPTS;
    // If the theme implemented this for us then call their version instead.
    $function = $_CONF['theme'] . '_siteHeader';
    if (function_exists($function)) {
        return $function($what, $pagetitle, $headercode);
    }
    // If we reach here then either we have the default theme OR
    // the current theme only needs the default variable substitutions
    switch ($_CONF['doctype']) {
        case 'html401transitional':
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
            break;
        case 'html401strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
            break;
        case 'xhtml10transitional':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
            break;
        case 'xhtml10strict':
            $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            break;
        default:
            // fallback: HTML 4.01 Transitional w/o system identifier
            $doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
            break;
    }
    // send out the charset header
    header('Content-Type: text/html; charset=' . COM_getCharset());
    if (!empty($_CONF['frame_options'])) {
        header('X-FRAME-OPTIONS: ' . $_CONF['frame_options']);
    }
    $header = COM_newTemplate($_CONF['path_layout']);
    $header->set_file(array('header' => 'header.thtml', 'menuitem' => 'menuitem.thtml', 'menuitem_last' => 'menuitem_last.thtml', 'menuitem_none' => 'menuitem_none.thtml', 'leftblocks' => 'leftblocks.thtml', 'rightblocks' => 'rightblocks.thtml'));
    $header->postprocess_fn = 'PLG_replaceTags';
    $header->set_var('doctype', $doctype);
    if (XHTML == '') {
        $header->set_var('xmlns', '');
    } else {
        $header->set_var('xmlns', ' xmlns="http://www.w3.org/1999/xhtml"');
    }
    // get topic if not on home page
    if (!isset($_GET['topic'])) {
        if (isset($_GET['story'])) {
            $sid = COM_applyFilter($_GET['story']);
        } elseif (isset($_GET['sid'])) {
            $sid = COM_applyFilter($_GET['sid']);
        } elseif (isset($_POST['story'])) {
            $sid = COM_applyFilter($_POST['story']);
        }
        if (empty($sid) && $_CONF['url_rewrite'] && strpos($_SERVER['PHP_SELF'], 'article.php') !== false) {
            COM_setArgNames(array('story', 'mode'));
            $sid = COM_applyFilter(COM_getArgument('story'));
        }
        if (!empty($sid)) {
            $topic = DB_getItem($_TABLES['stories'], 'tid', "sid='{$sid}'");
        }
    } else {
        $topic = COM_applyFilter($_GET['topic']);
    }
    $feed_url = array();
    if ($_CONF['backend'] == 1) {
        $baseurl = SYND_getFeedUrl();
        $sql = 'SELECT format, filename, title, language FROM ' . $_TABLES['syndication'] . " WHERE (header_tid = 'all')";
        if (!empty($topic)) {
            $sql .= " OR (header_tid = '" . addslashes($topic) . "')";
        }
        $result = DB_query($sql);
        $numRows = DB_numRows($result);
        for ($i = 0; $i < $numRows; $i++) {
            $A = DB_fetchArray($result);
            if (!empty($A['filename'])) {
                $format_type = SYND_getMimeType($A['format']);
                $format_name = SYND_getFeedType($A['format']);
                $feed_title = $format_name . ' Feed: ' . $A['title'];
                $feed_url[] = '<link rel="alternate" type="' . $format_type . '" hreflang="' . $A['language'] . '" href="' . $baseurl . $A['filename'] . '" title="' . htmlspecialchars($feed_title) . '"' . XHTML . '>';
            }
        }
    }
    $header->set_var('feed_url', implode(LB, $feed_url));
    // for backward compatibility only - use {feed_url} instead
    $feed = SYND_getDefaultFeedUrl();
    $header->set_var('rdf_file', $feed);
    $header->set_var('rss_url', $feed);
    $relLinks = array();
    if (COM_onFrontpage()) {
        $relLinks['canonical'] = '<link rel="canonical" href="' . $_CONF['site_url'] . '/"' . XHTML . '>';
    } else {
        $relLinks['home'] = '<link rel="home" href="' . $_CONF['site_url'] . '/" title="' . $LANG01[90] . '"' . XHTML . '>';
    }
    $loggedInUser = !COM_isAnonUser();
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['searchloginrequired'] == 0) {
        if (substr($_SERVER['PHP_SELF'], -strlen('/search.php')) != '/search.php' || isset($_GET['mode'])) {
            $relLinks['search'] = '<link rel="search" href="' . $_CONF['site_url'] . '/search.php" title="' . $LANG01[75] . '"' . XHTML . '>';
        }
    }
    if ($loggedInUser || $_CONF['loginrequired'] == 0 && $_CONF['directoryloginrequired'] == 0) {
        if (strpos($_SERVER['PHP_SELF'], '/article.php') !== false) {
            $relLinks['contents'] = '<link rel="contents" href="' . $_CONF['site_url'] . '/directory.php" title="' . $LANG01[117] . '"' . XHTML . '>';
        }
    }
    if (!$_CONF['disable_webservices']) {
        $relLinks['service'] = '<link rel="service" ' . 'type="application/atomsvc+xml" ' . 'href="' . $_CONF['site_url'] . '/webservices/atom/?introspection" ' . 'title="' . $LANG01[130] . '"' . XHTML . '>';
    }
    // TBD: add a plugin API and a lib-custom.php function
    $header->set_var('rel_links', implode(LB, $relLinks));
    $pagetitle_siteslogan = false;
    if (empty($pagetitle)) {
        if (empty($topic)) {
            $pagetitle = $_CONF['site_slogan'];
            $pagetitle_siteslogan = true;
        } else {
            $pagetitle = stripslashes(DB_getItem($_TABLES['topics'], 'topic', "tid = '{$topic}'"));
        }
    }
    if (!empty($pagetitle)) {
        $header->set_var('page_site_splitter', ' - ');
    } else {
        $header->set_var('page_site_splitter', '');
    }
    $header->set_var('page_title', $pagetitle);
    $header->set_var('site_name', $_CONF['site_name']);
    if (COM_onFrontpage() or $pagetitle_siteslogan) {
        $title_and_name = $_CONF['site_name'];
        if (!empty($pagetitle)) {
            $title_and_name .= ' - ' . $pagetitle;
        }
    } else {
        $title_and_name = '';
        if (!empty($pagetitle)) {
            $title_and_name = $pagetitle . ' - ';
        }
        $title_and_name .= $_CONF['site_name'];
    }
    $header->set_var('page_title_and_site_name', $title_and_name);
    COM_setLangIdAndAttribute($header);
    $header->set_var('background_image', $_CONF['layout_url'] . '/images/bg.' . $_IMAGE_TYPE);
    $header->set_var('site_mail', "mailto:{$_CONF['site_mail']}");
    $header->set_var('site_name', $_CONF['site_name']);
    $header->set_var('site_slogan', $_CONF['site_slogan']);
    $msg = rtrim($LANG01[67]) . ' ' . $_CONF['site_name'];
    if (!empty($_USER['username'])) {
        $msg .= ', ' . COM_getDisplayName($_USER['uid'], $_USER['username'], $_USER['fullname']);
    }
    $curtime = COM_getUserDateTimeFormat();
    $header->set_var('welcome_msg', $msg);
    $header->set_var('datetime', $curtime[0]);
    $header->set_var('site_logo', $_CONF['layout_url'] . '/images/logo.' . $_IMAGE_TYPE);
    $header->set_var('theme', $_CONF['theme']);
    $header->set_var('charset', COM_getCharset());
    $header->set_var('direction', $LANG_DIRECTION);
    // Now add variables for buttons like e.g. those used by the Yahoo theme
    $header->set_var('button_home', $LANG_BUTTONS[1]);
    $header->set_var('button_contact', $LANG_BUTTONS[2]);
    $header->set_var('button_contribute', $LANG_BUTTONS[3]);
    $header->set_var('button_sitestats', $LANG_BUTTONS[7]);
    $header->set_var('button_personalize', $LANG_BUTTONS[8]);
    $header->set_var('button_search', $LANG_BUTTONS[9]);
    $header->set_var('button_advsearch', $LANG_BUTTONS[10]);
    $header->set_var('button_directory', $LANG_BUTTONS[11]);
    // Get plugin menu options
    $plugin_menu = PLG_getMenuItems();
    if ($_COM_VERBOSE) {
        COM_errorLog('num plugin menu items in header = ' . count($plugin_menu), 1);
    }
    // Now add nested template for menu items
    COM_renderMenu($header, $plugin_menu);
    if (count($plugin_menu) == 0) {
        $header->parse('plg_menu_elements', 'menuitem_none', true);
    } else {
        $count_plugin_menu = count($plugin_menu);
        for ($i = 1; $i <= $count_plugin_menu; $i++) {
            $header->set_var('menuitem_url', current($plugin_menu));
            $header->set_var('menuitem_text', key($plugin_menu));
            if ($i == $count_plugin_menu) {
                $header->parse('plg_menu_elements', 'menuitem_last', true);
            } else {
                $header->parse('plg_menu_elements', 'menuitem', true);
            }
            next($plugin_menu);
        }
    }
    // Call to plugins to set template variables in the header
    PLG_templateSetVars('header', $header);
    if ($_CONF['left_blocks_in_footer'] == 1) {
        $header->set_var('left_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $lblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $lblocks = $function($what[1], 'left');
            } else {
                $lblocks = COM_showBlocks('left', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $lblocks = COM_showBlocks('left', $topic);
            }
        }
        if (empty($lblocks)) {
            $header->set_var('left_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $lblocks);
            $header->parse('left_blocks', 'leftblocks', true);
            $header->set_var('geeklog_blocks', '');
        }
    }
    if ($_CONF['right_blocks_in_footer'] == 1) {
        $header->set_var('right_blocks', '');
        $header->set_var('geeklog_blocks', '');
    } else {
        $rblocks = '';
        /* Check if an array has been passed that includes the name of a plugin
         * function or custom function
         * This can be used to take control over what blocks are then displayed
         */
        if (is_array($what)) {
            $function = $what[0];
            if (function_exists($function)) {
                $rblocks = $function($what[1], 'right');
            } else {
                $rblocks = COM_showBlocks('right', $topic);
            }
        } else {
            if ($what != 'none') {
                // Now show any blocks -- need to get the topic if not on home page
                $rblocks = COM_showBlocks('right', $topic);
            }
        }
        if (empty($rblocks)) {
            $header->set_var('right_blocks', '');
            $header->set_var('geeklog_blocks', '');
        } else {
            $header->set_var('geeklog_blocks', $rblocks, true);
            $header->parse('right_blocks', 'rightblocks', true);
        }
    }
    // Call any plugin that may want to include extra Meta tags
    // or Javascript functions
    $headercode .= PLG_getHeaderCode();
    // Meta Tags
    // 0 = Disabled, 1 = Enabled, 2 = Enabled but default just for homepage
    if ($_CONF['meta_tags'] > 0) {
        $meta_description = '';
        $meta_keywords = '';
        $no_meta_description = 1;
        $no_meta_keywords = 1;
        //Find out if the meta tag description or keywords already exist in the headercode
        if ($headercode != '') {
            $pattern = '/<meta ([^>]*)name="([^"\'>]*)"([^>]*)/im';
            if (preg_match_all($pattern, $headercode, $matches, PREG_SET_ORDER)) {
                // Loop through all meta tags looking for description and keywords
                for ($i = 0; $i < count($matches) && ($no_meta_description == 1 || $no_meta_keywords == 1); $i++) {
                    $str_matches = strtolower($matches[$i][0]);
                    $pos = strpos($str_matches, 'name=');
                    if (!(is_bool($pos) && !$pos)) {
                        $name = trim(substr($str_matches, $pos + 5), '"');
                        $pos = strpos($name, '"');
                        $name = substr($name, 0, $pos);
                        if (strcasecmp("description", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_description = 0;
                            }
                        }
                        if (strcasecmp("keywords", $name) == 0) {
                            $pos = strpos($str_matches, 'content=');
                            if (!(is_bool($pos) && !$pos)) {
                                $no_meta_keywords = 0;
                            }
                        }
                    }
                }
            }
        }
        if (COM_onFrontpage() && $_CONF['meta_tags'] == 2) {
            // Display default meta tags only on home page
            if ($no_meta_description) {
                $meta_description = $_CONF['meta_description'];
            }
            if ($no_meta_keywords) {
                $meta_keywords = $_CONF['meta_keywords'];
            }
        } else {
            if ($_CONF['meta_tags'] == 1) {
                // Display default meta tags anywhere there are no tags
                if ($no_meta_description) {
                    $meta_description = $_CONF['meta_description'];
                }
                if ($no_meta_keywords) {
                    $meta_keywords = $_CONF['meta_keywords'];
                }
            }
        }
        if ($no_meta_description or $no_meta_keywords) {
            $headercode .= COM_createMetaTags($meta_description, $meta_keywords);
        }
    }
    $headercode = $_SCRIPTS->getHeader() . $headercode;
    $header->set_var('plg_headercode', $headercode);
    // The following lines allow users to embed PHP in their templates.  This
    // is almost a contradition to the reasons for using templates but this may
    // prove useful at times ...
    // Don't use PHP in templates if you can live without it!
    $tmp = $header->finish($header->parse('index_header', 'header'));
    $xml_declaration = '';
    if (get_cfg_var('short_open_tag') == '1') {
        if (preg_match('/(<\\?xml[^>]*>)(.*)/s', $tmp, $match)) {
            $xml_declaration = $match[1] . LB;
            $tmp = $match[2];
        }
    }
    ob_start();
    eval('?>' . $tmp);
    $retval = $xml_declaration . ob_get_contents();
    ob_end_clean();
    return $retval;
}
示例#25
0
/**
* This function used to send out reminders to users to access the site or account may be deleted
*
* @return   string          HTML with success or error message
*
*/
function batchreminders()
{
    global $_CONF, $_TABLES, $LANG04, $LANG28;
    $msg = '';
    $user_list = array();
    if (isset($_POST['delitem'])) {
        $user_list = $_POST['delitem'];
    }
    if (count($user_list) == 0) {
        $msg = $LANG28[79] . '<br' . XHTML . '>';
    }
    $c = 0;
    if (isset($_POST['delitem']) and is_array($_POST['delitem'])) {
        foreach ($_POST['delitem'] as $delitem) {
            $userid = COM_applyFilter($delitem);
            $useremail = DB_getItem($_TABLES['users'], 'email', "uid = '{$userid}'");
            $username = DB_getItem($_TABLES['users'], 'username', "uid = '{$userid}'");
            $lastlogin = DB_getItem($_TABLES['userinfo'], 'lastlogin', "uid = '{$userid}'");
            $lasttime = COM_getUserDateTimeFormat($lastlogin);
            if (file_exists($_CONF['path_data'] . 'reminder_email.txt')) {
                $template = COM_newTemplate($_CONF['path_data']);
                $template->set_file(array('mail' => 'reminder_email.txt'));
                $template->set_var('site_name', $_CONF['site_name']);
                $template->set_var('site_slogan', $_CONF['site_slogan']);
                $template->set_var('lang_username', $LANG04[2]);
                $template->set_var('username', $username);
                $template->set_var('name', COM_getDisplayName($uid));
                $template->set_var('lastlogin', $lasttime[0]);
                $template->parse('output', 'mail');
                $mailtext = $template->finish($template->get_var('output'));
            } else {
                if ($lastlogin == 0) {
                    $mailtext = $LANG28[83] . "\n\n";
                } else {
                    $mailtext = sprintf($LANG28[82], $lasttime[0]) . "\n\n";
                }
                $mailtext .= sprintf($LANG28[84], $username) . "\n";
                $mailtext .= sprintf($LANG28[85], $_CONF['site_url'] . '/users.php?mode=getpassword') . "\n\n";
            }
            $subject = sprintf($LANG28[81], $_CONF['site_name']);
            if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) {
                $mailfrom = $_CONF['noreply_mail'];
                $mailtext .= LB . LB . $LANG04[159];
            } else {
                $mailfrom = $_CONF['site_mail'];
            }
            if (COM_mail($useremail, $subject, $mailtext, $mailfrom)) {
                DB_query("UPDATE {$_TABLES['users']} SET num_reminders=num_reminders+1 WHERE uid={$userid}");
                $c++;
            } else {
                COM_errorLog("Error attempting to send account reminder to use:{$username} ({$userid})");
            }
        }
    }
    // Since this function is used for deletion only, its necessary to say that
    // zero where deleted instead of just leaving this message away.
    COM_numberFormat($c);
    // just in case we have more than 999)..
    $msg .= "{$LANG28[80]}: {$c}<br" . XHTML . ">\n";
    return $msg;
}
示例#26
0
                 $cal_templates->set_var('event_endtime', ' - ' . $endtime);
             }
             $cal_templates->set_var('event_title_and_link', COM_createLink(stripslashes($A['title']), $_CONF['site_url'] . '/calendarjp/event.php?' . addMode($mode) . 'eid=' . $A['eid']));
             // Provide delete event link if user has access
             $cal_templates->set_var('delete_imagelink', getDeleteImageLink($mode, $A, $token));
             $cal_templates->parse('events_day' . $i, 'events', true);
         }
         if ($nrows == 0) {
             $cal_templates->set_var('event_starttime', '&nbsp;');
             $cal_templates->set_var('event_endtime', '');
             $cal_templates->set_var('event_title_and_link', '');
             $cal_templates->set_var('delete_imagelink', '');
             $cal_templates->parse('events_day' . $i, 'events', true);
         }
         // Go to next day
         $thedate = COM_getUserDateTimeFormat(mktime(0, 0, 0, $monthnum, $daynum + 1, $yearnum));
     }
     $display .= $cal_templates->parse('output', 'week');
     $display = COM_createHTMLDocument($display, array('pagetitle' => $pagetitle));
     break;
 case 'addentry':
     $display .= plugin_submit_calendarjp($mode);
     $display = COM_createHTMLDocument($display, array('pagetitle' => $pagetitle));
     break;
 case 'savepersonal':
     if (SEC_checkToken()) {
         $display = plugin_savesubmission_calendarjp($_POST);
     } else {
         $display = COM_refresh($_CONF['site_url'] . '/calendarjp/index.php');
     }
     break;
示例#27
0
             $promptform .= "<OPTION>{$showforums['forum_name']}";
         }
         $promptform .= '</SELECT>';
         $promptform .= '</div><div style="padding:10 0 5 0px;">' . $LANG_GF02['msg186'] . ':&nbsp;';
         $promptform .= '<input type="text" size="60" NAME="movetitle" VALUE="' . $topictitle . '">';
         /* Check and see request to move complete topic or split the topic */
         if (DB_getItem($_TABLES['gf_topic'], "pid", "id='{$fortopicid}'") == 0) {
             $promptform .= '</div><div style="padding:20 0 5 20px;">';
             $promptform .= '<input type="submit" NAME="submit" VALUE="' . $LANG_GF03['movetopic'] . '">';
             $promptform .= '&nbsp;&nbsp;<INPUT TYPE="submit" NAME="submit" VALUE="' . $LANG_GF01['CANCEL'] . '"></div>';
             $promptform .= '</FORM></div>';
             $alertmessage = sprintf($LANG_GF03['movetopicmsg'], $topictitle);
             alertMessage($alertmessage, $LANG_GF02['msg182'], $promptform);
         } else {
             $poster = DB_getItem($_TABLES['gf_topic'], "name", "id='{$fortopicid}'");
             $postdate = COM_getUserDateTimeFormat(DB_getItem($_TABLES['gf_topic'], "date", "id='{$fortopicid}'"));
             $promptform .= '<div style="padding-top:10px;">' . $LANG_GF03['splitheading'] . '<br>';
             $promptform .= '<input type="radio" name="splittype" value="remaining" CHECKED>' . $LANG_GF03['splitopt1'] . '<br>';
             $promptform .= '<input type="radio" name="splittype" value="single">' . $LANG_GF03['splitopt2'] . '</div>';
             $promptform .= '</div><div style="padding:20 0 5 20px;">';
             $promptform .= '<input type="submit" NAME="submit" VALUE="' . $LANG_GF03['movetopic'] . '">';
             $promptform .= '&nbsp;&nbsp;<INPUT TYPE="submit" NAME="submit" VALUE="' . $LANG_GF01['CANCEL'] . '"></div>';
             $promptform .= '</FORM></div>';
             $alertmessage = sprintf($LANG_GF03['splittopicmsg'], $topictitle, $poster, $postdate[0]);
             alertMessage($alertmessage, $LANG_GF02['msg182'], $promptform);
         }
     }
 } elseif ($modfunction == 'banip' and forum_modPermission($forum, $_USER['uid'], 'mod_ban') and $fortopicid != 0) {
     $iptobansql = DB_query("SELECT ip FROM {$_TABLES['gf_topic']} WHERE id='{$fortopicid}'");
     $forumpostipnum = DB_fetchArray($iptobansql);
     if ($forumpostipnum['ip'] == '') {
示例#28
0
/**
 * used for the list of stories in admin/story.php
 *
 * @param  string $fieldName
 * @param  string $fieldValue
 * @param  array  $A
 * @param  array  $icon_arr
 * @return string
 */
function ADMIN_getListField_stories($fieldName, $fieldValue, $A, $icon_arr)
{
    global $_CONF, $_TABLES, $LANG24, $LANG_ACCESS, $_IMAGE_TYPE;
    static $topics;
    if (!isset($topics)) {
        $topics = array();
    }
    $retval = '';
    switch ($fieldName) {
        case 'unixdate':
            $currentTime = COM_getUserDateTimeFormat($A['unixdate']);
            $retval = strftime($_CONF['daytime'], $currentTime[1]);
            break;
        case 'title':
            $A['title'] = str_replace('$', '&#36;', $A['title']);
            $article_url = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
            $attr = array();
            if (!empty($A['page_title'])) {
                $attr['title'] = htmlspecialchars($A['page_title']);
            }
            $retval = COM_createLink(stripslashes($A['title']), $article_url, $attr);
            break;
        case 'draft_flag':
            if ($A['draft_flag'] == 1) {
                $retval = $LANG24[35];
            } else {
                $retval = $LANG24[36];
            }
            break;
        case 'access':
        case 'copy':
        case 'edit':
        case 'edit_adv':
            $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
            if ($access == 3) {
                if (TOPIC_hasMultiTopicAccess('article', $A['sid']) == 3) {
                    $access = $LANG_ACCESS['edit'];
                } else {
                    $access = $LANG_ACCESS['readonly'];
                }
            } else {
                $access = $LANG_ACCESS['readonly'];
            }
            if ($fieldName === 'access') {
                $retval = $access;
            } elseif ($access === $LANG_ACCESS['edit']) {
                if ($fieldName == 'edit_adv') {
                    $editMode = 'adv';
                } elseif ($fieldName === 'edit') {
                    $editMode = 'std';
                }
                if ($fieldName === 'copy') {
                    $copyUrl = $_CONF['site_admin_url'] . '/story.php?mode=clone&amp;sid=' . $A['sid'];
                    $retval = COM_createLink($icon_arr['copy'], $copyUrl);
                } else {
                    $editUrl = $_CONF['site_admin_url'] . '/story.php?mode=edit&amp;editor=' . $editMode . '&amp;sid=' . $A['sid'];
                    $retval = COM_createLink($icon_arr['edit'], $editUrl);
                }
            }
            break;
        case 'featured':
            if ($A['featured'] == 1) {
                $retval = $LANG24[35];
            } else {
                $retval = $LANG24[36];
            }
            break;
        case 'ping':
            // Allow ping if all topics allow anonymous access that story belongs too
            $topic_anon = 0;
            $tids = TOPIC_getTopicIdsForObject('article', $A['sid']);
            foreach ($tids as $tid) {
                $current_access = DB_getItem($_TABLES['topics'], 'perm_anon', "tid = '" . DB_escapeString($tid) . "'");
                if ($topic_anon < $current_access) {
                    $topic_anon = $current_access;
                }
            }
            if ($A['draft_flag'] == 0 && $A['unixdate'] < time() && $A['perm_anon'] != 0 && $topic_anon != 0) {
                $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG24[21] . '" title="' . $LANG24[21] . '"' . XHTML . '>';
                $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&amp;id=' . $A['sid'];
                $retval = COM_createLink($pingico, $url);
            } else {
                $retval = '';
            }
            break;
        case 'tid':
            $retval = TOPIC_getTopicAdminColumn('article', $A['sid']);
            break;
        case 'username':
        case 'fullname':
            $retval = COM_getDisplayName($A['uid'], $A['username'], $A['fullname']);
            break;
        default:
            $retval = $fieldValue;
            break;
    }
    return $retval;
}
示例#29
0
function LIB_Edit($pi_name, $id, $edt_flg, $msg = '', $errmsg = "", $mode = "edit")
{
    global $_CONF;
    global $_TABLES;
    global $LANG_ADMIN;
    global $MESSAGE;
    global $LANG_ACCESS;
    global $_USER;
    $lang_box_admin = "LANG_" . strtoupper($pi_name) . "_ADMIN";
    global ${$lang_box_admin};
    $lang_box_admin = ${$lang_box_admin};
    $lang_box = "LANG_" . strtoupper($pi_name);
    global ${$lang_box};
    $lang_box = ${$lang_box};
    $lang_box_noyes = "LANG_" . strtoupper($pi_name) . "_NOYES";
    global ${$lang_box_noyes};
    $lang_box_noyes = ${$lang_box_noyes};
    $lang_box_inputtype = "LANG_" . strtoupper($pi_name) . "_INPUTTYPE";
    global ${$lang_box_inputtype};
    $lang_box_inputtype = ${$lang_box_inputtype};
    $table = $_TABLES[strtoupper($pi_name) . '_def_group'];
    $table1 = $_TABLES[strtoupper($pi_name) . '_def_category'];
    $table2 = $_TABLES[strtoupper($pi_name) . '_def_field'];
    //        $cur_year = date( 'Y' );
    //        $year_startoffset=1990 - $cur_year +1;
    //        $year_endoffset=0;
    $retval = '';
    $delflg = false;
    //メッセージ表示
    if (!empty($msg)) {
        $retval .= COM_showMessage($msg, $pi_name);
        $retval .= $errmsg;
        // clean 'em up
        $code = COM_applyFilter($_POST['code']);
        $name = COM_applyFilter($_POST['name']);
        $description = $_POST['description'];
        //COM_applyFilter($_POST['description']);
        $orderno = COM_applyFilter($_POST['orderno']);
        $parent_flg = COM_applyFilter($_POST['parent_flg'], true);
        $input_type = COM_applyFilter($_POST['input_type'], true);
        $uuid = $_USER['uid'];
    } else {
        if (empty($id)) {
            $id = 0;
            $code = "";
            $name = "";
            $description = "";
            $orderno = "";
            $parent_flg = 0;
            $uuid = 0;
            $udatetime = "";
            //"";
        } else {
            $sql = "SELECT ";
            $sql .= " *";
            $sql .= " ,UNIX_TIMESTAMP(udatetime) AS udatetime_un" . LB;
            $sql .= " FROM ";
            $sql .= $table;
            $sql .= " WHERE ";
            $sql .= " group_id = {$id}";
            $result = DB_query($sql);
            $A = DB_fetchArray($result);
            $code = COM_stripslashes($A['code']);
            $name = COM_stripslashes($A['name']);
            $description = COM_stripslashes($A['description']);
            $orderno = COM_stripslashes($A['orderno']);
            $parent_flg = COM_stripslashes($A['parent_flg']);
            $input_type = COM_stripslashes($A['input_type']);
            $uuid = COM_stripslashes($A['uuid']);
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['udatetime_un']));
            $udatetime = $wary[0];
            if ($edt_flg == FALSE) {
                $delflg = true;
            }
        }
    }
    if ($mode === "copy") {
        $id = 0;
        //作成日付
        $created = 0;
        $created_month = 0;
        $created_day = 0;
        $created_year = 0;
        $created_hour = 0;
        $created_minute = 0;
        //
        $delflg = false;
    }
    $retval .= COM_startBlock($lang_box_admin['edit'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $tmplfld = DATABOX_templatePath('admin', 'default', $pi_name);
    $templates = new Template($tmplfld);
    $templates->set_file('editor', "group_editor.thtml");
    //--
    $templates->set_var('about_thispage', $lang_box_admin['about_admin_group']);
    $templates->set_var('lang_must', $lang_box_admin['must']);
    $templates->set_var('site_url', $_CONF['site_url']);
    $templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $token = SEC_createToken();
    $retval .= SEC_getTokenExpiryNotice($token);
    $templates->set_var('gltoken_name', CSRF_TOKEN);
    $templates->set_var('gltoken', $token);
    $templates->set_var('xhtml', XHTML);
    $templates->set_var('script', THIS_SCRIPT);
    //
    $templates->set_var('lang_link_admin', $lang_box_admin['link_admin']);
    $templates->set_var('lang_link_admin_top', $lang_box_admin['link_admin_top']);
    //id
    $templates->set_var('lang_group_id', $lang_box_admin['group_id']);
    $templates->set_var('id', $id);
    //コード、名前&説明
    $templates->set_var('lang_code', $lang_box_admin['code']);
    $templates->set_var('code', $code);
    $templates->set_var('lang_name', $lang_box_admin['name']);
    $templates->set_var('name', $name);
    $templates->set_var('lang_description', $lang_box_admin['description']);
    $templates->set_var('description', $description);
    //順番
    $templates->set_var('lang_orderno', $lang_box_admin['orderno']);
    $templates->set_var('orderno', $orderno);
    //親ブループ?
    $templates->set_var('lang_parent_flg', $lang_box_admin['parent_flg']);
    $list_parent_flg = DATABOX_getradiolist($lang_box_noyes, "parent_flg", $parent_flg);
    $templates->set_var('list_parent_flg', $list_parent_flg);
    //入力タイプ
    $templates->set_var('lang_input_type', $lang_box_admin['input_type']);
    $list_input_type = DATABOX_getradiolist($lang_box_inputtype, "input_type", $input_type);
    $templates->set_var('list_input_type', $list_input_type);
    //保存日時
    $templates->set_var('lang_udatetime', $lang_box_admin['udatetime']);
    $templates->set_var('udatetime', $udatetime);
    $templates->set_var('lang_uuid', $lang_box_admin['uuid']);
    $templates->set_var('uuid', $uuid);
    // SAVE、CANCEL ボタン
    $templates->set_var('lang_save', $LANG_ADMIN['save']);
    $templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $templates->set_var('lang_preview', $LANG_ADMIN['preview']);
    //delete_option
    if ($delflg) {
        $wkcnt = DB_count($table1, "categorygroup_id", $id);
        if ($wkcnt > 0) {
            $templates->set_var('lang_delete_help', $lang_box_admin['delete_help_group']);
        } else {
            $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s>';
            $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
            $templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        }
    }
    //
    $templates->parse('output', 'editor');
    $retval .= $templates->finish($templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
示例#30
0
文件: index.php 项目: ivywe/maps
function MAPS_displayFrontPage()
{
    global $_CONF, $_MAPS_CONF, $LANG_MAPS_1, $_TABLES;
    $retval = '';
    if ($_MAPS_CONF['map_main_header'] != '') {
        $header = '<div>' . PLG_replaceTags($_MAPS_CONF['map_main_header']) . '</div>';
    } else {
        $header1 = '<p style="margin-top:25px;">' . $LANG_MAPS_1['user_maps_list'] . '</p>';
    }
    // Get maps from database
    $sql = "SELECT mid, name, description, active, hidden, modified, hits FROM {$_TABLES['maps_maps']} ORDER BY name ASC";
    $res = DB_query($sql);
    // Create maps list template
    $map = new Template($_CONF['path'] . 'plugins/maps/templates');
    $map->set_file(array('map' => 'list_map_item.thtml', 'start' => 'list_map_start.thtml', 'end' => 'list_map_end.thtml'));
    // Display the begging of the map list
    $retval .= $map->parse('output', 'start');
    $list = 0;
    $lastmod = array();
    $markerssum = 0;
    while ($A = DB_fetchArray($res)) {
        if ($A['active'] == 1 && $A['hidden'] == 0) {
            $map->set_var('mid', $A['mid']);
            $map->set_var('name', stripslashes($A['name']));
            $map->set_var('xhtml', XHTML);
            $name = urlencode($A['name']);
            $map->set_var('map_detail', $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=' . $A['mid'] . '&name=' . $name . '&amp;query_limit=500');
            if ($A['description'] != '') {
                $map->set_var('description', '<br' . XHTML . '>' . stripslashes($A['description']));
            } else {
                $map->set_var('description', '');
            }
            //See map and markers
            if (function_exists('MAPS_getFields')) {
                $map->set_var('view_map', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=' . $A['mid'] . '&name=' . $name . '&amp;query_limit=500">' . $LANG_MAPS_1['view_map'] . '</a> | ');
                $map->set_var('view_markers', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=markers&amp;mid=' . $A['mid'] . '&name=' . $name . '">' . $LANG_MAPS_1['view_markers'] . ' | </a>');
            } else {
                $map->set_var('view_map', '');
                $map->set_var('view_markers', '');
            }
            //update
            $currentmod = COM_getUserDateTimeFormat($A['modified']);
            if ($currentmod[1] > $lastmod[1]) {
                $lastmod = COM_getUserDateTimeFormat($A['modified']);
            }
            $update = COM_getUserDateTimeFormat($A['modified']);
            $map->set_var('update', $LANG_MAPS_1['last_modification'] . ' ' . $update[0]);
            //markers
            $markers = DB_count($_TABLES['maps_markers'], 'mid', $A['mid']);
            $markerssum = $markerssum + $markers;
            $map->set_var('markers', ' | ' . $markers . ' ' . $LANG_MAPS_1['records']);
            //hits
            $map->set_var('hits', ' | ' . $A['hits'] . ' ' . $LANG_MAPS_1['hits']);
            if (SEC_hasRights('maps.admin')) {
                $map->set_var('edit_button', '<form id="edit_map" action="' . $_CONF['site_admin_url'] . '/plugins/maps/map_edit.php" method="POST">
	        <div style="float:right">
	          <input type="image" src="' . $_CONF['site_admin_url'] . '/plugins/maps/images/edit.png" align="absmiddle" />
			  <input type="hidden" name="mode" value="edit" />
			   <input type="hidden" name="mid" value="' . $A['mid'] . '" />
	        </div>
	        </form>');
            } else {
                $map->set_var('edit_button', '');
            }
            $retval .= $map->parse('output', 'map');
            $list++;
        }
    }
    if ($list == 0 && $_MAPS_CONF['global_map'] == 0 && $_MAPS_CONF['users_map'] == 1) {
        $retval .= '<p>' . $LANG_MAPS_1['no_map_user'] . '</p>';
        if (SEC_hasRights('maps.admin')) {
            $retval .= '<p>' . $LANG_MAPS_1['admin_can'] . '<a href="' . $_CONF['site_admin_url'] . '/plugins/maps/map_edit.php?mode=new"> ' . $LANG_MAPS_1['create_map'] . '</a>.</p>';
        }
    } else {
        if ($_MAPS_CONF['global_map'] == 1 && $list > 1) {
            //global map
            $map->set_var('edit_button', '');
            $map->set_var('xhtml', XHTML);
            $map->set_var('name', $LANG_MAPS_1['global_map']);
            $map->set_var('map_detail', $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=0&name=' . urlencode($LANG_MAPS_1['global_map']) . '&amp;query_limit=500');
            $map->set_var('description', '<br' . XHTML . '>' . $LANG_MAPS_1['info_global_map']);
            if (function_exists('MAPS_getFields')) {
                $map->set_var('view_map', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=map&amp;mid=0&name=' . urlencode($LANG_MAPS_1['global_map']) . '&amp;query_limit=500">' . $LANG_MAPS_1['view_map'] . '</a> | ');
                $map->set_var('view_markers', '<a href="' . $_MAPS_CONF['site_url'] . '/index.php?mode=markers&amp;mid=0&name=' . urlencode($LANG_MAPS_1['global_map']) . '">' . $LANG_MAPS_1['view_markers'] . ' | </a>');
            } else {
                $map->set_var('view_map', '');
                $map->set_var('view_markers', '');
            }
            //update
            $updateglobal = COM_getUserDateTimeFormat(time());
            $map->set_var('update', $LANG_MAPS_1['last_modification'] . ' ' . $updateglobal[0]);
            //markers
            $markers = DB_count($_TABLES['maps_markers'], 'mid', $A['mid']);
            $map->set_var('markers', ' | ' . $markerssum . ' ' . $LANG_MAPS_1['records']);
            //hits
            $map->set_var('hits', ' | ' . DB_getItem($_TABLES['vars'], 'value', "name='globalMapHits'") . ' ' . $LANG_MAPS_1['hits']);
            $retval .= $map->parse('output', 'map');
        }
        if ($_MAPS_CONF['users_map'] == 1) {
            $retval .= '<p class="maps_list_item"><strong><a href="' . $_MAPS_CONF['site_url'] . '/users_map.php">' . $LANG_MAPS_1['users_map'] . '</a></strong><br' . XHTML . '>' . $LANG_MAPS_1['info_users_map'] . '</p>';
        }
        if (SEC_hasRights('maps.admin')) {
            $retval .= '&nbsp;<p>' . $LANG_MAPS_1['admin_can'] . ' <a href="' . $_CONF['site_admin_url'] . '/plugins/maps/map_edit.php?mode=new">' . $LANG_MAPS_1['create_map'] . '</a></p>';
        }
    }
    // Display the end of the maps list
    $retval .= $map->parse('output', 'end');
    //Display global map if active
    if (COM_isAnonUser() && $_MAPS_CONF['maps_login_required'] == 1) {
        // do not display global map
        $retval = $header1 . $retval;
    } else {
        if ($_MAPS_CONF['global_map'] == 1 && $list > 0) {
            $retval = MAPS_getGlobalMap('', '', true) . $header1 . $retval;
        } else {
            $retval = $header1 . $retval;
        }
    }
    $footer = '<div>' . PLG_replaceTags($_MAPS_CONF['map_main_footer']) . '</div>';
    return $header . $retval . $footer;
}