The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How to use "if" condition?
I have a plugin that inserts PHP code on all pages to check a user's IP address. What I want to do exclude it from checking administrator's IPs.
The plugin looks like this: HTML Code:
<dependencies /> <codes /> <templates /> <plugins> <plugin active="1" executionorder="1"> <title>BlockScript vBulletin Integration</title> <hookname>init_startup</hookname> <phpcode><![CDATA[if (file_exists(CWD.'/blockscript/detector.php')) { include_once(CWD.'/blockscript/detector.php'); } elseif (file_exists(CWD.'/../blockscript/detector.php')) { include_once(CWD.'/../blockscript/detector.php'); } else { include_once(CWD.'/../../blockscript/detector.php'); }]]></phpcode> </plugin> </plugins> <phrases /> <options /> <helptopics /> <cronentries /> <faqentries /> </product> <vb:if condition="is_member_of($bbuserinfo, 1,2,3,4,8,17,19,20,26,15,22,16,14,18,21)"> But if I insert that in the xml file when adding the product/plugin it gives me a mysql error and doesn't work. Any ideas? Thank you! -Jennifer |
#2
|
||||
|
||||
Wrap the plugin code with:
PHP Code:
|
2 благодарности(ей) от: | ||
RichieBoy67, TheLastSuperman |
#3
|
||||
|
||||
<vb:if> is for use in templates. Are you needing the IF statement in a template or in php code?
If using it in the php plugin, use it as MarkFL stated above. |
2 благодарности(ей) от: | ||
MarkFL, TheLastSuperman |
#4
|
|||
|
|||
Quote:
I've tried a few times but can't seem to know exactly where I'm supposed to wrap the code. I keep breaking something. This is the entire XML file... HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <product productid="blockscript" active="1"> <title>BlockScript vBulletin Integration</title> <description>BlockScript vBulletin Integration</description> <version>1.0</version> <url>http://www.blockscript.com/</url> <versioncheckurl /> <dependencies /> <codes /> <templates /> <plugins> <plugin active="1" executionorder="1"> <title>BlockScript vBulletin Integration</title> <hookname>init_startup</hookname> <phpcode><![CDATA[if (file_exists(CWD.'/blockscript/detector.php')) { include_once(CWD.'/blockscript/detector.php'); } elseif (file_exists(CWD.'/../blockscript/detector.php')) { include_once(CWD.'/../blockscript/detector.php'); } else { include_once(CWD.'/../../blockscript/detector.php'); }]]></phpcode> </plugin> </plugins> <phrases /> <options /> <helptopics /> <cronentries /> <faqentries /> </product> |
#5
|
||||
|
||||
Change it to read:
HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <product productid="blockscript" active="1"> <title>BlockScript vBulletin Integration</title> <description>BlockScript vBulletin Integration</description> <version>1.0</version> <url>http://www.blockscript.com/</url> <versioncheckurl /> <dependencies /> <codes /> <templates /> <plugins> <plugin active="1" executionorder="1"> <title>BlockScript vBulletin Integration</title> <hookname>init_startup</hookname> <phpcode><![CDATA[if (is_member_of($vbulletin->userinfo, array(1,2,3,4,8,17,19,20,26,15,22,16,14,18,21))) { if (file_exists(CWD.'/blockscript/detector.php')) { include_once(CWD.'/blockscript/detector.php'); } elseif (file_exists(CWD.'/../blockscript/detector.php')) { include_once(CWD.'/../blockscript/detector.php'); } else { include_once(CWD.'/../../blockscript/detector.php'); } }]]></phpcode> </plugin> </plugins> <phrases /> <options /> <helptopics /> <cronentries /> <faqentries /> </product> |
3 благодарности(ей) от: | ||
Dragonsys, Lynne, TheLastSuperman |
#6
|
|||
|
|||
Quote:
--------------- Added [DATE]1447265522[/DATE] at [TIME]1447265522[/TIME] --------------- I just realized today that the code isn't working It doensn't return any errors but the code isn't executing for any of the usergroups in the array. If anyone has any ideas I'd greatly appreciate it. Thank you! |
2 благодарности(ей) от: | ||
MarkFL, TheLastSuperman |
#7
|
||||
|
||||
Quote:
Code:
if (file_exists($CWD.'/blockscript/detector.php')) { $bs_detector_path = $CWD.'/blockscript/'; } Code:
ob_start(); include($bs_detector_path.'detector.php'); $includedphp = ob_get_contents(); ob_end_clean(); Unless you are using an external (to VB) file, $CWD should be the root VB folder, so you should not need to check it several times. |
#8
|
|||
|
|||
Quote:
HTML Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <product productid="blockscript" active="1"> <title>BlockScript vBulletin Integration</title> <description>BlockScript vBulletin Integration</description> <version>1.0</version> <url>http://www.blockscript.com/</url> <versioncheckurl /> <dependencies /> <codes /> <templates /> <plugins> <plugin active="1" executionorder="1"> <title>BlockScript vBulletin Integration</title> <hookname>init_startup</hookname> <phpcode><![CDATA[if (is_member_of($vbulletin->userinfo, array(1,2,3,4,8,17,19,20,26,15,22,16,14,18,21))) { if (file_exists($CWD.'/blockscript/detector.php')) { $bs_detector_path = $CWD.'/blockscript/'; } if (file_exists(CWD.'/blockscript/detector.php')) { include_once(CWD.'/blockscript/detector.php'); } elseif (file_exists(CWD.'/../blockscript/detector.php')) { include_once(CWD.'/../blockscript/detector.php'); } else { include_once(CWD.'/../../blockscript/detector.php'); } ob_start(); include($bs_detector_path.'detector.php'); $includedphp = ob_get_contents(); ob_end_clean(); }]]> </phpcode> </plugin> </plugins> <phrases /> <options /> <helptopics /> <cronentries /> <faqentries /> </product> |
#9
|
||||
|
||||
Quote:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <product productid="blockscript" active="1"> <title>BlockScript vBulletin Integration</title> <description>BlockScript vBulletin Integration</description> <version>1.0</version> <url>http://www.blockscript.com/</url> <versioncheckurl /> <dependencies /> <codes /> <templates /> <plugins> <plugin active="1" executionorder="1"> <title>BlockScript vBulletin Integration</title> <hookname>global_start</hookname> <phpcode><![CDATA[if (is_member_of($vbulletin->userinfo, array(1,2,3,4,8,17,19,20,26,15,22,16,14,18,21))) { if (file_exists($CWD.'/blockscript/detector.php')) { $bs_detector_path = $CWD.'/blockscript/'; ob_start(); include($bs_detector_path.'detector.php'); $includedphp = ob_get_contents(); ob_end_clean(); } elseif (file_exists(CWD.'/../blockscript/detector.php')) { $bs_detector_path = $CWD.'/../blockscript/'; ob_start(); include($bs_detector_path.'detector.php'); $includedphp = ob_get_contents(); ob_end_clean(); } elseif { $bs_detector_path = CWD.'/../../blockscript/'; ob_start(); include($bs_detector_path.'detector.php'); $includedphp = ob_get_contents(); ob_end_clean(); } else { $includedphp = "<!-- File Not Found -->"; } vB_Template::preRegister('FORUMHOME',array('includedphp' => $includedphp)); }]]> </phpcode> </plugin> </plugins> <phrases /> <options /> <helptopics /> <cronentries /> <faqentries /> </product> Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <product productid="blockscript" active="1"> <title>BlockScript vBulletin Integration</title> <description>BlockScript vBulletin Integration</description> <version>1.0</version> <url>http://www.blockscript.com/</url> <versioncheckurl /> <dependencies /> <codes /> <templates /> <plugins> <plugin active="1" executionorder="1"> <title>BlockScript vBulletin Integration</title> <hookname>global_start</hookname> <phpcode><![CDATA[if (is_member_of($vbulletin->userinfo, array(1,2,3,4,8,17,19,20,26,15,22,16,14,18,21))) { if (file_exists($CWD.'/blockscript/detector.php')) { $bs_detector_path = $CWD.'/blockscript/'; ob_start(); include($bs_detector_path.'detector.php'); $includedphp = ob_get_contents(); ob_end_clean(); } else { $includedphp = "<!-- File Not Found -->"; } vB_Template::preRegister('FORUMHOME',array('includedphp' => $includedphp)); }]]> </phpcode> </plugin> </plugins> <phrases /> <options /> <helptopics /> <cronentries /> <faqentries /> </product> Then in the template, where you want the included file to appear you put this: Code:
{vb:raw includedphp} |
Благодарность от: | ||
MarkFL |
#10
|
|||
|
|||
Thanks for the response.
Just to say: The original template I provided was working/already in use. The only thing that seemed to stop it from working altogether was the inclusion of the: HTML Code:
if (is_member_of($vbulletin->userinfo, array(1,2,3,4,8,17,19,20,26,15,22,16,14,18,21))) Thank you! |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|