예제 #1
0
}
/* Display ISP Billing version and Cacti Version */
if ($debug) {
    debug("Starting at " . date($date_format));
    debug("Cacti ISP Billing Version: " . $version);
    debug("Cacti Version: " . $config["cacti_version"]);
    debug("Cacti OS: " . $config["cacti_server_os"]);
    debug("PHP Version: " . phpversion());
    debug("PHP OS: " . PHP_OS);
    if (function_exists("php_uname")) {
        debug("PHP uname: " . php_uname());
    }
}
/* Build a config file if requested */
if ($cmd_build) {
    build_config($cmd_build_file, $cmd_filter, $cmd_email, $cmd_email_html, $cmd_email_csv);
    exit;
}
/* Check command line options */
if (empty($cmd_config)) {
    print "ERROR: Required command line option, -config not specified.\n";
    display_help($version);
    exit;
}
/* Check for track file */
if (empty($cmd_track)) {
    print "ERROR: Required command line option -track not specified.\n";
    display_help($version);
    exit;
}
/* Parse the configuration */
예제 #2
0
<?php

/**
 * CLI script to build the site configuration
 */
if (strtolower(php_sapi_name()) !== 'cli') {
    die("Must be run from the command line\n");
}
/* debug mode has to be set to something or include files will die() */
define('DEBUG_MODE', false);
/* determine current absolute path used for require statements */
define('APP_PATH', dirname(dirname(__FILE__)) . '/');
/* get the framework */
require APP_PATH . 'lib/framework.php';
/* create site */
build_config();
/**
 * Entry point into the configuration process
 *
 * @return void
 */
function build_config()
{
    /* get the site settings */
    $settings = parse_ini_file(APP_PATH . 'hm3.ini');
    if (is_array($settings) && !empty($settings)) {
        /* determine compression commands */
        list($js_compress, $css_compress) = compress_methods($settings);
        /* get module detail */
        list($js, $css, $filters, $assets) = get_module_assignments($settings);
        /* combine and compress page content */
예제 #3
0
파일: db_update.php 프로젝트: istrwei/Luna
     }
     // Remove contacts table
     if ($db->table_exists('contacts')) {
         $db->drop_table('contacts') or error('Unable to drop contacts table', __FILE__, __LINE__, $db->error());
     }
     // Luna 1.1 upgrade support
     $db->add_field('topics', 'solved', 'INT(10) UNSIGNED', true) or error('Unable to add solved field', __FILE__, __LINE__, $db->error());
     $db->add_field('users', 'accent', 'INT(10)', false, '2') or error('Unable to add column "accent" to table "users"', __FILE__, __LINE__, $db->error());
     $db->add_field('users', 'adapt_time', 'TINYINT(1)', false, '0') or error('Unable to add column "adapt_time" to table "users"', __FILE__, __LINE__, $db->error());
     build_config(1, 'o_allow_accent_color', '1');
     build_config(1, 'o_allow_night_mode', '1');
     build_config(1, 'o_announcement_title', '');
     build_config(1, 'o_announcement_type', 'info');
     build_config(1, 'o_board_tags', '');
     build_config(1, 'o_cookie_bar_url', 'http://getluna.org/docs/cookies.php');
     build_config(1, 'o_default_accent', '2');
     // Luna 1.2 upgrade support
     $db->add_field('users', 'enforce_accent', 'TINYINT(1)', false, 0) or error('Unable to add enforce_accent field', __FILE__, __LINE__, $db->error());
     $db->add_field('forums', 'solved', 'TINYINT(1)', false, 1) or error('Unable to add solved field', __FILE__, __LINE__, $db->error());
     $db->add_field('forums', 'icon', 'VARCHAR(50)', TRUE, NULL) or error('Unable to add icon field', __FILE__, __LINE__, $db->error());
     break;
     // Preparse posts
 // Preparse posts
 case 'preparse_posts':
     $query_str = '?stage=preparse_sigs';
     // If we don't need to parse the comments, skip this stage
     if (isset($luna_config['o_parser_revision']) && $luna_config['o_parser_revision'] >= Version::FORUM_PARSER_VERSION) {
         break;
     }
     require FORUM_ROOT . 'include/parser.php';
     // Fetch posts to process this cycle
예제 #4
0
     $db->add_field('users', 'use_inbox', 'TINYINT(1)', false, '1', 'activate_key') or error('Unable to add column "use_inbox" to table "users"', __FILE__, __LINE__, $db->error());
     $db->add_field('users', 'notify_inbox', 'TINYINT(1)', false, '1', 'use_inbox') or error('Unable to add column "notify_inbox" to table "users"', __FILE__, __LINE__, $db->error());
     $db->add_field('users', 'notify_inbox_full', 'TINYINT(1)', false, '0', 'notify_with_comment') or error('Unable to add column "notify_inbox_full" to table "users"', __FILE__, __LINE__, $db->error());
     $db->add_field('users', 'num_inbox', 'INT(10) UNSIGNED', false, '0', 'num_comments') or error('Unable to add column "num_inbox" to table "users"', __FILE__, __LINE__, $db->error());
     // Luna 1.1 upgrade support items that have to be executed after the Luna 1.3 upgrade
     $db->add_field('groups', 'g_soft_delete_comments', 'TINYINT(1)', false, 0, 'g_user_title') or error('Unable to add g_soft_delete_comments field', __FILE__, __LINE__, $db->error());
     $db->add_field('groups', 'g_soft_delete_threads', 'TINYINT(1)', false, 0, 'g_user_title') or error('Unable to add g_soft_delete_threads field', __FILE__, __LINE__, $db->error());
     $db->add_field('threads', 'solved', 'INT(10) UNSIGNED', true) or error('Unable to add solved field', __FILE__, __LINE__, $db->error());
     // Luna 1.2 upgrade support items that have to be executed after the Luna 1.3 upgrade
     $db->add_field('threads', 'solved', 'INT(10) UNSIGNED', true) or error('Unable to add solved field', __FILE__, __LINE__, $db->error());
     $db->add_field('threads', 'soft', 'TINYINT(1)', false, 0, null) or error('Unable to add soft field', __FILE__, __LINE__, $db->error());
     $db->drop_field('users', 'timezone') or error('Unable to drop timezone field', __FILE__, __LINE__, $db->error());
     $db->drop_field('users', 'dst') or error('Unable to drop timezone field', __FILE__, __LINE__, $db->error());
     $db->add_field('users', 'php_timezone', 'VARCHAR(100)', false, '\'UTC\'') or error('Unable to add php_timezone field', __FILE__, __LINE__, $db->error());
     build_config(0, 'o_default_timezone');
     build_config(1, 'o_timezone', 'UTC');
     break;
     // Preparse comments
 // Preparse comments
 case 'preparse_comments':
     $query_str = '?stage=preparse_sigs';
     // If we don't need to parse the comments, skip this stage
     if (isset($luna_config['o_parser_revision']) && $luna_config['o_parser_revision'] >= Version::LUNA_PARSER_VERSION) {
         break;
     }
     require LUNA_ROOT . 'include/parser.php';
     // Fetch comments to process this cycle
     $result = $db->query('SELECT id, message FROM ' . $db->prefix . 'comments WHERE id > ' . $start_at . ' ORDER BY id ASC LIMIT ' . PER_PAGE) or error('Unable to fetch comments', __FILE__, __LINE__, $db->error());
     $temp = array();
     $end_at = 0;
     while ($cur_item = $db->fetch_assoc($result)) {
function build_server()
{
    $ldap = new clladp();
    $unix = new unix();
    $sock = new sockets();
    $ca = "/etc/artica-postfix/openvpn/keys/ca.key";
    $cacrt = "/etc/artica-postfix/openvpn/keys/ca.crt";
    $open_vpn_ca_crt = "/etc/artica-postfix/openvpn/keys/openvpn-ca.crt";
    $openvpn_ca_csr = "/etc/artica-postfix/openvpn/keys/openvpn-ca.csr";
    $dh = '/etc/artica-postfix/openvpn/keys/dh2048.pem';
    $vpn_server_key = "/etc/artica-postfix/openvpn/keys/vpn-server.key";
    $vpn_server_crt = "/etc/artica-postfix/openvpn/keys/vpn-server.crt";
    $vpn_server_csr = "/etc/artica-postfix/openvpn/keys/vpn-server.csr";
    $open_vpn_ca_key = "/etc/artica-postfix/openvpn/keys/openvpn-ca.key";
    $cacrt1 = "/etc/artica-postfix/openvpn/keys/openvpn-ca.crt";
    $allca = "/etc/artica-postfix/openvpn/keys/allca.crt";
    $ligne = unserialize($sock->GET_INFO("OpenVPNCertificateSettings"));
    $hostname = $unix->hostname_g();
    $cp = $unix->find_program("cp");
    $rm = $unix->find_program("rm");
    $php = $unix->LOCATE_PHP5_BIN();
    $openssl = $unix->find_program("openssl");
    $CertificateMaxDays = intval($ligne["CertificateMaxDays"]);
    if ($CertificateMaxDays < 5) {
        $CertificateMaxDays = 730;
    }
    if (trim($ligne["password"]) == null) {
        $ligne["password"] = $ldap->ldap_password;
    }
    $directory = "/etc/artica-postfix/openvpn/keys";
    @mkdir($directory, 0755, true);
    system("{$rm} -rf {$directory}/*");
    build_progress(25, "{building_configuration}");
    build_config($directory, $hostname);
    $subj = @file_get_contents("{$directory}/subj.cf");
    $subjAndConfig = "{$subj} -config {$directory}/openssl.cf";
    $Config = "-config {$directory}/openssl.cf";
    $passout = "-passout pass:{$ligne["password"]}";
    $passin = "-passin pass:{$ligne["password"]}";
    // -------------------------------------------------------------------------------------------
    $cmd = "{$openssl} req -new -x509 -keyout {$ca} -out {$cacrt} {$subjAndConfig} {$passout} -batch -days {$CertificateMaxDays}";
    @chmod($ca, 0600);
    build_progress(10, "{$hostname} 1/5");
    echo "1)\n";
    echo $cmd . "\n";
    system($cmd);
    if (!check_file($ca)) {
        build_progress(110, "{$hostname} {failed}");
        system("{$rm} -rf {$directory}/*");
        return;
    }
    if (!check_file($cacrt)) {
        build_progress(110, "{$hostname} {failed}");
        system("{$rm} -rf {$directory}/*");
        return;
    }
    // -------------------------------------------------------------------------------------------
    $cmd = "{$openssl} req -new -keyout {$open_vpn_ca_key} -out {$openvpn_ca_csr} -batch  {$subjAndConfig} {$passout}";
    echo "2)\n";
    echo $cmd . "\n";
    build_progress(20, "{$hostname} 2/5");
    system($cmd);
    if (!check_file($open_vpn_ca_key)) {
        build_progress(110, "{$hostname} {failed}");
        system("{$rm} -rf {$directory}/*");
        return;
    }
    if (!check_file($openvpn_ca_csr)) {
        build_progress(110, "{$hostname} {failed}");
        system("{$rm} -rf {$directory}/*");
        return;
    }
    // -------------------------------------------------------------------------------------------
    $cmd = "{$openssl} ca -extensions v3_ca -days {$CertificateMaxDays} -out {$open_vpn_ca_crt} -in {$openvpn_ca_csr} -batch {$subjAndConfig} {$passin}";
    echo "3)\n";
    echo $cmd . "\n";
    build_progress(30, "{$hostname} 3/5");
    system($cmd);
    if (!check_file($open_vpn_ca_crt)) {
        build_progress(110, "{$hostname} {failed}");
        //system("$rm -rf $directory/*");
        return;
    }
    // -------------------------------------------------------------------------------------------
    system("/bin/cat {$cacrt} {$open_vpn_ca_crt} > {$allca}");
    // -------------------------------------------------------------------------------------------
    $cmd = "{$openssl} req -nodes -new -keyout {$vpn_server_key} -out {$vpn_server_csr} -batch {$subjAndConfig}";
    echo "4)\n";
    build_progress(40, "{$hostname} 4/5");
    echo $cmd . "\n";
    system($cmd);
    if (!check_file($vpn_server_key)) {
        build_progress(110, "{$hostname} {failed}");
        system("{$rm} -rf {$directory}/*");
        return;
    }
    if (!check_file($vpn_server_csr)) {
        build_progress(110, "{$hostname} {failed}");
        system("{$rm} -rf {$directory}/*");
        return;
    }
    @unlink("/etc/artica-postfix/openvpn/keys/index.txt");
    @touch("/etc/artica-postfix/openvpn/keys/index.txt");
    $cmd = "{$openssl} ca -keyfile {$open_vpn_ca_key} -cert {$open_vpn_ca_crt} -out {$vpn_server_crt} -in {$vpn_server_csr} -extensions server -batch {$subjAndConfig} {$passin}";
    chmod($vpn_server_key, 0600);
    echo "4)\n";
    echo $cmd . "\n";
    system($cmd);
    build_progress(50, "{$hostname} 5/5");
    if (!is_file("/etc/artica-postfix/openvpn/keys/dh2048.pem")) {
        $cmd = "{$openssl} dhparam -out /etc/artica-postfix/openvpn/keys/dh1024.pem 2048";
        echo "5)\n";
        echo $cmd . "\n";
        system($cmd);
    }
    build_progress(60, "{restarting_service}");
    system("{$php} /usr/share/artica-postfix/exec.openvpn.enable.php");
    build_progress(100, "{$hostname} {success}");
}