本文整理汇总了PHP中cmsUser::getIp方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser::getIp方法的具体用法?PHP cmsUser::getIp怎么用?PHP cmsUser::getIp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsUser
的用法示例。
在下文中一共展示了cmsUser::getIp方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$orfo = $this->request->get('orfo');
$url = $this->request->get('url');
$comment = $this->request->get('comment', false);
$author = !cmsUser::isLogged() ? cmsUser::getIp() : cmsUser::get('nickname');
$form = $this->getForm('orfo');
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
$data = $form->parse($this->request, $is_submitted);
$data['date'] = date('Y-m-d H:i:s');
$errors = $form->validate($this, $data);
dump($errors);
if (!$errors) {
$this->model->addComplaints($data);
$messenger = cmsCore::getController('messages');
$messenger->addRecipient(1);
$notice = array('content' => sprintf(LANG_COMPLAINTS_ADD_NOTICE, $url, $orfo), 'options' => array('is_closeable' => true));
$messenger->ignoreNotifyOptions()->sendNoticePM($notice, 'complaints_add');
}
cmsTemplate::getInstance()->renderJSON(array('errors' => false, 'callback' => 'formSuccess'));
}
$data = array('orfo' => $orfo, 'url' => $url, 'author' => $author, 'comment' => $comment);
return cmsTemplate::getInstance()->render('orfo', array('form' => $form, 'data' => $data));
}
示例2: setAuthToken
public function setAuthToken($user_id, $auth_token, $type = null, $subj = null)
{
if (!$type) {
$type = cmsRequest::getDeviceType();
}
return $this->insert('{users}_auth_tokens', array('ip' => sprintf('%u', ip2long(cmsUser::getIp())), 'access_type' => cmsModel::arrayToYaml(array('type' => $type, 'subj' => $subj)), 'auth_token' => $auth_token, 'user_id' => $user_id));
}
示例3: run
public function run($pass_token)
{
if (!$pass_token) {
cmsCore::error404();
}
if (cmsUser::isLogged()) {
$this->redirectToHome();
}
$users_model = cmsCore::getModel('users');
$user = $users_model->getUserByPassToken($pass_token);
if (!$user) {
cmsCore::error404();
}
$users_model->unlockUser($user['id']);
$users_model->clearUserPassToken($user['id']);
cmsEventsManager::hook('user_registered', $user);
cmsUser::addSessionMessage($this->options['reg_auto_auth'] ? LANG_REG_SUCCESS_VERIFIED_AND_AUTH : LANG_REG_SUCCESS_VERIFIED, 'success');
// авторизуем пользователя автоматически
if ($this->options['reg_auto_auth']) {
$user = cmsEventsManager::hook('user_login', $user);
cmsUser::sessionSet('user', array('id' => $user['id'], 'groups' => $user['groups'], 'time_zone' => $user['time_zone'], 'perms' => cmsUser::getPermissions($user['groups']), 'is_admin' => $user['is_admin']));
$update_data = array('ip' => cmsUser::getIp());
$this->model->update('{users}', $user['id'], $update_data, true);
cmsEventsManager::hook('auth_login', $user['id']);
}
$this->redirect($this->getAuthRedirectUrl($this->options['first_auth_redirect']));
}
示例4: getGeoByIp
public function getGeoByIp()
{
$cached_geo = cmsUser::sessionGet('geo_data');
if ($cached_geo) {
return $cached_geo;
}
$out = simplexml_load_string(file_get_contents_from_url('http://ipgeobase.ru:7020/geo?ip=' . cmsUser::getIp()));
$data = array();
if ($out && is_object($out) && !empty($out->ip[0])) {
foreach ($out->ip[0] as $key => $value) {
$data[$key] = (string) $value;
}
}
$geo = array('city' => array('id' => null, 'name' => null), 'country' => array('id' => null, 'name' => null));
if (isset($data['country'])) {
$geo['country'] = $this->model->getItemByField('geo_countries', 'alpha2', $data['country']);
}
if (isset($data['city'])) {
if (!empty($geo['country']['id'])) {
$this->model->filterEqual('country_id', $geo['country']['id']);
}
$geo['city'] = $this->model->getItemByField('geo_cities', 'name', $data['city']);
}
cmsUser::sessionSet('geo_data', $geo);
return $geo;
}
示例5: allowByIp
private function allowByIp()
{
$allow_ips = cmsConfig::get('allow_ips');
if (!$allow_ips) {
return true;
}
return string_in_mask_list(cmsUser::getIp(), $allow_ips);
}
示例6: run
public function run($request)
{
$response = $request->get('g-recaptcha-response', false);
if (!$response) {
return false;
}
return $this->callApi(array('secret' => $this->options['private_key'], 'response' => $response, 'remoteip' => cmsUser::getIp()));
}
示例7: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
// включено ли голосование от гостей?
if (empty($this->options['allow_guest_vote']) && !$this->cms_user->is_logged) {
return $this->cms_template->renderJSON(array('success' => false, 'message' => LANG_ERROR));
}
// Получаем параметры
$direction = $this->request->get('direction', '');
$target_controller = $this->request->get('controller', '');
$target_subject = $this->request->get('subject', '');
$target_id = $this->request->get('id', 0);
$is_valid = $this->validate_sysname($target_controller) === true && $this->validate_sysname($target_subject) === true && is_numeric($target_id) && in_array($direction, array('up', 'down'));
if (!$is_valid) {
return $this->cms_template->renderJSON(array('success' => false, 'message' => LANG_ERROR));
}
// Объединяем всю информацию о голосе
$vote = array('user_id' => $this->cms_user->id ? $this->cms_user->id : null, 'target_controller' => $target_controller, 'target_subject' => $target_subject, 'target_id' => $target_id, 'score' => $direction == 'up' ? 1 : -1, 'ip' => sprintf('%u', ip2long(cmsUser::getIp())));
$cookie_key = $target_subject . $target_id . $target_controller;
// Этот голос уже учитывался?
$is_voted = $this->model->isUserVoted($vote, $this->cms_user->is_logged);
if ($is_voted) {
// если куки нет, ставим
if (!empty($this->options['is_hidden']) && !cmsUser::getCookie($cookie_key)) {
cmsUser::setCookie($cookie_key, 1, 2628000);
// год
}
return $this->cms_template->renderJSON(array('success' => false, 'message' => LANG_RATING_VOTED));
}
$target_model = cmsCore::getModel($target_controller);
$target = $target_model->getRatingTarget($target_subject, $target_id);
if (!empty($target['user_id'])) {
if ($this->cms_user->is_logged) {
if ($target['user_id'] == $this->cms_user->id || !cmsUser::isAllowed($target_subject, 'rate')) {
return $this->cms_template->renderJSON(array('success' => false, 'message' => LANG_RATING_DISABLED));
}
}
}
// Добавляем голос в лог
$this->model->addVote($vote);
// Обновляем суммарный рейтинг цели
$rating = (int) $target['rating'] + $vote['score'];
$target_model->updateRating($target_subject, $target_id, $rating);
// Оповещаем всех об изменении рейтинга
cmsEventsManager::hook('rating_vote', array('subject' => $target_subject, 'id' => $target_id, 'target' => $target, 'vote' => $vote, 'rating' => $rating));
// Собираем результат
$result = array('success' => true, 'rating' => html_signed_num($rating), 'css_class' => html_signed_class($rating) . ($this->options['is_show'] ? ' clickable' : ''), 'message' => LANG_RATING_VOTED);
// запоминаем в куках
if (!empty($this->options['is_hidden'])) {
cmsUser::setCookie($cookie_key, 1, 2628000);
// год
}
return $this->cms_template->renderJSON($result);
}
示例8: getDownloadHash
public function getDownloadHash()
{
return md5(cmsUser::getIp() . $this->cms_config->host);
}
示例9: init
public function init()
{
$is_css_cache = cmsCore::getFilesList('cache/static/css', '*.css');
$is_js_cache = cmsCore::getFilesList('cache/static/js', '*.js');
$ctypes = cmsCore::getModel('content')->getContentTypes();
return array(array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_SITE, 'childs' => array(new fieldCheckbox('is_site_on', array('title' => LANG_CP_SETTINGS_SITE_ENABLED)), new fieldString('off_reason', array('title' => LANG_CP_SETTINGS_SITE_REASON)), new fieldString('sitename', array('title' => LANG_CP_SETTINGS_SITENAME, 'rules' => array(array('required')))), new fieldString('hometitle', array('title' => LANG_CP_SETTINGS_HOMETITLE, 'rules' => array(array('required')))), new fieldList('frontpage', array('title' => LANG_CP_SETTINGS_FP_SHOW, 'generator' => function ($item) use($ctypes) {
$items = array('none' => LANG_CP_SETTINGS_FP_SHOW_NONE, 'profile' => LANG_CP_SETTINGS_FP_SHOW_PROFILE);
if ($ctypes) {
foreach ($ctypes as $ctype) {
if (!$ctype['options']['list_on']) {
continue;
}
$items["content:{$ctype['name']}"] = sprintf(LANG_CP_SETTINGS_FP_SHOW_CONTENT, $ctype['title']);
}
}
return $items;
})), new fieldList('ctype_default', array('title' => LANG_CP_SETTINGS_CTYPE_DEF, 'hint' => LANG_CP_SETTINGS_CTYPE_DEF_HINT, 'generator' => function ($item) use($ctypes) {
$items[''] = LANG_NO;
if ($ctypes) {
foreach ($ctypes as $ctype) {
$items[$ctype['name']] = $ctype['title'];
}
}
return $items;
})), new fieldString('metakeys', array('title' => LANG_CP_SETTINGS_METAKEYS)), new fieldText('metadesc', array('title' => LANG_CP_SETTINGS_METADESC)), new fieldCheckbox('is_no_meta', array('title' => LANG_CP_SETTINGS_META_NO_DEFAULT)), new fieldCheckbox('is_sitename_in_title', array('title' => LANG_CP_SETTINGS_IS_SITENAME_IN_TITLE, 'default' => 1)), new fieldCheckbox('is_check_updates', array('title' => LANG_CP_SETTINGS_CHECK_UPDATES)), new fieldString('detect_ip_key', array('title' => LANG_CP_SETTINGS_DETECT_IP_KEY, 'hint' => LANG_CP_SETTINGS_DETECT_IP_KEY_HINT, 'default' => 'REMOTE_ADDR')))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_GUI, 'childs' => array(new fieldList('template', array('title' => LANG_CP_SETTINGS_TEMPLATE, 'hint' => '<a href="#" data-url="' . href_to('admin', 'settings', 'theme') . '">' . LANG_CP_SETTINGS_TEMPLATE_OPTIONS . '</a>', 'generator' => function ($item) {
$tpls = cmsCore::getTemplates();
$items = array();
if ($tpls) {
foreach ($tpls as $tpl) {
$items[$tpl] = $tpl;
}
}
return $items;
})), new fieldList('template_admin', array('title' => LANG_CP_SETTINGS_TEMPLATE_ADMIN, 'hint' => '<a href="#" data-url="' . href_to('admin', 'settings', 'theme') . '">' . LANG_CP_SETTINGS_TEMPLATE_OPTIONS . '</a>', 'generator' => function ($item) {
$tpls = cmsCore::getTemplates();
$items = array('' => LANG_BY_DEFAULT);
if ($tpls) {
foreach ($tpls as $tpl) {
$items[$tpl] = $tpl;
}
}
return $items;
})), new fieldList('template_mobile', array('title' => LANG_CP_SETTINGS_TEMPLATE_MOBILE, 'hint' => '<a href="#" data-url="' . href_to('admin', 'settings', 'theme') . '">' . LANG_CP_SETTINGS_TEMPLATE_OPTIONS . '</a>', 'generator' => function ($item) {
$tpls = cmsCore::getTemplates();
$items = array('' => LANG_BY_DEFAULT);
if ($tpls) {
foreach ($tpls as $tpl) {
$items[$tpl] = $tpl;
}
}
return $items;
})), new fieldList('template_tablet', array('title' => LANG_CP_SETTINGS_TEMPLATE_TABLET, 'hint' => '<a href="#" data-url="' . href_to('admin', 'settings', 'theme') . '">' . LANG_CP_SETTINGS_TEMPLATE_OPTIONS . '</a>', 'generator' => function ($item) {
$tpls = cmsCore::getTemplates();
$items = array('' => LANG_BY_DEFAULT);
if ($tpls) {
foreach ($tpls as $tpl) {
$items[$tpl] = $tpl;
}
}
return $items;
})), new fieldList('language', array('title' => LANG_CP_SETTINGS_LANGUAGE, 'generator' => function ($item) {
$langs = cmsCore::getLanguages();
$items = array();
if ($langs) {
foreach ($langs as $lang) {
$items[$lang] = mb_strtoupper($lang);
}
}
return $items;
})), new fieldCheckbox('is_user_change_lang', array('title' => LANG_CP_SETTINGS_USER_CHANGE_LANG)), new fieldList('default_editor', array('title' => LANG_CP_SETTINGS_EDITOR, 'default' => 'redactor', 'generator' => function ($item) {
$items = array();
$editors = cmsCore::getWysiwygs();
foreach ($editors as $editor) {
$items[$editor] = $editor;
}
return $items;
})), new fieldCheckbox('show_breadcrumbs', array('title' => LANG_CP_SETTINGS_SHOW_BREADCRUMBS, 'default' => 1)), new fieldCheckbox('min_html', array('title' => LANG_CP_SETTINGS_HTML_MINIFY)), new fieldCheckbox('merge_css', array('title' => LANG_CP_SETTINGS_MERGE_CSS, 'hint' => $is_css_cache ? sprintf(LANG_CP_SETTINGS_CACHE_CLEAN_MERGED, href_to('admin', 'clear_cache', 'css')) : false)), new fieldCheckbox('merge_js', array('title' => LANG_CP_SETTINGS_MERGE_JS, 'hint' => $is_js_cache ? sprintf(LANG_CP_SETTINGS_CACHE_CLEAN_MERGED, href_to('admin', 'clear_cache', 'js')) : false)))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_DATE, 'childs' => array(new fieldList('time_zone', array('title' => LANG_CP_SETTINGS_TIMEZONE, 'generator' => function ($item) {
return cmsCore::getTimeZones();
})), new fieldString('date_format', array('title' => LANG_CP_SETTINGS_DATE_FORMAT, 'rules' => array(array('required')))), new fieldString('date_format_js', array('title' => LANG_CP_SETTINGS_DATE_FORMAT_JS, 'rules' => array(array('required')))))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_MAIL, 'childs' => array(new fieldList('mail_transport', array('title' => LANG_CP_SETTINGS_MAIL_TRANSPORT, 'items' => array('mail' => 'PHP mail()', 'smtp' => 'SMTP', 'sendmail' => 'Sendmail'))), new fieldString('mail_from', array('title' => LANG_CP_SETTINGS_MAIL_FROM, 'rules' => array(array('required')))), new fieldString('mail_from_name', array('title' => LANG_CP_SETTINGS_MAIL_FROM_NAME)), new fieldString('mail_smtp_server', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_HOST)), new fieldNumber('mail_smtp_port', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_PORT)), new fieldCheckbox('mail_smtp_auth', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_AUTH)), new fieldString('mail_smtp_user', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_USER)), new fieldString('mail_smtp_pass', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_PASS, 'is_password' => true)), new fieldList('mail_smtp_enc', array('title' => LANG_CP_SETTINGS_MAIL_SMTP_ENC, 'items' => array(0 => LANG_CP_SETTINGS_MAIL_SMTP_ENC_NO, 'ssl' => LANG_CP_SETTINGS_MAIL_SMTP_ENC_SSL, 'tls' => LANG_CP_SETTINGS_MAIL_SMTP_ENC_TLS))))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_CACHE, 'childs' => array(new fieldCheckbox('cache_enabled', array('title' => LANG_CP_SETTINGS_CACHE_ENABLED)), new fieldNumber('cache_ttl', array('title' => LANG_CP_SETTINGS_CACHE_TTL)), new fieldList('cache_method', array('title' => LANG_CP_SETTINGS_CACHE_METHOD, 'hint' => !cmsConfig::get('cache_enabled') ? '' : sprintf(LANG_CP_SETTINGS_CACHE_CLEAN_MERGED, href_to('admin', 'cache_delete', cmsConfig::get('cache_method'))), 'items' => array('files' => 'Files', 'memory' => 'Memcached' . (extension_loaded('memcache') ? '' : ' (' . LANG_CP_SETTINGS_CACHE_METHOD_NO . ')')))), new fieldString('cache_host', array('title' => LANG_CP_SETTINGS_CACHE_HOST)), new fieldNumber('cache_port', array('title' => LANG_CP_SETTINGS_CACHE_PORT)))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_DEBUG, 'childs' => array(new fieldCheckbox('debug', array('title' => LANG_CP_SETTINGS_DEBUG_MODE)), new fieldCheckbox('emulate_lag', array('title' => LANG_CP_SETTINGS_EMULATE_LAG)))), array('type' => 'fieldset', 'title' => LANG_CP_SETTINGS_SECURITY, 'childs' => array(new fieldText('allow_ips', array('title' => LANG_CP_SETTINGS_ALLOW_IPS, 'hint' => sprintf(LANG_CP_SETTINGS_ALLOW_IPS_HINT, cmsUser::getIp()))))));
}