php Success类(方法)实例源码

下面列出了php Success 类(方法)源码代码实例,从而了解它的用法。

作者:jfefe    项目:ORK   
function OptimizeTable($Token, $Table = null)
 {
     $total = 0;
     if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($Token)) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, 0, AUTH_CREATE)) {
         if (is_null($Table)) {
             $tables = $this->db->query('show tables');
             $t = 'Tables_in_' . DB_DATABASE;
             do {
                 set_time_limit(60 * 60);
                 $this->db->query('optimize table "' . $tables->{$t} . '"');
                 $total++;
             } while ($tables->next());
         } else {
             if (is_array($Table) && count($Table > 0)) {
                 foreach ($Table as $k => $t) {
                     set_time_limit(60 * 60);
                     $this->db->query('optimize table "' . $t . '"');
                     $total++;
                 }
             }
         }
         return Success($total);
     }
     return NoAuthorization();
 }

作者:noiki    项目:meilal   
public function save()
 {
     $aid = $this->admin['aid'];
     $password = ForceStringFrom('password');
     $passwordconfirm = ForceStringFrom('passwordconfirm');
     $email = ForceStringFrom('email');
     $fullname = ForceStringFrom('fullname');
     $fullname_en = ForceStringFrom('fullname_en');
     if (strlen($password) or strlen($passwordconfirm)) {
         if (strcmp($password, $passwordconfirm)) {
             $errors[] = '两次输入的密码不相同!';
         }
     }
     if (!$email) {
         $errors[] = '请输入Email地址!';
     } elseif (!IsEmail($email)) {
         $errors[] = 'Email地址不规范!';
     } elseif (APP::$DB->getOne("SELECT aid FROM " . TABLE_PREFIX . "admin WHERE email = '{$email}' AND aid != '{$aid}'")) {
         $errors[] = 'Email地址已占用!';
     }
     if (!$fullname) {
         $errors[] = '请输入中文昵称!';
     }
     if (!$fullname_en) {
         $errors[] = '请输入英文昵称!';
     }
     if (isset($errors)) {
         Error($errors, '编辑我的信息错误');
     } else {
         APP::$DB->exe("UPDATE " . TABLE_PREFIX . "admin SET \r\n\t\t\t" . Iif($password, "password = '" . md5($password) . "',") . "\r\n\t\t\temail       = '{$email}',\r\n\t\t\tfullname       = '{$fullname}',\r\n\t\t\tfullname_en       = '{$fullname_en}'\r\n\t\t\tWHERE aid      = '{$aid}'");
         Success('myprofile');
     }
 }

作者:rkgladso    项目:PHPixm   
/**
 * @param callable $hof
 * @return Success|Failure
 */
function Attempt(callable $hof)
{
    try {
        return Success(call_user_func($hof));
    } catch (\Exception $e) {
        return Failure($e);
    }
}

作者:noiki    项目:meilal   
public function updatemessages()
 {
     $page = ForceIntFrom('p', 1);
     //页码
     $deletemids = $_POST['deletemids'];
     for ($i = 0; $i < count($deletemids); $i++) {
         $mid = ForceInt($deletemids[$i]);
         APP::$DB->exe("DELETE FROM " . TABLE_PREFIX . "msg WHERE mid = '{$mid}'");
     }
     Success('messages?p=' . $page);
 }

作者:tecshuttl    项目:51qs   
public function updateguests()
 {
     $page = ForceIntFrom('p', 1);
     //页码
     $deletegids = $_POST['deletegids'];
     for ($i = 0; $i < count($deletegids); $i++) {
         $gid = ForceInt($deletegids[$i]);
         $this->DeleteGuest($gid);
         //批量删除客人及对话记录
     }
     Success('guests?p=' . $page);
 }

作者:jfefe    项目:ORK   
public function CreateGame($request)
 {
     if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0) {
         switch ($request['Type']) {
             case 'flag-capture':
                 return Success($this->create_flag_capture($request['Name'], $mundane_id, $request['Configuration']));
                 break;
             default:
                 return Success($this->create_game($request['Name'], 'custom', $mundane_id, $request['Configuration'], array()));
                 break;
         }
     } else {
         return NoAuthorization();
     }
 }

作者:tecshuttl    项目:51qs   
public function restore()
 {
     $filename = ForceStringFrom('file');
     $fp = openFileRead($this->backupDir . $filename);
     while (!eof($fp)) {
         $query .= readFileData($fp, 10000);
     }
     closeFile($fp);
     $queries = ParseQueries($query, ';');
     for ($i = 0; $i < count($queries); $i++) {
         $sql = trim($queries[$i]);
         if (!empty($sql)) {
             APP::$DB->query($sql);
         }
     }
     Success('database');
 }

作者:zellfaz    项目:ORK   
public function RemoveLastDuesPaid($request)
 {
     logtrace('RemoveLastDuesPaid', $request);
     if (($player = Ork3::$Lib->player->player_info($request['MundaneId'])) === false) {
         return InvalidParameter('Player could not be found.');
     }
     logtrace('Found Player', $request);
     if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $player['ParkId'], AUTH_EDIT)) {
         $sql = "select \n\t\t\t                s.transaction_id \n\t\t\t            from " . DB_PREFIX . "split s \n\t\t\t                left join " . DB_PREFIX . "transaction t on s.transaction_id = t.transaction_id\n\t\t\t            where \n\t\t\t                src_mundane_id = '" . mysql_real_escape_string($request['MundaneId']) . "' and is_dues = 1 order by t.date_created desc limit 1";
         logtrace('Passed Security', $sql);
         $lastdues = $this->db->query($sql);
         if ($lastdues != false && $lastdues->size() == 1) {
             $this->remove_transaction($lastdues->transaction_id);
             return Success('Transaction ' . $lastdues->transaction_id . ' removed.');
         }
     }
     return NoAuthorization('You lack authoratah.');
 }

作者:noiki    项目:meilal   
public function updatecomments()
 {
     $page = ForceIntFrom('p', 1);
     //页码
     if (IsPost('updatecomms')) {
         $updatecids = $_POST['updatecids'];
         for ($i = 0; $i < count($updatecids); $i++) {
             $cid = ForceInt($updatecids[$i]);
             APP::$DB->exe("UPDATE " . TABLE_PREFIX . "comment SET readed = 1 WHERE cid = '{$cid}'");
         }
     } else {
         $deletecids = $_POST['deletecids'];
         for ($i = 0; $i < count($deletecids); $i++) {
             $cid = ForceInt($deletecids[$i]);
             APP::$DB->exe("DELETE FROM " . TABLE_PREFIX . "comment WHERE cid = '{$cid}'");
         }
     }
     Success('comments?p=' . $page);
 }

作者:tecshuttl    项目:51qs   
public function updatephrases()
 {
     $page = ForceIntFrom('p', 1);
     //页码
     if (IsPost('updatephrases')) {
         $pids = $_POST['pids'];
         $sorts = $_POST['sorts'];
         $activateds = $_POST['activateds'];
         $msgs = $_POST['msgs'];
         $msg_ens = $_POST['msg_ens'];
         for ($i = 0; $i < count($pids); $i++) {
             $pid = ForceInt($pids[$i]);
             APP::$DB->exe("UPDATE " . TABLE_PREFIX . "phrase SET sort = '" . ForceInt($sorts[$i]) . "',\n\t\t\t\t\tactivated = '" . ForceInt($activateds[$i]) . "',\n\t\t\t\t\tmsg = '" . ForceString($msgs[$i]) . "',\n\t\t\t\t\tmsg_en = '" . ForceString($msg_ens[$i]) . "'\t\t\t\t\t\n\t\t\t\t\tWHERE pid = '{$pid}'");
         }
     } else {
         $deletepids = $_POST['deletepids'];
         for ($i = 0; $i < count($deletepids); $i++) {
             $pid = ForceInt($deletepids[$i]);
             APP::$DB->exe("DELETE FROM " . TABLE_PREFIX . "phrase WHERE pid = '{$pid}'");
         }
     }
     Success('phrases?p=' . $page);
 }

作者:awasth    项目:aguila   
$in2['uidNumber'] = $in['uidNumber'];
                    // Incrementing maxUID entry
                    $mod = AssistedLDAPModify($ldapc, $moddn, $in2);
                }
                // If the modification went OK, we send the notification e-mail to the user
                if ($mod) {
                    $send = AssistedEMail("NewUserDo", $mail);
                }
                // If the mailing went OK ...
                if ($send) {
                    // We need to get rid of the temporary entry
                    $del_q = sprintf("DELETE FROM NewUser" . " WHERE uid='%s'" . " AND token='%s'", mysql_real_escape_string($uid), mysql_real_escape_string($token));
                    // Deleting the row from the table ...
                    $del_r = AssistedMYSQLQuery($del_q);
                    // We log the event
                    WriteLog("NewUserDo");
                    // Print the good news to the user
                    Success("NewUserDo");
                } else {
                    // We fail nicely, at least
                    Fail("NewUserDo");
                }
            }
        }
    }
}
// Closing the connection
$ldapx = AssistedLDAPClose($ldapc);
// Closing the connection
$mysqlx = AssistedMYSQLClose($mysqlc);
require_once "./themes/{$app_theme}/footer.php";

作者:jfefe    项目:ORK   
public function AddParticipant($request)
 {
     if (!$this->check_auth($request)) {
         return NoAuthorization();
     }
     if (valid_id($request['ParticipantId'])) {
         $sql = "insert into " . DB_PREFIX . "participant (tournament_id, bracket_id, alias, mundane_id, unit_id, park_id, kingdom_id, team_id) \n\t\t\t\t\t\tselect tournament_id, " . mysql_real_escape_string($request['BracketId']) . ", alias, mundane_id, unit_id, park_id, kingdom_id, team_id from " . DB_PREFIX . "participant where participant_id = '" . mysql_real_escape_string($request['ParticipantId']) . "'";
         $this->db->query($sql);
         return Success($this->db->getInsertId());
     } else {
         $this->Participant->clear();
         $this->Participant->tournament_id = $request['TournamentId'];
         $this->Participant->bracket_id = $request['BracketId'];
         $this->Participant->alias = $request['Alias'];
         $this->Participant->unit_id = $request['UnitId'];
         $this->Participant->park_id = $request['ParkId'];
         $this->Participant->kingdom_id = $request['KingdomId'];
         $this->Participant->team_id = $request['TeamId'];
         $this->Participant->save();
         if (!valid_id($request['MundaneId'])) {
             foreach ($request['Members'] as $k => $member) {
                 $this->Player->clear();
                 $this->Player->participant_id = $this->Participant->participant_id;
                 $this->Player->mundane_id = $member['MundaneId'];
                 $this->Player->tournament_id = $member['TournamentId'];
                 $this->Player->bracket_id = $member['BracketId'];
                 $this->Player->save();
             }
         }
         return Success($this->Participant->participant_id);
     }
 }

作者:sysuzj    项目:soy   
public function personal_()
 {
     eval(USER);
     try {
         $data = $_POST;
         unset($data['__hash__']);
         $root = C('ROOT');
         if (isset($_FILES["picture"])) {
             $upload = uploadImage();
             if (!is_string($upload)) {
                 $data['picture'] = $root . $upload[0]["savepath"] . $upload[0]["savename"];
             }
             if ($data["picture"] == $root) {
                 unset($data["picture"]);
             }
         }
         DBModel::updateDB('cernet_user', array('username' => session('username')), $data);
         $this->success(Success('modify'), '__ROOT__/User/personal');
     } catch (Exception $e) {
         throw_exception($e->getMessage());
     }
 }

作者:jfefe    项目:ORK   
public function NextYear($request)
 {
     $sql = "select event.event_id, event.name, detail.event_start, detail.event_end, detail.url, detail.description from " . DB_PREFIX . "event event left join " . DB_PREFIX . "event_calendardetail detail on detail.event_id = event.event_id where event_start >= '" . mysql_real_escape_string($request['Date']) . "' and event_end <= date_add('" . mysql_real_escape_string($request['Date']) . "', interval 1 year)";
     return array('Status' => Success(), 'Dates' => array_merge($this->_make_calendar_set($sql), $this->_park_days(strtotime($request['Date']), 'year')));
 }

作者:Covert-Infern    项目:Sapphirev   
}
    }
}
if (!$fail) {
    if (!$rankFail) {
        //Update Old Ranks
        for ($i = 0; $i < $anotherOldCount; $i++) {
            global $oldRankIds, $oldRankNewPower;
            $sql = "Call sp_UpdateRankPower(" . $oldRankIds[$i] . ", " . $oldRankNewPower[$i] . ")";
            $result = mysql_query($sql, $conn) or die(mysql_error());
        }
        //Add New Ranks
        for ($i = 0; $i < $newRankCount; $i++) {
            $sql = "Call sp_AddNewRank('" . $newRankNames[$i] . "', " . $newRankPower[$i] . ")";
            $result = mysql_query($sql, $conn) or die(mysql_error());
        }
    } else {
        Fail("You cannot Create or Edit the Rank of a Rank with higher or Equal Power as yourself");
    }
    Success();
} else {
    Fail("Bad Data");
}
function Fail($error)
{
    header('Location: ./TDSInError.php?Error=' . $error . '');
}
function Success()
{
    header('Location: ./TDSInAdminTools.php');
}

作者:jfefe    项目:ORK   
public function UpdateAward($request)
 {
     $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']);
     $awards = new yapo($this->db, DB_PREFIX . 'awards');
     $awards->clear();
     $awards->awards_id = $request['AwardsId'];
     if (valid_id($request['AwardsId']) && $awards->find()) {
         $mundane = $this->player_info($awards->mundane_id);
         if (valid_id($mundane_id) && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $mundane['ParkId'], AUTH_EDIT)) {
             if (valid_id($request['ParkId'])) {
                 $Park = new Park();
                 $info = $Park->GetParkShortInfo(array('ParkId' => $request['ParkId']));
                 if ($info['Status']['Status'] != 0) {
                     return InvalidParameter();
                 }
             }
             $awards->rank = $request['Rank'];
             $awards->date = $request['Date'];
             $awards->given_by_id = $request['GivenById'];
             $awards->note = $request['Note'];
             // If no event, then go Park!
             $awards->park_id = !valid_id($request['EventId']) ? $request['ParkId'] : 0;
             // If no event and valid parkid, go Park! Otherwise, go Kingdom.  Unless it's an event.  Then go ... ZERO!
             $awards->kingdom_id = !valid_id($request['EventId']) ? valid_id($request['ParkId']) ? $info['ParkInfo']['KingdomId'] : $request['KingdomId'] : 0;
             // Events are awesome.
             $awards->event_id = valid_id($request['EventId']) ? $request['EventId'] : 0;
             $awards->save();
             return Success($awards->awards_id);
         } else {
             return InvalidParamter();
         }
     } else {
         return NoAuthorization();
     }
 }

作者:jfefe    项目:ORK   
public function add_member_h($request)
 {
     logtrace("add_member_h", $request);
     $this->unit->clear();
     $this->unit->type = 'Company';
     $this->unit->unit_id = $request['UnitId'];
     if ($this->unit->find()) {
         $this->members->clear();
         $this->members->unit_id = $request['UnitId'];
         $this->members->mundane_id = $request['MundaneId'];
         $this->members->active = 'Active';
         if ($this->members->find()) {
             return InvalidParameter('Player is already an active member of this company.');
         }
         $this->members->clear();
         $this->members->mundane_id = $request['MundaneId'];
         $this->members->unit_id = $request['UnitId'];
         $this->members->active = 'Retired';
         if ($this->members->find()) {
             $this->members->active = 'Active';
             $this->members->save();
             return Success($this->members->unit_mundane_id);
         }
     }
     $this->members->clear();
     $this->members->unit_id = $request['UnitId'];
     $this->members->mundane_id = $request['MundaneId'];
     $this->members->role = $request['Role'];
     $this->members->title = $request['Title'];
     $this->members->active = $request['Active'];
     $this->members->save();
     return Success($this->members->unit_mundane_id);
 }

作者:Nordic-    项目:vanilla-plugin   
</div>
<h3>Control Panel</h3>
<br/>
<div id="ControlPanel">
    <br/>
    <table class="CPanel Searchd">
        <tbody>
            <tr>
                <th class="Desc">Searchd: </th>
                <th>Status</th>
            </tr>
            <tr>
                <td>Status: </td>
                <td> <?php 
if ($Settings['Status']->SearchdRunning) {
    Success('Running');
} else {
    Fail('Not Running');
}
?>
 </td>
            </tr>
        </tbody>
    </table>
    <br/>

</div>
<br/>

<h3>Changelog</h3>
20140115

作者:OvB    项目:v1.   
//.........这里部分代码省略.........
    }
    $strInterests = $dbConn->sanitize($aReg['interests']);
    // Occupation
    if (strlen($aReg['occupation']) > $CFG['maxlen']['occupation']) {
        // The occupation they specified is too long.
        $aError[] = "The occupation you specified is longer than {$CFG['maxlen']['occupation']} characters.";
    }
    $strOccupation = $dbConn->sanitize($aReg['occupation']);
    // Signature
    if (strlen($aReg['signature']) > $CFG['maxlen']['signature']) {
        // The signature they specified is too long.
        $aError[] = "The signature you specified is longer than {$CFG['maxlen']['signature']} characters.";
    }
    $strSignature = $dbConn->sanitize($aReg['signature']);
    // Default Thread View
    if ($aReg['threadview'] > 365 && $aReg['threadview'] != 1000) {
        // They specified an invalid choice for the default thread view.
        $iThreadView = 0;
    } else {
        $iThreadView = $aReg['threadview'];
    }
    // Default Posts Per Page
    if ($aReg['postsperpage'] < 0) {
        // They specified an invalid choice for the default posts per page.
        $iPostsPerPage = 0;
    } else {
        $iPostsPerPage = $aReg['postsperpage'];
    }
    // Default Threads Per Page
    if ($aReg['threadsperpage'] < 0) {
        // They specified an invalid choice for the default threads per page.
        $iThreadsPerPage = 0;
    } else {
        $iThreadsPerPage = $aReg['threadsperpage'];
    }
    // Start Of The Week
    if ($aReg['weekstart'] > 6) {
        // They specified an invalid day for the start of the week.
        $iWeekStart = 0;
    } else {
        $iWeekStart = $aReg['weekstart'];
    }
    // Time Offset
    if ($aReg['timeoffset'] > 43200 || $aReg['timeoffset'] < -43200) {
        // They specified an invalid time for the time offset.
        $strTimeOffset = $CFG['time']['display_offset'];
    } else {
        $strTimeOffset = $aReg['timeoffset'];
    }
    // DST Offset
    $iDSTOffset = $aReg['dsth'] * 3600 + $aReg['dstm'] * 60;
    if ($iDSTOffset > 65535 || $iDSTOffset < 0) {
        $iDSTOffset = 0;
    }
    // Do they have any errors?
    if (is_array($aError)) {
        return $aError;
    }
    // Is there already a user with the desired username?
    $dbConn->query("SELECT id FROM citizen WHERE username='{$strUsername}'");
    if ($dbConn->getresult()) {
        // Yep, a user already exists. Let them know the bad news.
        $aError[] = 'There is already a user with that username. Please specify a different one.';
    }
    // Is there already a user with the specified e-mail address?
    $dbConn->query("SELECT id FROM citizen WHERE email='{$strEMail}'");
    if ($dbConn->getresult()) {
        // Yep, e-mail address is already in use. Let them know the bad news.
        $aError[] = 'There is already a user with that e-mail address. Please specify a different one.';
    }
    // Do they have any errors?
    if (is_array($aError)) {
        return $aError;
    }
    // Is e-mail validation enabled?
    if ($CFG['reg']['email']) {
        // Yes, so generate a registration hash.
        $strHash = md5(mt_rand());
        // Add the user's member record.
        $dJoined = gmdate('Y-m-d');
        $dbConn->query("INSERT INTO citizen(username, passphrase, email, datejoined, website, aim, icq, msn, yahoo, referrer, birthday, bio, residence, interests, occupation, signature, allowmail, invisible, publicemail, enablepms, pmnotifya, pmnotifyb, threadview, postsperpage, threadsperpage, weekstart, timeoffset, dst, dstoffset, postcount, showsigs, showavatars, autologin, usergroup, pmfolders, reghash) VALUES('{$strUsername}', '{$strPassword}', '{$strEMail}', '{$dJoined}', '{$strWebsite}', '{$strAIM}', '{$strICQ}', '{$strMSN}', '{$strYahoo}', '{$strReferrer}', '{$strBirthday}', '{$strBio}', '{$strLocation}', '{$strInterests}', '{$strOccupation}', '{$strSignature}', {$aReg['allowmail']}, {$aReg['invisible']}, {$aReg['publicemail']}, {$aReg['enablepms']}, {$aReg['pmnotifya']}, {$aReg['pmnotifyb']}, {$iThreadView}, {$iPostsPerPage}, {$iThreadsPerPage}, {$iWeekStart}, {$strTimeOffset}, {$aReg['dst']}, {$iDSTOffset}, 0, {$aReg['showsigs']}, {$aReg['showavatars']}, {$aReg['autologin']}, 1, 'a:0:{}', '{$strHash}')");
        $iUserID = mysql_insert_id();
        // Send the user their activation e-mail.
        $strMessage = file_get_contents('includes/activation.tpl');
        $aReg['actlink'] = 'http://' . $_SERVER['HTTP_HOST'] . pathinfo($_SERVER['PHP_SELF'], PATHINFO_DIRNAME) . "/member.php?action=activate&userid={$iUserID}&hash={$strHash}";
        @eval("\$strMessage = \"{$strMessage}\";");
        mail($aReg['emaila'], "Action required to activate membership for {$CFG['general']['name']}!", preg_replace("/(\r\n|\r|\n)/s", "\r\n", $strMessage), "From: {$CFG['general']['name']} Mailer <{$CFG['general']['admin']['email']}>");
        // Show them the success page.
        JustRegistered();
    }
    // Add the user's member record.
    $dJoined = gmdate('Y-m-d');
    $dbConn->query("INSERT INTO citizen(username, passphrase, email, datejoined, website, aim, icq, msn, yahoo, referrer, birthday, bio, residence, interests, occupation, signature, allowmail, invisible, publicemail, enablepms, pmnotifya, pmnotifyb, threadview, postsperpage, threadsperpage, weekstart, timeoffset, dst, dstoffset, postcount, showsigs, showavatars, autologin, usergroup, pmfolders) VALUES('{$strUsername}', '{$strPassword}', '{$strEMail}', '{$dJoined}', '{$strWebsite}', '{$strAIM}', '{$strICQ}', '{$strMSN}', '{$strYahoo}', '{$strReferrer}', {$strBirthday}, '{$strBio}', '{$strLocation}', '{$strInterests}', '{$strOccupation}', '{$strSignature}', {$aReg['allowmail']}, {$aReg['invisible']}, {$aReg['publicemail']}, {$aReg['enablepms']}, {$aReg['pmnotifya']}, {$aReg['pmnotifyb']}, {$iThreadView}, {$iPostsPerPage}, {$iThreadsPerPage}, {$iWeekStart}, {$strTimeOffset}, {$aReg['dst']}, {$iDSTOffset}, 0, {$aReg['showsigs']}, {$aReg['showavatars']}, {$aReg['autologin']}, 1, 'a:0:{}')");
    $iUserID = $dbConn->getinsertid('citizen');
    // Update the forum stats.
    $dbConn->query("UPDATE stats SET content=content+1 WHERE name='membercount'");
    $dbConn->query("UPDATE stats SET content={$iUserID} WHERE name='newestmember'");
    // Show them the success page.
    Success($iUserID);
}

作者:sysuzj    项目:soy   
/**
  * Report List.
  */
 public function report_list()
 {
     $this->assign("less", __FUNCTION__ . ".less");
     try {
         $model = D('cernet_report');
         $list = $model->join('cernet_team ON cernet_report.id = cernet_team.report_id')->select();
         $this->assign('list', $list);
     } catch (Exception $e) {
         $this->assign('list', '<h1>' . Success('nullContent') . '</h1>');
     }
     eval(NDSP);
 }


问题


面经


文章

微信
公众号

扫码关注公众号