Example #1
0
<?php

require_once 'cfg_admin.php';
logincheck();
if (isset($_POST['id'], $_POST['into'])) {
    $szFolder = trim(trim($_POST['into'], './') . '/' . trim(strtr($_POST['id'], array('.' => '', ' ' => '', '/' => '')), './'), './');
    mkdir($_SERVER['DOCUMENT_ROOT'] . '/' . $szFolder);
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $szFolder . '/.htaccess', 'SetHandler This_is_a_security_line_DO_NOT_REMOVE');
    createHtaccessForSite();
    header('Location: edit.php?id=' . $szFolder);
    exit;
}
tpl_header();
echo '<h1>Creating new file folder</h1>';
?>
<form method="post" action="">

	<p>URL:<br />/<?php 
echo isset($_GET['into']) ? trim($_GET['into'], '/') . '/' : '';
?>
<input type="text" name="id" value="" maxlength="50" style="border:solid 1px black;border-width:0 0 1px;" /></p> 

	<p><input type="submit" value="Save" /></p>

	<input type="hidden" name="into" value="<?php 
echo isset($_GET['into']) ? trim($_GET['into'], '/') : '.';
?>
" />

</form>
Example #2
0
 if (isset($_POST['subdomain'], $_POST['urls'])) {
     $subdomain = $_POST['subdomain'];
     if ('zzzzz' == $subdomain || 0 == preg_match('/^[0-9a-z]+(?:\\-[0-9a-z]+)?$/i', $subdomain) || 3 > strlen($subdomain) || in_array($subdomain, $arrSites)) {
         exit('Invalid subdomain: invalid name or already exists');
     }
     echo '<pre>';
     $db_name = ROOT_SQL_DB . $_POST['subdomain'];
     $db_user = substr(ROOT_SQL_DB . $_POST['subdomain'], 0, 16);
     $db_pass = getDatabasePasswordForCMSSite($_POST['subdomain']);
     // create VHost
     $szVHost = strtr(file_get_contents(PROJECT_ROOT_RESOURCES . '/generic_vhost.conf'), array('__SERVERNAME__' => $subdomain . '.' . $_SERVER['HTTP_HOST'], '__SERVERALIASES__' => $_POST['urls'], '__DOCROOT__' => str_replace('CMS_SITE_SUBDOMAIN', $subdomain, PROJECT_IMPARTIAL_PUBLIC)));
     var_dump(file_put_contents(SCRIPT_ROOT . '/_config/vhosts/' . ROOT_SQL_DB . $subdomain . '.conf', $szVHost));
     // copy file structure
     rcopy(PROJECT_ROOT_RESOURCES . '/default', PROJECT_RESOURCES . $subdomain . '');
     rcopy(PROJECT_ROOT_RUNTIME . '/default', PROJECT_RUNTIME . $subdomain . '');
     createHtaccessForSite($subdomain);
     // create database
     tmp_debug($root->query('CREATE DATABASE `' . $db_name . '`;'));
     echo $root->error . "\n";
     // grant user database rights
     tmp_debug($root->query("GRANT SELECT , INSERT , UPDATE , DELETE ON  `" . str_replace('_', '\\_', $db_name) . "` . * TO  '" . $db_user . "'@'localhost' IDENTIFIED BY '" . $db_pass . "';"));
     echo $root->error . "\n";
     // connect with new database
     $db = new $_dbtype(SQL_HOST, ROOT_SQL_USER, ROOT_SQL_PASS, $db_name);
     // copy all tables, without data
     foreach ($root->fetch('SHOW TABLES IN `' . ROOT_SQL_DB . 'default`;') as $table) {
         $table = reset($table);
         $create = $root->fetch('SHOW CREATE TABLE `' . ROOT_SQL_DB . 'default`.`' . $table . '`');
         $create = $create[0]->{'Create Table'};
         tmp_debug(array('table ' . $table, $db->query($create)));
         echo $db->error . "\n";