Esempio n. 1
0
 function index()
 {
     $this->load->helper('gfx');
     if (!checkAuth(false, false, 'flashdata')) {
         header('Location: ' . base_url());
         return;
     }
     $user = $this->db->query('SELECT * FROM users WHERE `id` = ' . $this->session->userdata('id') . ' LIMIT 1');
     if ($user->num_rows() === 0) {
         //Rare cases where session exists but got deleted.
         session_data_unset(false);
         flashdata_message('no_such_user');
         header('Location: ' . base_url());
         return;
     }
     $U = $user->row_array();
     $user->free_result();
     $F = array();
     for ($i = 0; $i < 3; $i++) {
         $feature = $this->db->query('SELECT name, title, description FROM features ' . 'WHERE `id` = ' . $U['feature_' . $i] . ';');
         $F[] = $feature->row_array();
         $feature->free_result();
     }
     unset($feature);
     if ($U['ready'] !== 'Y') {
         flashdata_message('sticker_nopage');
         header('Location: ' . site_url('editor'));
         return;
     }
     $data = array('meta' => $this->load->view('sticker/meta.php', $U, true), 'content' => $this->load->view('sticker/content.php', array_merge($U, array('features' => $F)), true), 'db' => 'content ');
     $this->load->library('parser');
     $this->parser->page($data, $this->session->userdata('id'), $U);
 }
Esempio n. 2
0
 function delete()
 {
     $this->load->config('gfx');
     $this->load->helper('gfx');
     if (!checkAuth(true, true, 'flashdata')) {
         header('Location: ' . site_url('about'));
         return;
     }
     $this->load->database();
     $this->db->delete('aboutpages', array('id' => $this->input->post('id')));
     flashdata_message('about_deleted', 'highlight', 'info');
     header('Location: ' . site_url('about'));
 }
Esempio n. 3
0
 function forgetopenid()
 {
     $this->load->helper('gfx');
     //Due to privicy consideration, we will not show any onscreen message indicate email has been send or not.
     //Therefore all the flashdata message will be the same from this point on.
     $this->load->helper('email');
     if (!valid_email($this->input->post('email'))) {
         flashdata_message('openid_query_processed', 'highlight', 'info');
         header('Location: ' . site_url('about/faq'));
         return;
     }
     $this->load->database();
     $acs = $this->db->query('SELECT `login`, `name` FROM `users` WHERE `email` = ' . $this->db->escape($this->input->post('email')) . ';');
     if ($acs->num_rows() !== 0) {
         $this->load->library('email');
         $this->email->initialize(array('mailtype' => 'html'));
         $this->load->config('gfx');
         $this->email->from($this->config->item('gfx_mail_from_add'), $this->config->item('gfx_mail_from_name'));
         $this->email->to($this->input->post('email'));
         $this->email->subject($this->lang->line('gfx_email_subject_forgetopenid'));
         $data = array('ip' => $_SERVER['REMOTE_ADDR'] === '192.168.255.254' ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'], 'logins' => array());
         foreach ($acs->result_array() as $U) {
             if (substr($U['name'], 0, 8) === '__temp__') {
                 unset($U['name']);
             }
             $data['logins'][] = $U;
         }
         $this->email->message($this->load->view('forgetopenid.php', $data, true));
         $this->email->send();
         //echo $this->email->print_debugger();
     }
     flashdata_message('openid_query_processed', 'highlight', 'info');
     header('Location: ' . site_url('about/faq'));
 }
Esempio n. 4
0
function session_data_unset($msg = true)
{
    $CI =& get_instance();
    $CI->session->unset_userdata(array('id' => '', 'admin' => '', 'name' => '', 'hide_announcement' => ''));
    if ($msg) {
        flashdata_message('auth_logout', 'highlight', 'info');
    }
}
Esempio n. 5
0
 function index()
 {
     $this->load->helper('gfx');
     if (!checkAuth(false, false, 'flashdata')) {
         header('Location: ' . base_url());
         return;
     }
     $this->load->helper('form');
     $user = $this->db->query('SELECT * FROM users WHERE `id` = ' . $this->session->userdata('id') . ' LIMIT 1');
     if ($user->num_rows() === 0) {
         //Rare cases where session exists but user got deleted.
         session_data_unset(false);
         flashdata_message('no_such_user');
         header('Location: ' . base_url());
         return;
     }
     $U = $user->row_array();
     $user->free_result();
     unset($user);
     if (substr($U['name'], 0, 8) === '__temp__') {
         $U['name'] = '';
     }
     $allfeatures = $this->db->query('SELECT `id`, `name`, `title`, `description` FROM `features` ORDER BY `order` ASC;');
     $F = array();
     foreach ($allfeatures->result_array() as $feature) {
         for ($i = 0; $i < 3; $i++) {
             if ($feature['id'] === $U['feature_' . $i]) {
                 $feature['user_order'] = $i;
             }
         }
         $F[] = $feature;
     }
     $allfeatures->free_result();
     unset($allfeatures, $feature);
     $addons = $this->db->query('SELECT t1.*, t2.group_id FROM addons t1, u2a t2 ' . 'WHERE t2.addon_id = t1.id AND t2.user_id = ' . $U['id'] . ' ORDER BY t2.order ASC;');
     $A = array();
     foreach ($addons->result_array() as $addon) {
         if (!isset($A[$addon['group_id']])) {
             $A[$addon['group_id']] = array();
         }
         //$A[$addon['group_id']][] = $addon;
         $A[1][] = $addon;
     }
     unset($addons, $addon);
     $groups = $this->db->query('SELECT t1.id, t1.name, t1.title, t1.description FROM groups t1 WHERE t1.id = 1;');
     /*
     $groups = $this->db->query(
     	'SELECT t1.id, t1.name, t1.title, t1.description, G.user_id, G.order FROM groups t1 '
     	. 'LEFT OUTER JOIN '
     	. '( SELECT S.id, K.user_id, K.order FROM groups AS S, u2g AS K ' 
     	. 'WHERE S.id = K.group_id AND K.user_id = ' . $this->session->userdata('id') . ') AS G '
     	. 'ON t1.id = G.id ORDER BY G.user_id DESC, G.order ASC, t1.order ASC;');
     */
     $G = array();
     foreach ($groups->result_array() as $group) {
         $group['user_id'] = $this->session->userdata('id');
         $G[] = $group;
         if (!isset($A[$group['id']])) {
             $A[$group['id']] = array();
         }
     }
     unset($groups, $group);
     $data = array('meta' => $this->load->view('editor/meta.php', $U, true), 'content' => $this->load->view('editor/content.php', array_merge($U, array('allfeatures' => $F, 'allgroups' => $G, 'addons' => $A)), true), 'script' => '	<script type="text/javascript" src="./js/page.editor.js' . $this->config->item('gfx_suffix') . '" charset="UTF-8"></script>', 'db' => 'content ');
     if ($this->session->userdata('admin') === 'Y') {
         $this->load->_ci_cached_vars = array();
         $data['admin'] = $this->load->view('editor/admin.php', $U, true);
     }
     $this->load->library('parser');
     $this->parser->page($data, $this->session->userdata('id'), $U);
 }
Esempio n. 6
0
 function delete()
 {
     $this->load->helper('gfx');
     if (checkAuth(true, true, '')) {
         /* is an admin */
         $id = $this->db->escape($this->input->post('id'));
     } elseif (checkAuth(true, false, 'flashdata')) {
         /* is a user */
         $id = $this->session->userdata('id');
     } else {
         /* is not logged in; flashdata error already injected at last elseif */
         header('Location: ' . base_url());
         return;
     }
     /* Check whether user exists and his/her name */
     $this->load->database();
     $data = $this->db->query('SELECT `name` FROM `users` WHERE `id` = ' . $id . ';');
     if ($data->num_rows() === 0) {
         flashdata_message('no_such_user');
         header('Location: ' . base_url());
         return;
     }
     /* Actual Deletion */
     $this->db->delete('users', array('id' => $id));
     $this->db->delete('u2a', array('id' => $id));
     $this->db->delete('u2g', array('id' => $id));
     $this->load->library('cache');
     $this->cache->remove(strtolower($data->row()->name), 'user');
     $this->cache->remove($id, 'header');
     $d = './userstickers/' . dechex(intval($id) >> 12) . '/' . dechex(intval($id) & pow(2, 12) - 1) . '/';
     if (file_exists($d) && is_dir($d)) {
         foreach (scandir($d) as $filename) {
             if (in_array($filename, array('.', '..'))) {
                 continue;
             }
             unlink($d . $filename);
         }
     }
     /* Logout user if its the same id */
     if ($this->session->userdata('id') === $id) {
         $this->session->unset_userdata('id');
         $this->session->unset_userdata('name');
         $this->session->unset_userdata('admin');
     }
     flashdata_message('user_deleted', 'highlight', 'info');
     header('Location: ' . base_url());
 }