in my Yii2 frame work project i want to include a php file. the file contain two function file name "encryptdecrypt.php" and save it in common\extension folder
<?
public function encryptIt( $q ) {
$cryptKey = 'OrangeOnlineMedia';
$qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
return( $qEncoded );
}
public function decryptIt( $q ) {
$cryptKey = 'OrangeOnlineMedia';
$qDecoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $q ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
return( $qDecoded );
}
?>
i include this line in controller page("CustomersController")
top of the page include using this line
$encFile =Yii::getAlias('@common'). '\extensions\encryptdecrypt.php';
require_once($encFile);
and use the function in an action code bellow
public function actionCreate()
{
$model = new Customers();
if ($model->load(Yii::$app->request->post()) ) {
$model->password=encryptIt($model->password);
if($model->created_date==null)
{
$model->created_date=date('y-m-d') ;
}
$model->save();
return $this->redirect(['view', 'id' => $model->customer_id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
here i am getting the following error "Call to undefined function backend\controllers\encryptIt()"
thanks