本文整理匯總了PHP中is_post函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_post函數的具體用法?PHP is_post怎麽用?PHP is_post使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_post函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: register
public function register()
{
if (is_post()) {
$this->loadHelper('Validator');
if (captcha()) {
$data = ['email' => validate('email', 'email'), 'username' => validate('required', 'username'), 'password' => password_hash(validate('required', 'register_token'), PASSWORD_BCRYPT), 'token' => str_rand(40)];
if (validator($data)) {
if ($this->user->checkExistUser($data['email'])) {
$data2 = ['firstname' => validate('required', 'firstname'), 'lastname' => validate('required', 'lastname'), 'nickname' => validate('required', 'nickname'), 'major' => validate('required', 'major')];
if (validator($data2)) {
$this->user->createUser($data, $data2);
$validate = $this->user->validate($data['email'], $_POST['register_token']);
if (!empty($validate)) {
$_SESSION['auth'] = $validate;
$_SESSION['user'] = $this->user->getDetail($validate['id']);
cache_forgot('user.members.' . user('major'));
cache_forgot('user.get.members.' . user('major'));
}
}
}
}
}
}
return redirect('');
}
示例2: install_check
public static function install_check()
{
//Check the cache folder
if (!Backend::checkConfigFile()) {
if (function_exists('posix_getgrgid') && function_exists('posix_getegid')) {
if ($group = posix_getgrgid(posix_getegid())) {
$group = $group['name'];
}
}
$values = array('file' => Backend::getConfigFileLocation(), 'group' => isset($group) ? $group : false);
Backend::addContent(Render::file('config_value.fix_config.tpl.php', $values));
return false;
}
if (self::get('settings.ConfigValueSet')) {
return true;
}
if (is_post()) {
$result = true;
foreach ($_POST as $name => $value) {
$name = str_replace('_', '.', $name);
if (in_array($name, array('application.Title', 'application.Moto', 'application.HelpBoxContent', 'application.Description', 'author.Name', 'author.Email', 'author.Website'))) {
if (!self::set($name, $value)) {
Backend::addError('Could not set ' . $name);
$result = false;
}
} else {
var_dump('Rejected:', $name);
}
}
self::set('settings.ConfigValueSet', $result);
Controller::redirect();
}
Backend::addContent(Render::file('config_value.values.tpl.php'));
return false;
}
示例3: confirm
/**
* Show a simple confirmation form
*/
public static function confirm($label)
{
if (is_post()) {
if (isset($_POST['confirm_yes'])) {
return true;
} else {
if (isset($_POST['confirm_no'])) {
return false;
}
}
}
?>
<?php
print_header();
?>
<div id="confirm_form">
<?php
\Meta\Core\Form::open();
?>
<h2><?php
echo $label;
?>
</h2>
<input type="submit" name="confirm_yes" value="Sim" />
<input type="submit" name="confirm_no" value="Nao" />
<?php
\Meta\Core\Form::close();
?>
</div>
<?php
print_footer();
?>
<?php
exit;
}
示例4: action_create
public function action_create()
{
if (is_post()) {
$parameters = get_previous_parameters();
$object = new CommentObj();
$object = $object->fromRequest();
$object['foreign_id'] = empty($object['foreign_id']) ? reset($parameters) : $object['foreign_id'];
$object['foreign_table'] = empty($object['foreign_table']) ? table_name(get_previous_area()) : $object['foreign_table'];
//If we don't have a logged in user, create a dummy account
if (!BackendUser::check()) {
$query = new SelectQuery('BackendUser');
$query->filter('`email` = :email');
if ($old_user = Controller::getVar('user')) {
$existing_user = $query->fetchAssoc(array(':email' => $old_user['email']));
}
switch (true) {
case $existing_user && $existing_user['confirmed'] && $existing_user['active']:
//Attribute quote to user? Seems risque, actually, if I know a user's email address, I can just attribute to him. Auth first
Backend::addError('Comment not added. Please login first');
return false;
break;
case $existing_user && !$existing_user['confirmed'] && $existing_user['active']:
//Unregistered user commented before
$object['user_id'] = $existing_user['id'];
break;
default:
case !$existing_user:
$user_data = array('name' => $old_user['name'], 'surname' => '', 'email' => $old_user['email'], 'website' => $old_user['website'], 'username' => $old_user['email'], 'password' => get_random(), 'confirmed' => 0, 'active' => 1);
$user = self::getObject('BackendUser');
if ($user->create($user_data)) {
$object['user_id'] = $user->array['id'];
$url = SITE_LINK . '/?q=backend_user/confirm/' . $user->array['salt'];
$app_name = ConfigValue::get('Title');
$message = <<<END
Hi {$user->array['name']}!
Thank you for your comment on {$app_name}. An account has automatically been created for you. To activate it, please click on the following link:
{$url}
Please note that you don't need to do this for your comments to show, but this account will be deleted if it isn't confirmed in a weeks time.
Regards
END;
send_email($user->array['email'], 'Thank you for your comment.', $message);
} else {
Backend::addError('Could not create user to add Comment');
return false;
}
break;
}
}
$object = array_filter($object, create_function('$var', 'return !is_null($var);'));
Controller::setVar('obj', $object);
}
return parent::action_create();
}
示例5: stage4
public function stage4()
{
if (is_post()) {
if (Installer::stage4()) {
return redirect('complete');
}
}
render('stage4');
}
示例6: entry_password_edit
function entry_password_edit()
{
$model = model::load('user');
$_POST['user_id'] = $this->user_id;
if (is_post() && $model->edit_password($_POST) === false) {
$this->assign['message'] = $model->message;
}
$this->display('password_edit');
}
示例7: entry_comment
function entry_comment()
{
$feed_mod = model::load('feed');
$feed_mod->init('comments');
if (is_post()) {
$feed_mod->edit($_POST);
}
$this->assign['comment'] = $feed_mod->get($_GET);
$this->display('comment_edit');
}
示例8: fromRequest
function fromRequest()
{
$data = parent::fromRequest();
if (is_post() && array_key_exists('mime_type', $data)) {
if (!empty($data['meta_info']['mime']) && $data['mime_type'] != $data['meta_info']['mime']) {
$data['mime_type'] = $data['meta_info']['mime'];
}
}
return $data;
}
示例9: checkConfiguration
public static function checkConfiguration()
{
// configuration installer manager
$cfgFile = abspath('app/config.php');
if (file_exists($cfgFile)) {
return;
}
?>
<h2>Please configure the database</h2>
<form method="POST">
<label>Database host</label> <input type="text" name="DB_HOST" value="localhost">
<br/>
<label>Database user</label> <input type="text" name="DB_USER" value="root">
<br/>
<label>Database password</label> <input type="text" name="DB_PASS" value="">
<br/>
<label>Database name</label> <input type="text" name="DB_NAME" value="reservic">
<br/><br/>
<input type="submit" value="Install configuration file">
</form>
<?php
// write config file
if (is_post()) {
// check database connectivity
try {
$dbh = new \PDO('mysql:host=' . $_POST['DB_HOST'] . ';dbname=' . $_POST['DB_NAME'], $_POST['DB_USER'], $_POST['DB_PASS']);
} catch (\Exception $e) {
?>
<h2>Database connection error: <?php
echo $e->getMessage();
?>
</h2><?php
exit;
}
// create config file content
$content = "<?php\n";
foreach ($_POST as $key => $val) {
$content .= "define('{$key}', '{$val}');\n";
}
// try write config file
if (!file_put_contents($cfgFile, $content)) {
?>
<h2>The file <?php
echo $cfgFile;
?>
is not writable!
Please set write permission for the app/ folder</h2>
<?php
exit;
}
Flash::success(t('Database configuration saved.'));
redirect(page_home());
}
exit;
}
示例10: entry_admin_edit
function entry_admin_edit()
{
$model = model::load('user');
if (is_post() && !$model->edit($_POST)) {
$this->assign['message'] = $model->message;
}
if ($_GET['user_id']) {
$this->assign['admin'] = $model->get($_GET);
}
$this->display('admin_edit');
}
示例11: post_create
public function post_create($id = false)
{
$result = parent::post_create();
if ($result instanceof ContentObj) {
/* TODO This can easily "overwrite" existing urls */
if (is_post() && Component::isActive('BackendQuery')) {
BackendQuery::add($result->array['name'], 'content/display/' . $result->array['id']);
}
}
return $result;
}
示例12: add_message
public function add_message()
{
$this->moduleTag = 'message';
if (is_post()) {
$data = $this->check_message();
$info = $this->model->add_message_info($data);
if (!$info) {
response_code('-1');
}
response_code('1');
}
}
示例13: p
public function p($action = null, $id = null)
{
switch ($action) {
case 'news':
if (is_post()) {
$gbn = new \app\models\GbNews();
$data = array('title' => $_POST['title'], 'content' => $_POST['content']);
if ($_POST['active'] === 'on') {
$data['active'] = 1;
} else {
$data['active'] = 0;
}
if (!empty($_POST['action'])) {
$data['id'] = $_POST['id'];
$gbn->update($data);
cache_forgot('home.gbnews');
cache_forgot('p.gbn.' . $data['id']);
} else {
$gbn->create($data);
cache_forgot('home.gbnews');
}
return redirect('admin/p/news');
} else {
$gbn = new \app\models\GbNews();
$gbn = $gbn->all();
$data = empty($gbn) ? array() : $gbn;
return $this->view('admin/gbnews', compact('data'));
}
break;
case 'write':
if (!empty($id)) {
$id = intval($id);
$news = new \app\models\GbNews();
$news = $news->getNews($id);
if (empty($news)) {
return $this->view('errors/404');
}
return $this->view('admin/gbnews_write', compact('news'));
}
return $this->view('admin/gbnews_write');
break;
case 'destroy':
echo $_POST['id'];
if (is_post()) {
$news = new \app\models\GbNews();
$news->remove($_POST['id']);
}
break;
default:
return redirect('admin');
break;
}
}
示例14: edit
/**
*/
function edit()
{
$a = $this->_get_info();
if (!$a) {
return _404();
}
$a['back_link'] = url('/@object');
$form_id = 'content_form';
jquery('
var form_id = "' . $form_id . '";
var bak_action = $("form#" + form_id).attr("action");
var preview_url = "' . url_user('/dynamic/preview/static_pages/' . $a['id']) . '";
$("[type=submit].preview", "form#" + form_id).on("click", function() {
$(this).closest("form").attr("target", "_blank").attr("action", preview_url)
})
$("[type=submit]:not(.preview)", "form#" + form_id).on("click", function() {
$(this).closest("form").attr("target", "").attr("action", bak_action)
})
');
// Prevent execution of template tags when editing page content
$exec_fix = ['{' => '{', '}' => '}'];
$keys_to_fix = ['text'];
foreach ((array) $keys_to_fix as $k) {
if (false !== strpos($a[$k], '{') && false !== strpos($a[$k], '}')) {
$a[$k] = str_replace(array_keys($exec_fix), array_values($exec_fix), $a[$k]);
}
}
$a = (array) $_POST + (array) $a;
if (is_post()) {
foreach ((array) $keys_to_fix as $k) {
if (false !== strpos($_POST[$k], '{') && false !== strpos($_POST[$k], '}')) {
$_POST[$k] = str_replace(array_values($exec_fix), array_keys($exec_fix), $_POST[$k]);
}
}
}
$_this = $this;
return form($a, ['hide_empty' => true, 'id' => $form_id])->validate(['__before__' => 'trim', 'name' => ['required', function (&$in) use($_this) {
$in = $_this->_fix_page_name($in);
return (bool) strlen($in);
}, function ($name, $tmp, $d, &$error) use($_this, $a) {
$id = db()->from($_this::table)->where('locale', $a['locale'])->where('name', $name)->get_one('id');
if ($id && $id != $a['id']) {
$error = t('Page with this name and locale already exists');
}
return $error ? false : true;
}], 'text' => 'required'])->update_if_ok(self::table, ['name', 'text', 'page_title', 'page_heading', 'meta_keywords', 'meta_desc', 'active'], 'id=' . $a['id'])->on_before_update(function () use($a, $_this) {
module_safe('manage_revisions')->add(['object_name' => $_this::table, 'object_id' => $a['id'], 'old' => $a, 'new' => $_POST, 'action' => 'update']);
})->on_after_update(function () {
common()->admin_wall_add(['static page updated: ' . $a['name'], $a['id']]);
cache_del('static_pages_names');
})->container($this->_get_lang_links($a['locale'], $a['name'], 'edit'))->text('name')->textarea('text', ['id' => 'text', 'cols' => 200, 'rows' => 10, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->text('page_title')->text('page_heading')->text('meta_keywords')->text('meta_desc')->active_box()->save_and_back()->preview();
}
示例15: entry_register
function entry_register()
{
$model = model::load('user');
if (is_post()) {
if ($model->register($_POST)) {
header('Location: /');
} else {
$this->assign['message'] = $model->message;
$this->display('message');
exit;
}
}
$this->display('register');
}