/**
  * 
  * @return string
  */
 protected function getLogContents()
 {
     $log = $this;
     $request = $log->request;
     $remoteIp = $log->remoteIp;
     $referer = $request->referer();
     $params = Debugger::exportVar($request->params, 25);
     $data = Debugger::exportVar($request->data, 25);
     $result = array('LogType : User Login Error', 'IP      : ' . $remoteIp, 'Referer : ' . $referer, '---Params---', $params, '---Data---', $data, '---End---');
     return join("\n", $result);
 }
 /**
  * ユーザID、コントローラ名、アクション名、メソッド名(post or get)、リクエストパラメータ
  * @return string
  */
 protected function getLogContents()
 {
     $log = $this;
     $auth = $log->auth;
     $model = $log->model;
     $userId = self::createUserId($auth);
     $mdoelName = $model->name;
     $data = Debugger::exportVar($model->data, 25);
     $result = array('LogType   : Create Data', 'UserId    : ' . $userId, 'ModelName : ' . $mdoelName, '---Data---', $data, '---End---');
     return join("\n", $result);
 }
Esempio n. 3
0
 public function save($data = null, $validate = true, $fieldList = array())
 {
     $res = parent::save($data, $validate, $fieldList);
     if (!$res) {
         $this->log('[' . $this->alias . "] save error \n===== Validation errors =====\n" . Debugger::exportVar($this->validationErrors) . "\n===== Data =====" . Debugger::exportVar($this->data), 'debug');
         if (Configure::read('debug') != 0) {
             debug('[' . $this->alias . '] Save didn\'t work');
             debug($this->data);
             debug($this->validationErrors);
         }
     }
     return $res;
 }
 /**
  * ユーザID、コントローラ名、アクション名、メソッド名(post or get)、リクエストパラメータ
  * @return string
  */
 protected function getLogContents()
 {
     $log = $this;
     $request = $log->request;
     $auth = $log->auth;
     $userId = self::createUserId($auth);
     $medhod = $request->method();
     $referer = $request->referer();
     $params = Debugger::exportVar($request->params, 25);
     $data = Debugger::exportVar($request->data, 25);
     $ctlName = Inflector::camelize($request->params['controller']);
     $actionName = $request->params['action'];
     $result = array('LogType : User Access', 'UserId  : ' . $userId, 'Access  : ' . $ctlName . 'Controller::' . $actionName . '();', 'Referer : ' . $referer, 'Medhod  : ' . $medhod, '---Params---', $params, '---Data---', $data, '---End---');
     return join("\n", $result);
 }
Esempio n. 5
0
 /**
  * Override main() to handle action
  *
  * @access public
  */
 function main($command = null)
 {
     while (true) {
         if (empty($command)) {
             $command = trim($this->in(''));
         }
         switch ($command) {
             case 'help':
                 $this->out('Console help:');
                 $this->out('-------------');
                 $this->out('The interactive console is a tool for testing parts of your app before you commit code');
                 $this->out('');
                 $this->out('Model testing:');
                 $this->out('To test model results, use the name of your model without a leading $');
                 $this->out('e.g. Foo->find("all")');
                 $this->out('');
                 $this->out('To dynamically set associations, you can do the following:');
                 $this->out("\tModelA bind <association> ModelB");
                 $this->out("where the supported assocations are hasOne, hasMany, belongsTo, hasAndBelongsToMany");
                 $this->out('');
                 $this->out('To dynamically remove associations, you can do the following:');
                 $this->out("\t ModelA unbind <association> ModelB");
                 $this->out("where the supported associations are the same as above");
                 $this->out('');
                 $this->out("To save a new field in a model, you can do the following:");
                 $this->out("\tModelA->save(array('foo' => 'bar', 'baz' => 0))");
                 $this->out("where you are passing a hash of data to be saved in the format");
                 $this->out("of field => value pairs");
                 $this->out('');
                 $this->out("To get column information for a model, use the following:");
                 $this->out("\tModelA columns");
                 $this->out("which returns a list of columns and their type");
                 $this->out('');
                 $this->out('Route testing:');
                 $this->out('To test URLs against your app\'s route configuration, type:');
                 $this->out("\tRoute <url>");
                 $this->out("where url is the path to your your action plus any query parameters, minus the");
                 $this->out("application's base path");
                 $this->out('');
                 $this->out('To reload your routes config (config/routes.php), do the following:');
                 $this->out("\tRoute reload");
                 $this->out('');
                 break;
             case 'quit':
             case 'exit':
                 return true;
                 break;
             case 'models':
                 $this->out('Model classes:');
                 $this->hr();
                 foreach ($this->models as $model) {
                     $this->out(" - {$model}");
                 }
                 break;
             case preg_match("/^(\\w+) bind (\\w+) (\\w+)/", $command, $tmp) == true:
                 foreach ($tmp as $data) {
                     $data = strip_tags($data);
                     $data = str_replace($this->badCommandChars, "", $data);
                 }
                 $modelA = $tmp[1];
                 $association = $tmp[2];
                 $modelB = $tmp[3];
                 if ($this->__isValidModel($modelA) && $this->__isValidModel($modelB) && in_array($association, $this->associations)) {
                     $this->{$modelA}->bindModel(array($association => array($modelB => array('className' => $modelB))), false);
                     $this->out("Created {$association} association between {$modelA} and {$modelB}");
                 } else {
                     $this->out("Please verify you are using valid models and association types");
                 }
                 break;
             case preg_match("/^(\\w+) unbind (\\w+) (\\w+)/", $command, $tmp) == true:
                 foreach ($tmp as $data) {
                     $data = strip_tags($data);
                     $data = str_replace($this->badCommandChars, "", $data);
                 }
                 $modelA = $tmp[1];
                 $association = $tmp[2];
                 $modelB = $tmp[3];
                 // Verify that there is actually an association to unbind
                 $currentAssociations = $this->{$modelA}->getAssociated();
                 $validCurrentAssociation = false;
                 foreach ($currentAssociations as $model => $currentAssociation) {
                     if ($model == $modelB && $association == $currentAssociation) {
                         $validCurrentAssociation = true;
                     }
                 }
                 if ($this->__isValidModel($modelA) && $this->__isValidModel($modelB) && in_array($association, $this->associations) && $validCurrentAssociation) {
                     $this->{$modelA}->unbindModel(array($association => array($modelB)));
                     $this->out("Removed {$association} association between {$modelA} and {$modelB}");
                 } else {
                     $this->out("Please verify you are using valid models, valid current association, and valid association types");
                 }
                 break;
             case strpos($command, "->find") > 0:
                 // Remove any bad info
                 $command = strip_tags($command);
                 $command = str_replace($this->badCommandChars, "", $command);
                 // Do we have a valid model?
                 list($modelToCheck, $tmp) = explode('->', $command);
                 if ($this->__isValidModel($modelToCheck)) {
                     $findCommand = "\$data = \$this->{$command};";
                     @eval($findCommand);
                     if (is_array($data)) {
                         foreach ($data as $idx => $results) {
                             if (is_numeric($idx)) {
                                 // findAll() output
                                 foreach ($results as $modelName => $result) {
                                     $this->out("{$modelName}");
                                     foreach ($result as $field => $value) {
                                         if (is_array($value)) {
                                             foreach ($value as $field2 => $value2) {
                                                 $this->out("\t{$field2}: {$value2}");
                                             }
                                             $this->out("");
                                         } else {
                                             $this->out("\t{$field}: {$value}");
                                         }
                                     }
                                 }
                             } else {
                                 // find() output
                                 $this->out($idx);
                                 foreach ($results as $field => $value) {
                                     if (is_array($value)) {
                                         foreach ($value as $field2 => $value2) {
                                             $this->out("\t{$field2}: {$value2}");
                                         }
                                         $this->out("");
                                     } else {
                                         $this->out("\t{$field}: {$value}");
                                     }
                                 }
                             }
                         }
                     } else {
                         $this->out("\nNo result set found");
                     }
                 } else {
                     $this->out("{$modelToCheck} is not a valid model");
                 }
                 break;
             case strpos($command, '->save') > 0:
                 // Validate the model we're trying to save here
                 $command = strip_tags($command);
                 $command = str_replace($this->badCommandChars, "", $command);
                 list($modelToSave, $tmp) = explode("->", $command);
                 if ($this->__isValidModel($modelToSave)) {
                     // Extract the array of data we are trying to build
                     list($foo, $data) = explode("->save", $command);
                     $badChars = array("(", ")");
                     $data = str_replace($badChars, "", $data);
                     $saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));";
                     @eval($saveCommand);
                     $this->out('Saved record for ' . $modelToSave);
                 }
                 break;
             case preg_match("/^(\\w+) columns/", $command, $tmp) == true:
                 $modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1]));
                 if ($this->__isValidModel($modelToCheck)) {
                     // Get the column info for this model
                     $fieldsCommand = "\$data = \$this->{$modelToCheck}->getColumnTypes();";
                     @eval($fieldsCommand);
                     if (is_array($data)) {
                         foreach ($data as $field => $type) {
                             $this->out("\t{$field}: {$type}");
                         }
                     }
                 } else {
                     $this->out("Please verify that you selected a valid model");
                 }
                 break;
             case preg_match("/^routes\\s+reload/i", $command, $tmp) == true:
                 $router =& Router::getInstance();
                 $router->reload();
                 if (config('routes') && $router->parse('/')) {
                     $this->out("Routes configuration reloaded, " . count($router->routes) . " routes connected");
                 }
                 break;
             case preg_match("/^route\\s+(.*)/i", $command, $tmp) == true:
                 $this->out(Debugger::exportVar(Router::parse($tmp[1])));
                 break;
             default:
                 $this->out("Invalid command\n");
                 break;
         }
         $command = '';
     }
 }
Esempio n. 6
0
    /**
     * testExportVar method
     *
     * @access public
     * @return void
     */
    function testExportVar()
    {
        App::import('Controller');
        $Controller = new Controller();
        $Controller->helpers = array('Html', 'Form');
        $View = new View($Controller);
        $result = Debugger::exportVar($View);
        $expected = 'ViewView::$base = NULL
		View::$here = NULL
		View::$plugin = NULL
		View::$name = ""
		View::$action = NULL
		View::$params = array
		View::$passedArgs = array
		View::$data = array
		View::$helpers = array
		View::$viewPath = ""
		View::$viewVars = array
		View::$layout = "default"
		View::$layoutPath = NULL
		View::$pageTitle = false
		View::$autoRender = true
		View::$autoLayout = true
		View::$ext = ".ctp"
		View::$subDir = NULL
		View::$themeWeb = NULL
		View::$cacheAction = false
		View::$validationErrors = array
		View::$hasRendered = false
		View::$loaded = array
		View::$modelScope = false
		View::$model = NULL
		View::$association = NULL
		View::$field = NULL
		View::$fieldSuffix = NULL
		View::$modelId = NULL
		View::$uuids = array
		View::$output = false
		View::$__passedVars = array
		View::$__scripts = array
		View::$__paths = array
		View::$_log = NULL
		View::$webroot = NULL';
        $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
        $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
        $this->assertEqual($result, $expected);
    }
Esempio n. 7
0
 /**
  * Test that exportVar() doesn't loop through recursive structures.
  *
  * @return void
  */
 public function testExportVarRecursion()
 {
     $output = Debugger::exportVar($GLOBALS);
     $this->assertContains("'GLOBALS' => [recursion]", $output);
 }
 /**
  * Logs some debug output.
  * 
  * @return void
  */
 private function _debug($o)
 {
     if ($this->enableDebug) {
         $ds = str_repeat('-', 4);
         error_log(implode("\n", array('Begin debug output... ', "{$ds}Var Export{$ds}", Debugger::exportVar($o), "{$ds}Stack Trace{$ds}", Debugger::trace())));
     }
 }
    /**
     * testExportVar method
     *
     * @access public
     * @return void
     */
    function testExportVar()
    {
        App::import('Controller');
        $Controller = new Controller();
        $Controller->helpers = array('Html', 'Form');
        $View = new View($Controller);
        $result = Debugger::exportVar($View);
        $expected = 'View
		View::$Helpers = HelperCollection object
		View::$plugin = NULL
		View::$name = ""
		View::$passedArgs = array
		View::$helpers = array
		View::$viewPath = ""
		View::$viewVars = array
		View::$layout = "default"
		View::$layoutPath = NULL
		View::$autoLayout = true
		View::$ext = ".ctp"
		View::$subDir = NULL
		View::$theme = NULL
		View::$cacheAction = false
		View::$validationErrors = array
		View::$hasRendered = false
		View::$modelScope = false
		View::$model = NULL
		View::$association = NULL
		View::$field = NULL
		View::$fieldSuffix = NULL
		View::$modelId = NULL
		View::$uuids = array
		View::$output = false
		View::$request = NULL
		View::$elementCache = "default"';
        $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
        $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
        $this->assertEqual($result, $expected);
    }
 /**
  * Writes value to given session variable name.
  *
  * @param mixed $name Name of variable
  * @param string $value Value to write
  * @return boolean True if the write was successful, false if the write failed
  * @access public
  */
 public function write($name, $value)
 {
     if (empty($name)) {
         return false;
     }
     if (in_array($name, $this->watchKeys)) {
         trigger_error(sprintf(__('Writing session key {%s}: %s', true), $name, Debugger::exportVar($value)), E_USER_NOTICE);
     }
     $this->__overwrite($_SESSION, Set::insert($_SESSION, $name, $value));
     return Set::classicExtract($_SESSION, $name) === $value;
 }
Esempio n. 11
0
 /**
  * Handles object to string conversion.
  *
  * @param string $var Object to convert
  * @return string
  * @access private
  * @see Debugger:exportVar()
  */
 function __object($var)
 {
     $out = array();
     if (is_object($var)) {
         $className = get_class($var);
         $objectVars = get_object_vars($var);
         foreach ($objectVars as $key => $value) {
             if (is_object($value)) {
                 $value = get_class($value) . ' object';
             } elseif (is_array($value)) {
                 $value = 'array';
             } elseif ($value === null) {
                 $value = 'NULL';
             } elseif (in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource'))) {
                 $value = Debugger::exportVar($value);
             }
             $out[] = "{$className}::\${$key} = " . $value;
         }
     }
     return join("\n", $out);
 }
Esempio n. 12
0
 public function generate()
 {
     $rights = Configure::read('User.UserRight');
     $update = false;
     foreach (App::objects('plugins') as $plugin) {
         if (in_array($plugin, array('Blocks', 'DebugKit', 'MultiLanguage'))) {
             continue;
         }
         $path = CakePlugin::path($plugin) . 'Controller/';
         $files = scandir($path);
         if (!isset($rights['plugin'][$plugin]['name'])) {
             $rights['plugin'][$plugin]['name'] = $plugin;
             $rights['plugin'][$plugin]['status'] = USER_FUNC_ACTIVE;
             $update = true;
         }
         foreach ($files as $file) {
             if (is_file($path . $file)) {
                 $str = file_get_contents($path . $file);
                 preg_match_all('/public\\s+function\\s+(.+)\\s*\\(/', $str, $funcs);
                 if (count($funcs[1]) == 0) {
                     continue;
                 }
                 $controller = str_replace('.php', '', $file);
                 if ($controller != 'UserAdminController') {
                     if (!isset($rights['plugin'][$plugin]['controller'][$controller]['name'])) {
                         $rights['plugin'][$plugin]['controller'][$controller]['name'] = str_replace('Controller', '', $controller);
                         $rights['plugin'][$plugin]['controller'][$controller]['status'] = USER_FUNC_ACTIVE;
                     }
                     foreach ($funcs[1] as $func) {
                         if (in_array($func, array('beforeFilter', 'beforeRender', 'afterFilter'))) {
                             continue;
                         }
                         if (!isset($rights['plugin'][$plugin]['controller'][$controller]['action'][$func])) {
                             $rights['plugin'][$plugin]['controller'][$controller]['action'][$func]['name'] = $func;
                             $rights['plugin'][$plugin]['controller'][$controller]['action'][$func]['status'] = USER_FUNC_ACTIVE;
                             $update = true;
                         }
                     }
                 }
             }
         }
     }
     foreach (App::objects('controller') as $controller) {
         if ($controller == 'AppController') {
             continue;
         }
         $path = APP . 'Controller/';
         $str = file_get_contents($path . $controller . '.php');
         preg_match_all('/public\\s+function\\s+(.+)\\s*\\(/', $str, $funcs);
         if (count($funcs[1]) == 0) {
             continue;
         }
         if (!isset($rights['controller'][$controller]['name'])) {
             $rights['controller'][$controller]['name'] = str_replace('Controller', '', $controller);
             $rights['controller'][$controller]['status'] = USER_FUNC_ACTIVE;
             $update = true;
         }
         foreach ($funcs[1] as $func) {
             if (in_array($func, array('beforeFilter', 'beforeRender', 'afterFilter'))) {
                 continue;
             }
             if (!isset($rights['controller'][$controller]['action'][$func])) {
                 $rights['controller'][$controller]['action'][$func]['name'] = $func;
                 $rights['controller'][$controller]['action'][$func]['status'] = USER_FUNC_ACTIVE;
                 $update = true;
             }
         }
     }
     if ($update) {
         file_put_contents(CakePlugin::path('User') . 'Config/rights.php', "<?php\n\$rights = " . str_replace('(int) ', '', Debugger::exportVar($rights, 10)) . ';');
     }
     die;
 }
Esempio n. 13
0
    function testExportVar()
    {
        App::import('Controller');
        $Controller = new Controller();
        $Controller->helpers = array('Html', 'Form');
        $View = new View($Controller);
        $result = Debugger::exportVar($View);
        $expected = 'ViewView::$base = NULL
		View::$here = NULL
		View::$plugin = NULL
		View::$name = "[empty string]"
		View::$action = NULL
		View::$params = array()
		View::$passedArgs = array()
		View::$data = array()
		View::$helpers = array("Html","Form")
		View::$viewPath = "[empty string]"
		View::$viewVars = array()
		View::$layout = "default"
		View::$layoutPath = NULL
		View::$pageTitle = false
		View::$autoRender = true
		View::$autoLayout = true
		View::$ext = ".ctp"
		View::$subDir = NULL
		View::$themeWeb = NULL
		View::$cacheAction = false
		View::$validationErrors = array()
		View::$hasRendered = false
		View::$loaded = array()
		View::$modelScope = false
		View::$model = NULL
		View::$association = NULL
		View::$field = NULL
		View::$fieldSuffix = NULL
		View::$modelId = NULL
		View::$uuids = array()
		View::$__passedVars = array("viewVars","action","autoLayout","autoRender","ext","base","webroot","helpers","here","layout","name","pageTitle","layoutPath","viewPath","params","data","webservices","plugin","passedArgs","cacheAction")
		View::$__scripts = array()
		View::$__paths = array()
		View::$_log = NULL
		View::$webroot = NULL
		View::$webservices = NULL
		View::element()
		View::render()
		View::renderElement()
		View::renderLayout()
		View::renderCache()
		View::getVars()
		View::getVar()
		View::addScript()
		View::uuid()
		View::entity()
		View::set()
		View::error()
		View::Object()
		View::toString()
		View::requestAction()
		View::log()
		View::cakeError()';
        $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
        $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
        $this->assertEqual($result, $expected);
    }
Esempio n. 14
0
 /**
  * Handles object conversion to debug string
  *
  * @param string $var Object to convert
  * @access private
  */
 function __object($var)
 {
     static $history = array();
     $serialized = serialize($var);
     array_push($history, $serialized);
     $out = array();
     if (is_object($var)) {
         $className = get_class($var);
         $objectVars = get_object_vars($var);
         foreach ($objectVars as $key => $value) {
             $inline = null;
             if (strpos($key, '_', 0) !== 0) {
                 $inline = "{$className}::{$key} = ";
             }
             if (is_object($value) || is_array($value)) {
                 $serialized = serialize($value);
                 if (in_array($serialized, $history, true)) {
                     $value = ife(is_object($value), "*RECURSION* -> " . get_class($value), "*RECURSION*");
                 }
             }
             if (in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource', 'object', 'null'))) {
                 $out[] = "{$className}::\${$key} = " . Debugger::exportVar($value);
             } else {
                 $out[] = "{$className}::\${$key} = " . var_export($value, true);
             }
         }
         $objectMethods = get_class_methods($className);
         foreach ($objectMethods as $key => $value) {
             if (strpos($value, '_', 0) !== 0) {
                 $out[] = "{$className}::{$value}()";
             }
         }
     }
     array_pop($history);
     return join("\n", $out);
 }
Esempio n. 15
0
File: Mi.php Progetto: razzman/mi
 /**
  * Utility Exec method
  *
  * @param mixed $cmd
  * @param mixed $output
  * @return void
  * @access public
  */
 public function exec($cmd, &$out = array())
 {
     if (DS === '/') {
         $_out = exec($cmd . ' 2>&1', $out, $return);
     } else {
         $_out = exec($cmd, $out, $return);
     }
     if (Configure::read()) {
         $source = Debugger::trace(array('depth' => 1, 'start' => 2)) . "\n";
         CakeLog::write('system_calls_' . date('Y-m-d'), "\n" . $source . Debugger::exportVar(compact('cmd', 'out', 'return')));
         CakeLog::write('system_calls', "\n" . $source . Debugger::exportVar(compact('cmd', 'out', 'return')));
     }
     if ($return) {
         return false;
     }
     return $_out ? $_out : true;
 }
    /**
     * Prints out debug information about given variable.
     *
     * Only runs if debug level is greater than zero.
     *
     * @param boolean $var Variable to show debug information for.
     * @param boolean $showHtml If set to true, the method prints the debug data in a browser-friendly way.
     * @param boolean $showFrom If set to true, the method prints from where the function was called.
     * @return void
     * @link http://book.cakephp.org/2.0/en/development/debugging.html#basic-debugging
     * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#debug
     */
    function debug($var, $showHtml = null, $showFrom = true)
    {
        if (Configure::read('debug') > 0) {
            App::uses('Debugger', 'Utility');
            $file = '';
            $line = '';
            $lineInfo = '';
            if ($showFrom) {
                $trace = Debugger::trace(array('start' => 1, 'depth' => 2, 'format' => 'array'));
                $file = str_replace(array(CAKE_CORE_INCLUDE_PATH, ROOT), '', $trace[0]['file']);
                $line = $trace[0]['line'];
            }
            $html = <<<HTML
<div class="cake-debug-output">
%s
<pre class="cake-debug">
%s
</pre>
</div>
HTML;
            $text = <<<TEXT
%s
########## DEBUG ##########
%s
###########################

TEXT;
            $template = $html;
            if (php_sapi_name() === 'cli' || $showHtml === false) {
                $template = $text;
                if ($showFrom) {
                    $lineInfo = sprintf('%s (line %s)', $file, $line);
                }
            }
            if ($showHtml === null && $template !== $text) {
                $showHtml = true;
            }
            $var = Debugger::exportVar($var, 25);
            if ($showHtml) {
                $template = $html;
                $var = h($var);
                if ($showFrom) {
                    $lineInfo = sprintf('<span><strong>%s</strong> (line <strong>%s</strong>)</span>', $file, $line);
                }
            }
            printf($template, $lineInfo, $var);
        }
    }
Esempio n. 17
0
 /**
  * 
  * @return string
  */
 protected function getContents()
 {
     $log = $this;
     $auth = $log->auth;
     $mail = $log->extCakeEmail;
     $userId = self::createUserId($auth);
     $config = Debugger::exportVar($mail->getConfig(), 25);
     $from = Debugger::exportVar($mail->getFrom(), 25);
     $to = Debugger::exportVar($mail->getTo(), 25);
     $cc = Debugger::exportVar($mail->getCc(), 25);
     $bcc = Debugger::exportVar($mail->getBcc(), 25);
     $subject = Debugger::exportVar($mail->getSubject(), 25);
     $message = Debugger::exportVar($mail->getMessage(), 25);
     $error = $mail->getErrorMessage();
     $result = array('LogType : Mial Send Error', 'UserId  : ' . $userId, '--- From ---', $from, '--- To ---', $to, '--- Cc ---', $cc, '--- Bcc ---', $bcc, 'Subject : ' . $subject, '--- Message ---', $message, '--- Config ---', $config, '--- Error ---', $error, '--- End ---', '----------------------------------------------------------------------------', '----------------------------------------------------------------------------', '  ◆     ◆   ◆◆◆      ◆     ◆             ◆◆◆◆◆   ◆◆◆◆◆◆◆  ◆     ◆  ◆◆◆◆◆    ', '  ◆◆   ◆◆    ◆      ◆ ◆    ◆            ◆     ◆  ◆        ◆◆    ◆  ◆    ◆   ', '  ◆◆   ◆◆    ◆      ◆ ◆    ◆            ◆◆       ◆        ◆ ◆   ◆  ◆     ◆  ', '  ◆ ◆ ◆ ◆    ◆     ◆   ◆   ◆              ◆◆◆    ◆◆◆◆◆◆◆  ◆  ◆  ◆  ◆     ◆  ', '  ◆ ◆ ◆ ◆    ◆     ◆◆◆◆◆   ◆                 ◆◆  ◆        ◆   ◆ ◆  ◆     ◆  ', '  ◆  ◆  ◆    ◆    ◆     ◆  ◆            ◆     ◆  ◆        ◆    ◆◆  ◆    ◆   ', '  ◆  ◆  ◆   ◆◆◆   ◆     ◆  ◆◆◆◆◆◆◆       ◆◆◆◆◆   ◆◆◆◆◆◆◆  ◆     ◆  ◆◆◆◆◆    ', '----------------------------------------------------------------------------', '-----------------------------------------------', '  ◆◆◆◆◆◆◆  ◆◆◆◆◆◆   ◆◆◆◆◆◆    ◆◆◆◆◆   ◆◆◆◆◆◆   ', '  ◆        ◆     ◆  ◆     ◆  ◆     ◆  ◆     ◆  ', '  ◆        ◆     ◆  ◆     ◆  ◆     ◆  ◆     ◆  ', '  ◆◆◆◆◆◆◆  ◆◆◆◆◆◆   ◆◆◆◆◆◆   ◆     ◆  ◆◆◆◆◆◆   ', '  ◆        ◆    ◆   ◆    ◆   ◆     ◆  ◆    ◆   ', '  ◆        ◆     ◆  ◆     ◆  ◆     ◆  ◆     ◆  ', '  ◆◆◆◆◆◆◆  ◆     ◆  ◆     ◆   ◆◆◆◆◆   ◆     ◆  ', '-----------------------------------------------', '-----------------------------------------------');
     return join("\n", $result);
 }
 /**
  * testNoDbCredentials
  *
  * If a connection error occurs, the config variable is passed through exportVar
  * *** our database login credentials such that they are never visible
  *
  * @return void
  */
 public function testNoDbCredentials()
 {
     $config = array('datasource' => 'mysql', 'persistent' => false, 'host' => 'void.cakephp.org', 'login' => 'cakephp-user', 'password' => 'cakephp-password', 'database' => 'cakephp-database', 'prefix' => '');
     $output = Debugger::exportVar($config);
     $expectedArray = array('datasource' => 'mysql', 'persistent' => false, 'host' => '*****', 'login' => '*****', 'password' => '*****', 'database' => '*****', 'prefix' => '');
     $expected = Debugger::exportVar($expectedArray);
     $this->assertEquals($expected, $output);
 }
Esempio n. 19
0
 /**
  * Writes value to given session variable name.
  *
  * @param mixed $name Name of variable
  * @param string $value Value to write
  * @return boolean True if the write was successful, false if the write failed
  * @access public
  */
 function write($name, $value)
 {
     $var = $this->__validateKeys($name);
     if (empty($var)) {
         return false;
     }
     if (in_array($var, $this->watchKeys)) {
         trigger_error('Writing session key {' . $var . '}: ' . Debugger::exportVar($value), E_USER_NOTICE);
     }
     $this->__overwrite($_SESSION, Set::insert($_SESSION, $var, $value));
     return Set::extract($_SESSION, $var) === $value;
 }
Esempio n. 20
0
 /**
  * Outputs a stack trace based on the supplied options.
  *
  * ### Options
  *
  * - `depth` - The number of stack frames to return. Defaults to 999
  * - `format` - The format you want the return. Defaults to the currently selected format. If
  *    format is 'array' or 'points' the return will be an array.
  * - `args` - Should arguments for functions be shown?  If true, the arguments for each method call
  *   will be displayed.
  * - `start` - The stack frame to start generating a trace from. Defaults to 0
  *
  * @param array $options Format for outputting stack trace
  *
  * @return mixed Formatted stack trace
  * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::trace
  */
 public static function trace($options = array())
 {
     $self = Debugger::getInstance();
     $defaults = array('depth' => 999, 'format' => $self->_outputFormat, 'args' => FALSE, 'start' => 0, 'scope' => NULL, 'exclude' => array('call_user_func_array', 'trigger_error'));
     $options = Hash::merge($defaults, $options);
     $backtrace = debug_backtrace();
     $count = count($backtrace);
     $back = array();
     $_trace = array('line' => '??', 'file' => '[internal]', 'class' => NULL, 'function' => '[main]');
     for ($i = $options['start']; $i < $count && $i < $options['depth']; $i++) {
         $trace = array_merge(array('file' => '[internal]', 'line' => '??'), $backtrace[$i]);
         $signature = $reference = '[main]';
         if (isset($backtrace[$i + 1])) {
             $next = array_merge($_trace, $backtrace[$i + 1]);
             $signature = $reference = $next['function'];
             if (!empty($next['class'])) {
                 $signature = $next['class'] . '::' . $next['function'];
                 $reference = $signature . '(';
                 if ($options['args'] && isset($next['args'])) {
                     $args = array();
                     foreach ($next['args'] as $arg) {
                         $args[] = Debugger::exportVar($arg);
                     }
                     $reference .= implode(', ', $args);
                 }
                 $reference .= ')';
             }
         }
         if (in_array($signature, $options['exclude'])) {
             continue;
         }
         if ($options['format'] === 'points' && $trace['file'] !== '[internal]') {
             $back[] = array('file' => $trace['file'], 'line' => $trace['line']);
         } elseif ($options['format'] === 'array') {
             $back[] = $trace;
         } else {
             if (isset($self->_templates[$options['format']]['traceLine'])) {
                 $tpl = $self->_templates[$options['format']]['traceLine'];
             } else {
                 $tpl = $self->_templates['base']['traceLine'];
             }
             $trace['path'] = static::trimPath($trace['file']);
             $trace['reference'] = $reference;
             unset($trace['object'], $trace['args']);
             $back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
         }
     }
     if ($options['format'] === 'array' || $options['format'] === 'points') {
         return $back;
     }
     return implode("\n", $back);
 }
Esempio n. 21
0
 function __object($var)
 {
     static $history = array();
     $serialized = serialize($var);
     array_push($history, $serialized);
     echo "\n";
     if (is_object($var)) {
         $className = get_class($var);
         $objectVars = get_object_vars($var);
         foreach ($objectVars as $key => $value) {
             $value = ife(!is_object($value) && !is_array($value) && trim($value) == "", "[empty string]", $value);
             if (strpos($key, '_', 0) !== 0) {
                 echo "{$className}::{$key} = ";
             }
             if (is_object($value) || is_array($value)) {
                 $serialized = serialize($value);
                 if (in_array($serialized, $history, true)) {
                     $value = ife(is_object($value), "*RECURSION* -> " . get_class($value), "*RECURSION*");
                 }
             }
             if (in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource', 'object', 'null'))) {
                 if (is_array($value)) {
                     foreach ($value as $name => $output) {
                         if (is_numeric($name)) {
                             echo "{$output} ";
                         } else {
                             echo "{$name} => {$output} ";
                         }
                     }
                     echo "\n";
                 } else {
                     echo Debugger::exportVar($value) . "\n";
                 }
             } else {
                 echo $value . "\n";
             }
         }
         $objectMethods = get_class_methods($className);
         foreach ($objectMethods as $key => $value) {
             if (strpos($value, '_', 0) !== 0) {
                 echo "{$className}::{$value}() \n";
             }
         }
     }
     array_pop($history);
 }