Файловый менеджер - Редактировать - /home/lmsyaran/public_html/pusher/Utils.tar
Назад
Database.php 0000644 00000001552 15116747561 0007001 0 ustar 00 <?php /** * @package OSL * @subpackage Controller * * @copyright Copyright (C) 2016 Ossolution Team, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace OSL\Utils; use JDatabaseQuery; class Database { /** * Helper method to get fields from database table in case the site is multilingual * * @param \JDatabaseQuery $query * @param array $fields * @param string $fieldSuffix */ public static function getMultilingualFields(JDatabaseQuery $query, $fields = array(), $fieldSuffix) { foreach ($fields as $field) { $alias = $field; $dotPos = strpos($field, '.'); if ($dotPos !== false) { $alias = substr($field, $dotPos + 1); } $query->select($query->quoteName($field . $fieldSuffix, $alias)); } } } Helper.php 0000644 00000007716 15116747561 0006524 0 ustar 00 <?php /** * @package OSL * @subpackage Controller * * @copyright Copyright (C) 2016 Ossolution Team, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace OSL\Utils; use JComponentHelper, JFactory, JObject; class Helper { /** * Get list of language uses on the site * * @return array */ public static function getLanguages() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $params = JComponentHelper::getParams('com_languages'); $default = $params->get('site', 'en-GB'); $query->select('lang_id, lang_code, title, `sef`') ->from('#__languages') ->where('published = 1') ->where('lang_code != ' . $db->quote($default)) ->order('ordering'); $db->setQuery($query); $languages = $db->loadObjectList(); return $languages; } /** * Get actions can be performed by the current user on the view of a component * * @param string $option Name of the component is being dispatched * * @return JObject Actions which can be performed by the current user */ public static function getActions($option) { $result = new JObject(); $user = JFactory::getUser(); $actions = array('core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete'); foreach ($actions as $action) { $result->set($action, $user->authorise($action, $option)); } return $result; } /** * Apply some fixes for request data, this method should be called before the dispatcher is called * * @return void */ public static function prepareRequestData() { //Remove cookie vars from request data $cookieVars = array_keys($_COOKIE); if (count($cookieVars)) { foreach ($cookieVars as $key) { if (!isset($_POST[$key]) && !isset($_GET[$key])) { unset($_REQUEST[$key]); } } } if (isset($_REQUEST['start']) && !isset($_REQUEST['limitstart'])) { $_REQUEST['limitstart'] = $_REQUEST['start']; } if (!isset($_REQUEST['limitstart'])) { $_REQUEST['limitstart'] = 0; } } /** * Convert payment amount to from one currency to other currency * * @param float $amount * * @param string $fromCurrency * * @param string $toCurrency * * @return float */ public static function convertPaymentAmount($amount, $fromCurrency, $toCurrency) { $http = \JHttpFactory::getHttp(); $url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=' . $toCurrency . $fromCurrency . '=X'; $response = $http->get($url); if ($response->code == 200) { $currencyData = explode(',', $response->body); $rate = floatval($currencyData[1]); if ($rate > 0) { $amount = $amount / $rate; } } return round($amount, 2); } /** * Credit Card Type * * Iterates through known/supported card brands to determine the brand of this card * * @param string $cardNumber * * @return string */ public static function getCardType($cardNumber) { $supportedCardTypes = array( 'visa' => '/^4\d{12}(\d{3})?$/', 'mastercard' => '/^(5[1-5]\d{4}|677189)\d{10}$/', 'discover' => '/^(6011|65\d{2}|64[4-9]\d)\d{12}|(62\d{14})$/', 'amex' => '/^3[47]\d{13}$/', 'diners_club' => '/^3(0[0-5]|[68]\d)\d{11}$/', 'jcb' => '/^35(28|29|[3-8]\d)\d{12}$/', 'switch' => '/^6759\d{12}(\d{2,3})?$/', 'solo' => '/^6767\d{12}(\d{2,3})?$/', 'dankort' => '/^5019\d{12}$/', 'maestro' => '/^(5[06-8]|6\d)\d{10,17}$/', 'forbrugsforeningen' => '/^600722\d{10}$/', 'laser' => '/^(6304|6706|6709|6771(?!89))\d{8}(\d{4}|\d{6,7})?$/', ); foreach ($supportedCardTypes as $brand => $val) { if (preg_match($val, $cardNumber)) { return $brand; } } return ''; } } Html.php 0000644 00000007224 15116747561 0006203 0 ustar 00 <?php /** * @package OSL * @subpackage Controller * * @copyright Copyright (C) 2016 Ossolution Team, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ namespace OSL\Utils; use JFactory, JFormHelper; use JHtmlSidebar, JHtml, JText; class Html { /** * Add sub-menus which allow users to access to the other views in the component * * @param string $option Name of the component being dispatched * @param string $viewName Name of the view currently displayed */ public static function addSubMenus($option, $viewName) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $baseLink = 'index.php?option=' . $option; $currentViewLink = 'index.php?option=' . $option . '&view=' . $viewName; $query->select('title, link') ->from('#__menu') ->where('link LIKE ' . $db->quote($baseLink . '%')) ->where('parent_id != 1') ->where('client_id = 1') ->order('id'); $db->setQuery($query); $rows = $db->loadObjectList(); foreach ($rows as $row) { JHtmlSidebar::addEntry(JText::_($row->title), $row->link, $row->link == $currentViewLink); } } /** * Get label of the field (including tooltip) * * @param $name * @param $title * @param string $tooltip * * @return string */ public static function getFieldLabel($name, $title, $tooltip = '') { $label = ''; $text = $title; // Build the class for the label. $class = !empty($tooltip) ? 'hasTooltip hasTip' : ''; // Add the opening label tag and main attributes attributes. $label .= '<label id="' . $name . '-lbl" for="' . $name . '" class="' . $class . '"'; // If a description is specified, use it to build a tooltip. if (!empty($tooltip)) { $label .= ' title="' . JHtml::tooltipText(trim($text, ':'), $tooltip, 0) . '"'; } $label .= '>' . $text . '</label>'; return $label; } /** * Get bootstrapped style boolean input * * @param $name * @param $value * * @return string */ /** * Get bootstrapped style boolean input * * @param $name * @param $value * * @return string */ public static function getBooleanInput($name, $value) { JHtml::_('jquery.framework'); $value = (int) $value; $field = JFormHelper::loadFieldType('Radio'); $element = new \SimpleXMLElement('<field />'); $element->addAttribute('name', $name); if (version_compare(JVERSION, '4.0.0-dev', '>=')) { $element->addAttribute('class', 'switcher'); $element->addAttribute('layout', 'joomla.form.field.radio.switcher'); } else { $element->addAttribute('class', 'radio btn-group btn-group-yesno'); } $element->addAttribute('default', '0'); $node = $element->addChild('option', 'JNO'); $node->addAttribute('value', '0'); $node = $element->addChild('option', 'JYES'); $node->addAttribute('value', '1'); $field->setup($element, $value); return $field->input; } /** * Generate User Input Select * * @param int $userId * @param string $name * @param array $attributes * * @return string */ public static function getUserInput($userId, $name = 'user_id', array $attributes = array()) { /* @var \JFormField $field */ $field = JFormHelper::loadFieldType('User'); $element = new \SimpleXMLElement('<field />'); $element->addAttribute('name', $name); $element->addAttribute('class', 'readonly'); foreach ($attributes as $key => $value) { $element->addAttribute($key, $value); } $field->setup($element, $userId); return $field->input; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка