$action = ""; } $pos = strrpos($_SERVER["SCRIPT_NAME"], "/"); $path = substr($_SERVER["SCRIPT_NAME"], 0, $pos); if ($path == "/") { $path = ""; } define('my_pligg_base', $path); $my_pligg_base = $path; } else { define('my_base_url', $my_base_url); define('my_pligg_base', $my_pligg_base); } define('urlmethod', $URLMethod); if (isset($_COOKIE['template'])) { $thetemp = str_replace('..', '', sanit($_COOKIE['template'])); } // template check $file = dirname(__FILE__) . '/templates/' . $thetemp . "/pligg.tpl"; unset($errors); if (!file_exists($file)) { $errors[] = 'You may have typed the template name wrong or "' . $thetemp . '" does not exist. Click <a href = "admin/admin_config.php?page=Template">here</a> to fix it.'; } if (isset($errors)) { // Name of the default Pligg template $thetemp = "bootstrap"; $file = dirname(__FILE__) . '/templates/' . $thetemp . "/pligg.tpl"; if (!file_exists($file)) { echo 'The default template "Bootstrap" does not exist anymore. Please fix this by reuploading the Bootstrap template!'; die; }
break; case 'DB_HOST': $line = "define('DB_HOST', '" . sanit($_POST['dbhost']) . "');\r\n"; break; case 'AUTH_KEY': case 'SECURE_AUTH_KEY': case 'LOGGED_IN_KEY': case 'NONCE_KEY': case 'AUTH_SALT': case 'SECURE_AUTH_SALT': case 'LOGGED_IN_SALT': case 'NONCE_SALT': $line = "define('" . $constant . "', '" . $secret_keys[$key++] . "');\r\n"; break; case 'WPLANG': $line = "define('WPLANG', '" . sanit($_POST['language']) . "');\r\n"; break; } } unset($line); $handle = fopen($directory . 'wp-config.php', 'w'); foreach ($config_file as $line) { fwrite($handle, $line); } fclose($handle); // We set the good rights to the wp-config file chmod($directory . 'wp-config.php', 0666); break; case "install_wp": /*--------------------------*/ /* Let's install WordPress database
$path = substr($_SERVER["SCRIPT_NAME"], 0, $pos); if ($path == "/") { $path = ""; } define('my_pligg_base', $path); $my_pligg_base = $path; } else { define('my_base_url', $my_base_url); define('my_pligg_base', $my_pligg_base); } define('urlmethod', $URLMethod); if (isset($_COOKIE['template'])) { $thetemp = sanit($_COOKIE['template']); } if (isset($_COOKIE['language'])) { $language = sanit($_COOKIE['language']); if (!file_exists('./libs/lang_' . $language . '.conf')) { $language = 'english'; } } else { $language = 'english'; } define('pligg_language', $language); if (!file_exists(dirname(__FILE__) . '/languages/lang_' . $language . '.conf')) { die('The language file /languages/lang_' . $language . '.conf does not exist. Either this file is missing or you did not rename lang.conf after an upgrade. Try renaming /languages/lang.conf to /languages/lang_' . $language . '.conf.'); } // template check $file = dirname(__FILE__) . '/templates/' . $thetemp . "/pligg.tpl"; unset($errors); if (!file_exists($file)) { $errors[] = 'You may have typed the template name wrong or "' . $thetemp . '" does not exist. Click <a href = "admin/admin_config.php?page=Template">here</a> to fix it.';
function wp_config() { $directory = DIRECTORY; /*--------------------------*/ /* Let's create the wp-config file /*--------------------------*/ // We retrieve each line as an array $config_file = file($directory . 'wp-config-sample.php'); // Managing the security keys $secret_keys = explode("\n", file_get_contents('https://api.wordpress.org/secret-key/1.1/salt/')); foreach ($secret_keys as $k => $v) { $secret_keys[$k] = substr($v, 28, 64); } // We change the data $key = 0; foreach ($config_file as &$line) { if ('$table_prefix =' == substr($line, 0, 16)) { $line = '$table_prefix = \'' . sanit(WPPREFIX) . "';\r\n"; continue; } if (!preg_match('/^define\\(\'([A-Z_]+)\',([ ]+)/', $line, $match)) { continue; } $constant = $match[1]; switch ($constant) { case 'WP_DEBUG': // Debug mod if ((int) WPCONFIGDEBUG == 1) { $line = "define('WP_DEBUG', 'true');\r\n"; // Display error if ((int) WPCONFIGDEBUGDISPLAY == 1) { $line .= "define('WP_DEBUG_DISPLAY', 'true');\r\n"; } // To write error in a log files if ((int) WPCONFIGDEBUGLOG == 1) { $line .= "define('WP_DEBUG_LOG', 'true');\r\n"; } } // We add the extras constant if (!empty(UPLOADDIR)) { $line .= "define('UPLOADS', '" . sanit(UPLOADDIR) . "');"; } if ((int) POSTREVISIONS >= 0) { $line .= "define('WP_POST_REVISIONS', " . (int) POSTREVISIONS . ");"; } if ((int) DISALLOWFILEEDIT == 1) { $line .= "define('DISALLOW_FILE_EDIT', true);"; } if ((int) AUTOSAVETIMEINTERVAL >= 60) { $line .= "define('AUTOSAVE_INTERVAL', " . (int) AUTOSAVETIMEINTERVAL . ");"; } if (!empty(WPCOMAPIKEY)) { $line .= "\r\n\n " . "/** WordPress.com API Key */" . "\r\n"; $line .= "define('WPCOM_API_KEY', '" . WPCOMAPIKEY . "');"; } $line .= "define('WP_MEMORY_LIMIT', '96M');" . "\r\n"; break; case 'DB_NAME': $line = "define('DB_NAME', '" . sanit(WPDBNAME) . "');\r\n"; break; case 'DB_USER': $line = "define('DB_USER', '" . sanit(WPUSER) . "');\r\n"; break; case 'DB_PASSWORD': $line = "define('DB_PASSWORD', '" . sanit(WPPASS) . "');\r\n"; break; case 'DB_HOST': $line = "define('DB_HOST', '" . sanit(WPDBHOST) . "');\r\n"; break; case 'AUTH_KEY': case 'SECURE_AUTH_KEY': case 'LOGGED_IN_KEY': case 'NONCE_KEY': case 'AUTH_SALT': case 'SECURE_AUTH_SALT': case 'LOGGED_IN_SALT': case 'NONCE_SALT': $line = "define('" . $constant . "', '" . $secret_keys[$key++] . "');\r\n"; break; case 'WPLANG': $line = "define('WPLANG', '" . sanit(LANGUAGE) . "');\r\n"; break; } } unset($line); $handle = fopen($directory . 'wp-config.php', 'w'); foreach ($config_file as $line) { fwrite($handle, $line); } fclose($handle); // We set the good rights to the wp-config file chmod($directory . 'wp-config.php', 0666); return true; }