Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-10-2007, 10:32 PM
bigdog829 bigdog829 is offline
 
Join Date: Apr 2005
Location: Michigan
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default <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.
Reply With Quote
  #2  
Old 03-10-2007, 11:46 PM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 03-10-2007, 11:49 PM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 03-10-2007, 11:57 PM
bigdog829 bigdog829 is offline
 
Join Date: Apr 2005
Location: Michigan
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Redlinemotorsports View Post
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
Reply With Quote
  #5  
Old 03-11-2007, 01:52 AM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 03-11-2007, 02:19 AM
bigdog829 bigdog829 is offline
 
Join Date: Apr 2005
Location: Michigan
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 03-11-2007, 08:37 AM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 03-11-2007, 05:06 PM
bigdog829 bigdog829 is offline
 
Join Date: Apr 2005
Location: Michigan
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TECK View Post
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.
Reply With Quote
  #9  
Old 03-11-2007, 11:50 PM
JorgeX JorgeX is offline
 
Join Date: Oct 2005
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default


TECK, it's offtopic but can u explain step by step your script? i'm learning php and i want to absorb knoledge
Reply With Quote
  #10  
Old 03-12-2007, 01:53 AM
Gray Matter Gray Matter is offline
 
Join Date: May 2005
Posts: 260
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:

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

</if>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:12 PM.


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.04566 seconds
  • Memory Usage 2,269KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete