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


PHP failure函数代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store()
 {
     if (!Request::has('_id', 'type')) {
         return failure('参数错误');
     }
     $type = Request::input('type', 1);
     $id = Request::input('_id');
     $withdraw = UserWithdraw::find($id);
     if (!$withdraw) {
         return failure('该条数据不存在');
     }
     $user = User::find($withdraw->user_id);
     if (!$user) {
         return failure('该用户不存在');
     }
     if ($type) {
         $r = $withdraw->setSuccess($user);
     } else {
         $r = $withdraw->setFailure($user);
     }
     if ($r) {
         return success('提现成功');
     }
     return failure('提现失败');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:31,代码来源:UserWithdrawController.php

示例2: checkLogin

 /**
  * 检查登录是否成功
  *
  * @date   2015-10-09
  * @return [type]     [description]
  */
 public function checkLogin()
 {
     if (!Request::has('username', 'password')) {
         return failure('请输入用户名或密码');
     }
     // $rules = [
     //     'captcha' => 'required|captcha',
     // ];
     // $validator = Validator::make(Request::all(), $rules);
     // if ($validator->fails()) {
     //     return $this->failure('验证码错误');
     // }
     $admin = Admin::where('username', Request::input('username'))->first();
     if (!$admin) {
         return failure('用户不存在');
     }
     if (!Hash::check(Request::input('password'), $admin->password)) {
         return failure('用户名或密码错误');
     }
     $admin->increment('sign_in_cnt');
     $admin->last_sign_in_at = Carbon::now();
     $admin->last_sign_in_ip = Request::getClientIp();
     $admin->save();
     Auth::loginUsingId($admin->user_id);
     return success('登录成功');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:32,代码来源:AuthController.php

示例3: success_and_failure

/**
 * Prints the WordPress-standard success and/or failure bar when a message is stored
 * in either of success() or failure().
 */
function success_and_failure()
{
    foreach (array('success' => success(), 'failure' => failure()) as $class => $message) {
        if (is_admin() && $message) {
            ?>
				<div class="updated fade <?php 
            echo $class;
            ?>
" id="message" style="background-color: <?php 
            $class == 'success' ? 'rgb(255, 251, 204)' : '#AB6F74';
            ?>
;">
					<p><?php 
            echo $message;
            ?>
</p></div><br />
			<?php 
        } else {
            if ($message) {
                ?>
				<div class="<?php 
                echo $class;
                ?>
">
					<p><?php 
                echo $message;
                ?>
</p>
				</div>
			<?php 
            }
        }
    }
}
开发者ID:asalce,项目名称:wp-ci,代码行数:38,代码来源:wpci_helper.php

示例4: api

function api($method, $params)
{
    $json = rawapi($method, $params);
    if ($json["result"] === "failure") {
        failure($json["reason"]);
    }
    return $json;
}
开发者ID:BenBergman,项目名称:gameai-2014-09,代码行数:8,代码来源:GameAI.php

示例5: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $recharge = UserRecharge::find($id);
     if (!$recharge) {
         return failure('数据不存在');
     }
     if ($recharge->fail()) {
         return success('处理成功');
     }
     return failure('处理失败');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:17,代码来源:UserRechargeController.php

示例6: update

 public function update()
 {
     $id = Request::input('id');
     $adminBank = AdminBank::find($id);
     if (!$adminBank) {
         return failure('不存在该条记录');
     }
     if (!$adminBank->toggleStatus()) {
         return failure('修改状态失败');
     }
     return success('状态变更成功');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:12,代码来源:BanksController.php

示例7: failureClear

function failureClear($_Link, $p, $id)
{
    if ($id > 0 && !empty($id)) {
        $updateQuery = "UPDATE jobs SET job_status = 999 WHERE job_id = " . $id;
        $res = mysqli_query($_Link, $updateQuery);
        $queryAppend = '';
        if (isset($p) && $p != '') {
            $queryAppend = " AND cp = '" . $p . "'";
        }
        echo failure($_Link, $queryAppend);
    }
}
开发者ID:skrypnyk-dmytro,项目名称:Distributed-Video-Transcoding,代码行数:12,代码来源:ajax.php

示例8: insert

 public function insert()
 {
     $adminUser = Auth::user();
     $username = Request::input('username');
     if (User::where('username', $username)->exists()) {
         return failure('该用户存在');
     }
     $user = User::saveData(['username' => Request::input('username'), 'password' => Hash::make(Request::input('password')), 'nickname' => Request::input('username'), 'qq' => Request::input('qq'), 'type' => Request::input('type'), 'fandian' => Request::input('fandian'), 'parent_id' => $adminUser->id, 'ancestry' => $adminUser->username . '>' . Request::input('username'), 'ancestry_depth' => $adminUser->ancestry_depth . ',' . $adminUser->id, 'level' => 1, 'register_ip' => Request::getClientIp()]);
     if (!$user) {
         return failure('添加会员失败');
     }
     return success('添加会员成功');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:13,代码来源:UsersController.php

示例9: command_install

/**
 * @param $goption
 * @param $coption
 * @param $cparams
 */
function command_install($goption, $coption, $cparams)
{
    global $modslib;
    global $prefs;
    global $mods_server;
    $deps = $modslib->find_deps($prefs['mods_dir'], $mods_server, $cparams);
    if (count($deps['unavailable'])) {
        $err = "Sorry, theses packages are required but not available:\n";
        foreach ($deps['unavailable'] as $mod) {
            $err .= " - " . $mod->modname . "\n";
        }
        failure($err);
    }
    if (count($deps['conflicts'])) {
        $err = "Sorry, theses packages are required but conflicts:\n";
        foreach ($deps['conflicts'] as $mod) {
            $err .= " - " . $mod->modname . "\n";
        }
        failure($err);
    }
    if (count($deps['wanted'])) {
        echo "You asked to install these mods:\n";
        foreach ($deps['wanted'] as $mod) {
            echo "  " . $mod->modname . "\n";
        }
    }
    if (count($deps['toinstall'])) {
        echo "The following packages will be installed:\n";
        foreach ($deps['toinstall'] as $mod) {
            echo "  " . $mod->modname . " (" . $mod->revision . ")\n";
        }
    }
    if (count($deps['toupgrade'])) {
        echo "The following packages will be upgraded:\n";
        foreach ($deps['toupgrade'] as $meat) {
            echo "  " . $meat['to']->modname . " (" . $meat['to']->revision . ") (from version " . $meat['from']->revision . ")\n";
        }
    }
    if (count($deps['suggests'])) {
        echo "Suggested packages:\n";
        foreach ($deps['suggests'] as $mod) {
            echo "  " . $mod->modname . "\n";
        }
    }
    $res = ask("Would you like to continue (y/N) ? ");
    if ($res != 'y') {
        echo "Good bye\n";
        exit(0);
    }
    $modslib->install_with_deps($prefs['mods_dir'], $mods_server, $deps);
}
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:56,代码来源:modsadm.php

示例10: update

 public function update()
 {
     if (!Request::has('_id', 'title', 'content', 'status')) {
         return failure('参数错误');
     }
     $notice = Notice::find(Request::input('_id'));
     $notice->title = Request::input('title');
     $notice->content = Request::input('content');
     $notice->status = Request::input('status');
     if ($notice->save()) {
         return success('修改成功');
     }
     return failure('修改失败');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:14,代码来源:NoticesController.php

示例11: addBank

 public function addBank()
 {
     if (!Request::has('bank', 'name', 'account')) {
         return failure('参数错误');
     }
     $bank = Bank::find(Request::input('bank'));
     if (!$bank) {
         return failure('银行不存在');
     }
     $adminBank = AdminBank::add($bank, Request::input('name'), Request::input('account'), Request::input('address'));
     if (!$adminBank) {
         return failure('添加银行失败');
     }
     return success('添加银行成功');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:15,代码来源:SystemController.php

示例12: update

 /**
  * 修改昵称
  *  
  * @date   2015-09-19
  * @return [type]     [description]
  */
 public function update()
 {
     if (!Request::has('action')) {
         return failure('非法操作');
     }
     $user = Auth::user();
     if (Request::input('action') == 'nickname') {
         $nickname = Request::input('nickname');
         if (!$nickname) {
             return $this->failure('昵称不能为空');
         }
         $user->nickname = $nickname;
         $user->save();
         return success('修改成功');
     }
     if (Request::input('action') == 'passwd') {
         $old_pass = Request::input('old_pass');
         $new_pass = Request::input('new_pass');
         if (!Hash::check($old_pass, $user->password)) {
             return failure('密码错误');
         }
         if (Hash::check($new_pass, $user->payment_password)) {
             return failure('登陆密码不能和支付密码一样');
         }
         $user->password = Hash::make($new_pass);
         if (!$user->save()) {
             return failure('密码修改失败');
         }
         return success('密码修改成功');
     }
     if (Request::input('action') == 'coinpasswd') {
         $old_bank = Request::input('old_bank');
         $new_bank = Request::input('new_bank');
         if (!$user->payment_password == '') {
             if (!Hash::check($old_bank, $user->payment_password)) {
                 return failure('资金密码错误');
             }
         }
         if (Hash::check($new_bank, $user->password)) {
             return failure('支付密码不能和登陆密码一样');
         }
         $user->payment_password = Hash::make($new_bank);
         if (!$user->save()) {
             return failure('支付密码修改失败');
         }
         return success('支付密码修改成功');
     }
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:54,代码来源:UserController.php

示例13: loginTo

 public function loginTo()
 {
     $rules = ['captcha' => 'required|captcha'];
     $validator = Validator::make(Request::all(), $rules);
     if ($validator->fails()) {
         return failure('验证码错误');
     }
     if (Auth::attempt(['username' => Request::input('username'), 'password' => Request::input('passwd')])) {
         $user = Auth::user();
         $user->last_sign_in_ip = ip2long(Request::getClientIp());
         $user->last_sign_in_at = Carbon::now();
         $user->sign_in_cnt += 1;
         $user->user_tokens = md5($user->username);
         $user->save();
         return success('登录成功');
     }
     return failure('用户名或密码错误');
 }
开发者ID:jiujiubaba,项目名称:laravel,代码行数:18,代码来源:AuthController.php

示例14: file_re

function file_re($file, $pattern, $all = true)
{
    static $path;
    $path or $path = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] . '/include/curl/' : "/usr/local/include/curl/";
    if ($content = file_get_contents($path . $file)) {
        if ($all) {
            if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) {
                return $matches;
            }
        } else {
            if (preg_match($pattern, $content, $matches)) {
                return $matches;
            }
        }
        trigger_error("no match in {$file} for {$pattern}");
    }
    failure();
}
开发者ID:nickl-,项目名称:pecl-http,代码行数:18,代码来源:gen_curlinfo.php

示例15: check_game

function check_game()
{
    global $bot;
    // Check if we have now been assigned a game.
    $res = pg_query_params('SELECT
       b.game,
       b.cards,

       g.bot1,
       g.bot2,
       g.bid1,
       g.bid2
     FROM
       bots AS b JOIN games AS g
     ON
       b.game=g.id
     WHERE
       b.id=$1;', [$bot["id"]]);
    if ($res === FALSE) {
        failure("Failed to query the database to check whether you have been assigned a game.");
    }
    if (pg_affected_rows($res) !== 1) {
        return;
    }
    $row = pg_fetch_assoc($res);
    pg_free_result($res);
    // If our bid is null, we can return successfully and not confuse the bot.
    if ($row["bot1"] === $bot["id"] && !is_null($row["bid1"]) || $row["bot2"] === $bot["id"] && !is_null($row["bid2"])) {
        failure("You have already started playing a game, #{$row['game']}, and must finish it before attempting to start a new game.");
    }
    // Parse the cards the bot has been dealt into an array.
    $cards = explode(",", substr($row["cards"], 1, -1));
    // Determine our opponent.
    if ($row["bot1"] === $bot["id"]) {
        $opponent = (int) $row["bot2"];
    } else {
        $opponent = (int) $row["bot1"];
    }
    // Return the game information to the client.
    pg_query("BEGIN;");
    reset_timeout("session");
    success(["cards" => $cards, "game" => (int) $row["game"], "opponent" => $opponent]);
}
开发者ID:BenBergman,项目名称:gameai-2014-09,代码行数:43,代码来源:new-game.php


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