| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 4 // +----------------------------------------------------------------------+ 5 // | Akelos Framework - http://www.akelos.org | 6 // +----------------------------------------------------------------------+ 7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez | 8 // | Released under the GNU Lesser General Public License, see LICENSE.txt| 9 // +----------------------------------------------------------------------+ 10 11 /** 12 * @package ActiveSupport 13 * @subpackage Scripts 14 * @author Bermi Ferrer <bermi a.t akelos c.om> 15 * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org 16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html> 17 */ 18 19 error_reporting(defined('AK_ERROR_REPORTING_ON_SCRIPTS') ? AK_ERROR_REPORTING_ON_SCRIPTS : 0); 20 21 require_once (AK_LIB_DIR.DS.'Ak.php'); 22 require_once (AK_LIB_DIR.DS.'AkObject.php'); 23 require_once (AK_LIB_DIR.DS.'AkInflector.php'); 24 require_once (AK_LIB_DIR.DS.'AkPhpParser.php'); 25 26 defined('AK_SKIP_DB_CONNECTION') && AK_SKIP_DB_CONNECTION ? ($dsn='') : Ak::db(&$dsn); 27 defined('AK_RECODE_UTF8_ON_CONSOLE_TO') ? null : define('AK_RECODE_UTF8_ON_CONSOLE_TO', false); 28 29 require_once (AK_LIB_DIR.DS.'AkActiveRecord.php'); 30 require_once (AK_LIB_DIR.DS.'AkActionMailer.php'); 31 require_once(AK_APP_DIR.DS.'shared_model.php'); 32 require_once (AK_LIB_DIR.DS.'utils'.DS.'generators'.DS.'AkelosGenerator.php'); 33 require_once (AK_LIB_DIR.DS.'AkInstaller.php'); 34 35 36 if ($id_dir = opendir(AK_MODELS_DIR.DS)){ 37 while (false !== ($file = readdir($id_dir))){ 38 if ($file != "." && $file != ".." && $file != '.svn' && $file[0] != '_' && substr($file,-12,8) != '_service'){ 39 if(!is_dir(AK_MODELS_DIR.DS.$file)){ 40 include_once(AK_MODELS_DIR.DS.$file); 41 } 42 } 43 } 44 closedir($id_dir); 45 } 46 47 define('AK_PROMT',fopen("php://stdin","r")); 48 49 $join_command = false; 50 $promt_line = ">>> "; 51 while(true){ 52 if(empty($__promt_for_command)){ 53 $__promt_for_command = true; 54 echo "\nWelcome to the Akelos Framework Interactive Console\n\n>> "; 55 } 56 57 $command = ($join_command ? $command : '').fgets(AK_PROMT,25600); 58 59 if(substr(trim($command,"\n\r "), -1) == '\\'){ 60 $command = rtrim($command, "\\\n\r"); 61 $join_command = true; 62 echo "... "; 63 continue; 64 }else{ 65 $join_command = false; 66 } 67 68 switch (trim(strtolower($command),"\n\r\t ();")) { 69 case 'exit': 70 case 'die': 71 fclose(AK_PROMT); 72 exit; 73 break; 74 75 case '': 76 echo "... "; 77 break; 78 79 case '<': 80 $command = $last_command; 81 echo "running command: ".$command; 82 83 default: 84 85 $last_command = $command; 86 87 $_script_name = array_shift(explode(' ',trim($command).' ')); 88 89 $_script_file_name = AK_OS == 'WINDOWS' ? $_script_name : AK_SCRIPT_DIR.DS.$_script_name; 90 91 if (file_exists($_script_file_name)){ 92 93 $command = trim(substr(trim($command),strlen($_script_name))); 94 echo "\n"; 95 passthru((AK_OS == 'WINDOWS' ? 'php -q ':'').$_script_file_name.' '.escapeshellcmd($command)); 96 echo "\n>>> "; 97 98 }else{ 99 100 ob_start(); 101 $parser = new AkPhpParser($command); 102 echo $parser->parse() === 0 ? '' : "..."; 103 if(!$parser->hasErrors()){ 104 eval($parser->code); 105 }else{ 106 echo "\nPHP Error: \n".join("\n", $parser->getErrors())."\n"; 107 } 108 109 $result = ob_get_contents(); 110 ob_end_clean(); 111 112 $result = strstr($result,": eval()") ? 113 strip_tags(array_shift(explode(': eval()',$result))) : 114 $result; 115 116 Ak::file_add_contents(AK_LOG_DIR.DS.'command_line.log',$promt_line.$command."\n".$result."\n"); 117 echo empty($result) ? $promt_line : "\n". 118 (AK_RECODE_UTF8_ON_CONSOLE_TO ? Ak::recode($result, AK_RECODE_UTF8_ON_CONSOLE_TO) : $result). 119 "\n\n$promt_line"; 120 } 121 break; 122 } 123 } 124 fclose(AK_PROMT); 125 126 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |