public function postSavetranslation() { SiteHelpers::globalXssClean(); $form = "<?php \n"; $form .= "return array( \n"; foreach ($_POST as $key => $val) { if ($key != '_token' && $key != 'lang' && $key != 'file') { if (!is_array($val)) { $form .= '"' . $key . '" => "' . strip_tags($val) . '", ' . " \n "; } else { $form .= '"' . $key . '" => array( ' . " \n "; foreach ($val as $k => $v) { $form .= ' "' . $k . '" => "' . strip_tags($v) . '", ' . " \n "; } $form .= "), \n"; } } } $form .= ');'; //echo $form; exit; $lang = Input::get('lang'); $file = Input::get('file'); $filename = './protected/app/lang/' . $lang . '/' . $file; // $filename = 'lang.php'; $fp = fopen($filename, "w+"); fwrite($fp, $form); fclose($fp); return Redirect::to('config/translation?edit=' . $lang . '&file=' . $file)->with('messagetext', 'Translation has been saved !')->with('msgstatus', 'success'); }
function postSave($id = 0) { $trackUri = $this->data['trackUri']; //$rules = $this->validateForm(); $validator = Validator::make(Input::all(), Ncategories::$rules); SiteHelpers::globalXssClean(); if ($validator->passes()) { if (!is_null(Input::file('file'))) { $file = Input::file('file'); $destinationPath = ROOT . '/uploads/categories/'; $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); //if you need extension of the file $newfilename = Input::get('CategoryName') . '_' . time() . '.' . $extension; $uploadSuccess = Input::file('file')->move($destinationPath, $newfilename); if ($uploadSuccess) { $data['Picture'] = $newfilename; $orgFile = $destinationPath . '/' . $newfilename; $thumbFile = $destinationPath . '/thumb/' . $newfilename; //SiteHelpers::cropImage($this->img_width , $this->img_height , $orgFile , $extension, $thumbFile); SiteHelpers::resizewidth("180", $orgFile, $thumbFile); if (Input::get('action') != "") { $data_old = $this->model->getRow(Input::get('action')); @unlink(ROOT . '/uploads/categories/' . $data_old->Picture); @unlink(ROOT . '/uploads/categories/thumb/' . $data_old->Picture); } } } $data['postion'] = Input::get('postion'); $data['CategoryName'] = Input::get('CategoryName'); $data['Description'] = Input::get('Description'); $data['lang'] = $this->lang; $data['created'] = time(); $data['status'] = Input::get('status'); $data['alias'] = SiteHelpers::seoUrl(trim($data['CategoryName'])); $data['keywords'] = Input::get('keywords'); $data['seo_meta'] = Input::get('seo_meta'); //$data = $this->validatePost('categories'); $ID = $this->model->insertRow($data, Input::get('CategoryID')); // Input logs if (Input::get('CategoryID') == '') { $this->inputLogs("New Entry row with ID : {$ID} , Has Been Save Successfull"); $id = SiteHelpers::encryptID($ID); } else { $this->inputLogs(" ID : {$ID} , Has Been Changed Successfull"); } // Redirect after save //$md = str_replace(" ","+",Input::get('md')); $redirect = !is_null(Input::get('apply')) ? 'Ncategories/add/' . $id : 'Ncategories?md='; return Redirect::to($redirect)->with('message', SiteHelpers::alert('success', Lang::get('core.note_success'))); } else { return Redirect::to('Ncategories/add/' . $id)->with('message', SiteHelpers::alert('error', Lang::get('core.note_error')))->withErrors($validator)->withInput(); } }
function validatePost($table) { $str = $this->info['config']['forms']; $data = array(); foreach ($str as $f) { $field = $f['field']; if ($f['view'] == 1) { if ($f['type'] == 'textarea_editor' || $f['type'] == 'textarea') { $content = isset($_POST[$field]) ? $_POST[$field] : ''; /* Use this filter for html sanity $data[$field] = Purifier::clean($content); */ $data[$field] = $content; } else { SiteHelpers::globalXssClean(); if (!is_null(Input::get($field))) { $data[$field] = Input::get($field); } // if post is file or image if ($f['type'] == 'file') { if (!is_null(Input::file($field))) { $file = Input::file($field); $destinationPath = './' . str_replace('.', '', $f['option']['path_to_upload']); $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); //if you need extension of the file $rand = rand(1000, 100000000); $newfilename = strtotime(date('Y-m-d H:i:s')) . '-' . $rand . '.' . $extension; $uploadSuccess = Input::file($field)->move($destinationPath, $newfilename); if ($f['option']['resize_width'] != '0' && $f['option']['resize_width'] != '') { if ($f['option']['resize_height'] == 0) { $f['option']['resize_height'] = $f['option']['resize_width']; } $orgFile = $destinationPath . '/' . $newfilename; SiteHelpers::cropImage($f['option']['resize_width'], $f['option']['resize_height'], $orgFile, $extension, $orgFile); } if ($uploadSuccess) { $data[$field] = $newfilename; } } else { unset($data[$field]); } } // if post is checkbox if ($f['type'] == 'checkbox') { if (!is_null(Input::get($field))) { $data[$field] = implode(",", Input::get($field)); } } // if post is date if ($f['type'] == 'date') { $data[$field] = date("Y-m-d", strtotime(Input::get($field))); } // if post is seelct multiple if ($f['type'] == 'select') { if (isset($f['option']['is_multiple']) && $f['option']['is_multiple'] == 1) { $data[$field] = implode(",", Input::get($field)); } } } } } $global = isset($this->access['is_global']) ? $this->access['is_global'] : 0; if ($global == 0) { $data['entry_by'] = Session::get('uid'); } return $data; }