Пример #1
0
<?php

//-------------------------------------------------------------------------------
// we don't want all those deprecated notices
ini_set('display_errors', false);
// include the shared functions
include_once 'shared-functions.php';
// --------------------------------------------------------------------------------
/**
 * This is the directory where you put the smt2 CMS.
 * You can use relative as well as full URLs like /smt2/ or http://myserver.name/smt2/
 */
// prepare ABS_PATH
$abs_path = smt2wp_substract_strings(get_smt2wp_base_path_slash(), get_smt2wp_server_root());
$abs_path = '/' . $abs_path . '/';
$abs_path = smt2wp_sanitize_dir_path($abs_path);
define('ABS_PATH', $abs_path);
// always put an ending slash (/)
/**
* Load th WP config file and extract our needed constants from there.
*/
$wp_config_file = smt2wp_sanitize_dir_path(get_wp_base_dir() . '/wp-config.php');
// read the wp_config and extract and eval() the DB constants:
$php_code = '';
$handle = fopen($wp_config_file, "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        if (strpos(trim($line), 'define') === 0 && strpos($line, 'DB_') !== false) {
            // THEN:
            $php_code .= $line;
        }
function get_wp_base_dir()
{
    return smt2wp_substract_strings(get_smt2wp_base_path_slash(), get_smt2wp_path_relative_to_wp());
}