示例#1
0
$conf[\'db_password\'] = \'' . $dbpasswd . '\';
$conf[\'db_host\'] = \'' . $dbhost . '\';

$prefixeTable = \'' . $prefixeTable . '\';

define(\'PHPWG_INSTALLED\', true);
define(\'PWG_CHARSET\', \'utf-8\');
define(\'DB_CHARSET\', \'utf8\');
define(\'DB_COLLATE\', \'\');

?' . '>';
        @umask(0111);
        // writing the configuration file
        if (!($fp = @fopen($config_file, 'w'))) {
            // make sure nobody can list files of _data directory
            secure_directory(PHPWG_ROOT_PATH . $conf['data_location']);
            $tmp_filename = md5(uniqid(time()));
            $fh = @fopen(PHPWG_ROOT_PATH . $conf['data_location'] . 'pwg_' . $tmp_filename, 'w');
            @fputs($fh, $file_content, strlen($file_content));
            @fclose($fh);
            $template->assign(array('config_creation_failed' => true, 'config_url' => 'install.php?dl=' . $tmp_filename, 'config_file_content' => $file_content));
        }
        @fputs($fp, $file_content, strlen($file_content));
        @fclose($fp);
        // tables creation, based on piwigo_structure.sql
        execute_sqlfile(PHPWG_ROOT_PATH . 'install/piwigo_structure-mysql.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql');
        // We fill the tables with basic informations
        execute_sqlfile(PHPWG_ROOT_PATH . 'install/config.sql', DEFAULT_PREFIX_TABLE, $prefixeTable, 'mysql');
        $query = '
INSERT INTO ' . $prefixeTable . 'config (param,value,comment) 
   VALUES (\'secret_key\',md5(' . pwg_db_cast_to_text(DB_RANDOM_FUNCTION . '()') . '),
function prepare_directory($directory)
{
    if (!is_dir($directory)) {
        if (substr(PHP_OS, 0, 3) == 'WIN') {
            $directory = str_replace('/', DIRECTORY_SEPARATOR, $directory);
        }
        umask(00);
        $recursive = true;
        if (!@mkdir($directory, 0777, $recursive)) {
            die('[prepare_directory] cannot create directory "' . $directory . '"');
        }
    }
    if (!is_writable($directory)) {
        // last chance to make the directory writable
        @chmod($directory, 0777);
        if (!is_writable($directory)) {
            die('[prepare_directory] directory "' . $directory . '" has no write access');
        }
    }
    secure_directory($directory);
}