vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   GeoIP condition (https://vborg.vbsupport.ru/showthread.php?t=278368)

steveneff 02-10-2012 02:14 PM

yes it does.

I've tried it without show guest but still the same.

PHP Code:

<vb:if condition="!in_array($GLOBALS['mygig'],$GLOBALS['mycountry'], true)">
<
vb:if condition="$show['guest']"><div class="padtop">
stuff to go in here
</div></vb:if></vb:if> 


kh99 02-10-2012 02:21 PM

OK, what happens if you try this:

Code:

<vb:if condition="!in_array('XX', array('AL', 'AZ'), true)">
<vb:if condition="$show['guest']"><div class="padtop">
stuff to go in here
</div></vb:if></vb:if>


or this:

Code:

<vb:if condition="!in_array('AL', array('AL', 'AZ'), true)">
<vb:if condition="$show['guest']"><div class="padtop">
stuff to go in here
</div></vb:if></vb:if>


steveneff 02-10-2012 02:29 PM

They both parse, the second one does it's job ok

kh99 02-10-2012 02:34 PM

OK - if you still have the preRegister() call in there, what does this do:

Code:

<vb:if condition="!in_array($mygig, array('AL', 'AZ'), true)">
<vb:if condition="$show['guest']"><div class="padtop">
stuff to go in here
</div></vb:if></vb:if>


(I guess it will depend on if your country is one of AL or AZ - if it isn't, you could hard-code it in index.php).

steveneff 02-10-2012 02:39 PM

parse OK but doesn't work, I changed AZ to GB so I can see if it works.

kh99 02-10-2012 02:47 PM

Well, OK, I don't know. Seems like maybe it's not seeing the variables for some reason.

If you only want to use that ip check in the forumdisplay template, maybe try moving your code to a plugin using hook forumdisplay_complete.

steveneff 02-10-2012 03:06 PM

You mean this code

PHP Code:

$efvip $_SERVER['REMOTE_ADDR'];include('/home/myaccount/public_html/geo/geoip.inc');$gi geoip_open('/home/myaccount/public_html/geo/ip/GeoIP.dat',GEOIP_STANDARD);$mygig geoip_country_code_by_addr($gi$efvip);$mycountry = array('AL','AZ','BA','BD','BG','BW','CD','EE','EG','ET','FI','KW','KE','KP','KR','LB','LC','LR','LV','MA','MT','MU','NG','NP','PH','RS','SK','SL','TN','UY','VG','ZM','ZW'); 

Still no go, what a pig

kh99 02-10-2012 03:13 PM

Maybe this (assuming you don't use the country code elsewhere in the template): In a plugin using hook forumdisplay_complete:

PHP Code:

$efvip $_SERVER['REMOTE_ADDR'];
include(
'/home/myaccount/public_html/geo/geoip.inc');
$gi geoip_open('/home/myaccount/public_html/geo/ip/GeoIP.dat',GEOIP_STANDARD);
$mygig geoip_country_code_by_addr($gi$efvip);
$mycountry = array('AL','AZ','BA','BD','BG','BW','CD','EE','EG','ET','FI','KW','KE','KP','KR','LB','LC','LR','LV','MA','MT','MU','NG','NP','PH','RS','SK','SL','TN','UY','VG','ZM','ZW');  

$show['in_country'] = $show['guest'] AND in_array($mygig$mycountry); 


then in the template:

Code:

<vb:if condition="$show[in_country]"><div class="padtop">
stuff to go in here
</div></vb:if>


steveneff 02-10-2012 03:34 PM

No still nothing

kh99 02-10-2012 04:25 PM

Ah, OK...maybe I was wrong - maybe the code you're getting back from geoip_country_code_by_addr() isn't what you expect? What happens if you set $mygig to a country code? Also, you could put

Code:

{vb:raw GLOBALS.mygig}

in the template somewhere (not inside the if).


All times are GMT. The time now is 03:34 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.01065 seconds
  • Memory Usage 1,752KB
  • 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
  • (5)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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