public function auth() { if ($this->input->method() != 'post') { show_404(); } $email = $this->input->post('email'); $password = $this->input->post('password'); $auth = $this->user->login($email, sha1($password)); if (!empty($auth)) { $this->session->set_flashdata('login_success', true); $this->session->set_userdata('admin_logged_in', true); $this->session->set_userdata('auth', $auth); gotoUrl('/admin'); } $this->session->set_flashdata('login_fail', true); gotoUrl('/admin/login'); }
public function listusers() { if (!isset($_SESSION[APP_SES . 'id']) || $_SESSION[APP_SES . 'id'] == 0) { gotoUrl('/?route=/users/users'); exit; } $this->loadModel(SLASH . 'users' . SLASH . 'user'); $user = new User(); $data['list_of_users'] = $user->get_users(); $this->setTitle('Users'); $this->loadView(SLASH . 'users' . SLASH . 'display_users', TRUE, $data); }
public function store() { if ($this->input->method() != 'post') { show_404(); } $data = $this->input->post(); $imageName = uniqid('gume_'); $tmpImgName = $_FILES['thumb']['name']; $data['thumb'] = $imageName . substr($tmpImgName, stripos($tmpImgName, '.')); $newBlogId = $this->blog->createBlog($data); /* upload image */ $imagePath = 'resources/img/blogs/' . $newBlogId; if (!is_dir($imagePath)) { mkdir($imagePath, 0777); } $config['upload_path'] = $imagePath . '/'; $config['file_name'] = $imageName . substr($tmpImgName, stripos($tmpImgName, '.')); $config['allowed_types'] = '*'; $config['max_size'] = 10240; $this->load->library('upload', $config); if ($this->upload->do_upload('thumb')) { $image = $this->upload->data(); /* make image thumb */ $config['image_library'] = 'gd2'; $config['source_image'] = $imagePath . '/' . $image['file_name']; $config['create_thumb'] = TRUE; $config['maintain_ratio'] = TRUE; $config['width'] = 400; $this->load->library('image_lib', $config); $this->image_lib->resize(); } $this->session->set_flashdata('create_blog_success', true); gotoUrl('/admin/blog'); }
function refreshTo($nextAction, $nextStep = '') { global $step, $action, $nextId, $limit, $token, $transfers, $seprator; if (($nextStep != $step || $nextAction != $action) && $transfers < $limit) { if ('init' == $step && 'convert' == $nextStep || 'convert' == $step && 'finish' == $nextStep && $seprator == 1 || 'convert' == $step && $seprator == 1 && in_array($nextAction, $GLOBALS['gotoActions'])) { gotoUrl($nextAction, $nextStep, 'init' == $step && 'convert' == $nextStep ? true : false); } if ($nextStep) { $url = $_SERVER['SCRIPT_NAME'] . "?step={$nextStep}&token={$token}&action={$nextAction}&seprator={$seprator}"; } else { //本步数据已处理完 $url = $_SERVER['SCRIPT_NAME'] . "?step={$step}&action={$nextAction}&token={$token}&seprator={$seprator}"; } } else { $url = $_SERVER['SCRIPT_NAME'] . "?step={$step}&action={$action}&lastid={$nextId}&token={$token}&seprator={$seprator}"; } showMessage($url); }
public function get() { $id = intval($_GET['id']); $this->loadModel('schnippet'); $schnippet = new Schnippet(); $schnippet->load($id); if ($schnippet->getMember('protected') == 'on' && (!isset($_SESSION[APP_SES . 'id']) || $_SESSION[APP_SES . 'id'] == 0)) { $_SESSION[APP_SES . 'route'] = '/application/schnippets&m=edit&id=' . $_GET['id']; gotoUrl('/?route=/users/users'); exit; } $this->loadModel(SLASH . 'users' . SLASH . 'user'); $data['user'] = new User(); $data['schnippet'] = $schnippet->getMembers(); $this->setTitle($schnippet->getMember('title')); $this->loadView(SLASH . 'application' . SLASH . 'get', TRUE, $data); }