本文整理汇总了PHP中need_login函数的典型用法代码示例。如果您正苦于以下问题:PHP need_login函数的具体用法?PHP need_login怎么用?PHP need_login使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了need_login函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_profile
function save_profile()
{
need_login('ajax');
$current_id = $this->user->get_field('id');
$arr['user_nicename'] = safe_convert($this->getPost('user_nicename'));
$new_pass = $this->getPost('new_pass');
$old_pass = $this->getPost('old_pass');
$new_pass_again = $this->getPost('new_pass_again');
$extra_arr = $this->getPost('extra');
if ($extra_arr['email'] && !check_email($extra_arr['email'])) {
form_ajax_failed('text', lang('error_email'));
}
if ($new_pass) {
if (!$this->user->check_pass($current_id, md5($old_pass))) {
form_ajax_failed('text', lang('old_pass_error'));
}
if ($new_pass != $new_pass_again) {
form_ajax_failed('text', lang('pass_twice_error'));
}
$arr['user_pass'] = md5($new_pass);
}
if ($this->user->update($current_id, $arr)) {
$this->user->save_extra($current_id, $extra_arr);
form_ajax_success('box', lang('modify_success') . ($new_pass ? lang('pass_edit_ok') : ''), null, 0.5, $_SERVER['HTTP_REFERER']);
} else {
form_ajax_failed('text', lang('modify_failed'));
}
}
示例2: copyselectedurl
function copyselectedurl($config = array())
{
need_login('ajax_page');
global $base_root;
$ids = $this->getPost('sel_id');
if (!$ids || count($ids) == 0) {
ajax_box(lang('copyimg:pls_sel_photo_want_to_copy'));
} else {
$site_url = $this->setting->get_conf('site.url');
$mdl_photo =& loader::model('photo');
$ids = array_keys($ids);
$html = '';
$urls = '';
$ubb = '';
foreach ($ids as $id) {
$pic = $mdl_photo->get_info($id);
$img_path = img_path($pic['path']);
$html_code = $config['tpl'];
$html_code = str_replace('{thumbpath}', img_path($pic['thumb']), $html_code);
$html_code = str_replace('{imgpath}', $img_path, $html_code);
$html_code = str_replace('{imgname}', $pic['name'], $html_code);
$html_code = str_replace('{detailurl}', $base_root . site_link('photos', 'view', array('id' => $pic['id'])), $html_code);
$html .= $html_code . $config['split'];
$urls .= $img_path . "\r\n";
$ubb .= '[IMG]' . $img_path . "[/IMG]\r\n";
}
$this->output->set('img_url', $urls);
$this->output->set('img_html', $html);
$this->output->set('img_ubb', $ubb);
loader::view('copyimg:copyurlall');
}
}
示例3: __construct
public function __construct()
{
parent::__construct();
$this->load->library('htmllib');
$this->load->model('game');
$this->load->model('level');
// Your own constructor code
if (need_login() == false) {
redirect(base_url() . "base/login");
}
}
示例4: create_session
public function create_session()
{
if (need_login()) {
redirect(base_url() . "base/logout");
}
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run()) {
$this->load->model("user");
$user = $this->user->auth($this->input->post("username"), $this->input->post("password"));
if (count($user) > 0) {
$this->session->set_userdata("user_id", $user->id);
$this->session->set_userdata("user_name", $user->username);
redirect(base_url() . "intro");
} else {
$this->session->set_flashdata("alert", "Username dan password tidak cocok");
redirect(base_url() . "base/login");
}
} else {
$this->session->set_flashdata("alert", validation_errors());
redirect(base_url() . "base/login");
}
}
示例5: require_once
<?php
require_once (dirname ( dirname ( __FILE__ ) ) . '/app.php');
need_login ();
$condition = array (
'user_id' => $login_user_id,
'team_id > 0'
);
$selector = strval ( $_GET ['s'] );
$allow = array (
'index',
'unpay',
'pay',
'askrefund',
/* BEGIN add status by abei */
'unused',
'expiring',
'undp',
'refundsuccess',
'expired',
'had_dp'
/* END add status by abei */
);
if (false == in_array ( $selector, $allow )){
$selector = 'index';
}
if ($selector == 'index') {
$count = Table::Count ( 'order', $condition );
示例6: require_once
<?php
/**
* My
* ----------------------------------------------------------------------------
* This is not free software
* ----------------------------------------------------------------------------
* @author abei <abei@qiang8.cn>
* @version 1.0
* @link http://www.qiang8.cn
*/
require_once(dirname(dirname(__FILE__)) . '/app.php');
need_login(true);
$consume_times = Table::Count('order', array(
'user_id' => $login_user_id,
'state' => 'pay',
));
die(include template('m_my'));
示例7: emptying
function emptying()
{
need_login('ajax_page');
$albums = $this->mdl_album->get_trash();
if ($albums) {
foreach ($albums as $v) {
$ret = $this->mdl_album->real_delete($v['id'], $v);
}
}
$photos = $this->mdl_photo->get_trash();
if ($photos) {
foreach ($photos as $v) {
$ret = $this->mdl_photo->real_delete($v['id'], $v);
}
}
ajax_box(lang('empty_trash_success'), null, 0.5, $_SERVER['HTTP_REFERER']);
}
示例8: delete
function delete()
{
need_login('ajax_page');
$id = intval($this->getGet('id'));
if ($this->mdl_cate->delete($id)) {
$mdl_album =& Loader::model('album');
$mdl_album->set_default_cate($id);
ajax_box(lang('delete_cate_succ'), null, 0.5, $_SERVER['HTTP_REFERER']);
} else {
ajax_box(lang('delete_cate_fail'));
}
}
示例9: save_priv
function save_priv()
{
need_login('ajax');
$album['priv_type'] = $this->getPost('priv_type', '0');
$album['priv_pass'] = $this->getPost('priv_pass');
$album['priv_question'] = safe_convert($this->getPost('priv_question'));
$album['priv_answer'] = safe_convert($this->getPost('priv_answer'));
$id = intval($this->getGet('id'));
if ($album['priv_type'] == '1') {
if ($album['priv_pass'] == '') {
form_ajax_failed('text', lang('album_password_empty'));
}
}
if ($album['priv_type'] == '2') {
if ($album['priv_question'] == '') {
form_ajax_failed('text', lang('album_question_empty'));
}
if ($album['priv_answer'] == '') {
form_ajax_failed('text', lang('album_answer_empty'));
}
}
if ($this->mdl_album->update($id, $album)) {
$this->plugin->trigger('modified_album_priv', $id);
form_ajax_success('box', lang('modify_album_priv_success'), null, 0.5, $_SERVER['HTTP_REFERER']);
} else {
form_ajax_failed('text', lang('modify_album_priv_failed'));
}
}
示例10: approve_batch
function approve_batch()
{
need_login('ajax_page');
$ids = $this->getPost('sel_id');
if (!$ids || count($ids) == 0) {
ajax_box(lang('pls_sel_comments_want_to_approve'));
} else {
if ($this->mdl_comment->approve_batch(array_keys($ids))) {
ajax_box(lang('batch_approve_comments_success'), null, 1, $_SERVER['HTTP_REFERER']);
} else {
ajax_box(lang('batch_approve_comments_failed'));
}
}
}
示例11: remove_related_org_from_user
public function remove_related_org_from_user($user_id, $related_org_name)
{
need_login();
if (!user('is_admin')) {
$user_id = user('id');
}
$related_ngo_model = M('Related_ngos');
$related_ngo_model->where(array('user_name' => $related_org_name, 'user_id' => $user_id))->delete();
echo json_encode(array('status' => 'ok'));
}
示例12: save_nav
function save_nav()
{
need_login('ajax_box');
$mdl_nav =& Loader::model('nav');
$names = $this->getPost('name');
$urls = $this->getPost('url');
$sorts = $this->getPost('sort');
$dels = $this->getPost('del');
$enables = $this->getPost('enable');
$flag = true;
//编辑及删除
if ($names) {
foreach ($names as $key => $name) {
$key = intval($key);
$name = trim($name);
$urls[$key] = isset($urls[$key]) ? trim($urls[$key]) : '';
if (isset($dels[$key])) {
//delete 记录
$mdl_nav->delete($key);
} else {
$data = array();
if ($name) {
$data['name'] = $name;
}
if ($urls[$key]) {
$data['url'] = $urls[$key];
}
if ($sorts[$key]) {
$data['sort'] = intval($sorts[$key]);
}
if (isset($enables[$key])) {
$data['enable'] = 1;
} else {
$data['enable'] = 0;
}
if (!$mdl_nav->update($key, $data)) {
$flag = false;
}
}
}
}
//新增
$newnames = $this->getPost('namenew');
$newurls = $this->getPost('urlnew');
$newsorts = $this->getPost('sortnew');
if ($newnames) {
foreach ($newnames as $key => $newname) {
$newname = trim($newname);
$newurls[$key] = trim($newurls[$key]);
if ($newname == '') {
continue;
}
if ($newurls[$key] == '') {
$flag = false;
continue;
}
$data = array('name' => $newname, 'url' => $newurls[$key], 'sort' => $newsorts[$key] ? intval($newsorts[$key]) : 100, 'enable' => 1);
if (!$mdl_nav->save($data)) {
$flag = false;
}
}
}
//清除菜单缓存
$mdl_nav->clear_nav_cache();
if ($flag) {
form_ajax_success('box', lang('nav_save_succ'), null, 0.5, $_SERVER['HTTP_REFERER']);
} else {
form_ajax_failed('box', lang('nav_save_fail'), null, 2, $_SERVER['HTTP_REFERER']);
}
}
示例13: core
function core()
{
need_login('page');
@set_time_limit(0);
@ignore_user_abort(true);
$newversion = $this->getRequest('version');
$software = 'meiupic';
$version = MPIC_VERSION;
if ($newversion == $version) {
exit(lang('no_need_to_update'));
}
if (!$newversion) {
exit(lang('version_can_not_be_empty'));
}
//检查目录是否可以读写
$directory = @dir(ROOTDIR);
while ($entry = $directory->read()) {
if ($entry == '..' || $entry == '.') {
continue;
}
$filename = ROOTDIR . $entry;
if (is_dir($filename) && !dir_writeable($filename)) {
exit(lang('dir_not_writable', $filename));
} elseif (is_file($filename) && !is_writable($filename)) {
exit(lang('file_not_writable', $filename));
}
}
$directory->close();
$langset = LANGSET;
$time = time();
$hash = md5("{$newversion}{$software}{$version}{$langset}{$time}");
$q = base64_encode("newversion={$newversion}&software={$software}&version={$version}&langset={$langset}&time={$time}&hash={$hash}");
$url = CHECK_UPDATE_URL . '?act=update&q=' . $q;
$response = get_remote($url, 2);
if (!$response) {
exit(lang('connect_to_server_failed'));
}
$json =& loader::lib('json');
$result = $json->decode($response);
if ($result['return']) {
$tmpfile = ROOTDIR . 'cache/tmp/update.zip';
if (file_exists($tmpfile) && md5_file($tmpfile) == $result['md5']) {
echo lang('file_has_been_downloaded') . '<br />';
} else {
$content = get_remote($result['package']);
file_put_contents($tmpfile, $content);
$file_md5 = md5_file($tmpfile);
if ($file_md5 != $result['md5']) {
echo lang('download_package_failed') . '<br />';
exit;
}
echo lang('download_package_succ') . '<br />';
}
$zip =& loader::lib('zip');
$zip->load_file($tmpfile);
$zip->extract(PCLZIP_OPT_PATH, './', PCLZIP_OPT_REPLACE_NEWER);
echo lang('unzip_package_succ') . '<br />';
echo lang('delete_tmp_download_file') . '<br />';
@unlink($tmpfile);
echo lang('upgrade_after_jump') . '<br />';
redirect(site_link('default'), 1);
} else {
exit(lang('get_update_fail'));
}
}
示例14: save_desc
function save_desc()
{
need_login('ajax');
$id = intval($this->getGet('id'));
$desc = safe_convert($this->getPost('desc'));
if ($desc == '') {
form_ajax_failed('text', lang('empty_photo_desc'));
}
if ($this->mdl_photo->update($id, array('desc' => $desc))) {
$this->plugin->trigger('modified_photo_desc', $id);
form_ajax_success('text', $desc);
} else {
form_ajax_failed('text', lang('modify_photo_desc_failed'));
}
return;
}
示例15: base_url
?>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<input type="hidden" id="base_url" value="<?php
echo base_url();
?>
">
<?php
if (need_login()) {
?>
<div class="row">
<div class="col s12 grey darken-4">
<a href="<?php
echo base_url();
?>
"><h5 class="white-text" style="float:left">Naval - Intuition<i class="material-icons left">play_circle_outline</i></h5></a>
<a href="<?php
echo base_url();
?>
base/logout" class="white-text" style="float:right"><h5>Logout<i class="material-icons left">not_interested</i></h5></a>
</div>
</div>
<?php
}