Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all 685 articles
Browse latest View live

Complete Guide to the ICQ Field Replacement

$
0
0
***MyBB does not endorse or approve anything done below. Proceed at your own risk.***

This guide elaborates on information given in this thread:
https://community.mybb.com/thread-134852.html
Read that before attempting anything done below.

Say you want to change the ICQ field on your "Additional Contact Information" page to a Discord field, for instance.  You've changed the other contact fields to newfangled social media platforms like Facebook and Twitter, so of course this one should work the same way, right?

Alright, so you change the language files like normal, but this time you get an error.  You're perplexed!  Well, the reason that happens is because MyBB has a nice little integer check in a few places for the ICQ value.  Here's how to disable that check.

Notes:
- This tutorial involves editing the MySQL database through phpMyAdmin. If this daunts you, maybe don't do the things listed here or ask a friend for help.
- This is only tested in MyBB 1.8.13.
- I don't take responsibility for any damage you cause with this code to your files or forum.

Files modified:
- usercp.php
- /inc/datahandlers/user.php

1. BACKUP BOTH THE FILES LISTED ABOVE, AND YOUR DATABASE.

2. Open usercp.php and make these changes:

- Replace this:
PHP Code:
    foreach(array('icq''aim''yahoo''skype''google') as $cfield)
    {
        
$csetting 'allow'.$cfield.'field';
        if(
$mybb->settings[$csetting] == '')
        {
            continue;
        }

        if(!
is_member($mybb->settings[$csetting]))
        {
            continue;
        }

        if(
$cfield == 'icq')
        {
            
$user[$cfield] = $mybb->get_input($cfield1);
        }
        else
        {
            
$user[$cfield] = $mybb->get_input($cfield);
        }
    } 
with this:
PHP Code:
    foreach(array('icq''aim''yahoo''skype''google') as $cfield)
    {
        
$csetting 'allow'.$cfield.'field';
        if(
$mybb->settings[$csetting] == '')
        {
            continue;
        }

        if(!
is_member($mybb->settings[$csetting]))
        {
            continue;
        }
        
        
$user[$cfield] = $mybb->get_input($cfield);
    } 

- Replace this:
PHP Code:
    if($user['icq'] != "0")
    {
        
$user['icq'] = (int)$user['icq'];
    }

    if(
$user['icq'] == 0)
    {
        
$user['icq'] = '';
    }

    if(
$errors)
    {
        
$user['skype'] = htmlspecialchars_uni($user['skype']);
        
$user['google'] = htmlspecialchars_uni($user['google']);
        
$user['aim'] = htmlspecialchars_uni($user['aim']);
        
$user['yahoo'] = htmlspecialchars_uni($user['yahoo']);
    } 
with this:
PHP Code:
    if($errors)
    {
        
$user['icq'] = htmlspecialchars_uni($user['icq']);
        
$user['skype'] = htmlspecialchars_uni($user['skype']);
        
$user['google'] = htmlspecialchars_uni($user['google']);
        
$user['aim'] = htmlspecialchars_uni($user['aim']);
        
$user['yahoo'] = htmlspecialchars_uni($user['yahoo']);
    } 

3. Open inc/datahandlers/user.php and make these changes:

- Find and delete this:
PHP Code:
        if($this->method == "insert" || array_key_exists('icq'$user))
        {
            
$this->verify_icq();
        } 

- Replace this:
PHP Code:
            "website" => $db->escape_string($user['website']),
            
"icq" => (int)$user['icq'],
            
"aim" => $db->escape_string($user['aim']),
            
"yahoo" => $db->escape_string($user['yahoo']),
            
"skype" => $db->escape_string($user['skype']),
            
"google" => $db->escape_string($user['google']), 
with:
PHP Code:
            "website" => $db->escape_string($user['website']),
            
"icq" => $db->escape_string($user['icq']),
            
"aim" => $db->escape_string($user['aim']),
            
"yahoo" => $db->escape_string($user['yahoo']),
            
"skype" => $db->escape_string($user['skype']),
            
"google" => $db->escape_string($user['google']), 

- Replace this:
PHP Code:
        if(isset($user['icq']))
        {
            
$this->user_update_data['icq'] = (int)$user['icq'];
        } 
with this:
PHP Code:
        if(isset($user['icq']))
        {
            
$this->user_update_data['icq'] = $db->escape_string($user['icq']);
        } 


3. Save and quit, re-upload the files back to your server.

4. Open your MySQL database and go to the table titled "yourtableprefix_users".

5. Click the Structure tab and find the ICQ row (it should be #21).

6. Click the change button found in the ICQ row.

7. Change the value of "Length/Values" to your desired maximum character limit for the new type of field and click "Save."

8. OPTIONAL: MyBB saves a default value of 0 for the icq column. Click the SQL tab and enter this to clear all of the zeros:

Code:
UPDATE `yourtableprefix_users`
SET `icq` = ''
WHERE `icq` = '0';

That's it! Any questions can be put below.

@Staff: I'm not sure if anything here was against the rules. If it was, feel free to edit it out or delete the thread entirely.

Add User ID on Postbit

$
0
0
Please go to the directory: 
Admin CP -> Templates -> Postbit Templates -> postbit_author_user

Add the following codes;
Code:
<br />
ID: {$post['uid']}

Goodbye.

Plasma Television Style for Videos

$
0
0
Hi everyone,

Preview:
[Image: vpknzm.png]

Guide:

MyBB Admin CP -> Themes & Templates -> Your Theme ->
Add to Global.CSS:
Code:
.plazma_up {
 background: url("images/top.png");
 width: 587px;
 height: 26px;
}

.plazma_down {
 float: left;
 background: url("images/bottom.png");
 width: 534px;
 height: 73px;
 margin-top: -29px;
 margin-left: 26px;
}

.plazma_left {
 float: left;
 background: url("images/left.png");
 width: 26px;
 height: 330px;
}

.plazma_right {
float: left;
 background: url("images/right.png");
 width: 26px;
 height: 330px;
}

MyBB Admin CP -> Themes & Templates -> Your Theme Templates -> Find the template: Video MyCode Templates -> video_youtube_enbed

Replace All:
Code:
<div style="width: 600px; height=400px;"><div class="plazma_up"></div><div class="plazma_left"></div><div class="float_left"><iframe width="534" height="301" src="//www.youtube.com/embed/{$id}" frameborder="0" allowfullscreen></iframe></div><div class="plazma_right"></div><div class="plazma_down"></div></div><div style="margin-top: 400px"></div> 

Goodbye.

.zip   FTP-UPLOAD.zip (Size: 13.42 KB / Downloads: 1)

Spider traffic calming through Apaches .htaccess

$
0
0
Internet spiders are increasing in number constantly.  Some are written well and follow the guidelines for robots.txt or use included Meta tags to work out what they are (and aren't) allowed to spider.  There are however some that seem to negate any of those controls or rules and just go for all out scraping which can
create a number of problems from DDoS effects to reducing your sites capacity to be viewed by humans.

While there are things you can do within the forum software to help alleviate the problems (To my knowledge, Clients identified as spiders will be dropped when there is high traffic before humans users start suffering from 503 errors)

This thread/post covers a far more simplified approach to aid in calming the traffic for any spiders you deem rogue through the use of APACHE .htaccess (so it should work with most environments using an APACHE webserver tested on >v2.4)

There are some pre-requisites you need to know:
  • Which spiders do you want to traffic calm?
  • When is the the lowest traffic time period?

Which spiders do you want to traffic calm?
PHP Code:
<IfModule mod_setenvif.c>
 
   SetEnvIfNoCase User-Agent (roguebot1|roguebot2){1throttlebot=1
</IfModule

In this piece that can be placed into the .htaccess file, I use the SetEnvIf module to identify which User-Agent strings need to be traffic calmed.  

It's Either roguebot1 or roguebot2.  If you wanted to add another option for a roguebot3, just make sure you add a '|' pipe character after roguebot2 and insert roguebot3 there.
(You only need the bot name before the / and version number, so Googlebot/2.0 would just be Googlebot )

The {1} matches the first instance of the mentioned spidername (just in case the user-agent string contains multiple matches)

throttlebot=1 is how a Server Environment is set as throttlebot with a value of "1".  This environment is actually what Identifies what needs throttling.  So you could use other methods of setting the server environment which I'm not going to detail here.

When is the the lowest traffic time period?
In my example I have low traffic between 09:00-11:59 and 13:00-15:59 Server time.  So the intention here is to intermittently limit access for traffic calming outside of these times.   I don't want to block spiders in this instance as that can have repercussions later in both SEO ranking and of course server stability should the spider have a chance to catch up on indexing.

This uses mod_rewrite

PHP Code:
<IfModule mod_rewrite.c>
 
   # Initialise the Rewrite Engine if not already Initialised
 
   RewriteEngine on
    RewriteBase 
/

 
   #If its between the hours of 0 to 8, 12, or 16 to 23
 
   # set an environment of trafficcalm
 
   RewriteCond %{TIME_HOUR} >00
    RewriteCond 
%{TIME_HOUR} <08 
 
   RewriteRule ^ - [E=trafficcalm:1]

 
    RewriteCond %{TIME_HOUR} =12 
     RewriteRule 
^ - [E=trafficcalm:1]

 
    RewriteCond %{TIME_HOUR} >16
     RewriteCond 
%{TIME_HOUR} <23
     RewriteRule 
^ - [E=trafficcalm:1]
 
 
   # If trafficcalm and throttlebot are set and the request isn't for robots.txt
 
   # and it's between 10 and 50 seconds of the minute
 
   # Redirect to a 503 and set environment throttled else set environment normaltraffic
 
    RewriteCond %{ENV:trafficcalm1
     RewriteCond 
%{ENV:throttlebot1
     RewriteCond 
%{REQUEST_URI} !^\/robots\.txt$ [NC]
 
    RewriteCond %{TIME_SEC} >10
     RewriteCond 
%{TIME_SEC} <50
     RewriteRule 
^ - [E=throttled:1,R=503,L]
 
    RewriteRule ^ - [E=normaltraffic:1]
</
IfModule
You'll notice that in the last Rewrite block, there are two RewriteRule's  The first is what occurs when the time is greater than 10 but less than 50 seconds on the minute, the second occurs outside that range (0-9 and 51-59)

During the first rule a redirect to 503 Service Temporarily Unavailable will occur.  Spiders that are written correctly when not getting the code they want (301 etc) will usually attempt to get the URL again a little later.    

Now this .htaccess addition is great on it's own, however you can decrease the chance of spiders not being able to spider by making a couple of other additions.  

Adding the line of Crawl-Delay: 43 to your robots.txt file.
(The idea here is that if the intermittent block occurs for 40 seconds, you want the spider to try again a little bit later than 40 seconds from when it made it's current attempt.  This will make sure that it cycles being in and out of being retrievable.)

Create a Custom 503 page (503.php), something like:
PHP Code:
<?php
header
("HTTP/1.1 503 Service Temporarily Unavailable");
header("Status: 503 Service Temporarily Unavailable");
header("Retry-After: 43");
?>
<!DOCTYPE html>
<html>
<head>
<title>503 Service Temporarily Unavailable</title>
</head>
<body>
<h1>503 Service Temporarily Unavailable</h1>
<p>Don't threat, access should return shortly.  The server just needed a reprieve.</p>
</body>
</html> 

You'll notice the header of "Retry-After: 43" being used here to attempt to convey to spiders, how long to wait before retrying.  It's similar to the Crawl-Delay, but meant for spiders that ignore the robots.txt file completely.

And then just add to your .htaccess file the following to make sure it uses the custom script:
PHP Code:
ErrorDocument 503 503.php 
It assumes that the 503.php file is in your root folder.

So your .htaccess should look something like this (although you'll need to merge it with what you might already have in your .htaccess):
PHP Code:
ErrorDocument 503 503.php

<IfModule mod_setenvif.c>
 
   SetEnvIfNoCase User-Agent (roguebot1|roguebot2){1throttlebot=1
</IfModule

<
IfModule mod_rewrite.c>
 
   # Initialise the Rewrite Engine if not already Initialised
 
   RewriteEngine on
    RewriteBase 
/

 
   #If its between the hours of 0 to 8, 12, or 16 to 23
 
   # set an environment of trafficcalm
 
   RewriteCond %{TIME_HOUR} >00
    RewriteCond 
%{TIME_HOUR} <08 
 
   RewriteRule ^ - [E=trafficcalm:1]

 
    RewriteCond %{TIME_HOUR} =12 
     RewriteRule 
^ - [E=trafficcalm:1]

 
    RewriteCond %{TIME_HOUR} >16
     RewriteCond 
%{TIME_HOUR} <23
     RewriteRule 
^ - [E=trafficcalm:1]
 
 
   # If trafficcalm and throttlebot are set and the request isn't for robots.txt
 
   # and it's between 10 and 50 seconds of the minute
 
   # Redirect to a 503 and set environment throttled else set environment normaltraffic
 
    RewriteCond %{ENV:trafficcalm1
     RewriteCond 
%{ENV:throttlebot1
     RewriteCond 
%{REQUEST_URI} !^\/robots\.txt$ [NC]
 
    RewriteCond %{TIME_SEC} >10
     RewriteCond 
%{TIME_SEC} <50
     RewriteRule 
^ - [E=throttled:1,R=503,L]
 
    RewriteRule ^ - [E=normaltraffic:1]
</
IfModule


When this is used you will find that your server logs will start outputting 503 responses every so often to those roguebots you've listed reducing your overall server load hopefully increasing your sites accessibility and stability.

www.scivillage.com

Sticky Threads Fa Icon

$
0
0
If you're using thread icons as Fa icons and wondering how to set Important Threads with sticky fa icon like xenforo this is how you would want to do it.

Edit: Template Conditionals plugin needs to be installed for this.

Forumdisplay Template > Forumdisplay_Thread

Find:
Code:
<span class="{$folder}" title="{$folder_label}">&nbsp;</span>

Replace With:
Code:
<if $thread['sticky'] then>
<i class="fa fa-thumb-tack sticky-icon" aria-hidden="true"></i>
<else>
<span class="{$folder}" title="{$folder_label}">&nbsp;</span>
</if>

Now go to global.css and add
Code:
.sticky-icon {
    color: orange;
}

You're free to change the color to whatever you like.

Font Awesome - loading spinner

$
0
0
Do you wanna modern spinner and replace the old default one? There is a tutorial for Font Awesome spinner. All credits go to @Eric J. who help me a lot.

In your showthread_quickreply template (and anywhere else you might have a spinner), replace this:
Code:
<div id="quickreply_spinner" class="showthread_spinner" style="display: none"><img src="{$theme['imgdir']}/spinner.gif" /></div>

with this:
Code:
<div id="quickreply_spinner" class="showthread_spinner" style="display: none"><img src="{$theme['imgdir']}/spinner.gif" style="display: none;" /><i class="fa fa-spinner fa-spin"></i></div>


You'll also want to edit the variables in your headerinclude template for things like quickedit and multiquote, so change this:
Code:
var spinner = "<img src='" + spinner_image +"' alt='' />";

to this:
Code:
var spinner = "<img src='" + spinner_image +"' alt='' style='display: none' /><i class='fa fa-spinner fa-spin'></i>";


CSS part
Add into global.css this line of code (you can style this spinner)

Code:
#quickreply_spinner .fa {
font-size: 36px;
}

Save your changes, hard refresh your browser (Ctrl+F5) and try it, enjoy!

Eleven reasons your forum is destined to die.

$
0
0
Figured I'd share this here.

1) You're using a ripped theme.
If you want your forum to get anywhere, using a orange tier paki rip from a ripping community is not the way to go. 

2) You have no money.
Seriously, don't even try to start a forum if you're so broke that you can't even afford $5 a month to host your forum on a $5 a month digitalocean VPS. Nobody takes a forum seriously if the owner has no money.

3) You don't know basic web development.
The key to keeping your community happy is to keep providing them with what they want, you can't do this if you don't know basic stuff like html or css.

4) You use an overused niche.
You made a gaming forum? Wow, cool! So what makes yours better than the thousands that already exist?

5) You know nothing about your niche.
Not knowing a lot about your niche is like giving a seminar on a topic you don't know, it just isn't going to work.

6) Your site is literally just a copy of a bigger board.
Why would anyone want to join your forum, when they can get the "bigger and better" experience from elsewhere.

7) You have no content.
Don't even try to get people to start using your forum if you have no content.

8) Your forum engages in illegal activities, and you have no idea how to host it.
Have fun getting your site suspended :noh: 

9) You don't post.
You can't expect the members of your community to post if you don't post yourself.

10) The only places you advertise are "website showcase" categories on other forums.
If your userbase is literally just a small fragment of another forums members, they're going to slowly forget about you and return to the forum they came from.

11) You start the forum with the intent of making money.
Why the eggplant would you create a brand new community, and ask for donations/sell paid upgrades from the get go? Are you really that desperate for money? That you need your five members to empty their wallets into a community that likely won't be around long?
(courtesy of idkwhatimdoing)

If any of these eleven reasons sounds like you and/or your forum, you should probably delete or hand over to someone more competent.

How To Install MyBB With A Mobile iDevice

$
0
0
Hello MyBB!

Today I am going show you how to use your iPhone, iPad, and iPod Touch to install MyBB on a web server.

You Will Need:

  1. A Mobile iDevice.
  2. Google Drive. (Download from the app store.)
  3. A Copy of MyBB. (Save to the Google Drive app.)
  4. A Web Host.
This depends on your web host but should be pretty similar.
File uploading will depends on your IOS version too because apple changed it in IOS 11.

How To Install:

  1. Login to your web host.
  2. Go to your cPanel.
  3. Go to the online “File Manager” or use Net2FTP or TXFTP these are web based FTP clients just Google them.
  4. Go to “Upload“ in your file manager.
  5. Select MyBB from your Google Drive.
  6. In your FTP you should see a option to extract do that it might create it in a sub folder so just move it to your root.
  7. Now go to http://YourSite.com/install/ and follow the process.

If you guys want I can edit this post and add a lot more details I just made it pretty basic for the beginners and also some people are not a fan of reading long threads.

Anyway i hope you enjoyed this thread.

Add thread prefixes in portal latest threads

$
0
0

  1. Open portal.php
  2. Find 
    PHP Code:
    $query $db->query("
            SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username
            FROM "
    .TABLE_PREFIX."threads t
            LEFT JOIN "
    .TABLE_PREFIX."users u ON (u.uid=t.uid)
            WHERE 1=1 
    {$excludeforums}{$tunviewwhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
            ORDER BY t.lastpost DESC
            LIMIT 0, "
    .$mybb->settings['portal_showdiscussionsnum']
        ); 


  3. Replace with 
    PHP Code:
    $query $db->query("
            SELECT t.tid, t.fid, t.prefix, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username
            FROM "
    .TABLE_PREFIX."threads t
            LEFT JOIN "
    .TABLE_PREFIX."users u ON (u.uid=t.uid)
            WHERE 1=1 
    {$excludeforums}{$tunviewwhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
            ORDER BY t.lastpost DESC
            LIMIT 0, "
    .$mybb->settings['portal_showdiscussionsnum']
        ); 


  4. Above this
    PHP Code:
    $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject'])); 


  5. Add 
    PHP Code:
    $thread['threadprefix'] = $threadprefix '';

    if(
    $thread['prefix'] != 0)
    {
        
    $threadprefix build_prefixes($thread['prefix']);

        if(!empty(
    $threadprefix))
        {
            
    $thread['threadprefix'] = $threadprefix['displaystyle'].'&nbsp;';
        }



  6. In portal_latestthreads_thread template before 
    PHP Code:
    {$thread['subject']} 


  7. Add 
    PHP Code:
    {$thread['threadprefix']} 


  8. Profit.
[Image: HIEmwqb.png]


\/

[Image: tv6fPWa.png]

How to remove index.php from breadcrumbs

$
0
0
Hi,
Just a quick and simple trick if you want to remove index.php from your breadcrumbs homepage link.

1. Open global.php
2. Find 
PHP Code:
$navbits[0]['url'] = $mybb->settings['bburl'].'/index.php'

3. And just delete "index.php"
4. Refresh your forum page and annoying index.php in your homepage url is removed.
Good luck!

Responsive breadcrumb with arrows, css only.

$
0
0
Just made a responsive breadcrumb to work with mybb, beware I'm a casual programmer and I may have left some mistakes. To get this to work I mixed up two breadcrumbs

The one using bootstrap & being responsive:
https://bootsnipp.com/snippets/featured/...readcrumbs

And the one using pure css (but not responsive):
https://codepen.io/arkev/pen/DzCKF

The final result is a pure css breadcrumb without bootstrap.
So now that I've credited everyone Wink  let's start  !

Go to mybb template
In global.css of your theme , find & replace breadcrumb css with this : 
Code:
/** Breadcrumb **/

.breadcrumb {
/*centering*/
  text-align:center;
display: inline-block;
overflow: hidden;
  width:100%;
}

.breadcrumb a {
  text-overflow: ellipsis;
  min-width:5%;
  max-width:10%;
text-decoration: none;
display: inline-block;
  overflow: hidden;
  white-space: nowrap;
float: left;
font-size: 12px;
line-height: 36px;
padding-left:30px;
  padding-right:10px;
background: white;
color: #383838;
position: relative;
  transition: all 0.3s;
}


.breadcrumb a:first-child {
  text-overflow: none;
  min-width:15px;
padding-left: 20px;
border-radius: 5px 0 0 5px; /*to match with the parent's radius*/
}

.breadcrumb a:nth-last-child(-n+2){
border-radius: 0 5px 5px 0; /*this was to prevent glitches on hover*/
padding-right: 20px;
  max-width:100%;
  width:100%;
}

/*hover/active styles*/
.breadcrumb a.active, .breadcrumb a:hover{
  background: #dadada;
  color:black;
}

.breadcrumb a:hover + span{
  background: #dadada;
}

.breadcrumb span:last-child {
  display: none;
}

.breadcrumb a.active:after, .breadcrumb a:hover:after {
  background: #dadada;
}

/*adding the arrows for the breadcrumbs using rotated pseudo elements*/
.arrow {
display: inline-block;
float: left;
background: white;
color: #383838;
  position:relative;
top: 1px; 
right: 18px; /*half of square's length*/
/*same dimension as the line-height of .breadcrumb a */
height: 36px;
  width:36px;
transform: scale(0.707) rotate(45deg);
z-index: 1;
box-shadow: 
2px -2px 0 2px rgba(0, 0, 0, 0.4), 
3px -3px 0 2px rgba(255, 255, 255, 0.1);
border-radius: 0 2px 0 100px;
  transition: all 0.3s;
  background: white;
  margin-right:-36px;
}

.breadcrumb > * > a {
    /* With less: .text-overflow(); */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;    
}
#ptipoints{
  display:block;
  text-align:center;
  min-width:0px;
}

/* === For phones =================================== */
@media screen and (min-width:340px){
  #ptipoints{
    display:block;
  }
  #ptipoints + span{
     display:block;
  }
    .breadcrumb :nth-child(n+3){
      display:none;
    }
  .breadcrumb a:nth-last-child(-n+2){
     display:inline-block;
     max-width:40%;
width:auto;
    }
}

/* === For desktops ================================== */
@media screen and (min-width:670px){
    #ptipoints{
      display:none;
    }
    #ptipoints + span{
     display:none;
     }
    .breadcrumb :nth-child(n+2){
      display:inline-block;
    }
  .breadcrumb a:nth-last-child(-n+2){
      display:inline-block;
      max-width:40%;
  width:auto;
    }
  

}


/** END*/



In navigation template, replace "nav" with this :
Code:
<div class="breadcrumb">
{$nav}{$activesep}{$activebit}
</div>


replace "nav_bit" with this :
Code:
<a href="{$navbit['url']}">{$navbit['name']}</a>
<span class="arrow"></span>

In "nav_bit_active"

Code:
<a href="{$navbit['url']}">{$navbit['name']}</a>
<span class="arrow"></span>

You may want to change some things with the last element of the breadcrumb but I don't (+css is taking care of removing the last arrow so.. i use the same code as nav_bit, it's needed because I count child in css, without the last arrow counting fails.)
I do not use nav_sep & nav_dropdown but I'll look into it to check what funny things can be achieved with it !
If you have any suggestion of modifications or error corrections I'll be glad to read it !

convert pbboard 2 mybb

$
0
0
Convert pbboard forums manually
Because there is no script turned to mybb forums


تحويل منتديات pbboard يدويا
بسبب عدم وجود سكريبت تحول الى منتديات mybb

First Lesson






second lesson







third lesson






Lesson Four






The fifth lesson





How To Restrict Access To Any Page

$
0
0
Hello,

In this basic tutorial I will be showing you have to restrict access to any page on MyBB to certain user groups.

1. Go to your forums root and find the page / file you want to restrict.
2. Open it with NotePad++ or something like that.
3. Add this code to the file

PHP Code:
$allowed = array('4','3','6','12','13'); // The numbers are the usergroup IDs

if(!in_array($mybb->user['usergroup'], $allowed))
{
    
error('You are not allowed to access this page.''Page Name');


4. Change the numbers to the user group IDs that are allowed to access the page.
5. Change the error message and the page name.

That's it save the file and place it back into your forums root.

Tutorial - Add "Select All" to "Code: " and "PHP Code: "

$
0
0
In your language files find global.lang.php

Find:


PHP Code:
$l['code'] = "Code: ";
$l['php_code'] = "PHP Code: "

And replace with:

PHP Code:
$l['code'] = "Code:  <a href=# onclick=\"selectCode(this); return false;\">(Select All)</a>";
$l['php_code'] = "PHP Code:  <a href=# onclick=\"selectCode(this); return false;\">(Select All)</a>"

In your themes templates "headerinclude"  find:

PHP Code:
{$stylesheets


and after add:

PHP Code:
<!-- Select All in Code/PHP Code -->

<
script type="text/javascript">
function 
selectCode(a)
{
 
  var a.parentNode.parentNode.getElementsByTagName('CODE')[0];
 
  if (window.getSelection)
 
  {
 
     var s window.getSelection();
 
      if (s.setBaseAndExtent)
 
     {
 
        s.setBaseAndExtent(e0e.parentNode1);
 
     }
 
     else
      
{
 
        var document.createRange();
 
        r.selectNodeContents(e);
 
        s.removeAllRanges();
 
        s.addRange(r);
 
     }
 
  }
 
  else if (document.getSelection)
 
  {
 
     var s document.getSelection();
 
     var r document.createRange();
 
     r.selectNodeContents(e);
 
     s.removeAllRanges();
 
     s.addRange(r);
 
  }
 
  else if (document.selection)
 
  {
 
     var r document.body.createTextRange();
 
     r.moveToElementText(e);
 
     r.select();
 
  }
}
</
script

[Modification] How to show user avatar in the Who's Online?

$
0
0
Hi,
I hope the subject is in the right place.

How to show user avatar in the Who's Online.

View:

[Image: EkranResmi2018-04-0222.42.44.png]

[Image: EkranResmi2018-04-0223.04.13.png]

Open the FTP -> index.php:

Find the following code: (line 59)
PHP Code:
SELECT s.sids.ips.uids.times.locations.location1u.usernameu.invisibleu.usergroupu.displaygroup 

Change:
PHP Code:
SELECT s.sids.ips.uids.times.locations.location1u.usernameu.invisibleu.usergroupu.avataru.displaygroup 

And open the Admin KP -> Themes and Templates -> Templates -> Your Theme Templates -> Index Templates -> index_whosonline_memberbit

Open and replace all the codes with this one.

Code:
<div style="float: left">{$comma}<div style="margin-left: 5px"></div></div><div style="margin-top: 5px"><img src="{$user['avatar']}" width="20px" height="20px" style="float: left; margin-top: -4px; border-radius: 2px; border: 1px solid #ccc; margin-right: 3px"><div style="float: left; margin-top: -1px">{$user['profilelink']}{$invisiblemark}</div></div>

---

Open the FTP -> online.php:

Find this code: (Line 207)

PHP Code:
SELECT DISTINCT s.sids.ips.uids.times.locationu.usernames.nopermissionu.invisibleu.usergroupu.displaygroup 

Change:

PHP Code:
SELECT DISTINCT s.sids.ips.uids.times.locationu.usernames.nopermissionu.avataru.invisibleu.usergroupu.displaygroup 

Admin KP -> Temalar & Şablonlar -> Şablonlar -> Temanız Templates -> Kimler Çevrimiçi Şablonlar -> online_row

Replace all the codes with this one.

Code:
<tr>
<td class="trow1"><img src="{$user['avatar']}" width="38px" height="38px" style="float: left; margin-right: 5px; border-radius: 3px"/>{$online_name}{$user_ip}</td>
<td align="center" class="trow2">{$online_time}</td>
<td class="trow1" width="50%">{$location}</td>
</tr>

Good works!

Usergroup Page

$
0
0
Hello,

Before I start I want to say I did not create this I am just sharing it, the creator is Sazze. Well thats what he said but i'll take his word for it for now. LOL. Ever wanted to have a page to display your sites user groups without you adding them to the page by yourself? Well now you can! Once set up all you need to do is add the user group IDs and that's it. The page will display the group name, description of the group, group image, and how much members are in it. 

Step 1. Create a new file in your forums root called usergroups.php and paste this code into it :
Code:
<?php

define( 'IN_MYBB', TRUE );
define( 'NAME', basename( __FILE__ ) );
define( 'THIS_SCRIPT', NAME );
define( 'GUEST', 'Please login or register in order to see this page.' );
require_once __DIR__ . '/global.php';

add_breadcrumb( 'Usergroups', NAME );

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

$allowed_groups = array( 'x','x','x'); // Please group IDs here

if( !$mybb->input['request'] )
{
    foreach ( $allowed_groups as &$groupid )
    {
        $groupcache = $cache->read( 'usergroups' );

        $query = $db->write_query( "
            SELECT *
            FROM ".TABLE_PREFIX."usergroups
            WHERE `gid`='".(int)$groupid."'
            ORDER BY gid
        " );

        if( isset( $query->num_rows ) )
        {
            while( $groups = $db->fetch_array( $query ) )
            {
                /* Fetch group leaders */
                $leaders_array = array();
                $leader_query = $db->write_query("
                    SELECT u.username, u.uid, u.usergroup, u.displaygroup, l.gid
                    FROM ".TABLE_PREFIX."groupleaders l
                    INNER JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid)
                    WHERE `gid`='".(int)$groupid."'
                ");

                while( $leader = $db->fetch_array( $leader_query ) )
                {                    
                    $leaders = build_profile_link( format_name( $leader['username'], ( !empty( $leader['displaygroup'] ) ? $leader['displaygroup'] : $leader['usergroup'] ) ), $leader['uid'] );
                    array_push( $leaders_array, $leaders );
                }

                $usergroups['groupleaders'] = rtrim( implode( ', ', $leaders_array ), ', ' );

                if( !$usergroups['groupleaders'] )
                {
                    $usergroups['groupleaders'] = 'None';
                }

                $usergroups['groupname'] = htmlspecialchars_uni( $groupcache[$groups['gid']]['title'] );
                $usergroups['groupdesc'] = htmlspecialchars_uni( $groupcache[$groups['gid']]['description'] );
                $usergroups['userbar'] = '<img src="'.$groupcache[$groups['gid']]['image'].'" />';
                $usergroups['gid'] = intval( $groupcache[$groups['gid']]['gid'] );
                $usergroups['members'] = intval( countmembers( $groupid ) );

                eval( "\$groups_row .= \"".$templates->get( 'usergroups_row' )."\";" );
            }
        }
        else
        {
            $groups_row = '<td class="trow1" align="left">No usergroups was found.</td>';
        }
    }
}

eval( "\$usergroups_page = \"".$templates->get( 'usergroups' )."\";" );
output_page( $usergroups_page );


/* Count members function */
function countmembers( $groupid )
{
    global $db, $plugins;

    $query = $db->query("
        SELECT g.gid, COUNT(u.uid) AS users
        FROM ".TABLE_PREFIX."users u
        LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup)
        GROUP BY g.gid
    ");

    while( $groupcount = $db->fetch_array( $query ) )
    {
        $primaryusers[$groupcount['gid']] = $groupcount['users'];
    }

    switch( $db->type )
    {
        case "pgsql":
        case "sqlite":
            $query = $db->query("
                SELECT g.gid, COUNT(u.uid) AS users
                FROM ".TABLE_PREFIX."users u
                LEFT JOIN ".TABLE_PREFIX."usergroups g ON (','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%')
                WHERE g.gid != '0' AND g.gid is not NULL GROUP BY g.gid
            ");

        break;
        default:
            $query = $db->query("
                SELECT g.gid, COUNT(u.uid) AS users
                FROM ".TABLE_PREFIX."users u
                LEFT JOIN ".TABLE_PREFIX."usergroups g ON (CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%'))
                WHERE g.gid != '0' AND g.gid is not NULL GROUP BY g.gid
            ");
        }

        while( $groupcount = $db->fetch_array( $query ) )
        {
            $secondaryusers[$groupcount['gid']] = $groupcount['users'];
        }
                
        $numusers = $primaryusers[$groupid];
        $numusers += $secondaryusers[$groupid];
                
        if( !$numusers )
        {
            $numusers = "0";
        }

        return $numusers;
    }
?>

Now find $allowed_groups = array( 'x','x','x'); (Line 16) change the x to the user group ID you want to be displayed and remember you can add more if needed.

Step 2. Now go to

Admin CP -> Templates & Styles -> Templates -> Global Templates create a new template called usergroups and paste this code into it :
Code:
<html>
    <head>
        <title>
            {$mybb->settings['bbname']} - Usergroups
        </title>
        {$headerinclude}
    </head>
    <body>
        <style>
            .joingroup {
                color: #fff;
                text-shadow: none;
                padding: 5px 8px;
                border-radius: 2px;
                text-align: center;
                margin-left: 5px;
                background: rgba(0,0,0,0.2);
            }
            .joingroup:hover {
                cursor: pointer;
                background: rgb(167, 70, 70);
            }
        </style>
        {$header}
        <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
            <tr>
                <td class="thead" colspan="5"><strong>Usergroups</strong></td>
            </tr>
            <tr>
                <td class="trow1">{$groups_row}</td>
            </tr>
        </table>
        {$footer}
    </body>
</html>

Step 3. Now go back and create a new template called usergroups_row and paste this code into it :
Code:
<div style="width: 48%; min-height: 150px; float: left; border: 1px #333 solid; margin: 4px; padding: 2px;">
    <table width="100%" cellspacing="0" cellpadding="5" border="0">
        <tr>
            <td width="75%">
                <span style="color: #fff; font-size: 15px;">{$usergroups['groupname']}</span><br />
                </br>{$usergroups['groupdesc']}<br />
        Members: {$usergroups['members']}
        </td>
    <td width="25%" align="right" valign="top">
        {$usergroups['userbar']}
    </td>
    </tr>
</table>
</div>

Note: You might need to change the color to match with your theme to do this just find <span style="color: #fff; font-size: 15px;"> and change the #fff to the color code you want.

That's it your done now go to http://yoursite.com/usergroups.php and enjoy!

Screenshot:

[Image: Untitled.png]

Custom CSS For Mobile Devices

$
0
0
Themes » Default » Editing global.css

Replace

Code:
.wrapper {
    width: 85%;
    min-width: 970px;
    max-width: 1500px;
    margin: auto auto;
}

With

Code:
@media only screen and (max-width: 799px) {
   .wrapper {
       width: 100%;
       margin: auto auto;
   }
}

@media only screen and (min-width: 800px) {
   .wrapper {
       width: 600px;
       margin: auto auto;
   }
}

Add filtering by thread prefix in forumdisplay_thread

$
0
0
This is a simple tutorial how to add a support for easier filtering of threads by their thread prefixes. After this change prefixes will be changed to links. When you click to them, threads with the selected prefix will be displayed.

1) In ACP open and edit "forumdisplay_thread" template

2) Find and select this code:
PHP Code:
{$thread['threadprefix']} 

3) Replace the code above by this one:
PHP Code:
<a href="{$mybb->settings['bburl']}/forumdisplay.php?fid={$mybb->input['fid']}&prefix={$thread['prefix']}style="text-decoration: none !important;">{$thread['threadprefix']}</a

4) Save and reload your page (Ctrl+F5)
5) Click on any thread prefix and check the output Smile

Usergroup stars - FontAwesome

$
0
0
In this tutorial I will show you how you can easily replace img stars by FontAwesome icons. 

Note: FontAwesome library is needed. Compatible with FontAwesome 4.7, may require modification for upgraded versions of FontAwesome.

1) In ACP open "postbit_classic" template.
2) Find and select this code:
PHP Code:
{$post['userstars']} 
3) Replace the code above by this one and save.
PHP Code:
<span style="text-align: center;" class="userstar star_{$post['stars']}title="{$post['usertitle']}"></span
4) Open "memberlist_user" template.
5) Find and select this code:
PHP Code:
{$user['userstars']} 

6) Replace the code above by this one and save.
PHP Code:
<span style="text-align: center;" class="userstar star_{$user['stars']}title="{$user['usertitle']}"></span
7) Open "member_profile" template.
8) Find and select this code:
PHP Code:
{$userstars
9) Replace the code above by this one and save.
PHP Code:
<span style="text-align: center;" class="userstar star_{$stars}title="{$usertitle}"></span
10) Open "global.css" and add at the end this code:
PHP Code:
/** Usergroup star rating - FontAwesome **/
.userstar {
    
font-familyFontAwesome;
    
font-size13px;
    
color#969696;
    
line-height13px;
    
displayinline-block;
    
letter-spacing2px;
}
.
star_0 :before {
    
content"\f006\f006\f006\f006\f006\f006";
}
.
star_1 :before {
    
content"\f005\f006\f006\f006\f006\f006";
}
.
star_2 :before {
    
content"\f005\f005\f006\f006\f006\f006";
}
.
star_3 :before {
    
content"\f005\f005\f005\f006\f006\f006";
}
.
star_4 :before {
    
content"\f005\f005\f005\f005\f006\f006";
}
.
star_5 :before {
    
content"\f005\f005\f005\f005\f005\f006";
}
.
star_6 :before {
    
content"\f005\f005\f005\f005\f005\f005";

11) You can fully customise the output via this CSS. Letter "X" in .star_X represents the number of stars set in the usergroup settings. Save changes and go to User&Groups tab and continue to "Groups" settings in ACP.
12) Open any of you usergroup (for example "Administrators") and find "User Stars" settings. 
13) Here you can set any number - in our case 0-6 (you can add more, just edit your CSS code mentioned above). 
14) After that leave blank URL for User Star image on the right and save the changes.

Here you can see the output. 
[Image: 4iukH3s.png]

[Image: DgrLUWt.png]
You can change color, icons, size and whatever you need. 

Thank you @effone for your hints and support! Really appreciate it!

How to make your embedded videos responsive

$
0
0
In this little tutorial I'll show you how to make your embedded video ifames responsive.

I'll demonstrate it in case of YouTube videos...but it works on same way with all other video mycode templates.

Open the theme template "video_youtube_embed"
PHP Code:
<iframe width="560" height="315" src="//www.youtube.com/embed/{$id}frameborder="0" allowfullscreen></iframe

and replace the whole content with:
PHP Code:
<div class="resp_vid_cont">
 <
div class="resp_vid">
 <
iframe width="560" height="315" src="//www.youtube.com/embed/{$id}frameborder="0" allowfullscreen></iframe>
 </
div>
</
div

Save this themplate changes and open the theme CSS file "global.css" in advanced mode.

Include the following CSS rules into this global.css file:
Code:
.resp_vid_cont {
max-width: 560px;
height: auto;
overflow: hidden;
}

.resp_vid {
position: relative;
padding-bottom: 56.25%;
padding-top: 0px;
height: 0;
overflow: hidden;
}

.resp_vid iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

Save this file changes and you're done.
Viewing all 685 articles
Browse latest View live