本文整理汇总了PHP中strcmp函数的典型用法代码示例。如果您正苦于以下问题:PHP strcmp函数的具体用法?PHP strcmp怎么用?PHP strcmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strcmp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sc_check_priv
function sc_check_priv($prob_id, $opened, $user)
{
if (!function_exists('check_priv')) {
require __DIR__ . '/privilege.php';
}
if (isset($_SESSION['user'])) {
if (strcmp($user, $_SESSION['user']) == 0 || check_priv(PRIV_SOURCE)) {
return TRUE;
}
}
require __DIR__ . '/../conf/database.php';
if (!defined('PROB_HAS_TEX')) {
require __DIR__ . '/../lib/problem_flags.php';
}
if ($opened) {
$row = mysqli_fetch_row(mysqli_query($con, "select has_tex from problem where problem_id={$prob_id}"));
if (!$row) {
return _('There\'s no such problem');
}
$prob_flag = $row[0];
if ($prob_flag & PROB_IS_HIDE && !check_priv(PRIV_INSIDER)) {
return _('Looks like you can\'t access this page');
}
if ($prob_flag & PROB_DISABLE_OPENSOURCE) {
return _('This solution is not open-source');
} else {
if ($prob_flag & PROB_SOLVED_OPENSOURCE) {
if (isset($_SESSION['user'])) {
$query = 'select min(result) from solution where user_id=\'' . $_SESSION['user'] . "' and problem_id={$prob_id} group by problem_id";
$user_status = mysqli_query($con, $query);
$row = mysqli_fetch_row($user_status);
if ($row && $row[0] == 0) {
return TRUE;
}
}
return _('You can\'t see me before solving it');
} else {
if (isset($_SESSION['user'])) {
$res = mysqli_query($con, "SELECT contest.contest_id,co.contest_id from contest\n RIGHT JOIN (select contest_id from contest_status where user_id='" . $_SESSION['user'] . "' and leave_time is NULL) as cs on (contest.contest_id=cs.contest_id)\n LEFT JOIN (select contest_id from contest_problem where problem_id={$prob_id}) as cp on (contest.contest_id=cp.contest_id)\n LEFT JOIN (select contest_id from contest_owner where user_id='" . $_SESSION['user'] . "') as co on (contest.contest_id=co.contest_id)\n where NOW()>start_time and NOW()<end_time and contest.hide_source_code");
$num = mysqli_num_rows($res);
if ($num > 0) {
$accessible = false;
while ($row = mysqli_fetch_row($res)) {
if (!is_null($row[1])) {
$accessible = true;
}
}
if ($accessible) {
return TRUE;
} else {
return _('You can\'t see me before the contest ends');
}
}
return TRUE;
}
}
}
}
return _('Looks like you can\'t access this page');
}
开发者ID:CDFLS,项目名称:CWOJ,代码行数:60,代码来源:sourcecode.php
示例2: action_edit
function action_edit($lid)
{
$model = $this->model;
$model->get_link_by_id($lid);
if (!isset($_POST['edit'])) {
$this->view = new Main_View(array(CONTENT => 'Edit_Link', 'edit_data' => $model));
$this->view->render();
}
if (isset($_POST['edit'])) {
if (isset($_POST['check']) && strcmp($_POST['check'], 'on') == 0) {
$privacy_status = 'private';
} else {
$privacy_status = 'public';
}
$model->set_title($_POST['title']);
$model->set_link($_POST['link']);
$model->set_description($_POST['description']);
$model->set_privacy_status($privacy_status);
$is_saved = $model->save();
if (!$is_saved) {
$this->view = new Main_View(array(CONTENT => 'Edit_Link', 'edit_data' => $model));
$this->view->render();
} else {
header('Location: /Link/show_my');
}
}
}
开发者ID:dariachechulina,项目名称:LinkStorage,代码行数:27,代码来源:Link_Controller.php
示例3: getQualityWithId
/**
* @param $id The Quality ID to analyse
* @return \QualityInfo the object corresponding to the ID
*/
public function getQualityWithId($id)
{
$json = getCall($this->basePath . "/" . $id);
$quality = QualityInfo::create($json);
if (strcmp($quality->status, "FINISHED") == 0) {
$stepsize = 100;
for ($rep = 0; $rep < count($quality->results); $rep++) {
$psnr = QualityPSNR::create("{}");
$psnr->setID($quality->results[$rep]->id);
$psnr->setStatus($quality->status);
$psnr->initvalues();
for ($i = 0; $i < $quality->numberOfFrames; $i += $stepsize + 1) {
$json = getCall($this->basePath . "/" . $id . "/psnr/" . $quality->results[$rep]->id . "/" . $i . "/" . ($i + $stepsize));
$partPSNR = QualityPartResult::create($json);
//var_dump($partPSNR);
for ($ii = 0; $ii < count($partPSNR->values); $ii++) {
$psnr->addValue($partPSNR->values[$ii]);
}
}
$quality->addPSNRValues($psnr);
}
}
//var_dump($quality);
return $quality;
}
开发者ID:TheElk205,项目名称:qualityWeb,代码行数:29,代码来源:QualityApi.php
示例4: endsWith
function endsWith($haystack, $needle, $case = true)
{
if ($case) {
return strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
}
return strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
}
开发者ID:JustKiddingCode,项目名称:apvel,代码行数:7,代码来源:lib.php
示例5: compare
function compare($respw, $pw)
{
if(strcmp($respw, $pw)==0)
return true;
else
return false;
}
开发者ID:rashmibachani,项目名称:Feed-Reader,代码行数:7,代码来源:funx.php
示例6: check_command
function check_command($check_str)
{
if (strcmp($check_str, "actionTrainees")) {
return SYMBOL_ERROR;
}
return $check_str;
}
开发者ID:ahmatjan,项目名称:iLearn_iSearch_API,代码行数:7,代码来源:Trainees_action.php
示例7: check_command
function check_command($check_str)
{
if (strcmp($check_str, "read") && strcmp($check_str, "write")) {
return SYMBOL_ERROR;
}
return $check_str;
}
开发者ID:ahmatjan,项目名称:iLearn_iSearch_API,代码行数:7,代码来源:Categories_modify.php
示例8: handleLanguageChange
/**
* Set the cultureKey for the login page and get the list of languages
* @return string The loaded cultureKey
*/
public function handleLanguageChange()
{
$cultureKey = $this->modx->getOption('cultureKey', $_REQUEST, 'en');
if ($cultureKey) {
$cultureKey = $this->modx->sanitizeString($cultureKey);
$this->modx->setOption('cultureKey', $cultureKey);
$this->modx->setOption('manager_language', $cultureKey);
}
$this->setPlaceholder('cultureKey', $cultureKey);
$languages = $this->modx->lexicon->getLanguageList('core');
$list = array();
foreach ($languages as $language) {
$selected = $language == $cultureKey ? ' selected="selected"' : '';
$list[] = '<option value="' . $language . '"' . $selected . '>' . $language . '</option>';
}
$this->setPlaceholder('languages', implode("\n", $list));
$this->modx->lexicon->load('login');
$languageString = $this->modx->lexicon('login_language');
if (empty($languageString) || strcmp($languageString, 'login_language') == 0) {
$this->modx->lexicon->load('en:core:login');
$languageString = $this->modx->lexicon('login_language', array(), 'en');
}
$this->setPlaceholder('language_str', $languageString);
return $cultureKey;
}
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:29,代码来源:login.class.php
示例9: isValid
/**
* Returns TRUE, if the given property ($value) is a valid array consistent of two equal passwords and their length
* is between 'minimum' (defaults to 0 if not specified) and 'maximum' (defaults to infinite if not specified)
* to be specified in the validation options.
*
* If at least one error occurred, the result is FALSE.
*
* @param mixed $value The value that should be validated
* @return void
* @throws \TYPO3\Flow\Validation\Exception\InvalidSubjectException
*/
protected function isValid($value)
{
if (!is_array($value)) {
throw new \TYPO3\Flow\Validation\Exception\InvalidSubjectException('The given value was not an array.', 1324641197);
}
$password = trim(strval(array_shift($value)));
$repeatPassword = trim(strval(array_shift($value)));
$passwordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
$passwordNotEmptyValidatorResult = $passwordNotEmptyValidator->validate($password);
$repeatPasswordNotEmptyValidator = new \TYPO3\Flow\Validation\Validator\NotEmptyValidator();
$repeatPasswordNotEmptyValidatorResult = $repeatPasswordNotEmptyValidator->validate($repeatPassword);
if ($passwordNotEmptyValidatorResult->hasErrors() === TRUE && $repeatPasswordNotEmptyValidatorResult->hasErrors() === TRUE) {
if (!isset($this->options['allowEmpty']) || isset($this->options['allowEmpty']) && intval($this->options['allowEmpty']) === 0) {
$this->addError('The given password was empty.', 1324641097);
}
return;
}
if (strcmp($password, $repeatPassword) !== 0) {
$this->addError('The passwords did not match.', 1324640997);
return;
}
$stringLengthValidator = new \TYPO3\Flow\Validation\Validator\StringLengthValidator(array('minimum' => $this->options['minimum'], 'maximum' => $this->options['maximum']));
$stringLengthValidatorResult = $stringLengthValidator->validate($password);
if ($stringLengthValidatorResult->hasErrors() === TRUE) {
foreach ($stringLengthValidatorResult->getErrors() as $error) {
$this->result->addError($error);
}
}
}
开发者ID:radmiraal,项目名称:neos-development-collection,代码行数:40,代码来源:PasswordValidator.php
示例10: getVenuesSortedByLocation
/**
* @return array of \app\model\Venue sorted alphabetically by location
*/
public function getVenuesSortedByLocation()
{
usort($this->venues, function ($venueA, $venueB) {
return strcmp($venueA->getLocation(), $venueB->getLocation());
});
return $this->venues;
}
开发者ID:kk222hk,项目名称:1dv608-laborations,代码行数:10,代码来源:VenueList.php
示例11: radioButtonList
public static function radioButtonList($name, $select, $data, $htmlOptions = array())
{
$template = isset($htmlOptions['template']) ? $htmlOptions['template'] : '{input} {label}';
$separator = isset($htmlOptions['separator']) ? $htmlOptions['separator'] : "<br/>\n";
unset($htmlOptions['template'], $htmlOptions['separator']);
$labelOptions = isset($htmlOptions['labelOptions']) ? $htmlOptions['labelOptions'] : array();
unset($htmlOptions['labelOptions']);
$items = array();
$baseID = self::getIdByName($name);
$id = 0;
$hasJqueryUIScreenshot = strpos($template, '{jqueryUIScreenshot}') !== false;
//+
foreach ($data as $value => $label) {
$jqueryUIScreenshot = $hasJqueryUIScreenshot ? self::image(Yii::app()->request->baseUrl . '/static/css/ui/' . $value . '/screenshot.png', $label, array('height' => 105, 'title' => $label)) : '';
//+
$checked = !strcmp($value, $select);
$htmlOptions['value'] = $value;
$htmlOptions['id'] = $baseID . '_' . $id++;
$option = self::radioButton($name, $checked, $htmlOptions);
$label = self::label($label, $htmlOptions['id'], $labelOptions);
$items[] = strtr($template, array('{input}' => $option, '{label}' => $label, '{jqueryUIScreenshot}' => $jqueryUIScreenshot));
//!
}
return implode($separator, $items);
}
开发者ID:megabr,项目名称:web3cms,代码行数:25,代码来源:_CHtml.php
示例12: cmp_date
function cmp_date($a, $b)
{
if ($a['date'] == $b['date']) {
return strcmp($a['post']->post_title, $b['post']->post_title);
}
return $a['date'] > $b['date'] ? -1 : 1;
}
开发者ID:peterbehr,项目名称:peterbehr,代码行数:7,代码来源:functions.php
示例13: getNavigation
/**
* @return array
*/
public function getNavigation()
{
//$this->setActiveElements();
$return = [];
foreach ($this->pages as $block => $blockPages) {
if (is_array($blockPages) && count($blockPages) > 0 && $blockPages[0] instanceof rex_be_page_main) {
uasort($blockPages, function (rex_be_page_main $a, rex_be_page_main $b) {
$a_prio = (int) $a->getPrio();
$b_prio = (int) $b->getPrio();
if ($a_prio == $b_prio || $a_prio <= 0 && $b_prio <= 0) {
return strcmp($a->getTitle(), $b->getTitle());
}
if ($a_prio <= 0) {
return 1;
}
if ($b_prio <= 0) {
return -1;
}
return $a_prio > $b_prio ? 1 : -1;
});
}
$n = $this->_getNavigation($blockPages);
if (count($n) > 0) {
$fragment = new rex_fragment();
$fragment->setVar('navigation', $n, false);
$return[] = ['navigation' => $n, 'headline' => ['title' => $this->getHeadline($block)]];
}
}
return $return;
}
开发者ID:staabm,项目名称:redaxo,代码行数:33,代码来源:navigation.php
示例14: GetGroupInfo
function GetGroupInfo(LOGGROUP $grp = NULL, $flags = 0)
{
$groups = array();
$res = $this->cache->ListCachedGroups();
foreach ($res as $gid) {
if ($grp && strcmp($grp->gid, $gid)) {
continue;
}
$groups[$gid] = array('gid' => $gid, 'name' => $gid);
if ($flags & REQUEST::NEED_INFO) {
$postfix = $this->cache->GetCachePostfix($gid);
$info = $this->cache->GetCacheInfo($postfix, $flags & REQUEST::FLAG_MASK);
if (!$info) {
throw new ADEIException(translate("The CACHE for group (%s) is empty", $grp->gid));
}
foreach ($info as $key => &$value) {
$groups[$gid][$key] = $value;
}
if ($flags & REQUEST::NEED_ITEMINFO) {
$groups[$gid]['items'] = $this->cache->GetCacheItemList($postfix);
}
}
}
return $grp ? $groups[$grp->gid] : $groups;
}
开发者ID:nicolaisi,项目名称:adei,代码行数:25,代码来源:cachereader.php
示例15: SB_trOrderCmp
function SB_trOrderCmp(&$a, &$b)
{
if ($a->order == $b->order) {
return strcmp($a->name, $b->name);
}
return $a->order > $b->order ? 1 : -1;
}
开发者ID:kidexx,项目名称:sitebar,代码行数:7,代码来源:tree.inc.php
示例16: CheckLoginCookie
function CheckLoginCookie()
{
global $wpdb, $ewd_feup_user_table_name;
$LoginTime = get_option("EWD_FEUP_Login_Time");
$Salt = get_option("EWD_FEUP_Hash_Salt");
$CookieName = "EWD_FEUP_Login" . "%" . sha1(md5(get_site_url() . $Salt));
$cookie_name_url_encoded = urlencode($CookieName);
$Cookie = null;
if (isset($_COOKIE[$CookieName])) {
$Cookie = $_COOKIE[$CookieName];
}
if (isset($_COOKIE[$cookie_name_url_encoded])) {
$Cookie = $_COOKIE[$cookie_name_url_encoded];
}
$Username = substr($Cookie, 0, strpos($Cookie, "%"));
$TimeStamp = substr($Cookie, strpos($Cookie, "%") + 1, strrpos($Cookie, "%") - strpos($Cookie, "%"));
$SecCheck = substr($Cookie, strrpos($Cookie, "%") + 1);
$UserAgent = $_SERVER['HTTP_USER_AGENT'];
if (isset($_COOKIE[$CookieName]) || isset($_COOKIE[$cookie_name_url_encoded]) and $TimeStamp < time() + $LoginTime * 60) {
$UserDB = $wpdb->get_row($wpdb->prepare("SELECT User_Sessioncheck , User_Password FROM {$ewd_feup_user_table_name} WHERE Username ='%s'", $Username));
$DBSeccheck = $UserDB->User_Sessioncheck;
if (strcmp(sha1($SecCheck . $UserAgent), $DBSeccheck) === 0) {
$User = array('Username' => $Username, 'User_Password' => $UserDB->User_Password);
return $User;
} else {
return false;
}
}
return false;
}
开发者ID:jeremygeltman,项目名称:ThinkThinly,代码行数:30,代码来源:CheckLoginCookie.php
示例17: setLanguage
function setLanguage($params)
{
$locale = Configure::read('Config.language');
//$locale = 'rus';
//echo "set: locale: {$locale}\n";
// first check cookie,
// then parameter
// then compare current config value with session
if ($this->Cookie->read('lang') && !$this->Session->check('Config.language')) {
$this->Session->write('Config.language', $this->Cookie->read('lang'));
$locale = $this->Cookie->read('lang');
//echo "case 1\n";
} else {
if (isset($params['lang']) && $params['lang'] != $this->Session->read('Config.language')) {
$this->Session->write('Config.language', $params['lang']);
$this->Cookie->write('lang', $params['lang'], null, '20 days');
$locale = $params['lang'];
//echo "case 2\n";
} else {
if ($this->Session->check('Config.language') && $locale != $this->Session->read('Config.language')) {
$locale = $this->Session->read('Config.language');
// TODO: uncomment this if your languages do not work
if (strcmp($locale, 'rus') != 0 && strcmp($locale, 'eng') != 0) {
$this->Session->write('Config.language', 'rus');
}
//echo "case 3\n";
}
}
}
//$locale = 'rus';
//Configure::write('Config.language', $locale);
return $locale;
}
开发者ID:GregFeehan,项目名称:govorimvmeste,代码行数:33,代码来源:language_helper.php
示例18: wpseo_title_test
/**
* Test whether force rewrite should be enabled or not.
*/
function wpseo_title_test()
{
$options = get_option('wpseo_titles');
$options['forcerewritetitle'] = false;
$options['title_test'] = 1;
update_option('wpseo_titles', $options);
// Setting title_test to > 0 forces the plugin to output the title below through a filter in class-frontend.php.
$expected_title = 'This is a Yoast Test Title';
WPSEO_Utils::clear_cache();
$args = array('user-agent' => sprintf('WordPress/%1$s; %2$s - Yoast', $GLOBALS['wp_version'], get_site_url()));
$resp = wp_remote_get(get_bloginfo('url'), $args);
if ($resp && !is_wp_error($resp) && (200 == $resp['response']['code'] && isset($resp['body']))) {
$res = preg_match('`<title>([^<]+)</title>`im', $resp['body'], $matches);
if ($res && strcmp($matches[1], $expected_title) !== 0) {
$options['forcerewritetitle'] = true;
$resp = wp_remote_get(get_bloginfo('url'), $args);
$res = false;
if ($resp && !is_wp_error($resp) && (200 == $resp['response']['code'] && isset($resp['body']))) {
$res = preg_match('`/<title>([^>]+)</title>`im', $resp['body'], $matches);
}
}
if (!$res || $matches[1] != $expected_title) {
$options['forcerewritetitle'] = false;
}
} else {
// If that dies, let's make sure the titles are correct and force the output.
$options['forcerewritetitle'] = true;
}
$options['title_test'] = 0;
update_option('wpseo_titles', $options);
}
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:34,代码来源:wpseo-non-ajax-functions.php
示例19: dologin
public function dologin()
{
if ($this->check_loginform() === false) {
$this->login();
} else {
$username = $this->input->post('username');
$password = $this->input->post('password');
$rolename = $this->input->post('rolename');
if ($user = $this->user_model->get_by_username($username)) {
if ($this->role_model->check_role($rolename, $user['role_id'])) {
if ($this->user_model->check_password($password, $user['password'])) {
$this->user_model->save_user_session($user);
if (!strcmp($rolename, "内容审核员")) {
redirect('admin/audit');
} else {
redirect('admin/index');
}
} else {
$this->data['login_error'] = '用户名或者密码不正确';
}
} else {
$this->data['login_error'] = '角色不符合';
}
} else {
$this->data['login_error'] = '用户名没找到';
}
$this->load->view('admin/login', $this->data);
}
}
开发者ID:wooyiuhan,项目名称:paperassist,代码行数:29,代码来源:login.php
示例20: isSae
/**
* @descrpition 判断平台是否是SAE
* @param $appname,运行时所属环境下的应用名称
* @param $accesskey, 运行时所属环境下的accesskey
* @return bool
*/
public static function isSae($appname, $accesskey)
{
if (!strcmp(HTTP_APPNAME, $appname) && !strcmp(HTTP_ACCESSKEY, $accesskey)) {
return true;
}
return false;
}
开发者ID:lixuancn,项目名称:lanewechat,代码行数:13,代码来源:environment.lib.php
注:本文中的strcmp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论