Daily Lucky Numbers:


Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Chen Zhen

vbgamer has a mod that stores links in the database.
Its copyright allows me to edit it & post it on the forum.
I'm attaching it to this post so you can use it for your needs.

Mod Details:
- can change the permissions of adding/editing links to admin only (if that's your preference)
- BBCode option to allow you to use links as an ID#
- BBC membergroup permission is available for the admin which can set the permission to allow/disallow all BBC links as BBC (admin permissions)
- BBC membergroup permission to allow/disallow all BBC per category (mod admin)
- option to allow same window / external window for the BBC link
- each link shows its ID# to the left of its name in each category list
- each link shows its ID# in the edit link template
- option to provide a unique BBC name

If the membergroup has the permission to view the link & use the BBC then it will count the hits.
However if you only have the allow BBC checked then it will not count the hits.

If you really need to use a .txt file then try this...

contents for file : list.txt
https://simplemachines.org, SMF
https://web-develop.ca, WebDev

BBCode insert for your SMF source file:
                'tag' => 'test',
                'type' => 'unparsed_content',
                'before' => '[test]',
                'after' => '[/test]',
                'validate' => function(&$tag, $url) {
                    if (preg_match('%([^"&?/ ])%i', $url, $match)) {
                        $f = fopen('./list.txt', 'r');
                        list($lines, $value) = array(array(), array());
                        if (!empty($f)) {
                            while (!feof($f)) {
                                $lines[] = fgets($f);
                            $lineValue = !empty($match[1]) && abs($match[1]) > 0 ? abs($match[1]) - 1 : 0;
                            if (!empty($lines[$lineValue])) {
                                $value = explode(',', $lines[$lineValue]);
                                $tag['content'] = !empty($value) && count($value) > 1 ? '<a href="' . $value[0] . '">' . $value[1] . '</a>' : '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>';
                        if (count($value) < 2)
                            $tag['content'] = '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>';
                        $tag['content'] = '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>';
                'trim' => 'both',
                'quoted' => 'optional',

I still included the link & text since it makes more sense to do it that way.
A more efficient way would be to store the data in your database.
Does the source have to be a text file?

If you must use a file why not a CSV file?
You can put the file into an array & then just use the key (line #) that you're after.

Here is an example of a file named list.csv that contains links with their text:
https://simplemachines.org, SMF
https://web-develop.ca, WebDev

Here is an example of your BBCODE that brings up a link by line #:
                'tag' => 'test',
                'type' => 'unparsed_content',
                'before' => '[test]',
                'after' => '[/test]',
                'validate' => function(&$tag, $url) {
                    if (preg_match('%([^"&?/ ])%i', $url, $match)) {
                        $rows = array_map('str_getcsv', file('./list.csv'));
                        $csv = array();
                        foreach ($rows as $row) {
                          $csv[] = $row;
                        $value = !empty($match[1]) && abs($match[1]) > 0 ? abs($match[1]) - 1 : 0;
                        $tag['content'] = !empty($csv[$value]) ? '<a href="'. $csv[$value][0] .'">' . $csv[$value][1] . '</a>' : '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>';
                        $tag['content'] = '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>';
                'trim' => 'both',
                'quoted' => 'optional',

If you put something like this BBC:

.. it should show the following:

I haven't tested this but you should have an idea of what to do.
Yes a lengthy file will cause a delay when using line breaks to separate data.
This is just an example that you can tweak.

Create a board that has a profile setting of read only which will only allow admins to post in it.
Make your posts in that board that you want to appear on your front page block.

Now create a PHP block with the following code in it:
$admin_group_id = 0;
$admin_ids = array(1);
$board_ids = array(1);
$board_profile = 4;

//$query_where = 'mem.id_member IN ({array_int:admin_ids}) AND FIND_IN_SET({int:groupid}, b.member_groups) != 0 AND b.id_profile = {int:read_only} AND m.id_board IN ({array_int:board_ids})';

$query_where = 'mem.id_member IN ({array_int:admin_ids}) AND FIND_IN_SET({int:groupid}, b.member_groups) != 0 AND b.id_profile = {int:read_only}';
$query_where_params = array('groupid' => $admin_group_id, 'admin_ids' => $admin_ids, 'board_ids' => $board_ids, 'read_only' => $board_profile);
$query_limit = 10;
$query_order = 'm.id_msg DESC';
$limit_body = true;
$override_permissions = false;

$queryPosts = ehPortal_queryPosts($query_where, $query_where_params, $query_limit, $query_order, $output_method, $limit_body, $override_permissions);

function ehPortal_queryPosts($query_where, $query_where_params, $query_limit, $query_order, $limit_body, $override_permissions)
    global $scripturl, $txt, $user_info;
    global $modSettings, $smcFunc, $context;

    if (!empty($modSettings['enable_likes']))
        $context['can_like'] = allowedTo('likes_like');

    // Find all the posts. Newer ones will have higher IDs.
    $request = $smcFunc['db_query']('substring', '
            m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, m.id_board, m.likes, b.name AS board_name, b.member_groups, b.id_profile,
            COALESCE(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
            COALESCE(lt.id_msg, lmr.id_msg, 0) >= m.id_msg_modified AS is_read,
            COALESCE(lt.id_msg, lmr.id_msg, -1) + 1 AS new_from') . ', ' . ($limit_body ? 'SUBSTRING(m.body, 1, 384) AS body' : 'm.body') . ', m.smileys_enabled
        FROM {db_prefix}messages AS m
            INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)' . ($modSettings['postmod_active'] ? '
            INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)' : '') . '
            LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
            LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = {int:current_member})
            LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = m.id_board AND lmr.id_member = {int:current_member})' : '') . '
        WHERE 1=1 ' . ($override_permissions ? '' : '
            AND {query_wanna_see_board}') . ($modSettings['postmod_active'] ? '
            AND m.approved = {int:is_approved}
            AND t.approved = {int:is_approved}' : '') . '
        ' . (empty($query_where) ? '' : 'AND ' . $query_where) . '
        ORDER BY ' . $query_order . '
        ' . ($query_limit == '' ? '' : 'LIMIT ' . $query_limit),
        array_merge($query_where_params, array(
            'current_member' => $user_info['id'],
            'is_approved' => 1,
    $posts = array();
    while ($row = $smcFunc['db_fetch_assoc']($request))
        $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);

        // Censor it!

        $preview = strip_tags(strtr($row['body'], array('<br>' => '&#10;')));

        // Build the array.
        $posts[$row['id_msg']] = array(
            'id' => $row['id_msg'],
            'board' => array(
                'id' => $row['id_board'],
                'name' => $row['board_name'],
                'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
                'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'
            'topic' => $row['id_topic'],
            'poster' => array(
                'id' => $row['id_member'],
                'name' => $row['poster_name'],
                'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
                'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
            'subject' => $row['subject'],
            'short_subject' => shorten_subject($row['subject'], 25),
            'preview' => $smcFunc['strlen']($preview) > 128 ? $smcFunc['substr']($preview, 0, 128) . '...' : $preview,
            'body' => $row['body'],
            'time' => timeformat($row['poster_time']),
            'timestamp' => $row['poster_time'],
            'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
            'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>',
            'new' => !empty($row['is_read']),
            'is_new' => empty($row['is_read']),
            'new_from' => $row['new_from'],

        // Get the likes for each message.
        if (!empty($modSettings['enable_likes']))
            $posts[$row['id_msg']]['likes'] = array(
                'count' => $row['likes'],
                'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
                'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),

    echo '
        <div style="width: 100%;overflow: hidden;">
            <div style="width: 100%;text-align: center;margin: 0 auto;color: blue;font-size: 1.5em;text-decoration: underline;padding: 1em;">IMPORTANT POSTS</div>';
    foreach ($posts as $post) {
        $date = date('Y-m-d', $post['timestamp']);
        echo '
            <div>Board: ' . $post['board']['link'] . '</div>
            <div>Topic: ' . $post['link'] . '</div>
            <div>Author: ' . $post['poster']['link'] . '</div>
            <div>Date: ' . $date . '</div>
            <hr />';
    echo '

You can change the $query_where, $query_where_params and the database SELECT to filter what you're trying to display.
The above finds the latest 10 posts from member id #1 (more can be added to the array) & admin group id 0 in boards set to read-only. 
I put in $board_ids to help show you as an example but the above query doesn't use it because that string is commented out.

I can help you with a PHP block that will contain some specifics for the query.

The ssi_queryPosts function in SSI.php sounds like it will do what you want.
You just need to give it arguments to target your query.
If you use the option it will attempt to escape various characters that would normally not allow you to save the block due to errors.

You copy/paste some HTML and want to use it in a PHP block but it contains a mixture of single (apostrophes) & double quotes.
With that option enabled it will attempt to escape characters automatically when needed.
It will also remove anything using a double escape (backslash).

I can take a look myself if it's a live arcade forum.
The only link I see on SMF forum's under your user-name points to idahogaragecade but I don't know the sub-path to a possible SMF forum if one exists.
My apologies for the late replies as I have been preoccupied with other things.

As long as you're using an up-to-date browser then it should work fine.
Other things on the arcade page from mods or manual edits can sometimes conflict with JavaScript which may cause your problem.
If the HTML5 game plays here on this arcade then download it and try it on your arcade.
If it doesn't work then on that arcade page you can right-click & inspect (developer mode) the page in your browser.
Use the "console" option to view JavaScript errors. This will likely provide clues as to what is wrong.

I will investigate your report although this does not occur on this forum.
However I may have different settings for guests.
Well I'm glad you got it sorted out.

The latest stable release has been tested thoroughly by our Beta testers so it should function quite well.
I'll look at this later today.
With the admin access, I can now test it myself.
The way I tried to detect a XML string was not good.
Ok, try this package...

I can always fix the older shoutbox if you really like it.
Unless the TP shoutbox is ok.
You might need to edit the user permissions for that TP shoutbox because I was only able to read the shouts.

Now I see what I did wrong because the function I added a DOM parser to doubles for HTML & XML content.

So when you click the sitemap link, it shows a list of boards in HTML and if you then opt the XML link it shows a bunch of topics in XML format. Is this correct?

I'd like you to try this copy...

If the error comes up again let me know.
Post the reference line to Load.php because I forgot which one it was  ???
I think it had something to do with a funny character in a cache file and I'm thinking it might be a SMF 2.1 glitch that may need to be fixed.


IMO it was likely nneonneo's shoutbox.
That mod is old and unless someone updated it for 4 byte emoji's, those will likely jam it up.
All someone had to do was use an emoji from their smart phone & it will likely crash it.
It's easily amended if you know how to do it.
I used a wordpress code for my EhPortal shoutbox.