public function index() { // Parameters $params = array('join_columns' => array('`n`.`active`=1'), 'join_items' => array()); // Process filters $params = $this->parseCounters($params); // Process query string $qstring = $this->parseQuerystring(config::item('news_per_page', 'news'), $params['max']); // Get news $news = array(); if ($params['total']) { $news = $this->news_model->getEntries('in_list', $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']); } // Set pagination $config = array('base_url' => config::siteURL('news?' . $qstring['url']), 'total_items' => $params['total'], 'max_items' => $params['max'], 'items_per_page' => config::item('news_per_page', 'news'), 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('news' => $news, 'pagination' => $pagination)); // Set meta tags $this->metatags_model->set('news', 'news_index'); // Set title view::setTitle(__(config::item('news_blog', 'news') ? 'blog' : 'news', 'system_navigation'), false); // Assign actions if (session::permission('news_search', 'news') && ($params['total'] || input::post_get('do_search'))) { view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#news-search\').toggle();return false;')); } // Load view view::load('news/index'); }
public function browse() { // Parameters $params = array('join_columns' => array(), 'join_items' => array()); // Process filters $params = $this->parseCounters($params); // Process query string $qstring = $this->parseQuerystring($params['total']); // Actions $actions = array(0 => __('select', 'system'), 'approve' => __('approve', 'system'), 'decline' => __('decline', 'system'), 'delete' => __('delete', 'system')); // Check form action if (input::post('do_action')) { // Delete selected blogs if (input::post('action') && isset($actions[input::post('action')]) && input::post('blog_id') && is_array(input::post('blog_id'))) { foreach (input::post('blog_id') as $blogID) { $blogID = (int) $blogID; if ($blogID && $blogID > 0) { $this->action(input::post('action'), $blogID); } } } // Success view::setInfo(__('action_applied', 'system')); router::redirect('cp/plugins/blogs?' . $qstring['url'] . 'page=' . $qstring['page']); } // Get blogs $blogs = array(); if ($params['total']) { $blogs = $this->blogs_model->getBlogs('in_list', $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']); } // Create table grid $grid = array('uri' => 'cp/plugins/blogs', 'keyword' => 'blogs', 'header' => array('check' => array('html' => 'blog_id', 'class' => 'check'), 'data_title' => array('html' => __('name', 'system'), 'class' => 'name', 'sortable' => true), 'user' => array('html' => __('user', 'system'), 'class' => 'user'), 'post_date' => array('html' => __('post_date', 'system'), 'class' => 'date', 'sortable' => true), 'status' => array('html' => __('status', 'system'), 'class' => 'status'), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array()); // Create grid content foreach ($blogs as $blog) { if ($blog['active'] == 1) { $status = html_helper::anchor('cp/plugins/blogs/decline/' . $blog['blog_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('active', 'system'), array('class' => 'label small success')); } else { $status = html_helper::anchor('cp/plugins/blogs/approve/' . $blog['blog_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], $blog['active'] ? __('pending', 'system') : __('inactive', 'system'), array('class' => 'label small ' . ($blog['active'] ? 'info' : 'important'))); } $grid['content'][] = array('check' => array('html' => $blog['blog_id']), 'data_title' => array('html' => html_helper::anchor('cp/plugins/blogs/edit/' . $blog['blog_id'], text_helper::truncate($blog['data_title'], 64))), 'user' => array('html' => users_helper::anchor($blog['user'])), 'post_date' => array('html' => date_helper::formatDate($blog['post_date'])), 'status' => array('html' => $status), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/plugins/blogs/edit/' . $blog['blog_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/plugins/blogs/delete/' . $blog['blog_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('delete', 'system'), array('data-html' => __('blog_delete?', 'blogs'), 'data-role' => 'confirm', 'class' => 'delete'))))); } // Set pagination $config = array('base_url' => config::siteURL('cp/plugins/blogs?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->blogsPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Filter hooks hook::filter('cp/plugins/blogs/browse/grid', $grid); hook::filter('cp/plugins/blogs/browse/actions', $actions); // Assign vars view::assign(array('grid' => $grid, 'actions' => $actions, 'pagination' => $pagination)); // Set title view::setTitle(__('blogs_manage', 'system_navigation')); // Set trail if ($qstring['search_id']) { view::setTrail('cp/plugins/blogs?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system')); } // Assign actions view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#blogs-search\').toggle();return false;')); // Load view view::load('cp/plugins/blogs/browse'); }
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 __construct($config = array()) { parent::__construct(); $this->config = $config; $this->config['driver'] = 'recaptcha'; loader::library('captcha', $this->config); }
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 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 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; }
public function browse() { // Parameters $params = array('join_columns' => array(), 'join_items' => array()); // Process filters $params = $this->parseCounters($params); // Process query string $qstring = $this->parseQuerystring($params['total']); // Actions $actions = array(0 => __('select', 'system'), 'delete' => __('delete', 'system')); // Check form action if (input::post('do_action')) { // Delete selected news if (input::post('action') == 'delete') { if (input::post('news_id') && is_array(input::post('news_id'))) { foreach (input::post('news_id') as $newsID) { $newsID = (int) $newsID; if ($newsID && $newsID > 0) { $this->delete($newsID); } } } } // Success view::setInfo(__('action_applied', 'system')); router::redirect('cp/content/news?' . $qstring['url'] . 'page=' . $qstring['page']); } // Get news $news = array(); if ($params['total']) { $news = $this->news_model->getEntries('in_list', $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']); } // Create table grid $grid = array('uri' => 'cp/content/news', 'keyword' => 'news', 'header' => array('check' => array('html' => 'news_id', 'class' => 'check'), 'data_title_' . session::item('language') => array('html' => __('name', 'system'), 'class' => 'name', 'sortable' => true), 'post_date' => array('html' => __('post_date', 'system'), 'class' => 'date', 'sortable' => true), 'status' => array('html' => __('status', 'system'), 'class' => 'status'), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array()); // Create grid content foreach ($news as $entry) { $grid['content'][] = array('check' => array('html' => $entry['news_id']), 'data_title_' . session::item('language') => array('html' => html_helper::anchor('cp/content/news/edit/' . $entry['news_id'], text_helper::truncate($entry['data_title'], 64))), 'post_date' => array('html' => date_helper::formatDate($entry['post_date'])), 'status' => array('html' => $entry['active'] ? '<span class="label success small">' . __('yes', 'system') . '</span>' : '<span class="label important small">' . __('no', 'system') . '</span>'), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/content/news/edit/' . $entry['news_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/content/news/delete/' . $entry['news_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('delete', 'system'), array('data-html' => __('entry_delete?', 'news'), 'data-role' => 'confirm', 'class' => 'delete'))))); } // Set pagination $config = array('base_url' => config::siteURL('cp/content/news?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->newsPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Filter hooks hook::filter('cp/content/news/browse/grid', $grid); hook::filter('cp/content/news/browse/actions', $actions); // Assign vars view::assign(array('grid' => $grid, 'actions' => $actions, 'pagination' => $pagination)); // Set title view::setTitle(__('news_manage', 'system_navigation')); // Set trail if ($qstring['search_id']) { view::setTrail('cp/content/news?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system')); } // Assign actions view::setAction('cp/content/news/edit/', __('entry_new', 'news'), array('class' => 'icon-text icon-news-new')); view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#news-search\').toggle();return false;')); // Load view view::load('cp/content/news/browse'); }
public function browse($resource = '', $itemID = 0, $total = false, $page = false, $post = true, $info = true, $static = false) { // Get vars if (input::isAjaxRequest() && !$static) { $resource = input::post_get('resource'); $itemID = (int) input::post_get('item_id'); $post = (bool) input::post_get('post'); $info = (bool) input::post_get('info'); } $split = (int) input::post_get('split') && (int) input::post_get('split') <= config::item('comments_per_page', 'comments') ? (int) input::post_get('split') : config::item('comments_per_page', 'comments'); // Get resource ID $resourceID = config::item('resources', 'core', $resource, 'resource_id'); if (!$resourceID || !$itemID) { return false; } // Do we have the number of comments? if ($total === false) { // Count comments $total = $this->comments_model->countComments(array(), array(), array('resource' => $resource, 'item_id' => $itemID)); } // Post comment if (input::post('do_save_comment') && session::permission('comments_post', 'comments')) { if ($this->_saveComment($resource, $itemID)) { $total++; } } elseif (input::post('delete') && session::permission('comments_delete', 'comments')) { if ($this->_deleteComment($resource, $itemID, (int) input::post('delete'))) { $total--; } } // Current page $page = $page ? $page : (int) input::post_get('page', 1); $page = $page > 0 ? $page : 1; // Limit $limit = ($page - 1) * $split . ', ' . $split; // Get comments $comments = $this->comments_model->getComments($resource, $itemID, array(), '`c`.`post_date` desc', $limit); // If no comments were found, try to fetch from from the previous page if (!$comments && $page > 1) { $page--; // Limit $from = ($page - 1) * $split; $limit = $from . ', ' . $split; $comments = $this->comments_model->getComments($resource, $itemID, array(), '`c`.`post_date` desc', $limit); } // Pagination config $config = array('base_url' => 'comments/browse?', 'total_items' => $total, 'items_per_page' => $split, 'current_page' => $page, 'uri_segment' => 'page', 'link_attr' => array('onclick' => "runAjax(this.href,{'resource':'" . $resource . "','item_id':" . $itemID . ",'split':" . $split . ",'post':" . ($post ? 1 : 0) . ",'info':" . ($info ? 1 : 0) . "},'replaceContent','comments-container-" . $resource . "-" . $itemID . "','pagination-" . $resource . "-" . $itemID . "');return false;")); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('resource' => $resource, 'itemID' => $itemID, 'comments' => $comments, 'pagination' => $pagination, 'split' => $split, 'post' => users_helper::isLoggedin() && $post ? true : false, 'info' => $info), '', 'comments/index'); if (input::isAjaxRequest() && !$static) { $output = view::load('comments/index', array(), true); view::ajaxResponse($output); } else { view::load('comments/index'); } }
public static function captcha($name, $value = '') { $service = config::item('default_captcha', 'security'); $settings = config::item('default_captcha_settings', 'security'); // Load library loader::library('captchas/' . $service, $settings, 'captcha_' . $service); $str = codebreeder::instance()->{'captcha_' . $service}->getCaptcha($name); return $str; }
public function __construct($manifest = array()) { parent::__construct(); $this->manifest = $manifest; loader::library('dbforge'); $engines = $this->dbforge->getEngines(); $this->dbEngine = in_array('InnoDB', $engines) ? 'InnoDB' : 'MyISAM'; //$this->dbEngine = 'MyISAM'; }
public function browse() { // Parameters $params = array('join_columns' => array()); // Process filters $params = $this->parseCounters($params); // Process query string $qstring = $this->parseQuerystring($params['total']); // Actions $actions = array(0 => __('select', 'system'), 'delete' => __('delete', 'system')); // Check form action if (input::post('do_action')) { // Delete selected messages if (input::post('action') == 'delete') { if (input::post('message_id') && is_array(input::post('message_id'))) { foreach (input::post('message_id') as $messageID) { $messageID = (int) $messageID; if ($messageID && $messageID > 0) { $this->delete($messageID); } } } } // Success view::setInfo(__('action_applied', 'system')); router::redirect('cp/plugins/messages?' . $qstring['url'] . 'page=' . $qstring['page']); } // Get messages $messages = array(); if ($params['total']) { $messages = $this->messages_model->getMessages($params['join_columns'], $qstring['order'], $qstring['limit']); } // Create table grid $grid = array('uri' => 'cp/plugins/messages', 'keyword' => 'messages', 'header' => array('check' => array('html' => 'message_id', 'class' => 'check'), 'message' => array('html' => __('message', 'messages'), 'class' => 'name'), 'user' => array('html' => __('user', 'system'), 'class' => 'user'), 'post_date' => array('html' => __('post_date', 'system'), 'class' => 'date', 'sortable' => true), 'actions' => array('html' => __('actions', 'system'), 'class' => 'actions')), 'content' => array()); // Create grid content foreach ($messages as $message) { $grid['content'][] = array('check' => array('html' => $message['message_id']), 'message' => array('html' => html_helper::anchor('cp/plugins/messages/edit/' . $message['message_id'], text_helper::truncate($message['message'], 64))), 'user' => array('html' => users_helper::anchor($message['user'])), 'post_date' => array('html' => date_helper::formatDate($message['post_date'])), 'actions' => array('html' => array('edit' => html_helper::anchor('cp/plugins/messages/edit/' . $message['message_id'], __('edit', 'system'), array('class' => 'edit')), 'delete' => html_helper::anchor('cp/plugins/messages/delete/' . $message['message_id'] . '?' . $qstring['url'] . 'page=' . $qstring['page'], __('delete', 'system'), array('data-html' => __('message_delete?', 'messages'), 'data-role' => 'confirm', 'class' => 'delete'))))); } // Set pagination $config = array('base_url' => config::siteURL('cp/plugins/messages?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->messagesPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Filter hooks hook::filter('cp/plugins/messages/browse/grid', $grid); hook::filter('cp/plugins/messages/browse/actions', $actions); // Assign vars view::assign(array('grid' => $grid, 'actions' => $actions, 'pagination' => $pagination)); // Set title view::setTitle(__('messages_manage', 'system_navigation')); // Set trail if ($qstring['search_id']) { view::setTrail('cp/plugins/messages?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system')); } // Assign actions view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#messages-search\').toggle();return false;')); // Load view view::load('cp/plugins/messages/browse'); }
public function confirm() { $class = uri::segment(4); $action = uri::segment(5) == 'signup' ? 'signup' : 'login'; $service = $this->users_authentication_model->getService($class); if ($service) { loader::library('authentication/' . uri::segment(4), $service['settings'], 'users_authentication_' . $class . '_model'); $this->{'users_authentication_' . $class . '_model'}->confirm($action); } router::redirect('users/login'); }
public function sendFeedback($email, $subject, $message) { loader::library('email'); $this->email->reply($email); $retval = $this->email->sendEmail(config::item('feedback_email', 'feedback'), $subject, $message); if ($retval) { // Action hook hook::action('feedback/send/post', $email, $subject, $message); } return $retval; }
public function index() { $service = config::item('default_captcha', 'security'); $settings = config::item('default_captcha_settings', 'security'); // Load library $captcha = loader::library('captcha', $settings, null); if (uri::segment(3) == 'reload') { $captcha->create(); } echo $captcha->render(); exit; }
public function getManifest($keyword) { $manifest = array(); // Load captcha $captcha = loader::library('captchas/' . $keyword, array(), null); // Does captcha exist? if ($captcha) { $params = $captcha->getManifest(); $manifest = array('keyword' => $keyword, 'name' => $params['name'], 'description' => $params['description'], 'settings' => isset($params['settings']) && is_array($params['settings']) ? $params['settings'] : array(), 'values' => array(), 'default' => 0); } return $manifest; }
public function getManifest($keyword) { $manifest = array(); // Load gateway $gateway = loader::library('payments/' . $keyword, array(), null); // Does gateway exist? if ($gateway) { $params = $gateway->getManifest(); $manifest = array('keyword' => $keyword, 'name' => $params['name'], 'settings' => isset($params['settings']) && is_array($params['settings']) ? $params['settings'] : array(), 'values' => array(), 'active' => 0); } return $manifest; }
public static function getFilePath($serviceID, $path, $name, $ext, $suffix = '') { // Get storage service and settings $service = config::item('storages', 'core', $serviceID); $settings = config::item('storages', 'core', 'settings', $serviceID); if (!$service) { return ''; } // Load library loader::library('storages/' . $service, $settings, 'storage_' . $service); $str = codebreeder::instance()->{'storage_' . $service}->getFilePath($path, $name, $ext, $suffix); return $str; }
public function validatePayment($gatewayID) { // Verify payment status if (strtolower(input::post('payment_status')) != 'completed' || strtolower(input::post('txn_type')) != 'web_accept') { $this->setError('Invalid payment status.'); return false; } // Verify receiver's email if (strcasecmp($this->config['email'], input::post('business')) || strcasecmp($this->config['email'], input::post('receiver_email'))) { $this->setError('Invalid receiver email.'); return false; } // Load http library loader::library('http'); // Set parameters $params = $_POST; $params['cmd'] = '_notify-validate'; // Run paypal request $response = $this->http->run($this->config['test'] ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', 'POST', $params); // Verify reponse if (strcasecmp(trim($response), 'verified')) { $this->setError('Invalid response: ' . $response); return false; } // Get parameters $receiptID = input::post('txn_id'); $invoiceID = input::post('item_number'); $amount = input::post('mc_gross'); $currency = input::post('mc_currency'); // Verify duplicates if (!$this->transactions_model->isUniqueTransaction($gatewayID, $receiptID)) { $this->setError('Duplicate transaction: ' . $receiptID); return false; } // Get invoice if (!($invoice = $this->transactions_model->getInvoice($invoiceID))) { $this->setError('Invalid invoice ID: ' . $invoiceID); return false; } // Verify amount if (strcmp($invoice['amount'], $amount)) { $this->setError('Invalid payment amount: ' . money_helper::symbol(config::item('currency', 'billing')) . $amount); return false; } $invoice['receipt_id'] = $receiptID; return $invoice; }
public function browse() { // Parameters $params = array('join_columns' => array("`u`.`picture_id`!=0"), 'join_items' => array()); // Process filters $params = $this->parseCounters($params, 0); // Process query string $qstring = $this->parseQuerystring($params['total']); // Actions $actions = array(0 => __('select', 'system'), 'approve' => __('approve', 'system'), 'decline' => __('decline', 'system'), 'delete' => __('delete', 'system')); // Check form action if (input::post('do_action')) { // Delete selected albums if (input::post('action') && isset($actions[input::post('action')]) && input::post('user_id') && is_array(input::post('user_id'))) { foreach (input::post('user_id') as $userID) { $userID = (int) $userID; if ($userID && $userID > 0) { $this->action(input::post('action'), $userID); } } } // Success view::setInfo(__('action_applied', 'system')); router::redirect('cp/users/pictures/browse?' . $qstring['url'] . 'page=' . $qstring['page']); } // Get pictures $users = array(); if ($params['total']) { $users = $this->users_model->getUsers('in_list', isset($params['values']['type']) ? $params['values']['type'] : 0, $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']); } // Set pagination $config = array('base_url' => config::siteURL('cp/users/pictures/browse?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->picturesPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('users' => $users, 'pagination' => $pagination, 'actions' => $actions)); // Set title view::setTitle(__('users_pictures_manage', 'system_navigation')); // Set trail if ($qstring['search_id']) { view::setTrail('cp/users/pictures/browse?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system')); } // Assign actions view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#pictures-search\').toggle();return false;')); // Load view view::load('cp/users/pictures/browse'); }
public function manage() { // Does user have permission to view visitors? if (!session::permission('users_visitors_browse', 'users')) { view::noAccess(); } // 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' => session::permission('users_visitors_limit', 'users') && session::permission('users_visitors_limit', 'users') < $user['total_visitors'] ? session::permission('users_visitors_limit', 'users') : $user['total_visitors'], 'profiles' => true); // Process query string $qstring = $this->parseQuerystring($params['total']); // Get visitors $visitors = array(); if ($params['total']) { $visitors = $this->users_visitors_model->getVisitors(session::item('user_id'), $qstring['order'], $qstring['limit'], $params); } else { view::setInfo(__('no_visitors', 'users_visitors')); } // Set pagination $config = array('base_url' => config::siteURL('users/visitors/manage?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => config::item('visitors_per_page', 'users'), 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('user' => $user, 'visitors' => $visitors, 'fields' => $fields, 'pagination' => $pagination)); // Dow we have new visitors? if (session::item('total_visitors_new')) { // Reset new visitors counter $this->users_visitors_model->resetCounter(); } // Set title view::setTitle(__('my_visitors', 'system_navigation')); // Set trail view::setTrail(session::item('slug'), __('my_profile', 'system_navigation')); view::setTrail('users/visitors/manage', __('users_visitors', 'system_navigation')); // Load view view::load('users/visitors/manage'); }
public function ipn() { // Get URI vars $gatewayID = uri::segment(4); // Get gateway if (!$gatewayID || !($gateway = $this->gateways_model->getGateway($gatewayID)) || !$gateway['active']) { die(__('no_gateway', 'billing_gateways')); } // Update gateway ID $gatewayID = $gateway['gateway_id']; // Load payment library $payment = loader::library('payments/' . $gateway['keyword'], $gateway['settings'], null); // Run IPN function if (!($invoice = $payment->validatePayment($gatewayID))) { $this->transactions_model->saveLog(0, $gatewayID, 0, $payment->getError()); die($payment->getError()); } // Save transaction if ($transactionID = $this->transactions_model->saveTransaction(0, $gatewayID, $invoice['invoice_id'], $invoice['receipt_id'], $invoice['user_id'], $invoice['amount'])) { // Mark invoice as paid $this->transactions_model->payInvoice($invoice['invoice_id'], $invoice['user_id'], $invoice['amount']); } // Get payment type if (!($type = $this->payments_model->getPaymentType($invoice['type_id']))) { return false; } // Load payment type model $product = loader::model('billing/' . $type['keyword'], array(), null); // Setup product $product->process($invoice['user_id'], $invoice['product_id'], $invoice['params']); // Run complete function $payment->completePayment(); // Log transaction $logID = $this->transactions_model->saveLog(0, $gatewayID, 1); die('ok'); }
public function action($action, $actionID = false) { // Check if demo mode is enabled if (input::demo(1, 'cp/users')) { return false; } // Get URI vars $userID = $actionID ? $actionID : (int) uri::segment(4); // Get user if (!$userID || !($user = $this->users_model->getUser($userID))) { view::setError(__('no_user', 'users')); router::redirect('cp/users'); } // Make sure we're not trying to decline ourselves if ($userID != session::item('user_id')) { switch ($action) { case 'approve': case 'approve_email': if ($this->users_model->toggleUserStatus($userID, $user, 1) && $action == 'approve_email') { loader::library('email'); $this->email->sendTemplate('users_account_welcome', $user['email'], $user, $user['language_id']); } $str = __('user_approved', 'users'); break; case 'decline': case 'decline_email': if ($this->users_model->toggleUserStatus($userID, $user, 0) && $action == 'decline_email') { loader::library('email'); $this->email->sendTemplate('users_account_declined', $user['email'], $user, $user['language_id']); } $str = __('user_declined', 'users'); break; case 'verify': $this->users_model->toggleVerifiedStatus($userID, $user, 1); $str = __('user_verified', 'users'); break; case 'unverify': $this->users_model->toggleVerifiedStatus($userID, $user, 0); $str = __('user_unverified', 'users'); break; case 'delete': $this->users_model->deleteUser($userID, $user); $str = __('user_deleted', 'users'); break; } } else { $str = ''; } // Is this an action call? if ($actionID) { return; } // Process query string $qstring = $this->parseQuerystring(); // Success view::setInfo($str); router::redirect('cp/users?' . $qstring['url'] . 'page=' . $qstring['page']); }
$db->runQuery("update " . FORM . " set content2='" . $db->clearText($val) . "' where id='" . substr($set1, 2) . "' "); } } if ($_POST['type'] == 'multiple page' && $_POST['sub_id'] == '') { if (is_numeric(substr($set1, 1))) { $db->runQuery("insert into " . FORM . " \n\t\t\t\t\t\t\t(category_id,\n\t\t\t\t\t\t\tsub_id,\n\t\t\t\t\t\t\tforms,\n\t\t\t\t\t\t\tcontent\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tvalues(\n\t\t\t\t\t\t\t'{$_POST['id']}',\n\t\t\t\t\t\t\t'{$rand}',\n\t\t\t\t\t\t\t'{$forms}',\n\t\t\t\t\t\t\t'" . $db->clearText($val) . "'\n\t\t\t\t\t\t\t)"); } } next($name); } $_SESSION['succ'] = 'Update Successfully'; echo "<script>window.location='{$_SERVER['HTTP_REFERER']}'</script>"; die; } if ($act == 'images-upload') { $load->library('ajax_upload'); $idx = $_POST['idx']; if ($_POST['del']) { @unlink($baseurl . image_folder . '/' . $_POST['del']); $db->runQuery("delete from " . IMG . " where img='{$_POST['del']}' "); } else { if ($_POST['name']) { //edit $load->model('site_function'); if ($img = $load->site_function->images_upload('images', 'image', $baseurl)) { @unlink($baseurl . image_folder . '/' . $_POST['name']); $db->runQuery("UPDATE " . IMG . " SET img='{$img}' WHERE slug = '{$_POST['slug']}' "); } } else { //new $load->model('site_function');
public function manage() { // Is user loggedin ? if (!users_helper::isLoggedin()) { router::redirect('users/login'); } elseif (!session::permission('albums_post', 'pictures')) { view::noAccess(session::item('slug')); } // Assign user from session to variable $user = session::section('session'); // Parameters $params = array('select_users' => false, 'join_columns' => array('`a`.`user_id`=' . session::item('user_id')), 'join_items' => array(), 'total' => $user['total_albums']); // Process filters $params = $this->parseCounters($params, 'manage'); // Process query string $qstring = $this->parseQuerystring(config::item('user_albums_per_page', 'pictures'), $params['max']); // Get albums $albums = array(); if ($params['total']) { $albums = $this->pictures_albums_model->getAlbums('in_list', $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit'], $params); } // Set pagination $config = array('base_url' => config::siteURL('pictures/albums/manage?' . $qstring['url']), 'total_items' => $params['total'], 'max_items' => $params['max'], 'items_per_page' => config::item('user_albums_per_page', 'pictures'), 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('user' => $user, 'albums' => $albums, 'pagination' => $pagination)); // Set title view::setTitle(__('my_albums', 'system_navigation')); // Set trail view::setTrail(session::item('slug'), __('my_profile', 'system_navigation')); view::setTrail('pictures/manage', __('pictures_albums', 'system_navigation')); // Assign actions view::setAction('pictures/albums/edit', __('album_new', 'pictures'), array('class' => 'icon-text icon-pictures-albums-new')); if (session::permission('albums_search', 'pictures') && ($params['total'] || input::post_get('do_search'))) { view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#albums-search\').toggle();return false;')); } // Load view view::load('pictures/albums/manage'); }
public function uninstall($languageID, $language) { // Delete language $retval = $this->db->delete('core_languages', array('language_id' => $languageID), 1); if ($retval) { // Update users with the new system language ID $this->db->update('users', array('language_id' => config::item('language_id', 'system')), array('language_id' => $languageID)); // Load dbforge library loader::library('dbforge'); // Languages $this->dbforge->dropColumns(':prefix:core_languages_data', array('value_' . $language['keyword'])); // Email templates $this->dbforge->dropColumns(':prefix:core_email_templates', array('subject_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_email_templates', array('message_html_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_email_templates', array('message_text_' . $language['keyword'])); // Meta tags $this->dbforge->dropColumns(':prefix:core_meta_tags', array('meta_title_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_meta_tags', array('meta_description_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_meta_tags', array('meta_keywords_' . $language['keyword'])); // Custom fields $this->dbforge->dropColumns(':prefix:core_fields', array('name_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields', array('sname_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields', array('vname_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields', array('validate_error_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields_items', array('name_' . $language['keyword'])); $this->dbforge->dropColumns(':prefix:core_fields_items', array('sname_' . $language['keyword'])); // Geo data foreach (array('countries', 'states', 'cities') as $table) { $this->dbforge->dropColumns(':prefix:geo_' . $table, array('name_' . $language['keyword'])); } // Report subjects $this->dbforge->dropColumns(':prefix:reports_subjects', array('name_' . $language['keyword'])); if ($languageID == session::item('language_id')) { session::set('language', config::item('language_id', 'system')); session::delete('', 'config'); } // Action hook hook::action('system/languages/uninstall', $languageID, $language['keyword']); $this->cache->cleanup(); } return $retval; }
public function deleteFiles($fileID, $limit = 1) { $files = $this->getFiles($fileID, $limit); if (!$files) { return true; } $services = array(); foreach ($files as $file) { // Did we already load storage library? if (!isset($services[$file['service_id']])) { // Get storage service and settings $service = config::item('storages', 'core', $file['service_id']); $settings = config::item('storages', 'core', 'settings', $file['service_id']); // Load library loader::library('storages/' . $service, $settings, 'storage_' . $service); $services[$file['service_id']] = true; } $this->{'storage_' . $service}->delete($file['path'], $file['name'], $file['extension'], $file['suffix']); } if (is_array($fileID)) { $retval = $this->db->query("DELETE FROM `:prefix:storage_files` WHERE `file_id` IN (?) OR `parent_id` IN (?) LIMIT ?", array($fileID, $fileID, count($files))); } else { $retval = $this->db->query("DELETE FROM `:prefix:storage_files` WHERE `file_id`=? OR `parent_id`=? LIMIT ?", array($fileID, $fileID, count($files))); } if ($retval) { // Action hook hook::action('system/storage/files/delete', $fileID, $files); } return $retval; }
public function deleteField($plugin, $table, $fieldID, $field) { loader::library('dbforge'); // Is multi language enabled? if ($field['multilang']) { // Loop through languages foreach (config::item('languages', 'core', 'keywords') as $lang) { // Drop table column $this->dbforge->dropColumn(':prefix:' . $table, 'data_' . $field['keyword'] . '_' . $lang); } } else { $this->dbforge->dropColumn(':prefix:' . $table, 'data_' . $field['keyword']); if ($field['type'] == 'location') { $this->dbforge->dropColumn(':prefix:' . $table, 'data_' . $field['keyword'] . '_state'); $this->dbforge->dropColumn(':prefix:' . $table, 'data_' . $field['keyword'] . '_city'); } } // Delete field items $this->db->delete('core_fields_items', array('field_id' => $fieldID)); // Delete field if ($retval = $this->db->delete('core_fields', array('plugin' => $plugin, 'category_id' => $field['category_id'], 'field_id' => $fieldID), 1)) { // Update order IDs $this->db->query("UPDATE `:prefix:core_fields` SET `order_id`=`order_id`-1 WHERE `plugin`=? AND `category_id`=? AND `order_id`>?", array($plugin, $field['category_id'], $field['order_id'])); } $this->cache->cleanup(); return $retval; }
protected function _resendHash() { // Create rules $rules = array('email' => array('label' => 'email', 'rules' => array('trim', 'required', 'max_length' => 255, 'valid_email'))); // Assign rules validate::setRules($rules); // Validate fields if (!validate::run()) { return false; } // Does user exist? if (!($user = $this->users_model->getUser(input::post('email')))) { validate::setFieldError('email', __('email_invalid', 'users_signup')); return false; } // Is user's email already verified? if ($user['verified']) { view::setError(__('user_already_verified', 'users_signup')); return false; } // Loader loader::library('email'); loader::model('system/requests'); // Is this a recent request? if ($this->requests_model->isRecentRequest('signup', $user['user_id'], 0, 5)) { // Success view::setError(__('request_recent_sendhash', 'users_signup')); return false; } // Save resend hash request $hash = $this->requests_model->saveRequest('signup', $user['user_id']); $user['security_hash'] = $hash; $user['activation_link'] = config::siteURL('users/signup/confirm/' . $user['user_id'] . '/' . $hash); // Send activation email $this->email->sendTemplate('users_account_confirm', $user['email'], $user, $user['language_id']); // Success view::setInfo(__('confirm_email', 'users_signup')); router::redirect('users/login/index/verify'); }
public function send() { // Get URI vars $newsletterID = (int) uri::segment(5); $counter = (int) uri::segment(6, 0); $test = uri::segment(7) == 'test' ? 1 : 0; $step = config::item('emails_batch', 'newsletters'); // Get newsletter if (!$newsletterID || !($newsletter = $this->newsletters_model->getNewsletter($newsletterID, false))) { view::setError(__('no_newsletter', 'newsletters')); router::redirect('cp/content/newsletters'); } // Do we have recipients? if (!$newsletter['total_users']) { router::redirect('cp/content/newsletters/recipients/' . $newsletterID); } // Is this the first step? if (!$test && !$counter) { // Update total user count $searchID = $this->search_model->searchData('profile', array(), $newsletter['params']['conditions'], $newsletter['params']['values'], array('type_id' => isset($newsletter['params']['values']['type_id']) ? $newsletter['params']['values']['type_id'] : 0)); // Do we have any search terms? if ($searchID == 'no_terms' || $searchID == 'no_results' || !($search = $this->search_model->getSearch($searchID))) { router::redirect('cp/content/newsletters/recipients/' . $newsletterID); } // Did total user count change? if ($search['results'] != $newsletter['total_users']) { $newsletter = array('total_users' => $search['results']); $this->newsletters_model->saveNewsletter($newsletterID, $newsletter); } } elseif ($test && !config::item('email_test', 'newsletters')) { view::setError(__('newsletters_test_none', 'newsletters', array(), array('%' => html_helper::anchor('cp/system/config/newsletters', '\\1')))); router::redirect('cp/content/newsletters/review/' . $newsletterID); } // Load email library loader::library('email'); // Is this a test? if ($test) { $this->email->sendEmail(config::item('email_test', 'newsletters'), $newsletter['subject'], $newsletter['message_text'], $newsletter['message_html']); view::setInfo(__('newsletter_sent', 'newsletters')); router::redirect('cp/content/newsletters/review/' . $newsletterID); } // Get users $users = $this->users_model->getUsers('in_view', isset($newsletter['params']['values']['type_id']) ? $newsletter['params']['values']['type_id'] : 0, $newsletter['params']['conditions']['columns'], $newsletter['params']['conditions']['items'], false, $counter . ',' . $step); foreach ($users as $user) { if (!input::demo(0)) { $this->email->sendEmail($user['email'], $newsletter['subject'], $newsletter['message_text'], $newsletter['message_html'], $user); } $counter++; } // Do we have any users? if (!$users) { view::setInfo(__('newsletter_sent', 'newsletters')); $next = ''; } else { $next = $counter; } // Update total sent $this->newsletters_model->saveNewsletter($newsletterID, array('total_sent' => $next ? $counter : 0)); // Did total number of users change? if ($counter > $newsletter['total_users'] || !$next && $counter < $newsletter['total_users']) { $newsletter['total_users'] = $counter; $this->newsletters_model->saveNewsletter($newsletterID, array('total_users' => $counter)); } $message = __('newsletter_sending_status', 'newsletters', array('%1' => $counter, '%2' => $newsletter['total_users'])); $message .= '<br/>' . __('newsletter_sending_redirect', 'newsletters', array(), array('%' => html_helper::anchor('cp/content/newsletters/send/' . $newsletterID . '/' . $next, '\\1'))); // Assign vars view::assign(array('newsletterID' => $newsletterID, 'newsletter' => $newsletter, 'counter' => $counter, 'redirect' => $next, 'output' => $message)); if (input::isAjaxRequest()) { view::ajaxResponse(array('output' => $message, 'redirect' => $next)); } // Set title view::setTitle(__('newsletter_sending', 'newsletters')); // Set trail view::setTrail('cp/content/newsletters/send/' . $newsletterID, __('newsletter_send', 'newsletters') . ' - ' . text_helper::entities($newsletter['subject'])); // Load view view::load('cp/content/newsletters/send'); }