source: 0.4/iphp.php @ 4

Revision 4, 6.1 KB checked in by anthemfor182, 6 years ago (diff)

Un cambio de Prueba

Line 
1<?php
2
3/** Kumbia - PHP Rapid Development Framework *****************************
4*       
5* Copyright (C) 2005-2007 Andrés Felipe Gutiérrez (andresfelipe at vagoogle.net)
6*       
7* This framework is free software; you can redistribute it and/or
8* modify it under the terms of the GNU Lesser General Public
9* License as published by the Free Software Foundation; either
10* version 2.1 of the License, or (at your option) any later version.
11*
12* This framework is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15* Lesser General Public License for more details.
16*
17* You should have received a copy of the GNU Lesser General Public
18* License along with this framework; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20*
21* Este framework es software libre; puedes redistribuirlo y/o modificarlo
22* bajo los terminos de la licencia pública general GNU tal y como fue publicada
23* por la Fundación del Software Libre; desde la versión 2.1 o cualquier
24* versión superior.
25*
26* Este framework es distribuido con la esperanza de ser util pero SIN NINGUN
27* TIPO DE GARANTIA; sin dejar atrás su LADO MERCANTIL o PARA FAVORECER ALGUN
28* FIN EN PARTICULAR. Lee la licencia publica general para más detalles.
29*
30* Debes recibir una copia de la Licencia Pública General GNU junto con este
31* framework, si no es asi, escribe a Fundación del Software Libre Inc.,
32* 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
33*****************************************************************************/
34
35if(isset($_SERVER['SERVER_SOFTWARE'])){
36        header('Location: index.php');
37        exit;
38}
39
40require_once "forms/config/main.php";
41require_once "forms/generator/main.php";
42require_once "forms/xml/main.php";
43require_once "kumbia.php";
44
45if(!dbBase::load_driver()){
46        Flash::warning('No se pudo cargar el driver de la base de datos definido en forms/config/config.ini');
47        return false;
48}
49
50if($kumbia_config = Config::read('core.ini')){
51        $kumbia_config->modules->extensions = str_replace(" ", "", $kumbia_config->modules->extensions);
52        $extensions = explode(",", $kumbia_config->modules->extensions);
53        foreach($extensions as $extension){
54                $ex = explode(".", $extension);
55                require_once "lib/{$ex[0]}/{$ex[1]}.php";
56        }
57}
58
59$models = array();
60foreach(scandir('models/') as $model){
61        if(strpos($model, ".php")){
62                require_once "models/$model";
63                $model = str_replace(".php", "", $model);
64                $objModel = str_replace("_", " ", $model);
65                $objModel = ucwords($objModel);
66                $objModel = str_replace(" ", "", $objModel);
67                if(!class_exists($objModel)){
68                        throw new kumbiaException(
69                        "No se encontr&oacute; la Clase \"$objModel\"",
70                        "Es necesario definir una clase en el modelo
71                        '$model' llamado '$objModel' para que esto
72                        funcione correctamente.");
73                        return false;
74                } else {
75                        $$objModel = new $objModel($model, false);
76                        $$objModel->source = $model;
77                        $$objModel->source = $model;
78                        $models[] = $objModel;
79                }
80        }
81}
82
83function create_controller($a=''){
84        if(!$a){
85                print "Error: Debe especificar el nombre del Controlador!\n";
86                return false;
87        } else {
88                if(file_exists("controllers/$a"."_controller.php")){
89                        print "Error: El controlador '$a' ya existe\n";
90                        return false;
91                } else {
92                        $file = "<?php
93                       
94        class ".ucwords(strtolower($a))."Controller extends ApplicationController {
95       
96        }
97       
98?>\n";          file_put_contents("controllers/$a"."_controller.php", $file);
99                        print "El controlador '$a' se creó correctamente\n";
100                }
101        }
102        return true;
103}
104
105function create_standardform($a=''){
106        if(!$a){
107                print "Error: Debe especificar el nombre del Controlador!\n";
108                return false;
109        } else {
110                if(file_exists("controllers/$a"."_controller.php")){
111                        print "Error: El controlador '$a' ya existe\n";
112                        return false;
113                } else {
114                        $file = "<?php
115                       
116        class ".ucwords(strtolower($a))."Controller extends StandardForm {
117         
118               public \$scaffold = true;
119               
120        }
121       
122?>\n";          file_put_contents("controllers/$a"."_controller.php", $file);
123                        print "El controlador '$a' se creó correctamente\n";
124                }
125        }
126        return true;
127}
128
129
130function create_model($a=''){
131        if(!$a){
132                print "Error: Debe especificar el nombre del Modelo!\n";
133                return false;
134        } else {
135                if(file_exists("models/$a.php")){
136                        print "Error: El modelo '$a' ya existe\n";
137                        return false;
138                } else {
139                        $file = "<?php
140                       
141        class ".ucwords(strtolower($a))." extends ActiveRecord {
142       
143        }
144       
145?>\n";          file_put_contents("models/$a.php", $file);
146                        print "El modelo '$a' se creó correctamente\n";
147                }
148        }
149        return true;
150}
151
152$fp = fopen("php://stdin", "r");
153print "Bienvenido al Kumbia 0.4 Interactivo\n";
154print "Escribe 'exit' para salir\n\n";
155print "iphp> ";
156while($c = fgets($fp)){
157        if(rtrim($c)=="quit"){
158                exit;
159        }
160        try {
161                if(trim($c)){
162                        $a = eval("return ".trim($c).";");
163                        if($a===null){
164                                print "NULL";
165                        } else {
166                                if($a===false){
167                                        print "FALSE";
168                                } else {
169                                        if($a===true){
170                                                print "TRUE";
171                                        } else {
172                                                if(!is_object($a)){
173                                                        print_r($a);
174                                                } else {
175                                                        print "Object Instance Of ".get_class($a);
176                                                }
177                                        }
178                                }
179                        }
180                        print "\niphp> ";
181                } else {
182                        print "iphp> ";
183                }
184        }
185        catch(kumbiaException $e){                             
186                print $e->getMessage()."\n";
187                $i = 1;
188                foreach($e->getTrace() as $trace){
189                        if($trace['class']){
190                                print "#$i {$trace['class']}::{$trace['function']}(".join(",",$trace['args']).") en ".basename($trace['file'])."\n";                           
191                        }
192                        $i++;
193                }
194        }
195        catch(dbException $e){         
196                print $e->getMessage()."\n";
197                $i = 1;
198                foreach($e->getTrace() as $trace){
199                        if($trace['class']){
200                                print "#$i {$trace['class']}::{$trace['function']}(".join(",",$trace['args']).") en ".basename($trace['file'])."\n";                           
201                        }
202                        $i++;
203                }
204        }
205        catch(ActiveRecordException $e){               
206                print $e->getMessage()."\n";
207                $i = 1;
208                foreach($e->getTrace() as $trace){
209                        if($trace['class']){
210                                print "#$i {$trace['class']}::{$trace['function']}(".join(",",$trace['args']).") en ".basename($trace['file'])."\n";                           
211                        }
212                        $i++;
213                }       
214        }
215}
216fclose($fp);
217
218?>
Note: See TracBrowser for help on using the repository browser.