public function output() { $this->load->library('lib'); $lib = new Lib(); $test = $lib->test(); $data['json'] = $test; $this->load->view('news/output', $data); }
public function view($viewname, $params) { $getpublic = new Lib(); $public = $getpublic->getPublic(); $checkuri = explode('/', $_SERVER['REQUEST_URI']); $uri = $checkuri[2]; $withparams = $params; $name = __DIR__ . '/../views/' . $viewname . '.php'; include __DIR__ . '/../views/MainView.php'; }
public function main() { $pageview = Lib::view('page'); $pages = $pageview->getPages(); $this->set('pageview', $pageview); $this->set('pages', $pages); }
public function display() { $this->main(); $body = $this->output(); $vars = array_merge(array('body' => $body, 'viewname' => $this->viewname, 'pagetitle' => $this->pagetitle, 'metakeywords' => $this->metakeywords, 'metadescription' => $this->metadescription, 'canonical' => $this->canonical, 'css' => $this->css, 'js' => $this->js), $this->vars); echo Lib::output('common/dom', $vars); }
public function main() { $this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com'); $cookie = Lib::cookie(); $identifier = $cookie->get(Lib::hash(Config::$userkey)); $user = Lib::table('user'); $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier)); $this->set('user', $user); $this->set('isLoggedIn', $isLoggedIn); $this->js[] = $isLoggedIn ? 'inbox' : 'login'; if ($isLoggedIn) { array_shift($this->js); $id = Req::get('id'); if (empty($id)) { Lib::redirect('index'); } $report = Lib::table('report'); if (!$report->load($id)) { $this->template = 'no-report'; return; } $report->init(); $assignees = Lib::model('user')->getProjectAssignees($report->project_id); $projectTable = Lib::table('project'); $projectTable->load($report->project_id); $this->set('report', $report); $this->set('assignees', $assignees); $this->set('project', $projectTable); } }
public function arhive() { try { $zip = new Zip(); $res = array(); foreach ($this->params->files as $n) { $file = BasefileModel::createFromPath($n, false); if ($file->type == 'folder') { $this->arhiveRecursive($zip, $file, $file->name); } else { $zip->addFile($file->getContent(), Lib::convert($file->name, Cfg::get('charset'), Cfg::get('charsetZip')), $file->ctime()); } $res[] = $file; } $c = count($res); $name = 'arhive.zip'; if ($c == 1) { $name = $res[0]->filename() . '.zip'; } $zip->sendZip($name); exit; } catch (Exception $ex) { Log::exception($ex); echo gettext('Не возможно получить архив'); } exit; }
public function execute() { $api = Lib::api('admin', array('response' => 'return', 'format' => 'php')); $type = Req::get('type'); if (!is_callable(array($api, $type))) { return Lib::redirect('error'); } $result = $api->{$type}(); $options = array('view' => 'admin'); $ref = Req::post('ref'); if (!$result['state']) { if (!empty($ref)) { $options['ref'] = $ref; } } else { $segments = explode('/', base64_decode(urldecode($ref))); $base = array_shift($segments); $type = array_shift($segments); $subtype = array_shift($segments); if (!empty($type)) { $options['type'] = $type; } if (!empty($subtype)) { $options['subtype'] = $subtype; } } Lib::redirect('admin', $options); }
public function saveAssignees() { $keys = array('project', 'setting'); if (!Req::haspost($keys)) { return $this->fail('Insufficient data.'); } $identifier = Lib::cookie(Lib::hash(Config::$userkey)); $user = Lib::table('user'); $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier)); if (!$isLoggedIn || $user->role != USER_ROLE_ADMIN) { return $this->fail('You are not authorized.'); } $project = Req::post('project'); $setting = json_decode(Req::post('setting')); $projectTable = Lib::table('project'); if ($project !== 'all' && $project !== '-1' && !$projectTable->load(array('name' => $project))) { return $this->fail('No such project.'); } if ($project !== 'all') { $projectAssignee = Lib::table('project_assignee'); $projectAssignee->load(array('user_id' => $setting->id, 'project_id' => $projectTable->id)); if ($setting->value) { $projectAssignee->store(); } else { $projectAssignee->delete(); } } return $this->success(); }
/** * Initializes config given the assosiative array of **/ public static function init($config) { if (isset(self::$config)) { trigger_error("Helpers is already initialized", E_USER_ERROR); } self::$config = $config; }
public function display() { $this->main(); $body = $this->output(); $vars = array_merge(array('body' => $body, 'css' => $this->css, 'js' => $this->js, 'googlefont' => $this->googlefont, 'meta' => $this->meta), $this->vars); echo Lib::output('common/html', $vars); }
public function main() { $this->set('backgroundPattern', '1001000110010111011001101100110111110000010101111101111111001011011001100100'); $this->set('hideHeader', true); $this->set('pagetitle', 'Hello World'); $twitterHelper = Lib::helper('twitter'); $tweet = $twitterHelper->getLatestTweet('jasonkeorey'); $this->set('tweet', $tweet); $now = new DateTime(); $currentDay = (int) $now->format('j'); $currentMonth = (int) $now->format('n'); $startYear = $endYear = $currentYear = (int) $now->format('Y'); if ($currentMonth < 7 || $currentMonth === 7 && $currentDay < 10) { $startYear = $currentYear - 1; } else { $endYear = $currentYear + 1; } $startDate = new DateTime($startYear . '-07-10'); $endDate = new DateTime($endYear . '-07-10'); $totalDays = ($endDate->format('U') - $startDate->format('U')) / (60 * 60 * 24); $elapsedDays = floor(($now->format('U') - $startDate->format('U')) / (60 * 60 * 24)); $expPercentage = floor($elapsedDays / $totalDays * 100); $level = $currentYear - 1988; $this->set('expPercentage', $expPercentage); $this->set('level', $level); }
static function Instance() { if (self::$_instance == NULL) { self::$_instance = new Lib(); } return self::$_instance; }
public function __construct() { $expired = time() - Lib::GetSetting('sess.gc_maxlifetime'); $users = DBA::Open()->Query("SELECT * FROM " . USERS . " WHERE birthday != 0"); $this->count = $users->NumRows(); $this->users = $users->GetIterator(); $this->i = 1; }
public function __construct($data, $success = true, $message = '', $resultdata = true, $code = true) { $this->success = $success; $this->message = $message; $this->data = Lib::code($data); if ($resultdata) { $this->data = array('success' => $this->success, 'message' => $this->message, 'data' => $this->data); } }
public function to($userid) { $userTable = Lib::table('user'); $userTable->load($userid); $table = Lib::table('slackuser'); if ($table->load(array('email' => $userTable->email))) { $this->channel = '@' . $table->name; } }
public function main() { $filterProject = Req::get('project'); if (empty($filterProject)) { $this->template = 'empty-project'; return; } $projectTable = Lib::table('project'); if (!$projectTable->load(array('name' => $filterProject))) { $this->set('name', $filterProject); $this->template = 'new-project'; return; } $this->meta[] = array('name' => 'google-signin-client_id', 'content' => Config::$googleClientId . '.apps.googleusercontent.com'); $cookie = Lib::cookie(); $identifier = $cookie->get(Lib::hash(Config::$userkey)); $user = Lib::table('user'); $isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier)); $this->set('user', $user); $this->set('filterProject', $filterProject); $this->set('filterSettingsProject', $filterProject); $this->set('isLoggedIn', $isLoggedIn); if (!$isLoggedIn) { $this->js[] = 'login'; } if ($isLoggedIn) { $this->js[] = 'inbox'; $this->js[] = 'settings'; array_shift($this->js); $userModel = Lib::model('user'); $assignees = $userModel->getProjectAssignees($projectTable->id); $users = $userModel->getUsers(); $filterState = $cookie->get('filter-state', 'pending'); $filterAssignee = $cookie->get('filter-assignee', empty($assignees[$user->id]) ? 'all' : $user->id); $filterSort = $cookie->get('filter-sort', 'asc'); $reportModel = Lib::model('report'); $reports = $reportModel->getItems(array('state' => constant('STATE_' . strtoupper($filterState)), 'assignee_id' => $filterAssignee, 'order' => 'date', 'direction' => $filterSort, 'project_id' => $projectTable->id)); $userSettingsTable = Lib::table('user_settings'); if (!$userSettingsTable->load(array('user_id' => $user->id, 'project_id' => $projectTable->id))) { $userSettingsTable->load(array('user_id' => $user->id, 'project_id' => 0)); } $userSettings = $userSettingsTable->getData(); if ($userSettings['color'] !== 'cyan' && $userSettings['color'] !== 'custom') { $this->css[] = 'theme-' . str_replace(' ', '', $userSettings['color']); } $categories = Lib::model('category')->getCategories(['projectid' => $projectTable->id]); $this->set('filterState', $filterState); $this->set('filterAssignee', $filterAssignee); $this->set('filterSort', $filterSort); $this->set('reports', $reports); $this->set('assignees', $assignees); $this->set('userSettings', $userSettings); $this->set('users', $users); $this->set('projectTable', $projectTable); $this->set('categories', $categories); } }
public static function send($data) { if (!$data['to'] || !$data['text']) { return false; } $slackTable = Lib::table('slackuser'); if ($slackTable->load(['email' => $data['to']])) { // Send slack $slackMessage = Lib::helper('slack')->newMessage(); $slackMessage->channel = '@' . $slackTable->name; $slackMessage->text = $data['text']; $messageKeys = ['username', 'icon_emoji']; foreach ($messageKeys as $mKey) { if (!empty($data[$mKey])) { $slackMessage->{$mKey} = $data[$mKey]; } } if (!empty($data['attachments'])) { $attachmentKeys = ['fallback', 'color', 'title', 'title_link', 'text']; foreach ($data['attachments'] as $attach) { $attachment = $slackMessage->newAttachment(); foreach ($attachmentKeys as $aKey) { if (!empty($attach[$aKey])) { $attachment->{$aKey} = $attach[$aKey]; } } if (!empty($attach['fields'])) { foreach ($attach['fields'] as $fieldKey => $fieldValue) { $attachment->newField($fieldKey, $fieldValue); } } } } $slackMessage->send(); } else { // Send email $mail = Lib::helper('mail')->newMessage(); $mail->recipientEmail = $data['to']; $mail->subject = 'Report Notification'; $mail->body = '<p>' . $data['text'] . '</p>'; $attachments = ''; foreach ($data['attachments'] as $attach) { if (empty($attach['title']) || empty($attach['title_link'])) { continue; } $attachments .= '<p><a href="' . $attach['title_link'] . '">' . $attach['title'] . '</a></p>'; } if (!empty($attachments)) { $mail->body .= '<p><strong><u>Attachments</u></strong></p>'; $mail->body .= $attachments; } $mail->body .= '<p style="font-size: 10px;">Do not reply to this email.</p>'; $mail->send(); } return true; }
public function route($segments = array()) { $name = array_shift($segments); $method = array_shift($segments); $api = Lib::api($name); if (!is_callable(array($api, $method))) { return Lib::api()->fail(); } $api->{$method}($segments); }
function __construct() { parent::__construct(); $servers = array(); foreach ($this->e->mcache['servers'] as $server) { $servers[] = array($server['host'], $server['port'], $server['weight']); } $this->_conn = new Memcached(); $this->_conn->addServers($servers); }
public function initTables() { $db = Lib::db(); foreach (glob(Config::getBasePath() . '/schemas/*.sql') as $file) { $sql = file_get_contents($file); $db->query($sql); } echo 'Completed'; exit; }
public function getCategory() { static $categories = []; if (!isset($categories[$this->category_id])) { $category = Lib::table('category'); $category->load($this->category_id); $categories[$this->category_id] = $category; } return $categories[$this->category_id]; }
public static function env() { if (Req::hasget('development')) { Lib::cookie()->set('development', Req::get('development')); } if (Lib::cookie()->get('development')) { return 'development'; } return self::$env; }
public function attach($key, $file) { $fileObject = Lib::file($file['tmp_name'], $file['name']); $copiedFile = $fileObject->copy(Config::getBasePath() . '/' . Config::$attachmentFolder, $key . '-' . $file['name']); $attachmentTable = Lib::table('comment_attachment'); $attachmentTable->link($this); $attachmentTable->filename = $copiedFile->filename; $attachmentTable->name = $file['name']; $attachmentTable->store(); }
function __construct() { parent::__construct(); $servers = array(); foreach ($this->e->mcache->servers as $server) { $servers[] = array($server->host, $server->port, $server->weight); } $this->_conn = new Memcached(); $this->_conn->addServers($servers); }
public static function request($key = null, $default = null) { if (empty($key)) { $data = array(); foreach ($_REQUEST as $k => $v) { $data[$k] = Lib::escape($v); } return $data; } return self::hasrequest($key) ? Lib::escape($_REQUEST[$key]) : $default; }
public function form() { $ref = Req::get('ref'); $this->set('ref', $ref); $model = Lib::model('admin'); if (!$model->hasAdmins()) { $this->template = 'formcreate'; return; } $this->template = 'form'; }
function __construct() { parent::__construct(); $this->_post = $_POST; $this->_rules = array(); $this->_errors = array(); $this->_min_len_rules = array(); $this->_max_len_rules = array(); $this->_valid_mail_rules = array(); $this->_curname = ''; }
public function getLatestPosts() { Lib::load('pagination'); $query = "\r\nSELECT\r\n\t[blog_posts]p.[post_id] AS [post_id],\r\n\t[blog_posts]p.[post_slug] AS [post_slug],\r\n\t[blog_posts]p.[post_date] AS [post_date],\r\n\t[blog_posts]p.[post_header] AS [post_header],\r\n\t[blog_posts]p.[category_id] AS [category_id],\r\n\t[blog_categories]p.[category_slug] AS [category_slug],\r\n\t[blog_categories]p.[category_header] AS [category_header],\r\n\t[blog_posts_contents]p.[post_prologue] AS [post_prologue],\r\n\tcount([blog_comments]p.[comment_id]) AS [comments_count]\r\nFROM [blog_posts]p\r\nLEFT JOIN [blog_categories]p\r\n\tON [blog_posts]p.[category_id] == [blog_categories]p.[category_id]\r\nLEFT JOIN [blog_posts_contents]p\r\n\tON [blog_posts]p.[post_id] == [blog_posts_contents]p.[post_id]\r\nLEFT JOIN [blog_comments]p\r\n\tON [blog_posts]p.[post_id] == [blog_comments]p.[post_id]\r\nGROUP BY [blog_posts]p.[post_id]\r\nORDER BY [blog_posts]p.[post_date]"; $p = new Pagination(array('query' => $query, 'url' => './archive/%page/', 'perPage' => 1, 'urlFirst' => './')); if (!$p->make()) { throw new Exception('The latest posts could not be selected.'); } else { $this->fetchPosts($p, false); } }
public function update($obj) { try { $sql = "UPDATE " . $this->table . " set\n valorUM = :valorUM,\n valorDois = :valorDois\n WHERE id = :id"; $p_sql = Conexao::getInstance()->prepare($sql); $p_sql->bindValue(':valorUM', $obj->getValorUM()); $p_sql->bindValue(':valorDois', $obj->getValorDois()); return $p_sql->execute(); } catch (Exception $e) { Lib::warning($e); } }
public function copy($target, $filename = '') { if (empty($filename)) { $filename = $this->filename; } if (!file_exists($target)) { mkdir($target, 0777, true); } if (!copy($this->path, $target . '/' . $filename)) { return false; } return Lib::file($target . '/' . $filename, $filename); }