Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Project U-232 (http://www.bvlist.com/forumdisplay.php?f=80)
-   -   New ShoutBox ~ Beta Code (http://www.bvlist.com/showthread.php?t=10076)

Jinx 9th November 2014 04:14

Praise
 
looks/Sounds good keep working on

lil development idea im gonna throw in .... consider adding a private shout function to it makes life easier ;)

BamBam0077 17th December 2014 09:11

Upgrade News:

I have come to the point where I should redo this software and upgrade it to php 5.4 standards no offense to the original source base, I will make it work never the less.

Query Added :wild:
PHP 5.4 Added :wild:
Emotions Function Recoded :wild:
BBCode Function Recoded :wild:
Donor Function Added :wild:
Bot Function Re-Modified :wild:
Font Function Recoded :wild:
Staff Private Chat System Added :wild:
Public Private Chat System Re-Modified :wild:

I will dump all general chat into the database as does other chat systems but I have this policy where snooping is a crime & well its really upto the owner/developer that modifies my next release to either allow or disallow the owner/developer (only) from peeking into the private chat system. If you understand SQL you will learn you can also check your pr_logs404 dumps which are going to be generated to be doing them every 48hrs then send site e-mail a message saying pr_log404 has been backed up along side other false backup recalls.

E.G
Code:

Hello BamBam0077,

 It has come to our attention you requested a random backup of your own
 database "BETA5_SQL". We have kindly attached your requested file and would like to wish you a Merry Christmas!.

pr_log404
pr_mes404
pr_clas404
pr_curid404

[file will be attached]

Thanks For Your Patience,
BamBam0077

P.S
MIT License Applies

code snippet preview:
http://i.imgbox.com/in4VgcDr.png

http://i.imgbox.com/ktPqBNxN.png

Reading this:
http://www.impressivewebs.com/jquery...-beginners.pdf

Will use to intergrate JQuery & CSS3

Bump: Replace /var/www/blocks/index/shoutbox.php line 14 - 59
Code:

  $HTMLOUT .= "

 

    ShoutBox - General Chit-chat
    ";
  if ($CURUSER['class'] >= UC_STAFF){
  $HTMLOUT .= "{$lang['index_shoutbox_history']}";
  }
  $HTMLOUT .= "

 

 
 
\n";

With:
Code:

  $HTMLOUT .= "
 

 
";
  $HTMLOUT .= "
   
   
 
 
 
 
 


   

 
\n";


Replace entire /var/www/shoutbox.php

Code:

/**
 *  https://09source.kicks-ass.net:8443/svn/installer09/
 *  Licence Info: GPL
 *  Copyright (C) 2010 Installer09 v.2
 *  A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
 *  Project Leaders: Mindless,putyn,kidvision.
 **/
/*
+------------------------------------------------
|  $Date$
|  $Revision$ 09 Final
|  $shoutbox
|  $Author$ drykilllogic,snuggs,pdq,putyn,Bigjoos
|  $URL$
+------------------------------------------------
*/
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
require_once(INCL_DIR.'bbcode_functions.php');
dbconn( false );
loggedinorreturn();

$HTMLOUT = $query = '';

header('Content-Type: text/html; charset='.$INSTALLER09['char_set'].'');

// === added turn on / off shoutbox - sir snuggs
if ( ( isset( $_GET['show_shout'] ) ) && ( ( $show_shout = $_GET['show'] ) !== $CURUSER['show_shout'] ) ) {
sql_query( "UPDATE users SET show_shout = " . sqlesc( $_GET['show'] ) . " WHERE id = {$CURUSER['id']}" );
$mc1->begin_transaction('MyUser_'.$CURUSER['id']);
$mc1->update_row(false, array('show_shout' => $_GET['show']));
$mc1->commit_transaction(900);
header( "Location: " . $_SERVER['HTTP_REFERER'] );
}

unset( $insert );
$insert = false;

// Delete single shout
if ( isset( $_GET['del'] ) && $CURUSER['class'] >= UC_STAFF && is_valid_id( $_GET['del'] ) )
sql_query( "DELETE FROM shoutbox WHERE id=" . sqlesc( $_GET['del'] ) );
// Empty shout - sysop
if ( isset( $_GET['delall'] ) && $CURUSER['class'] == UC_SYSOP )
$query = "TRUNCATE TABLE shoutbox";
sql_query( $query );
unset($query);

// Staff edit
if (isset($_GET['edit']) && $CURUSER['class'] >= UC_STAFF && is_valid_id($_GET['edit']))
{   
$sql = sql_query('SELECT id, text FROM shoutbox WHERE id='.sqlesc($_GET['edit']));
$res = mysql_fetch_assoc($sql);
unset($sql);

$HTMLOUT .="














";
echo $HTMLOUT;
die;
}

// Power Users+ can edit anyones single shouts //== pdq
if (isset($_GET['edit']) && ($_GET['user'] == $CURUSER['id']) && ($CURUSER['class'] >= UC_POWER_USER && $CURUSER['class'] <= UC_STAFF) && is_valid_id($_GET['edit']))
{   
$sql = sql_query('SELECT id, text, userid FROM shoutbox WHERE userid ='.sqlesc($_GET['user']).' AND id='.sqlesc($_GET['edit']));
$res = mysql_fetch_array($sql);
$HTMLOUT .="















";
echo $HTMLOUT;
die;
}

// Staff shout edit
if (isset($_POST['text']) && $CURUSER['class'] >= UC_STAFF && is_valid_id($_POST['id']))
{
require_once(INCL_DIR.'bbcode_functions.php');
$text = trim($_POST['text']);
$text_parsed = format_comment($text);
sql_query('UPDATE shoutbox SET text = '.sqlesc($text).', text_parsed = '.sqlesc($text_parsed).' WHERE id='.sqlesc($_POST['id']));
unset($text, $text_parsed);
}
// Power User+ shout edit //==pdq
if (isset($_POST['text']) && (isset($_POST['user']) == $CURUSER['id']) && ($CURUSER['class'] >= UC_POWER_USER && $CURUSER['class'] < UC_STAFF) && is_valid_id($_POST['id']))
{
require_once(INCL_DIR.'bbcode_functions.php');
$text = trim($_POST['text']);
$text_parsed = format_comment($text);
sql_query('UPDATE shoutbox SET text = '.sqlesc($text).', text_parsed = '.sqlesc($text_parsed).' WHERE userid='.sqlesc($_POST['user']).' AND id='.sqlesc($_POST['id']));
unset($text, $text_parsed);
}

//== begin main output
$HTMLOUT .="


ShoutBox



";
//==Background colours begin
//== White
if ( $CURUSER['shoutboxbg'] == 1 ) {
$HTMLOUT .="";
$bg = '#ffffff';
$fontcolor = '#000000';
$dtcolor = '#356AA0';
}
// == Grey
if ( $CURUSER['shoutboxbg'] == 2 ) {
$HTMLOUT .="";
$bg = '#777777';
$fontcolor = '#000000';
$dtcolor = '#FFFFFF';
}
// == Black
if ( $CURUSER['shoutboxbg'] == 3 ) {
$HTMLOUT .="";
$bg = '#1f1f1f';
$fontcolor = '#FFFFFF';
$dtcolor = '#FFFFFF';
}
$HTMLOUT .="";
//== Banned from shout ??
if ($CURUSER['chatpost'] == 0|| $CURUSER['chatpost'] > 1)
{
$HTMLOUT .="
Sorry, you are not authorized to Shout.  (Contact Site Admin For The Reason Why)
";
echo $HTMLOUT;
exit;
}
//=End
if ( isset( $_GET['sent'] ) && ( $_GET['sent'] == "yes" ) ) {
    require_once(INCL_DIR.'bbcode_functions.php');
    $limit = 5;
    $userid = $CURUSER["id"];
    $date = TIME_NOW;
    $text = (trim( $_GET["shbox_text"] ));
    $text_parsed = format_comment($text);
        $system_pattern = '/(^\/system)\s([\w\W\s]+)/is';
    if(preg_match($system_pattern,$text,$out) && $CURUSER["class"] >= UC_STAFF)
    {
        $userid = $INSTALLER09['bot_id'];
        $text = $out[2];
        $text_parsed = format_comment($text);
    }
    // ///////////////////////shoutbox command system by putyn /////////////////////////////
    $commands = array( "\/EMPTY", "\/GAG", "\/UNGAG", "\/WARN", "\/UNWARN", "\/DISABLE", "\/ENABLE" ); // this / was replaced with \/ to work with the regex
    $pattern = "/(" . implode( "|", $commands ) . "\w+)\s([a-zA-Z0-9_:\s(?i)]+)/";
      //== private mode by putyn
      $private_pattern = "/(^\/private)\s([a-zA-Z0-9]+)\s([\w\W\s]+)/";
    if (preg_match( $pattern, $text, $vars ) && $CURUSER["class"] >= UC_STAFF) {
        $command = $vars[1];
        $user = $vars[2];
        $c = sql_query( "SELECT id, class, modcomment FROM users where username=" . sqlesc( $user ) ) or sqlerr();
        $a = mysql_fetch_row( $c );
        if ( mysql_num_rows( $c ) == 1 && $CURUSER["class"] > $a[1] ) {
            switch ( $command ) {
                case "/EMPTY" :
                    $what = 'deleted all shouts';
                    $msg = "" . $user . "'s shouts have been deleted";
                    $query = "DELETE FROM shoutbox where userid = " . $a[0];
                    break;
                case "/GAG" :
                    $what = 'gagged';
                    $modcomment = get_date( TIME_NOW, 'DATE', 1 ) . " - [ShoutBox] User has been gagged by " . $CURUSER["username"] . "\n" . $a[2];
                    $msg = "" . $user . " - has been gagged by " . $CURUSER["username"];
                    $query = "UPDATE users SET chatpost='0', modcomment = concat(" . sqlesc( $modcomment ) . ", modcomment) WHERE id = " . $a[0];
                    $mc1->delete_value('MyUser_'.$user);
                    $mc1->delete_value('user'.$user);
                    break;
                case "/UNGAG" :
                    $what = 'ungagged';
                    $modcomment = get_date( TIME_NOW, 'DATE', 1 ) . " - [ShoutBox] User has been ungagged by " . $CURUSER["username"] . "\n" . $a[2];
                    $msg = "" . $user . " - has been ungagged by " . $CURUSER["username"];
                    $query = "UPDATE users SET chatpost='1', modcomment = concat(" . sqlesc( $modcomment ) . ", modcomment) WHERE id = " . $a[0];
                    $mc1->delete_value('MyUser_'.$user);
                    $mc1->delete_value('user'.$user);
                    break;
                case "/WARN" :
                    $what = 'warned';
                    $modcomment = get_date( TIME_NOW, 'DATE', 1 ) . " - [ShoutBox] User has been warned by " . $CURUSER["username"] . "\n" . $a[2];
                    $msg = "" . $user . " - has been warned by " . $CURUSER["username"];
                    $query = "UPDATE users SET warned='1', modcomment = concat(" . sqlesc( $modcomment ) . ", modcomment) WHERE id = " . $a[0];
                    $mc1->delete_value('MyUser_'.$user);
                    $mc1->delete_value('user'.$user);
                    break;
                case "/UNWARN" :
                    $what = 'unwarned';
                    $modcomment = get_date( TIME_NOW, 'DATE', 1 ) . " - [ShoutBox] User has been unwarned by " . $CURUSER["username"] . "\n" . $a[2];
                    $msg = "" . $user . " - warning removed by " . $CURUSER["username"];
                    $query = "UPDATE users SET warned='0', modcomment = concat(" . sqlesc( $modcomment ) . ", modcomment) WHERE id = " . $a[0];
                    $mc1->delete_value('MyUser_'.$user);
                    $mc1->delete_value('user'.$user);
                    break;
                case "/DISABLE" :
                    $what = 'disabled';
                    $modcomment = get_date( TIME_NOW, 'DATE', 1 ) . " - [ShoutBox] User has been disabled by " . $CURUSER["username"] . "\n" . $a[2];
                    $msg = "" . $user . " - has been disabled by " . $CURUSER["username"];
                    $query = "UPDATE users SET enabled='no', modcomment = concat(" . sqlesc( $modcomment ) . ", modcomment) WHERE id = " . $a[0];
                    $mc1->delete_value('MyUser_'.$user);
                    $mc1->delete_value('user'.$user);
                    break;
                case "/ENABLE" :
                    $what = 'enabled';
                    $modcomment = get_date( TIME_NOW, 'DATE', 1 ) . " - [ShoutBox] User has been enabled by " . $CURUSER["username"] . "\n" . $a[2];
                    $msg = "" . $user . " - has been enabled by " . $CURUSER["username"];
                    $query = "UPDATE users SET enabled='yes', modcomment = concat(" . sqlesc( $modcomment ) . ", modcomment) WHERE id = " . $a[0];
                    $mc1->delete_value('MyUser_'.$user);
                    $mc1->delete_value('user'.$user);
                    break;
            }
            if ( sql_query( $query ) )
                autoshout($msg);
            $HTMLOUT .="";
            write_log("Shoutbox user " . $user . " has been " . $what . " by " . $CURUSER["username"] );
            unset($text, $text_parsed, $query, $date, $modcomment, $what, $msg, $commands);
        }
    }
      elseif(preg_match($private_pattern,$text,$vars)) {
        $to_user = mysql_result(sql_query('SELECT id FROM users WHERE username = '.sqlesc($vars[2])),0) or exit(mysql_error());
        if($to_user != 0 && $to_user != $CURUSER['id']) {
            $text = $vars[2]." - ".$vars[3];
            $text_parsed = format_comment($text);
            sql_query( "INSERT INTO shoutbox (userid, date, text, text_parsed,to_user) VALUES (".sqlesc($userid).", $date, " . sqlesc( $text ) . ",".sqlesc( $text_parsed) .",".sqlesc($to_user).")") or sqlerr( __FILE__, __LINE__ );
        }       
        $HTMLOUT .="";
    } else {
        $a = mysql_fetch_row( sql_query( "SELECT userid,date FROM shoutbox ORDER by id DESC LIMIT 1 " ) ) or print( "First shout or an error :)" );
        if ( empty( $text ) || strlen( $text ) == 1 )
            $HTMLOUT .="Shout can't be empty";
        elseif ( $a[0] == $userid && ( TIME_NOW - $a[1] ) < $limit && $CURUSER['class'] < UC_STAFF )
            $HTMLOUT .="$limit seconds between shouts Seconds Remaining : (" . ( $limit - ( TIME_NOW - $a[1] ) ) . ")";
        else {
            sql_query( "INSERT INTO shoutbox (id, userid, date, text, text_parsed) VALUES ('id'," . sqlesc( $userid ) . ", $date, " . sqlesc( $text ) . ",".sqlesc( $text_parsed ) .")" ) or sqlerr( __FILE__, __LINE__ );
            $HTMLOUT .="";
            $trigger_words = array('doing your mom'=>array('im doing your mom too','yeah you\'d wish :P'),
            'good morning'=>array('what morning ? its still night!','Go back to sleep! '.$CURUSER['username'],'Quiet there are still people who sleep'),
            'good night'=>array('Night, what is that ?!'),
            'help me'=>array('Help with what?','If it is real important you can hit up the FLS on staff page..','Cant help you if you dont say what you need help for..','Somebody help that guy!! Im to busy atm.. Got a hot girl over.. :P'),
            //'Mindless'=>array('He aint here','If it is a problem then i know absolutely nothing.','Is currently smoking some nasty weed through a bhong..','Leave a message after the tone, im to busy atm.. Got a spliff on the go man.. :P'),
            'im back'=>array('You were gone ?','Who are you anyway ?','Welcome home :-P'),
            //'fuck'=>array('Potty mouthed git lol','Wash yer mouth out wi soap','Does your mother know you swear so much'),
            ':finger:'=>array(':finger:')
            );
          if(preg_match('/('.join('|',array_keys($trigger_words)).')/iU',$text,$trigger_key) && isset($trigger_words[$trigger_key[0]])) {
            shuffle($trigger_words[$trigger_key[0]]);
            $message = $trigger_words[$trigger_key[0]][0];
            sleep(1);
            autoshout($message);
          }
        }
    }
}
// //////////////////////
$res = sql_query( "SELECT s.id, s.userid, s.date, s.text, s.to_user, u.username, u.avatar, u.pirate, u.king, u.class, u.donor, u.warned, u.leechwarn, u.enabled, u.chatpost, (SELECT count(id) FROM messages WHERE receiver = ".$CURUSER['id']." AND unread = 'yes' AND location = '1') as pms FROM shoutbox as s LEFT JOIN users as u ON s.userid=u.id ORDER BY s.date DESC LIMIT 30" ) or sqlerr( __FILE__, __LINE__ );

if ( mysql_num_rows( $res ) == 0 )
    $HTMLOUT .="No shouts here";
else {
  $HTMLOUT .="\n";
        $gotpm = 0;
    while ( $arr = mysql_fetch_assoc( $res ) ){
        /*
        if($arr['pms'] > 0 && $gotpm == 0){
      $HTMLOUT .= '';
      $gotpm++;
      } */
     
    # BamBam0077 - New Shoutbox Mod ;) - 2014
    if ($arr["avatar"]) {
    $avatar['shoutbox'] = "
";
    } else {
    $avatar['shoutbox'] = "
";
    }     
   
    if(($arr['to_user'] != $CURUSER['id'] && $arr['to_user'] != 0) && $arr['userid'] != $CURUSER['id'])
        continue;
    elseif($arr['to_user'] == $CURUSER['id'] || ($arr['userid'] == $CURUSER['id'] && $arr['to_user'] !=0) )
        $private = ":private_reply('".$arr['username']."')\">\"Private";
    else
        $private = '';
        $edit = ($CURUSER['class'] >= UC_STAFF || ($arr['userid'] == $CURUSER['id']) && ($CURUSER['class'] >= UC_POWER_USER && $CURUSER['class'] <= UC_STAFF) ? "\"Edit " : "" );
        $del = ( $CURUSER['class'] >= UC_STAFF ? "\"Delete " : "" );
        //$delall = ( $CURUSER['class'] >= UC_SYSOP ? "\"Empty " : "" );     
        //$delall
        $pm = "\"Pm\n";
        $date = get_date($arr["date"], 0,1);
        $reply = "\",\"shbox\",\"shbox_text\")'>Reply";
        $user_stuff = $arr;
        $user_stuff['id'] = $arr['userid'];

    if ($arr["avatar"]) {
      $HTMLOUT .="
";
    } else {
      $HTMLOUT .="
";
    }
 }
    $HTMLOUT .="
You have '.$arr['pms'].' new message'.($arr['pms'] > 1 ? 's' : '').'
\n{$avatar['shoutbox']}
$date
\n
$reply $edit $delete $pm $private
".format_username($user_stuff, true)."
\n
".get_user_class_name($arr['class'])."
" . format_comment( $arr["text"] ) . "\n
\n{$avatar['shoutbox']}
$date
\n
  $reply $edit $delete $pm $private
".format_username($user_stuff, true)."
\n
".get_user_class_name($arr['class'])."
" . format_comment( $arr["text"] ) . "\n
";   
}
$HTMLOUT .="";
echo $HTMLOUT;
?>

Bump: Above is for v2 :drink:

also new screenshot:


http://www.bvlist.com/data:image/png...BJRU5ErkJggg==

Bump: http://mystical.pw/bitbucket/BamBam_Capture.PNG


All times are GMT +2. The time now is 15:22.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.