Esempio n. 1
0
/**
 * function to scan $_POST for any settings.conf array values
 *  Warning: function very loopy - needs to be optimized
 * @param string $match=null *optional* name of "$_POST key string array" to return - get all if null
 * @return array,bool Array containing one storage array name per key or FALSE if none where found
 */
function VPN_get_post_storage_arrays($match = null)
{
    global $_settings;
    $settings = $_settings->get_settings();
    $ret = array();
    reset($_POST);
    foreach ($_POST as $key => $val) {
        //$_POST keys are md5() of the setting names so loop over $settings to find a match
        reset($settings);
        $found = false;
        foreach ($settings as $set_key => $set_val) {
            if ($set_key === $key) {
                $found = true;
                break;
            }
        }
        if ($found === true) {
            if ($_settings->is_settings_array($set_key) === true) {
                $name_only = substr($set_key, 0, strpos($set_key, '['));
                //get only the array name, without key, from $set_key string
                //this is an array, do we know this key already?
                if (array_is_value_unique($ret, $name_only) === true) {
                    $ret[] = $name_only;
                }
            } elseif ($set_key === 'MYVPN[0]') {
                $ret[] = 'MYVPN';
            }
        }
    }
    if (count($ret) == 0) {
        return false;
    } else {
        return $ret;
    }
}
Esempio n. 2
0
 /**
  * method to get a list of arrays contained in settings.conf
  *  use $settings[$returnFromThisFunction[0]] to get the current value from settings.conf
  * @return array,bool return array of names,FALSE if no arrays have been found
  * array[0] == 'name of setting'
  * array[1] == 'name of setting2'
  */
 function get_array_list()
 {
     $ret = array();
     if (array_key_exists('settings.conf', $_SESSION) !== true) {
         if ($this->load_settings() === false) {
             echo "FATAL ERROR: Unable to get list of settings!";
             return false;
         }
     }
     foreach ($_SESSION['settings.conf'] as $key => $val) {
         if ($this->is_settings_array($key) === true) {
             $name_only = substr($key, 0, strpos($key, '['));
             //get only the array name, without key, from $set_key string
             //var_dump($name_only);
             if (array_is_value_unique($ret, $name_only) === true) {
                 $ret[] = $name_only;
             }
         }
     }
     if (count($ret) == 0) {
         return false;
     }
     return $ret;
 }