• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Script to toggle rule

Scheduled Pinned Locked Moved General pfSense Questions
3 Posts 2 Posters 1.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E
    epalzeolithe
    last edited by Jul 24, 2017, 6:56 AM

    Hello

    i'd like to make an easy interface to toggle rules on the fly from an ios or android device, to switch parameters on the fly.

    So my first need is to easyly toggle rules

    I've seen this post : https://forum.pfsense.org/index.php?topic=56751.0

    It's exactely what i need :

    • i've understand i can toggle a rule with a POST method like :
    http://router_adress/firewall_rules.php?if=lan&act=toggle&id=4
    
    

    Then to validate the rule toggle, i need to use a script php the guy on the post propose :

    require_once("config.inc");
    require_once("functions.inc");
    require_once("filter.inc");
    require_once("shaper.inc");
    require_once("ipsec.inc");
    require_once("vpn.inc");
    
    /* invalidate interface cache */
    get_interface_arr(true);
    
    $retval = 0;
                    $retval = filter_configure();
    
                    clear_subsystem_dirty('filter');
    
                    pfSense_handle_custom_code("/usr/local/pkg/firewall_rules/apply");
    
                    echo "The settings have been applied. The firewall rules are now reloading in the background.
    ";
    

    So i put this script as the file "done.php", inside /usr/local/www.

    but when i try with my browser to post this php script, with

    http://router_adress/done.php
    
    

    it doesn't execute the php script, it only shows the content of the script as an html file.

    What did i do wrong ?

    Thanks !!!

    1 Reply Last reply Reply Quote 0
    • H
      heper
      last edited by Jul 24, 2017, 7:51 AM

      http://php.net/manual/en/language.basic-syntax.phptags.php

      1 Reply Last reply Reply Quote 0
      • E
        epalzeolithe
        last edited by Jul 27, 2017, 9:31 AM

        Thank you !

        1 Reply Last reply Reply Quote 0
        3 out of 3
        • First post
          3/3
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
          This community forum collects and processes your personal information.
          consent.not_received