Rules Server Variables
Categories
Component ID
2159421
Component name
Rules Server Variables
Component type
module
Maintenance status
Development status
Component security advisory coverage
covered
Downloads
391
Component created
Component changed
Component body
Creates rules integration (currently only conditions) to compare the string values of server variables.
Options:
Greater than
Less than
Equal to
Contains
Regex
About:
The need for this module came when I wanted to prevent commerce recurring
transactions from happening on production envorionments. By comparing
the $_SERVER['SERVER_ADDR'] address in a condition, I'm able to prevent this
on all other installations of the project.
Instructions:
Install module and add exposed rules condition to any rule.
Note: If running these rules via cron, the variables may not be available if use CLI or Drush based crons.
Example Rules condition component to check if site is "production"
{ "rules_site_is_running_on_production_server" : {
"LABEL" : "Site is running on production server",
"PLUGIN" : "and",
"REQUIRES" : [ "rules_server_variables" ],
"AND" : [
{ "rules_server_variables_compare" : {
"variable" : "SERVER_ADDR",
"value" : " [LAN IP OF SERVER]",
"operator" : "equal_to"
}
},
{ "rules_server_variables_compare" : {
"variable" : "SERVER_NAME",
"value" : "[FQDN/DOMAIN NAME]",
"operator" : "equal_to"
}
}
]
}
}