set_config('user_image_maxwidth', 1024);
set_config('user_image_maxheight', 768);
set_config('user_image_maxsize', 512);
$table = new DBTable('userimages');
$new_fld = new DBField('id', 'INT');
$new_fld->add_key('PRIMARY');
$new_fld->add_extra('NOT NULL');
$new_fld->add_extra('AUTO_INCREMENT');
$table->add_field($new_fld);
$new_fld = new DBField('filename', 'VARCHAR(256)');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('user', 'INT');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('ip_addr', 'VARCHAR(50)');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('time', 'INT');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('extension', 'VARCHAR(10)');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$table->commit();
$new_fld = new DBField('g_upload_images', 'TINYINT(1)');
$new_fld->add_extra('NOT NULL');
$new_fld->set_default(0);
$db->add_field('user_groups', $new_fld, 'g_post_images');
$db->query('UPDATE `#^user_groups` SET g_upload_images=1 WHERE g_permanent=1') or enhanced_error('Failed to update user groups', true);
Esempio n. 2
0
 function drop_index($table, $name)
 {
     if (!$this->index_exists($table, $name)) {
         return;
     }
     return $this->query('ALTER TABLE `' . $this->prefix . $table . '` DROP INDEX \'' . $this->prefix . $table . '_' . $name, '\'') or enhanced_error('Failed to drop index');
 }
Esempio n. 3
0
$db->add_field('config', $new_fld, 'c_value');
set_config('header_links', '<?xml version="1.0" ?>
<linkset>
    <link path="">index</link>
    <link path="users/$username$" perm="valid">profile</link>
    <link path="users" perm="g_user_list">userlist</link>
    <link path="search">search</link>
    <link path="admin" perm="g_admin_privs">administration</link>
    <link path="admin/bans" perm="g_mod_privs ~g_admin_privs">administration</link>
    <link path="register/$reghash$" perm="~valid">register</link>
    <link path="logout" perm="valid">logout</link>
</linkset>');
set_config('admin_pages', 'PT5pbmRleApiYW5zPT5iYW5zCnJlcG9ydHM9PnJlcG9ydHMKY2Vuc29yaW5nPT5jZW5zb3JpbmcKZm9ydW1zPT5mb3J1bXMKaXBfdHJhY2tlcj0+aXB0cmFja2VyCnVzZXJfZ3JvdXBzPT51c2VyZ3JvdXBzCnRyYXNoX2Jpbj0+dHJhc2hiaW4KbWFpbnRlbmFuY2U9Pm1haW50ZW5hbmNlCnN0eWxlPT5zdHlsZQpleHRlbnNpb25zPT5leHRlbnNpb25zCmludGVyZmFjZT0+aW50ZXJmYWNl');
set_config('mod_pages', 'YmFucz0+YmFucwpyZXBvcnRzPT5yZXBvcnRzCnRyYXNoX2Jpbj0+dHJhc2hiaW4KaXBfdHJhY2tlcj0+aXB0cmFja2Vy');
set_config('db_version', 2);
$db->query('DELETE FROM `#^config` WHERE c_name=\'addl_header_links\'') or enhanced_error('Failed to remove old header links', true);
echo '<li>RV2: Adding new config values... success</li>';
$tables['language'] = new DBTable('language');
$new_fld = new DBField('id', 'INT');
$new_fld->add_key('PRIMARY');
$new_fld->add_extra('NOT NULL');
$new_fld->add_extra('AUTO_INCREMENT');
$tables['language']->add_field($new_fld);
$new_fld = new DBField('language', 'VARCHAR(20)');
$new_fld->add_extra('NOT NULL');
$new_fld->set_default('\'English\'');
$tables['language']->add_field($new_fld);
$new_fld = new DBField('langkey', 'VARCHAR(50)');
$new_fld->add_extra('NOT NULL');
$new_fld->set_default('\'\'');
$new_fld->set_default('\'\'');
Esempio n. 4
0
            }
            $field_edits[$entry['field']][] = array('time' => $entry['time'], 'old_value' => $entry['old_value'], 'username' => $entry['username'], 'action' => $entry['action']);
        } else {
            if ($entry['area'] == 'language') {
                if (!isset($lang_edits[$entry['field']])) {
                    $lang_edits[$entry['field']] = array();
                    $lang_ids[] = $entry['field'];
                }
                $lang_edits[$entry['field']][] = array('time' => $entry['time'], 'old_value' => $entry['old_value'], 'username' => $entry['username'], 'action' => $entry['action']);
            }
        }
    }
}
//put the latest value for each language entry changed
if (sizeof($lang_edits)) {
    $result = $db->query('SELECT * FROM `#^language` WHERE id IN(' . implode(',', $lang_ids) . ')') or enhanced_error('Failed to find latest language values', true);
    while ($lang_entry = $db->fetch_assoc($result)) {
        $lines = array();
        foreach ($lang_entry as $db_key => $db_val) {
            $lines[] = $db_key . '=>' . $db_val;
        }
        $lang_edits[$lang_entry['id']][0]['new_value'] = implode("\n", $lines);
    }
    foreach ($lang_edits as &$entry) {
        if (!isset($entry[0]['new_value'])) {
            $entry[0]['new_value'] = '';
        }
    }
}
foreach ($page_edits as $pageid => &$page_entry) {
    for ($i = 0; $i < sizeof($page_entry); $i++) {
Esempio n. 5
0
    //popup window for editing a forum
    include FORUM_ROOT . '/app_resources/pages/admin/includes/edit_forum.php';
    $page_info['template'] = false;
    return;
}
if (isset($_POST['add_new_category'])) {
    $result = $db->query('SELECT MAX(sort_position) FROM `#^categories`') or enhanced_error('Failed to get sort position');
    list($max) = $db->fetch_row($result);
    $db->query('INSERT INTO `#^categories`(name,sort_position) VALUES(\'New category\',' . ($max + 1) . ')') or error('Failed to create new category', __FILE__, __LINE__, $db->error());
}
if (isset($_POST['add_new_forum'])) {
    //get allowed user groups
    $view = array();
    $topics = array();
    $replies = array();
    $result = $db->query('SELECT g_id AS id,g_view_forums,g_post_topics,g_post_replies FROM `#^user_groups`') or enhanced_error('Failed to find user groups', true);
    while ($group = $db->fetch_assoc($result)) {
        if ($group['g_view_forums']) {
            $view[] = $group['id'];
        }
        if ($group['g_post_topics']) {
            $topics[] = $group['id'];
        }
        if ($group['g_post_replies']) {
            $replies[] = $group['id'];
        }
    }
    create_forum($_POST['category'], $_POST['name'], $view, $topics, $replies);
}
if (!isset($dirs[3])) {
    $dirs[3] = '';
Esempio n. 6
0
        echo $base_config['baseurl'] . '/' . htmlspecialchars($cur_topic['furl']);
        ?>
"><?php 
        echo htmlspecialchars($cur_topic['forum_name']);
        ?>
</a> &raquo; <a href="<?php 
        echo $base_config['baseurl'] . '/' . htmlspecialchars($cur_topic['furl']) . '/' . htmlspecialchars($cur_topic['turl']);
        ?>
"><?php 
        echo htmlspecialchars($cur_topic['subject']);
        ?>
</a></p>
                <?php 
    } else {
        if ($dirs[4] == 'post') {
            $result = $db->query('SELECT p.id,p.parsed_content,t.subject,t.url AS turl,f.name AS forum_name,f.url AS furl FROM `#^posts` AS p LEFT JOIN `#^topics` AS t ON t.id=p.topic_id LEFT JOIN `#^forums` AS f ON f.id=t.forum_id WHERE p.deleted IS NOT NULL AND p.id=' . $id) or enhanced_error('Failed to get post', true);
            if (!$db->num_rows($result)) {
                httperror(404);
            }
            $cur_post = $db->fetch_assoc($result);
            ?>
           		<p><?php 
            echo translate('undeletepostheader');
            ?>
<input type="hidden" name="post_id" value="<?php 
            echo $id;
            ?>
" /></p>
                <p><a href="<?php 
            echo $base_config['baseurl'] . '/' . htmlspecialchars($cur_post['furl']);
            ?>
Esempio n. 7
0
        //working with posts
        //TODO: make sure that the posts selected to be deleted haven't already been deleted, and the opposite for undeletion
        $result = $db->query('SELECT t.url AS turl,t.id AS id,f.url AS furl,f.id AS fid FROM `#^posts` AS p LEFT JOIN `#^topics` AS t ON t.id=p.topic_id LEFT JOIN `#^forums` AS f ON f.id=t.forum_id WHERE p.id=' . intval(array_keys($_POST['items'])[0])) or enhanced_error('Failed to get first post info', true);
        if (!$db->num_rows($result)) {
            httperror(404);
        }
        $topic_info = $db->fetch_assoc($result);
        switch ($_POST['action']) {
            case 'delete':
                $db->query('UPDATE `#^posts` SET deleted=' . time() . ',deleted_by=' . $futurebb_user['id'] . ' WHERE id IN(' . implode(',', array_keys($_POST['items'])) . ')') or enhanced_error('Failed to delete posts', true);
                //update post counts
                $db->query('UPDATE `#^topics` SET num_replies=num_replies-' . sizeof($_POST['items']) . ' WHERE id=' . $topic_info['id']) or error('Failed to delete post', __FILE__, __LINE__, $db->error());
                $db->query('UPDATE `#^forums` SET num_posts=num_posts-' . sizeof($_POST['items']) . ' WHERE id=' . $topic_info['fid']) or error('Failed to update topic count', __FILE__, __LINE__, $db->error());
                break;
            case 'undelete':
                $db->query('UPDATE `#^posts` SET deleted=NULL,deleted_by=NULL WHERE id IN(' . implode(',', array_keys($_POST['items'])) . ')') or enhanced_error('Failed to delete posts', true);
                //update post counts
                $db->query('UPDATE `#^topics` SET num_replies=num_replies+' . sizeof($_POST['items']) . ' WHERE id=' . $topic_info['id']) or error('Failed to delete post', __FILE__, __LINE__, $db->error());
                $db->query('UPDATE `#^forums` SET num_posts=num_posts+' . sizeof($_POST['items']) . ' WHERE id=' . $topic_info['fid']) or error('Failed to update topic count', __FILE__, __LINE__, $db->error());
                break;
            default:
                httperror(404);
        }
        //update topic last post data
        $result = $db->query('SELECT id,posted FROM `#^posts` WHERE topic_id=' . $topic_info['id'] . ' AND deleted IS NULL ORDER BY posted DESC') or error('Failed to get new last post', __FILE__, __LINE__, $db->error());
        update_last_post($topic_info['id'], $topic_info['fid']);
        redirect($base_config['baseurl'] . '/' . rawurlencode($topic_info['furl']) . '/' . rawurlencode($topic_info['turl']));
    }
} else {
    //show a confirmation
    //check the validity of the data
Esempio n. 8
0
 if ($sortby == 'relevance' && defined('SHOW_SCORES')) {
     //store the scores for debugging
     $scores = array();
 }
 if (is_object($results[0])) {
     foreach ($results as $post) {
         $ids[] = $post->getId();
         if ($sortby == 'relevance' && defined('SHOW_SCORES')) {
             $scores[$post->getId()] = $post->getScore();
         }
     }
 } else {
     $ids = $results;
 }
 //now that we have the results, let's show this!
 $result = $db->query('SELECT p.deleted AS pdeleted,p.id,p.parsed_content,f.url AS furl,f.name AS forum,t.url AS turl,t.subject,t.deleted AS tdeleted,u.username AS poster,u.avatar_extension,u.id AS user_id,g.g_title AS poster_title FROM `#^posts` AS p LEFT JOIN `#^topics` AS t ON t.id=p.topic_id LEFT JOIN `#^forums` AS f ON f.id=t.forum_id LEFT JOIN `#^users` AS u ON u.id=p.poster LEFT JOIN `#^user_groups` AS g ON g.g_id=u.group_id WHERE p.id IN(' . implode(',', $ids) . ')') or enhanced_error('Failed to get post information' . implode(',', $ids), true);
 $boxes = array();
 //the boxes to show
 while ($message = $db->fetch_assoc($result)) {
     $box_content = '<div class="catwrap" id="post' . $message['id'] . '"><h2 class="cat_header">';
     if ($message['pdeleted'] || $message['tdeleted']) {
         $box_content .= '&#10060; ';
     }
     $box_content .= '<a href="' . $base_config['baseurl'] . '/' . $message['furl'] . '">' . htmlspecialchars($message['forum']) . '</a> &raquo; <a href="' . $base_config['baseurl'] . '/' . $message['furl'] . '/' . $message['turl'] . '">' . htmlspecialchars($message['subject']) . '</a> &raquo; <a href="' . $base_config['baseurl'] . '/posts/' . $message['id'] . '">' . translate('post') . ' #' . $message['id'] . '</a></h2>';
     $box_content .= '<div class="cat_body' . ($message['pdeleted'] || $message['tdeleted'] ? ' deleted_post' : '') . '"><div class="postleft"><p><a href="' . $base_config['baseurl'] . '/users/' . htmlspecialchars($message['poster']) . '">' . htmlspecialchars($message['poster']) . '</a></p><p><b>' . htmlspecialchars($message['poster_title']) . '</b></p>';
     if ($futurebb_config['avatars'] && file_exists(FORUM_ROOT . '/static/img/avatars/' . $message['user_id'] . '.' . $message['avatar_extension'])) {
         $box_content .= '<p><img src="' . $base_config['baseurl'] . '/img/avatars/' . $message['user_id'] . '.' . htmlspecialchars($message['avatar_extension']) . '" alt="avatar" class="avatar" /></p>';
     }
     $box_content .= '</div><div class="postright"><p>' . $message['parsed_content'] . '</p>';
     if ($sortby == 'relevance' && defined('SHOW_SCORES')) {
         $box_content .= '<hr />Score: ' . $scores[$message['id']];
Esempio n. 9
0
$new_fld->add_extra('NOT NULL');
$new_fld->add_extra('AUTO_INCREMENT');
$table->add_field($new_fld);
$new_fld = new DBField('hash', 'VARCHAR(50)');
$new_fld->set_default('');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('results', 'TEXT');
$new_fld->set_default('');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('time', 'INT');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$table->commit();
echo '<li>RV4: Adding search cache table... success</li>';
//insert new language keys
ExtensionConfig::add_language_key('exttoonew', 'The extension you are installing requires FutureBB version $1, while you are currently running $2. Go to <a href="http://futurebb.futuresight.org">the FutureBB website</a> to update your forum software.', 'English', 'admin');
ExtensionConfig::add_language_key('notextinsidetag', 'You are not allowed to place any text directly inside the <b>[$1]</b> tag.', 'English', 'main');
ExtensionConfig::add_language_key('posttime', 'Post time', 'English', 'main');
ExtensionConfig::add_language_key('tables', 'Tables', 'English', 'main');
ExtensionConfig::add_language_key('colrow', 'Col $1, Row $2', 'English', 'main');
ExtensionConfig::add_language_key('tableintro', 'You use the <code>[table][/table]</code> tags to start and end a table. You use <code>[tr][/tr]</code> to indicate a row, and <code>[td][/td]</code> to indicate a cell. The <code>[tr]</code> tag must go directly inside the <code>[table]</code> tag, and the <code>[td]</code> tag must go inside the <code>[tr]</code> tag.', 'English', 'main');
ExtensionConfig::add_language_key('relevance', 'Relevance', 'English', 'main');
echo '<li>RV4: Adding new language keys... success</li>';
//alert the admin that the promotion operator has been changed from > to >=
$db->query('INSERT INTO `#^reports`(post_id,post_type,reason,reported_by,time_reported) VALUES(0, \'special\',\'' . $db->escape('For automatic user group promotion, the system now checks if the user\'s post count is greater than or equal to the number you enter, as opposed to strictly greater than.') . '\',0,' . time() . ')') or enhanced_error('Failed to alert admin about promotion operator change', true);
//welcome the admin to FutureBB 1.4
$db->query('INSERT INTO `#^reports`(post_id,post_type,reason,reported_by,time_reported) VALUES(0, \'special\',\'' . $db->escape('Welcome to FutureBB 1.4! Once you follow the steps explained in the other automatic notifications, your upgrade will be complete. We hope you enjoy it!') . '\',0,' . time() . ')') or enhanced_error('Failed to alert admin to rebuild search index', true);
set_config('db_version', 4);
set_config('new_version', 0);
Esempio n. 10
0
<?php

$db->query('DELETE FROM `#^bans` WHERE expires<=' . time()) or enhanced_error('Failed to delete old bans', true);
//delete any bans that have already expired
if ($ban_type == 'ban') {
    $page_title = translate('banned');
    $result = $db->query('SELECT * FROM `#^bans` WHERE (username=\'' . $db->escape($futurebb_user['username']) . '\' OR ip=\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\') AND (expires>' . time() . ' OR expires IS NULL)') or error('Failed to check for bans', __FILE__, __LINE__, $db->error());
    $cur_ban = $db->fetch_assoc($result);
    $ban_page_replaced = false;
    //this sets up for a hook, where the ban page can be replaced
    ExtensionConfig::run_hooks('ban_page', array('ban_info' => $cur_ban, 'type' => $ban_type));
    if (!$ban_page_replaced) {
        ?>
		<h2><?php 
        echo translate('banned');
        ?>
</h2>
		<p><?php 
        echo translate('bannedmsg1');
        if ($cur_ban['expires'] != null) {
            echo ' ' . translate('until') . ' ' . user_date($cur_ban['expires']);
        }
        ?>
. <?php 
        echo translate('bannedmsg2');
        ?>
<br /><b><?php 
        echo htmlspecialchars($cur_ban['message']);
        ?>
</b><br /><?php 
        echo translate('bannedmsg3', $futurebb_config['admin_email']);
" /></td>
				</tr>
				<tr>
					<th>Maximum size (KiB)</th>
					<td><input type="text" name="maxsize" value="<?php 
echo intval($futurebb_config['user_image_maxsize']);
?>
" /></td>
				</tr>
			</table>
			<p><input type="submit" name="form_sent" value="Save" /></p>
		</form>
		<h3>Recent images</h3>
		<?php 
$result = $db->query('SELECT 1 FROM `#^userimages`') or enhanced_error('Failed to get recent images', true);
$num_images = $db->num_rows($result);
$result = $db->query('SELECT i.id,i.extension,i.time,i.filename,i.ip_addr,i.user,u.username FROM `#^userimages` AS i LEFT JOIN `#^users` AS u ON u.id=i.user ORDER BY time DESC LIMIT 20') or enhanced_error('Failed to get recent images', true);
if ($db->num_rows($result)) {
    echo '<p>Pages: ' . paginate('<a href="' . $base_config['baseurl'] . '/' . htmlspecialchars($dirs[1]) . '?page=$page$"$bold$>$page$</a>', $page, ceil($num_images / 20)) . '</p>';
    echo '<table border="0px">';
    echo '<tr><th>Image</th><th>Uploader</th><th>IP address</th><th>Time</th><th>Code</th></tr>';
    while ($img = $db->fetch_assoc($result)) {
        echo '<tr><td><img src="' . htmlspecialchars($base_config['baseurl']) . '/static/userimages/' . $img['id'] . '.' . $img['extension'] . '" alt="' . htmlspecialchars($img['filename']) . '" style="max-width:48px; max-height:48px" /></td><td><a href="' . $base_config['baseurl'] . '/users/' . htmlspecialchars(rawurlencode($img['username'])) . '">' . htmlspecialchars($img['username']) . '</a> (<a href="' . $base_config['baseurl'] . '/myimages?user='******'user'] . '">images</a>)</td><td><a href="' . $base_config['baseurl'] . '/admin/ip_tracker?ip=' . htmlspecialchars(rawurlencode($img['ip_addr'])) . '">' . htmlspecialchars($img['ip_addr']) . '</a></td><td>' . user_date($img['time']) . '</td><td><input type="text" readonly="readonly" value="[img]' . htmlspecialchars($base_config['baseurl']) . '/static/userimages/' . $img['id'] . '.' . $img['extension'] . '[/img]" size="50" /></td></tr>';
    }
    echo '</table>';
} else {
    echo '<p>No images found!</p>';
}
?>
	</div>
</div>
Esempio n. 12
0
		document.getElementById('table_cat_' + new_cat_id).childNodes[0].appendChild(forumRow);
		document.getElementById('sort_order_' + forum_id).value = max_sort_orders[new_cat_id] + 1;
		max_sort_orders[new_cat_id]++;
		
		var oldCat = document.getElementById('catof_' + forum_id).value;
		//document.getElementById('table_cat_' + oldCat).childNodes[0].removeChild(forumRow);
		max_sort_orders[oldCat]--;
		document.getElementById('catof_' + forum_id).value = new_cat_id;
		
		unlockSubmit();
	}
	//]]>
	</script>
	<?php 
//get the plain list of categories
$result = $db->query('SELECT id,name FROM `#^categories` ORDER BY name ASC') or enhanced_error('Failed to get categories', true);
$catlist_html = '<option value="-1">' . translate('changecategory') . '</option>';
while (list($id, $name) = $db->fetch_row($result)) {
    $catlist_html .= '<option value="' . $id . '">' . htmlspecialchars($name) . '</option>';
}
?>
	<div class="forum_content rightbox admin">
    	<form action="<?php 
echo $base_config['baseurl'];
?>
/admin/forums/enhanced" method="post" enctype="multipart/form-data" id="theform">
            <h3><?php 
echo translate('editforums');
?>
</h3>
			<p><a style="text-decoration: underline;cursor:pointer" onclick="addCat();"><?php 
Esempio n. 13
0
 static function remove_page($url)
 {
     global $db;
     $db->query('DELETE FROM `#^pages` WHERE url=\'' . $db->escape($url) . '\'') or enhanced_error('Failed to remove page from database', true);
     CacheEngine::CachePages();
 }
Esempio n. 14
0
 function commit()
 {
     global $db;
     $sql = 'SELECT ';
     $sql .= implode(',', $this->fields);
     $sql .= ' FROM `' . $db->prefix . $this->table . '` ';
     if ($this->table_as != '') {
         $sql .= ' AS ' . $this->table_as;
     }
     if (!empty($this->joins)) {
         foreach ($this->joins as $join) {
             $sql .= ' ' . $join->type() . ' JOIN `' . $db->prefix . $join->table() . '` AS ' . $join->join_as() . ' ON ' . $join->getOn();
         }
     }
     if ($this->where != '') {
         $sql .= ' WHERE ' . $this->where;
     }
     if ($this->order != '') {
         $sql .= ' ORDER BY ' . $this->order;
     }
     if ($this->limit != '') {
         $sql .= ' LIMIT ' . $this->limit;
     }
     $result = $db->query($sql) or enhanced_error($this->error . '<br />Query: ' . $sql, true);
     return $result;
 }
Esempio n. 15
0
     $keys = implode(',', array_keys($cfg_list));
     foreach ($cfg_list as $name => $type) {
         switch ($type) {
             case 'bool':
                 $sql .= ',' . (isset($_POST['config'][$name]) ? '1' : '0');
                 break;
             case 'string':
                 $sql .= ',\'' . $db->escape(isset($_POST['config'][$name]) ? $_POST['config'][$name] : '') . '\'';
                 break;
             case 'int':
                 $sql .= ',' . (isset($_POST['config'][$name]) ? intval($_POST['config'][$name]) : 0) . '';
                 break;
         }
     }
     $sql = substr($sql, 1);
     $db->query('INSERT INTO `#^user_groups`(' . $keys . ') VALUES(' . $sql . ')') or enhanced_error('Failed to insert new group', true);
 } else {
     foreach ($cfg_list as $name => $type) {
         switch ($type) {
             case 'bool':
                 $sql .= ',' . $name . '=' . (isset($_POST['config'][$name]) ? '1' : '0');
                 break;
             case 'string':
                 $sql .= ',' . $name . '=\'' . $db->escape($_POST['config'][$name]) . '\'';
                 break;
             case 'int':
                 $sql .= ',' . $name . '=' . intval($_POST['config'][$name]) . '';
                 break;
         }
     }
     $sql = substr($sql, 1);
Esempio n. 16
0
//update database structure
$db->drop_field('users', 'dst');
$new_timezone = new DBField('timezone', 'INT(3)');
$new_timezone->set_default(0);
$db->alter_field('users', $new_timezone);
$archived_fld = new DBField('archived', 'TINYINT(1)');
$archived_fld->add_extra('NOT NULL');
$archived_fld->set_default(0);
$db->add_field('forums', $archived_fld, 'num_posts');
echo '<li>RV3: Updating database structure... success</li>';
//convert all old timezones (just the UTC offset) to the new technique which uses the entire PHP dictionary
//map all UTC offsets to new timezones
$mappings = array(-12 => 383, -11 => 398, -10 => 53, -9 => 94, -8 => 132, -7 => 162, -6 => 144, -5 => 151, -4 => 84, -3 => 57, -2 => 295, -1 => 8, 0 => 415, 1 => 333, 2 => 327, 3 => 340, 4 => 230, 5 => 244, 6 => 266, 7 => 220, 8 => 271, 9 => 279, 10 => 309, 11 => 399, 12 => 385, 13 => 213);
//I hate mass queries as much as anyone, but they have to be done
foreach ($mappings as $oldtime => $newtime) {
    $db->query('UPDATE `#^users` SET timezone=' . $newtime . ' WHERE timezone=' . $oldtime) or enhanced_error('Failed to update timezone', true);
}
echo '<li>RV3: Converting timezones... success</li>';
ExtensionConfig::add_page('/styles', array('file' => 'style.php', 'template' => false, 'admin' => false, 'mod' => false, 'subdirs' => true));
ExtensionConfig::remove_page('/styles/default.css');
ExtensionConfig::remove_page('/styles/default.css/');
ExtensionConfig::remove_page('/styles/embed.css');
echo '<li>RV3: Adding missing pages... success</li>';
ExtensionConfig::add_language_key('showallposts', 'Show all posts', 'English');
ExtensionConfig::add_language_key('timeformatdesc', 'The following two entries allow you to set the format used for displaying all times by the software. For items that only display the date, the date format is used, but for items that display the time, the date format and time format are joined together. The formats must follow the <a href="http://php.net/manual/en/function.date.php#refsect1-function.date-parameters">PHP guidelines</a>.', 'English');
ExtensionConfig::add_language_key('unknownerror', 'An unknown error occurred', 'English');
ExtensionConfig::add_language_key('specificnestingerror', 'The tag <b>[$1]</b> cannot be placed directly inside <b>[$2]</b>.', 'English');
ExtensionConfig::add_language_key('errorwaslocated', 'The above error was located at: ', 'English');
ExtensionConfig::add_language_key('tagwasopened', 'The <b>[$1]</b> tag was opened at the following location: ', 'English');
ExtensionConfig::add_language_key('archived', '(Archived)', 'English');
ExtensionConfig::add_language_key('dateformat', 'Date format', 'English');
Esempio n. 17
0
            } else {
                echo '<table border="0">
						<tr>
							<th>' . translate('time') . '</th>
							<th>' . translate('sentby') . '</th>
							<th>' . translate('sentto') . '</th>
							<th>' . translate('message') . '</th>
						</tr>';
                while ($msg = $db->fetch_assoc($result)) {
                    echo '<tr><td>' . user_date($msg['send_time']) . '</td><td>' . htmlspecialchars($msg['arguments']) . '</td><td>' . htmlspecialchars($msg['recipient']) . '</td><td>' . $msg['contents'] . '</td></tr>';
                }
                echo '</table>';
            }
            break;
        case 'pm_reply':
            $result = $db->query('SELECT contents,send_time FROM `#^notifications` WHERE id=' . intval($_GET['id']) . ' AND user='******'id']) or enhanced_error('Failed to find notification', true);
            if (!$db->num_rows($result)) {
                httperror(404);
            }
            list($msg, $time) = $db->fetch_row($result);
            $lines = explode("\n", $msg);
            foreach ($lines as &$line) {
                $line = '> ' . $line;
            }
            pmbox(translate('pm_reply_header', user_date($time)) . "\n" . implode("\n", $lines));
            break;
        default:
            httperror(404);
    }
} else {
    //view-only
Esempio n. 18
0
 static function parse_msg($text, $show_smilies = true, $preview = false, $bbcode = true)
 {
     global $db, $futurebb_user, $futurebb_config;
     if ($bbcode && empty(self::$pattern)) {
         self::$pattern = array();
         self::$replace = array();
         self::add_bbcode('%\\[b\\](.*?)\\[/b\\]%ms', '<strong>$1</strong>');
         self::add_bbcode('%\\[i\\](.*?)\\[/i\\]%ms', '<em>$1</em>');
         self::add_bbcode('%\\[u\\](.*?)\\[/u\\]%ms', '<u>$1</u>');
         self::add_bbcode('%\\[s\\](.*?)\\[/s\\]%ms', '<del>$1</del>');
         self::add_bbcode('%\\[colou?r=(white|black|red|green|blue|orange|yellow|pink|gray|magenta|#[0-9a-fA-F]{6}|\\#[0-9a-fA-F]{3})\\](.*?)\\[/colou?r\\]%m', '<span style="color:$1">$2</span>');
     }
     $text = htmlspecialchars($text);
     //clear out any funny business
     $text = preg_replace_callback('%\\s?\\[code\\](.*?)\\[/code\\]\\s?%msi', 'self::handle_code_tag_remove', $text);
     //remove content of code tags prior to parsing
     while (preg_match('%\\[quote(=.*?)?\\](.*?)\\[/quote\\]%ms', $text)) {
         $text = preg_replace_callback('%\\[quote\\](.*?)\\[/quote\\]%ms', 'self::handle_quote_tag', $text);
         $text = preg_replace_callback('%\\[quote=(.*?)\\](.*?)\\[/quote\\]%ms', 'self::handle_quote_tag', $text);
     }
     //links and images (these can't be grouped with the rest because they use a different function
     $text = preg_replace_callback('%\\[url=?(.*?)\\](.*?)\\[/url\\]%s', 'self::handle_url_tag', $text);
     $text = preg_replace_callback('%\\[img\\](.*?)\\[/img\\]%s', 'self::handle_img_tag', $text);
     // Format @username into tags
     if ($futurebb_config['allow_notifications'] == 1) {
         $text = preg_replace('%(\\s|^)@([a-zA-Z0-9_\\-]+)%', '$1<span class="usertag">@$2</span>', $text);
     }
     //run the bbcode parser with the items entered into the array at the beginning of this function
     if ($bbcode) {
         self::parse_bbcode($text);
     }
     if ($show_smilies) {
         // only parse similies if they were enabled by poster
         self::parse_smilies($text);
     }
     $text = self::add_line_breaks($text);
     //make the @username into links where applicable
     $at_usernames = array();
     $text = preg_replace_callback('%<span class="usertag">@([a-zA-Z0-9_\\-]+)</span>%', function ($matches) use(&$at_usernames) {
         if (in_array($matches[1], $at_usernames)) {
             $return = array_search($matches[1], $at_usernames);
         } else {
             $at_usernames[] = $matches[1];
             $return = sizeof($at_usernames) - 1;
         }
         return '<span class="usertag">' . $return . '</span>';
     }, $text);
     if (!empty($at_usernames)) {
         $at_usernames_safe = array();
         foreach ($at_usernames as $username) {
             $at_usernames_safe[] = '\'' . $db->escape(strtolower($username)) . '\'';
         }
         $returned_usernames = array();
         $result = $db->query('SELECT LOWER(username) FROM `#^users` WHERE LOWER(username) IN(' . implode(',', $at_usernames_safe) . ')') or enhanced_error('Failed to validate usernames', true);
         while (list($username) = $db->fetch_row($result)) {
             $returned_usernames[] = $username;
         }
         $text = preg_replace_callback('%<span class="usertag">(\\d+)</span>%', function ($matches) use($at_usernames, $returned_usernames) {
             global $base_config;
             $req_username = $at_usernames[$matches[1]];
             if (in_array(strtolower($req_username), $returned_usernames)) {
                 $return = '<a href="' . $base_config['baseurl'] . '/users/' . $req_username . '">@' . $req_username . '</a>';
             } else {
                 $return = '@' . $req_username;
             }
             return '<span class="usertag">' . $return . '</span>';
         }, $text);
     }
     //handle list and table tags last, they're weird
     $text = self::handle_list_tags($text);
     $text = self::handle_table_tags($text);
     $text = preg_replace_callback('%\\s?\\[code\\](.*?)\\[/code\\]\\s?%msi', 'self::handle_code_tag_replace', $text);
     //put [code] tags back
     $text = censor($text);
     return $text;
 }
Esempio n. 19
0
				<th><?php 
echo translate('onlinetimeout');
?>
</th>
				<td><input type="text" name="config[online_timeout]" value="<?php 
echo intval($futurebb_config['online_timeout']);
?>
" size="5" /><br /><?php 
echo translate('onlinetimeoutdesc');
?>
</td>
			</tr>
			<tr>
				<th>Default language</th>
				<td><select name="config[default_language]"><?php 
$result = $db->query('SELECT DISTINCT(language) FROM `#^language` ORDER BY language ASC') or enhanced_error('Failed to find language information', true);
while (list($language) = $db->fetch_row($result)) {
    echo '<option value="' . htmlspecialchars($language) . '"';
    if ($language == $futurebb_config['default_language']) {
        echo ' selected="selected"';
    }
    echo '>' . htmlspecialchars($language) . '</option>';
}
?>
</select></td>
			</tr>
			<tr>
				<th><?php 
echo translate('allowPM');
?>
</th>
<?php

ExtensionConfig::remove_language_key('imageuploading');
ExtensionConfig::remove_page('/extensions/uploadimage');
ExtensionConfig::remove_page('/admin/imageuploading', array('file' => 'admin/imageuploading.php', 'template' => true, 'nocontentbox' => true, 'admin' => true));
ExtensionConfig::remove_admin_menu('imageuploading');
ExtensionConfig::remove_page('/myimages');
$db->query('DELETE FROM `#^config` WHERE c_name IN(\'user_image_maxwidth\', \'user_image_maxheight\', \'user_image_maxsize\')') or enhanced_error('Failed to delete config entries', true);
$db->drop_table('userimages');
$db->drop_field('user_groups', 'g_upload_images');
unlink(FORUM_ROOT . '/app_resources/pages/myimages.php');
unlink(FORUM_ROOT . '/app_resources/pages/uploadimage.php');
unlink(FORUM_ROOT . '/app_resources/pages/admin/imageuploading.php');
    }
    list($username) = $db->fetch_row($result);
} else {
    $user = $futurebb_user['id'];
}
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$page_title = 'My images';
?>
<h2><?php 
echo $user == $futurebb_user['id'] ? 'My' : $username . '&apos;s';
?>
 images</h2>
<?php 
$result = $db->query('SELECT 1 FROM `#^userimages` WHERE user='******'Failed to get recent images', true);
$num_images = $db->num_rows($result);
$result = $db->query('SELECT id,extension,time,filename,ip_addr FROM `#^userimages` WHERE user='******' ORDER BY time DESC LIMIT ' . 20 * ($page - 1) . ',20') or enhanced_error('Failed to get recent images', true);
if ($db->num_rows($result)) {
    echo '<p>Pages: ' . paginate('<a href="' . $base_config['baseurl'] . '/' . htmlspecialchars($dirs[1]) . '?page=$page$"$bold$>$page$</a>', $page, ceil($num_images / 20)) . '</p>';
    echo '<table border="0px">';
    echo '<tr><th>Image</th><th>Time</th><th>Code</th>';
    if ($futurebb_user['g_admin_privs'] || $futurebb_user['g_mod_privs'] && $futurebb_user['g_mod_view_ip']) {
        echo '<th>IP address</th>';
    }
    echo '</tr>';
    while ($img = $db->fetch_assoc($result)) {
        echo '<tr>
			<td><img src="' . htmlspecialchars($base_config['baseurl']) . '/static/userimages/' . $img['id'] . '.' . $img['extension'] . '" alt="' . htmlspecialchars($img['filename']) . '" style="max-width:48px; max-height:48px" /></td>
			<td>' . user_date($img['time']) . '</td>';
        if ($futurebb_user['g_admin_privs'] || $futurebb_user['g_mod_privs'] && $futurebb_user['g_mod_view_ip']) {
            echo '<td><a href="' . $base_config['baseurl'] . '/admin/ip_tracker?ip=' . htmlspecialchars(rawurlencode($img['ip_addr'])) . '">' . htmlspecialchars($img['ip_addr']) . '</a></td>';
        }