View Single Post
durangod
Senior Member
Join Date: Mar 2016
Location: SW USA
Old 03-09-2016 , 00:18   Re: [RELEASE] SourceBans++ (v1.5.4.1) [Updated: 2016-03-01]
#600

Preface:

Ok this post will be kind of long and I wanted to contribute my part to this so as to help the dev a bit. I hope he adds my mod to the production version.

First let me say that I learned that you have to set up your main admin group for the primary admin for the web side of this before they will get an email on new requests. The php mail is inside and if statement that it will only execute if the permissions are set for the admin.

Once I set the permissions and added the admin to the group the email went out.


Also the only issue I am having now (if you want to even call it an issue) is that the section that does the updates is not connecting to get updates, it says failed. But that's ok I would rather download the updates anyway, but it would be nice to know if there was one available.


OK now for the MOD

Make sure you copy from the file and not from this post because I tried really hard to keep track of the changes as I went so I could just copy and paste but I found a few I missed and I don't know how because every time I made a change I put it on my notepad. Anyway the files should be perfectly accurate because that is what I am running.



What it does:

This mod to this plugin adds a youtube field at the end of the "report player" form so that someone can submit a link to their youtube video of the player they are reporting. It validates that url input as either:

Quote:

https://www.youtube.com/watch?v=zzzzzzzzz
https://youtu.be/zzzzzzzzz

as http or https and with or without the www
Then it includes the link on the email that the admin gets so they can click on the link from their email.

Basic MOD Code Addition:

I added a field to the sb_submission table called tube

Quote:
tube VARCHAR 70 None utf8_general_ci Null(yes)
I edited four files: 3 theme files and 1 process php file

Files edited:
(3) themes/<theme_name>/page_submitban.tpl
(1) pages/page.submit.php

I will attach one default theme file (as a sample - just repeat on other 2) and the page.submit.php file if it will let me do so below.

DONT FORGET TO LOG INTO ADMIN WHEN YOU ARE DONE AND REFRESH THE CACHE!


Detailed Code Changes:


themes/<theme_name>/page_submitban.tpl Do this 3x once for each theme

Code:
 
<!-- added for youtube url input -->
      <tr>
         <td width="20%">
          Youtube Link:
        </td>
         <td>
           <input name="youtube_link" type="text" size="40" maxlength="70" value="{$youtube_link}" class="textbox" style="width: 250px;" /> 
        </td>
      </tr>
<!-- end add youtube url input -->
pages/page.submit.php 1x

THESE CHANGES ARE IN DIFFERENT PLACES IN THE FILE - I HAVE POSTED THE CHANGES SEQUENTIAL TOP TO BOTTOM


PHP Code:
 
//added for youtube link
        
$Youtubelink "";
        
$youtubepre "";
        
$got_tubelink "";
//end youtube link add 
look for next part

PHP Code:
 
//added for youtube link
        
        
$youtubepre = (string) trim($_POST['youtube_link']);
        
$tubepattern "#(https?:\/\/).*?(?:youtu\.be\/|(?:www\.)?youtube\.com\/watch(?:\.php)?\?.*v=)([a-zA-Z0-9\-_]+)#";
        
$Youtubelink preg_match$tubepattern$youtubepre$matches);
//end youtube link add 
look for next part


PHP Code:

//added for youtube link
           
if(!empty($youtubepre) )
           {
             if(!
$Youtubelink)  // will be 0 or 1
             
{
             
               
$errors .= '* The youtube link is not a valid youtube url.<br>';
        
$validsubmit false;
              }else{
                     
$got_tubelink $matches[0];
                    }
//close else if youtubelink
           
}//close if !empty
//end added for youtube link 
look for next part

PHP Code:
 
 
//added tube to the end 
//and added another ? to the end for tube value
   
$pre $GLOBALS['db']->Prepare("INSERT INTO ".DB_PREFIX."_submissions(submitted,SteamId,name,email,ModID,reason,ip,subname,sip,archiv,server,tube) 
VALUES (UNIX_TIMESTAMP(),?,?,?,?,?,?,?,?,0,?,?)"
);
   
$GLOBALS['db']->Execute($pre,array($SteamID,$PlayerName,$Email,$modid[0],$BanReason$_SERVER['REMOTE_ADDR'], $SubmitterName$BanIP$SID$got_tubelink)); 
look for next part

PHP Code:
 
 
//added reinit for var
   
if(!empty($_FILES['demo_file']['name']))
    
$GLOBALS['db']->Execute("INSERT INTO ".DB_PREFIX."_demos(demid,demtype,filename,origname) VALUES (?, 'S', ?, ?)", array($subid$filename$_FILES['demo_file']['name']));
   
$SteamID "";
   
$BanIP "";
   
$PlayerName "";
   
$BanReason "";
   
$SubmitterName "";
   
$Email "";
   
$SID = -1;
   
$Youtubelink ""
look for next part


PHP Code:
                        
 
//added youtube link
    
$message .= "Player: ".$_POST['PlayerName']." (".$_POST['SteamID'].")\nDemo: ".(empty($_FILES['demo_file']['name'])?'no':'yes (http://' $_SERVER['HTTP_HOST'] . $requri 'getdemo.php?type=S&id='.$subid.')')."\n".$mailserver."Reason: ".$_POST['BanReason']."\n\n"."Youtube Link:".$got_tubelink."\n\n"
go to bottom of file to see the next part

PHP Code:
 
//added for youtube link
$theme->assign('youtube_link',  $got_tubelink);
//end added for youtube link 
Now run the sql to add the new field to the table or you can do it manually if you wish

Code:
 
either 
 
tube   VARCHAR  70  None utf8_general_ci  Null (yes)
 
or
 
ALTER TABLE  `sb_submissions` ADD  `tube` VARCHAR( 70 ) CHARACTER SET 
utf8 COLLATE utf8_general_ci  NULL
DONE GREAT JOB!!!

Refresh your cache from admin and your good to go.. enjoy!


Files included:

youtubemod.zip

which includes:
page_submitban.tpl Template file
page.submit.php Process file

Thanks, Dev hope this helps you and everyone
Attached Files
File Type: zip youtubemod.zip (5.1 KB, 95 views)
__________________
Freedom is never free!

Last edited by durangod; 02-09-2017 at 12:59. Reason: fixed sql to null instead of not null
durangod is offline