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


PHP response::success方法代码示例

本文整理汇总了PHP中response::success方法的典型用法代码示例。如果您正苦于以下问题:PHP response::success方法的具体用法?PHP response::success怎么用?PHP response::success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在response的用法示例。


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

示例1: __construct

 public function __construct()
 {
     $endpoint = $this;
     if ($page = page('webmention') and kirby()->path() == $page->uri()) {
         if (r::is('post')) {
             try {
                 $endpoint->start();
                 header::status(202);
                 tpl::set('status', 'success');
                 tpl::set('alert', null);
             } catch (Exception $e) {
                 header::status(400);
                 tpl::set('status', 'error');
                 tpl::set('alert', $e->getMessage());
             }
         } else {
             tpl::set('status', 'idle');
         }
     } else {
         kirby()->routes(array(array('pattern' => 'webmention', 'method' => 'GET|POST', 'action' => function () use($endpoint) {
             try {
                 $endpoint->start();
                 echo response::success('Yay', 202);
             } catch (Exception $e) {
                 echo response::error($e->getMessage());
             }
         })));
     }
 }
开发者ID:aizlewood,项目名称:2016,代码行数:29,代码来源:endpoint.php

示例2: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.avatar.delete.error.missing'));
     }
     if ($avatar = $user->avatar()) {
         if (f::remove($avatar->root())) {
             return response::success(l('users.avatar.delete.success'));
         }
     }
     return response::error(l('users.avatar.delete.error'));
 }
开发者ID:kompuser,项目名称:panel,代码行数:13,代码来源:avatars.php

示例3: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.error.missing'));
     }
     try {
         $user->delete();
         return response::success('success');
     } catch (Exception $e) {
         return response::error(l('users.delete.error'));
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:13,代码来源:users.php

示例4: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.avatar.delete.error.missing'));
     }
     if (!site()->user()->isAdmin() and !$user->isCurrent()) {
         return response::error('You are not allowed to delete the avatar of this user');
     }
     if ($avatar = $user->avatar()) {
         if (f::remove($avatar->root())) {
             return response::success(l('users.avatar.delete.success'));
         }
     }
     return response::error(l('users.avatar.delete.error'));
 }
开发者ID:williampan,项目名称:w,代码行数:16,代码来源:avatars.php

示例5: delete

 public function delete($username)
 {
     $user = $this->user($username);
     if (!$user) {
         return response::error(l('users.error.missing'));
     }
     if (!site()->user()->isAdmin() and !$user->isCurrent()) {
         return response::error('You are not allowed to delete this user');
     }
     try {
         $user->delete();
         return response::success('success');
     } catch (Exception $e) {
         return response::error(l('users.delete.error'));
     }
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:16,代码来源:users.php

示例6: login

 public function login()
 {
     $user = app::$site->users()->find(str::lower(get('username')));
     $message = l('login.error');
     if (!$user) {
         return response::error($message);
     }
     try {
         if (!$user->login(get('password'))) {
             throw new Exception($message);
         }
         return response::success(l('login.success'));
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:16,代码来源:auth.php

示例7: delete

 public function delete($id)
 {
     $filename = get('filename');
     $file = $this->file($id, $filename);
     if (!$file) {
         return response::error(l('files.error.missing.file'));
     }
     try {
         $file->delete();
         return response::success('success');
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:14,代码来源:files.php

示例8: url

 public function url($id)
 {
     $page = $this->page($id);
     if (!$page) {
         return response::error(l('pages.error.missing'));
     }
     // avoid url changes for the home and error pages
     if ($page->isErrorPage() or $page->isHomePage()) {
         return response::error('This page type\'s url cannot be changed');
     }
     $changes = PageStore::fetch($page);
     PageStore::discard($page);
     try {
         if (site()->multilang() and site()->language()->code() != site()->defaultLanguage()->code()) {
             $page->update(array('URL-Key' => get('uid')));
         } else {
             $page->move(get('uid'));
         }
         PageStore::update($page, $changes);
         // hit the hook
         kirby()->trigger('panel.page.move', $page);
         return response::success('success', array('uid' => $page->uid(), 'uri' => $page->id()));
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
开发者ID:madebypost,项目名称:Gulp-Neat-KirbyCMS,代码行数:26,代码来源:pages.php

示例9: url

 public function url($id)
 {
     $page = $this->page($id);
     if (!$page) {
         return response::error(l('pages.error.missing'));
     }
     try {
         if (site()->multilang() and app::$language != site()->defaultLanguage()->code()) {
             $page->update(array('URL-Key' => get('uid')));
         } else {
             $page->move(get('uid'));
         }
         return response::success('success', array('uid' => $page->uid(), 'uri' => $page->id()));
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:17,代码来源:pages.php

示例10: response

require 'config.php';
//GET DATA FROM ANGULAR $HTTP
$postdata = file_get_contents("php://input");
$data = json_decode($postdata)->data;
$action = $data->action;
$response = new response();
switch ($action) {
    case 'login':
        $username = $data->username;
        $password = $data->password;
        $query = "SELECT * FROM users WHERE (username = '{$username}' OR email = '{$username}') AND password=MD5('{$password}')";
        if ($result = $db->query($query)) {
            if ($user = $result->fetch_object()) {
                $response->user = $user;
                $response->success('Login successful');
                $token = bin2hex(openssl_random_pseudo_bytes(16));
                $query = "UPDATE users set login_token = '{$token}' where id={$user->id}";
                if ($db->query($query)) {
                    $response->user->login_token = $token;
                }
            } else {
                $query = "SELECT * FROM users WHERE username = '{$username}' OR email = '{$username}'";
                if ($user = $db->query($query)->fetch_object()) {
                    $response->error('Invalid password');
                } else {
                    $response->error('Invalid username');
                }
            }
        }
        break;
开发者ID:ariksavage,项目名称:float.ariksavage.com,代码行数:30,代码来源:login.action.php

示例11: MAX

             $response->documents[] = $doc;
         }
     } else {
         $response->error('unable to load library');
     }
     break;
 case 'create':
     $title = $data->title;
     $owner = $data->owner;
     $owner = 1;
     $query = "select MAX(sort) from documents where (parent is NULL) AND (owner={$owner})";
     $result = mysqli_fetch_assoc($db->query($query));
     $sort = $result['MAX(sort)'] == null ? 0 : intval($result['MAX(sort)']) + 1;
     $query = "INSERT INTO documents (title, parent, sort, owner, status) VALUES ('{$title}', null, {$sort}, {$owner}, 1)";
     if ($db->query($query)) {
         $response->success('Added document: "' . $title . '"');
     } else {
         $response->error('Could not add document');
     }
     break;
 case 'update':
     $library = $data->library;
     foreach ($library as $doc) {
         $query = "UPDATE documents SET ";
         $vars = get_object_vars($doc);
         $i = 0;
         $skip = array('id', 'updated');
         foreach ($vars as $k => $v) {
             if (!in_array($k, $skip)) {
                 if ($i > 0) {
                     $query .= ', ';
开发者ID:ariksavage,项目名称:float.ariksavage.com,代码行数:31,代码来源:library.action.php

示例12: kirby

<?php

kirby()->hook('panel.page.create', function ($page) {
    $templates = c::get('autopublish.templates', false);
    if (!$templates || in_array($page->template(), $templates)) {
        $parent = $page->parent();
        $subpages = new Subpages($parent);
        try {
            $num = $subpages->sort($page, 'last');
            return response::success('The page has been sorted', array('num' => $num));
        } catch (Exception $e) {
            return response::error($e->getMessage());
        }
    }
});
开发者ID:cnoss,项目名称:fubix,代码行数:15,代码来源:autopublish.php

示例13: url

 public function url($id)
 {
     $page = $this->page($id);
     if (!$page) {
         return response::error(l('pages.error.missing'));
     }
     // avoid url changes for the home and error pages
     if ($page->isErrorPage() or $page->isHomePage()) {
         return response::error('This page type\'s url cannot be changed');
     }
     try {
         if (site()->multilang() and site()->language()->code() != site()->defaultLanguage()->code()) {
             $page->update(array('URL-Key' => get('uid')));
         } else {
             $page->move(get('uid'));
         }
         return response::success('success', array('uid' => $page->uid(), 'uri' => $page->id()));
     } catch (Exception $e) {
         return response::error($e->getMessage());
     }
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:21,代码来源:pages.php


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