Example #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);
 }
Example #2
0
 function logout()
 {
     $this->load->config('gfx');
     $this->load->helper('gfx');
     if (!checkAuth(true, false, 'flashdata')) {
         header('Location: ' . base_url());
         return;
     }
     session_data_unset();
     header('Location: ' . base_url());
 }
Example #3
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);
 }