vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   <if> conditional (https://vborg.vbsupport.ru/showthread.php?t=141689)

bigdog829 03-10-2007 10:32 PM

<if> conditional
 
Is there a way I could write an <if> conditional that I could include multiple i.p. addys instead of say a certain usergroup.

TECK 03-10-2007 11:46 PM

I don't understand nothing from your request.
A code example will help us to understand what exacly you are trying to achieve.

Post one and I will help you. :)

HMBeaty 03-10-2007 11:49 PM

I would assume bigdog829 is looking for something like this:
HTML Code:

<if condition="is_member_of($bbuserinfo, 5,6,7)">

</if>

but instead of using $bbuserinfo, 5,6,7.........use an IP address.

Correct me if I am wrong

bigdog829 03-10-2007 11:57 PM

Quote:

Originally Posted by Redlinemotorsports (Post 1200538)
I would assume bigdog829 is looking for something like this:
HTML Code:

<if condition="is_member_of($bbuserinfo, 5,6,7)">

</if>

but instead of using $bbuserinfo, 5,6,7.........use an IP address.

Correct me if I am wrong

Exactly what Im loking for sorry if I didnt explain it well enough !

Thanks

TECK 03-11-2007 01:52 AM

If it's what Redlinemotorsports said, this is very easy.

Use this function:
PHP Code:

/**
* Checks to see if the IP address of the visiting user is allowed and defines a conditional
*
* @param    string    String of allowed IP's
*/
function check_allowed_ip($iplist '')
{
    global 
$show;

    if (empty(
$iplist))
    {
        return;
    }

    
$show['allowedip'] = false;
    
$user_ipaddress IPADDRESS '.';
    
$addresses preg_split('#\s+#'$iplist, -1PREG_SPLIT_NO_EMPTY);
    foreach (
$addresses AS $allowed_ip)
    {
        if (
strpos($allowed_ip'*') === false AND $allowed_ip{strlen($allowed_ip) - 1} != '.')
        {
            
$allowed_ip .= '.';
        }

        
$allowed_ip_regex str_replace('\*''(.*)'preg_quote($allowed_ip'#'));
        if (
preg_match('#^' $allowed_ip_regex '#U'$user_ipaddress))
        {
            
$show['allowedip'] = true;
        }
    }


Function Usage
PHP Code:

// separate allowed IP's by a space, you could define a vB option for that
$allowediplist '127.0.0.* 127.1.1.53';
check_allowed_ip($allowediplist); 

In your template, all you have to do is add this condition:
Code:

<if condition="$show['allowedip']">
... do your stuff for allowed users only ...
</if>

In other words, users who have an IP starting with 127.0.0.* or users with the exact IP 127.1.1.53 will be able to see your stuff.
Hope that helps.

BTW, this was not tested, it was done off my mind.

bigdog829 03-11-2007 02:19 AM

Im not looking to allow certain ip's I actually want to redirect certain ones I figured a if conditional with a simple html redirect would do the trick.

TECK 03-11-2007 08:37 AM

Aha, so why you did not post this from the beginning then?
From your post:
Exactly what Im loking for sorry if I didnt explain it well enough !

If you found a solution, you should post it here, so others can benefit from your experience.
That what is all about at vb.org, sharing knowledge with other hackers.

bigdog829 03-11-2007 05:06 PM

Quote:

Originally Posted by TECK (Post 1200699)
Aha, so why you did not post this from the beginning then?
From your post:
Exactly what Im loking for sorry if I didnt explain it well enough !

If you found a solution, you should post it here, so others can benefit from your experience.
That what is all about at vb.org, sharing knowledge with other hackers.

I didnt find a solution yet & I deff would post it here if I did.

JorgeX 03-11-2007 11:50 PM


TECK, it's offtopic but can u explain step by step your script? i'm learning php and i want to absorb knoledge :p

Gray Matter 03-12-2007 01:53 AM

Try:

Code:

<if condition="$bbuserinfo[ipaddress] == 'xxx.xxx.xxx.xxx'">

</if>



All times are GMT. The time now is 08:25 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01132 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_html_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete