function migrate_config_2_2()
{
    global $l;
    if (!is_writable(DOCUMENT_REAL_ROOT . '/config')) {
        msg_error($l->g(2029));
        exit;
    }
    require_once 'require/function_files.php';
    $config = read_config_file();
    migrate_urls_2_2($config);
    migrate_js_2_2($config);
    migrate_profiles_2_2();
    migrate_menus_2_2($config);
}
Example #2
0
/**
 * Main functions. Just decides what mode we are in and calls the
 * appropriate methods.
 */
function main()
{
    global $info, $config;
    $args = Console_Getopt::readPHPArgv();
    if (count($args) < 2) {
        print_usage_info();
    }
    if (substr($args[1], 0, 1) == "-" || substr($args[1], 0, 1) == "/") {
        print "invalid parameter " . $args[2] . "\n";
        print_usage_info();
    }
    if (substr($args[1], -4) == ".php") {
        // mode 2: create zombie app
        if (!file_exists($args[1])) {
            die("config file " . $args[1] . " does not exist\n");
        }
        read_config_file($args[1]);
        $outdir = ZOMBIE_BASE . '/../' . Horde_String::lower($config['app']);
        if (is_dir($outdir) && $args[2] != "-f") {
            print "Directory {$outdir} already exists.\nUse -f flag to force overwrite\n";
            exit;
        }
        $n = $config['app'];
        print "Creating Horde Application {$n} in directory " . Horde_String::lower($n) . "\n";
        transform($outdir);
        print "\nHorde Application '{$n}' successfully written. Where to go from here:\n" . "1) Paste content of {$n}/registry.stub to horde/config/registry.php.\n" . "   After that, the {$n} should be working!\n" . "2) Replace {$n}.gif with proper application icon\n" . "3) Ensure conf.php is not world-readable as it may contain password data.\n" . "4) Start playing around and enhancing your new horde application. Enjoy!\n";
    } else {
        // mode 1: create config file
        parse_options($args);
        print "creating config file for table " . $config['table'] . "\n";
        create_table_info();
        enhance_info();
        print "writing config file to " . $config['file'] . "\n";
        dump_config_file();
    }
}
<?php

//error_reporting(E_ALL);
//ini_set('display_errors', 'on');
include 'functions.php';
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include 'Net/SSH2.php';
?>
<!DOCTYPE HTML>
<html>
<head>
        <link type="text/css" rel="stylesheet" href="css/bootstrap.css"/>
</head>
<?php 
//TODO: Functionize this entire page... or at least parts of this... could save a lot of lines and simplify
read_config_file();
$default_pkitool_location = $config_dir . "/easy-rsa/2.0/pkitool";
$var_file = $config_dir . "easy-rsa/2.0/vars";
$var_dir = $config_dir . "easy-rsa/2.0/";
$key_dir = $var_dir . "keys/";
//$a_var_lines = file($var_file);
if ($_GET['action'] == "initial-setup") {
    if (!isset($_SESSION['password'])) {
        start_session('create_certs.php?action=initial-setup');
    }
    $password = stripslashes(trim($_SESSION['password']));
    $username = stripslashes(trim($_SESSION['username']));
    if ($username == "") {
        $username = "******";
    }
    $ssh = new Net_SSH2('localhost');
    public function __construct($config = array())
    {
        $CI =& get_instance();
        $CI->load->model('datatable_model');
        // Load the databale model
        $this->model = $CI->datatable_model;
        $this->model->init();
        // Initialise the datatable using the configuration file
        $CI->dataTable();
        // Add the js and css
        $js = 'window.datatable_conf = ' . str_replace('\\/', '/', json_encode($CI->datatable_model)) . ";\n";
        $js .= <<<EOT
window.datatable_conf = \$.extend(true, window.datatable_conf, {
\tlanguage: {
\t\tsearch: "",
\t\tpaginate: {
\t\t\tprevious: '<i class="glyphicon glyphicon-backward"></i>',
\t\t\tnext: '<i class="glyphicon glyphicon-forward"></i>'
\t\t}
\t},
\tautoWidth: false
});
\$(".datatable").dataTable(window.datatable_conf);
EOT;
        $js .= read_config_file('datatable/datatable.js');
        if ($this->model->selectType == 'multi') {
            $js .= <<<EOT
\t\t\t\$("#datatable tbody").selectable({
\t\t\t\tdelay: 1
\t\t\t});
EOT;
        }
        $CI->js($js);
    }
Example #5
0
<?php 
/**
 * Redirecting script - this file checks for URL matching config.ini entries
 * and redirects those URLs to Imposter server
 *
 * This file is a part of squid-imposter project.
 * @author Krzysztof Kotowicz <kkotowicz at gmail dot com>
 */
ini_set('display_errors', true);
set_error_handler('error_handler');
$cfg = read_config_file();
// do_log("Started");
while ($input = fgets(STDIN)) {
    if (!empty($cfg['test_mode'])) {
        // refresh config file at each request
        $cfg = read_config_file();
    }
    // Split the output (space delimited) from squid into an array.
    $line = explode(' ', $input);
    $url = trim($line[0]);
    if (count($line) >= 4) {
        $ip_fqdn = $line[1];
        $user = $line[2];
        $method = $line[3];
    }
    $elements = array('payload', 'manifest');
    foreach ($cfg as $site_id => $site) {
        foreach ($elements as $element) {
            if ($match = url_matches($url, $site, $element)) {
                if (empty($site[$element])) {
                    $site[$element] = !empty($match[1]) ? $match[1] : $match[0];
function update_key_list($key_dir_name)
{
    if (!isset($_SESSION['password'])) {
        start_session('certs.php?action=create_server');
        //TODO add cert name to line so don't have to refill form (see create_client_config_and_send)
    }
    $password = stripslashes(trim($_SESSION['password']));
    $username = stripslashes(trim($_SESSION['username']));
    if ($username == "") {
        $username = "******";
    }
    $ssh = new Net_SSH2('localhost');
    if (!$ssh->login($username, $password)) {
        exit('Login Failed');
    }
    //Now scanning the key directory for keys, and adding the names to keys.conf
    read_config_file();
    $cwd = getcwd();
    $num_keys = 0;
    //need to read index.txt and throw it in openvpngui dir so we can read and so we can extract key names.
    $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX);
    $output = $ssh->write("cp {$key_dir_name}/index.txt {$cwd}/keys.conf\n");
    $output = $ssh->read('/.*@.*[$|#]/', NET_SSH2_READ_REGEX);
    //list should now be stored in curr_work_dir, php will read, extract key names.
    $key_filename = "keys.conf";
    $key_list = file($key_filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    echo "<h3>Reading list of keys.... </h3><br />";
    //Counting the keys in the keydir
    echo str_repeat(' ', 1024 * 64);
    foreach ($key_list as $current_key) {
        //TODO!! prolly don't need this... each line on index.txt SHOULD be a key... but hey for now leave it...
        //Since in the future I will need to do some REGEX to get the actual key names
        if (fnmatch("CN=", $current_key)) {
            //first setup, so overwrite old keys.conf if it exists, and start again.
            if ($num_keys == 0) {
                file_put_contents("keys.conf", $current_key . PHP_EOL);
            } else {
                file_put_contents("keys.conf", $current_key . PHP_EOL, FILE_APPEND | LOCK_EX);
            }
            $key_array[$num_keys] = $current_key;
            //each line of file will be stored in this array
            $num_keys++;
        }
    }
}
Example #7
0
function read_config_file()
{
    global $config_values;
    $config_file = platform_getConfigFile();
    $config_cache = platform_getConfigCache();
    $comment = ";";
    $group = "NONE";
    if (!file_exists($config_file)) {
        _debug("No Config File Found, Creating default config\n", 0);
        write_config_file();
    }
    if (file_exists($config_cache)) {
        $CacheAge = time() - filemtime($config_cache);
        $ConfigAge = time() - filemtime($config_file);
    }
    if (file_exists($config_cache) && $CacheAge <= 300 && $CacheAge <= $ConfigAge) {
        $config_values = unserialize(file_get_contents($config_cache));
        if (!$config_values['Settings']) {
            unlink($config_cache);
            read_config_file();
        }
    } else {
        if (!($fp = fopen($config_file, "r"))) {
            _debug("read_config_file: Could not open {$config_file}\n", 0);
            exit(1);
        }
        if (flock($fp, LOCK_EX)) {
            while (!feof($fp)) {
                $line = trim(fgets($fp));
                if ($line && !preg_match("/^{$comment}/", $line)) {
                    if (preg_match("/^\\[/", $line) && preg_match("/\\]\$/", $line)) {
                        $line = trim($line, "[");
                        $line = trim($line, "]");
                        $group = trim($line);
                    } else {
                        $pieces = explode("=", $line, 2);
                        $pieces[0] = trim($pieces[0], "\"");
                        $pieces[1] = trim($pieces[1], "\"");
                        $option = trim($pieces[0]);
                        $value = trim($pieces[1]);
                        if (preg_match("/\\[\\]\$/", $option)) {
                            $option = substr($option, 0, strlen($option) - 2);
                            $pieces = explode("=>", $value, 2);
                            if (isset($pieces[1])) {
                                $config_values[$group][$option][trim($pieces[0])] = trim($pieces[1]);
                            } else {
                                $config_values[$group][$option][] = $value;
                            }
                        } else {
                            $config_values[$group][$option] = $value;
                        }
                    }
                }
            }
            flock($fp, LOCK_UN);
        }
        fclose($fp);
        file_put_contents($config_cache, serialize($config_values));
        chmod($config_cache, 0660);
    }
    // Create the base arrays if not already
    if (!isset($config_values['Favorites'])) {
        $config_values['Favorites'] = array();
    }
    if (!isset($config_values['Hidden'])) {
        $config_values['Hidden'] = array();
    }
    if (!isset($config_values['Feeds'])) {
        $config_values['Feeds'] = array(0 => array('Link' => 'http://ezrss.it/feed/', 'Type' => 'RSS', 'seedRatio' => '-1', 'Name' => 'ezRSS - Latest torrent releases'), 1 => array('Link' => 'http://rss.bt-chat.com/?group=3&cat=9', 'Type' => 'RSS', 'seedRatio' => '-1', 'Name' => 'BT-Chat.com'), 2 => array('Link' => 'http://rss.thepiratebay.org/205', 'Type' => 'RSS', 'seedRatio' => '-1', 'Name' => 'The Pirate Bay - TV shows'), 3 => array('Link' => 'http://rss.thepiratebay.org/208', 'Type' => 'RSS', 'seedRatio' => '-1', 'Name' => 'The Pirate Bay - Highres - TV shows'));
        write_config_file();
    }
    if (isset($config_values['Settings']['TimeZone'])) {
        date_default_timezone_set($config_values['Settings']['TimeZone']);
    }
    return true;
}
function admin_profil($form)
{
    global $protectedPost, $l, $pages_refs;
    $yes_no = array('YES' => $l->g(455), 'NO' => $l->g(454));
    $info_field = array('NAME' => array('INFO' => array('LBL' => $l->g(1153) . ": ", 'VALUE' => '')), 'GUI' => array('RESTRICTION' => array('LBL' => $l->g(1154) . ": ", 'VALUE' => $yes_no)), 'TELEDIFF_ACTIVATE' => array('RESTRICTION' => array('LBL' => $l->g(1158) . ": ", 'VALUE' => $yes_no)), 'TELEDIFF_VISIBLE' => array('RESTRICTION' => array('LBL' => $l->g(1301) . ": ", 'VALUE' => $yes_no)), 'EXPORT_XML' => array('RESTRICTION' => array('LBL' => $l->g(1305), 'VALUE' => $yes_no)), 'WOL' => array('RESTRICTION' => array('LBL' => $l->g(1281) . ": ", 'VALUE' => $yes_no)), 'MACADD' => array('ADMIN_BLACKLIST' => array('LBL' => $l->g(1159) . ": ", 'VALUE' => $yes_no)), 'SERIAL' => array('ADMIN_BLACKLIST' => array('LBL' => $l->g(1160) . ": ", 'VALUE' => $yes_no)), 'IPDISCOVER' => array('ADMIN_BLACKLIST' => array('LBL' => $l->g(1161) . ": ", 'VALUE' => $yes_no), 'CONFIGURATION' => array('LBL' => $l->g(1172) . ": ", 'VALUE' => $yes_no)), 'TELEDIFF' => array('CONFIGURATION' => array('LBL' => $l->g(1162) . ": ", 'VALUE' => $yes_no)), 'CONFIG' => array('CONFIGURATION' => array('LBL' => $l->g(1163) . ": ", 'VALUE' => $yes_no)), 'GROUPS' => array('CONFIGURATION' => array('LBL' => $l->g(1164) . ": ", 'VALUE' => $yes_no)), 'CONSOLE' => array('CONFIGURATION' => array('LBL' => $l->g(1165) . ": ", 'VALUE' => $yes_no)), 'ALERTE_MSG' => array('CONFIGURATION' => array('LBL' => $l->g(1166) . ": ", 'VALUE' => $yes_no)), 'ACCOUNTINFO' => array('CONFIGURATION' => array('LBL' => $l->g(1167) . ": ", 'VALUE' => $yes_no)), 'CHANGE_ACCOUNTINFO' => array('CONFIGURATION' => array('LBL' => $l->g(1168) . ": ", 'VALUE' => $yes_no)), 'CHANGE_USER_GROUP' => array('CONFIGURATION' => array('LBL' => $l->g(1169) . ": ", 'VALUE' => $yes_no)), 'MANAGE_PROFIL' => array('CONFIGURATION' => array('LBL' => $l->g(1170) . ": ", 'VALUE' => $yes_no)), 'MANAGE_USER_GROUP' => array('CONFIGURATION' => array('LBL' => $l->g(1171) . ": ", 'VALUE' => $yes_no)), 'MANAGE_SMTP_COMMUNITIES' => array('CONFIGURATION' => array('LBL' => $l->g(1205) . ": ", 'VALUE' => $yes_no)), 'DELETE_COMPUTERS' => array('CONFIGURATION' => array('LBL' => $l->g(1272) . ": ", 'VALUE' => $yes_no)));
    $lbl_cat = array('INFO' => $l->g(1173), 'PAGE_PROFIL' => $l->g(1174), 'RESTRICTION' => $l->g(1175), 'ADMIN_BLACKLIST' => $l->g(1176), 'CONFIGURATION' => $l->g(1177));
    if ($protectedPost['Valid_modif_profil']) {
        //read profil file
        $forprofil = read_profil_file($protectedPost['PROFILS']);
        //read all profil value
        $forall = read_config_file();
        //build new tab with new values
        foreach ($info_field as $if_name => $if_value) {
            foreach ($if_value as $if_cat => $if_val) {
                if (isset($protectedPost[$if_name]) and $protectedPost['cat'] == $if_cat) {
                    $new_value[$if_cat][$if_name] = $protectedPost[$if_name];
                } else {
                    $new_value[$if_cat][$if_name] = $forprofil[$if_cat][$if_name];
                }
            }
        }
        foreach ($forall['URL'] as $name => $value) {
            if (isset($protectedPost[$name]) and $protectedPost['cat'] == "PAGE_PROFIL") {
                $new_value["PAGE_PROFIL"][$name] = '';
            }
        }
        if (!isset($new_value['PAGE_PROFIL'])) {
            $new_value['PAGE_PROFIL'] = $forprofil['PAGE_PROFIL'];
        }
        update_config_file($protectedPost['PROFILS'], $new_value);
        msg_success($l->g(1274));
    }
    $array_profil = get_profile_labels();
    echo $l->g(1196) . ": " . show_modif($array_profil, "PROFILS", 2, $form);
    echo "<a href=\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_new_profil'] . "&head=1&form=" . $form . "\"><img src=image/plus.png></a>";
    if (isset($protectedPost['PROFILS']) and $protectedPost['PROFILS'] != '') {
        $forall = read_config_file();
        $forprofil = read_profil_file($protectedPost['PROFILS'], 'WRITE');
        if (is_array($forprofil) and is_array($forall)) {
            foreach ($forprofil as $key => $value) {
                if (isset($lbl_cat[$key])) {
                    $data_on[$key] = $lbl_cat[$key];
                }
            }
            onglet($data_on, $form, "cat", 10);
            if (isset($forprofil[$protectedPost['cat']]) and $protectedPost['cat'] != 'PAGE_PROFIL') {
                $name_field = array();
                $type_field = array();
                $tab_name = array();
                $value_field = array();
                foreach ($info_field as $if_name => $if_value) {
                    foreach ($if_value as $if_cat => $if_val) {
                        if ($protectedPost['cat'] == $if_cat) {
                            if (isset($forprofil[$if_cat][$if_name])) {
                                $protectedPost[$if_name] = $forprofil[$if_cat][$if_name];
                            }
                            array_push($name_field, $if_name);
                            array_push($tab_name, $if_val['LBL']);
                            if (is_array($if_val['VALUE'])) {
                                array_push($type_field, 2);
                                if (!isset($protectedPost[$if_name])) {
                                    array_push($if_val['VALUE'], '');
                                }
                                array_push($value_field, $if_val['VALUE']);
                            } else {
                                array_push($type_field, 0);
                                array_push($value_field, replace_language($forprofil[$if_cat][$if_name]));
                            }
                        }
                    }
                }
                $tab_typ_champ = show_field($name_field, $type_field, $value_field);
                tab_modif_values($tab_name, $tab_typ_champ, $tab_hidden, array('button_name' => 'modif_profil'));
            } elseif ($protectedPost['cat'] == 'PAGE_PROFIL') {
                $champs = "<table align=center><tr><td align=center>";
                $i = 0;
                ksort($forall['URL']);
                foreach ($forall['URL'] as $key => $value) {
                    $champs .= "<input type='checkbox' name='" . $key . "' id='" . $key . "' ";
                    if (isset($forprofil[$protectedPost['cat']][$key])) {
                        $champs .= " checked ";
                    }
                    $champs .= " ></td><td>" . $key . "</td><td align=center>";
                    $i++;
                    if ($i == 4) {
                        $champs .= "</td></tr><tr><td align=center>";
                        $i = 0;
                    }
                }
                $champs .= "</td></tr></table>";
                tab_modif_values($champs, array(), array(), array('button_name' => 'modif_profil'));
            }
        }
    }
}