AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / install / include / config_template.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 if (!defined('TR_INCLUDE_PATH')) { exit; }
14
15 function write_config_file($filename, $comments) {
16         global $config_template;
17
18         $tokens = array('{USER}',
19                                         '{PASSWORD}',
20                                         '{HOST}',
21                                         '{PORT}',
22                                         '{DBNAME}',
23                                         '{TABLE_PREFIX}',
24                                         '{CONTENT_DIR}',
25                                         '{GENERATED_COMMENTS}',
26                                         '{GET_FILE}'
27                                 );
28
29                 $values = array(urldecode($_POST['step2']['db_login']),
30                                         addslashes(urldecode($_POST['step2']['db_password'])),
31                                         $_POST['step2']['db_host'],
32                                         $_POST['step2']['db_port'],
33                                         $_POST['step2']['db_name'],
34                                         $_POST['step2']['tb_prefix'],
35                                         addslashes(urldecode($_POST['step4']['content_dir'])),
36                                         $comments,
37                                         $_POST['step4']['get_file']
38                                         );
39
40         $config_template = str_replace($tokens, $values, $config_template);
41
42         if (!$handle = @fopen($filename, 'wb')) {
43          return false;
44     }
45         @ftruncate($handle,0);
46     if (!@fwrite($handle, $config_template, strlen($config_template))) {
47                 return false;
48     }
49         
50     @fclose($handle);
51         return true;
52 }
53
54 $config_template = "<"."?php 
55 /************************************************************************/
56 /* AContent                                                        */
57 /************************************************************************/
58 /* Copyright (c) 2009                                                   */
59 /* Adaptive Technology Resource Centre / University of Toronto          */
60 /*                                                                      */
61 /* This program is free software. You can redistribute it and/or        */
62 /* modify it under the terms of the GNU General Public License          */
63 /* as published by the Free Software Foundation.                        */
64 /************************************************************************/
65 {GENERATED_COMMENTS}
66 /************************************************************************/
67 /************************************************************************/
68 /* the database user name                                               */
69 define('DB_USER',                      '{USER}');
70
71 /* the database password                                                */
72 define('DB_PASSWORD',                  '{PASSWORD}');
73
74 /* the database host                                                    */
75 define('DB_HOST',                      '{HOST}');
76
77 /* the database tcp/ip port                                             */
78 define('DB_PORT',                      '{PORT}');
79
80 /* the database name                                                    */
81 define('DB_NAME',                      '{DBNAME}');
82
83 /* The prefix to add to table names to avoid conflicts with existing    */
84 /* tables. Default: TR_                                                 */
85 define('TABLE_PREFIX',                 '{TABLE_PREFIX}');
86
87 /* Where the content files are located.  This includes all file       */
88 /* manager and imported files.  If security is a concern, it is         */
89 /* recommended that the content directory be moved outside of the web   */
90 /* accessible area.                                                                                                             */
91 define('TR_CONTENT_DIR', '{CONTENT_DIR}');
92
93 /* Whether or not to use the TR_CONTENT_DIR as a protected directory.   */
94 /* The if set to FALSE then the content directory will be hard coded    */
95 /* to Transformable_install_dir/content/ and TR_CONTENT_DIR will be ignored.   */
96 /* This option is used for compatability with IIS and Apache 2.         */
97 define('TR_FORCE_GET_FILE', {GET_FILE});
98
99 /* DO NOT ALTER THIS LAST LINE                                          */
100 define('TR_INSTALL', TRUE);
101
102 ?".">";
103
104 ?>