浏览代码

fix controller bug in hack

euromark 12 年之前
父节点
当前提交
a5962ac05d

+ 1 - 1
Controller/MyController.php

@@ -17,7 +17,7 @@ class MyController extends Controller {
 	 */
 	public function __construct($request = null, $response = null) {
 		parent::__construct($request, $response);
-		if (strpos($this->request->here, '/js/cjs/') === 0 || strpos($this->request->here, '/css/ccss/') === 0) {
+		if ($this->request !== null && strpos($this->request->here, '/js/cjs/') === 0 || strpos($this->request->here, '/css/ccss/') === 0) {
 			unset($this->request->params['ext']);
 		}
 	}

+ 6 - 6
Model/Behavior/CaptchaBehavior.php

@@ -1,7 +1,7 @@
 <?php
 
 define('CAPTCHA_MIN_TIME', 3); # seconds the form will need to be filled in by a human
-define('CAPTCHA_MAX_TIME', HOUR);	# seconds the form will need to be submitted in
+define('CAPTCHA_MAX_TIME', HOUR);	// seconds the form will need to be submitted in
 
 App::uses('ModelBehavior', 'Model');
 App::uses('CaptchaLib', 'Tools.Lib');
@@ -31,14 +31,14 @@ class CaptchaBehavior extends ModelBehavior {
 		$defaults = array_merge(CaptchaLib::$defaults, $this->defaults);
 		$this->Model = $Model;
 
-		# bootstrap configs
+		// bootstrap configs
 		$this->settings[$Model->alias] = $defaults;
 		$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], (array)Configure::read('Captcha'));
 		if (!empty($settings)) {
 			$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], $settings);
 		}
 
-		# local configs in specific action
+		// local configs in specific action
 		if (!empty($settings['minTime'])) {
 			$this->settings[$Model->alias]['minTime'] = (int)$settings['minTime'];
 		}
@@ -101,7 +101,7 @@ class CaptchaBehavior extends ModelBehavior {
 			return $this->_setError(__('Illegal call'));
 		}
 		if (!empty($data[$dummyField])) {
-			# dummy field not empty - SPAM!
+			// dummy field not empty - SPAM!
 			return $this->_setError(__('Illegal content'), 'DummyField = \'' . $data[$dummyField] . '\'');
 		}
 		return true;
@@ -149,7 +149,7 @@ class CaptchaBehavior extends ModelBehavior {
 	 */
 	protected function _validateCaptcha($data) {
 		if (!isset($data['captcha'])) {
-			# form inputs missing? SPAM!
+			// form inputs missing? SPAM!
 			return $this->_setError(__('captchaContentMissing'));
 		}
 
@@ -158,7 +158,7 @@ class CaptchaBehavior extends ModelBehavior {
 		if ($data['captcha_hash'] === $hash) {
 			return true;
 		}
-		# wrong captcha content or session expired
+		// wrong captcha content or session expired
 		return $this->_setError(__('Captcha incorrect'), 'SubmittedResult = \'' . $data['captcha'] . '\'');
 	}
 

+ 2 - 2
Model/Behavior/ConfirmableBehavior.php

@@ -37,8 +37,8 @@ class ConfirmableBehavior extends ModelBehavior {
 		$return = parent::beforeValidate($Model, $options);
 
 		if ($this->settings[$Model->alias]['before'] === 'validate') {
-			# we dont want to return the value, because other fields might then not be validated
-			# (save will not continue with errors, anyway)
+			// we dont want to return the value, because other fields might then not be validated
+			// (save will not continue with errors, anyway)
 			$this->confirm($Model, $return);
 		}
 

+ 3 - 3
Model/Behavior/DecimalInputBehavior.php

@@ -42,7 +42,7 @@ class DecimalInputBehavior extends ModelBehavior {
 			'float'
 		),
 		'localeconv' => false,
-		# based on input (output other direction)
+		// based on input (output other direction)
 		'transform' => array(
 			'.' => '',
 			',' => '.',
@@ -67,14 +67,14 @@ class DecimalInputBehavior extends ModelBehavior {
 			$this->config[$Model->alias]['transform']['.'] = '#';
 		}
 		if ($this->config[$Model->alias]['localeconv'] || !empty($config['localeconv'])) {
-			# use locale settings
+			// use locale settings
 			$conv = localeconv();
 			$loc = array(
 				'decimals' => $conv['decimal_point'],
 				'thousands' => $conv['thousands_sep']
 			);
 		} elseif ($configure = Configure::read('Localization')) {
-			# use configure settings
+			// use configure settings
 			$loc = (array)$configure;
 		}
 		if (!empty($loc)) {

+ 4 - 4
Model/Behavior/MasterPasswordBehavior.php

@@ -48,7 +48,7 @@ class MasterPasswordBehavior extends ModelBehavior {
 			$this->settings[$Model->alias] = $this->_defaults;
 		}
 		$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], is_array($settings) ? $settings : array());
-		# deactivate dynamically
+		// deactivate dynamically
 		if (Configure::read('MasterPassword.password') === false) {
 			$this->settings[$Model->alias]['before'] = '';
 		}
@@ -58,8 +58,8 @@ class MasterPasswordBehavior extends ModelBehavior {
 		$return = parent::beforeValidate($Model, $options);
 
 		if ($this->settings[$Model->alias]['before'] === 'validate') {
-			# we dont want to return the value, because other fields might then not be validated
-			# (save will not continue with errors, anyway)
+			// we dont want to return the value, because other fields might then not be validated
+			// (save will not continue with errors, anyway)
 			$this->confirm($Model, $return);
 		}
 
@@ -131,7 +131,7 @@ class MasterPasswordBehavior extends ModelBehavior {
 		if ($algorithm === 'md5') {
 			return md5($string);
 		}
-		# mcrypt installed?
+		// mcrypt installed?
 		if (function_exists('hash') && in_array($algorithm, hash_algos())) {
 			return hash($algorithm, $string);
 		}

+ 1 - 1
Model/Behavior/MultipleDisplayFieldsBehavior.php

@@ -137,7 +137,7 @@ class MultipleDisplayFieldsBehavior extends ModelBehavior {
 	 */
 	public function beforeFind(Model $Model, $queryData) {
 		if (isset($queryData['list']) && !isset($this->settings[$Model->alias]['multiple_display_fields'])) {
-			# MOD 2009-01-09 ms (fixes problems with model related index functions - somehow gets triggered even on normal find queries...)
+			// MOD 2009-01-09 ms (fixes problems with model related index functions - somehow gets triggered even on normal find queries...)
 			$this->settings[$Model->alias]['multiple_display_fields'] = 1;
 
 			// substr is used to get rid of "{n}" fields' prefix...

+ 3 - 3
Model/Behavior/NumberFormatBehavior.php

@@ -42,7 +42,7 @@ class NumberFormatBehavior extends ModelBehavior {
 		),
 		'localeconv' => false, // use system settings for decimals and thousands
 		'currency' => false, // would make localeconf use mon_ values or Configure use Currency
-		# based on input (output other direction)
+		// based on input (output other direction)
 		'multiply' => 0, // direction 'in' (inverted value automatically used for 'out')
 		'transform' => array( // transform mask
 			'.' => '',
@@ -67,14 +67,14 @@ class NumberFormatBehavior extends ModelBehavior {
 			$this->settings[$Model->alias]['transform']['.'] = '#';
 		}
 		if ($this->settings[$Model->alias]['localeconv'] || !empty($config['localeconv'])) {
-			# use locale settings
+			// use locale settings
 			$conv = localeconv();
 			$loc = array(
 				'decimals' => $conv['decimal_point'],
 				'thousands' => $conv['thousands_sep']
 			);
 		} elseif ($configure = Configure::read('Localization')) {
-			# use configure settings
+			// use configure settings
 			$loc = (array)$configure;
 		}
 		if (!empty($loc)) {

+ 5 - 5
Model/Behavior/PasswordableBehavior.php

@@ -156,7 +156,7 @@ class PasswordableBehavior extends ModelBehavior {
 
 		$this->Auth = new $authClass(new ComponentCollection());
 
-		# easiest authenticate method via form and (id + pwd)
+		// Easiest authenticate method via form and (id + pwd)
 		$authConfig = array(
 			'fields' => array('username' => 'id', 'password' => $this->settings[$Model->alias]['field']),
 			'userModel' => $this->settings[$Model->alias]['userModel'] ? $this->settings[$Model->alias]['userModel'] : $Model->alias
@@ -266,7 +266,7 @@ class PasswordableBehavior extends ModelBehavior {
 			$rules[$field] = $fieldRules;
 		}
 
-		# add the validation rules if not already attached
+		// Add the validation rules if not already attached
 		if (!isset($Model->validate[$formField])) {
 			$Model->validator()->add($formField, $rules['formField']);
 		}
@@ -288,7 +288,7 @@ class PasswordableBehavior extends ModelBehavior {
 				));
 			}
 		} elseif (!isset($Model->validate[$formFieldCurrent])) {
-			# try to match the password against the hash in the DB
+			// Try to match the password against the hash in the DB
 			if (!$this->settings[$Model->alias]['allowSame']) {
 				$Model->validator()->add($formField, 'validateNotSame', array(
 					'rule' => array('validateNotSameHash', $formField),
@@ -310,7 +310,7 @@ class PasswordableBehavior extends ModelBehavior {
 		$formFieldRepeat = $this->settings[$Model->alias]['formFieldRepeat'];
 		$formFieldCurrent = $this->settings[$Model->alias]['formFieldCurrent'];
 
-		# make sure fields are set and validation rules are triggered - prevents tempering of form data
+		// Make sure fields are set and validation rules are triggered - prevents tempering of form data
 		if (!isset($Model->data[$Model->alias][$formField])) {
 			$Model->data[$Model->alias][$formField] = '';
 		}
@@ -321,7 +321,7 @@ class PasswordableBehavior extends ModelBehavior {
 			$Model->data[$Model->alias][$formFieldCurrent] = '';
 		}
 
-		# check if we need to trigger any validation rules
+		// Check if we need to trigger any validation rules
 		if (!$this->settings[$Model->alias]['require']) {
 			$current = !empty($Model->data[$Model->alias][$formFieldCurrent]);
 			$new = !empty($Model->data[$Model->alias][$formField]) || !empty($Model->data[$Model->alias][$formFieldRepeat]);

+ 23 - 23
Model/MyModel.php

@@ -24,7 +24,7 @@ class MyModel extends Model {
 	public function __construct($id = false, $table = null, $ds = null) {
 		parent::__construct($id, $table, $ds);
 
-		# enable caching
+		// enable caching
 		if (!Configure::read('Cache.disable') && Cache::config('sql') === false) {
 			if (!file_exists(CACHE . 'sql')) {
 				mkdir(CACHE . 'sql', CHOWN_PUBLIC);
@@ -41,7 +41,7 @@ class MyModel extends Model {
 			$this->prefixOrderProperty();
 		}
 
-		# Get a notice if there is an AppModel instance instead of a real Model (in those cases usually a dev error!)
+		// Get a notice if there is an AppModel instance instead of a real Model (in those cases usually a dev error!)
 		if (!is_a($this, $this->name) && $this->displayField !== $this->primaryKey && $this->useDbConfig === 'default'
 			&& !Configure::read('Core.disableModelInstanceNotice')) {
 			trigger_error('AppModel instance! Expected: ' . $this->name);
@@ -495,7 +495,7 @@ class MyModel extends Model {
 	 * @return array
 	 */
 	public function find($type = null, $query = array()) {
-		# reset/delete
+		// reset/delete
 		if (!empty($query['reset'])) {
 			if (!empty($query['cache'])) {
 				if (is_array($query['cache'])) {
@@ -511,7 +511,7 @@ class MyModel extends Model {
 			}
 		}
 
-		# custom fixes
+		// custom fixes
 		if (is_string($type)) {
 			switch ($type) {
 				case 'count':
@@ -523,7 +523,7 @@ class MyModel extends Model {
 			}
 		}
 
-		# having and group clauses enhancement
+		// having and group clauses enhancement
 		if (is_array($query) && !empty($query['having']) && !empty($query['group'])) {
 			if (!is_array($query['group'])) {
 				$query['group'] = array($query['group']);
@@ -538,7 +538,7 @@ class MyModel extends Model {
 		}
 		*/
 
-		# find
+		// find
 		if (!Configure::read('Cache.disable') && Configure::read('Cache.check') && !empty($query['cache'])) {
 			if (is_array($query['cache'])) {
 				$key = $query['cache'][0];
@@ -573,7 +573,7 @@ class MyModel extends Model {
 			return $results;
 		}
 
-		# Without caching
+		// Without caching
 		return parent::find($type, $query);
 	}
 
@@ -605,7 +605,7 @@ class MyModel extends Model {
 			}
 
 			switch ($type) {
-					# @see http://bakery.cakephp.org/deu/articles/nate/2010/10/10/quick-tipp_-_doing_ad-hoc-joins_bei_model_find
+					// @see http://bakery.cakephp.org/deu/articles/nate/2010/10/10/quick-tipp_-_doing_ad-hoc-joins_bei_model_find
 				case 'matches':
 					if (!isset($options['joins'])) {
 						$options['joins'] = array();
@@ -638,7 +638,7 @@ class MyModel extends Model {
 					unset($options['model'], $options['scope']);
 					$type = 'all';
 					break;
-					# probably deprecated since "virtual fields" in 1.3
+					// probably deprecated since "virtual fields" in 1.3
 				case 'formattedlist':
 					if (!isset($options['fields']) || count($options['fields']) < 3) {
 						$res = parent::find('list', $options);
@@ -791,7 +791,7 @@ class MyModel extends Model {
 		$findOptions['fields'] = array($this->alias . '.' . $this->primaryKey, $this->alias . '.' . $displayField);
 		$findOptions['conditions'][$this->alias . '.' . $this->primaryKey . ' !='] = $id;
 
-		# //TODO: take out
+		// //TODO: take out
 		if (!empty($options['filter']) && $options['filter'] == REQUEST_STATUS_FILTER_OPEN) {
 			$findOptions['conditions'][$this->alias . '.status <'] = REQUEST_STATUS_DECLINED;
 		} elseif (!empty($options['filter']) && $options['filter'] == REQUEST_STATUS_FILTER_CLOSED) {
@@ -933,7 +933,7 @@ class MyModel extends Model {
 
 		$matching = array('string' => 'string', 'int' => 'integer', 'float' => 'float', 'bool' => 'boolean');
 		if (!empty($options['cast']) && array_key_exists($options['cast'], $matching)) {
-			# cast values to string/int/float/bool if desired
+			// cast values to string/int/float/bool if desired
 			settype($compareValue, $matching[$options['cast']]);
 			settype($value, $matching[$options['cast']]);
 		}
@@ -967,7 +967,7 @@ class MyModel extends Model {
 			$this->alias . '.' . $fieldName => $fieldValue,
 			$this->alias . '.id !=' => $id);
 
-		# careful, if fields is not manually filled, the options will be the second param!!! big problem...
+		// careful, if fields is not manually filled, the options will be the second param!!! big problem...
 		$fields = (array)$fields;
 		if (!array_key_exists('allowEmpty', $fields)) {
 			foreach ($fields as $dependingField) {
@@ -978,7 +978,7 @@ class MyModel extends Model {
 					$conditions[$this->alias . '.' . $dependingField] = $this->data['Validation'][$dependingField];
 
 				} elseif (!empty($id)) {
-					# manual query! (only possible on edit)
+					// manual query! (only possible on edit)
 					$res = $this->find('first', array('fields' => array($this->alias . '.' . $dependingField), 'conditions' => array($this->alias . '.id' => $id)));
 					if (!empty($res)) {
 						$conditions[$this->alias . '.' . $dependingField] = $res[$this->alias][$dependingField];
@@ -1023,19 +1023,19 @@ class MyModel extends Model {
 		$defaults = array('batch' => true, 'scope' => array());
 		$options = array_merge($defaults, $options);
 
-		# for batch
+		// for batch
 		if ($options['batch'] !== false && !empty($this->batchRecords)) {
 			if (array_key_exists($value, $this->batchRecords[$fieldName])) {
 				return $options['scope'] === $this->batchRecords[$fieldName][$value];
 			}
 		}
 
-		# continue with validation
+		// continue with validation
 		if (!$this->validateUnique($data, $options['scope'])) {
 			return false;
 		}
 
-		# for batch
+		// for batch
 		if ($options['batch'] !== false) {
 			if (!isset($this->batchRecords)) {
 				$this->batchRecords = array();
@@ -1082,11 +1082,11 @@ class MyModel extends Model {
 			$options['strict'] = true;
 		}
 
-		# validation
+		// validation
 		if (!Validation::url($url, $options['strict']) && env('REMOTE_ADDR') !== '127.0.0.1') {
 			return false;
 		}
-		# same domain?
+		// same domain?
 		if (!empty($options['sameDomain']) && !empty($_SERVER['HTTP_HOST'])) {
 			$is = parse_url($url, PHP_URL_HOST);
 			$expected = env('HTTP_HOST');
@@ -1170,7 +1170,7 @@ class MyModel extends Model {
 		}
 		*/
 		if (Validation::date($date, $format) && Validation::time($time)) {
-			# after/before?
+			// after/before?
 			$minutes = isset($options['min']) ? $options['min'] : 1;
 			if (!empty($options['after']) && isset($this->data[$this->alias][$options['after']])) {
 				if (strtotime($this->data[$this->alias][$options['after']]) > strtotime($value) - $minutes) {
@@ -1212,7 +1212,7 @@ class MyModel extends Model {
 			return true;
 		}
 		if (Validation::date($date, $format)) {
-			# after/before?
+			// after/before?
 			$days = !empty($options['min']) ? $options['min'] : 0;
 			if (!empty($options['after']) && isset($this->data[$this->alias][$options['after']])) {
 				if ($this->data[$this->alias][$options['after']] > date(FORMAT_DB_DATE, strtotime($date) - $days * DAY)) {
@@ -1250,7 +1250,7 @@ class MyModel extends Model {
 		$value = array_pop($dateTime);
 
 		if (Validation::time($value)) {
-			# after/before?
+			// after/before?
 			if (!empty($options['after']) && isset($this->data[$this->alias][$options['after']])) {
 				if ($this->data[$this->alias][$options['after']] >= $value) {
 					return false;
@@ -1310,7 +1310,7 @@ class MyModel extends Model {
 			$this->UndisposableEmail = new UndisposableEmail();
 		}
 		if (!$onlineMode) {
-			# crashed with white screen of death otherwise... (if foreign page is 404)
+			// crashed with white screen of death otherwise... (if foreign page is 404)
 			$this->UndisposableEmail->useOnlineList(false);
 		}
 		if (!class_exists('Validation')) {
@@ -1320,7 +1320,7 @@ class MyModel extends Model {
 			return false;
 		}
 		if ($this->UndisposableEmail->isUndisposableEmail($email) === false) {
-			# trigger log
+			// trigger log
 			$this->log('Disposable Email detected: ' . h($email) . ' (IP ' . env('REMOTE_ADDR') . ')', 'undisposable');
 			if ($proceed === true) {
 				return true;

+ 4 - 4
Model/Token.php

@@ -118,19 +118,19 @@ class Token extends ToolsAppModel {
 			// return $res; # more secure to fail here if user_id is not provided, but was submitted prev.
 			return false;
 		}
-		# already used?
+		// already used?
 		if (!empty($res[$this->alias]['used'])) {
 			if ($treatUsedAsInvalid) {
 				return false;
 			}
-			# return true and let the application check what to do then
+			// return true and let the application check what to do then
 			return $res;
 		}
-		# actually spend key (set to used)
+		// actually spend key (set to used)
 		if ($this->spendKey($res[$this->alias]['id'])) {
 			return $res;
 		}
-		# no limit? we dont spend key then
+		// no limit? we dont spend key then
 		if (!empty($res[$this->alias]['unlimited'])) {
 			return $res;
 		}

+ 1 - 1
README.md

@@ -86,7 +86,7 @@ A quick reference or some larger modules: [USAGE.md](https://github.com/dereurom
 * Disable cache also works for older IE versions.
 * Redirect with additional encoding for Apache (if still using named params insteaf of query strings).
 * Default settings for Paginator, ... can be set using Configure.
-* RSS and Ajax Views for better repsonses there (Ajax also includes an optional component).
+* RSS and Ajax Views for better responses (Ajax also comes with an optional component).
 * Minor misc. tweaks.
 
 ### Additional classes and features