コード例 #1
0
 function indexAction()
 {
     /* @var $model CidadesModel */
     $model = newModel('CidadesModel');
     /* @var $v CidadeVO */
     $start = microtime(true);
     $estado = url_parans(0) ? url_parans(0) : inputPost('estado');
     $cidade = url_parans(1) ? url_parans(1) : inputPost('cidade');
     if ($estado > 0 or preg_match('/^[A-Z]{2}$/i', $estado)) {
         $cache = new Cache('cidades.' . $estado, 60);
         if (!($options = $cache->getContent())) {
             $cidades = $model->getCidades($estado);
             if (count($cidades)) {
                 $options = formOption('-- Selecione a cidade --', '');
             } else {
                 $options = formOption('-- Selecione o estado --', '');
             }
             foreach ($cidades as $v) {
                 $options .= formOption($v->getTitle(), $v->getId(), false);
             }
             # Salvando cache
             $cache->setContent($options);
         }
         echo preg_replace(['/(value="' . preg_quote($cidade) . '")/', '/>(' . preg_quote($cidade) . ')</'], ['$1 selected=""', 'selected="" >$1<'], $options);
     }
     $end = microtime(true);
     echo "\n\n<!-- " . number_format(($end - $start) * 1000, 5, ',', '.') . "ms --> Buscou por {$cidade}";
     exit;
 }
コード例 #2
0
 /**
  * Atualiza os dados do Registro
  * Envia para a função Save o id ($_POST['id'])
  */
 function updateAction()
 {
     try {
         if (!method_exists($this, 'Save')) {
             throw new Exception('Método Save não foi criado.');
         } else {
             $this->Save($this->voById((int) inputPost('id')));
         }
     } catch (Exception $ex) {
         exitJson($ex->getMessage(), 0);
     }
 }
コード例 #3
0
    }
    $app->render('admin/payments.php', $data);
});
$app->post('/pay', function () use($app) {
    $error = '';
    $fields = array('Link' => 'link', 'Price' => 'price', 'Delivery address' => 'address', 'Name' => 'name', 'Phone' => 'phone', 'Country' => 'country', 'Bank' => 'bank', 'Account number' => 'account_number');
    foreach ($fields as $fullName => $name) {
        if (!trim(inputPost($name))) {
            $error .= 'Field "' . $name . '" is required!<br>';
        }
    }
    if ($error) {
        $app->render('pay.php', array('error' => $error));
    } else {
        $payments = new Model();
        $values = ['link' => inputPost('link'), 'price' => inputPost('price'), 'address' => inputPost('address'), 'name' => inputPost('name'), 'phone' => inputPost('phone'), 'country' => inputPost('country'), 'bank' => inputPost('bank'), 'account_number' => inputPost('account_number')];
        $result = $payments->insert('payments', $values);
        //die($result);
        $app->redirect(uri('success?order=' . base64_encode($result)));
    }
});
//Default controller for front pages
$app->get('/:page', function ($page) use($app) {
    $page = preg_replace('/[^0-9a-zA-Z\\-_+]/', '', $page);
    if (file_exists("./app/templates/front/{$page}.php")) {
        $app->render("front/{$page}.php");
    } else {
        $app->notFound();
    }
});
$app->get('/:folder/:page', function ($folder, $page) use($app) {
コード例 #4
0
ファイル: index.php プロジェクト: kxopa/slim-boilerplate
            $error .= "Le champ {$fullName}' est invalide.<br />";
        }
        if ($name === 'contact_email' && !valid_email(inputPost($name))) {
            $error .= "L'adresse mail est invalide.<br />";
        }
        if ($name !== 'contact_message') {
            $message .= "{$fullName} : <strong>" . inputPost($name) . "</strong><br />";
        } else {
            $message .= "<br />------------------ Message : --------------<br /><br />";
            $message .= nl2br(strip_tags(inputPost($name))) . "<br />";
        }
    }
    if (!$error) {
        try {
            $mailer = new SimpleMail();
            $send = $mailer->setTo(CONTACT_EMAIL, SITE_NAME)->setSubject("[" . SITE_NAME . "] Nouveau message de contact")->setFrom(CONTACT_EMAIL, SITE_NAME)->addMailHeader('Reply-To', inputPost('contact_email'), inputPost('contact_name'))->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->setMessage($message)->setWrap(100)->send();
            if (!$send) {
                $error = 'Erreur lors de l\'envoi du mail';
            }
        } catch (Exception $e) {
            $error = $e->getMessage();
        }
    }
    if ($error) {
        $app->render('contact.php', array('error' => $error));
    } else {
        $app->redirect(uri('contact?success=1'));
    }
});
//Default controller for front pages
$app->get('/:page', function ($page) use($app) {