本文整理汇总了PHP中is_ajax_request函数的典型用法代码示例。如果您正苦于以下问题:PHP is_ajax_request函数的具体用法?PHP is_ajax_request怎么用?PHP is_ajax_request使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_ajax_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
include ROOT . "/library/browser/Browser.php";
$browser = new Browser();
if ($browser->getBrowser() == Browser::BROWSER_IE && $browser->getVersion() < 7) {
flash_error(lang("ie browser outdated"));
}
if (is_ajax_request()) {
$timezone = array_var($_GET, 'utz');
if ($timezone && $timezone != '') {
$usu = logged_user();
if ($usu instanceof Contact && $usu->isUser() && !$usu->getDisabled()) {
$usu->setTimezone($timezone);
$usu->save();
}
}
$this->redirectTo('dashboard', 'main_dashboard');
} else {
if (!(logged_user() instanceof Contact && logged_user()->isUser())) {
$this->redirectTo('access', 'login');
}
$this->setLayout("website");
$this->setTemplate(get_template_path("empty"));
}
}
示例2: header
<?php
include 'include/function.php';
include 'include/config.php';
include 'include/db.php';
if (!is_logged() or !isset($_GET['id'])) {
header("location: {$config['base_url']}");
exit;
}
$db = new DB();
if (isset($_POST['update'])) {
$id = $db->escape_string($_POST['id']);
$title = $db->escape_string($_POST['title']);
$artist = $db->escape_string($_POST['artist']);
$url = $db->escape_string($_POST['url']);
$db->query("UPDATE songs SET title='{$title}', artist='{$artist}', path='{$url}' WHERE id={$id}");
header('Location: ' . $config['base_url'] . 'dashboard?msg=update_success');
exit;
}
$db = new DB();
$row = $db->query("SELECT * FROM songs WHERE id={$_GET['id']}");
$row = $row->fetch_array();
$title = 'Update ' . $row['title'];
if (!is_ajax_request()) {
include './views/header.php';
}
include './views/update.php';
if (!is_ajax_request()) {
include './views/footer.php';
}
$db->close();
示例3: info_page
function info_page($info, $title = '系统消息')
{
if (is_ajax_request()) {
$layout = 'ajax';
} else {
$layout = 'web';
}
$data['top_title'] = $data['title'] = $title;
$data['info'] = $info;
render($data, $layout, 'info');
}
示例4: render
function render($view)
{
$viewFile = DUP_VIEWS_DIR . "/" . $view . ".php";
if (file_exists($viewFile)) {
if (!empty($this->layout) && !is_ajax_request()) {
ob_start();
include $viewFile;
$content_for_page = ob_get_contents();
ob_end_clean();
$layoutFile = DUP_VIEWS_DIR . "/layouts/" . $this->layout . ".php";
include $layoutFile;
} else {
include $viewFile;
}
}
}
示例5: output
function output()
{
global $lang;
if ($_SERVER['REQUEST_METHOD'] == 'POST' && method_exists($this, 'output_onpost_' . $_POST['form_name'])) {
return call_user_func(array($this, 'output_onpost_' . $_POST['form_name']));
}
$this->tpl['lang'] = $lang;
$this->tpl['link_restore_password'] = make_ref('/users', array("action" => "restore"));
$this->tpl['form_submit_url'] = make_ref('/users/loginform');
$output = template($this->tpl, __FILE__);
if (is_ajax_request()) {
print $output;
exit;
} else {
return $output;
}
}
示例6: render
public function render($data = NULL, $layout = NULL, $sharp = 'default')
{
if ($layout == null) {
if (is_ajax_request()) {
$layout = 'ajax';
} elseif (is_mobile_request()) {
//$layout = 'mobile';
$layout = 'web';
} else {
$layout = 'web';
}
}
$layout_file = AROOT . 'view/layout/' . $layout . '/' . $sharp . '.tpl.html';
if (file_exists($layout_file)) {
@extract($data);
require $layout_file;
}
}
示例7: define
//Define the OS file path separator
define('DS', DIRECTORY_SEPARATOR);
//Define the base file system path to MicroMVC
define('SYSTEM_PATH', realpath(dirname(__FILE__)) . DS);
//Define the base file system path to libraries
define('LIBRARY_PATH', SYSTEM_PATH . 'libraries' . DS);
//Define the base file system path to functions
define('FUNCTION_PATH', SYSTEM_PATH . 'functions' . DS);
//Define the base file system path to modules
define('MODULE_PATH', SYSTEM_PATH . 'modules' . DS);
//Define the base file system path to logs
define('LOG_PATH', SYSTEM_PATH . 'logs' . DS);
//Include the common file to continue loading
require_once FUNCTION_PATH . 'common.php';
//Discover whether this is an AJAX request or not
define('AJAX_REQUEST', is_ajax_request());
//Discover the current domain for the whole script
define('DOMAIN', current_domain());
//Define the file system path to the current site
define('SITE_PATH', SYSTEM_PATH . DOMAIN . DS);
//The file system path of the site's cache folder
define('CACHE_PATH', SITE_PATH . 'cache' . DS);
//The file system path of the site's config folder
define('CONFIG_PATH', SITE_PATH . 'config' . DS);
//The file system path of the site's models folder
define('MODEL_PATH', SITE_PATH . 'models' . DS);
//The file system path of the site's uploads folder
define('UPLOAD_PATH', SITE_PATH . 'uploads' . DS);
//The file system path of the site's views folder
define('VIEW_PATH', SITE_PATH . 'views' . DS);
//Override the PHP error handler
示例8: session_start
<?php
session_start();
define('DS', DIRECTORY_SEPARATOR);
define('PATH', dirname(__FILE__) . DS);
define('DOC_ROOT', str_replace(DS, '/', realpath($_SERVER['DOCUMENT_ROOT'])));
header("Content-type:text/html; charset=utf-8");
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
$default_lang = 'uk';
if (isset($_REQUEST['lang'])) {
$_SESSION['install']['lang'] = $_REQUEST['lang'];
header('Location: ' . $_SERVER['SCRIPT_NAME']);
}
$is_lang_selected = isset($_SESSION['install']['lang']);
$lang = $is_lang_selected ? $_SESSION['install']['lang'] : $default_lang;
define('LANG', $lang);
include PATH . "functions.php";
include PATH . DS . 'languages' . DS . LANG . DS . "language.php";
$steps = array(array('id' => 'start', 'title' => LANG_STEP_START), array('id' => 'license', 'title' => LANG_STEP_LICENSE), array('id' => 'php', 'title' => LANG_STEP_PHP_CHECK), array('id' => 'paths', 'title' => LANG_STEP_PATHS), array('id' => 'database', 'title' => LANG_STEP_DATABASE), array('id' => 'site', 'title' => LANG_STEP_SITE), array('id' => 'admin', 'title' => LANG_STEP_ADMIN), array('id' => 'config', 'title' => LANG_STEP_CONFIG), array('id' => 'cron', 'title' => LANG_STEP_CRON), array('id' => 'finish', 'title' => LANG_STEP_FINISH));
$current_step = 0;
if (is_ajax_request()) {
$step = $steps[(int) $_POST['step']];
$is_submit = isset($_POST['submit']);
echo json_encode(run_step($step, $is_submit));
exit;
}
$step_result = run_step($steps[$current_step], false);
echo render('main', array('steps' => $steps, 'is_lang_selected' => $is_lang_selected, 'lang' => LANG, 'current_step' => $current_step, 'step_html' => $step_result['html']));
示例9: execute_questions
function execute_questions()
{
$game = R::load('game', $_SESSION['quiz_id']);
if (quiz_has_expired($game)) {
finish_game($game);
redirect('result');
}
if (($question_id = find_first_unanswered_question(unserialize($game->answers))) == null) {
redirect('result');
}
$question = R::load('question', $question_id);
$answers = R::find('answer', 'question_id = ? ORDER BY RAND()', array($question_id));
$seconds_left = strtotime($game->started_at) - time() + QUIZ_TIMELIMIT;
ob_start();
if (is_ajax_request()) {
include_once dirname(__FILE__) . '/views/_question.php';
} else {
include_once dirname(__FILE__) . '/views/test-middle.php';
}
$content = ob_get_clean();
echo $content;
}
示例10: makeProperties
/**
* @return Model $this
* @throws Exception
*/
public function makeProperties()
{
if ($this->getStoredAql()) {
$this->makeAqlArray();
$i = 0;
foreach ($this->getStoredAqlArray() as $table) {
if ($i == 0) {
$this->_primary_table = $table['table'];
$this->addProperty($this->_primary_table . '_id');
}
$this->tableMakeProperties($table);
$i++;
}
} else {
$e = sprintf(self::E_INVALID_MODEL, $this->_model_name);
if (!is_ajax_request()) {
throw new Exception($e);
return $this;
} else {
exit_json(array('status' => 'Error', 'errors' => array($e)));
}
}
return $this;
}
示例11: __construct
/**
* Create the page object and set if this is an ajax request
* Optionally set other properties
* @param array $config
*/
public function __construct(array $config = array())
{
$this->is_ajax_request = \is_ajax_request();
$this->uri = $_SERVER['REQUEST_URI'];
foreach ($config as $k => $v) {
$this->{$k} = $v;
}
}
示例12: redirect_to_referer
/**
* Redirect to referer
*
* @access public
* @param string $alternative Alternative URL is used if referer is not valid URL
* @return null
*/
function redirect_to_referer($alternative = nulls)
{
$referer = get_referer();
if (true || !is_valid_url($referer)) {
if (is_ajax_request()) {
$alternative = make_ajax_url($alternative);
}
redirect_to($alternative);
} else {
if (is_ajax_request()) {
$referer = make_ajax_url($referer);
}
redirect_to($referer);
}
// if
}
示例13: is_ajax_request
<?php
function is_ajax_request()
{
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'BAWXMLHttpRequest';
}
$ajax = is_ajax_request();
if (!$ajax) {
?>
<html>
<head>
<style>
img {
display: block;
max-width: 100%;
height: auto;
background-size: cover;
backface-visibility: hidden;
}
section {
width: 50%;
}
main {
display: flex;
opacity: 1;
transition: opacity 0.5s ease-out;
}
main.loading {
opacity: 0;
示例14: smart_box
function smart_box($info)
{
if (is_json_request()) {
$array = array();
$array['error_code'] = intval(20001);
$array['error_message'] = $info;
return ajax_echo(json_encode($array));
} elseif (is_ajax_request()) {
return ajax_echo($info);
} else {
return info_page($info);
}
}
示例15: initFolder
public function initFolder($refresh = false)
{
$path = is_object($this->folder) ? $this->folder->folders_path : $this->folder;
$e = $refresh || is_ajax_request() ? array('refresh_memcached' => true) : null;
return $this->folder = vf::getFolder($path, array('limit' => $this->limit), $e);
}