function admin_index() { $this->Ticket->recursive = 0; $filters = $this->AlaxosFilter->get_filter(); $data_ticket = array(); if (empty($this->params['named']['export_excel'])) { $this->set('tickets', $this->paginate($this->Ticket, $filters)); } else { Configure::write('debug', 0); $options = array(); $this->set('export_to_excel', 1); $i = 0; $tickets = $this->Ticket->find('all', array_merge_recursive($options, array('conditions' => $filters))); foreach ($tickets as $ticket) { foreach ($ticket as $indx => $module) { foreach ($module as $k => $v) { $arr_fields_in_xls = array(); if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) { $data_ticket[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } else { $data_ticket[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } } } $i++; } $this->set('tickets', $data_ticket); } }
function login() { Configure::write('debug', 0); if ($this->Auth->isAuthorized()) { $this->redirect('/fams/index'); } }
function admin_index() { $this->FrequencyType->recursive = 0; $filters = $this->AlaxosFilter->get_filter(); $data_frequencyType = array(); if (empty($this->params['named']['export_excel'])) { $this->set('frequencyTypes', $this->paginate($this->FrequencyType, $filters)); } else { Configure::write('debug', 0); $options = array(); $this->set('export_to_excel', 1); $i = 0; $frequencyTypes = $this->FrequencyType->find('all', array_merge_recursive($options, array('conditions' => $filters))); foreach ($frequencyTypes as $frequencyType) { foreach ($frequencyType as $indx => $module) { foreach ($module as $k => $v) { $arr_fields_in_xls = array(); if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) { $data_frequencyType[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } else { $data_frequencyType[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } } } $i++; } $this->set('frequencyTypes', $data_frequencyType); } $frequencies = $this->FrequencyType->Frequency->find('list'); $this->set(compact('frequencies')); }
function beforeFilter() { // Set some generic Auth stuff, in case Auth is used in the model: if (isset($this->Auth)) { $this->Auth->userModel = 'Artist'; $this->Auth->loginAction = array('controller' => 'artists', 'action' => 'login'); // Set Login system to use email adress as username: $this->Auth->fields = array('username' => 'email', 'password' => 'password'); $this->Auth->loginError = __('Login failed. Please try again.', true); $this->Auth->loginRedirect = '/'; $this->Auth->autoRedirect = true; $this->Auth->allow('set_language'); // enable access control via isAuthorized(): $this->Auth->authorize = 'controller'; } // Init language stuff: App::import('Core', 'L10n'); $this->L10n = new L10n(); // Read setting from session: $lang = $this->Session->read('lang'); // Set language: if ($lang != '') { $this->L10n->get($lang); Configure::write('Config.language', $lang); } else { $this->L10n->get(); } }
/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop('xcache'); Cache::drop('xcache_groups'); Cache::config('default'); }
/** * index method * * @return void */ public function download() { $this->set('employees', $this->Employee->find('all', array('fields' => array('id', 'first_name', 'last_name', 'address', 'city', 'home_phone', 'hire_date', 'gender', 'date_of_birth', 'status', 'employment_type', 'designation')))); $this->layout = null; $this->autoLayout = false; Configure::write('debug', '0'); }
public function tearDown() { parent::tearDown(); $this->Data->cleanUp(); ClassRegistry::flush(); Configure::write('Media', $this->oldConfig); }
public function orderCreate($country_id, $presenterId, $userId, $hostmarket_id, $partyId) { Configure::write("market_id", (int) $country_id); if ($country_id == 1) { $postal_code = "20350-1000"; } else { if ($country_id == 2) { $postal_code = "K1A 0B1"; } else { if ($country_id == 3) { $postal_code = "0872"; } else { if ($country_id == 4) { $postal_code = "6000"; } else { if ($country_id == 5) { $postal_code = "NN8 4TH"; } else { if ($country_id == 6) { $postal_code = "15030"; } else { echo "I am from else block"; exit; } } } } } } // debug($postal_code); $address = array("first_name" => "testing", "last_name" => "last", "address1" => "Some address 1", "address2" => "Some address 2", "address3" => "Some address 3", "city" => "Awesome city", "state_id" => 20, "postal_code" => $postal_code, "email_address" => "*****@*****.**", "country_id" => $country_id); $promoterId = 2; //$presenterId = 141683; // from presenter , we get market_id for orders $items = array(array("sku" => "US-42031-01", "qty" => 1, "options" => array("US-21000-00" => array("skus" => array("US-11001-01" => 1, "US-11001-08" => 1)), "US-22100-00" => array("skus" => array("US-12101-03" => 1, "US-12101-04" => 1)), "US-21400-00" => array("skus" => array("US-11401-07" => 1)), "US-22401-00" => array("skus" => array("US-12401-03" => 1)), "US-22301-00" => array("skus" => array("US-12301-07" => 1)))), array("sku" => "US-1017-00", "qty" => 1, "coupons" => array("1" => array("discount_percentage" => 50, "discount_flat" => Money::fromFloat(0), "name" => "Half Priced Item"))), array("sku" => "US-53021-01", "qty" => 1, "coupons" => array("1" => array("discount_percentage" => 50, "discount_flat" => Money::fromFloat(0), "name" => "Half Priced Item")))); $coupons = array(); $productCredits = Money::fromFloat(675.0); //20.00//29.00//29.00//45.00//29.00//90.00//75.00//175.00//58.00 //$prices = $this->Order->getOrderCosts($address['postal_code'], $items,null, $coupons); $prices = $this->Order->getOrderCosts($address['postal_code'], $items, $productCredits, $coupons); //$prices = $this->getOrderCosts($address['country_id'], $items,null, $coupons); //echo "<pre>"; //print_r($prices);exit; $insert_order = TRUE; // $result = $this->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address,Order::TYPE_PRODUCT,null, $coupons,FALSE,$insert_order); $result = $this->Order->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address, Order::TYPE_PRODUCT, $productCredits, $coupons, FALSE, TRUE); // debug($result); // $result = $this->Order->createOrder($promoterId, $presenterId, $userId, $partyId, $items, $address,Order::TYPE_PRODUCT,$productCredits, $coupons,FALSE);//$insert_order $orderId = $this->Order->id; // $orderId = $this->Order->query("SELECT MAX(id) FROM orders"); // debug($this->Order->id); // debug($orderId); // debug($result); // exit; $orderPaymentResult = array("success" => false, "payments" => array(array('type' => 'creditcard', 'amount' => $prices['total']['total'], "transaction_id" => "Wohootest", "identifier" => "3123", 'cardholder' => 'Test wohoo', 'billingzip' => '84003', 'cardnum' => '123123123', 'carexp' => '12/2015', 'cardcode' => '962', 'status' => 'failed'))); $result = $this->Order->finalize($orderPaymentResult); // debug($prices['total']['total']); $orderPaymentResult = array("success" => true, "payments" => array(array('type' => 'creditcard', 'transaction_id' => 'Wohootest', 'amount' => $prices['total']['total'], 'cardholder' => 'Test wohoo', 'billingzip' => '84003', 'cardnum' => '123123123', 'carexp' => '12/2015', 'cardcode' => '962', 'status' => 'success', "identifier" => "3123"))); $result = $this->Order->finalize($orderPaymentResult); return $orderId; }
function kcaptchaReset() { Configure::write('debug', 0); $this->autoRender = false; $this->kcaptcha->render(); exit; }
function selTheme() { //ajax preparation Configure::write('debug', 0); $this->autoLayout = false; $this->autoRender = false; if ($this->RequestHandler->isAjax()) { //our host only if (strpos(env('HTTP_REFERER'), trim(env('HTTP_HOST'), '/')) === false) { $this->Security->blackHoleCallback = 'gotov'; } $auth = $this->Auth->user('id'); if ($auth && $this->data['Theme']['id'] != null) { $this->data['Theme']['current_theme'] = time(); if ($this->Theme->save($this->data)) { $contents['stat'] = 1; $allThemeCards = $this->Theme->Card->find('all', array('conditions' => array('Card.theme_id' => $this->data['Theme']['id'], 'Card.user_id' => $auth), 'fields' => array('Card.id', 'Card.word'), 'order' => array('Card.id DESC'), 'contain' => false)); $contents['cards'] = $allThemeCards; } else { $contents['stat'] = 0; } } else { $contents['stat'] = 0; } $contents = json_encode($contents); $this->header('Content-Type: application/json'); return $contents; } else { $this->Security->blackHoleCallback = 'gotov'; } }
/** * Tests the exception handling. * */ public function testExceptions() { Configure::write('debug', 2); // Create some requests. $rawPostData = json_encode(array(array('action' => 'ThisControllerDoesNotExist', 'method' => 'index', 'tid' => 1, 'type' => 'rpc', 'data' => array()), array('action' => 'ArticlesException', 'method' => 'throwNotFoundExceptionMethod', 'tid' => 2, 'type' => 'rpc', 'data' => array()), array('action' => 'ArticlesException', 'method' => 'throwExceptionMethod', 'tid' => 3, 'type' => 'rpc', 'data' => array()))); // Create dispatcher and dispatch requests. $dispatcher = new BanchaDispatcher(); $responses = json_decode($dispatcher->dispatch(new BanchaRequestCollection($rawPostData), array('return' => true))); // set debug level back to normal Configure::write('debug', $this->standardDebugLevel); $this->assertEquals(3, count($responses), 'Three requests result in three responses.'); // controller class not found $this->assertEquals('exception', $responses[0]->type); $this->assertEquals('MissingControllerException', $responses[0]->exceptionType); $this->assertEquals('Controller class ThisControllerDoesNotExistsController could not be found.', $responses[0]->message); $this->assertTrue(!empty($responses[0]->where), 'message'); // application controller method exception catched $this->assertEquals('exception', $responses[1]->type); $this->assertEquals('NotFoundException', $responses[1]->exceptionType); $this->assertEquals('Invalid article', $responses[1]->message); // another application level error $this->assertEquals('exception', $responses[2]->type); $this->assertEquals('Exception', $responses[2]->exceptionType); $this->assertEquals('Method specific error message, see bottom of this test', $responses[2]->message); $this->assertEquals('In file "' . __FILE__ . '" on line ' . $GLOBALS['EXCEPTION_LINE'] . '.', $responses[2]->where, 'message'); }
/** * override core one with the following enhancements/fixes: * - 404s log to a different domain * - IP, Referer and Browser-Infos are added for better error debugging/tracing * 2011-12-21 ms */ public static function handleException(Exception $exception) { $config = Configure::read('Exception'); if (!empty($config['log'])) { $log = LOG_ERR; $message = sprintf("[%s] %s\n%s\n%s", get_class($exception), $exception->getMessage(), $exception->getTraceAsString(), self::traceDetails()); if (in_array(get_class($exception), array('MissingControllerException', 'MissingActionException', 'PrivateActionException', 'NotFoundException'))) { $log = '404'; } CakeLog::write($log, $message); } $renderer = $config['renderer']; if ($renderer !== 'ExceptionRenderer') { list($plugin, $renderer) = pluginSplit($renderer, true); App::uses($renderer, $plugin . 'Error'); } try { $error = new $renderer($exception); $error->render(); } catch (Exception $e) { set_error_handler(Configure::read('Error.handler')); // Should be using configured ErrorHandler Configure::write('Error.trace', false); // trace is useless here since it's internal $message = sprintf("[%s] %s\n%s\n%s", get_class($e), $e->getMessage(), $e->getTraceAsString(), self::traceDetails()); trigger_error($message, E_USER_ERROR); } }
/** * Listings Administration */ function listingsadmin() { Configure::write('debug', '3'); $this->set('listings', $this->Listing->findAll()); $this->render(); exit; }
/** * testProcessVersion * * @return void */ public function testProcessVersion() { $this->Image->create(); $result = $this->Image->save(array('foreign_key' => 'test-1', 'model' => 'Test', 'file' => array('name' => 'titus.jpg', 'size' => 332643, 'tmp_name' => CakePlugin::path('FileStorage') . DS . 'Test' . DS . 'Fixture' . DS . 'File' . DS . 'titus.jpg', 'error' => 0))); $result = $this->Image->find('first', array('conditions' => array('id' => $this->Image->getLastInsertId()))); $this->assertTrue(!empty($result) && is_array($result)); $this->assertTrue(file_exists($this->testPath . $result['ImageStorage']['path'])); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 3); Configure::write('Media.imageSizes.Test', array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200)))); ClassRegistry::init('FileStorage.ImageStorage')->generateHashes(); $Event = new CakeEvent('ImageVersion.createVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))))); CakeEventManager::instance()->dispatch($Event); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 4); $Event = new CakeEvent('ImageVersion.removeVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))))); CakeEventManager::instance()->dispatch($Event); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 3); }
/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Configure::write('log', true); if ($this->_restoreError) { restore_error_handler(); } }
function testRequestFile() { $data = array('hash' => 'f93b1cc0dd5b5a634ace4c662190a566', 'segments' => array(array(0, 119)), 'send' => true); $result = $this->testAction('/peers/request_file', array('data' => json_encode($data), 'method' => 'post')); Configure::write('debug', 1); debug(json_decode($result, true)); }
/** * setUp method * * @access public * @return void */ public function setup() { Configure::write('Parsers', array('markdown' => array('name' => 'Markdown', 'className' => 'MarkupParsers.Markdown'), 'bbcode' => array('name' => 'BBCode', 'className' => 'MarkupParsers.Bbcode'), 'html' => array('name' => 'Html', 'className' => 'MarkupParsers.Html'))); $controller = null; $View = new View($controller); $this->Parser = new ParserHelper($View); }
public function beforeFilter() { parent::beforeFilter(); Configure::write('debug', 0); $this->layout = 'ajax'; $this->autoRender = false; }
public function beforeFilter() { // debug($this->request->params); parent::beforeFilter(); $gallerySidebar = $this->__gallerySidebar(); // debug($this->request->params['prefix']); $admin = isset($this->request->params['prefix']) && $this->request->params['prefix'] == 'admin' ? 'admin/' : false; if (!$admin) { $this->Auth->allow(); } if ($admin) { $this->layout = 'default'; } else { $this->layout = 'index'; } if (isset($this->params['language']) && $this->params['language'] == 'kz') { Configure::write('Config.language', 'kz'); } elseif (isset($this->params['language']) && $this->params['language'] == 'en') { Configure::write('Config.language', 'en'); } else { Configure::write('Config.language', 'ru'); } // debug($this->request->params); // debug($this->params['language']); $lang = $this->params['language'] ? $this->params['language'] . '/' : ''; $this->set(compact('admin', 'lang', 'gallerySidebar')); }
/** * initialize method * * Merge settings and set Config.language to a valid locale * * @return void * @access public */ function initialize(&$Controller, $config = array()) { App::import('Vendor', 'Mi.MiCache'); $lang = MiCache::setting('Site.lang'); if (!$lang) { if (!defined('DEFAULT_LANGUAGE')) { return; } $lang = DEFAULT_LANGUAGE; } elseif (!defined('DEFAULT_LANGUAGE')) { define('DEFAULT_LANGUAGE', $lang); } Configure::write('Config.language', $lang); App::import('Core', 'I18n'); $I18n =& I18n::getInstance(); $I18n->domain = 'default_' . $lang; $I18n->__lang = $lang; $I18n->l10n->get($lang); if (!empty($Controller->plugin)) { $config['plugins'][] = Inflector::underscore($Controller->plugin); } if (!empty($config['plugins'])) { $plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']); $Inst = App::getInstance(); foreach ($plugins as $path => $name) { $Inst->locales[] = $path . DS . 'locale' . DS; } } }
/** * Test task execution * * @param array $freeSlots * @param array $getPending * @param array $processEvents * @dataProvider executeProvider */ public function testExecute(array $freeSlots, array $getPending, array $processEvents) { $tasksCount = count($getPending); $slotsCount = count($freeSlots); $ProcessManager = $this->getMockBuilder('ProcessManager')->disableAutoload()->setMethods(array('fork'))->getMock(); $ProcessManager->expects($this->exactly(count($getPending)))->method('fork')->willReturnCallback(function ($callable) { $callable(); }); $Task = $this->getMockBuilder('TaskServerTask')->setMethods(array('_makeRunner'))->getMock(); $Task->ProcessManager = $ProcessManager; if ($tasksCount > 0) { for ($number = 0; $number < $tasksCount; $number++) { $Task->expects($this->at($number))->method('_makeRunner')->with($getPending[$number])->willReturnCallback($this->_makeRunner($processEvents)); } } else { $Task->expects($this->never())->method('_run'); } $Task->TaskClient = ClassRegistry::init('TaskClient'); $Task->TaskServer = $this->getMockBuilder('TaskServer')->setConstructorArgs(array(false, null, 'test'))->setMethods(array('freeSlots', 'getPending', 'killZombies'))->getMock(); $Task->TaskServer->expects($this->at(0))->method('killZombies'); $at = 1; for ($number = 0; $number < $slotsCount; $number++) { $Task->TaskServer->expects($this->at($at++))->method('freeSlots')->willReturn($freeSlots[$number]); if (isset($getPending[$number])) { $Task->TaskServer->expects($this->at($at++))->method('getPending')->willReturn($getPending[$number]); } } Configure::write('Task.processEvents', $processEvents); $Task->execute(); foreach ($processEvents as $processEvent) { $this->assertNotEmpty(TaskServerTaskTestEventModel1::$calls[$processEvent['key']]); $this->assertCount(count($getPending), TaskServerTaskTestEventModel1::$calls[$processEvent['key']]); } }
public function setup($environment = null) { if (Configure::read('Environment.setup')) { return; } $current = $environment === null ? 'development' : $environment; if (empty($environment)) { foreach ($this->environments as $name => $config) { if ($this->_cliMatch($name) || $this->_match($config['params'])) { $current = $name; break; } } } $config = array_merge($this->environments[$current]['config'], array('Environment.name' => $current)); foreach ($config as $param => $value) { if (isset($this->_configMap[$param])) { $param = $this->_configMap[$param]; } Configure::write($param, $value); } if (is_callable($this->environments[$current]['callable'])) { $this->environments[$current]['callable'](); } if (Configure::read('debug') > 0) { App::uses('CakeLog', 'Log'); if (class_exists('CakeLog')) { CakeLog::write(LOG_INFO, $current); Configure::write('Environment.setup', true); } } }
public function download() { $this->set('vendormasters', $this->VendorMaster->find('all', array('fields' => array('id', 'vendor_type', 'name', 'address', 'phone_number', 'fax', 'setup_date', 'email', 'pc_name', 'pc_phone', 'pc_email', 'pc_fax', 'sc_name', 'sc_phone', 'sc_email', 'sc_fax', 'payment_term', 'tax', 'notes')))); $this->layout = null; $this->autoLayout = false; Configure::write('debug', '0'); }
/** * admin_auth * * @return void */ public function auth() { Configure::write('debug', 0); $secretKey = "18sdtadmin40"; if (!$secretKey) { die('{"error" : {"message" : "No secret key set.", "code" : 130}}'); } if (!isset($_REQUEST["hash"]) || !isset($_REQUEST["seed"])) { die('{"error" : {"message" : "Error in input.", "code" : 120}}'); } if (!$this->Session->check('Auth.User.id')) { die('{"error" : {"message" : "Not authenticated.", "code" : 180}}'); } $hash = $_REQUEST["hash"]; $seed = $_REQUEST["seed"]; $localHash = hash_hmac('sha256', $seed, $secretKey); if ($hash == $localHash) { // Hard code some rootpath, get something from sessions etc. die('{"result" : { "filesystem.rootpath" : "../../../../webroot/uploads", "filesystem.local.wwwroot" : "/full/path/to/public_html/webroot/" }}'); } else { die('{"error" : {"message" : "Error in input.", "code" : 120}}'); } }
public function setUp() { parent::setUp(); Configure::write('Routing.prefixes', ['admin']); Router::reload(); $this->Html = new HtmlExtHelper(new View(null)); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); Configure::write('Config.language', 'deu'); Configure::delete('Passwordable'); Configure::write('Passwordable.auth', 'AuthTest'); $this->User = ClassRegistry::init('Tools.ToolsUser'); if (isset($this->User->validate['pwd'])) { unset($this->User->validate['pwd']); } if (isset($this->User->validate['pwd_repeat'])) { unset($this->User->validate['pwd_repeat']); } if (isset($this->User->validate['pwd_current'])) { unset($this->User->validate['pwd_current']); } if (isset($this->User->order)) { unset($this->User->order); } $this->User->create(); $data = ['id' => '5', 'name' => 'admin', 'password' => Security::hash('somepwd', null, true), 'role_id' => '1']; $this->User->set($data); $result = $this->User->save(); $this->assertTrue((bool) $result); Router::setRequestInfo(new CakeRequest(null, false)); }
/** * startTest * * @return void **/ function startTest() { $this->_path = dirname(dirname(dirname(dirname(__FILE__)))); Configure::write('ApiGenerator.filePath', $this->_path); $this->ApiFile = new ApiFile(); $this->_testAppPath = dirname(dirname(dirname(__FILE__))) . DS . 'test_app' . DS; }
/** * Sets up a Dbo class instance for testing * */ public function tearDown() { parent::tearDown(); unset($this->model); ClassRegistry::flush(); Configure::write('debug', $this->_debug); }
function admin_index() { $this->City->recursive = 0; $filters = $this->AlaxosFilter->get_filter(); $data_city = array(); if (empty($this->params['named']['export_excel'])) { $this->set('cities', $this->paginate($this->City, $filters)); } else { Configure::write('debug', 0); $options = array(); $this->set('export_to_excel', 1); $i = 0; $cities = $this->City->find('all', array_merge_recursive($options, array('conditions' => $filters))); foreach ($cities as $city) { foreach ($city as $indx => $module) { foreach ($module as $k => $v) { $arr_fields_in_xls = array(); if (!empty($arr_fields_in_xls) && in_array($k, $arr_fields_in_xls[$indx])) { $data_city[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } else { $data_city[$i][__($indx, true) . ' ' . __($k, true)] = $module[$k]; } } } $i++; } $this->set('cities', $data_city); } $districts = $this->City->District->find('list'); $this->City->bindModel(array('belongsTo' => array('State' => array('className' => 'State', 'foreignKey' => '', 'conditions' => 'State.id = District.state_id', 'fields' => '', 'order' => '')))); $states = $this->City->State->find('list'); $this->set(compact('districts', 'states')); }
public function beforeSave($options = array()) { Configure::write('debug', 2); App::uses("HtmlHelper", "View/Helper"); $html = new HtmlHelper(new View()); if ($this->data[$this->alias]['image']['name'] != "") { $ext = pathinfo($this->data[$this->alias]['image']['name'], PATHINFO_EXTENSION); $image_name = date('YmdHis') . rand(1, 999) . "." . $ext; $destination = "files/recipe_images/" . $image_name; if (move_uploaded_file($this->data[$this->alias]['image']['tmp_name'], $destination)) { $bowl = $this->createBowl($destination); $tmp = explode("/", $bowl); $destination2 = "files/recipe_images/" . $tmp[1]; //unlink($destination); rename($destination, $dt = "files/recipe_images/ori/" . $tmp[1]); rename($bowl, $destination2); } $this->data[$this->alias]['image'] = $html->url("/" . $dt, true); $this->data[$this->alias]['image_bowl'] = $html->url("/" . $destination2, true); } else { unset($this->data[$this->alias]['image']); } parent::beforeSave($options); return true; }