source: branches/unified_backend/Configure.php @ 72

Last change on this file since 72 was 72, checked in by yermol, 15 years ago

work-in-progress commit to Unified Backend branch.

added devutils directory for server side convenience scripts

svn_commit.pl front-end to svn commit to update about.html on submit.
makedocs.pl to generates JSDoc and PHPDoc documentation.

added Configure.php script to generate cli script paths and to set perms.
added index.html
added README, INSTALL, README_DEVELOPERS
added examples/simple_example.html
added ddt.js debug trace message to text area class.
htmlarea.js reworked

  • reorganized to group related pieces together.
  • JSDoc headers added to all methods
  • debugging trace messages added to entry points of most methods.
File size: 6.1 KB
Line 
1<?php
2
3// [COPY
4// -----------------------------------------------------------------
5// Copyright (C) DTLink, LLC.
6// http://www.dtlink.com and http://www.formvista.com
7// -----------------------------------------------------------------
8// Use of this code is granted by the sames terms as described in the
9// htmlArea License (based on BSD license). Please read license.txt
10// in this package for details.
11//
12// All software distributed under the Licenses is provided strictly on
13// an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
14// IMPLIED, AND DTLINK LLC HEREBY DISCLAIMS ALL SUCH
15// WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
16// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT,
17// OR NON-INFRINGEMENT.
18// ------------------------------------------------------------------
19// COPY]
20
21/**
22* Simple Configure system ported from formVista
23*
24* @package Xinha
25* @subpackage configure
26* @author Yermo Lamers
27* @copyright DTLink, LLC
28* @see http://www.formvista.com
29*/
30
31// ---------------------------------------------------------------
32// REVISION HISTORY:
33//
34// 2005-04-15 YmL:
35// . ported from formVista.
36// . this version relicensed under HTMLArea license.
37// ---------------------------------------------------------------
38
39// make sure we're not running in a webserver
40
41if ( @$_SERVER["HTTP_HOST"] != NULL )
42        {
43        die( "No\n" );
44        }
45
46// a hack that works with versions of PHP prior to 4.3
47
48$stdin = fopen("php://stdin","r");
49$stdout = fopen("php://stdout","r");
50$stderr = fopen("php://stderr","r");
51
52// a nice little banner.
53
54readfile( "./conf/banner.txt" );
55
56print( "Press any key to continue:" );
57
58$response = fgets( $stdin, 256 );
59
60/**
61* configure support library
62*/
63
64include_once( "./devutils/lib/install.php" );
65
66$dataExport = array();
67
68// ---------------------------------------------------------------
69// Prompts
70// ---------------------------------------------------------------
71
72while ( true )
73        {
74
75        print "\n";
76        print "---------------------------------------------------------\n";
77        print "\nFull Path to PHP command line interpreter:\n";
78        print "[" . @$dataExport["PHP"] . "]:";
79
80        $response = fgets( $stdin, 256 );
81                                                                                 
82   if ( preg_match( "/\S/", $response ) )
83                {
84                $response = trim($response);
85
86        $dataExport[ "PHP" ] = $response;
87
88                break;
89                }
90        else
91                {
92
93                // it's possible we've already looped through this
94
95                if ( preg_match( "/\S/", @$dataExport[ "PHP" ] ))
96                        break;
97
98                print( "\nPlease enter the path to PHP\n" );
99                }
100        }
101
102while ( true )
103        {
104
105        print "\n";
106        print "---------------------------------------------------------\n";
107        print "\nPath to PERL:\n";
108        print "[" . @$dataExport["PERL"] . "]:";
109
110        $response = fgets( $stdin, 256 );
111                                                                                 
112   if ( preg_match( "/\S/", $response ) )
113                {
114                $response = trim($response);
115
116        $dataExport[ "PERL" ] = $response;
117
118                break;
119                }
120        else
121                {
122
123                // it's possible we've already looped through this
124
125                if ( preg_match( "/\S/", @$dataExport[ "PERL" ] ))
126                        break;
127
128                print( "\nPlease enter the path to Perl\n" );
129                }
130        }
131
132// ---------------------------------------------------------------
133//                      TEMPLATE EXPANSION
134// ---------------------------------------------------------------
135//
136// There are a number of utility configuration files and utility scripts
137// that need to have some of these settings embedded in them.
138
139// PHP kludge for taking a source file and turning it into an array.
140
141if (( $infile_list = file( "./conf/infile_list.txt" )) == NULL )
142        {
143        print( "ERROR - unable open '.in' files list in './conf/infile_list.txt'\n" );
144        return  false ;
145        }
146
147// now loop over each file in the list and expand it.
148
149foreach ( $infile_list as $offset => $source_line )
150        {
151
152        // is our source_line blank or does it mark a phpDocumentor docblock?
153
154        if (( preg_match( "/^\s$/", $source_line )) ||
155                ( substr( $source_line, 0, 3 ) == "/**" ) ||
156                ( substr( $source_line, 0, 1 ) == "*" ) ||
157                ( substr( $source_line, 0, 2 ) == "<?" ) ||
158                ( substr( $source_line, 0, 2 ) == "?>" ))
159                {
160
161                // blank line or phpDocumentor comment.
162
163                continue;
164                }
165
166        $source_line = rtrim( $source_line );
167
168        // lines in the file are source file, target permissions. (unix only)
169
170        list( $filename, $permissions ) = split( " ", $source_line );
171
172        $permissions = rtrim( $permissions );
173
174        // the target name is the source name minus '.in'.
175
176        $target_filename = str_replace( ".in", "", $filename );
177
178        // do variable replacement in the file.
179
180        process_template( $filename, $target_filename, $dataExport );
181
182        // nice little bug in chmod() call ...
183
184        $mode_oct = octdec($permissions);
185       
186        chmod( $target_filename, $mode_oct );
187       
188        print( "Generated '$target_filename' permissions '$permissions'\n" );
189
190        }
191
192// ---------------------------------------------------------------
193//              CHECKING PERMISSIONS
194// ---------------------------------------------------------------
195//
196// We've run into countless situations where directory and file
197// permissions get changed. Read in a list of files and directories
198// and change permission and ownership accordingly.
199
200// PHP kludge for taking a source file and turning it into an array.
201
202if (( $infile_list = file( "./conf/perms_list.txt" )) == NULL )
203        {
204        print( "ERROR - unable open perms list in './conf/perms_list.txt'\n" );
205        return  false ;
206        }
207
208// now loop over each file and directory in the list and expand it.
209
210foreach ( $infile_list as $offset => $source_line )
211        {
212
213        // is our source_line blank or does it mark a phpDocumentor docblock?
214
215        if (( preg_match( "/^\s$/", $source_line )) ||
216                ( substr( $source_line, 0, 3 ) == "/**" ) ||
217                ( substr( $source_line, 0, 1 ) == "*" ) ||
218                ( substr( $source_line, 0, 2 ) == "<?" ) ||
219                ( substr( $source_line, 0, 2 ) == "?>" ))
220                {
221
222                // blank line or phpDocumentor comment.
223
224                continue;
225                }
226
227        $source_line = rtrim( $source_line );
228
229        // lines in the file are source file or dir, permissions, owner. (unix only)
230        // where owner is either the web user or root.
231
232        list( $filename, $permissions, $owner ) = split( " ", $source_line );
233
234        $owner = rtrim( $owner );
235
236        // nice little bug in chmod() call ...
237
238        $mode_oct = octdec($permissions);
239       
240        chmod( $filename, $mode_oct );
241        chown( $filename, $owner );
242               
243        print( "Set '$filename' to perms '$permissions' owner '$owner'\n" );
244
245        }
246
247// END
248
249?>
Note: See TracBrowser for help on using the repository browser.