本文整理汇总了PHP中get_int函数的典型用法代码示例。如果您正苦于以下问题:PHP get_int函数的具体用法?PHP get_int怎么用?PHP get_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select_profile
function select_profile($cmd)
{
// Request for a random profile.
//
if ($cmd == "rand") {
$profiles = array();
$pic = get_int('pic');
if ($pic == 0) {
$profiles = BoincProfile::enum("has_picture=0", "limit 1000");
} else {
if ($pic == 1) {
$profiles = BoincProfile::enum("has_picture=1", "limit 1000");
} else {
if ($pic == -1) {
$profiles = BoincProfile::enum(null, "limit 1000");
}
}
}
if (count($profiles) == 0) {
page_head(tra("No profiles"));
echo tra("No profiles matched your query.");
page_tail();
exit;
}
shuffle($profiles);
$userid = $profiles[0]->userid;
header("Location: " . URL_BASE . "view_profile.php?userid={$userid}");
exit;
}
}
示例2: includeNominations
public function includeNominations(Beatmapset $beatmapset, ParamBag $params = null)
{
if ($beatmapset->isPending()) {
if ($params !== null) {
$userId = get_int($params->get('user_id')[0] ?? null);
}
$nominations = $beatmapset->recentEvents()->get();
foreach ($nominations as $nomination) {
if ($nomination->type === BeatmapsetEvent::DISQUALIFY) {
$disqualifyEvent = $nomination;
}
if (isset($userId) && $nomination->user_id === $userId && $nomination->type === BeatmapsetEvent::NOMINATE) {
$alreadyNominated = true;
}
}
$result = ['required' => $beatmapset->requiredNominationCount(), 'current' => $beatmapset->currentNominationCount()];
if (isset($disqualifyEvent)) {
$result['disqualification'] = ['reason' => $disqualifyEvent->comment, 'created_at' => json_time($disqualifyEvent->created_at)];
}
if (isset($userId)) {
$result['nominated'] = $alreadyNominated ?? false;
}
return $this->item($beatmapset, function ($beatmapset) use($result) {
return $result;
});
} elseif ($beatmapset->qualified()) {
$eta = $beatmapset->rankingETA();
$result = ['ranking_eta' => json_time($eta)];
return $this->item($beatmapset, function ($beatmapset) use($result) {
return $result;
});
} else {
return;
}
}
示例3: update_info
function update_info()
{
global $user;
$sex = get_int('sex');
$birth_year = get_int('birth_year');
$user->bolt->update("sex={$sex}, birth_year={$birth_year}");
}
示例4: remove_admin
function remove_admin($team)
{
$userid = get_int('userid');
$ret = BoincTeamAdmin::delete("teamid={$team->id} and userid={$userid}");
if (!$ret) {
error_page(tra("failed to remove admin"));
}
}
示例5: show
public function show($id)
{
$postStartId = Request::input('start');
$postEndId = get_int(Request::input('end'));
$nthPost = get_int(Request::input('n'));
$skipLayout = Request::input('skip_layout') === '1';
$jumpTo = null;
$topic = Topic::with('forum.cover')->findOrFail($id);
$this->authorizeView($topic->forum);
$posts = $topic->posts();
if ($postStartId === 'unread') {
$postStartId = Post::lastUnreadByUser($topic, Auth::user());
} else {
$postStartId = get_int($postStartId);
}
if ($nthPost !== null) {
$post = $topic->nthPost($nthPost);
if ($post) {
$postStartId = $post->post_id;
}
}
if (!$skipLayout) {
foreach ([$postStartId, $postEndId, 0] as $jumpPoint) {
if ($jumpPoint === null) {
continue;
}
$jumpTo = $jumpPoint;
break;
}
}
if ($postStartId !== null && !$skipLayout) {
// move starting post up by ten to avoid hitting
// page autoloader right after loading the page.
$postPosition = $topic->postPosition($postStartId);
$post = $topic->nthPost($postPosition - 10);
$postStartId = $post->post_id;
}
if ($postStartId !== null) {
$posts = $posts->where('post_id', '>=', $postStartId);
} elseif ($postEndId !== null) {
$posts = $posts->where('post_id', '<=', $postEndId)->orderBy('post_id', 'desc');
}
$posts = $posts->take(20)->with('user.rank')->with('user.country')->with('user.supports')->get()->sortBy(function ($p) {
return $p->post_id;
});
if ($posts->count() === 0) {
abort($skipLayout ? 204 : 404);
}
$postsPosition = $topic->postsPosition($posts);
Event::fire(new TopicWasViewed($topic, $posts->last(), Auth::user()));
$template = $skipLayout ? '_posts' : 'show';
$cover = fractal_item_array($topic->cover()->firstOrNew([]), new TopicCoverTransformer());
return view("forum.topics.{$template}", compact('topic', 'posts', 'postsPosition', 'jumpTo', 'cover'));
}
示例6: IdQuery
function IdQuery($query, $id)
{
global $app, $db;
$cleanID = get_int($id);
// bad request
if ($cleanID == null) {
$app->halt(400);
}
// execute query
$result = $db->query(str_replace("_ID_", $cleanID, $query));
return $result;
}
示例7: handle_add
function handle_add($job, $inst)
{
$f = null;
$f->x = get_int('pic_x');
$f->y = get_int('pic_y');
$f->type = sanitize_tags(get_str('type'));
$c = sanitize_tags(get_str('comment', true));
if (strstr($c, "(optional)")) {
$c = "";
}
$f->comment = $c;
$output = $inst->get_opaque_data();
$output->features[] = $f;
$inst->set_opaque_data($output);
header("location: bossa_example4.php?bji={$inst->id}");
}
示例8: discussion
public function discussion($id)
{
$returnJson = Request::input('format') === 'json';
$lastUpdated = get_int(Request::input('last_updated'));
$beatmapset = Beatmapset::findOrFail($id);
$discussion = $beatmapset->beatmapsetDiscussion()->firstOrFail();
if ($returnJson && $lastUpdated !== null && $lastUpdated >= $discussion->updated_at->timestamp) {
return ['updated' => false];
}
$initialData = ['beatmapset' => $beatmapset->defaultJson(), 'beatmapsetDiscussion' => $discussion->defaultJson()];
if ($returnJson) {
return $initialData;
} else {
return view('beatmapsets.discussion', compact('beatmapset', 'initialData'));
}
}
示例9: show_batch
function show_batch($user)
{
$batch_id = get_int('batch_id');
$batch = BoincBatch::lookup_id($batch_id);
if (!$batch || $batch->user_id != $user->id) {
error_page("no batch");
}
page_head("Batch {$batch->id}");
$results = BoincResult::enum("batch={$batch->id} order by workunitid");
$i = 0;
result_table_start(true, true, null);
foreach ($results as $result) {
show_result_row($result, true, true, true, $i++);
}
end_table();
page_tail();
}
示例10: get_batch_output_files
function get_batch_output_files($auth_str)
{
$batch_id = get_int('batch_id', true);
if ($batch_id) {
$batch = BoincBatch::lookup_id($batch_id);
if (!$batch) {
die("no batch {$batch_id}");
}
} else {
$batch_name = get_int('batch_name');
$batch_name = BoincDb::escape_string($batch_name);
$batch = BoincBatch::lookup("name='{$batch_name}'");
if (!$batch) {
die("no batch {$batch_name}");
}
}
$user = BoincUser::lookup_id($batch->user_id);
if (!$user) {
die("no user {$batch->user_id}");
}
$x = md5($user->authenticator . $batch->id);
if ($x != $auth_str) {
die("bad auth str");
}
$zip_basename = tempnam("../cache", "boinc_batch_");
$zip_filename = $zip_basename . ".zip";
$fanout = parse_config(get_config(), "<uldl_dir_fanout>");
$upload_dir = parse_config(get_config(), "<upload_dir>");
$wus = BoincWorkunit::enum("batch={$batch->id}");
foreach ($wus as $wu) {
if (!$wu->canonical_resultid) {
continue;
}
$result = BoincResult::lookup_id($wu->canonical_resultid);
$names = get_outfile_names($result);
foreach ($names as $name) {
$path = dir_hier_path($name, $upload_dir, $fanout);
if (is_file($path)) {
system(" nice -9 zip -jq {$zip_basename} {$path}");
}
}
}
do_download($zip_filename);
unlink($zip_filename);
}
示例11: print_cart
function print_cart()
{
global $in_cart;
if (array_key_exists('игрушка детская велосипед', $in_cart)) {
if (get_available($in_cart['игрушка детская велосипед']['количество заказано'], $in_cart['игрушка детская велосипед']['осталось на складе']) >= 3) {
echo '<p>Поздравляем вас с участием в акции, вы купили товар "игрушка детская велосипед" в количестве более 3 штук, и получаете скидку в 30%</p>';
$in_cart['игрушка детская велосипед']['diskont'] = 'diskont3';
} else {
echo 'Купив товар "игрушка детская велосипед" количеством более 3 штук вы получите скидку 30%!';
}
$action_profit = get_profit($in_cart['игрушка детская велосипед']['количество заказано'], $in_cart['игрушка детская велосипед']['осталось на складе'], $in_cart['игрушка детская велосипед']['цена']);
}
$cart = '<table border="1"><tr>';
$cart .= '<td>№</td>' . '<td><b>Наименование</b></td>' . '<td><b>Цена</b></td>' . '<td><b>Скидка</b></td>';
$cart .= '<td><b>В заказе</b></td>' . '<td><b>На складе</b></td>' . '<td><b>Итого со скидкой</b></td></tr>';
static $total_goods = 0;
static $total_cost = 0;
static $count = 0;
static $total_profit = 0;
foreach ($in_cart as $key => $val) {
$item_price = $val['цена'];
$in_order = $val['количество заказано'];
$in_stock = $val['осталось на складе'];
$diskont = get_int($val['diskont']);
$show_diskont = $diskont > 0 ? $diskont . '0%' : '0%';
//красивое число скидки в таблице
$price = get_price($item_price, $diskont, $in_order, $key, $in_stock);
$cart .= '<tr><td>' . ++$count . '</td>';
$cart .= '<td>' . $key . '</td>';
$cart .= '<td>' . $item_price . '</td>';
$cart .= '<td>' . $show_diskont . '</td>';
$cart .= '<td>' . $in_order . '</td>';
$cart .= '<td>' . $in_stock . '</td>';
$cart .= '<td>' . $price[0] . '</td>';
$cart .= '</tr>';
$total_goods += get_available($in_order, $in_stock);
$total_cost += $price[0];
$total_profit += $price[1] - $price[0];
}
$cart .= '</table>';
$cart .= $action_profit;
$cart .= '<table style="border:1px solid gray;background:lightgray"><tr><td>ИТОГО в заказе:</td><td> - ' . $count . ' наименования,<br/>';
$cart .= '- ' . $total_goods . ' товаров,<br/> - ' . $total_cost . ' сумма к оплате,<br/> - ' . $total_profit . ' сэкономлено на скидках</td></tr></table>';
return $cart;
}
示例12: validate
function validate()
{
$x = get_str("x");
$u = get_int("u");
$user = lookup_user_id($u);
if (!$user) {
error_page(tra("No such user."));
}
$x2 = $user->signature;
if ($x2 != $x) {
error_page(tra("Error in URL data - can't validate email address"));
}
$result = $user->update("email_validated=1");
if (!$result) {
error_page(tra("Database update failed - please try again later."));
}
page_head(tra("Validate email address"));
echo tra("The email address of your account has been validated.");
page_tail();
}
示例13: includeCurrentUserAttributes
public function includeCurrentUserAttributes(BeatmapDiscussion $discussion, ParamBag $params = null)
{
if ($params === null) {
return;
}
$userId = get_int($params->get('user_id')[0] ?? null);
if ($userId === null) {
return;
}
$score = 0;
// This assumes beatmapDiscussionVotes are already preloaded and
// thus will save one query.
foreach ($discussion->beatmapDiscussionVotes as $vote) {
if ($vote->user_id === $userId) {
$score = $vote->score;
break;
}
}
return $this->item($discussion, function ($discussion) use($score) {
return ['vote_score' => $score];
});
}
示例14: error_page
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
require_once "../inc/boinc_db.inc";
require_once "../inc/util.inc";
if (DISABLE_PROFILES) {
error_page("Profiles are disabled");
}
check_get_args(array("search_string", "offset"));
function show_profile_link2($profile, $n)
{
$user = BoincUser::lookup_id($profile->userid);
echo "<tr><td>" . user_links($user) . "</td><td>" . date_str($user->create_time) . "</td><td>{$user->country}</td><td>" . (int) $user->total_credit . "</td><td>" . (int) $user->expavg_credit . "</td></tr>\n";
}
$search_string = get_str('search_string');
$search_string = sanitize_tags($search_string);
$search_string = BoincDb::escape_string($search_string);
$offset = get_int('offset', true);
if (!$offset) {
$offset = 0;
}
$count = 10;
page_head(tra("Profiles containing '%1'", $search_string));
$profiles = BoincProfile::enum("match(response1, response2) against ('{$search_string}') limit {$offset},{$count}");
start_table();
echo "\n <tr><th>" . tra("User name") . "</th>\n <th>" . tra("Joined project") . "</th>\n <th>" . tra("Country") . "</th>\n <th>" . tra("Total credit") . "</th>\n <th>" . tra("Recent credit") . "</th></tr>\n";
$n = 0;
foreach ($profiles as $profile) {
show_profile_link2($profile, $n + $offset + 1);
$n += 1;
}
end_table();
if ($offset == 0 && $n == 0) {
示例15: page_head
if ($passwd_hash != $user->passwd_hash) {
page_head("Password incorrect");
echo "The password you entered is incorrect. Please try again.\n";
print_login_form_aux($next_url, null, $email_addr);
page_tail();
exit;
}
$authenticator = $user->authenticator;
Header("Location: {$next_url}");
$perm = $_POST['stay_logged_in'];
send_cookie('auth', $authenticator, $perm);
exit;
}
// check for time/id/hash case.
$id = get_int('id', true);
$t = get_int('t', true);
$h = get_str('h', true);
if ($id && $t && $h) {
$user = BoincUser::lookup_id($id);
if (!$user) {
error_page("Invalid user ID.\r\n\t\t\tPlease make sure you visited the complete URL;\r\n\t\t\tit may have been split across lines by your email reader.");
}
$x = $id . $user->authenticator . $t;
$x = md5($x);
$x = substr($x, 0, 16);
if ($x != $h) {
error_page("Invalid authenticator.\r\n\t\t\tPlease make sure you visited the complete URL;\r\n\t\t\tit may have been split across lines by your email reader.");
}
if (time() - $t > 86400) {
error_page("Link has expired;\r\n\t\t\tgo <a href=get_passwd.php>here</a> to\r\n\t\t\tget a new login link by email.");
}