public function router($resource, $arguments) { // ルート情報を表示 Debug::dump($this->request->route); // 名前付きパラメータの一覧を表示 Debug::dump($this->params()); }
function debug() { $args = func_get_args(); foreach ($args as $index => $arg) { Debug::dump($arg); } }
private function display_database_query($query) { if (Debug::is_display_database_query_enabled()) { Debug::dump($query); Debug::print_stacktrace(4); } }
/** * Debug::dump shortcut. */ function dump($var) { foreach (func_get_args() as $arg) { Debug::dump($arg); } return $var; }
public function connectTo($host, $port, $blockConnect = false) { Debug::netEvent(get_class($this) . '::' . __METHOD__ . '(' . $host . ':' . $port . ') invoked.'); $connSocket = stream_socket_client("tcp://{$host}:{$port}", $errno, $errstr, 30); //add err connect stream_set_blocking($connSocket, 0); if (!is_resource($connSocket)) { Debug::netErrorEvent(get_class($this) . ': can not add errorneus socket with address \'' . $host . ':' . $port . '\'.'); return false; } $connId = daemon::getNextSocketId(); //@todo 增加阻塞 connect , 这样可以返回 connId 的时候 socketSession 已经建立好 if ($blockConnect) { } $ev = event_new(); // why not use EV_PERSIST, is because first event is acceptEvent? if (!event_set($ev, $connSocket, EV_WRITE, array($this, 'onConnectedEvent'), array($connId))) { Debug::netErrorEvent(get_class($this) . '::' . __METHOD__ . ': can not set onAcceptEvent() on binded socket: ' . Debug::dump($connSocket)); return false; } event_base_set($ev, daemon::$eventBase); event_add($ev, 1 * 1000 * 1000); $this->checkConnSocketPool[$connId] = $connSocket; $this->checkConnEvPool[$connId] = $ev; return $connId; }
public static function inspect($obj, $die = true) { \Debug::dump($obj); if ($die) { die; } }
function dump() { $args = (array) func_get_args(); foreach ($args as $arg) { Debug::dump($arg); } }
public function action_index() { // Statusモデルから結果を取得する $results = Model_Status::find_body_by_username('foo'); // $resultsをダンプして確認する Debug::dump($results); }
/** * * Reads a file and parse the vars, then returns it as a string: * @param string $file File to parse * @param string $post Post object * @return string String with the file already parsed */ public static function ReadAndParse($file, $post = "") { if (!file_exists($file)) { Debug::error("File '{$file}' not found."); } Debug::say("Parsing and including '{$file}'"); $string = file_get_contents($file, 1024); # Date is the first: while (preg_match("/\\\$\\{(GMDATE)\\}/", $string, $aRegs)) { $string = str_replace($aRegs[0], gmdate("r"), $string); } while (preg_match("/\\\$\\{(DATE)\\}/", $string, $aRegs)) { $string = str_replace($aRegs[0], date(), $string); } # Parsing with regular expressions: # CONSTANTS ${CONSTANT}: while (preg_match("/\\\$\\{([A-Z]*)\\}/", $string, $aRegs)) { Debug::dump($aRegs); Debug::say(" Replace {$aRegs['0']} by " . constant($aRegs[1]) . "..."); Debug::say(" Constant: " . print_r($aRegs, true)); $string = str_replace($aRegs[0], constant($aRegs[1]), $string); } # Vars from post ${post:key}: if (!empty($post) and is_array($post)) { while (preg_match("/\\\$\\{post\\:([a-z_]*)\\}/", $string, $aRegs)) { Debug::dump($aRegs); Debug::say(" Replace {$aRegs['0']} by post['" . $aRegs[1] . "']..."); $string = str_replace($aRegs[0], $post[$aRegs[1]], $string); } } return $string; }
public function edit($url) { $this->load->model('admin_model', 'edit'); $data->row = $this->edit->edit($url); Debug::dump($data->row); exit; $this->template->title('Edit:' . $url)->build('admin/edit', $data); }
function process() { Debug::dump(self::config()); $layout = Responce::layout('index', 'TestBaseLayout'); $layout->title("hello, world!"); $layout->addCss('main.css'); // Debug::dump($layout); Responce::send(); }
public function test_debug_dump_normally() { $expected = ' <script type="text/javascript">function fuel_debug_toggle(a){if(document.getElementById){if(document.getElementById(a).style.display=="none"){document.getElementById(a).style.display="block"}else{document.getElementById(a).style.display="none"}}else{if(document.layers){if(document.id.display=="none"){document.id.display="block"}else{document.id.display="none"}}else{if(document.all.id.style.display=="none"){document.all.id.style.display="block"}else{document.all.id.style.display="none"}}}};</script><div class="fuelphp-dump" style="font-size: 13px;background: #EEE !important; border:1px solid #666; color: #000 !important; padding:10px;"><h1 style="border-bottom: 1px solid #CCC; padding: 0 0 5px 0; margin: 0 0 5px 0; font: bold 120% sans-serif;">COREPATH/tests/debug.php @ line: 41</h1><pre style="overflow:auto;font-size:100%;"><strong>Variable #1:</strong>' . "\n" . '<i></i> <strong></strong> (Integer): 1' . "\n\n\n" . '<strong>Variable #2:</strong>' . "\n" . '<i></i> <strong></strong> (Integer): 2' . "\n\n\n" . '<strong>Variable #3:</strong>' . "\n" . '<i></i> <strong></strong> (Integer): 3' . "\n\n\n" . '</pre></div>'; ob_start(); \Debug::dump(1, 2, 3); $output = ob_get_contents(); ob_end_clean(); $this->assertEquals($expected, $output); }
public function get_stocks() { # Where we'll get our data $url = "http://ichart.finance.yahoo.com/table.csv?s=MSFT&d=11&e=15&f=2012&g=d&a=2&b=13&c=1986&ignore=.csv"; # use cURL to ping the above URL $results = Utils::curl($url); # Convery the huge CSV string to a PHP array (http://stackoverflow.com/questions/7502370/converting-csv-to-array) $results = array_map("str_getcsv", preg_split('/\\r*\\n+|\\r+/', $results)); # Debug the results echo Debug::dump($results, ""); }
/** * Called when the worker is ready to go. * @return void */ public function onReady() { $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance(); /*$this->redis->eval("return {'a','b','c', {'d','e','f', {'g','h','i'}} }",0, function($redis) { Daemon::log(Debug::dump($redis->result)); });*/ $this->redis->subscribe('te3st', function ($redis) { Daemon::log(Debug::dump($redis->result)); }); $this->redis->psubscribe('test*', function ($redis) { Daemon::log(Debug::dump($redis->result)); }); }
private function exampleForm() { $countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other'); $sex = array('m' => 'male', 'f' => 'female'); // Step 1: Define form with validation rules $form = new Form(); // group Personal data $form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.'); $form->addText('name', 'Your name:', 35)->addRule(Form::FILLED, 'Enter your name'); $form->addText('age', 'Your age:', 5)->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %.2f to %.2f', array(9.9, 100)); $form->addRadioList('gender', 'Your gender:', $sex); $form->addText('email', 'E-mail:', 35)->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address'); // ... then check email // group Shipping address $form->addGroup('Shipping address')->setOption('embedNext', TRUE); $form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox'); // toggle div #sendBox // subgroup $form->addGroup()->setOption('container', Html::el('div')->id('sendBox')); $form->addText('street', 'Street:', 35); $form->addText('city', 'City:', 35)->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address'); $form->addSelect('country', 'Country:', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country'); // group Your account $form->addGroup('Your account'); $form->addPassword('password', 'Choose password:'******'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); $form->addPassword('password2', 'Reenter password:'******'password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']); $form->addFile('avatar', 'Picture:')->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Uploaded file is not image', 'image/*'); $form->addHidden('userid'); $form->addTextArea('note', 'Comment:', 30, 5); // group for buttons $form->addGroup(); $form->addSubmit('submit1', 'Send'); // Step 2: Check if form was submitted? if ($form->isSubmitted()) { // Step 2c: Check if form is valid if ($form->isValid()) { echo '<h2>Form was submitted and successfully validated</h2>'; $values = $form->getValues(); Debug::dump($values); // this is the end, my friend :-) if (empty($disableExit)) { exit; } } } else { // not submitted, define default values $defaults = array('name' => 'John Doe', 'userid' => 231, 'country' => 'CZ'); $form->setDefaults($defaults); } return $form; }
public function __construct($method, $param) { $this->param = new ReflectionParameter($method, $param); $this->name = $this->param->name; if ($this->param->isDefaultValueAvailable()) { $this->default = Debug::dump($this->param->getDefaultValue()); } if ($this->param->isPassedByReference()) { $this->reference = TRUE; } if ($this->param->isOptional()) { $this->optional = TRUE; } }
/** * Global setup */ public function onBeforeInit() { Requirements::css('shop_livepub/css/shoplivepub.css'); LivePubHelper::add_template_path('shop_livepub/templates/php'); if (!empty($_REQUEST['flushsessioncart']) || !empty($_REQUEST['flush'])) { $cart = ShoppingCart::curr(); if ($cart) { $cart->rebuildSessionCart(); } } if (!empty($_REQUEST['debugsessioncart'])) { Debug::dump(Session::get('Cart')); } }
public static function calCulateDistance($fromcoordinate, $tocoordinate, $decimals = 0) { // Create procedure if not exists; $exists = DB::query("SELECT IF( \n\t\t\tEXISTS (\n\t\t\t\tSELECT 1 FROM Information_schema.Routines\n\t\t\t\tWHERE SPECIFIC_NAME = 'calc_distance' \n\t\t\t\tAND ROUTINE_TYPE='FUNCTION'\n\t\t\t\t), \n\t\t\t'function exists', 'not found')"); // Debug::dump($exists->numRecords( )); if (array_shift($exists->first()) == 'not found') { Debug::dump('DEFINING'); DB::query("CREATE FUNCTION calc_distance \n\t\t\t\t\t(lat1 DECIMAL(10,6), long1 DECIMAL(10,6), lat2 DECIMAL(10,6), long2 DECIMAL(10,6))\n\t\t\t\t\tRETURNS DECIMAL(10,6)\n\t\t\t\t\tRETURN (6353 * 2 * ASIN(SQRT( \n\t\t\t\t\t\t\tPOWER(SIN((lat1 - abs(lat2)) * pi()/180 / 2),2) + COS(lat1 * pi()/180 ) \n\t\t\t\t\t\t\t* COS( abs(lat2) * pi()/180) * POWER(SIN((long1 - long2) * pi()/180 / 2), {$decimals}) \n\t\t\t\t\t\t)))"); } $query_result = DB::query("SELECT ROUND(calc_distance({$fromcoordinate},{$tocoordinate}), 0)"); $result = array_shift($query_result->first()); // Debug::dump("Distance between Eiffel Tower (48.858278,2.294254) and Big Ben (51.500705,-0.124575) // ".DB::query("SELECT ROUND(calc_distance(51.500705,-0.124575,48.858278,2.294254), 2)")." KM"); //Debug::dump("Distance Eiffel Tower (48.858278,2.294254) - Big Ben (51.500705,-0.124575): $result KM"); return $result; }
/** * Init the controller and execute the action * * @param $route * @return int */ private function renderAction($route) { //loads the class from matched route try { //create a instance of controller $class = $this->loadControllerClass($route['route']['Module'], $route['route']['Controller']); //execute the action ob_start(); $viewClass = $class->{$route['route']['Action'] . 'Action'}(); Application::$action = ob_get_clean(); } catch (\Exception $e) { echo $e->getCode() . ' - ' . $e->getMessage(); Debug::dump($e->getTraceAsString()); exit; } return isset($viewClass) ? $viewClass->getRenderType() : View::HTML; }
public static function logError($error_msg, $data) { $output = '<tr class="error"><td valign="top>' . time() . '</td><td valign="top">' . $error_msg . '</td><td valign="top" colspan="2">' . Debug::dump($data, 'Attached Data') . '</td></tr>'; $output .= '<tr class="trace"><td colspan="3">'; $trace = debug_backtrace(); $lines = array(); foreach ($trace as $index => $line) { $lines[] = '#' . (count($trace) - 1 - $index) . ' ' . $line['function'] . '(' . Debug::serializeArgs($line['args']) . ');'; } $output .= join('<br>', $lines) . '</td><td>'; $lines = array(); foreach ($trace as $index => $line) { $lines[] = 'in ' . Arrays::get($line, 'file', '[Unknown]') . ':' . Arrays::get($line, 'line', '[Unknown]'); } $output .= join('<br>', $lines) . '</td></tr>'; file_put_contents(dirname(__FILE__) . '/../../internal_errors.inc', $output, FILE_APPEND); }
public function users() { # Set up the view $this->template->content = View::instance("v_posts_users"); # Grab all the users $q = "SELECT * \n\t\t\tFROM users"; $users = DB::instance(DB_NAME)->select_rows($q); # Figure out the connections $q = "SELECT * \n\t\t\tFROM users_users \n\t\t\tWHERE user_id = " . $this->user->user_id; $connections = DB::instance(DB_NAME)->select_array($q, 'user_id_followed'); echo Debug::dump($connections, "connections"); # Pass data to the view $this->template->content->connections = $connections; $this->template->content->users = $users; # Render the view echo $this->template; }
protected function bindSocket($addr, $port) { $bindSocket = stream_socket_server("tcp://{$addr}:{$port}", $errno, $errstr); stream_set_blocking($bindSocket, 0); if (!is_resource($bindSocket)) { Debug::netErrorEvent(get_class($this) . ': can not add error socket with address \'' . $addr . ':' . $port . '\'.'); return false; } $socketId = daemon::getNextSocketId(); $ev = event_new(); // why not use EV_PERSIST, is because first event is acceptEvent? if (!event_set($ev, $bindSocket, EV_READ, array($this, 'onAcceptEvent'), array($socketId))) { Debug::netErrorEvent(get_class($this) . '::' . __METHOD__ . ': can not set onAcceptEvent() on binded socket: ' . Debug::dump($bindSocket)); return false; } $this->bindSocketEvPool[$socketId] = $ev; $this->bindSocketPool[$socketId] = $bindSocket; event_base_set($ev, daemon::$eventBase); event_add($ev); }
function run($request) { $intercom = Injector::inst()->get('Sminnee\\SilverStripeIntercom\\Intercom'); if ($jobID = $request->getVar('JobID')) { $job = $intercom->getBulkJob($request->getVar('JobID')); Debug::dump($job->getInfo()); Debug::dump($job->getErrors()); } else { $members = $intercom->getUserList(); echo "<li>" . implode("</li>\n<li>", $members->column('Email')), "</li>\n"; $result = $intercom->bulkLoadUsers($members); $jobID = $result->getID(); if (Director::is_cli()) { echo "Job id {$jobID}\n"; echo "To see status, run: sake dev/tasks/IntercomBulkLoadTask JobID={$jobID}\n"; } else { echo "<p>Job id {$jobID}</p>\n"; echo "<p><a href=\"" . Director::absoluteURL('dev/tasks/IntercomBulkLoadTask?JobID=' . urlencode($jobID)) . "\">Click here to see job status</a></p>"; } } }
<?php require_once '../../Nette/loader.php'; /*use Nette\Caching\Cache;*/ /*use Nette\Debug;*/ // key and data with special chars $key = 'nette'; $value = '"Hello World"'; $cache = new Cache(new DummyStorage(), 'myspace'); echo "Is cached?\n"; Debug::dump(isset($cache[$key])); echo "Cache content:\n"; Debug::dump($cache[$key]); echo "Writing cache...\n"; $cache[$key] = $value; $cache->release(); echo "Is cached?\n"; Debug::dump(isset($cache[$key])); echo "Is cache ok?\n"; Debug::dump($cache[$key] === $value); echo "Removing from cache using unset()...\n"; unset($cache[$key]); $cache->release(); echo "Is cached?\n"; Debug::dump(isset($cache[$key])); $cache[$key] = $value; echo "Removing from cache using set NULL...\n"; $cache[$key] = NULL; $cache->release(); echo "Is cached?\n"; Debug::dump(isset($cache[$key]));
/** * Delete all usage statistics, or the usage statistics for an API. * * @param string $api The API to delete the usage statistics for, or leave it empty to remove everything */ public static function delete_usage($api = null) { // Delete everything if (empty($api)) { \Cache::delete('account.' . \Session::get('consumer_key') . 'usage'); /* * Remove the reset time from the DB so that we aren't always resetting it. * Free account don't pay (obviously), so we set their reset timer to 30 days * from now. */ $account_data = \V1\Model\Account::get_account(); $time = null; if ($account_data['access_level'] === 1) { $time = time() + (int) \Config::get('tiers.free.reset_period', 30) * 24 * 60 * 60; } \Debug::dump($time); \V1\Model\Account::set_reset_usage($time); } else { try { // If we have an entry for the API, then delete it. $usage = \Cache::get('account.' . \Session::get('consumer_key') . 'usage'); if (isset($usage[$api])) { unset($usage[$api]); } // Set it without the value for the chosen API. \Cache::set('account.' . \Session::get('consumer_key') . 'usage', $usage); } catch (\CacheNotFoundException $e) { } } }
'avatar' => 0, ), 'size' => array( 'avatar' => 3013, ), ), ); */ // invalid #1 $_POST = array('name' => array(NULL), 'note' => array(NULL), 'gender' => array(NULL), 'send' => array(NULL), 'country' => array(NULL), 'countrym' => '', 'password' => array(NULL), 'firstperson' => TRUE, 'secondperson' => array('age' => array(NULL)), 'submit1' => array(NULL), 'userid' => array(NULL)); $_FILES = array('avatar' => array('name' => 'readme.txt', 'type' => 'text/plain'), 'secondperson' => array('name' => array(NULL), 'type' => array(NULL), 'tmp_name' => array(NULL), 'error' => array(NULL), 'size' => array(NULL))); echo "<h2>Invalid data #1</h2>\n"; echo "Submitted?\n"; $dolly = clone $form; Environment::getHttpRequest()->initialize(); Debug::dump(gettype($dolly->isSubmitted())); echo "Values:\n"; Debug::dump($dolly->getValues()); // invalid #2 $_POST = array('name' => "invalidªªªutf", 'note' => "invalidªªªutf", 'userid' => "invalidªªªutf", 'secondperson' => array(NULL)); $tmp = array('name' => 'readme.txt', 'type' => 'text/plain', 'tmp_name' => 'C:\\PHP\\temp\\php1D5B.tmp', 'error' => 0, 'size' => 209); $_FILES = array('name' => $tmp, 'note' => $tmp, 'gender' => $tmp, 'send' => $tmp, 'country' => $tmp, 'countrym' => $tmp, 'password' => $tmp, 'firstperson' => $tmp, 'secondperson' => array('age' => $tmp), 'submit1' => $tmp, 'userid' => $tmp); echo "<h2>Invalid data #2</h2>\n"; echo "Submitted?\n"; $dolly = clone $form; Environment::getHttpRequest()->initialize(); Debug::dump(gettype($dolly->isSubmitted())); echo "Values:\n"; Debug::dump($dolly->getValues());
/** * Replace the existing filter (ON clause) on a join */ public function setJoinFilter($tableAlias, $filter) { if(is_string($this->from[$tableAlias])) {Debug::message($tableAlias); Debug::dump($this->from);} $this->from[$tableAlias]['filter'] = array($filter); }
$config->save('tmp/cfg.ini', 'mysection'); readfile('tmp/cfg.ini'); echo "\n"; echo "Load section from INI\n"; $config = Config::fromFile('config1.ini', 'development', NULL); Debug::dump($config); echo "Save INI\n"; $config->display_errors = true; $config->html_errors = false; $config->save('tmp/cfg.ini', 'mysection'); readfile('tmp/cfg.ini'); echo "\n"; try { echo "check read-only:\n"; $config->freeze(); $config->database->adapter = 'new value'; } catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } echo "check read-only clone:\n"; $dolly = clone $config; $dolly->database->adapter = 'works good'; Debug::dump($dolly->database->adapter); Debug::dump($config->database->adapter); unset($dolly); echo "check read-only clone II:\n"; $dolly = unserialize(serialize($config)); $dolly->database->adapter = 'works good'; Debug::dump($dolly->database->adapter); Debug::dump($config->database->adapter); unset($dolly);
?> </a></h3> <div id="<?php echo $env_id; ?> " class="collapsed"> <table cellspacing="0"> <?php foreach ($GLOBALS[$var] as $key => $value) { ?> <tr> <td><code><?php echo htmlspecialchars((string) $key, ENT_QUOTES, Kohana::$charset, true); ?> </code></td> <td><pre><?php echo Debug::dump($value); ?> </pre></td> </tr> <?php } ?> </table> </div> <?php } ?> </div> </div>
?> <br /> "cache_dir" = <?php echo Debug::dump(Kohana::$cache_dir); ?> <br /> "errors" = <?php echo Debug::dump(Kohana::$errors); ?> <br /> "profile" = <?php echo Debug::dump(Kohana::$profiling); ?> <br /> "caching" = <?php echo Debug::dump(Kohana::$caching); ?> </code></td> </tr> </table> <h2>Loaded Modules</h2> <?php if (count(Kohana::modules()) > 0) { ?> <table cellspacing="0"> <?php foreach (Kohana::modules() as $module => $path) { ?> <tr>