• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP failure函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: pg_query_params

// Retrieve the password hash for the bot.
$res = pg_query_params('SELECT id,password FROM bots WHERE name=$1;', [$req["name"]]);
if ($res === FALSE) {
    failure("Failed to query the database for the existence of your name.");
}
if (pg_affected_rows($res) !== 1) {
    failure("The 'name' you provided, '{$req['name']}', has not been registered.");
}
$row = pg_fetch_assoc($res);
$id = (int) $row["id"];
$pass = $row["password"];
pg_free_result($res);
// Validate the password from the request against the database.
if (!password_verify($req["password"], $pass)) {
    failure("The 'password' you provided did not match the one given during registration.");
}
// Generate a shoddy but workable session identifier.
$sess = md5($req["name"] . openssl_random_pseudo_bytes(128));
// Record the session in the database.
$res = pg_query_params('UPDATE bots SET session=$1, session_timeout=now()+\'30 minutes\'::interval WHERE name=$2;', [$sess, $req["name"]]);
if ($res === FALSE || pg_affected_rows($res) !== 1) {
    failure("Failed to record your session in the database.");
}
pg_free_result($res);
// Extract the full session information from the database.
$bot = get_session($sess);
// Be sure that we don't have an active game.
forfeit();
// Return successfully.
reset_timeout("session");
success(["session" => $sess, "id" => $id]);
开发者ID:BenBergman,项目名称:gameai-2014-09,代码行数:31,代码来源:login.php


示例17: failure

// ---------------------------------------------------------------------------
// Error checking
// ---------------------------------------------------------------------------
if (!isset($_SESSION['users_id'])) {
    failure('Invalid user id');
}
if (!isset($_POST['id']) || !filter_var($_POST['id'], FILTER_VALIDATE_INT) || $_POST['id'] < 1) {
    failure('Invalid bookmark id');
}
$id = $_POST['id'];
// ---------------------------------------------------------------------------
// Secondary error checking
// ---------------------------------------------------------------------------
$bm = new suxBookmarks();
if (!$bm->getByID($id)) {
    failure('Invalid bookmark ' . $id);
}
// ---------------------------------------------------------------------------
// Go
// ---------------------------------------------------------------------------
$module = 'bookmarks';
$link = 'link__bookmarks__users';
$col = 'bookmarks';
// Get image names from template config
$tpl = new suxTemplate($module);
$tpl->configLoad('my.conf', $module);
$image = $tpl->getConfigVars('imgUnsubscribed');
$db = suxDB::get();
$query = "SELECT COUNT(*) FROM {$link} WHERE {$col}_id = ? AND users_id = ? ";
$st = $db->prepare($query);
$st->execute(array($id, $_SESSION['users_id']));
开发者ID:hashimmm,项目名称:sux0r,代码行数:31,代码来源:ajax.toggle.php


示例18: array

        //Make the webrequest
        //Only if we have a valid url
        if (valid_url($url, true)) {
            // Load Requests Library
            include 'requests/Requests.php';
            Requests::register_autoloader();
            $headers = array('Content-Type' => 'application/json');
            $response = Requests::post($url, $headers, json_encode($obj));
            if ($response->success) {
                success('<string>' . $response->status_code . '</string>');
            } else {
                failure($response->status_code);
            }
        } else {
            //since the url was invalid, we return 400 (Bad Request)
            failure(400);
        }
}
/** Copied from wordpress */
function success($innerXML)
{
    $xml = <<<EOD
<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value>
      {$innerXML}
      </value>
    </param>
  </params>
开发者ID:tunisiano187,项目名称:ifttt-webhook,代码行数:31,代码来源:xmlrpc.php


示例19: save

 /**
  * Saves this instance of the model to the database.
  */
 final function save()
 {
     if ($this->_is_valid) {
         $props = $this->get_properties();
         if (isset($props['id']) && $props['id']) {
             $id = $props['id'];
             unset($props['id']);
             $this->db->where('id', $id);
             $this->db->update($this->get_table(), $props);
         } else {
             unset($props['id']);
             $this->db->insert($this->get_table(), $props);
             $this->id = $this->db->insert_id();
         }
         if ($message = $this->db->_error_message()) {
             failure($message);
             return false;
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:asalce,项目名称:wp-ci,代码行数:26,代码来源:MY_Model.php


示例20: pg_query_params

$res = pg_query_params('SELECT bot1, bot2, bid1, bid2 FROM games WHERE id=$1;', [$bot["game"]]);
if ($res === FALSE) {
    failure("Failed to query the database to check whether you have bid in this game.");
}
if (pg_affected_rows($res) !== 1) {
    failure("The 'game' attached to your session, '{$bot['game']}', was not found.");
}
$row = pg_fetch_assoc($res);
pg_free_result($res);
// Check which player the bot is in this game.
if ($row["bot1"] === $bot["id"]) {
    $col = "bid1";
} elseif ($row["bot2"] === $bot["id"]) {
    $col = "bid2";
} else {
    failure("The 'game' attached to your session, '{$bot['game']}', does not have you recorded as a player. Contact Mak about this error.");
}
// Check if a bid has already been made.
if (!is_null($row[$col])) {
    failure("You have already bid '{$row[$col]}' in this game, and changing your bid is not permitted.");
}
// Register our bid.
$res = pg_query_params('UPDATE games SET ' . $col . '=$1 WHERE id=$2;', [$req["bid"], $bot["game"]]);
if ($res === FALSE || pg_affected_rows($res) !== 1) {
    failure("Failed to update the database to add your bid to this game.");
}
pg_free_result($res);
// Return successfully.
reset_timeout("game");
reset_timeout("session");
success([]);
开发者ID:BenBergman,项目名称:gameai-2014-09,代码行数:31,代码来源:bid.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP falcraftLoad函数代码示例发布时间:2022-05-15
下一篇:
PHP fail函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap