예제 #1
0
 public function index()
 {
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => 'confirmDelete();'));
     if ($this->input->post('delete') and $this->_deleteTemplate() === TRUE) {
         redirect('mail_templates');
     }
     $results = $this->Mail_templates_model->getList();
     $data['templates'] = array();
     foreach ($results as $result) {
         if ($result['template_id'] !== $this->config->item('mail_template_id')) {
             $default = site_url('mail_templates?default=1&template_id=' . $result['template_id']);
         } else {
             $default = '1';
         }
         $data['templates'][] = array('template_id' => $result['template_id'], 'name' => $result['name'], 'date_added' => mdate('%d %M %y - %H:%i', strtotime($result['date_added'])), 'date_updated' => mdate('%d %M %y - %H:%i', strtotime($result['date_updated'])), 'status' => $result['status'] === '1' ? $this->lang->line('text_enabled') : $this->lang->line('text_disabled'), 'default' => $default, 'edit' => site_url('mail_templates/edit?id=' . $result['template_id']));
     }
     if ($this->input->get('default') === '1' and $this->input->get('template_id')) {
         $template_id = $this->input->get('template_id');
         if ($this->Settings_model->addSetting('prefs', 'mail_template_id', $template_id, '0')) {
             $this->alert->set('success', $this->lang->line('alert_set_default'));
         }
         redirect('mail_templates');
     }
     $this->template->render('mail_templates', $data);
 }
예제 #2
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'category_id';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'ASC';
         $data['order_by_active'] = 'ASC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('categories' . $url . 'sort_by=name&order_by=' . $order_by);
     $data['sort_priority'] = site_url('categories' . $url . 'sort_by=priority&order_by=' . $order_by);
     $data['sort_id'] = site_url('categories' . $url . 'sort_by=category_id&order_by=' . $order_by);
     $results = $this->Categories_model->getList($filter);
     $data['categories'] = array();
     foreach ($results as $result) {
         //load categories data into array
         $data['categories'][] = array('category_id' => $result['category_id'], 'name' => $result['name'], 'parent_id' => $result['parent_id'], 'priority' => $result['priority'], 'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..', 'edit' => site_url('categories/edit?id=' . $result['category_id']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('categories' . $url);
     $config['total_rows'] = $this->Categories_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteCategory() === TRUE) {
         redirect('categories');
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('categories', $data);
 }
예제 #3
0
파일: log.php 프로젝트: eappl/prototype
 function onlogView($msg = '', $ty = '')
 {
     $action = "index.php?admin_log/logView";
     $hasLogViewPrivilege = $_ENV['menu']->checkPermission($this->ask_login_name, $_SERVER['QUERY_STRING'], "logView");
     $hasLogViewPrivilege['url'] = "?admin_main";
     $hasLogViewPrivilege['return'] = true;
     !$hasLogViewPrivilege['return'] && __msg($hasLogViewPrivilege);
     $LogTypeList = $this->ask_config->getLogType();
     $operator_list = $_ENV['operator']->getList(0, 0);
     $ConditionList['StartDate'] = isset($this->post['StartDate']) ? $this->post['StartDate'] : (isset($this->get[2]) ? $this->get[2] : date("Y-m-d", time()));
     $ConditionList['EndDate'] = isset($this->post['EndDate']) ? $this->post['EndDate'] : (isset($this->get[3]) ? $this->get[3] : date("Y-m-d", time()));
     $ConditionList['EndDate'] = min($ConditionList['EndDate'], date("Y-m-d", time()), date("Y-m-t", strtotime($ConditionList['StartDate'])));
     $ConditionList['operatorId'] = isset($this->post['operatorId']) ? intval(urldecode($this->post['operatorId'])) : (isset($this->get[4]) ? intval(urldecode($this->get[4])) : 0);
     $ConditionList['operator'] = !in_array($ConditionList['operatorId'], array(-2, -1, 0)) ? $operator_list[$ConditionList['operatorId']]['login_name'] : $ConditionList['operatorId'];
     $ConditionList['QuestionId'] = isset($this->post['QuestionId']) ? intval($this->post['QuestionId']) : (isset($this->get[5]) ? intval($this->get[5]) : 0);
     $ConditionList['log_type_id'] = isset($this->post['log_type_id']) ? intval(urldecode($this->post['log_type_id'])) : (isset($this->get[6]) ? intval(urldecode($this->get[6])) : 0);
     $ConditionList['AuthorName'] = isset($this->post['AuthorName']) ? trim(urldecode($this->post['AuthorName'])) : (isset($this->get[7]) ? trim(urldecode($this->get[7])) : '');
     $ConditionList['log_type'] = $ConditionList['log_type_id'] ? $LogTypeList[$ConditionList['log_type_id']] : $ConditionList['log_type_id'];
     @($page = max(1, intval($this->get[8])));
     $export = trim($this->get[9]) == "export" ? 1 : 0;
     $setting = $this->setting;
     if (!$export) {
         $pagesize = $this->setting['list_default'];
         $pagesize = 20;
         $log_list = $_ENV['log']->getLogList($ConditionList, $page, $pagesize);
         $departstr = page($log_list['LogCount'], $pagesize, $page, "admin_log/logView/" . $ConditionList['StartDate'] . "/" . $ConditionList['EndDate'] . "/" . urlencode($ConditionList['operatorId']) . "/" . $ConditionList['QuestionId'] . "/" . $ConditionList['log_type_id'] . "/" . urlencode($ConditionList['AuthorName']));
         $downloadstr = page_url("<下载EXCEL表格>", "admin_log/logView/" . $ConditionList['StartDate'] . "/" . $ConditionList['EndDate'] . "/" . urlencode($ConditionList['operatorId']) . "/" . $ConditionList['QuestionId'] . "/" . $ConditionList['log_type_id'] . "/" . urlencode($ConditionList['AuthorName']) . "/" . $page . "/export");
         $msg && ($message = $msg);
         $ty && ($type = $ty);
     } else {
         set_time_limit(0);
         $page = 1;
         $pagesize = 1000;
         $num = 1;
         require TIPASK_ROOT . '/lib/Excel.php';
         $oExcel = new Excel();
         $FileName = '操作日志表';
         $oExcel->download($FileName)->addSheet('日志表');
         //标题栏
         $title = array("日志ID", "对应问题ID", "用户名", "操作人", "操作时间", "日志内容");
         $oExcel->addRows(array($title));
         while ($num > 0) {
             $log_list = $_ENV['log']->getLogList($ConditionList, $page, $pagesize);
             foreach ($log_list['LogList'] as $key => $value) {
                 $value['message'] = htmlspecialchars_decode($value['message']);
                 $log_list['LogList'][$key]['message'] = preg_replace("/<(.*?)>/", "", $value['message']);
                 $excelArr = array("id" => $log_list['LogList'][$key]['id'], "qid" => $log_list['LogList'][$key]['qid'], "AuthorName" => $log_list['LogList'][$key]['AuthorName'], "user" => $log_list['LogList'][$key]['user'], "time" => date("Y-m-d H:i:s", $log_list['LogList'][$key]['time']), "message" => $log_list['LogList'][$key]['message']);
                 $oExcel->addRows(array($excelArr));
             }
             $page++;
             $num = count($order_list['OrderList']);
         }
         $oExcel->closeSheet()->close();
     }
     include template('logview', 'admin');
 }
예제 #4
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_type')) {
         $filter['filter_type'] = $data['filter_type'] = $this->input->get('filter_type');
         $url .= 'filter_type=' . $filter['filter_type'] . '&';
     } else {
         $filter['filter_type'] = '';
         $data['filter_type'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'status_for';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'ASC';
         $data['order_by_active'] = '';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_id'] = site_url('statuses' . $url . 'sort_by=status_id&order_by=' . $order_by);
     $data['sort_name'] = site_url('statuses' . $url . 'sort_by=status_name&order_by=' . $order_by);
     $data['sort_type'] = site_url('statuses' . $url . 'sort_by=status_for&order_by=' . $order_by);
     $data['sort_notify'] = site_url('statuses' . $url . 'sort_by=notify_customer&order_by=' . $order_by);
     $data['statuses'] = array();
     $results = $this->Statuses_model->getList($filter);
     foreach ($results as $result) {
         $data['statuses'][] = array('status_id' => $result['status_id'], 'status_name' => $result['status_name'], 'status_comment' => $result['status_comment'], 'status_for' => $result['status_for'] === 'reserve' ? 'Reservations' : ucwords($result['status_for']), 'notify_customer' => $result['notify_customer'] === '1' ? 'Yes' : 'No', 'edit' => site_url('statuses/edit?id=' . $result['status_id']));
     }
     $config['base_url'] = site_url('statuses' . $url);
     $config['total_rows'] = $this->Statuses_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteStatus() === TRUE) {
         redirect('statuses');
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('statuses', $data);
 }
 function action_url($class, $method, $current_url = TRUE)
 {
     $EE =& get_instance();
     $EE->db->where(array('class' => $class, 'method' => $method));
     $action = $EE->db->get('actions')->row();
     $action_id = isset($action->action_id) ? $action->action_id : NULL;
     if ($current_url) {
         $url = page_url(TRUE, FALSE);
     } else {
         $url = base_page(TRUE);
     }
     return $url . '?ACT=' . $action_id;
 }
예제 #6
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'customer_group_id';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = '';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_id'] = site_url('customer_groups' . $url . 'sort_by=customer_group_id&order_by=' . $order_by);
     $data['customer_group_id'] = $this->config->item('customer_group_id');
     $data['customer_groups'] = array();
     $results = $this->Customer_groups_model->getList($filter);
     foreach ($results as $result) {
         $data['customer_groups'][] = array('customer_group_id' => $result['customer_group_id'], 'group_name' => $result['group_name'], 'edit' => site_url('customer_groups/edit?id=' . $result['customer_group_id']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('customer_groups' . $url);
     $config['total_rows'] = $this->Customer_groups_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteCustomerGroup() === TRUE) {
         redirect('customer_groups');
     }
     $this->template->render('customer_groups', $data);
 }
예제 #7
0
 public function index()
 {
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $this->template->setButton($this->lang->line('button_modules'), array('class' => 'btn btn-default', 'href' => site_url('extensions')));
     $data['banners'] = array();
     $results = $this->Banners_model->getBanners();
     foreach ($results as $result) {
         $data['banners'][] = array('banner_id' => $result['banner_id'], 'name' => $result['name'], 'type' => $result['type'], 'status' => $result['status'] === '1' ? $this->lang->line('text_enabled') : $this->lang->line('text_disabled'), 'edit' => site_url('banners/edit?id=' . $result['banner_id']));
     }
     if ($this->input->post('delete') and $this->_deleteBanner() === TRUE) {
         redirect('banners');
     }
     $this->template->render('banners', $data);
 }
예제 #8
0
 public function index()
 {
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/add'));
     $data['payments'] = array();
     $results = $this->Extensions_model->getList(array('type' => 'payment'));
     foreach ($results as $result) {
         if ($result['installed'] === TRUE) {
             $manage = 'uninstall';
         } else {
             $manage = 'install';
         }
         $data['payments'][] = array('extension_id' => $result['extension_id'], 'name' => $result['title'], 'installed' => $result['installed'], 'type' => $result['type'], 'options' => $result['options'], 'edit' => site_url('payments/edit?action=edit&name=' . $result['name'] . '&id=' . $result['extension_id']), 'manage' => site_url('payments/edit?action=' . $manage . '&name=' . $result['name'] . '&id=' . $result['extension_id']));
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('payments', $data);
 }
예제 #9
0
 public function index()
 {
     $this->user->restrict('Site.Themes.Access');
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/add'));
     $data['themes'] = array();
     $themes = $this->Themes_model->getList();
     foreach ($themes as $theme) {
         if ($theme['name'] === trim($this->config->item(MAINDIR, 'default_themes'), '/')) {
             $active = '1';
         } else {
             $active = FALSE;
         }
         $data['themes'][] = array('name' => $theme['name'], 'title' => $theme['title'], 'version' => $theme['version'], 'description' => $theme['description'], 'author' => $theme['author'], 'active' => $active, 'screenshot' => $theme['screenshot'], 'activate' => site_url('themes/activate/' . $theme['name']), 'edit' => site_url('themes/edit/' . $theme['name']), 'delete' => site_url('themes/delete/' . $theme['name']));
     }
     $this->template->render('themes', $data);
 }
예제 #10
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $data['pages'] = array();
     $results = $this->Pages_model->getList($filter);
     foreach ($results as $result) {
         $data['pages'][] = array('page_id' => $result['page_id'], 'name' => $result['name'], 'language' => $result['language_name'], 'date_updated' => mdate('%d %M %y - %H:%i', strtotime($result['date_updated'])), 'status' => $result['status'] === '1' ? 'Enabled' : 'Disabled', 'preview' => root_url('pages?page_id=' . $result['page_id']), 'edit' => site_url('pages/edit?id=' . $result['page_id']));
     }
     $config['base_url'] = site_url('pages' . $url);
     $config['total_rows'] = $this->Pages_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deletePage() === TRUE) {
         redirect('pages');
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('pages', $data);
 }
예제 #11
0
 function onbroadcast($msg = '', $ty = '')
 {
     $action = "?admin_broadcast/broadcast";
     $hasIntoBroadcastPrivilege = $_ENV['menu']->checkPermission($this->ask_login_name, $_SERVER['QUERY_STRING'], "intoBroadCast");
     // 是否有进入操作员管理页面权限
     if ($hasIntoBroadcastPrivilege['return']) {
         $ConditionList['StartTime'] = isset($this->post['StartTime']) ? $this->post['StartTime'] : (isset($this->get[2]) ? $this->get[2] : date("Y-m-01", time()));
         $ConditionList['EndTime'] = isset($this->post['EndTime']) ? $this->post['EndTime'] : (isset($this->get[3]) ? $this->get[3] : date("Y-m-d", time() + 86400));
         $BreadCastStatusList = $this->ask_config->getBroadCastStatus();
         $BroadCastZoneList = $this->ask_config->getBroadCastZone();
         $ConditionList['BroadCastZone'] = isset($this->post['BroadCastZone']) ? intval($this->post['BroadCastZone']) : (isset($this->get[4]) ? intval($this->get[4]) : -1);
         $ConditionList['BroadCastStatus'] = isset($this->post['BroadCastStatus']) ? intval($this->post['BroadCastStatus']) : (isset($this->get[5]) ? intval($this->get[5]) : 0);
         @($page = max(1, intval($this->get[6])));
         $export = trim($this->get[7]) == "export" ? 1 : 0;
         $setting = $this->setting;
         $pagesize = $this->setting['list_default'];
         $pagesize = 20;
         $BroadCastList = $_ENV['broadcast']->getBroadCastList($ConditionList, $page, $pagesize);
         foreach ($BroadCastList['BroadCastList'] as $key => $value) {
             $BroadCastList['BroadCastList'][$key]['BroadCastZone'] = $BroadCastZoneList[$value['BroadCastZone']];
             $time = time();
             if ($value['BroadCastStatus'] != 3) {
                 if ($value['StartTime'] <= $time && $value['EndTime'] >= $time) {
                     $BroadCastList['BroadCastList'][$key]['BroadCastStatus'] = 1;
                 } elseif ($value['EndTime'] < $time) {
                     $BroadCastList['BroadCastList'][$key]['BroadCastStatus'] = 2;
                 } elseif ($value['StartTime'] > $time) {
                     $BroadCastList['BroadCastList'][$key]['BroadCastStatus'] = 4;
                 }
             }
             $BroadCastList['BroadCastList'][$key]['BroadCastStatus'] = $BreadCastStatusList[$BroadCastList['BroadCastList'][$key]['BroadCastStatus']];
         }
         $departstr = page($complain_list['ComplainCount'], $pagesize, $page, "admin_broadcast/broadcast/" . $ConditionList['StartDate'] . "/" . $ConditionList['EndDate'] . "/" . $ConditionList['AnswerStartDate'] . "/" . $ConditionList['BroadCastZone'] . "/" . $ConditionList['BroadCastStatus']);
         $downloadstr = page_url("<下载EXCEL表格>", "admin_broadcast/broadcast/" . $ConditionList['StartDate'] . "/" . $ConditionList['EndDate'] . "/" . $ConditionList['AnswerStartDate'] . "/" . $ConditionList['BroadCastZone'] . "/" . $ConditionList['BroadCastStatus'] . "/" . $page . "/export");
         $msg && ($message = $msg);
         $ty && ($type = $ty);
         include template('broadcast', 'admin');
     } else {
         $hasIntoBroadcastPrivilege['url'] = "?admin_main";
         __msg($hasIntoBroadcastPrivilege);
     }
 }
예제 #12
0
 public function index()
 {
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => 'confirmDelete();'));
     if ($this->input->post('delete') and $this->_deleteLayout() === TRUE) {
         redirect('layouts');
     }
     $data['layouts'] = array();
     $results = $this->Layouts_model->getLayouts();
     foreach ($results as $result) {
         $data['layouts'][] = array('layout_id' => $result['layout_id'], 'name' => $result['name'], 'edit' => site_url('layouts/edit?id=' . $result['layout_id']));
     }
     $data['uri_routes'] = array();
     $results = $this->Layouts_model->getRoutes(1);
     foreach ($results as $result) {
         $data['uri_routes'][] = array('uri_route_id' => $result['uri_route_id'], 'uri_route' => $result['uri_route']);
     }
     $this->template->render('layouts', $data);
 }
예제 #13
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_category')) {
         $filter['filter_category'] = $data['category_id'] = (int) $this->input->get('filter_category');
         $url .= 'filter_category=' . $filter['filter_category'] . '&';
     } else {
         $data['category_id'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'menus.menu_id';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'ASC';
         $data['order_by_active'] = 'ASC active';
     }
     $this->template->setTitle($this->lang->line('text_heading'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => 'confirmDelete();'));
     if ($this->input->post('delete') and $this->_deleteMenu() === TRUE) {
         redirect('menus');
     }
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('menus' . $url . 'sort_by=menu_name&order_by=' . $order_by);
     $data['sort_price'] = site_url('menus' . $url . 'sort_by=menu_price&order_by=' . $order_by);
     $data['sort_stock'] = site_url('menus' . $url . 'sort_by=stock_qty&order_by=' . $order_by);
     $data['sort_id'] = site_url('menus' . $url . 'sort_by=menus.menu_id&order_by=' . $order_by);
     $this->load->model('Image_tool_model');
     $data['menus'] = array();
     $results = $this->Menus_model->getList($filter);
     foreach ($results as $result) {
         $price = ($result['special_status'] === '1' and $result['is_special'] === '1') ? $result['special_price'] : $result['menu_price'];
         $data['menus'][] = array('menu_id' => $result['menu_id'], 'menu_name' => $result['menu_name'], 'menu_description' => $result['menu_description'], 'category_name' => $result['name'], 'menu_price' => $this->currency->format($price), 'menu_photo' => $result['menu_photo'], 'stock_qty' => $result['stock_qty'], 'special_status' => $result['special_status'], 'is_special' => $result['is_special'], 'menu_status' => $result['menu_status'] === '1' ? $this->lang->line('text_enabled') : $this->lang->line('text_disabled'), 'edit' => site_url('menus/edit?id=' . $result['menu_id']));
     }
     //load category data into array
     $data['categories'] = array();
     $categories = $this->Categories_model->getCategories();
     foreach ($categories as $category) {
         $data['categories'][] = array('category_id' => $category['category_id'], 'category_name' => $category['name']);
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('menus' . $url);
     $config['total_rows'] = $this->Menus_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     $this->template->render('menus', $data);
 }
예제 #14
0
 private function getList($data, $filter)
 {
     $url = '?';
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = 1;
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     } else {
         $filter['limit'] = '';
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_access')) {
         $filter['filter_access'] = $data['filter_access'] = $this->input->get('filter_access');
         $url .= 'filter_access=' . $filter['filter_access'] . '&';
     } else {
         $filter['filter_access'] = $data['filter_access'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = '';
     }
     if ($filter['filter_type'] === 'online') {
         $data['text_empty'] = $this->lang->line('text_empty');
     } else {
         $data['text_empty'] = $this->lang->line('text_empty_report');
     }
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_date'] = site_url('customers_online' . $url . 'sort_by=date_added&order_by=' . $order_by);
     $customers_online = $this->Customer_online_model->getList($filter);
     $data['customers_online'] = array();
     foreach ($customers_online as $online) {
         $country_code = $online['country_code'] ? strtolower($online['country_code']) : 'no_flag';
         $data['customers_online'][] = array('activity_id' => $online['activity_id'], 'ip_address' => $online['ip_address'], 'customer_name' => $online['customer_id'] ? $online['first_name'] . ' ' . $online['last_name'] : $this->lang->line('text_guest'), 'access_type' => ucwords($online['access_type']), 'browser' => $online['browser'], 'user_agent' => $online['user_agent'], 'request_uri' => !empty($online['request_uri']) ? $online['request_uri'] : '--', 'referrer_uri' => !empty($online['referrer_uri']) ? $online['referrer_uri'] : '--', 'request_url' => !empty($online['request_uri']) ? root_url($online['request_uri']) : '#', 'referrer_url' => !empty($online['referrer_uri']) ? root_url($online['referrer_uri']) : '#', 'date_added' => time_elapsed($online['date_added']), 'country_code' => image_url('data/flags/' . $country_code . '.png'), 'country_name' => $online['country_name'] ? $online['country_name'] : $this->lang->line('text_private'));
     }
     $data['types'] = array('online' => array('badge' => '', 'url' => site_url('customers_online'), 'title' => $this->lang->line('text_online')), 'all' => array('badge' => '', 'url' => site_url('customers_online/all'), 'title' => $this->lang->line('text_all')));
     $data['online_dates'] = array();
     $online_dates = $this->Customer_online_model->getOnlineDates($filter);
     foreach ($online_dates as $date) {
         $month_year = mdate('%Y-%m', strtotime($date['year'] . '-' . $date['month']));
         $data['online_dates'][$month_year] = mdate('%F %Y', strtotime($date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = page_url() . $url;
     $config['total_rows'] = $this->Customer_online_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     return $data;
 }
예제 #15
0
 ><?php 
        echo lang('text_uninstalled');
        ?>
</option>
                                            <?php 
    }
}
?>
                                        </select>
                                    </div>
                                    <a class="btn btn-grey" onclick="filterList();" title="<?php 
echo lang('text_filter');
?>
"><i class="fa fa-filter"></i></a>&nbsp;
                                    <a class="btn btn-grey" href="<?php 
echo page_url();
?>
" title="<?php 
echo lang('text_clear');
?>
"><i class="fa fa-times"></i></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>

            <form role="form" id="list-form" accept-charset="utf-8" method="POST" action="<?php 
echo current_url();
?>
예제 #16
0
 public function index()
 {
     $this->user->restrict('Admin.Staffs');
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_group')) {
         $filter['filter_group'] = $data['filter_group'] = $this->input->get('filter_group');
         $url .= 'filter_group=' . $filter['filter_group'] . '&';
     } else {
         $filter['filter_group'] = $data['filter_group'] = '';
     }
     if (is_numeric($this->input->get('filter_location'))) {
         $filter['filter_location'] = $data['filter_location'] = $this->input->get('filter_location');
         $url .= 'filter_location=' . $filter['filter_location'] . '&';
     } else {
         $filter['filter_location'] = $data['filter_location'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'staffs.date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('staffs' . $url . 'sort_by=staff_name&order_by=' . $order_by);
     $data['sort_group'] = site_url('staffs' . $url . 'sort_by=staff_group_name&order_by=' . $order_by);
     $data['sort_location'] = site_url('staffs' . $url . 'sort_by=location_name&order_by=' . $order_by);
     $data['sort_date'] = site_url('staffs' . $url . 'sort_by=date_added&order_by=' . $order_by);
     $data['sort_id'] = site_url('staffs' . $url . 'sort_by=staff_id&order_by=' . $order_by);
     $data['staffs'] = array();
     $results = $this->Staffs_model->getList($filter);
     foreach ($results as $result) {
         $data['staffs'][] = array('staff_id' => $result['staff_id'], 'staff_name' => $result['staff_name'], 'staff_email' => $result['staff_email'], 'staff_group_name' => $result['staff_group_name'], 'location_name' => $result['location_name'], 'date_added' => day_elapsed($result['date_added']), 'staff_status' => $result['staff_status'] === '1' ? $this->lang->line('text_enabled') : $this->lang->line('text_disabled'), 'edit' => site_url('staffs/edit?id=' . $result['staff_id']));
     }
     $data['staff_groups'] = array();
     $results = $this->Staff_groups_model->getStaffGroups();
     foreach ($results as $result) {
         $data['staff_groups'][] = array('staff_group_id' => $result['staff_group_id'], 'staff_group_name' => $result['staff_group_name']);
     }
     $this->load->model('Locations_model');
     $data['locations'] = array();
     $results = $this->Locations_model->getLocations();
     foreach ($results as $result) {
         $data['locations'][] = array('location_id' => $result['location_id'], 'location_name' => $result['location_name']);
     }
     $data['staff_dates'] = array();
     $staff_dates = $this->Staffs_model->getStaffDates();
     foreach ($staff_dates as $staff_date) {
         $month_year = $staff_date['year'] . '-' . $staff_date['month'];
         $data['staff_dates'][$month_year] = mdate('%F %Y', strtotime($staff_date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('staffs' . $url);
     $config['total_rows'] = $this->Staffs_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteStaff() === TRUE) {
         redirect('staffs');
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('staffs', $data);
 }
예제 #17
0
    ?>
                </div>
              </li>
              <?php 
}
?>
            </ul>
            <nav>
              <?php 
for ($i = 0; $i <= intval($total_rows / 5); $i++) {
    if ($i == $current_page) {
        echo "<a class='current'>" . ($i + 1) . "</a>";
    } elseif ($i == 0) {
        echo "<a href='" . page_url() . "'>1</a>";
    } else {
        echo "<a href='" . page_url('list/' . $i) . "'>" . ($i + 1) . "</a>";
    }
}
?>
            </nav>
        </div>

        </div>
        

        
<?php 
$this->load->view('template/v_admin_footer.php');
?>

예제 #18
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'permission_id';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'ASC';
         $data['order_by_active'] = 'ASC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('permissions' . $url . 'sort_by=name&order_by=' . $order_by);
     $data['sort_status'] = site_url('permissions' . $url . 'sort_by=status&order_by=' . $order_by);
     $data['sort_id'] = site_url('permissions' . $url . 'sort_by=permission_id&order_by=' . $order_by);
     $data['permissions'] = array();
     $results = $this->Permissions_model->getList($filter);
     foreach ($results as $result) {
         $data['permissions'][] = array('permission_id' => $result['permission_id'], 'name' => $result['name'], 'description' => $result['description'], 'action' => !empty($result['action']) ? ucwords(implode(' | ', unserialize($result['action']))) : '', 'status' => $result['status'] == '1' ? 'Enabled' : 'Disabled', 'edit' => site_url('permissions/edit?id=' . $result['permission_id']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('permissions' . $url);
     $config['total_rows'] = $this->Permissions_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deletePermission() === TRUE) {
         redirect('permissions');
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('permissions', $data);
 }
예제 #19
0
 private function getList($data, $filter)
 {
     if ($this->input->post('message_state')) {
         if ($this->_updateMessageState($this->input->post('message_state'), '', $this->user->getStaffId()) === TRUE) {
             redirect(current_url());
         }
     }
     $url = '?';
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_recipient')) {
         $filter['filter_recipient'] = $data['filter_recipient'] = $this->input->get('filter_recipient');
         $url .= 'filter_recipient=' . $filter['filter_recipient'] . '&';
     } else {
         $filter['filter_recipient'] = $data['filter_recipient'] = '';
     }
     if ($this->input->get('filter_type')) {
         $filter['filter_type'] = $data['filter_type'] = $this->input->get('filter_type');
         $url .= 'filter_type=' . $filter['filter_type'] . '&';
     } else {
         $filter['filter_type'] = $data['filter_type'] = '';
     }
     $filter['filter_staff'] = $this->user->getStaffId();
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $filter['filter_date'];
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'messages.date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_type'] = site_url($data['page_uri'] . $url . 'sort_by=send_type&order_by=' . $order_by);
     $data['sort_date'] = site_url($data['page_uri'] . $url . 'sort_by=messages.date_added&order_by=' . $order_by);
     $message_state = $data['filter_folder'] === 'inbox' ? 'message message-unread' : 'message';
     $data['messages'] = array();
     $results = $this->Messages_model->getList($filter);
     foreach ($results as $result) {
         $data['messages'][] = array('message_id' => $result['message_id'], 'from' => $result['staff_name'], 'send_type' => $result['send_type'], 'type_icon' => (isset($result['send_type']) and $result['send_type'] === 'account') ? 'user' : 'envelope', 'subject' => strlen($result['subject']) > 30 ? substr(strip_tags(html_entity_decode($result['subject'], ENT_QUOTES, 'UTF-8')), 0, 30) . '..' : strip_tags(html_entity_decode($result['subject'], ENT_QUOTES, 'UTF-8')), 'recipient' => ucwords(str_replace('_', ' ', $result['recipient'])), 'date_added' => time_elapsed($result['date_added']), 'body' => strlen($result['body']) > 40 ? substr(strip_tags(html_entity_decode($result['body'], ENT_QUOTES, 'UTF-8')), 0, 40) . '..' : strip_tags(html_entity_decode($result['body'], ENT_QUOTES, 'UTF-8')), 'state' => (isset($result['state']) and $result['state'] === '1') ? 'message message-read' : $message_state, 'view' => $filter['filter_folder'] === 'draft' ? site_url('messages/compose?id=' . $result['message_id']) : site_url('messages/view?id=' . $result['message_id']));
     }
     $message_unread = $this->user->unreadMessageTotal();
     $data['folders'] = array('inbox' => array('title' => $this->lang->line('text_inbox'), 'icon' => 'fa-inbox', 'badge' => $message_unread, 'url' => site_url('messages')), 'draft' => array('title' => $this->lang->line('text_draft'), 'icon' => 'fa-file-text-o', 'badge' => '', 'url' => site_url('messages/draft')), 'sent' => array('title' => $this->lang->line('text_sent'), 'icon' => 'fa-paper-plane-o', 'badge' => '', 'url' => site_url('messages/sent')), 'all' => array('title' => $this->lang->line('text_all'), 'icon' => 'fa-briefcase', 'badge' => '', 'url' => site_url('messages/all')), 'archive' => array('title' => $this->lang->line('text_archive'), 'icon' => 'fa-archive', 'badge' => '', 'url' => site_url('messages/archive')));
     $data['labels'] = array('account' => array('title' => $this->lang->line('text_account'), 'icon' => 'fa-circle-o text-primary', 'url' => page_url() . '?filter_type=account'), 'email' => array('title' => $this->lang->line('text_email'), 'icon' => 'fa-circle-o text-danger', 'url' => page_url() . '?filter_type=email'));
     $data['message_dates'] = array();
     $message_dates = $this->Messages_model->getMessageDates();
     foreach ($message_dates as $message_date) {
         $month_year = $message_date['year'] . '-' . $message_date['month'];
         $data['message_dates'][$month_year] = mdate('%F %Y', strtotime($message_date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url($data['page_uri'] . $url);
     $config['total_rows'] = $this->Messages_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     return $data;
 }
예제 #20
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'location_id';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'ASC';
         $data['order_by_active'] = 'ASC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('locations' . $url . 'sort_by=location_name&order_by=' . $order_by);
     $data['sort_city'] = site_url('locations' . $url . 'sort_by=location_city&order_by=' . $order_by);
     $data['sort_state'] = site_url('locations' . $url . 'sort_by=location_state&order_by=' . $order_by);
     $data['sort_postcode'] = site_url('locations' . $url . 'sort_by=location_postcode&order_by=' . $order_by);
     $data['sort_id'] = site_url('locations' . $url . 'sort_by=location_id&order_by=' . $order_by);
     $data['country_id'] = $this->config->item('country_id');
     $data['default_location_id'] = $this->config->item('default_location_id');
     $data['locations'] = array();
     $results = $this->Locations_model->getList($filter);
     foreach ($results as $result) {
         if ($result['location_id'] !== $this->config->item('default_location_id')) {
             $default = site_url('locations?default=1&location_id=' . $result['location_id']);
         } else {
             $default = '1';
         }
         $data['locations'][] = array('location_id' => $result['location_id'], 'location_name' => $result['location_name'], 'location_address_1' => $result['location_address_1'], 'location_city' => $result['location_city'], 'location_state' => $result['location_state'], 'location_postcode' => $result['location_postcode'], 'location_telephone' => $result['location_telephone'], 'location_lat' => $result['location_lat'], 'location_lng' => $result['location_lng'], 'location_status' => $result['location_status'] === '1' ? $this->lang->line('text_enabled') : $this->lang->line('text_disabled'), 'default' => $default, 'edit' => site_url('locations/edit?id=' . $result['location_id']));
     }
     $data['tables'] = array();
     $tables = $this->Tables_model->getTables();
     if ($tables) {
         foreach ($tables as $table) {
             $data['tables'][] = array('table_id' => $table['table_id'], 'table_name' => $table['table_name'], 'min_capacity' => $table['min_capacity'], 'max_capacity' => $table['max_capacity']);
         }
     }
     $data['countries'] = array();
     $results = $this->Countries_model->getCountries();
     foreach ($results as $result) {
         $data['countries'][] = array('country_id' => $result['country_id'], 'name' => $result['country_name']);
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('locations' . $url);
     $config['total_rows'] = $this->Locations_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->get('default') === '1' and $this->input->get('location_id')) {
         $location_id = $this->input->get('location_id');
         if ($this->Locations_model->updateDefault($this->Locations_model->getAddress($location_id))) {
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), $this->lang->line('alert_set_default')));
         }
         redirect('locations');
     }
     if ($this->input->post('delete') and $this->_deleteLocation() === TRUE) {
         redirect('locations');
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('locations', $data);
 }
예제 #21
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_first'] = site_url('customers' . $url . 'sort_by=first_name&order_by=' . $order_by);
     $data['sort_last'] = site_url('customers' . $url . 'sort_by=last_name&order_by=' . $order_by);
     $data['sort_email'] = site_url('customers' . $url . 'sort_by=email&order_by=' . $order_by);
     $data['sort_date'] = site_url('customers' . $url . 'sort_by=date_added&order_by=' . $order_by);
     $data['sort_id'] = site_url('customers' . $url . 'sort_by=customer_id&order_by=' . $order_by);
     $data['customers'] = array();
     $results = $this->Customers_model->getList($filter);
     foreach ($results as $result) {
         $data['customers'][] = array('customer_id' => $result['customer_id'], 'first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'email' => $result['email'], 'telephone' => $result['telephone'], 'date_added' => day_elapsed($result['date_added']), 'status' => $result['status'] === '1' ? 'Enabled' : 'Disabled', 'edit' => site_url('customers/edit?id=' . $result['customer_id']));
     }
     $data['questions'] = array();
     $results = $this->Security_questions_model->getQuestions();
     foreach ($results as $result) {
         $data['questions'][] = array('id' => $result['question_id'], 'text' => $result['text']);
     }
     $data['country_id'] = $this->config->item('country_id');
     $data['countries'] = array();
     $results = $this->Countries_model->getCountries();
     // retrieve countries array from getCountries method in locations model
     foreach ($results as $result) {
         // loop through crountries array
         $data['countries'][] = array('country_id' => $result['country_id'], 'name' => $result['country_name']);
     }
     $data['customer_dates'] = array();
     $customer_dates = $this->Customers_model->getCustomerDates();
     foreach ($customer_dates as $customer_date) {
         $month_year = '';
         $month_year = $customer_date['year'] . '-' . $customer_date['month'];
         $data['customer_dates'][$month_year] = mdate('%F %Y', strtotime($customer_date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('customers' . $url);
     $config['total_rows'] = $this->Customers_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteCustomer() === TRUE) {
         redirect('customers');
     }
     $this->template->render('customers', $data);
 }
예제 #22
0
function showDailyRSS()
{
    // Cache system
    $query = $_SERVER["QUERY_STRING"];
    $cache = new CachedPage($GLOBALS['config']['PAGECACHE'], page_url($_SERVER), startsWith($query, 'do=dailyrss') && !isLoggedIn());
    $cached = $cache->cachedVersion();
    if (!empty($cached)) {
        echo $cached;
        exit;
    }
    // If cached was not found (or not usable), then read the database and build the response:
    // Read links from database (and filter private links if used it not logged in).
    $LINKSDB = new LinkDB($GLOBALS['config']['DATASTORE'], isLoggedIn(), $GLOBALS['config']['HIDE_PUBLIC_LINKS'], $GLOBALS['redirector']);
    /* Some Shaarlies may have very few links, so we need to look
          back in time (rsort()) until we have enough days ($nb_of_days).
       */
    $linkdates = array();
    foreach ($LINKSDB as $linkdate => $value) {
        $linkdates[] = $linkdate;
    }
    rsort($linkdates);
    $nb_of_days = 7;
    // We take 7 days.
    $today = Date('Ymd');
    $days = array();
    foreach ($linkdates as $linkdate) {
        $day = substr($linkdate, 0, 8);
        // Extract day (without time)
        if (strcmp($day, $today) < 0) {
            if (empty($days[$day])) {
                $days[$day] = array();
            }
            $days[$day][] = $linkdate;
        }
        if (count($days) > $nb_of_days) {
            break;
            // Have we collected enough days?
        }
    }
    // Build the RSS feed.
    header('Content-Type: application/rss+xml; charset=utf-8');
    $pageaddr = escape(index_url($_SERVER));
    echo '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">';
    echo '<channel>';
    echo '<title>Daily - ' . $GLOBALS['title'] . '</title>';
    echo '<link>' . $pageaddr . '</link>';
    echo '<description>Daily shared links</description>';
    echo '<language>en-en</language>';
    echo '<copyright>' . $pageaddr . '</copyright>' . PHP_EOL;
    // For each day.
    foreach ($days as $day => $linkdates) {
        $daydate = linkdate2timestamp($day . '_000000');
        // Full text date
        $rfc822date = linkdate2rfc822($day . '_000000');
        $absurl = escape(index_url($_SERVER) . '?do=daily&day=' . $day);
        // Absolute URL of the corresponding "Daily" page.
        // Build the HTML body of this RSS entry.
        $html = '';
        $href = '';
        $links = array();
        // We pre-format some fields for proper output.
        foreach ($linkdates as $linkdate) {
            $l = $LINKSDB[$linkdate];
            $l['formatedDescription'] = format_description($l['description'], $GLOBALS['redirector']);
            $l['thumbnail'] = thumbnail($l['url']);
            $l['timestamp'] = linkdate2timestamp($l['linkdate']);
            if (startsWith($l['url'], '?')) {
                $l['url'] = index_url($_SERVER) . $l['url'];
                // make permalink URL absolute
            }
            $links[$linkdate] = $l;
        }
        // Then build the HTML for this day:
        $tpl = new RainTPL();
        $tpl->assign('title', $GLOBALS['title']);
        $tpl->assign('daydate', $daydate);
        $tpl->assign('absurl', $absurl);
        $tpl->assign('links', $links);
        $tpl->assign('rfc822date', escape($rfc822date));
        $html = $tpl->draw('dailyrss', $return_string = true);
        echo $html . PHP_EOL;
    }
    echo '</channel></rss><!-- Cached version of ' . escape(page_url($_SERVER)) . ' -->';
    $cache->cache(ob_get_contents());
    ob_end_flush();
    exit;
}
예제 #23
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if (is_numeric($this->input->get('filter_location'))) {
         $filter['filter_location'] = $data['filter_location'] = $this->input->get('filter_location');
         $url .= 'filter_location=' . $filter['filter_location'] . '&';
     } else {
         $filter['filter_location'] = $data['filter_location'] = '';
     }
     if ($this->input->get('filter_date')) {
         $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date');
         $url .= 'filter_date=' . $filter['filter_date'] . '&';
     } else {
         $filter['filter_date'] = $data['filter_date'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'reviews.date_added';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => '$(\'#list-form\').submit();'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_location'] = site_url('reviews' . $url . 'sort_by=location_name&order_by=' . $order_by);
     $data['sort_author'] = site_url('reviews' . $url . 'sort_by=author&order_by=' . $order_by);
     $data['sort_id'] = site_url('reviews' . $url . 'sort_by=sale_id&order_by=' . $order_by);
     $data['sort_status'] = site_url('reviews' . $url . 'sort_by=review_status&order_by=' . $order_by);
     $data['sort_date'] = site_url('reviews' . $url . 'sort_by=date_added&order_by=' . $order_by);
     $ratings = $this->config->item('ratings');
     $data['ratings'] = $ratings['ratings'];
     $reviews = $this->Reviews_model->getList($filter);
     $data['reviews'] = array();
     foreach ($reviews as $review) {
         $data['reviews'][] = array('review_id' => $review['review_id'], 'location_name' => $review['location_name'], 'author' => $review['author'], 'quality' => $review['quality'], 'delivery' => $review['delivery'], 'service' => $review['service'], 'sale_type' => $review['sale_type'], 'sale_id' => $review['sale_id'], 'date_added' => mdate('%d %M %y', strtotime($review['date_added'])), 'review_status' => $review['review_status'], 'edit' => site_url('reviews/edit?id=' . $review['review_id']));
     }
     $this->load->model('Locations_model');
     $data['locations'] = array();
     $results = $this->Locations_model->getLocations();
     foreach ($results as $result) {
         $data['locations'][] = array('location_id' => $result['location_id'], 'location_name' => $result['location_name']);
     }
     $data['review_dates'] = array();
     $review_dates = $this->Reviews_model->getReviewDates();
     foreach ($review_dates as $review_date) {
         $month_year = $review_date['year'] . '-' . $review_date['month'];
         $data['review_dates'][$month_year] = mdate('%F %Y', strtotime($review_date['date_added']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('reviews' . $url);
     $config['total_rows'] = $this->Reviews_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     if ($this->input->post('delete') and $this->_deleteReview() === TRUE) {
         redirect('reviews');
     }
     $this->template->render('reviews', $data);
 }
예제 #24
0
function url_path()
{
    $url_parts = explode('?', page_url());
    return $url_parts[0];
}
예제 #25
0
 public function index()
 {
     $this->user->restrict('Admin.Modules');
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if ($this->input->get('filter_type')) {
         $filter['filter_type'] = $data['filter_type'] = $this->input->get('filter_type');
         $url .= 'filter_type=' . $filter['filter_type'] . '&';
     } else {
         $data['filter_type'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'name';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'ASC';
         $data['order_by_active'] = 'ASC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/add'));
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('extensions' . $url . 'sort_by=name&order_by=' . $order_by);
     $data['sort_type'] = site_url('extensions' . $url . 'sort_by=type&order_by=' . $order_by);
     $data['extensions'] = array();
     $results = $this->Extensions_model->getList($filter);
     foreach ($results as $result) {
         if ($result['config'] !== TRUE) {
             $this->alert->warning_now($result['config']);
             continue;
         }
         if ($result['installed'] === TRUE and $result['status'] === '1') {
             $manage = 'uninstall';
         } else {
             $manage = 'install';
         }
         $data['extensions'][] = array('extension_id' => $result['extension_id'], 'author' => isset($result['author']) ? $result['author'] : '--', 'name' => $result['name'], 'title' => $result['title'], 'installed' => $result['installed'], 'type' => ucfirst($result['type']), 'description' => isset($result['description']) ? substr($result['description'], 0, 128) : '', 'settings' => $result['settings'], 'status' => $result['status'], 'edit' => site_url('extensions/edit?id=' . $result['extension_id'] . '&name=' . $result['name']), 'delete' => site_url('extensions/delete?id=' . $result['extension_id'] . '&name=' . $result['name']), 'manage' => site_url('extensions/' . $manage . '?id=' . $result['extension_id'] . '&name=' . $result['name']));
     }
     $this->template->setPartials(array('header', 'footer'));
     $this->template->render('extensions', $data);
 }
예제 #26
0
 public function index()
 {
     $this->user->restrict('Admin.MediaManager.Access');
     $this->output->enable_profiler(FALSE);
     $data['uploads'] = $this->_uploads;
     $data['new_folder'] = $this->_new_folder;
     $data['move'] = $this->_move;
     $data['copy'] = $this->_copy;
     $data['rename'] = $this->_rename;
     $data['delete'] = $this->_delete;
     $popup = $data['popup'] = $this->input->get('popup') ? $this->_fixGetParams($this->input->get('popup')) : '';
     $field_id = $data['field_id'] = $this->input->get('field_id') ? $this->_fixGetParams($this->input->get('field_id')) : '';
     $filter = $data['filter'] = $this->input->get('filter') ? $this->_fixGetParams($this->input->get('filter')) : '';
     $sort_by = $data['sort_by'] = $this->input->get('sort_by') ? $this->_fixGetParams($this->input->get('sort_by')) : 'name';
     $sort_order = $data['sort_order'] = $this->input->get('sort_order') ? $this->_fixGetParams($this->input->get('sort_order')) : 'ascending';
     $data['sort_icon'] = $sort_order === 'ascending' ? '<i class="fa fa-caret-up"></i>' : '<i class="fa fa-caret-down"></i>';
     $get_params = http_build_query(array('popup' => $popup, 'field_id' => $field_id, 'sub_folder' => ''));
     $root_folder = $this->media_manager->getRootFolder();
     $open_file = '';
     if ($this->input->get('sub_folder') and strpos($this->input->get('sub_folder'), '../') === FALSE and strpos($this->input->get('sub_folder'), './') === FALSE) {
         $sub_folder = $this->input->get('sub_folder');
         if ($pathinfo = pathinfo($sub_folder) and !empty($pathinfo['extension'])) {
             $sub_folder = isset($pathinfo['dirname']) ? $pathinfo['dirname'] . '/' : '';
             $open_file = isset($pathinfo['basename']) ? $pathinfo['basename'] : '';
             if (strpos($sub_folder, $root_folder) !== FALSE) {
                 $sub_folder = str_replace($root_folder, '', $sub_folder);
             }
         } else {
             $sub_folder = urldecode(trim(strip_tags($sub_folder), '/') . '/');
         }
         $this->session->set_tempdata('last_sub_folder', $sub_folder, 86400 * (int) $this->_remember_days);
     } else {
         if ($this->session->tempdata('last_sub_folder')) {
             $sub_folder = $this->security->sanitize_filename($this->session->tempdata('last_sub_folder'), TRUE);
         } else {
             $sub_folder = '';
         }
     }
     $sub_folder = $sub_folder === "/" ? '' : $sub_folder;
     $this->setTemplateTags($popup);
     $data['title'] = $this->lang->line('text_heading');
     $data['files_empty'] = $this->lang->line('text_empty');
     $data['back'] = $this->lang->line('text_disabled');
     $data['back_url'] = '';
     if (trim($sub_folder) != '') {
         $src = explode('/', $sub_folder);
         unset($src[count($src) - 2]);
         $src = implode('/', $src);
         if ($src == '') {
             $src = '/';
         }
         $data['back'] = '';
         $data['back_url'] = page_url() . '?' . $get_params . rawurlencode($src) . '&' . uniqid();
     }
     $data['current_url'] = current_url();
     $data['refresh_url'] = page_url() . '?' . $get_params . $sub_folder . '&' . uniqid();
     $data['link'] = page_url() . '?' . $get_params;
     $data['delete_folder'] = FALSE;
     $data['rename_folder'] = FALSE;
     $data['current_folder'] = '';
     $data['breadcrumbs'] = array();
     if ($sub_folder_array = explode('/', $sub_folder)) {
         $tmp_path = '';
         $data['breadcrumbs'][] = array('name' => '<i class="fa fa-home"></i>', 'link' => $data['link'] . '/');
         foreach ($sub_folder_array as $key => $p_dir) {
             $tmp_path .= $p_dir . '/';
             if ($p_dir != '') {
                 $data['breadcrumbs'][] = array('name' => $p_dir, 'link' => $data['link'] . $tmp_path);
                 $data['current_folder'] = $p_dir;
             }
         }
         if ($data['current_folder'] === 'gallery') {
             $data['new_folder'] = TRUE;
         }
         $dirname = dirname($sub_folder);
         $data['parent_folder'] = $dirname === '.' ? '' : $dirname . '/';
     }
     $data['total_files'] = $total_size = 0;
     $data['files'] = array();
     $files = $this->media_manager->fetchFiles($sub_folder, array('by' => $sort_by, 'order' => $sort_order, 'filter' => $filter));
     foreach ($files as $k => $file) {
         $file_ext = !empty($file['ext']) ? $file['ext'] : '';
         $new_name = $this->media_manager->fixFileName($file['name']);
         $file_name = ($file['name'] != '..' and $file['name'] != $new_name) ? $new_name : $file['name'];
         $human_name = ($file['type'] === 'img' or $file['type'] === 'file') ? substr($file_name, 0, '-' . (strlen($file_ext) + 1)) : $file_name;
         $html_class = $file['type'] === 'img' ? 'ff-item-type-2 file' : 'ff-item-type-1 file';
         if ($open_file === $file['name']) {
             $html_class .= ' selected-on-open';
         }
         $img_dimension = $img_url = $thumb_url = '';
         $img_url = image_url($root_folder . $sub_folder . $file_name);
         if ($file['type'] === 'img') {
             $thumb_type = 'thumb';
             $thumbnail = $this->media_manager->getThumbnail($file_name, $sub_folder);
             $img_dimension = $thumbnail['dimension'];
             $thumb_url = $thumbnail['url'];
         }
         if ($thumb_url == '') {
             $thumb_type = 'icon';
             $thumb_url = image_url('default-icon.svg');
         }
         $total_size += $file['size'];
         $data['files'][] = array('name' => $file_name, 'human_name' => $human_name, 'type' => $file['type'], 'date' => $file['date'], 'size' => $this->_makeSize($file['size']), 'ext' => $file_ext, 'perms' => $file['perms'], 'path' => $sub_folder . $file_name, 'img_url' => $img_url, 'thumb_type' => $thumb_type, 'thumb_url' => $thumb_url, 'img_dimension' => $img_dimension, 'html_class' => $html_class);
     }
     $data['galleries'] = $this->media_manager->fetchGalleries();
     $tree_link = page_url() . '?' . $get_params . '{link}&' . uniqid();
     $data['folder_tree'] = $this->media_manager->folderTree($sub_folder, $tree_link);
     $data['total_files'] = count($files);
     $data['root_folder'] = $root_folder;
     $data['sub_folder'] = $sub_folder;
     $data['folders_list'] = $this->media_manager->recursiveFolders();
     $data['folder_size'] = $this->_makeSize($total_size);
     $data['max_size_upload'] = $this->media_manager->getUploadMaxSize();
     $data['allowed_ext'] = $this->media_manager->getAllowedExt();
     if ($popup === 'iframe') {
         $this->load->view($this->config->item(ADMINDIR, 'default_themes') . 'image_manager', $data);
     } else {
         $this->template->render('image_manager', $data);
     }
 }
예제 #27
0
 public function index()
 {
     $url = '?';
     $filter = array();
     if ($this->input->get('page')) {
         $filter['page'] = (int) $this->input->get('page');
     } else {
         $filter['page'] = '';
     }
     if ($this->config->item('page_limit')) {
         $filter['limit'] = $this->config->item('page_limit');
     }
     if ($this->input->get('filter_search')) {
         $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search');
         $url .= 'filter_search=' . $filter['filter_search'] . '&';
     } else {
         $data['filter_search'] = '';
     }
     if (is_numeric($this->input->get('filter_status'))) {
         $filter['filter_status'] = $data['filter_status'] = $this->input->get('filter_status');
         $url .= 'filter_status=' . $filter['filter_status'] . '&';
     } else {
         $filter['filter_status'] = $data['filter_status'] = '';
     }
     if ($this->input->get('sort_by')) {
         $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by');
     } else {
         $filter['sort_by'] = $data['sort_by'] = 'language_id';
     }
     if ($this->input->get('order_by')) {
         $filter['order_by'] = $data['order_by'] = $this->input->get('order_by');
         $data['order_by_active'] = $this->input->get('order_by') . ' active';
     } else {
         $filter['order_by'] = $data['order_by'] = 'DESC';
         $data['order_by_active'] = 'DESC';
     }
     $this->template->setTitle($this->lang->line('text_title'));
     $this->template->setHeading($this->lang->line('text_heading'));
     $this->template->setButton($this->lang->line('button_new'), array('class' => 'btn btn-primary', 'href' => page_url() . '/edit'));
     $this->template->setButton($this->lang->line('button_delete'), array('class' => 'btn btn-danger', 'onclick' => 'confirmDelete();'));
     if ($this->input->post('delete') and $this->_deleteLanguage() === TRUE) {
         redirect('languages');
     }
     $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC';
     $data['sort_name'] = site_url('languages' . $url . 'sort_by=name&order_by=' . $order_by);
     $data['sort_code'] = site_url('languages' . $url . 'sort_by=code&order_by=' . $order_by);
     $data['language_id'] = $this->config->item('language_id');
     $data['languages'] = array();
     $results = $this->Languages_model->getList($filter);
     foreach ($results as $result) {
         $data['languages'][] = array('language_id' => $result['language_id'], 'name' => $result['name'], 'code' => $result['code'], 'image' => !empty($result['image']) ? $this->Image_tool_model->resize($result['image']) : $this->Image_tool_model->resize('data/flags/no_flag.png'), 'status' => $result['status'] === '1' ? $this->lang->line('text_enabled') : $this->lang->line('text_disabled'), 'edit' => site_url('languages/edit?id=' . $result['language_id']));
     }
     if ($this->input->get('sort_by') and $this->input->get('order_by')) {
         $url .= 'sort_by=' . $filter['sort_by'] . '&';
         $url .= 'order_by=' . $filter['order_by'] . '&';
     }
     $config['base_url'] = site_url('languages' . $url);
     $config['total_rows'] = $this->Languages_model->getCount($filter);
     $config['per_page'] = $filter['limit'];
     $this->pagination->initialize($config);
     $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links());
     $this->template->render('languages', $data);
 }
예제 #28
0
파일: index.php 프로젝트: toneiv/Shaarli
function renderPage()
{
    $LINKSDB = new LinkDB($GLOBALS['config']['DATASTORE'], isLoggedIn(), $GLOBALS['config']['HIDE_PUBLIC_LINKS'], $GLOBALS['redirector'], $GLOBALS['config']['REDIRECTOR_URLENCODE']);
    $updater = new Updater(read_updates_file($GLOBALS['config']['UPDATES_FILE']), $GLOBALS, $LINKSDB, isLoggedIn());
    try {
        $newUpdates = $updater->update();
        if (!empty($newUpdates)) {
            write_updates_file($GLOBALS['config']['UPDATES_FILE'], $updater->getDoneUpdates());
        }
    } catch (Exception $e) {
        die($e->getMessage());
    }
    $PAGE = new PageBuilder();
    $PAGE->assign('linkcount', count($LINKSDB));
    $PAGE->assign('privateLinkcount', count_private($LINKSDB));
    // Determine which page will be rendered.
    $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
    $targetPage = Router::findPage($query, $_GET, isLoggedIn());
    // Call plugin hooks for header, footer and includes, specifying which page will be rendered.
    // Then assign generated data to RainTPL.
    $common_hooks = array('includes', 'header', 'footer');
    $pluginManager = PluginManager::getInstance();
    foreach ($common_hooks as $name) {
        $plugin_data = array();
        $pluginManager->executeHooks('render_' . $name, $plugin_data, array('target' => $targetPage, 'loggedin' => isLoggedIn()));
        $PAGE->assign('plugins_' . $name, $plugin_data);
    }
    // -------- Display login form.
    if ($targetPage == Router::$PAGE_LOGIN) {
        if ($GLOBALS['config']['OPEN_SHAARLI']) {
            header('Location: ?');
            exit;
        }
        // No need to login for open Shaarli
        $token = '';
        if (ban_canLogin()) {
            $token = getToken();
        }
        // Do not waste token generation if not useful.
        $PAGE->assign('token', $token);
        if (isset($_GET['username'])) {
            $PAGE->assign('username', escape($_GET['username']));
        }
        $PAGE->assign('returnurl', isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : '');
        $PAGE->renderPage('loginform');
        exit;
    }
    // -------- User wants to logout.
    if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout')) {
        invalidateCaches($GLOBALS['config']['PAGECACHE']);
        logout();
        header('Location: ?');
        exit;
    }
    // -------- Picture wall
    if ($targetPage == Router::$PAGE_PICWALL) {
        // Optionally filter the results:
        $links = $LINKSDB->filterSearch($_GET);
        $linksToDisplay = array();
        // Get only links which have a thumbnail.
        foreach ($links as $link) {
            $permalink = '?' . escape(smallhash($link['linkdate']));
            $thumb = lazyThumbnail($link['url'], $permalink);
            if ($thumb != '') {
                $link['thumbnail'] = $thumb;
                // Thumbnail HTML code.
                $linksToDisplay[] = $link;
                // Add to array.
            }
        }
        $data = array('linksToDisplay' => $linksToDisplay);
        $pluginManager->executeHooks('render_picwall', $data, array('loggedin' => isLoggedIn()));
        foreach ($data as $key => $value) {
            $PAGE->assign($key, $value);
        }
        $PAGE->renderPage('picwall');
        exit;
    }
    // -------- Tag cloud
    if ($targetPage == Router::$PAGE_TAGCLOUD) {
        $tags = $LINKSDB->allTags();
        // We sort tags alphabetically, then choose a font size according to count.
        // First, find max value.
        $maxcount = 0;
        foreach ($tags as $value) {
            $maxcount = max($maxcount, $value);
        }
        // Sort tags alphabetically: case insensitive, support locale if avalaible.
        uksort($tags, function ($a, $b) {
            // Collator is part of PHP intl.
            if (class_exists('Collator')) {
                $c = new Collator(setlocale(LC_COLLATE, 0));
                if (!intl_is_failure(intl_get_error_code())) {
                    return $c->compare($a, $b);
                }
            }
            return strcasecmp($a, $b);
        });
        $tagList = array();
        foreach ($tags as $key => $value) {
            // Tag font size scaling:
            //   default 15 and 30 logarithm bases affect scaling,
            //   22 and 6 are arbitrary font sizes for max and min sizes.
            $size = log($value, 15) / log($maxcount, 30) * 2.2 + 0.8;
            $tagList[$key] = array('count' => $value, 'size' => number_format($size, 2, '.', ''));
        }
        $data = array('tags' => $tagList);
        $pluginManager->executeHooks('render_tagcloud', $data, array('loggedin' => isLoggedIn()));
        foreach ($data as $key => $value) {
            $PAGE->assign($key, $value);
        }
        $PAGE->renderPage('tagcloud');
        exit;
    }
    // Daily page.
    if ($targetPage == Router::$PAGE_DAILY) {
        showDaily($PAGE, $LINKSDB);
    }
    // ATOM and RSS feed.
    if ($targetPage == Router::$PAGE_FEED_ATOM || $targetPage == Router::$PAGE_FEED_RSS) {
        $feedType = $targetPage == Router::$PAGE_FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM;
        header('Content-Type: application/' . $feedType . '+xml; charset=utf-8');
        // Cache system
        $query = $_SERVER['QUERY_STRING'];
        $cache = new CachedPage($GLOBALS['config']['PAGECACHE'], page_url($_SERVER), startsWith($query, 'do=' . $targetPage) && !isLoggedIn());
        $cached = $cache->cachedVersion();
        if (!empty($cached)) {
            echo $cached;
            exit;
        }
        // Generate data.
        $feedGenerator = new FeedBuilder($LINKSDB, $feedType, $_SERVER, $_GET, isLoggedIn());
        $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0)));
        $feedGenerator->setHideDates($GLOBALS['config']['HIDE_TIMESTAMPS'] && !isLoggedIn());
        $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$GLOBALS['config']['ENABLE_RSS_PERMALINKS']);
        if (!empty($GLOBALS['config']['PUBSUBHUB_URL'])) {
            $feedGenerator->setPubsubhubUrl($GLOBALS['config']['PUBSUBHUB_URL']);
        }
        $data = $feedGenerator->buildData();
        // Process plugin hook.
        $pluginManager = PluginManager::getInstance();
        $pluginManager->executeHooks('render_feed', $data, array('loggedin' => isLoggedIn(), 'target' => $targetPage));
        // Render the template.
        $PAGE->assignAll($data);
        $PAGE->renderPage('feed.' . $feedType);
        $cache->cache(ob_get_contents());
        ob_end_flush();
        exit;
    }
    // Display openseach plugin (XML)
    if ($targetPage == Router::$PAGE_OPENSEARCH) {
        header('Content-Type: application/xml; charset=utf-8');
        $PAGE->assign('serverurl', index_url($_SERVER));
        $PAGE->renderPage('opensearch');
        exit;
    }
    // -------- User clicks on a tag in a link: The tag is added to the list of searched tags (searchtags=...)
    if (isset($_GET['addtag'])) {
        // Get previous URL (http_referer) and add the tag to the searchtags parameters in query.
        if (empty($_SERVER['HTTP_REFERER'])) {
            header('Location: ?searchtags=' . urlencode($_GET['addtag']));
            exit;
        }
        // In case browser does not send HTTP_REFERER
        parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $params);
        // Prevent redirection loop
        if (isset($params['addtag'])) {
            unset($params['addtag']);
        }
        // Check if this tag is already in the search query and ignore it if it is.
        // Each tag is always separated by a space
        if (isset($params['searchtags'])) {
            $current_tags = explode(' ', $params['searchtags']);
        } else {
            $current_tags = array();
        }
        $addtag = true;
        foreach ($current_tags as $value) {
            if ($value === $_GET['addtag']) {
                $addtag = false;
                break;
            }
        }
        // Append the tag if necessary
        if (empty($params['searchtags'])) {
            $params['searchtags'] = trim($_GET['addtag']);
        } else {
            if ($addtag) {
                $params['searchtags'] = trim($params['searchtags']) . ' ' . trim($_GET['addtag']);
            }
        }
        unset($params['page']);
        // We also remove page (keeping the same page has no sense, since the results are different)
        header('Location: ?' . http_build_query($params));
        exit;
    }
    // -------- User clicks on a tag in result count: Remove the tag from the list of searched tags (searchtags=...)
    if (isset($_GET['removetag'])) {
        // Get previous URL (http_referer) and remove the tag from the searchtags parameters in query.
        if (empty($_SERVER['HTTP_REFERER'])) {
            header('Location: ?');
            exit;
        }
        // In case browser does not send HTTP_REFERER
        parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $params);
        // Prevent redirection loop
        if (isset($params['removetag'])) {
            unset($params['removetag']);
        }
        if (isset($params['searchtags'])) {
            $tags = explode(' ', $params['searchtags']);
            // Remove value from array $tags.
            $tags = array_diff($tags, array($_GET['removetag']));
            $params['searchtags'] = implode(' ', $tags);
            if (empty($params['searchtags'])) {
                unset($params['searchtags']);
            }
            unset($params['page']);
            // We also remove page (keeping the same page has no sense, since the results are different)
        }
        header('Location: ?' . http_build_query($params));
        exit;
    }
    // -------- User wants to change the number of links per page (linksperpage=...)
    if (isset($_GET['linksperpage'])) {
        if (is_numeric($_GET['linksperpage'])) {
            $_SESSION['LINKS_PER_PAGE'] = abs(intval($_GET['linksperpage']));
        }
        header('Location: ' . generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('linksperpage')));
        exit;
    }
    // -------- User wants to see only private links (toggle)
    if (isset($_GET['privateonly'])) {
        if (empty($_SESSION['privateonly'])) {
            $_SESSION['privateonly'] = 1;
            // See only private links
        } else {
            unset($_SESSION['privateonly']);
            // See all links
        }
        header('Location: ' . generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('privateonly')));
        exit;
    }
    // -------- Handle other actions allowed for non-logged in users:
    if (!isLoggedIn()) {
        // User tries to post new link but is not logged in:
        // Show login screen, then redirect to ?post=...
        if (isset($_GET['post'])) {
            header('Location: ?do=login&post=' . urlencode($_GET['post']) . (!empty($_GET['title']) ? '&title=' . urlencode($_GET['title']) : '') . (!empty($_GET['description']) ? '&description=' . urlencode($_GET['description']) : '') . (!empty($_GET['source']) ? '&source=' . urlencode($_GET['source']) : ''));
            // Redirect to login page, then back to post link.
            exit;
        }
        showLinkList($PAGE, $LINKSDB);
        if (isset($_GET['edit_link'])) {
            header('Location: ?do=login&edit_link=' . escape($_GET['edit_link']));
            exit;
        }
        exit;
        // Never remove this one! All operations below are reserved for logged in user.
    }
    // -------- All other functions are reserved for the registered user:
    // -------- Display the Tools menu if requested (import/export/bookmarklet...)
    if ($targetPage == Router::$PAGE_TOOLS) {
        $data = array('pageabsaddr' => index_url($_SERVER));
        $pluginManager->executeHooks('render_tools', $data);
        foreach ($data as $key => $value) {
            $PAGE->assign($key, $value);
        }
        $PAGE->renderPage('tools');
        exit;
    }
    // -------- User wants to change his/her password.
    if ($targetPage == Router::$PAGE_CHANGEPASSWORD) {
        if ($GLOBALS['config']['OPEN_SHAARLI']) {
            die('You are not supposed to change a password on an Open Shaarli.');
        }
        if (!empty($_POST['setpassword']) && !empty($_POST['oldpassword'])) {
            if (!tokenOk($_POST['token'])) {
                die('Wrong token.');
            }
            // Go away!
            // Make sure old password is correct.
            $oldhash = sha1($_POST['oldpassword'] . $GLOBALS['login'] . $GLOBALS['salt']);
            if ($oldhash != $GLOBALS['hash']) {
                echo '<script>alert("The old password is not correct.");document.location=\'?do=changepasswd\';</script>';
                exit;
            }
            // Save new password
            $GLOBALS['salt'] = sha1(uniqid('', true) . '_' . mt_rand());
            // Salt renders rainbow-tables attacks useless.
            $GLOBALS['hash'] = sha1($_POST['setpassword'] . $GLOBALS['login'] . $GLOBALS['salt']);
            try {
                writeConfig($GLOBALS, isLoggedIn());
            } catch (Exception $e) {
                error_log('ERROR while writing config file after changing password.' . PHP_EOL . $e->getMessage());
                // TODO: do not handle exceptions/errors in JS.
                echo '<script>alert("' . $e->getMessage() . '");document.location=\'?do=tools\';</script>';
                exit;
            }
            echo '<script>alert("Your password has been changed.");document.location=\'?do=tools\';</script>';
            exit;
        } else {
            $PAGE->assign('token', getToken());
            $PAGE->renderPage('changepassword');
            exit;
        }
    }
    // -------- User wants to change configuration
    if ($targetPage == Router::$PAGE_CONFIGURE) {
        if (!empty($_POST['title'])) {
            if (!tokenOk($_POST['token'])) {
                die('Wrong token.');
                // Go away!
            }
            $tz = 'UTC';
            if (!empty($_POST['continent']) && !empty($_POST['city']) && isTimeZoneValid($_POST['continent'], $_POST['city'])) {
                $tz = $_POST['continent'] . '/' . $_POST['city'];
            }
            $GLOBALS['timezone'] = $tz;
            $GLOBALS['title'] = $_POST['title'];
            $GLOBALS['titleLink'] = $_POST['titleLink'];
            $GLOBALS['redirector'] = $_POST['redirector'];
            $GLOBALS['disablesessionprotection'] = !empty($_POST['disablesessionprotection']);
            $GLOBALS['privateLinkByDefault'] = !empty($_POST['privateLinkByDefault']);
            $GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = !empty($_POST['enableRssPermalinks']);
            $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
            $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = !empty($_POST['hidePublicLinks']);
            try {
                writeConfig($GLOBALS, isLoggedIn());
            } catch (Exception $e) {
                error_log('ERROR while writing config file after configuration update.' . PHP_EOL . $e->getMessage());
                // TODO: do not handle exceptions/errors in JS.
                echo '<script>alert("' . $e->getMessage() . '");document.location=\'?do=tools\';</script>';
                exit;
            }
            echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
            exit;
        } else {
            $PAGE->assign('token', getToken());
            $PAGE->assign('title', empty($GLOBALS['title']) ? '' : $GLOBALS['title']);
            $PAGE->assign('redirector', empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']);
            list($timezone_form, $timezone_js) = generateTimeZoneForm($GLOBALS['timezone']);
            $PAGE->assign('timezone_form', $timezone_form);
            $PAGE->assign('timezone_js', $timezone_js);
            $PAGE->renderPage('configure');
            exit;
        }
    }
    // -------- User wants to rename a tag or delete it
    if ($targetPage == Router::$PAGE_CHANGETAG) {
        if (empty($_POST['fromtag']) || empty($_POST['totag']) && isset($_POST['renametag'])) {
            $PAGE->assign('token', getToken());
            $PAGE->assign('tags', $LINKSDB->allTags());
            $PAGE->renderPage('changetag');
            exit;
        }
        if (!tokenOk($_POST['token'])) {
            die('Wrong token.');
        }
        // Delete a tag:
        if (isset($_POST['deletetag']) && !empty($_POST['fromtag'])) {
            $needle = trim($_POST['fromtag']);
            // True for case-sensitive tag search.
            $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true);
            foreach ($linksToAlter as $key => $value) {
                $tags = explode(' ', trim($value['tags']));
                unset($tags[array_search($needle, $tags)]);
                // Remove tag.
                $value['tags'] = trim(implode(' ', $tags));
                $LINKSDB[$key] = $value;
            }
            $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']);
            echo '<script>alert("Tag was removed from ' . count($linksToAlter) . ' links.");document.location=\'?\';</script>';
            exit;
        }
        // Rename a tag:
        if (isset($_POST['renametag']) && !empty($_POST['fromtag']) && !empty($_POST['totag'])) {
            $needle = trim($_POST['fromtag']);
            // True for case-sensitive tag search.
            $linksToAlter = $LINKSDB->filterSearch(array('searchtags' => $needle), true);
            foreach ($linksToAlter as $key => $value) {
                $tags = explode(' ', trim($value['tags']));
                $tags[array_search($needle, $tags)] = trim($_POST['totag']);
                // Replace tags value.
                $value['tags'] = trim(implode(' ', $tags));
                $LINKSDB[$key] = $value;
            }
            $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']);
            // Save to disk.
            echo '<script>alert("Tag was renamed in ' . count($linksToAlter) . ' links.");document.location=\'?searchtags=' . urlencode($_POST['totag']) . '\';</script>';
            exit;
        }
    }
    // -------- User wants to add a link without using the bookmarklet: Show form.
    if ($targetPage == Router::$PAGE_ADDLINK) {
        $PAGE->renderPage('addlink');
        exit;
    }
    // -------- User clicked the "Save" button when editing a link: Save link to database.
    if (isset($_POST['save_edit'])) {
        // Go away!
        if (!tokenOk($_POST['token'])) {
            die('Wrong token.');
        }
        // Remove multiple spaces.
        $tags = trim(preg_replace('/\\s\\s+/', ' ', $_POST['lf_tags']));
        // Remove first '-' char in tags.
        $tags = preg_replace('/(^| )\\-/', '$1', $tags);
        // Remove duplicates.
        $tags = implode(' ', array_unique(explode(' ', $tags)));
        $linkdate = $_POST['lf_linkdate'];
        $url = trim($_POST['lf_url']);
        if (!startsWith($url, 'http:') && !startsWith($url, 'https:') && !startsWith($url, 'ftp:') && !startsWith($url, 'magnet:') && !startsWith($url, '?') && !startsWith($url, 'javascript:')) {
            $url = 'http://' . $url;
        }
        $link = array('title' => trim($_POST['lf_title']), 'url' => $url, 'description' => $_POST['lf_description'], 'private' => isset($_POST['lf_private']) ? 1 : 0, 'linkdate' => $linkdate, 'tags' => str_replace(',', ' ', $tags));
        // If title is empty, use the URL as title.
        if ($link['title'] == '') {
            $link['title'] = $link['url'];
        }
        $pluginManager->executeHooks('save_link', $link);
        $LINKSDB[$linkdate] = $link;
        $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']);
        pubsubhub();
        // If we are called from the bookmarklet, we must close the popup:
        if (isset($_GET['source']) && ($_GET['source'] == 'bookmarklet' || $_GET['source'] == 'firefoxsocialapi')) {
            echo '<script>self.close();</script>';
            exit;
        }
        $returnurl = !empty($_POST['returnurl']) ? $_POST['returnurl'] : '?';
        $location = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link'));
        // Scroll to the link which has been edited.
        $location .= '#' . smallHash($_POST['lf_linkdate']);
        // After saving the link, redirect to the page the user was on.
        header('Location: ' . $location);
        exit;
    }
    // -------- User clicked the "Cancel" button when editing a link.
    if (isset($_POST['cancel_edit'])) {
        // If we are called from the bookmarklet, we must close the popup:
        if (isset($_GET['source']) && ($_GET['source'] == 'bookmarklet' || $_GET['source'] == 'firefoxsocialapi')) {
            echo '<script>self.close();</script>';
            exit;
        }
        $returnurl = isset($_POST['returnurl']) ? $_POST['returnurl'] : '?';
        $returnurl .= '#' . smallHash($_POST['lf_linkdate']);
        // Scroll to the link which has been edited.
        $returnurl = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link'));
        header('Location: ' . $returnurl);
        // After canceling, redirect to the page the user was on.
        exit;
    }
    // -------- User clicked the "Delete" button when editing a link: Delete link from database.
    if (isset($_POST['delete_link'])) {
        if (!tokenOk($_POST['token'])) {
            die('Wrong token.');
        }
        // We do not need to ask for confirmation:
        // - confirmation is handled by JavaScript
        // - we are protected from XSRF by the token.
        $linkdate = $_POST['lf_linkdate'];
        $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
        unset($LINKSDB[$linkdate]);
        $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']);
        // save to disk
        // If we are called from the bookmarklet, we must close the popup:
        if (isset($_GET['source']) && ($_GET['source'] == 'bookmarklet' || $_GET['source'] == 'firefoxsocialapi')) {
            echo '<script>self.close();</script>';
            exit;
        }
        // Pick where we're going to redirect
        // =============================================================
        // Basically, we can't redirect to where we were previously if it was a permalink
        // or an edit_link, because it would 404.
        // Cases:
        //    - /             : nothing in $_GET, redirect to self
        //    - /?page        : redirect to self
        //    - /?searchterm  : redirect to self (there might be other links)
        //    - /?searchtags  : redirect to self
        //    - /permalink    : redirect to / (the link does not exist anymore)
        //    - /?edit_link   : redirect to / (the link does not exist anymore)
        // PHP treats the permalink as a $_GET variable, so we need to check if every condition for self
        // redirect is not satisfied, and only then redirect to /
        $location = "?";
        // Self redirection
        if (count($_GET) == 0 || isset($_GET['page']) || isset($_GET['searchterm']) || isset($_GET['searchtags'])) {
            if (isset($_POST['returnurl'])) {
                $location = $_POST['returnurl'];
                // Handle redirects given by the form
            } else {
                $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('delete_link'));
            }
        }
        header('Location: ' . $location);
        // After deleting the link, redirect to appropriate location
        exit;
    }
    // -------- User clicked the "EDIT" button on a link: Display link edit form.
    if (isset($_GET['edit_link'])) {
        $link = $LINKSDB[$_GET['edit_link']];
        // Read database
        if (!$link) {
            header('Location: ?');
            exit;
        }
        // Link not found in database.
        $data = array('link' => $link, 'link_is_new' => false, 'token' => getToken(), 'http_referer' => isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : '', 'tags' => $LINKSDB->allTags());
        $pluginManager->executeHooks('render_editlink', $data);
        foreach ($data as $key => $value) {
            $PAGE->assign($key, $value);
        }
        $PAGE->renderPage('editlink');
        exit;
    }
    // -------- User want to post a new link: Display link edit form.
    if (isset($_GET['post'])) {
        $url = cleanup_url($_GET['post']);
        $link_is_new = false;
        // Check if URL is not already in database (in this case, we will edit the existing link)
        $link = $LINKSDB->getLinkFromUrl($url);
        if (!$link) {
            $link_is_new = true;
            $linkdate = strval(date('Ymd_His'));
            // Get title if it was provided in URL (by the bookmarklet).
            $title = empty($_GET['title']) ? '' : escape($_GET['title']);
            // Get description if it was provided in URL (by the bookmarklet). [Bronco added that]
            $description = empty($_GET['description']) ? '' : escape($_GET['description']);
            $tags = empty($_GET['tags']) ? '' : escape($_GET['tags']);
            $private = !empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0;
            // If this is an HTTP(S) link, we try go get the page to extract the title (otherwise we will to straight to the edit form.)
            if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) {
                // Short timeout to keep the application responsive
                list($headers, $content) = get_http_response($url, 4);
                if (strpos($headers[0], '200 OK') !== false) {
                    // Retrieve charset.
                    $charset = get_charset($headers, $content);
                    // Extract title.
                    $title = html_extract_title($content);
                    // Re-encode title in utf-8 if necessary.
                    if (!empty($title) && strtolower($charset) != 'utf-8') {
                        $title = mb_convert_encoding($title, 'utf-8', $charset);
                    }
                }
            }
            if ($url == '') {
                $url = '?' . smallHash($linkdate);
                $title = 'Note: ';
            }
            $url = escape($url);
            $title = escape($title);
            $link = array('linkdate' => $linkdate, 'title' => $title, 'url' => $url, 'description' => $description, 'tags' => $tags, 'private' => $private);
        }
        $data = array('link' => $link, 'link_is_new' => $link_is_new, 'token' => getToken(), 'http_referer' => isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : '', 'source' => isset($_GET['source']) ? $_GET['source'] : '', 'tags' => $LINKSDB->allTags());
        $pluginManager->executeHooks('render_editlink', $data);
        foreach ($data as $key => $value) {
            $PAGE->assign($key, $value);
        }
        $PAGE->renderPage('editlink');
        exit;
    }
    if ($targetPage == Router::$PAGE_EXPORT) {
        // Export links as a Netscape Bookmarks file
        if (empty($_GET['selection'])) {
            $PAGE->renderPage('export');
            exit;
        }
        // export as bookmarks_(all|private|public)_YYYYmmdd_HHMMSS.html
        $selection = $_GET['selection'];
        if (isset($_GET['prepend_note_url'])) {
            $prependNoteUrl = $_GET['prepend_note_url'];
        } else {
            $prependNoteUrl = false;
        }
        try {
            $PAGE->assign('links', NetscapeBookmarkUtils::filterAndFormat($LINKSDB, $selection, $prependNoteUrl, index_url($_SERVER)));
        } catch (Exception $exc) {
            header('Content-Type: text/plain; charset=utf-8');
            echo $exc->getMessage();
            exit;
        }
        $now = new DateTime();
        header('Content-Type: text/html; charset=utf-8');
        header('Content-disposition: attachment; filename=bookmarks_' . $selection . '_' . $now->format(LinkDB::LINK_DATE_FORMAT) . '.html');
        $PAGE->assign('date', $now->format(DateTime::RFC822));
        $PAGE->assign('eol', PHP_EOL);
        $PAGE->assign('selection', $selection);
        $PAGE->renderPage('export.bookmarks');
        exit;
    }
    // -------- User is uploading a file for import
    if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=upload')) {
        // If file is too big, some form field may be missing.
        if (!isset($_POST['token']) || !isset($_FILES) || isset($_FILES['filetoupload']['size']) && $_FILES['filetoupload']['size'] == 0) {
            $returnurl = empty($_SERVER['HTTP_REFERER']) ? '?' : $_SERVER['HTTP_REFERER'];
            echo '<script>alert("The file you are trying to upload is probably bigger than what this webserver can accept (' . getMaxFileSize() . ' bytes). Please upload in smaller chunks.");document.location=\'' . escape($returnurl) . '\';</script>';
            exit;
        }
        if (!tokenOk($_POST['token'])) {
            die('Wrong token.');
        }
        importFile($LINKSDB);
        exit;
    }
    // -------- Show upload/import dialog:
    if ($targetPage == Router::$PAGE_IMPORT) {
        $PAGE->assign('token', getToken());
        $PAGE->assign('maxfilesize', getMaxFileSize());
        $PAGE->renderPage('import');
        exit;
    }
    // Plugin administration page
    if ($targetPage == Router::$PAGE_PLUGINSADMIN) {
        $pluginMeta = $pluginManager->getPluginsMeta();
        // Split plugins into 2 arrays: ordered enabled plugins and disabled.
        $enabledPlugins = array_filter($pluginMeta, function ($v) {
            return $v['order'] !== false;
        });
        // Load parameters.
        $enabledPlugins = load_plugin_parameter_values($enabledPlugins, $GLOBALS['plugins']);
        uasort($enabledPlugins, function ($a, $b) {
            return $a['order'] - $b['order'];
        });
        $disabledPlugins = array_filter($pluginMeta, function ($v) {
            return $v['order'] === false;
        });
        $PAGE->assign('enabledPlugins', $enabledPlugins);
        $PAGE->assign('disabledPlugins', $disabledPlugins);
        $PAGE->renderPage('pluginsadmin');
        exit;
    }
    // Plugin administration form action
    if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) {
        try {
            if (isset($_POST['parameters_form'])) {
                unset($_POST['parameters_form']);
                foreach ($_POST as $param => $value) {
                    $GLOBALS['plugins'][$param] = escape($value);
                }
            } else {
                $GLOBALS['config']['ENABLED_PLUGINS'] = save_plugin_config($_POST);
            }
            writeConfig($GLOBALS, isLoggedIn());
        } catch (Exception $e) {
            error_log('ERROR while saving plugin configuration:.' . PHP_EOL . $e->getMessage());
            // TODO: do not handle exceptions/errors in JS.
            echo '<script>alert("' . $e->getMessage() . '");document.location=\'?do=' . Router::$PAGE_PLUGINSADMIN . '\';</script>';
            exit;
        }
        header('Location: ?do=' . Router::$PAGE_PLUGINSADMIN);
        exit;
    }
    // -------- Otherwise, simply display search form and links:
    showLinkList($PAGE, $LINKSDB);
    exit;
}
예제 #29
0
function home_url()
{
    return dirname(page_url());
}
예제 #30
0
파일: page.php 프로젝트: nathggns/Light
<?php

defined('IN_CMS') or die('No direct access allowed.');
$title = page_title();
$content = page_content();
$url = page_url();
$time = false;
$page = true;
include 'includes/template.php';