Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / deepfreeze.php
1 <?php
2 /**
3  * Strips out all fluid functions (experimental)
4  */
5 $functions = array(
6         'addFK','addIndex','addUniqueConstraint','createTable',
7         'widenColumn','buildFK','addColumn','wipeAll'
8 );
9 $code = file_get_contents('rb.php');
10 $functionDefs = array();
11 foreach($functions as $function) {
12         $functionDefs[] = "public function $function";
13         $functionDefs[] = "private function $function";
14         $functionDefs[] = "protected function $function";
15         $functionDefs[] = "public static function $function";
16         $functionDefs[] = "private static function $function";
17         $functionDefs[] = "protected static function $function";
18 }
19 $functionDefs[] = 'class Fluid extends Repository';
20 foreach( $functionDefs as $function ) {
21         while( strpos( $code, $function ) !== FALSE ) {
22                 $begin = strpos( $code, $function );
23                 $pointer = $begin;
24                 $char = '';
25                 while( $char !== '{'  && $char !== ';' ) {
26                         echo $char;
27                         $char = substr( $code, $pointer, 1);
28                         $pointer ++;
29                 }
30                 if ($char === ';') {
31                         $code = substr( $code, 0, $begin-1 ) . substr( $code, $pointer );
32                         continue;
33                 }
34                 if ($char === '{') {
35                         $nesting = 1;
36                         $pointer ++;
37                         $beginOfFunction = $pointer;
38                         while( !( $char === '}' && $nesting === 0 ) ) {
39                                 $char = substr( $code, $pointer, 1);
40                                 if ($char === '{') {  $nesting ++; echo "($nesting)"; }
41                                 if ($char === '}') { $nesting --; echo "($nesting)"; }
42                                 $pointer ++;
43                         }
44                         $code = substr( $code, 0, $begin-1 ) . substr( $code, $pointer );
45                         continue;               
46                 }
47         }
48 }
49 file_put_contents('rbf.php', $code);