public function action_index() { if (!file_exists(DOCROOT . $this->sitemap_directory_base)) { throw new HTTP_Exception_404(); } $this->site_code = ORM::factory('site', $this->request->site_id)->code; $this->sitemap_directory = $this->sitemap_directory_base . DIRECTORY_SEPARATOR . $this->site_code; $this->response->headers('Content-Type', 'text/xml')->headers('cache-control', 'max-age=0, must-revalidate, public')->headers('expires', gmdate('D, d M Y H:i:s', time()) . ' GMT'); try { $dir = new DirectoryIterator(DOCROOT . $this->sitemap_directory); $xml = new DOMDocument('1.0', Kohana::$charset); $xml->formatOutput = TRUE; $root = $xml->createElement('sitemapindex'); $root->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $xml->appendChild($root); foreach ($dir as $fileinfo) { if ($fileinfo->isDot() or $fileinfo->isDir()) { continue; } $_file_path = str_replace(DOCROOT, '', $fileinfo->getPathName()); $_file_url = $this->domain . '/' . str_replace(DIRECTORY_SEPARATOR, '/', $_file_path); $sitemap = $xml->createElement('sitemap'); $root->appendChild($sitemap); $sitemap->appendChild(new DOMElement('loc', $_file_url)); $_last_mod = Sitemap::date_format($fileinfo->getCTime()); $sitemap->appendChild(new DOMElement('lastmod', $_last_mod)); } } catch (Exception $e) { echo Debug::vars($e->getMessage()); die; } echo $xml->saveXML(); }
/** * Loads a class and uses [reflection](http://php.net/reflection) to parse * the class. Reads the class modifiers, constants and comment. Parses the * comment to find the description and tags. * * @param string class name * @return void */ public function __construct($class) { $this->class = new ReflectionClass($class); if ($modifiers = $this->class->getModifiers()) { $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> '; } if ($constants = $this->class->getConstants()) { foreach ($constants as $name => $value) { $this->constants[$name] = Debug::vars($value); } } $parent = $this->class; do { if ($comment = $parent->getDocComment()) { // Found a description for this class break; } } while ($parent = $parent->getParentClass()); list($this->description, $this->tags) = Kodoc::parse($comment); // If this class extends Kodoc_Missing, add a warning about possible // incomplete documentation $parent = $this->class; while ($parent = $parent->getParentClass()) { if ($parent->name == 'Kodoc_Missing') { $warning = "[!!] **This class, or a class parent, could not be\n\t\t\t\t found or loaded. This could be caused by a missing\n\t\t\t\t\t\t module or other dependancy. The documentation for\n\t\t\t\t\t\t class may not be complete!**"; $this->description = Markdown($warning) . $this->description; } } }
public function __construct($class, $property) { $property = new ReflectionProperty($class, $property); list($description, $tags) = Kodoc::parse($property->getDocComment()); $this->description = $description; if ($modifiers = $property->getModifiers()) { $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> '; } if (isset($tags['var'])) { if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) { $this->type = $matches[1]; if (isset($matches[2])) { $this->description = Markdown($matches[2]); } } } $this->property = $property; // Show the value of static properties, but only if they are public or we are php 5.3 or higher and can force them to be accessible if ($property->isStatic() and ($property->isPublic() or version_compare(PHP_VERSION, '5.3', '>='))) { // Force the property to be accessible if (version_compare(PHP_VERSION, '5.3', '>=')) { $property->setAccessible(TRUE); } // Don't debug the entire object, just say what kind of object it is if (is_object($property->getValue($class))) { $this->value = '<pre>object ' . get_class($property->getValue($class)) . '()</pre>'; } else { $this->value = Debug::vars($property->getValue($class)); } } }
public function find_product_url($product_name) { $url = 'http://ek.ua/'; $data = array('search_' => $product_name); $response = Request::factory($url)->query($data)->execute(); //echo Debug::vars($response->body()); //echo Debug::vars($response->headers()); $response = $response->body(); try { $doc = phpQuery::newDocument($response); } catch (Exception $ex) { $errors[] = $ex->getMessage(); echo Debug::vars($errors); } if (!isset($errors)) { /* Нужно взять заголовок и найти в нем слово найдено */ /* * что я заметил, удивительно но на разных машинах этот заголовои идет с разным классом * на данный момент этот класс oth */ $str = $doc->find('h1.oth')->html(); if (preg_match('/найдено/', $str)) { echo Debug::vars('алилуя !!!'); die; } return $str; } }
/** * * @return array */ public function validate_authorize_params() { $request_params = $this->_get_authorize_params(); $validation = Validation::factory($request_params)->rule('client_id', 'not_empty')->rule('client_id', 'uuid::valid')->rule('response_type', 'not_empty')->rule('response_type', 'in_array', array(':value', OAuth2::$supported_response_types))->rule('scope', 'in_array', array(':value', OAuth2::$supported_scopes))->rule('redirect_uri', 'url'); if (!$validation->check()) { throw new OAuth2_Exception_InvalidRequest("Invalid Request: " . Debug::vars($validation->errors())); } // Check we have a valid client $client = Model_OAuth2_Client::find_client($request_params['client_id']); if (!$client->loaded()) { throw new OAuth2_Exception_InvalidClient('Invalid client'); } // Lookup the redirect_uri if none was supplied in the URL if (!Valid::url($request_params['redirect_uri'])) { $request_params['redirect_uri'] = $client->redirect_uri; // Is the redirect_uri still empty? Error if so.. if (!Valid::url($request_params['redirect_uri'])) { throw new OAuth2_Exception_InvalidRequest('\'redirect_uri\' is required'); } } else { if ($client->redirect_uri != $request_params['redirect_uri']) { throw new OAuth2_Exception_InvalidGrant('redirect_uri mismatch'); } } // Check if this client is allowed use this response_type if (!in_array($request_params['response_type'], $client->allowed_response_types())) { throw new OAuth2_Exception_UnauthorizedClient('You are not allowed use the \':response_type\' response_type', array(':response_type' => $request_params['response_type'])); } return $request_params; }
/** * Gets the constants of this class as HTML. * * @return array */ public function constants() { $result = array(); foreach ($this->constants as $name => $value) { $result[$name] = Debug::vars($value); } return $result; }
function sort_array_by_keys(array $unsorted, array $sortKeys) { if (count($unsorted) != count($sortKeys)) { echo Debug::vars($unsorted); exit; } $sorted = []; foreach ($sortKeys as $key => $value) { $sorted[$key] = str_replace(",", ";", $unsorted[$key]); } return $sorted; }
private function _get_from_files() { $validation = Validation::factory($_FILES, 'uploads'); $validation->rule('file', 'Upload::not_empty')->rule('file', 'Upload::type', array(':value', array('csv'))); if ($validation->check()) { $this->hash = md5(time()); Upload::save($_FILES['file'], $this->hash, sys_get_temp_dir()); } else { foreach ($validation->errors() as $err) { switch ($err[0]) { case 'Upload::not_empty': throw new Kohana_Exception('You did not choose a file to upload!'); case 'Upload::type': throw new Kohana_Exception('You can only import CSV files.'); default: throw new Kohana_Exception('An error occured.<br />' . Debug::vars($err)); } } } }
public function action_registration() { if ($post = $this->request->post()) { try { // Сохраняем пользователя в БД $user = ORM::factory('user'); $user->values($this->request->post(), array('username', 'password', 'email')); $extra_rules = Validation::factory($this->request->post())->rule('password_confirm', 'matches', array(':validation', ':field', 'password')); $user->save($extra_rules); // Выставляем ему роль, роль login означает что пользователь может авторизоваться $user->add('roles', ORM::factory('role', array('name' => 'login'))); // Отправляем письмо пользователю с логином и паролем mail($post['email'], 'Регистрация на сайте SiteName', 'Вы были зерегестрированы на сайте SiteName, ваш логин: ' . $post['username'] . ' Ваш пароль: ' . $post['password']); // Делаем редирект на страницу авторизации $this->redirect("/users/login"); } catch (ORM_Validtion_Exception $e) { // $errors = $e->errors('models'); echo Debug::vars($errors); } } // Выводим шаблон регистрации $this->template->title = 'Регистраця'; $this->template->content = View::factory('elements/registration_form'); }
public function action_test() { echo Debug::vars(gd_info()); }
public function action_checkdupes() { $events = ORM::factory("game_EventLog")->where('event_id', '=', 14)->find_all(); $used = array(); $this->template->content = "<h3>Possible Duplicates</h3>"; foreach ($events as $event) { $search = array_search($event->id, $used); if ($search === false) { $used[] = $event->id; } else { $this->template->content .= print_r($search, true) . " " . $event->id . "<br />"; } } echo Debug::vars("---------Users Checked-------", $used); }
protected static function render_field(Jam_Model $item, Jam_Field $field) { $value = $item->{$field->name}; if ($field instanceof Jam_Field_Integer) { return HTML::chars(number_format($value)); } elseif ($field instanceof Jam_Field_Float) { return HTML::chars(number_format($value, 2)); } elseif ($field instanceof Jam_Field_Boolean) { return $value ? '<i class="icon-ok"></i>' : ''; } elseif ($field instanceof Jam_Field_Serialized) { return Debug::vars($value); } elseif ($field instanceof Jam_Field_Timestamp) { if (!$value) { return '-'; } $time = is_numeric($value) ? $value : strtotime($value); return '<span title="' . date('j M Y H:i:s', $time) . '">' . Tart_Html::date_span($time) . '</span>'; } elseif ($field instanceof Jam_Field_Weblink) { return Text::limit_chars(HTML::chars($value), 30) . ' ' . HTML::anchor($value, '<i class="icon-share-alt"></i>'); } elseif ($field instanceof Jam_Field_Text) { return Text::widont(Text::limit_chars(HTML::chars($value), 40)); } elseif ($field instanceof Jam_Field_Upload) { return HTML::image($value->url(TRUE), array('class' => 'img-polaroid', 'alt' => $item->name())); } else { return HTML::chars($value); } }
public function action_demo13() { $user = Mango::factory('user', array('role' => 'viewer', 'email' => '*****@*****.**'))->create(); $group = Mango::factory('group', array('name' => 'wouter'))->create(); $user->add($group, 'circle'); echo Debug::vars($user->changed(TRUE), $group->changed(TRUE)); $user->update(); $group->update(); $group->reload(); $user->reload(); foreach ($group->users as $user) { echo Debug::vars($user->as_array(FALSE)); } foreach ($user->circles as $circle) { echo Debug::vars($circle->as_array(FALSE)); } $group->remove($user); echo Debug::vars($user->changed(TRUE), $group->changed(TRUE)); $user->delete(); $group->delete(); }
<h1>I18n Dump</h1> <?php foreach ($i18n as $path => $name) { echo "<h3>{$path}</h3>"; try { echo Debug::vars(I18n::load($name)); } catch (exception $e) { echo "Something went terribly wrong. Error message: " . Kohana::exception_text($e); } }
public static function debug($value) { return Debug::vars($value); }
echo '<img src="' . $value . '" class="img-thumbnail">'; } elseif (filter_var($value, FILTER_VALIDATE_EMAIL)) { echo '<a href="mailto:' . $value . '">' . $value . '</a>'; } elseif (filter_var($value, FILTER_VALIDATE_URL)) { echo '<a href="' . $value . '" target="_blank">' . $value . '</a>'; } else { echo $value; } echo '</td>'; echo '</tr>'; } // Show dump of raw data echo '<tr>'; echo '<td><strong>raw</strong></td>'; echo '<td>'; echo Debug::vars($raw); echo '</td>'; echo '</tr>'; ?> </tbody> </table> <div class="page-header" style="border-bottom: none;"> <div class="row"> <a href="<?php echo URL::site(Route::get('kopauth')->uri()); ?> " class="btn btn-default">Return to Providers</a> </div> </div>
/** * Determine if the field's value has changed * * @access public * @return boolean */ public function is_changed() { $value = $this->_field->get('value'); $new_value = $this->_field->get('new_value'); echo Debug::vars($value, $new_value); if (!$this->val_isset()) { return FALSE; } return $value != $new_value; }
echo isset($_FILES) ? Debug::vars($_FILES) : Debug::vars(array()); ?> </div> <div style="display: none;" id="vars-server"> <?php echo isset($_SERVER) ? Debug::vars($_SERVER) : Debug::vars(array()); ?> </div> <div style="display: none;" id="vars-cookie"> <?php echo isset($_COOKIE) ? Debug::vars($_COOKIE) : Debug::vars(array()); ?> </div> <div style="display: none;" id="vars-session"> <?php echo isset($_SESSION) ? Debug::vars($_SESSION) : Debug::vars(array()); ?> </div> </div> <?php } ?> <!-- Ajax Requests --> <?php if (Kohana::$config->load('debug_toolbar.panels.ajax')) { ?> <div id="debug-ajax" class="top" style="display:none;"> <h1>Ajax</h1> <table cellspacing="0" cellpadding="0"> <tr align="left">
public function demo_user_followers() { if ($this->request->method() === 'POST') { // Get the screen name and account id from POST $params = Arr::extract($_POST, array('screen_name', 'account_id')); if (!$params) { // No parameters included $this->request->redirect($this->request->uri()); } $api = Twitter::factory('user'); $response = $api->followers($this->consumer, $this->token, $params); $this->content = Debug::vars($response); } else { $this->content = View::factory('demo/form')->set('message', 'Enter an account ID or screen name.')->set('inputs', array('Screen Name' => Form::input('screen_name'), 'Account ID' => Form::input('acount_id'))); } }
/** * Set a single variable for a set of fields * * @access public * @param mixed $var * @param array $array * @param boolean $not_recursive (default: TRUE) * @return void */ public function set_var_fields($var, array $array, $not_recursive = TRUE) { foreach ($array as $alias => $val) { if ($alias === '*') { foreach ($this->_fields as $field) { echo \Debug::vars($var, $val); $field->set($var, $val); } continue; } $field = $this->find($alias, $not_recursive); if (!$field) { continue; } $field->set($var, $val); } return $this; }
<h1>Config Dump</h1> <?php foreach ($configs as $path => $name) { echo "<h3>{$path}</h3>"; try { echo Debug::vars(Kohana::$config->load($name)); } catch (exception $e) { echo "Something went terribly wrong. This is usually caused by\n\t\t undefined constants because of missing dependancies. Error\n\t\t\t message: " . Kohana::exception_text($e); } }
<?php defined('SYSPATH') or die('No direct script access.'); echo Debug::vars($errors); echo FORM::open($url); ?> <fieldset> <legend>Параметры страницы</legend> <div class="clearfix"> <label>Город</label> <div class="input"> <span class="uneditable-input"><?php echo $city; ?> </span> </div> </div> <div class="clearfix"> <label>Тип:</label> <div class="input"> <span class="uneditable-input"> <?php echo $type; ?> </span> </div> </div> </fieldset> <h3>Текст</h3> <div class="clearfix"> <?php echo FORM::textarea('text', $values['text'], array('id' => 'text'));
public function action_index() { $model = Model::factory('Parser'); $product_name = 'Кентавр СП 224'; echo Debug::vars($model->find_product_url($product_name)); }
/** * Validates the current model's data * * @param Validation $extra_validation Validation object * @throws ORM_Validation_Exception * @return ORM */ public function check(Validation $extra_validation = NULL) { // Determine if any external validation failed $extra_errors = ($extra_validation and !$extra_validation->check()); // Always build a new validation object $this->_validation(); $array = $this->_validation; if (($this->_valid = $array->check()) === FALSE or $extra_errors) { die(Debug::vars($array->errors())); $exception = new ORM_Validation_Exception($this->errors_filename(), $array); if ($extra_errors) { // Merge any possible errors from the external object $exception->add_object('_external', $extra_validation); } throw $exception; } return $this; }
/** * Nicely outputs contents of $this->items for debugging info * * @return string */ public function debug() { return Debug::vars($this->items); }
/** * Tests Debug::vars() * * @test * @dataProvider provider_vars * @covers Debug::vars * @param boolean $thing The thing to debug * @param boolean $expected Output for Debug::vars */ public function test_var($thing, $expected) { $this->assertEquals($expected, Debug::vars($thing)); }
function debug($var, $die = TRUE) { echo Debug::vars($var); if ($die) { die; } }
/** * Nicely outputs contents of $this->_widgets for debugging info * * @return string */ public function debug() { return Debug::vars($this->_widgets); }
<dd><?php echo Form::input('key', $key); ?> </dd> <dt>New Value</dt> <dd><?php echo Form::input('value', $value); ?> </dd> </dl> </p> <button type="submit">Change Config</button> </form> <?php if (isset($key)) { ?> <p>Changed the value of <tt><?php echo HTML::chars($key); ?> </tt>:<br/> <?php echo Debug::vars($before); ?> <?php echo Debug::vars($after); ?> </p> <?php }
<div style="display: none;" id="vars-post"> <?php echo Debug::vars(Debugger::get_post()); ?> </div> <div style="display: none;" id="vars-get"> <?php echo Debug::vars(Debugger::get_query()); ?> </div> <div style="display: none;" id="vars-files"> <?php echo isset($_FILES) ? Debug::vars($_FILES) : Debug::vars(array()); ?> </div> <div style="display: none;" id="vars-server"> <?php echo isset($_SERVER) ? Debug::vars($_SERVER) : Debug::vars(array()); ?> </div> <div style="display: none;" id="vars-cookie"> <?php echo Session::instance()->as_array(); ?> </div> <div style="display: none;" id="vars-session"> <?php echo Debug::vars(Debugger::get_session()); ?> </div> </div>