/** * Método para manipulação da foto do perfil * Este método utiliza uma classe externa que não foi criada por mim */ public function uploadFoto() { if (Input::exists('files')) { $fotoperfil = isset($_FILES[$this->coluna]) ? $_FILES[$this->coluna] : null; if ($fotoperfil['error'] > 0) { echo 'Nenhuma imagem enviada.<br>'; } else { // array com extensões válidas $validExtensions = array('.jpg', '.jpeg'); // pega a extensão do arquivo enviado $fileExtension = strrchr($fotoperfil['name'], "."); // testa se extensão é permitida if (in_array($fileExtension, $validExtensions)) { $manipulator = new ImageManipulator($fotoperfil['tmp_name']); // o tamanho da imagem poderia ser 800x600 $width = $manipulator->getWidth(); $height = $manipulator->getHeight(); // Encontrando o centro da imagem $centreX = round($width / 2); // 400 $centreY = round($height / 2); //300 // Define canto esquerdo de cima if ($width > $height) { // Parâmetros caso a imagem fornecida seja no formato paisagem $x1 = $centreX - $centreY; // 400 - 300 = 100 "Topo esquerdo X" $y1 = 0; // "Topo esquerdo Y" // Define canto direito de baixo $x2 = $centreX + $centreY; // 400 + 300 = 700 / 2 "Base X" $y2 = $centreY * 2; // 300 * 2 = 600 "Base Y" } else { // Parâmetros caso a imagem não seja no formato paisagem $y1 = $centreY - $centreX; // 400 - 300 = 100 "Topo esquerdo X" $x1 = 0; // "Topo esquerdo Y" // Define canto direito de baixo $y2 = $centreX + $centreY; // 400 + 300 = 700 / 2 "Base X" $x2 = $centreX * 2; // 300 * 2 = 600 "Base Y" } // corta no centro 200x200 $manipulator->crop($x1, $y1, $x2, $y2); // redimensiona a imagem para 400x400 $manipulator->resample(400, 400, true); $manipulator->save(IMG_UPLOADS_FOLDER . $this->arquivo_temp); $this->foto_enviada = true; } else { $this->foto_enviada = false; } } } }
public function RequesracallAction() { if (Input::exists() && Token::check(Input::get('token'))) { $this->_DB->insert('phones', array('id' => 0, 'name' => Input::get('name'), 'number' => Input::get('number'))); $this->registerAction(); } ?> <form action="" method="post"> <div class="field"> <LABEL for="name">Name: </LABEL> <input type="text" name="name" id="name" /> </div> <div class="field"> <label for="number">Number: </label> <input type="tel" name="number" id="number" /> </div> <input type="hidden" name="token" value="<?php echo Token::generate(); ?> " /> <input type="submit" value="Save"/> </form> <?php }
public function send() { $out = ''; if (Input::exists("post")) { $this->subject = Input::method("POST", "s"); $this->name = Input::method("POST", "n"); $this->email = Input::method("POST", "e"); $this->message = Input::method("POST", "m"); $this->lang = Input::method("POST", "l"); $this->ip = get_ip::ip(); $_SESSION["send_view"] = isset($_SESSION["send_view"]) ? $_SESSION["send_view"] + 1 : 1; if ($_SESSION["send_view"] > 150) { if ($this->lang == "en") { $out = '<font color="red">Error !</font>'; } else { $out = '<font color="red">მოხდა შეცდომა !</font>'; } exit; } // echo $this->email; if (empty($this->subject) || empty($this->name) || empty($this->email) || empty($this->message) || empty($this->lang)) { if ($this->lang == "en") { $out = '<font color="red">All field are required !</font>'; } else { $out = '<font color="red">ყველა ველის შევსება სავალდებულოა !</font>'; } } else { if (!$this->isValidEmail($this->email)) { if ($this->lang == "en") { $out = '<font color="red">Email is not valid !</font>'; } else { $out = '<font color="red">გთხოვთ გადაამოწმოთ ელ-ფოსტის ველი !</font>'; } } else { $i = $this->selectEmailGeneralInfo(); $message = wordwrap(strip_tags($this->message), 70, "\r\n"); $message .= '<br />Sender IP: ' . $this->ip; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'To: ' . $i["fromname"] . ' <' . $i["from"] . '>' . "\r\n"; $headers .= 'From: ' . $this->name . ' <' . $this->email . '>' . "\r\n"; $send_email = mail($to, $this->subject, $message, $headers); if ($send_email) { if ($this->lang == "en") { $out = '<font color="green">Message sent !</font>'; } else { $out = '<font color="green">შეტყობინება გაგზავნილია !</font>'; } } else { if ($this->lang == "en") { $out = '<font color="red">Error !</font>'; } else { $out = '<font color="red">მოხდა შეცდომა !</font>'; } } } } } echo $out; }
/** * Initializes the session system. */ private static function initialize() { // Make sure it's not initialized already if (self::$initialized) { return; } // See if we were given a session id explicitly // If so we also need a matching token to allow it $setSid = false; if (Input::exists('_sid')) { session_id(Input::get('_sid')); $setSid = true; } // Start the default PHP session self::$prefix = crc32(APP_SALT) . '_'; session_name('session'); session_start(); // Set the initialized flag self::$initialized = true; // Make sure the token is good before we allow // explicit session id setting if ($setSid) { Auth::checkToken(); } }
public function login($id = null) { $user = $this->user; $this->data['user']['name'] = $user->data()->user; Config::set('html.title', 'Авторизация'); Config::set('html.description.val', 'На этой странице можно залогиниться'); //$user = new User(); $salt = uniqid(); if (!Session::exists(Config::get('session.token_name'))) { Token::generate(); } if (Input::exists()) { if (Token::check(Input::get('token'))) { $validate = new VALIDATE(); $validation = $validate->check($_POST, array('user' => array('required' => true), 'password' => array('required' => true))); if ($validate->passed()) { $remember = Input::get('remember') === 'on' ? true : false; $login = $user->login(Input::get('user'), Input::get('password'), null); if ($login) { Redirect::to('/'); } else { echo '<p>Sorry, logging in failed</p>'; } } else { foreach ($validation->errors() as $error) { //echo $error, '<br/>'; $this->data['validate_errors'][] = $error; } } } } //$this->data['id']=$id; //$this->data['name']=Input::get('name'); $this->view('user/login'); }
public function install() { if (Request::isMethod('post')) { $step = Session::get('step'); $inputs = Input::all(); foreach ($inputs as $key => $value) { Session::put($key, $value); } if (Input::exists('back')) { $step--; } else { $step++; } Session::put('step', $step); if ($step < 7) { return Redirect::to("/install?step=" . $step); } else { return Redirect::to("/install/complete"); } } else { $step = Input::get('step') ? Input::get('step') : 1; Session::put('step', $step); return View::make("installer.step" . $step); } }
/** * @todo Sanitizar entrada de dados */ public function cadastra() { if (Input::exists()) { $pessoaJuridicaTelefone = $this->setDados(); try { $telefone = $this->model->gravar($pessoaJuridicaTelefone); } catch (Exception $e) { CodeFail((int) $e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } $return['fone'] = $telefone->getFone(); foreach ($this->operadoras as $catg_tel) { if ($catg_tel->getCdVlCategoria() == $telefone->getCdVlCatgOperadora()) { $return['operadora'] = $catg_tel->getDescVlCatg(); } } foreach ($this->categorias as $pj_tel) { if ($pj_tel->getCdVlCategoria() == $telefone->getCdVlCatgFonePj()) { $return['categoria'] = $pj_tel->getDescVlCatg(); } } $return['observacao'] = $telefone->getObservacao(); $return['cd_pj_fone'] = $telefone->getCdPjFone(); echo json_encode($return); } }
public function getValue() { parent::getValue(); if (\Request::isMethod('post') && !\Input::exists($this->name)) { $this->value = $this->unchecked_value; } $this->checked = (bool) ($this->value == $this->checked_value); }
public function getNewValue() { $process = \Input::get('search') || \Input::get('save') ? true : false; if ($process && \Input::exists($this->lat)) { $this->new_value['lat'] = \Input::get($this->lat); $this->new_value['lon'] = \Input::get($this->lon); } }
public function index() { if (\Input::exists('query')) { $projects = $this->service->searchProjects(Input::get('query')); } else { $projects = $this->service->getProjects(\Authorization::user()); } return $this->returnProjectModels($projects); }
public function request() { if (Input::exists()) { if (Input::get('del_relacao') != 's') { $this->cadastra(); } else { $this->apagar(); } } }
public static function cssClass($field, array $erros) { if (Input::exists()) { if (in_array($field, $erros)) { return 'has-error'; } else { return 'has-success'; } } return ''; }
/** * Registra um usuário com dados recebidos do formulário * */ public function salvarUsuario($id = null) { if (Input::exists()) { if (Token::check(Input::get('token'))) { $usuario = $this->setDados(); if ($this->getModel()->findByLogin($usuario)) { $this->atualizar = true; } $msg = $this->getModel()->gravar($usuario, $this->atualizar); Session::flash('msg', $msg['fc_criar_usuario'], 'success'); } } }
public function cadastra() { if (Input::exists()) { $pessoaFisicaEndereco = $this->setDados(); try { $endereco = $this->model->gravar($pessoaFisicaEndereco); } catch (Exception $e) { CodeFail((int) $e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } $return = $this->pessoaFisicaEnderecoModel->setDTO($endereco)->getArrayDados(); echo json_encode($return); } }
public function run() { if (Input::exists('post')) { //check if form loaded propely if (Token::check(Input::get('token'))) { echo $this->model->process(); } else { return miscellaneous::Error(); } } else { return miscellaneous::Error(); } }
public static function boot() { parent::boot(); static::saving(function ($user) { if ($user->skipEvents) { return; } // If we're updating the password, hash it if (Input::exists('password')) { $user->password = Hash::make(Input::get('password')); } }); }
public function cadastra() { if (Input::exists()) { $obj = $this->setDados(); try { $moradorEndereco = $this->model->gravar($obj); $arrayDados = $this->moradorEnderecoModel->setDTO($moradorEndereco)->getArrayDados(); echo json_encode($arrayDados); } catch (Exception $e) { CodeFail((int) $e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } } }
/** * Make sure the CSRF token exists and is valid. * This should be checked on most forms and get methods that manipulate state. */ public static function checkToken() { // Check to see if the token is what it needs to be if (Input::exists('_token') && Input::get('_token') == Session::getToken()) { return; } // Check to see if it's the secret development token if (Input::exists('_token') && Input::get('_token') === DEVELOPMENT_KEY) { return; } // Throw a token mismatch error throw new Exception('Token mismatch.'); }
public function getNewValue() { $process = \Input::get('search') || \Input::get('save') ? true : false; if ($process && \Input::exists($this->lat)) { $this->new_value['lat'] = \Input::get($this->lat); $this->new_value['lon'] = \Input::get($this->lon); } elseif ($this->action == "insert" && $this->insert_value != null) { $this->edited = true; $this->new_value = $this->insert_value; } elseif ($this->action == "update" && $this->update_value != null) { $this->edited = true; $this->new_value = $this->update_value; } }
public function create(array $Params = array()) { //Load Everything $this->loadModel(); $this->loadView(); if (\Input::exists()) { $this->Model->validateInput($_POST); if ($this->Model->isAuthenticaed == true) { \Redirect::to("home"); } } //Lets Go $this->Model->create(); $this->View->create($this->Model); }
/** * Não existe update para esta tabela * Ao tentar gravar um registro que já existe, o método retorna o * array 'msg' => 'Registro já existe!' */ public function cadastra() { if (Input::exists()) { $obj = $this->setDados(); try { $dados = $this->model->gravar($obj); if (!is_array($dados)) { $dados = $this->ocorrenciaPessoaFisicaEnvolvidaModel->setDTO($dados)->getArrayDados(); } echo json_encode($dados); } catch (Exception $e) { CodeFail((int) $e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } } }
public static function doUpdate() { if (Input::exists()) { switch (Input::get('action')) { case 'switch_completion': self::switchCompletion(); break; case 'item_insert': self::insertItem(); break; case 'item_update': self::updateItem(); break; } } }
function createPage($smarty) { if (!Users::isAdmin()) { Redirect::error(403); } if (Input::exists() && Input::get('action') === 'admin_item_insert') { Update::adminInsertItem(); } if (Input::exists() && Input::get('action') === 'admin_item_update') { Update::adminUpdateItem(); } if (Input::exists() && Input::get('action') === 'admin_item_delete') { Update::adminDeleteItem(); } $smarty->assign('columns', Queries::editableEntry(Input::get('table', 'get'), Input::get('id', 'get'))); return $smarty; }
function createPage($smarty) { if (Users::loggedIn()) { Redirect::to('?page=profile'); } if (Input::exists()) { if (Input::get('action') === 'register') { $validation = new Validate(); $validation->check($_POST, array_merge(Config::get('validation/register_info'), Config::get('validation/set_password'))); if ($validation->passed()) { try { Users::create(array('student_id' => Input::get('sid'), 'password' => Hash::hashPassword(Input::get('password')), 'permission_group' => 1, 'name' => Input::get('name'), 'email' => Input::get('email'), 'umail' => Input::get('sid') . '@umail.leidenuniv.nl', 'phone' => Phone::formatNumber(Input::get('phone')), 'joined' => DateFormat::sql())); Users::login(Input::get('sid'), Input::get('password')); Notifications::addSuccess('You have been succesfully registered!'); Redirect::to('?page=profile'); } catch (Exception $e) { Notifications::addError($e->getMessage()); } } else { Notifications::addValidationFail($validation->getErrors()); } } if (Input::get('action') === 'login') { $validation = new Validate(); $validation->check($_POST, Config::get('validation/login')); if ($validation->passed()) { $login = Users::login(Input::get('sid'), Input::get('password'), Input::getAsBool('remember')); if ($login) { Notifications::addSuccess('You have been logged in!'); Redirect::to('?page=profile'); } else { Notifications::addValidationFail('Invalid student number or password.'); } } else { Notifications::addValidationFail($validation->getErrors()); } } } $smarty->assign('remember', Input::getAsBool('remember')); $smarty->assign('name', Input::get('name')); $smarty->assign('sid', Input::get('sid')); $smarty->assign('email', Input::get('email')); $smarty->assign('phone', Input::get('phone')); return $smarty; }
public function cadastra() { if (Input::exists()) { $obj = $this->setDados(); $deletar = isset($_POST['delete']) ? Input::get('delete') : null; try { $gravar = array(); $relacDados = array(); if ($gravar = $this->model->save($obj, $deletar)) { $relacDados = $this->relacionadosModel->setDTO($obj)->getArrayDados(); } echo json_encode(array_merge($gravar, $relacDados)); } catch (Exception $e) { CodeFail((int) $e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine()); } return false; } }
public function create(array $Params = array()) { //Load Everything $this->loadModel(); $this->loadView(); if (\Input::exists()) { $this->Model->validateInput($_POST); if ($this->Model->registeredUser() == true) { echo $this->Model->getUser()->Data->UserID; \Session::put(\Config::get("session/session_name"), $this->Model->getUser()->Data->UserID); $this->setAlert('You were registered successfully.', "index"); \Redirect::to("home"); } } //Testing everything is loaded $this->Model->create(); $this->View->create($this->Model); }
public function loginProcess() { //check if the run request from submition form if (Input::exists('post')) { //check if form loaded propely if (Token::check(Input::get('token'))) { if ($this->model->login()) { header("Location: " . SITE_URL . '/admin'); } else { Session::flush('error-login', Messages::login_unsuccess()); header("Location: " . SITE_URL . "/admin/login"); } } else { return miscellaneous::Error(); } } else { return miscellaneous::Error(); } }
public function watchAction() { if (!Input::exists('get') || !isset($_GET['file'])) { Redirect::to('videos.php'); } $filename = Input::get('file'); $ext = explode('.', $filename); $ext = array_pop($ext); //if (!$this->_user->isLoggedIn()) { // Redirect::to('index.php'); //} ?> <html> <head> <title>Videos - <?php echo $filename; ?> </title> <link rel="stylesheet" type="text/css" href="css/main.css"> </head> <body> <section> <button id="small">Small</button> <button id="medium">Medium</button> <button id="large">Large</button> <button id="original">Original</button> <br /> <video id="video" width="720" controls > <source src="<?php echo $filename; ?> " type="video/<?php echo $ext; ?> "> Video not supported! </video> <script src="video.js"></script> </section> </body> </html> <?php }
public function run() { //check if the run request from submition form if (Input::exists('post')) { //check if form loaded propely if (Token::check(Input::get('token'))) { if ($this->model->process()) { header("Location: " . SITE_URL); } else { Session::flush('error-login', 'Username or password is incorrrect!'); header("Location: " . SITE_URL . "/login"); } } else { return miscellaneous::Error(); } } else { return miscellaneous::Error(); } }
function create() { Auth::checkLoggedIn(); $course = Course::fromId(Input::get('courseid')); if (!$course->canEdit(Auth::getUser())) { throw new Exception('You are not allowed to create an entry in this course.'); } $entry = Entry::create(Auth::getUser(), $course, Input::get('title'), Input::get('description')); if (Input::exists('due_at')) { $entry->setDueTime(Input::get('due_at')); } if (Input::exists('display_at')) { $entry->setDisplayTime(Input::get('display_at')); } if (Input::exists('visible')) { $entry->setVisible(Input::getBoolean('visible')); } View::renderJson($entry->getContext(Auth::getUser())); }