当前位置: 首页>>代码示例>>PHP>>正文


PHP ossn_is_xhr函数代码示例

本文整理汇总了PHP中ossn_is_xhr函数的典型用法代码示例。如果您正苦于以下问题:PHP ossn_is_xhr函数的具体用法?PHP ossn_is_xhr怎么用?PHP ossn_is_xhr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ossn_is_xhr函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ossn_action

/**
 * Load action.
 *
 * @param string $action The name of the action
 *
 * @return void
 */
function ossn_action($action)
{
    global $Ossn;
    if (isset($Ossn->action) && array_key_exists($action, $Ossn->action)) {
        if (is_file($Ossn->action[$action])) {
            $params['action'] = $action;
            ossn_trigger_callback('action', 'load', $params);
            include_once $Ossn->action[$action];
            if (ossn_is_xhr()) {
                header('Content-Type: application/json');
                $vars = array();
                if (isset($_SESSION['ossn_messages']['success']) && !empty($_SESSION['ossn_messages']['success'])) {
                    $vars['success'] = $_SESSION['ossn_messages']['success'];
                }
                //danger = error bootstrap
                if (isset($_SESSION['ossn_messages']['danger']) && !empty($_SESSION['ossn_messages']['danger'])) {
                    $vars['error'] = $_SESSION['ossn_messages']['danger'];
                }
                if (isset($Ossn->redirect) && !empty($Ossn->redirect)) {
                    $vars['redirect'] = $Ossn->redirect;
                }
                if (isset($Ossn->ajaxData) && !empty($Ossn->ajaxData)) {
                    $vars['data'] = $Ossn->ajaxData;
                }
                unset($_SESSION['ossn_messages']);
                if (!empty($vars)) {
                    echo json_encode($vars);
                }
            }
        }
    } else {
        ossn_error_page();
    }
}
开发者ID:nongdanit-nongdanit,项目名称:ossn,代码行数:41,代码来源:ossn.lib.actions.php

示例2: OssnComments

 * @copyright 2014 iNFORMATIKON TECHNOLOGIES
 * @license   General Public Licence http://www.opensource-socialnetwork.org/licence
 * @link      http://www.opensource-socialnetwork.org/licence
 */
$OssnComment = new OssnComments();
$image = input('comment-attachment');
//comment image check if is attached or not
if (!empty($image)) {
    $OssnComment->comment_image = $image;
}
//post on which comment is going to be posted
$post = input('post');
//comment text
$comment = input('comment');
if ($OssnComment->PostComment($post, ossn_loggedin_user()->guid, $comment)) {
    $data['comment'] = ossn_get_comment($OssnComment->getCommentId());
    $data = ossn_plugin_view('comments/templates/comment', $data);
    if (!ossn_is_xhr()) {
        redirect(REF);
    } else {
        header('Content-Type: application/json');
        echo json_encode(array('comment' => $data, 'process' => 1));
    }
} else {
    if (!ossn_is_xhr()) {
        redirect(REF);
    } else {
        header('Content-Type: application/json');
        echo json_encode(array('process' => 0));
    }
}
开发者ID:nongdanit-nongdanit,项目名称:ossn,代码行数:31,代码来源:comment.php

示例3: input

//walltype is user
$OssnWall->name = 'user';
//getting some inputs that are required for wall post
$post = input('post');
$friends = input('friends');
$location = input('location');
$privacy = input('privacy');
//validate wall privacy
$privacy = ossn_access_id_str($privacy);
if (!empty($privacy)) {
    $access = input('privacy');
} else {
    $access = OSSN_FRIENDS;
}
if ($OssnWall->Post($post, $friends, $location, $access)) {
    if (ossn_is_xhr()) {
        $guid = $OssnWall->getObjectId();
        $get = $OssnWall->GetPost($guid);
        if ($get) {
            $get = ossn_wallpost_to_item($get);
            ossn_set_ajax_data(array('post' => ossn_wall_view_template($get)));
        }
    }
    //no need to show message on success.
    //3.x why not? $arsalanshah
    ossn_trigger_message(ossn_print('post:created'));
    redirect(REF);
} else {
    ossn_trigger_message(ossn_print('post:create:error'), 'error');
    redirect(REF);
}
开发者ID:nongdanit-nongdanit,项目名称:ossn,代码行数:31,代码来源:user.php

示例4: ossn_post_page

/**
 * OssnWall post page handlers 
 * 
 * @param array $pages List of pages
 *
 * @return false|mixed data
 * @access private
 */
function ossn_post_page($pages)
{
    $page = $pages[0];
    if (empty($page)) {
        return false;
    }
    switch ($page) {
        case 'view':
            $title = ossn_print('post:view');
            $wall = new OssnWall();
            $post = $pages[1];
            $post = $wall->GetPost($post);
            if (empty($post->guid) || empty($pages[1])) {
                ossn_error_page();
            }
            $params['post'] = $post;
            $contents = array('content' => ossn_plugin_view('wall/pages/view', $params));
            $content = ossn_set_page_layout('newsfeed', $contents);
            echo ossn_view_page($title, $content);
            break;
        case 'photo':
            if (isset($pages[1]) && isset($pages[2])) {
                $image = ossn_get_userdata("object/{$pages[1]}/ossnwall/images/{$pages[2]}");
                header('Content-Type: image/jpeg');
                echo file_get_contents($image);
            }
            break;
        case 'privacy':
            if (ossn_is_xhr()) {
                $params = array('title' => ossn_print('privacy'), 'contents' => ossn_plugin_view('wall/privacy'), 'callback' => '#ossn-wall-privacy');
                echo ossn_plugin_view('output/ossnbox', $params);
            }
            break;
        case 'refresh_home':
            echo ossn_plugin_view('wall/siteactivity');
            break;
        default:
            ossn_error_page();
            break;
    }
}
开发者ID:sthefanysoares,项目名称:Social-Network,代码行数:49,代码来源:ossn_com.php

示例5: ossn_photos_page_handler

/**
 * Ossn Photos page handler
 * @pages:
 *       view,
 *    user,
 *       add,
 *       viewer
 *
 * @return mixed contents
 */
function ossn_photos_page_handler($album)
{
    $page = $album[0];
    if (empty($page)) {
        ossn_error_page();
    }
    switch ($page) {
        case 'view':
            if (isset($album[1])) {
                $title = ossn_print('photos');
                $photo['photo'] = $album[1];
                $view = new OssnPhotos();
                $image = $view->GetPhoto($photo['photo']);
                $photo['entity'] = $image;
                //redirect user to home page if image is empty
                if (empty($image)) {
                    redirect();
                }
                //throw 404 page if there is no album access
                $albumget = ossn_albums();
                $owner = $albumget->GetAlbum($image->owner_guid)->album;
                if ($owner->access == 3) {
                    if (!ossn_validate_access_friends($owner->owner_guid)) {
                        ossn_error_page();
                    }
                }
                //shows widget back button
                $addphotos = array('text' => ossn_print('back'), 'href' => 'javascript::;', 'class' => 'button-grey');
                $control = ossn_plugin_view('output/url', $addphotos);
                $contents = array('title' => ossn_print('photos'), 'content' => ossn_plugin_view('photos/pages/photo/view', $photo), 'controls' => $control);
                //set page layout
                $module['content'] = ossn_set_page_layout('media', $contents);
                $content = ossn_set_page_layout('contents', $module);
                echo ossn_view_page($title, $content);
            }
            break;
        case 'user':
            if (isset($album[1]) && isset($album[2]) && $album[1] == 'view') {
                $title = ossn_print('photos');
                $photo['photo'] = $album[2];
                $type = input('type');
                $view = new OssnPhotos();
                $image = $view->GetPhoto($photo['photo']);
                $photo['entity'] = $image;
                //redirect user if photo is empty
                if (empty($image->value)) {
                    redirect();
                }
                $addphotos = array('text' => ossn_print('back'), 'href' => 'javascript::;', 'class' => 'button-grey');
                $control = ossn_plugin_view('output/url', $addphotos);
                $contents = array('title' => 'Photos', 'content' => ossn_plugin_view('photos/pages/profile/photos/view', $photo), 'controls' => $control);
                //set page layout
                $module['content'] = ossn_set_page_layout('media', $contents);
                $content = ossn_set_page_layout('contents', $module);
                echo ossn_view_page($title, $content);
            }
            break;
        case 'cover':
            if (isset($album[1]) && isset($album[2]) && $album[1] == 'view') {
                $title = ossn_print('cover:view');
                $photo['photo'] = $album[2];
                $type = input('type');
                $image = ossn_get_entity($photo['photo']);
                $photo['entity'] = $image;
                //redirect user if photo is empty
                if (empty($image->value)) {
                    redirect();
                }
                $addphotos = array('text' => ossn_print('back'), 'href' => 'javascript::;', 'class' => 'button-grey');
                $control = ossn_plugin_view('output/url', $addphotos);
                $contents = array('title' => 'Photos', 'content' => ossn_plugin_view('photos/pages/profile/covers/view', $photo), 'controls' => $control);
                //set page layout
                $module['content'] = ossn_set_page_layout('media', $contents);
                $content = ossn_set_page_layout('contents', $module);
                echo ossn_view_page($title, $content);
            }
            break;
        case 'add':
            //add photos (ajax)
            if (!ossn_is_xhr()) {
                ossn_error_page();
            }
            echo ossn_plugin_view('output/ossnbox', array('title' => ossn_print('add:photos'), 'contents' => ossn_plugin_view('photos/pages/photos/add'), 'callback' => '#ossn-photos-submit'));
            break;
        case 'viewer':
            //ossn image viewer currently works for profile images
            $image = input('user');
            $url = ossn_site_url("avatar/{$image}");
            $media = "<img src='{$url}' />";
            $photo_guid = get_profile_photo_guid(ossn_user_by_username($image)->guid);
//.........这里部分代码省略.........
开发者ID:sthefanysoares,项目名称:Social-Network,代码行数:101,代码来源:ossn_com.php

示例6: ossn_post_page

/**
 * OssnWall post page handlers 
 * 
 * @param array $pages List of pages
 *
 * @return false|mixed data
 * @access private
 */
function ossn_post_page($pages)
{
    $page = $pages[0];
    if (empty($page)) {
        return false;
    }
    switch ($page) {
        case 'view':
            $title = ossn_print('post:view');
            $wall = new OssnWall();
            $post = $pages[1];
            $post = $wall->GetPost($post);
            if (empty($post->guid) || empty($pages[1])) {
                ossn_error_page();
            }
            $params['post'] = $post;
            $contents = array('content' => ossn_plugin_view('wall/pages/view', $params));
            $content = ossn_set_page_layout('newsfeed', $contents);
            echo ossn_view_page($title, $content);
            break;
        case 'photo':
            if (isset($pages[1]) && isset($pages[2])) {
                $name = str_replace(array('.jpg', '.jpeg', 'gif'), '', $pages[2]);
                $etag = $pages[1] . $name;
                if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$etag}\"") {
                    header("HTTP/1.1 304 Not Modified");
                    exit;
                }
                $image = ossn_get_userdata("object/{$pages[1]}/ossnwall/images/{$pages[2]}");
                //get image file else show error page
                if (is_file($image)) {
                    //Image cache on wall post #529
                    $filesize = filesize($image);
                    header("Content-type: image/jpeg");
                    header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+6 months")), true);
                    header("Pragma: public");
                    header("Cache-Control: public");
                    header("Content-Length: {$filesize}");
                    header("ETag: \"{$etag}\"");
                    readfile($image);
                    return;
                } else {
                    ossn_error_page();
                }
            }
            break;
        case 'privacy':
            if (ossn_is_xhr()) {
                $params = array('title' => ossn_print('privacy'), 'contents' => ossn_plugin_view('wall/privacy'), 'callback' => '#ossn-wall-privacy');
                echo ossn_plugin_view('output/ossnbox', $params);
            }
            break;
        case 'refresh_home':
            echo ossn_plugin_view('wall/siteactivity');
            break;
        default:
            ossn_error_page();
            break;
    }
}
开发者ID:emnaborgi,项目名称:RS,代码行数:68,代码来源:ossn_com.php

示例7: ossn_action_validate_callback

/**
 * Validate an action token on requested action.
 *
 * Calls to actions will automatically validate tokens. If token is invalid
 * the action stops and user will be redirected with warning of invalid token.
 *
 * @param string $callback	Name of callback
 * @param string $type	Type of callback
 * @param array $params
 *
 * @access private
 * @return void
 */
function ossn_action_validate_callback($callback, $type, $params)
{
    $action = $params['action'];
    $bypass = array();
    $bypass = ossn_call_hook('action', 'validate:bypass', null, $bypass);
    //validate post request also
    ossn_post_size_exceed_error();
    if (!in_array($action, $bypass)) {
        if (!ossn_validate_actions()) {
            if (ossn_is_xhr()) {
                header("HTTP/1.0 404 Not Found");
                exit;
            } else {
                ossn_trigger_message(ossn_print('ossn:securitytoken:failed'), 'error');
                redirect(REF);
            }
        }
    }
}
开发者ID:nongdanit-nongdanit,项目名称:ossn,代码行数:32,代码来源:ossn.lib.securitytoken.php

示例8: ossn_set_ajax_data

/**
 * Set Ajax Data
 * Use only in action files
 *
 * @param array $data A data array
 *
 * @return void
 */
function ossn_set_ajax_data(array $data = array())
{
    global $Ossn;
    if (ossn_is_xhr()) {
        $Ossn->ajaxData = $data;
    }
}
开发者ID:ntmtri23,项目名称:lienminh365,代码行数:15,代码来源:ossn.lib.system.php

示例9: trip_page_handler

/**
 * Viatges "handler" 
 * @pages:
 *       view,
 *       add
 *       
 *
 * @return diferent contents
 */
function trip_page_handler($trip)
{
    $page = $trip[0];
    if (empty($page)) {
        ossn_error_page();
        //Mostra 404
    }
    // var_dump($trip);
    switch ($page) {
        //Vista viatge (Accés públic no existeix restricció de visualització)
        case 'view':
            $view = new OptionTrips();
            $viewAlbum = new OssnAlbums();
            $album = $viewAlbum->GetAlbum(19);
            //Agafa id del viatge
            $infoTrip = $view->GetTrip($trip[1]);
            //Agafa id del viatge
            $infoDays = $view->GetTripDays($trip[1]);
            // var_dump($image);
            //$photo['entity'] = $image;
            $trip['info'] = $infoTrip;
            $trip['day'] = $infoDays;
            $trip['album'] = $album;
            //redirect user to home page if trip is empty
            if (empty($infoTrip)) {
                redirect();
            }
            //Missing "back" button to trips
            $owner = ossn_user_by_guid($infoTrip->guid);
            $back = array('text' => ossn_print('back'), 'href' => ossn_site_url("u/{$owner->username}/trips"), 'class' => 'button-grey');
            $control = ossn_plugin_view('output/url', $back);
            $contents = array('title' => ossn_print('trip:details'), 'content' => ossn_plugin_view('trips/pages/trip/view', $trip), 'controls' => $control, 'module_width' => '850px');
            //inclou page layout
            $module['content'] = ossn_set_page_layout('module', $contents);
            //Inclou modul amb els botons d'accions
            $content = ossn_set_page_layout('contents', $module);
            echo ossn_view_page($title, $content);
            break;
            //Afegir viatge
        //Afegir viatge
        case 'add':
            //Missing "back" button to trips
            $owner = ossn_loggedin_user()->username;
            // var_dump($owner);
            $back = array('text' => ossn_print('back'), 'href' => ossn_site_url("u/{$owner}/trips"), 'class' => 'button-grey');
            $control = ossn_plugin_view('output/url', $back);
            $contents = array('title' => ossn_print('add:trip'), 'content' => ossn_plugin_view('trips/pages/trip/add'), 'controls' => $control, 'module_width' => '850px');
            //inclou page layout
            $module['content'] = ossn_set_page_layout('module', $contents);
            //Inclou modul amb els botons d'accions
            $content = ossn_set_page_layout('contents', $module);
            echo ossn_view_page($title, $content);
            // echo ossn_plugin_view('output/url', array(
            // 		'title' => ossn_print('add:trip'),
            // 		'contents' => ossn_plugin_view('trips/pages/trip/add'),
            // 		'callback' => '#ossn-trip-submit'
            // ));
            break;
        case 'addPhoto':
            //add photos (ajax)
            if (!ossn_is_xhr()) {
                ossn_error_page();
            }
            echo ossn_plugin_view('output/ossnbox', array('title' => ossn_print('add:photos'), 'contents' => ossn_plugin_view('trips/pages/trip/addPhoto'), 'callback' => '#photos-submit'));
            break;
        default:
            ossn_error_page();
            //Mostra 404
            break;
    }
}
开发者ID:tricotrin,项目名称:OptionTrips,代码行数:80,代码来源:ossn_com.php


注:本文中的ossn_is_xhr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。