/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Cache
/Cache.php
if (!static::isInitialized($config)) {
return false;
}
$key = static::$_engines[$config]->key($key);
if (!$key || is_resource($value)) {
return false;
}
$success = static::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']);
static::set(null, $config);
if ($success === false && $value !== '') {
trigger_error(
__d('cake_dev',
"%s cache was unable to write '%s' to %s cache",
$config,
$key,
static::$_engines[$config]->settings['engine']
),
E_USER_WARNING
);
}
return $success;
}
/**
* Read a key from a cache config.
*
* ### Usage:
*
* Reading from the active cache configuration.
*
* `Cache::read('my_data');`
*
* Reading from a specific cache configuration.
*
* `Cache::read('my_data', 'long_term');`
*
* @param string $key Identifier for the data
* @param string $config optional name of the configuration to use. Defaults to 'default'
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Cache
/Cache.php
if (!static::isInitialized($config)) {
return false;
}
$key = static::$_engines[$config]->key($key);
if (!$key || is_resource($value)) {
return false;
}
$success = static::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']);
static::set(null, $config);
if ($success === false && $value !== '') {
trigger_error(
__d('cake_dev',
"%s cache was unable to write '%s' to %s cache",
$config,
$key,
static::$_engines[$config]->settings['engine']
),
E_USER_WARNING
);
}
return $success;
}
/**
* Read a key from a cache config.
*
* ### Usage:
*
* Reading from the active cache configuration.
*
* `Cache::read('my_data');`
*
* Reading from a specific cache configuration.
*
* `Cache::read('my_data', 'long_term');`
*
* @param string $key Identifier for the data
* @param string $config optional name of the configuration to use. Defaults to 'default'
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Model
/Datasource
/DataSource.php
*
* @param mixed $data Unused in this class.
* @return array|null Array of sources available in this datasource.
*/
public function listSources($data = null) {
if ($this->cacheSources === false) {
return null;
}
if ($this->_sources !== null) {
return $this->_sources;
}
$key = ConnectionManager::getSourceName($this) . '_' . $this->config['database'] . '_list';
$key = preg_replace('/[^A-Za-z0-9_\-.+]/', '_', $key);
$sources = Cache::read($key, '_cake_model_');
if (empty($sources)) {
$sources = $data;
Cache::write($key, $data, '_cake_model_');
}
return $this->_sources = $sources;
}
/**
* Returns a Model description (metadata) or null if none found.
*
* @param Model|string $model The model to describe.
* @return array|null Array of Metadata for the $model
*/
public function describe($model) {
if ($this->cacheSources === false) {
return null;
}
if (is_string($model)) {
$table = $model;
} else {
$table = $model->tablePrefix . $model->table;
}
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Model
/Datasource
/Database
/Mysql.php
return $this->connected;
}
/**
* Check whether the MySQL extension is installed/loaded
*
* @return bool
*/
public function enabled() {
return in_array('mysql', PDO::getAvailableDrivers());
}
/**
* Returns an array of sources (tables) in the database.
*
* @param mixed $data List of tables.
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
if ($cache) {
return $cache;
}
$result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']));
if (!$result) {
$result->closeCursor();
return array();
}
$tables = array();
while ($line = $result->fetch(PDO::FETCH_NUM)) {
$tables[] = $line[0];
}
$result->closeCursor();
parent::listSources($tables);
return $tables;
}
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Model
/Model.php
$assoc['dynamicWith'] = true;
}
}
}
/**
* Sets a custom table for your model class. Used by your controller to select a database table.
*
* @param string $tableName Name of the custom table
* @throws MissingTableException when database table $tableName is not found on data source
* @return void
*/
public function setSource($tableName) {
$this->setDataSource($this->useDbConfig);
$db = ConnectionManager::getDataSource($this->useDbConfig);
if (method_exists($db, 'listSources')) {
$restore = $db->cacheSources;
$db->cacheSources = ($restore && $this->cacheSources);
$sources = $db->listSources();
$db->cacheSources = $restore;
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
throw new MissingTableException(array(
'table' => $this->tablePrefix . $tableName,
'class' => $this->alias,
'ds' => $this->useDbConfig,
));
}
if ($sources) {
$this->_schema = null;
}
}
$this->table = $this->useTable = $tableName;
$this->tableToModel[$this->table] = $this->alias;
}
/**
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Model
/Model.php
$this->tablePrefix = $db->config['prefix'];
}
$schema = $db->getSchemaName();
$defaultProperties = get_class_vars(get_class($this));
if (isset($defaultProperties['schemaName'])) {
$schema = $defaultProperties['schemaName'];
}
$this->schemaName = $schema;
}
/**
* Gets the DataSource to which this model is bound.
*
* @return DataSource A DataSource object
*/
public function getDataSource() {
if (!$this->_sourceConfigured && $this->useTable !== false) {
$this->_sourceConfigured = true;
$this->setSource($this->useTable);
}
return ConnectionManager::getDataSource($this->useDbConfig);
}
/**
* Get associations
*
* @return array
*/
public function associations() {
return $this->_associations;
}
/**
* Gets all the models with which this model is associated.
*
* @param string $type Only result associations of this type
* @return array|null Associations
*/
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Model
/Model.php
$date[$index] = sprintf('%02d', $date[$index]);
}
}
return str_replace(array_keys($date), array_values($date), $format);
}
return $data;
}
/**
* Returns an array of table metadata (column names and types) from the database.
* $field => keys(type, null, default, key, length, extra)
*
* @param bool|string $field Set to true to reload schema, or a string to return a specific field
* @return array|null Array of table metadata
*/
public function schema($field = false) {
if ($this->useTable !== false && (!is_array($this->_schema) || $field === true)) {
$db = $this->getDataSource();
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
if (method_exists($db, 'describe')) {
$this->_schema = $db->describe($this);
}
}
if (!is_string($field)) {
return $this->_schema;
}
if (isset($this->_schema[$field])) {
return $this->_schema[$field];
}
return null;
}
/**
* Returns an associative array of field names and column types.
*
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/View
/Helper
/FormHelper.php
* `$this->_introspectModel('Post', 'fields', 'title');` will return the schema information for title column
*
* @param string $model name of the model to extract information from
* @param string $key name of the special information key to obtain (key, fields, validates, errors)
* @param string $field name of the model field to get information from
* @return mixed information extracted for the special key and field in a model
*/
protected function _introspectModel($model, $key, $field = null) {
$object = $this->_getModel($model);
if (!$object) {
return null;
}
if ($key === 'key') {
return $this->fieldset[$model]['key'] = $object->primaryKey;
}
if ($key === 'fields') {
if (!isset($this->fieldset[$model]['fields'])) {
$this->fieldset[$model]['fields'] = $object->schema();
foreach ($object->hasAndBelongsToMany as $alias => $assocData) {
$this->fieldset[$object->alias]['fields'][$alias] = array('type' => 'multiple');
}
}
if ($field === null || $field === false) {
return $this->fieldset[$model]['fields'];
} elseif (isset($this->fieldset[$model]['fields'][$field])) {
return $this->fieldset[$model]['fields'][$field];
}
return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null;
}
if ($key === 'errors' && !isset($this->validationErrors[$model])) {
$this->validationErrors[$model] =& $object->validationErrors;
return $this->validationErrors[$model];
} elseif ($key === 'errors' && isset($this->validationErrors[$model])) {
return $this->validationErrors[$model];
}
if ($key === 'validates' && !isset($this->fieldset[$model]['validates'])) {
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/View
/Helper
/FormHelper.php
if (!empty($options['encoding'])) {
$htmlAttributes['accept-charset'] = $options['encoding'];
unset($options['encoding']);
}
$htmlAttributes = array_merge($options, $htmlAttributes);
$this->fields = array();
if ($this->requestType !== 'get') {
$append .= $this->_csrfField();
}
if (!empty($append)) {
$append = $this->Html->useTag('hiddenblock', $append);
}
if ($model !== false) {
$this->setEntity($model, true);
$this->_introspectModel($model, 'fields');
}
if ($action === null) {
return $this->Html->useTag('formwithoutaction', $htmlAttributes) . $append;
}
return $this->Html->useTag('form', $action, $htmlAttributes) . $append;
}
/**
* Return a CSRF input if the _Token is present.
* Used to secure forms in conjunction with SecurityComponent
*
* @return string
*/
protected function _csrfField() {
if (empty($this->request->params['_Token'])) {
return '';
}
if (!empty($this->request['_Token']['unlockedFields'])) {
/var
/www
/html
/app
/src
/View
/AdminInquiries
/login.ctp
<?php /* @var $this View */ ?>
<div class="row login">
<div class="col-xs-12 header">
<img class="img-responsive" src="/img/main_contact.jpg" alt="Consumer Inquiries Admin">
</div>
<div class="col-xs-12">
<?= $this->Form->create('User', [
'class' => 'form-horizontal',
'inputDefaults' => [
'div' => 'form-group',
'label' => [
'class' => 'col col-md-2 control-label',
],
'wrapInput' => 'col col-md-10',
'class' => 'form-control',
]]
); ?>
<?= $this->Form->hidden('remember_me', ['value' => true]) ?>
<?= $this->Form->input('email') ?>
<?= $this->Form->input('password') ?>
<div class="form-group">
<div class="col-md-offset-2 col col-md-10">
<button class="btn btn-large btn-primary" type="submit">Enter</button>
</div>
</div>
<?= $this->Form->end(); ?>
</div>
</div>
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/View
/View.php
throw new CakeException(__d('cake_dev', 'The "%s" block was left open. Blocks are not allowed to cross files.', $this->Blocks->active()));
}
return $content;
}
/**
* Sandbox method to evaluate a template / view script in.
*
* @param string $viewFile Filename of the view
* @param array $dataForView Data to include in rendered view.
* If empty the current View::$viewVars will be used.
* @return string Rendered output
*/
protected function _evaluate($viewFile, $dataForView) {
$this->__viewFile = $viewFile;
extract($dataForView);
ob_start();
include $this->__viewFile;
unset($this->__viewFile);
return ob_get_clean();
}
/**
* Loads a helper. Delegates to the `HelperCollection::load()` to load the helper
*
* @param string $helperName Name of the helper to load.
* @param array $settings Settings for the helper
* @return Helper a constructed helper object.
* @see HelperCollection::load()
*/
public function loadHelper($helperName, $settings = array()) {
return $this->Helpers->load($helperName, $settings);
}
/**
* Returns filename of given action's template file (.ctp) as a string.
* CamelCased action names will be under_scored! This means that you can have
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/View
/View.php
*
* @param string $viewFile Filename of the view
* @param array $data Data to include in rendered view. If empty the current View::$viewVars will be used.
* @return string Rendered output
* @triggers View.beforeRenderFile $this, array($viewFile)
* @triggers View.afterRenderFile $this, array($viewFile, $content)
* @throws CakeException when a block is left open.
*/
protected function _render($viewFile, $data = array()) {
if (empty($data)) {
$data = $this->viewVars;
}
$this->_current = $viewFile;
$initialBlocks = count($this->Blocks->unclosed());
$eventManager = $this->getEventManager();
$beforeEvent = new CakeEvent('View.beforeRenderFile', $this, array($viewFile));
$eventManager->dispatch($beforeEvent);
$content = $this->_evaluate($viewFile, $data);
$afterEvent = new CakeEvent('View.afterRenderFile', $this, array($viewFile, $content));
$afterEvent->modParams = 1;
$eventManager->dispatch($afterEvent);
$content = $afterEvent->data[1];
if (isset($this->_parents[$viewFile])) {
$this->_stack[] = $this->fetch('content');
$this->assign('content', $content);
$content = $this->_render($this->_parents[$viewFile]);
$this->assign('content', array_pop($this->_stack));
}
$remainingBlocks = count($this->Blocks->unclosed());
if ($initialBlocks !== $remainingBlocks) {
throw new CakeException(__d('cake_dev', 'The "%s" block was left open. Blocks are not allowed to cross files.', $this->Blocks->active()));
}
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/View
/View.php
* View and layout names can point to plugin views/layouts. Using the `Plugin.view` syntax
* a plugin view/layout can be used instead of the app ones. If the chosen plugin is not found
* the view will be located along the regular view path cascade.
*
* @param string $view Name of view file to use
* @param string $layout Layout to use.
* @return string|null Rendered content or null if content already rendered and returned earlier.
* @triggers View.beforeRender $this, array($viewFileName)
* @triggers View.afterRender $this, array($viewFileName)
* @throws CakeException If there is an error in the view.
*/
public function render($view = null, $layout = null) {
if ($this->hasRendered) {
return null;
}
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
$this->_currentType = static::TYPE_VIEW;
$this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($viewFileName)));
$this->Blocks->set('content', $this->_render($viewFileName));
$this->getEventManager()->dispatch(new CakeEvent('View.afterRender', $this, array($viewFileName)));
}
if ($layout === null) {
$layout = $this->layout;
}
if ($layout && $this->autoLayout) {
$this->Blocks->set('content', $this->renderLayout('', $layout));
}
$this->hasRendered = true;
return $this->Blocks->get('content');
}
/**
* Renders a layout. Returns output from _render(). Returns false on error.
* Several variables are created for use in layout.
*
* - `title_for_layout` - A backwards compatible place holder, you should set this value if you want more control.
* - `content_for_layout` - contains rendered view file
* - `scripts_for_layout` - Contains content added with addScript() as well as any content in
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Controller
/Controller.php
list($plugin, $className) = pluginSplit($model);
$this->request->params['models'][$className] = compact('plugin', 'className');
}
}
$this->View = $this->_getViewObject();
$models = ClassRegistry::keys();
foreach ($models as $currentModel) {
$currentObject = ClassRegistry::getObject($currentModel);
if ($currentObject instanceof Model) {
$className = get_class($currentObject);
list($plugin) = pluginSplit(App::location($className));
$this->request->params['models'][$currentObject->alias] = compact('plugin', 'className');
$this->View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors;
}
}
$this->autoRender = false;
$this->response->body($this->View->render($view, $layout));
return $this->response;
}
/**
* Returns the referring URL for this request.
*
* @param string $default Default URL to use if HTTP_REFERER cannot be read from headers
* @param bool $local If true, restrict referring URLs to local server
* @return string Referring URL
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::referer
*/
public function referer($default = null, $local = false) {
if (!$this->request) {
return '/';
}
$referer = $this->request->referer($local);
if ($referer === '/' && $default && $default !== $referer) {
return Router::url($default, !$local);
}
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Routing
/Dispatcher.php
* action are returned.
*
* @param Controller $controller Controller to invoke
* @param CakeRequest $request The request object to invoke the controller for.
* @return CakeResponse the resulting response object
*/
protected function _invoke(Controller $controller, CakeRequest $request) {
$controller->constructClasses();
$controller->startupProcess();
$response = $controller->response;
$render = true;
$result = $controller->invokeAction($request);
if ($result instanceof CakeResponse) {
$render = false;
$response = $result;
}
if ($render && $controller->autoRender) {
$response = $controller->render();
} elseif (!($result instanceof CakeResponse) && $response->body() === null) {
$response->body($result);
}
$controller->shutdownProcess();
return $response;
}
/**
* Applies Routing and additionalParameters to the request to be dispatched.
* If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.
*
* @param CakeEvent $event containing the request, response and additional params
* @return void
*/
public function parseParams($event) {
$request = $event->data['request'];
Router::setRequestInfo($request);
$params = Router::parse($request->url);
$request->addParams($params);
/var
/www
/html
/app
/Vendor
/cakephp
/cakephp
/lib
/Cake
/Routing
/Dispatcher.php
$request = $beforeEvent->data['request'];
if ($beforeEvent->result instanceof CakeResponse) {
if (isset($request->params['return'])) {
return $beforeEvent->result->body();
}
$beforeEvent->result->send();
return null;
}
$controller = $this->_getController($request, $response);
if (!($controller instanceof Controller)) {
throw new MissingControllerException(array(
'class' => Inflector::camelize($request->params['controller']) . 'Controller',
'plugin' => empty($request->params['plugin']) ? null : Inflector::camelize($request->params['plugin'])
));
}
$response = $this->_invoke($controller, $request);
if (isset($request->params['return'])) {
return $response->body();
}
$afterEvent = new CakeEvent('Dispatcher.afterDispatch', $this, compact('request', 'response'));
$this->getEventManager()->dispatch($afterEvent);
$afterEvent->data['response']->send();
}
/**
* Initializes the components and models a controller will be using.
* Triggers the controller action, and invokes the rendering if Controller::$autoRender
* is true and echo's the output. Otherwise the return value of the controller
* action are returned.
*
* @param Controller $controller Controller to invoke
* @param CakeRequest $request The request object to invoke the controller for.
* @return CakeResponse the resulting response object
*/
protected function _invoke(Controller $controller, CakeRequest $request) {
// for built-in server
if (php_sapi_name() == 'cli-server') {
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) {
return false;
}
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
}
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
if (!empty($failed)) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
App::uses('Dispatcher', 'Routing');
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(
new CakeRequest(),
new CakeResponse()
);