function __construct() { require_once 'functions/loader.php'; $loader = new loader(); $config = $loader->load('configuration'); require_once 'functions/classes/coinbase/Coinbase.php'; $this->provider = Coinbase::withApiKey($config->api_key(), $config->api_secret()); }
function __construct() { require_once 'functions/loader.php'; $loader = new loader(); $config = $loader->load('configuration'); $this->key = $config->api_key(); $this->coin = $config->coin_code(); }
function logIP() { $time = time(); require_once 'functions/loader.php'; $loader = new loader(); $config = $loader->load('configuration'); $ip = $_SERVER[$config->ip_forward()]; $this->saveLog($ip, $time); }
function __construct() { require_once 'functions/loader.php'; $loader = new loader(); $config = $loader->load('configuration'); if ($config->debug_mode()) { // Show warnings and errors. error_reporting(E_ERROR | E_WARNING); } else { // Hide all errors, warnings, notices, etc from view of public. error_reporting(0); } }
function __construct() { require_once 'functions/loader.php'; $loader = new loader(); $config = $loader->load('configuration'); switch ($config->api_provider()) { case 'coinbase': $this->provider = $loader->load('coinbaseapi'); break; default: echo '<div class="errormsg">The API provided is not valid, please set up a valid API provider in the configuration.</div>'; $this->provider = new fakeapi(); break; } }
public function invoices() { // Get page $page = is_numeric(input::get('page')) && input::get('page') > 0 ? input::get('page') : 1; // Parameters $params = array('join_columns' => array('`t`.`user_id`=' . session::item('user_id'))); // Process query string $qstring = $this->parseQuerystring(config::item('invoices_per_page', 'billing'), session::item('total_transactions')); // Get invoices $invoices = array(); if (session::item('total_transactions')) { $invoices = $this->transactions_model->getTransactions($params['join_columns'], '', $qstring['limit']); } else { view::setInfo(__('no_invoices_user', 'billing_transactions')); } // Set pagination $config = array('base_url' => config::siteURL('billing/invoices?'), 'total_items' => session::item('total_transactions'), 'items_per_page' => config::item('invoices_per_page', 'billing'), 'current_page' => $page, 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('invoices' => $invoices, 'pagination' => $pagination)); // Set title view::setTitle(__('invoices', 'billing_transactions')); // Load view view::load('billing/invoices'); }
public function addScalableButtonCSS() { $basepath = base::baseUrl(); echo "<style type=\"text/css\"> @import \"{$basepath}/core/styles/btn.php\"; </style>"; $lib = loader::load("library"); $lib->jsm->loadButtonJS(); }
function _createtable($sql) { $db =& loader::database(); $type = strtoupper(preg_replace("/^\\s*CREATE TABLE\\s+.+\\s+\\(.+?\\).*(ENGINE|TYPE)\\s*=\\s*([a-z]+?).*\$/isU", "\\2", $sql)); $type = in_array($type, array('MYISAM', 'HEAP', 'MEMORY')) ? $type : 'MYISAM'; return preg_replace("/^\\s*(CREATE TABLE\\s+.+\\s+\\(.+?\\)).*\$/isU", "\\1", $sql) . ($db->version() > '4.1' ? " ENGINE={$type} DEFAULT CHARSET=utf8" : " TYPE={$type}"); }
public static function instance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
/** * render Add Blog dialog */ public function render() { if ($_REQUEST['akID']) { $akID = $_REQUEST['akID']; if ($_REQUEST['akID']) { if ($_REQUEST['akID'] == 'same_tags') { $key = CollectionAttributeKey::getByHandle('tags'); $akID = $key->getAttributeKeyID(); } } $html = '<fieldset>'; $db = loader::db(); $r = $db->execute("SELECT * FROM atSelectOptions WHERE akID = ?", array($akID)); while ($row = $r->fetchrow()) { $id = $row['ID']; $options[$id] = $row['value']; } if (is_array($options)) { foreach ($options as $key => $option) { $html .= '<input type="checkbox" name="fields[]" value="' . $option . '">' . $option . '<br/>'; } } $html .= '</fieldset>'; //print json_encode($options); print $html; exit; } }
public function render() { $id = $this->options['id']; $type = $this->options['type']; $data = $this->options['data']; $style = $this->options['style']; $class = $this->options['class']; $callback = $this->options['callback']; $name = $this->options['name']; $theme = $this->options['theme']; $refreshinterval = $this->options['refreshinterval']; $position = $this->options['position']; if ($type == "text" || $type == "html") { //process text based widgets $output = "<div id='{$id}' class='widget {$class}' style='{$style}'>"; if (!empty($name)) { $output .= "<h2 class='widgettitle'>{$name}</h2>"; } $output .= "<div class='widgetdata'>{$data}</div>"; $output .= "</div>"; } else { if ($type == "rss") { $url = $data; $config = loader::load("config"); $googleApiKey = $config->google_api; $output = "\n\t\t\t\t\n\t\t\t\t<div id='{$id}' class='widget {$class}' style='{$style}'>\n\t\t\t\t<h2 class='widgettitle'>{$name}</h2>\n\t\t\t\t<div class='widgetdata'>\n\t\t\t\t<script type=\"text/javascript\" src=\"http://www.google.com/jsapi?key={$googleApiKey}\"></script>\n\t\t\t <script type=\"text/javascript\">\n\t\t\t\t \$('#{$id}').gFeed({ \n\t\t\t\t url: '{$data}', \n\t\t\t\t title: ''\n\t\t\t\t }); \n\t\t\t </script>\n\t\t\t </div>\n\t\t\t "; } } return $output; }
public function manage() { // Assign user from session to variable $user = session::section('session'); // Get fields $fields = array(); foreach (config::item('usertypes', 'core', 'keywords') as $categoryID => $keyword) { $fields[$categoryID] = $this->fields_model->getFields('users', $categoryID, 'view', 'in_list'); } // Parameters $params = array('total' => $user['total_blocked'], 'profiles' => true); // Process query string $qstring = $this->parseQuerystring($params['total']); // Get blocked users $users = array(); if ($params['total']) { $users = $this->users_blocked_model->getUsers(session::item('user_id'), $qstring['order'], $qstring['limit'], $params); } else { view::setInfo(__('no_blocked_users', 'users_blocked')); } // Set pagination $config = array('base_url' => config::siteURL('users/blocked/manage?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => config::item('blocked_per_page', 'users'), 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('user' => $user, 'users' => $users, 'fields' => $fields, 'pagination' => $pagination)); // Set title view::setTitle(__('blacklist', 'users')); // Load view view::load('users/blocked/manage'); }
public function sendTemplate($keyword, $email, $tags = array(), $language = '') { loader::model('system/emailtemplates'); if (!$language) { $language = config::item('language_id', 'system'); } if (is_numeric($language)) { $language = config::item('languages', 'core', 'keywords', $language); } elseif (!in_array($language, config::item('languages', 'core', 'keywords'))) { return false; } if (!($template = config::item($keyword . '_' . $language, '_system_emails_cache'))) { if (!($template = $this->cache->item('core_email_template_' . $keyword . '_' . $language))) { $template = $this->emailtemplates_model->prepareTemplate($keyword, $language); if (count($template) == 3) { if ($template[$keyword]['active']) { $template = array('subject' => $template[$keyword]['subject'], 'message_html' => utf8::trim($template['header']['message_html'] . $template[$keyword]['message_html'] . $template['footer']['message_html']), 'message_text' => utf8::trim($template['header']['message_text'] . "\n\n" . $template[$keyword]['message_text'] . "\n\n" . $template['footer']['message_text'])); } else { $template = 'none'; } } else { error::show('Could not fetch email template from the database: ' . $keyword); } $this->cache->set('core_email_template_' . $keyword . '_' . $language, $template, 60 * 60 * 24 * 30); } config::set(array($keyword . '_' . $language => $template), '', '_system_emails_cache'); } $retval = true; if (is_array($template) && $template) { $retval = $this->sendEmail($email, $template['subject'], $template['message_text'], $template['message_html'], $tags); } return $retval; }
function __construct($base = null) { if (!$base) { $base = loader::get_root() . '../cache/'; } $this->set_root($base); }
/** * 加载语言文件 */ public static function load() { $agrs = func_get_args(); for ($i = 0, $n = count($agrs); $i < $n; $i++) { ($lang = loader::language($agrs[$i])) && (self::$sfLang = array_merge(self::$sfLang, (array) $lang)); } }
function fetch($file, $templateid = null, $tpldir = null) { global $base_path; $output =& loader::lib('output'); $params = $output->getAll(); extract($params); if (!$templateid) { $templateid = TEMPLATEID; } $style_path = $base_path . TPLDIR . '/'; $setting =& loader::model('setting'); $theme_config = $setting->get_conf('theme_' . $templateid, array()); if (isset($_config)) { if ($theme_config) { $_config = array_merge($_config, $theme_config); } } else { $_config = $theme_config; } $footer = '<script src="' . $statics_path . 'js/common.js" type="text/javascript"></script>'; if (isset($loggedin) && $loggedin) { $footer .= '<script src="' . $statics_path . 'js/admin.js" type="text/javascript"></script>'; } $footer .= 'Pow' . 'ered by <a href="http://mei' . 'upic.m' . 'eiu.cn/" target="_blank">Mei' . 'uPic ' . MPIC_VERSION . '</a> '; $footer .= safe_invert($setting->get_conf('site.footer'), true); $show_process_info = $setting->get_conf('system.show_process_info'); ob_start(); include $this->template($file, $templateid, $tpldir); $content = ob_get_clean(); return $content; }
public function view() { $ct = CollectionType::getByHandle('pb_post'); $ctID = $ct->getPageTypeID(); if ($this->targetCID > 0) { $target = Page::getByID($this->targetCID); $this->set('target', $target); } else { $target = Page::getByPath('/blogsearch'); $this->set('target', $target); } if (!$this->page_type) { $this->page_type = 'pb_post'; } $page_type = trim($this->page_type); $query = "SELECT MIN(cv.cvDatePublic) as firstPost\n\t\t\tFROM CollectionVersions cv\n INNER JOIN Pages pp ON cv.cID = pp.cID\n\t\t\tINNER JOIN PageTypes pt ON pp.ptID = pt.ptID\n\t\t\tWHERE pt.ptHandle = ? and cv.cvIsApproved = 1\n\t\t\tAND cv.cvDatePublic < CURDATE()\n ORDER BY firstPost ASC"; $db = Loader::db(); $firstPost = $db->getOne($query, array($page_type)); if (strlen($firstPost)) { $firstPost = new \DateTime($firstPost); $this->set('firstPost', $firstPost); } $this->set('numMonths', $this->numMonths); $this->set('navigation', loader::helper('navigation')); }
public function __construct($config = array()) { parent::__construct(); $this->config = $config; $this->config['driver'] = 'recaptcha'; loader::library('captcha', $this->config); }
public static function getPictures($params = array()) { if (!session::permission('users_groups_browse', 'users') && !session::permission('users_types_browse', 'users')) { return ''; } loader::model('pictures/pictures'); $template = isset($params['template']) ? $params['template'] : 'pictures/helpers/pictures'; $user = isset($params['user']) && $params['user'] ? $params['user'] : array(); $userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0); $params['albums'] = true; if ($userID) { $params['join_columns'][] = '`p`.`user_id`=' . $userID; } if (!$userID || $userID != session::item('user_id')) { if ($userID) { $params['privacy'] = $userID; } else { $params['join_columns'][] = '`a`.`public`=1'; $params['join_columns'][] = '`u`.`verified`=1'; $params['join_columns'][] = '`u`.`active`=1'; $params['join_columns'][] = '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')'; $params['join_columns'][] = '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')'; } } $params['limit'] = isset($params['limit']) ? $params['limit'] : 10; $params['order'] = isset($params['order']) ? $params['order'] : ''; $pictures = codebreeder::instance()->pictures_model->getPictures('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params); view::assign(array('pictures' => $pictures, 'user' => $user, 'params' => $params), '', $template); return view::load($template, array(), 1); }
/** * @param array * server = path to file */ function connect() { if (!class_exists('SQLite3', 0)) { throw new dbal_exception('Sqlite support not compiled with PHP!'); } if (empty($this->dbname)) { throw new dbal_exception('Sqlite connect empty database!'); } // check is relative path (to site root) // $dbname = (substr($this->dbname, 0, 1) == '/') // ? substr($this->dbname, 1) // : ('../' . $this->dbname); $this->_db_file = loader::get_root($this->dbname); if (!file_exists($this->_db_file)) { throw new dbal_exception('No database: ' . $this->_db_file); } core::dprint(array('CONNECT %s %s', __CLASS__, $this->_db_file), core::E_SQL); $error = ''; $this->_connect_id = new SQLite3($this->_db_file, SQLITE3_OPEN_READWRITE); if ($this->_connect_id) { $this->_connect_id->exec('PRAGMA short_column_names = 1'); $this->_connect_id->exec('PRAGMA encoding = "UTF-8"'); } else { throw new dbal_exception('Cant connect to database ' . $this->_db_file); } return $this->_connect_id; }
public function postBlog($items, $users) { $stream = array(); loader::model('blogs/blogs'); $params = array('select_users' => false); // Get blogs $columns = array('`b`.`blog_id` IN (' . implode(',', array_keys($items)) . ')'); $blogs = codebreeder::instance()->blogs_model->getBlogs('in_list', $columns, array(), false, count($items), $params); foreach ($items as $itemID => $data) { if (isset($blogs[$itemID]) && isset($users[$blogs[$itemID]['user_id']])) { foreach ($data as $actionID => $item) { $stream[$itemID][$actionID]['html'] = view::load('blogs/timeline/blog', array('user' => $users[$blogs[$itemID]['user_id']], 'blog' => $blogs[$itemID], 'params' => $item['params']), true); $stream[$itemID][$actionID]['rating']['total_votes'] = $blogs[$itemID]['total_votes']; $stream[$itemID][$actionID]['rating']['total_score'] = $blogs[$itemID]['total_score']; $stream[$itemID][$actionID]['rating']['total_rating'] = $blogs[$itemID]['total_rating']; $stream[$itemID][$actionID]['rating']['total_likes'] = $blogs[$itemID]['total_likes']; $stream[$itemID][$actionID]['rating']['type'] = config::item('blog_rating', 'blogs'); $stream[$itemID][$actionID]['comments']['total_comments'] = $blogs[$itemID]['total_comments']; $stream[$itemID][$actionID]['comments']['privacy'] = $blogs[$itemID]['comments']; $stream[$itemID][$actionID]['comments']['post'] = $blogs[$itemID]['comments'] && codebreeder::instance()->users_model->getPrivacyAccess($blogs[$itemID]['user_id'], $blogs[$itemID]['comments'], false, $users[$blogs[$itemID]['user_id']]['friends'] ? 1 : 0) ? true : false; } } } return $stream; }
public function view() { // Get URI vars $newsID = (int) uri::segment(3); // Get news entry if (!$newsID || !($news = $this->news_model->getEntry($newsID, 'in_view')) || !$news['active']) { error::show404(); } // Do we have views enabled? if (config::item('news_views', 'news')) { // Update views counter $this->news_model->updateViews($newsID); } // Load ratings if (config::item('news_rating', 'news') == 'stars') { // Load votes model loader::model('comments/votes'); // Get votes $news['user_vote'] = $this->votes_model->getVote('news', $newsID); } elseif (config::item('news_rating', 'news') == 'likes') { // Load likes model loader::model('comments/likes'); // Get likes $news['user_vote'] = $this->likes_model->getLike('news', $newsID); } // Assign vars view::assign(array('newsID' => $newsID, 'news' => $news)); // Set title view::setTitle($news['data_title']); // Set meta tags view::setMetaDescription($news['data_meta_description']); view::setMetaKeywords($news['data_meta_keywords']); // Load view view::load('news/view'); }
function __constuct() { parent::__constuct(); // Call the Model constructor loader::database(); // Connect to current database setting. }
public function results() { if (!input::get('search_id')) { $this->index(); return; } // Parameters $params = array('join_columns' => array('`u`.`verified`=1', '`u`.`active`=1', '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')', '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')'), 'join_items' => array()); // Process filters $params = $this->parseCounters($params); // Process query string $qstring = $this->parseQuerystring($params['max']); // Get users $users = array(); if ($params['total']) { $users = $this->users_model->getUsers('in_list', isset($params['values']['type_id']) ? $params['values']['type_id'] : 0, $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']); } // Get fields $fields = $this->fields_model->getFields('users', isset($params['values']['type_id']) ? $params['values']['type_id'] : 0, 'view', 'in_list'); // Set pagination $config = array('base_url' => config::siteURL('users/results?' . $qstring['url']), 'total_items' => $params['total'], 'max_items' => config::item('max_search_results', 'system'), 'items_per_page' => config::item('users_per_page', 'users'), 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('users' => $users, 'fields' => $fields, 'pagination' => $pagination)); // Set meta tags $this->metatags_model->set('users', 'users_search_results'); // Set title view::setTitle(__('search_results', 'system'), false); // Assign actions view::setAction('users?' . substr($qstring['url'], 0, -1), __('search_modify', 'system'), array('class' => 'icon-text icon-users-search-edit')); // Load view view::load('users/index'); }
public function __construct() { if ($this->auth) { $this->auth(); } loader::lib("view"); }
public function deleteComments($resource, $itemID, $limit = false) { // Get resource ID if (!($resourceID = config::item('resources', 'core', $resource, 'resource_id')) || !$itemID) { return false; } if (!is_array($itemID)) { $itemID = array($itemID); } $commentIDs = array(); // Get comment IDs $result = $this->db->query("SELECT * FROM `:prefix:core_comments` WHERE `resource_id`=? AND `item_id` IN (?)", array($resourceID, $itemID))->result(); foreach ($result as $comment) { $commentIDs[] = $comment['comment_id']; } // Delete reports loader::model('reports/reports'); $this->reports_model->deleteReports('comment', $commentIDs); // Delete comments if ($retval = $this->db->delete('core_comments', array('resource_id' => $resourceID, 'item_id' => $itemID), $limit)) { // Action hook hook::action('comments/delete_multiple', $resourceID, $itemID); } return $retval; }
public function deleteType($typeID, $type) { loader::library('dbforge'); $this->dbforge->dropTable(':prefix:users_data_' . $type['keyword']); // Delete user type if ($retval = $this->db->delete('users_types', array('type_id' => $typeID), 1)) { // Update order IDs $this->db->query("UPDATE `:prefix:users_types` SET `order_id`=`order_id`-1 WHERE `order_id`>?", array($type['order_id'])); // Select fields IDs $fieldIDs = array(); foreach ($this->db->query("SELECT `field_id`, `category_id`, `keyword` FROM `:prefix:core_fields` WHERE `category_id`=?", array($typeID))->result() as $field) { $fieldIDs[] = $field['field_id']; } // Do we have any field IDs? if ($fieldIDs) { // Delete field items $this->db->query("DELETE FROM `:prefix:core_fields_items` WHERE `field_id` IN (" . implode(',', $fieldIDs) . ")"); } // Delete fields $this->db->delete('core_fields', array('category_id' => $typeID)); // Action hook hook::action('users/types/delete', $typeID, $type); } $this->cache->cleanup(); return $retval; }
function run() { /**@var tf_sat $sat */ $sat = core::module('sat'); $site = $sat->get_current_site(); $json_file = loader::get_public('assets/' . $site->domain . '.json'); $last_mod = @filemtime($json_file); $tree_last_mod = 0; if ($last_mod) { $last_node = $sat->get_node_handle()->set_where('site_id = %d', $sat->get_current_site_id())->set_order('updated_at DESC')->load_first(); $tree_last_mod = $last_node ? $last_node->updated_at : 0; core::dprint(__METHOD__ . ': cached'); // uptodate if ($tree_last_mod <= $last_mod) { $this->renderer->set_ajax_answer(file_get_contents($json_file))->ajax_flush(); return; } } core::dprint(__METHOD__ . ': fetch!'); $tree = $sat->get_current_site_tree(); $allowedKeys = array('title', 'url'); array_walk($tree, function (&$v) use($allowedKeys) { $v = array_intersect_key($v, array_flip($allowedKeys)); }); $tree = array_values($tree); // cache file_put_contents($json_file, functions::json_encode($tree)); $this->renderer->set_ajax_answer($tree)->ajax_flush(); }
private function __get($var) { if ($var == "params") { return $this->params; } return loader::load($var); }
public function deleteEntry($newsID, $news) { // Delete entry $retval = $this->fields_model->deleteValues('news', $newsID); if ($retval) { // Delete comments if ($news['total_comments']) { loader::model('comments/comments'); $this->comments_model->deleteComments('news', $newsID, $news['total_comments']); } // Delete likes if ($news['total_likes']) { loader::model('comments/likes'); $this->likes_model->deleteLikes('news', $newsID, $news['total_likes']); } // Delete votes if ($news['total_votes']) { loader::model('comments/votes'); $this->votes_model->deleteVotes('news', $newsID, $news['total_votes']); } // Action hook hook::action('news/delete', $newsID, $news); } return $retval; }