Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Some Patch For Eval In Ccomponent.php

$
0
0
Hello all,
Sorry for my bad english. I have some modified File in framework/base/CComponent.php
to run Yii on restricted eval environtment (something like php_suhosin ).
Hopelly this can help someone has similar problem with me.
before patch I cannot use:

 'value'=>'$data->frx0->columnx' 


with this patch calling eval variable will worked on restricted eval environtment


You can replace function evaluateExpression with this patch:

	public function evaluateExpression($_expression_,$_data_=array())
	{
		if(is_string($_expression_))
		{
			$key=str_replace("\$data->","",$_expression_);
			if(preg_match("/-\>/",$key)){
			  $data=$_data_['data'];
			  $var=explode("->",$key);
			  foreach($var as $key){
				if(isset($data->$key)) $data=$data->$key;
			  }
			  return $data;
			}elseif(!empty($key)) return   $_data_['data']->$key;
			else return null;
		}
		else
		{
			$_data_[]=$this;
			return call_user_func_array($_expression_, $_data_);
		}
	}


Viewing all articles
Browse latest Browse all 18717

Trending Articles