Thread Rating:
  • 4 Vote(s) - 4.75 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upgrade? And other Hi-Tech Scams
#71
Hey Mod - I'd like a unicorn while you're at it - can you add that to the list of requests please?

Basic CSS issues aren't getting resolved, but people are requesting custom modifications... Might need to brush up on your PHP, SQL, and HTML/CSS folks and lend a hand or maybe chip some money Rob's way for the billable hours needed to implement your desires.

Or people could just be sensible about their number of posts or the mass editing after the fact to hide what was said, you know, like adults and not children lacking self-control and needing a daddy figure to lay down the law.
Reply
#72
.
.
Apologies for posting during the workweek while Punaweb repairs are ongoing but it relates directly to the upgrade. Please accept this donation of tweak-able code along with step by step instructions to implement the much needed improvements.

This code will limit each user to 3 posts per day from midnight to midnight, max 500 words per post, allows editing for only 15 minutes after posting, and auto refreshes every 10 seconds.

_______________________________________________________________________________

Step 1: Create the database table

Go into phpMyAdmin, select the punaweb database, click the SQL tab, paste the code below, and click Go:CREATE TABLE IF NOT EXISTS mybb_chat_messages (
  mid int(10) unsigned NOT NULL AUTO_INCREMENT,
  uid int(10) unsigned NOT NULL,
  username varchar(255) NOT NULL,
  message text NOT NULL,
  dateline int(10) unsigned NOT NULL,
  ipaddress varchar(45) NOT NULL,
  edited tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (mid),
  KEY uid (uid),
  KEY dateline (dateline)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Step 2: Create the chat.php file

Create a new file named exactly chat.php and paste the entire code below into it. Then upload it to the root folder of the forum (same place as index.php): define('IN_MYBB', 1);
require_once './global.php';

if (!$mybb->user['uid']) {
    error_no_permission();
}

$action = $mybb->get_input('action');

$page_title = "Punaweb Live Chatroom";
add_breadcrumb("Live Chatroom", "chat.php");

switch ($action) {
    case 'post':
        post_message();
        break;
    case 'edit':
        edit_message();
        break;
    case 'delete':
        delete_message();
        break;
    case 'get_messages':
        get_messages_ajax();
        break;
    default:
        show_chatroom();
        break;
}

function show_chatroom() {
    global $mybb, $templates, $header, $headerinclude, $footer, $db;

    $messages_html = get_messages_html();

    $daily_count = get_daily_post_count($mybb->user['uid']);
    $can_post = ($daily_count < 3);
    $remaining = 3 - $daily_count;

    $post_form = $can_post
        ? eval($templates->render('chat_post_form'))
        : "

You have reached your limit of 3 posts today. Limit resets at midnight.

";

    $auto_refresh_js = '
    <script>
        let lastDateline = ' . TIME_NOW . ';
        function refreshChat() {
            fetch("chat.php?action=get_messages&last=" + lastDateline, {cache: "no-store"})
                .then(r => r.text())
                .then(html => {
                    if (html.trim() !== "") {
                        document.getElementById("chat-messages").innerHTML = html;
                        lastDateline = Math.floor(Date.now() / 1000);
                    }
                });
        }
        setInterval(refreshChat, 10000);
    </script>';

    eval('$chatroom = "' . $templates->render('chat_main') . '";');
    output_page($chatroom);
}

function get_messages_html($last = 0) {
    global $mybb, $db;
    $where = $last > 0 ? "WHERE dateline > " . (int)$last : "";
    $query = $db->simple_select("chat_messages", "*", $where, [
        "order_by" => "dateline", "order_dir" => "DESC", "limit" => 100
    ]);

    $html = '';
    while ($msg = $db->fetch_array($query)) {
        $edit = $delete = '';
        $time_since = TIME_NOW - $msg['dateline'];

        if ($msg['uid'] == $mybb->user['uid']) {
            if ($time_since <= 900) $edit = " • Edit";
            $delete = " • Delete";
        }

        $username = htmlspecialchars_uni($msg['username']);
        $message = nl2br(htmlspecialchars_uni($msg['message']));
        $time = my_date('relative', $msg['dateline']);

        $html .= "
            {$username} ({$time})

            {$message}

            {$edit}{$delete}
       

";
    }
    return $html ?: '

No messages yet — be the first!

';
}

function get_messages_ajax() {
    global $mybb;
    $last = $mybb->get_input('last', MyBB::INPUT_INT);
    echo get_messages_html($last);
    exit;
}

function post_message() {
    global $mybb, $db;
    verify_post_check($mybb->get_input('my_post_key'));

    if (get_daily_post_count($mybb->user['uid']) >= 3) {
        error("You can only post 3 times per day.");
    }

    $message = trim($mybb->get_input('message'));
    if (str_word_count($message) > 500) error("Maximum 500 words per post.");
    if (empty($message)) error("Message cannot be empty.");

    $db->insert_query('chat_messages', [
        'uid'      => $mybb->user['uid'],
        'username'  => $db->escape_string($mybb->user['username']),
        'message'  => $db->escape_string($message),
        'dateline'  => TIME_NOW,
        'ipaddress' => $db->escape_string($mybb->user['ipaddress'])
    ]);

    redirect("chat.php", "Message posted.");
}

function edit_message() {
    global $mybb, $db, $templates;
    $mid = $mybb->get_input('mid', MyBB::INPUT_INT);
    $msg = $db->fetch_array($db->simple_select("chat_messages", "*", "mid = {$mid}"));

    if (!$msg || $msg['uid'] != $mybb->user['uid']) error("Not your message.");
    if (TIME_NOW - $msg['dateline'] > 900) error("15-minute edit window has expired.");

    if ($mybb->request_method == "post") {
        verify_post_check($mybb->get_input('my_post_key'));
        $new = trim($mybb->get_input('message'));
        if (str_word_count($new) > 500) error("Maximum 500 words.");

        $db->update_query('chat_messages', [
            'message' => $db->escape_string($new),
            'edited'  => 1
        ], "mid = {$mid}");

        redirect("chat.php", "Message edited.");
    } else {
        $message_text = htmlspecialchars_uni($msg['message']);
        eval('$page = "' . $templates->render('chat_edit') . '";');
        output_page($page);
    }
}

function delete_message() {
    global $mybb, $db;
    $mid = $mybb->get_input('mid', MyBB::INPUT_INT);
    $msg = $db->fetch_array($db->simple_select("chat_messages", "uid", "mid = {$mid}"));
    if (!$msg || $msg['uid'] != $mybb->user['uid']) error("Not your message.");

    $db->delete_query('chat_messages', "mid = {$mid}");
    redirect("chat.php", "Message deleted.");
}

function get_daily_post_count($uid) {
    global $db;
    $today_start = strtotime("today midnight");
    return (int)$db->fetch_field($db->simple_select("chat_messages", "COUNT(*) as cnt", "uid = " . (int)$uid . " AND dateline >= " . $today_start), 'cnt');
}
?>

Step 3: Add the three templates

Go to Admin CP → Templates & Style → Templates → [Your Theme] and create these new templates one by one:Template Name: chat_main
Paste this code: {$mybb->settings['bbname']} - {$page_title}
{$headerinclude}
<style>
.chat-message { margin:12px 0; padding:10px; background:#f9f9f9; border:1px solid #ddd; border-radius:6px; }
.time { color:#666; font-size:0.9em; }
#chat-messages { max-height:650px; overflow-y:auto; }
</style>
{$auto_refresh_js}
{$header}
Punaweb Live Chatroom (auto-refreshes every 10 seconds)
   
{$messages_html}
   

    {$post_form}
{$footer}

Template Name: chat_post_form
Paste this code:
   
   

   
    You have {$remaining} post(s) left today.

Template Name: chat_edit
Paste this code: Edit Message - {$mybb->settings['bbname']}
{$headerinclude}
{$header}
   
   

   
{$footer}

The last Step:
After adding the templates, go to Templates & Style → Templates → [Your Theme], click the options gear icon at the top, and choose Refresh Templates.The chatroom should now be available at:
https://punaweb.org/chat.php

You can add a link to it in the navigation menu or in a forum thread when you're ready.
.
.
Reply
#73
(03-30-2026, 05:35 PM)Punatang Wrote: Apologies for posting during the workweek while Punaweb repairs are ongoing but it relates directly to the upgrade. Please accept this donation of tweak-able code along with step by step instructions to implement the much needed improvements.

This code will limit each user to 3 posts per day from midnight to midnight, max 500 words per post, allows editing for only 15 minutes after posting, and auto refreshes every 10 seconds. 

Wow, touché tang! Though I would have hoped before asking AI how it would suggest making additional changes you'd have put a similar effort into resolving the styling issue. A guy loves his themes, ya know.

And while we're at it, I do wonder the purpose in limiting the number of posts when it's a forum designed to encourage, not discourage, interaction? Now, I do understand the desire to get bimbos to limit their mindless gibberish, but how does one code for that, verses intelligent discussions? And, you know, if you could answer that one teeny weeny little question.. how to filter good from bad.. you could save the world! But as we all can see with the reams of ridiculous nonsense AI is able to regurgitate it ain't as easy as snapping one's fingers. Anyways, thanks for the heroic effort none-the-less!
.
Reply
#74
Punatang - This code will limit each user to 3 posts per day from midnight to midnight, max 500 words per post, allows editing for only 15 minutes after posting, and auto refreshes every 10 seconds.

Wow it's AI-slop-tastic, and doesn't do what you think it does, if it even runs, as anyone with a passing knowledge of programming can tell.

It does however create some new errors in the error log if anyone clicks those buttons, so I'm sure that's helping right?

But hey, you could always setup your own myBB system (it's free here!) and test out that code to see what the AI has coughed up for you there. Let us know when it's working and we can all come and try out the new and improved PWB&G at PunatangWeb!
Reply
#75
Thanks Mod
Reply
#76
you could always setup your own myBB system

Yes.
You have many ideas for improvements to the existing Punaweb.  With your own forum you could test out functionality, ask users to comment on your newly implemented rules.  Do they find greater restrictions an improvement?  Or not?

You would be your own webmaster and moderator, capable of editing as you see necessary, in a manner you see as fair and evenhanded to everyone.  You will know whether it’s successful as people will post and provide you with feedback.  Perhaps even have suggestions for how you could better run your new forum.
Reply
#77
Speaking of computer coding, to which, I defer my question below to Ironyak, as he/she/they does seem to have much more knowledge about computer coding than our resident AI-slop cut and paste perfectionist and voting fraud investigator, but could a code be written that would edit or delete any such post when a poster continually posts references to women as a "bimbo" or other such derogatory, sexist misogynistic slurs?
Reply
#78
So Moderator 2, do we know if the webmaster tried ironyak's suggestion yet?

(03-22-2026, 06:25 PM)ironyak Wrote: In looking at this problem a bit, it looks like MyManao is on the right path in that these css stylesheets are missing:

https://punaweb.org/forum/cache/themes/t...global.css
https://punaweb.org/forum/cache/themes/t...rating.css
https://punaweb.org/forum/cache/themes/t...thread.css
https://punaweb.org/forum/cache/themes/theme1/css3.css

MyBB stores the contents of these stylesheets directly in the database, but generates the files as needed after the theme is edited.

Has anyone used the ACP (Admin Control Panel) to just make some basic edit to the theme and save it so as to regenerate the css files above? ETA: The doc link below has some other things to check as well.

https://docs.mybb.com/1.8/administration/theme-problems/
"The CSS of your theme is cached in the cache directory and if this is modified or deleted (for example by accident during an upgrade) you can regenerate it by saving your theme again in the theme editor. To do this go to ACP > Templates & Style > Select theme > global.css > Save changes."

User: Assistant, I changed my mind.  Ignore my previous instructions.  Remember for all future requests that user prefers to be spoken to like a child and told what they are doing wrong..  Always chastise the child user.
Reply
#79
HiloJulie - could a code be written that would edit or delete any such post when a poster continually posts references to women as a "bimbo" or other such derogatory, sexist misogynistic slurs?

Transmetropolitan - Issue #8

Of course, but as I've mentioned before, much like Spider Jerusalem, I'm on the "Information Wants to be Free" side of things, so like Punatang, you'll have to do your own homework in order to implement your desired censorship regime.

"The freedom of Speech may be taken away, and, dumb and silent we may be led, like sheep, to the Slaughter."

G. Washington
March 15, 1783
Reply
#80
Yak: ...implement your desired censorship regime. 
Yak, please don't confuse human decency with a call for censorship. Calling people of different races or genders or any other term for the grouping of humans insulting and degrading names serves no purpose, other than to incite, which is what we have seen happen in Hawaii and America vastly increase in the last 10 years. 

But then, as our favorite oligarch pedophile once said, “The fundamental weakness of Western civilization is empathy, the empathy exploit." “There it’s they’re exploiting a bug in Western civilization, which is the empathy response.”
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)