Ejemplo n.º 1
0
 /**
  * render
  *
  * @return string rendered form element
  */
 public function render()
 {
     static $included = false;
     $xoops = \Xoops::getInstance();
     $ele_value = (string) $this->getValue(false);
     $display_value = $ele_value;
     if (0 < (int) $ele_value) {
         $display_value = date(\XoopsLocale::getFormatShortDate(), $ele_value);
     }
     if ($this->getSize() > $this->getMaxcols()) {
         $maxcols = $this->getMaxcols();
     } else {
         $maxcols = $this->getSize();
     }
     $this->addAttribute('class', 'span' . $maxcols);
     $dlist = $this->isDatalist();
     if (!empty($dlist)) {
         $this->addAttribute('list', 'list_' . $this->getName());
     }
     $attributes = $this->renderAttributeString();
     $xoops->theme()->addBaseStylesheetAssets('@jqueryuicss');
     $xoops->theme()->addBaseScriptAssets('@jqueryui');
     // TODO - select and apply script by locale, example:
     // $i18nScript = 'media/jquery/ui/i18n/datepicker-es.js';
     // $xoops->theme()->addBaseScriptAssets($i18nScript);
     $xoops->theme()->addScript('', '', ' $(function() { $( "#' . $this->getAttribute('id') . '" ).datepicker({' . 'showOn: "button", buttonImageOnly: false, ' . 'buttonImage: "' . $xoops->url('media/xoops/images/icons/calendar.png') . '", ' . 'buttonImageOnly: false, buttonText: "' . \XoopsLocale::A_SELECT . '" }); }); ');
     return '<input ' . $attributes . 'value="' . $display_value . '" ' . $this->getExtra() . ' >';
 }
Ejemplo n.º 2
0
 /**
  * Get a list of localized timezone names
  *
  * @return array
  */
 public static function getList()
 {
     $xoops = \Xoops::getInstance();
     $locale = \Xoops\Locale::getCurrent();
     $key = ['system', 'lists', 'timezone', $locale];
     //$xoops->cache()->delete($key);
     $timeZones = $xoops->cache()->cacheRead($key, function () {
         $timeZones = array();
         $territories = Territory::getContinentsAndCountries();
         $maxLen = 0;
         $utcDtz = new \DateTimeZone('UTC');
         foreach ($territories as $byContinent) {
             $continent = $byContinent['name'];
             foreach ($byContinent['children'] as $cCode => $cName) {
                 $allZones = $utcDtz->listIdentifiers(\DateTimeZone::PER_COUNTRY, $cCode);
                 foreach ($allZones as $zone) {
                     $maxLen = max(strlen($zone), $maxLen);
                     $name = Calendar::getTimezoneExemplarCity($zone);
                     if (!isset($timeZones[$zone]) && !empty($name)) {
                         $timeZones[$zone] = $continent . '/' . $name;
                     }
                 }
             }
         }
         \XoopsLocale::asort($timeZones);
         $default = array('UTC' => Calendar::getTimezoneNameNoLocationSpecific(new \DateTimeZone('GMT')));
         $timeZones = array_merge($default, $timeZones);
         return $timeZones;
     });
     return $timeZones;
 }
Ejemplo n.º 3
0
 /**
  * Constructor
  *
  * @return XoopsMailerLocal
  */
 public function __construct()
 {
     parent::__construct();
     // It is supposed no need to change the charset
     $this->charSet = strtolower(XoopsLocale::getCharset());
     // You MUST specify the language code value so that the file exists: XOOPS_ROOT_PAT/class/mail/phpmailer/language/lang-["your-language-code"].php
     $this->multimailer->SetLanguage("en");
 }
Ejemplo n.º 4
0
/**
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
 * @license         GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         Publisher
 * @since           1.0
 * @author          trabis <*****@*****.**>
 * @version         $Id$
 */
function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "", $extra = "")
{
    $publisher = Publisher::getInstance();
    $ret = array();
    if ($queryarray == '' || count($queryarray) == 0) {
        $hightlight_key = '';
    } else {
        $keywords = implode('+', $queryarray);
        $hightlight_key = "&amp;keywords=" . $keywords;
    }
    $itemsObjs = $publisher->getItemHandler()->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra);
    $withCategoryPath = $publisher->getConfig('search_cat_path');
    $usersIds = array();
    /* @var $obj PublisherItem */
    foreach ($itemsObjs as $obj) {
        $item['image'] = "images/item_icon.gif";
        $item['link'] = $obj->getItemUrl();
        $item['link'] .= !empty($hightlight_key) && strpos($item['link'], '.php?') === false ? "?" . ltrim($hightlight_key, '&amp;') : $hightlight_key;
        if ($withCategoryPath) {
            $item['title'] = $obj->getCategoryPath(false) . " > " . $obj->title();
        } else {
            $item['title'] = $obj->title();
        }
        $item['time'] = $obj->getVar('datesub');
        //must go has unix timestamp
        $item['uid'] = $obj->getVar('uid');
        //"Fulltext search/highlight
        $text = $obj->body();
        $sanitized_text = "";
        $text_i = strtolower($text);
        $queryarray = is_array($queryarray) ? $queryarray : array($queryarray);
        //@todo look into xoopslocal
        foreach ($queryarray as $query) {
            $pos = strpos($text_i, strtolower($query));
            //xoops_local("strpos", $text_i, strtolower($query));
            $start = max($pos - 100, 0);
            $length = strlen($query) + 200;
            //xoops_local("strlen", $query) + 200;
            $context = $obj->highlight(XoopsLocale::substr($text, $start, $length, " [...]"), $query);
            $sanitized_text .= "<p>[...] " . $context . "</p>";
        }
        //End of highlight
        $item['text'] = $sanitized_text;
        $item['author'] = $obj->getVar('author_alias');
        $item['datesub'] = $obj->datesub($publisher->getConfig('format_date'));
        $usersIds[$obj->getVar('uid')] = $obj->getVar('uid');
        $ret[] = $item;
        unset($item, $sanitized_text);
    }
    $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true);
    foreach ($ret as $key => $item) {
        if ($item["author"] == '') {
            $ret[$key]["author"] = @$usersNames[$item["uid"]];
        }
    }
    unset($usersNames, $usersIds);
    return $ret;
}
Ejemplo n.º 5
0
 /**
  * Return all extensions
  *
  * @return array
  */
 public function getExtensionList()
 {
     // Get main instance
     $xoops = Xoops::getInstance();
     $module_handler = $xoops->getHandlerModule();
     $moduleperm_handler = $xoops->getHandlerGroupperm();
     $ret = array();
     $i = 0;
     foreach ($this->modulesList as $file) {
         $file = trim($file);
         if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) {
             clearstatcache();
             /* @var $module XoopsModule */
             $module = $module_handler->create();
             $module->loadInfoAsVar($file);
             if ($module->getInfo('extension')) {
                 if (in_array($file, $this->modulesDirnames)) {
                     $module->setInfo('install', true);
                     $extension = $module_handler->getByDirname($module->getInfo('dirname'));
                     $module->setInfo('mid', $extension->getVar('mid'));
                     $module->setInfo('update', XoopsLocale::formatTimestamp($extension->getVar('last_update'), 's'));
                     $module->setInfo('hasconfig', $module->getVar('hasconfig'));
                     if (round($module->getInfo('version'), 2) != $extension->getVar('version')) {
                         $module->setInfo('warning_update', true);
                     }
                     $groups = array();
                     if (is_object($xoops->user)) {
                         $groups = $xoops->user->getGroups();
                     }
                     $sadmin = $moduleperm_handler->checkRight('module_admin', $module->getInfo('mid'), $groups);
                     if ($sadmin && ($module->getVar('hasnotification') || is_array($module->getInfo('config')) || is_array($module->getInfo('comments')))) {
                         $module->setInfo('link_pref', \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $module->getInfo('mid'));
                     }
                 } else {
                     $module->setInfo('install', false);
                 }
                 $module->setInfo('version', round($module->getInfo('version'), 2));
                 if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png')) {
                     $module->setInfo('logo_small', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png');
                 } else {
                     $module->setInfo('logo_small', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/16/default.png');
                 }
                 if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png')) {
                     $module->setInfo('logo_large', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png');
                 } else {
                     $module->setInfo('logo_large', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/32/default.png');
                 }
                 $module->setInfo('link_admin', \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/' . $module->getInfo('adminindex'));
                 $module->setInfo('options', $module->getAdminMenu());
                 $ret[] = $module;
                 unset($module);
                 ++$i;
             }
         }
     }
     return $ret;
 }
Ejemplo n.º 6
0
 /**
  * @return string
  */
 public static function decode($url, $width, $height)
 {
     $config = parent::loadConfig(__DIR__);
     if (empty($url) || empty($config['link'])) {
         return $url;
     }
     $charset = !empty($config['charset']) ? $config['charset'] : "UTF-8";
     $ret = "<a href='" . sprintf($config['link'], urlencode(XoopsLocale::convert_encoding($url, $charset))) . "' rel='external' title=''>{$text}</a>";
     return $ret;
 }
Ejemplo n.º 7
0
 /**
  * @param string $name
  */
 public function loadLanguage($name)
 {
     $helper = Menus::getInstance();
     $language = XoopsLocale::getLegacyLanguage();
     $path = $helper->path("decorators/{$name}/language");
     if (!($ret = XoopsLoad::loadFile("{$path}/{$language}/decorator.php"))) {
         $ret = XoopsLoad::loadFile("{$path}/english/decorator.php");
     }
     return $ret;
 }
Ejemplo n.º 8
0
 /**
  * gets list of locales
  *
  * @param boolean $showInCodeLanguage true to show a code's name in the language the code represents
  *
  * @return array
  */
 public static function getList($showInCodeLanguage = false)
 {
     $locales = Data::getAvailableLocales();
     $languages = array();
     foreach ($locales as $locale) {
         $key = \Xoops\Locale::normalizeLocale($locale);
         $languages[$key] = Language::getName($locale, $showInCodeLanguage ? $locale : null);
     }
     \XoopsLocale::asort($languages);
     return $languages;
 }
Ejemplo n.º 9
0
 public function getValues($keys = null, $format = null, $maxDepth = null)
 {
     $page = Page::getInstance();
     $ret = parent::getValues($keys, $format, $maxDepth);
     $ret['rating'] = number_format($this->getVar('content_rating'), 1);
     // these next two lines are rather silly
     $ret['content_authorid'] = $this->getVar('content_author');
     $ret['content_author'] = XoopsUser::getUnameFromId($this->getVar('content_author'), true);
     $ret['content_date'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_dateformat'));
     $ret['content_time'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_timeformat'));
     $ret['content_rating'] = number_format($this->getVar('content_rating'), 2);
     return $ret;
 }
 function execute()
 {
     $xoops = Xoops::getInstance();
     // use HTMLPurifier inside Protector
     //require_once $xoops->path('lib/HTMLPurifier/HTMLPurifier.auto.php');
     $config = HTMLPurifier_Config::createDefault();
     $config->set('Cache', 'SerializerPath', \XoopsBaseConfig::get('lib-path'));
     $config->set('Core', 'Encoding', XoopsLocale::getCharset());
     //$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
     $this->purifier = new HTMLPurifier($config);
     $this->method = 'purify';
     $_POST = $this->purify_recursive($_POST);
 }
Ejemplo n.º 11
0
 /**
  * gets list of image file names in a directory
  *
  * @param string $path   filesystem path
  * @param string $prefix prefix added to file names
  *
  * @return array
  */
 public static function getList($path = null, $prefix = '')
 {
     $fileList = array();
     if (is_dir($path) && ($handle = opendir($path))) {
         while (false !== ($file = readdir($handle))) {
             if (preg_match('/\\.(gif|jpg|jpeg|png|swf)$/i', $file)) {
                 $file = $prefix . $file;
                 $fileList[$file] = $file;
             }
         }
         closedir($handle);
         \XoopsLocale::asort($fileList);
         reset($fileList);
     }
     return $fileList;
 }
Ejemplo n.º 12
0
 public function __construct()
 {
     parent::__construct();
     // SMARTY_PLUGINS_DIR is initialized into parent
     $xoops = Xoops::getInstance();
     $xoops->preload()->triggerEvent('core.template.construct.start', array($this));
     $this->left_delimiter = '<{';
     $this->right_delimiter = '}>';
     $this->setTemplateDir(\XoopsBaseConfig::get('themes-path'));
     $this->setCacheDir(\XoopsBaseConfig::get('smarty-cache'));
     $this->setCompileDir(\XoopsBaseConfig::get('smarty-compile'));
     $this->compile_check = $xoops->getConfig('theme_fromfile') == 1;
     $this->setPluginsDir(\XoopsBaseConfig::get('smarty-xoops-plugins'));
     $this->addPluginsDir(SMARTY_PLUGINS_DIR);
     $this->setCompileId();
     $this->assign(array('xoops_url' => \XoopsBaseConfig::get('url'), 'xoops_rootpath' => \XoopsBaseConfig::get('root-path'), 'xoops_langcode' => XoopsLocale::getLangCode(), 'xoops_charset' => XoopsLocale::getCharset(), 'xoops_version' => \Xoops::VERSION, 'xoops_upload_url' => \XoopsBaseConfig::get('uploads-url')));
 }
Ejemplo n.º 13
0
 public function test__construct()
 {
     $xoops = \Xoops::getInstance();
     $this->assertSame('{', $this->object->left_delimiter);
     $this->assertSame('}', $this->object->right_delimiter);
     $this->assertTrue(in_array(\XoopsBaseConfig::get('themes-path') . DIRECTORY_SEPARATOR, $this->object->getTemplateDir()));
     $this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_cache' . DIRECTORY_SEPARATOR, $this->object->getCacheDir());
     $this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_compile' . DIRECTORY_SEPARATOR, $this->object->getCompileDir());
     $this->assertSame($xoops->getConfig('theme_fromfile') == 1, $this->object->compile_check);
     $this->assertSame(array(\XoopsBaseConfig::get('lib-path') . '/smarty/xoops_plugins' . DIRECTORY_SEPARATOR, SMARTY_DIR . 'plugins' . DS), $this->object->plugins_dir);
     $this->assertSame(\XoopsBaseConfig::get('url'), $this->object->getTemplateVars('xoops_url'));
     $this->assertSame(\XoopsBaseConfig::get('root-path'), $this->object->getTemplateVars('xoops_rootpath'));
     $this->assertSame(\XoopsLocale::getLangCode(), $this->object->getTemplateVars('xoops_langcode'));
     $this->assertSame(\XoopsLocale::getCharset(), $this->object->getTemplateVars('xoops_charset'));
     $this->assertSame(\Xoops::VERSION, $this->object->getTemplateVars('xoops_version'));
     $this->assertSame(\XoopsBaseConfig::get('uploads-url'), $this->object->getTemplateVars('xoops_upload_url'));
 }
Ejemplo n.º 14
0
/**
 * @param string $value
 * @param string $out_charset
 * @param string $in_charset
 *
 * @return string
 */
function xlanguage_convert_item($value, $out_charset, $in_charset)
{
    $xoops = Xoops::getInstance();
    if (strtolower($in_charset) == strtolower($out_charset)) {
        return $value;
    }
    $xconv_handler = $xoops->getModuleHandler('xconv', 'xconv', true);
    if (is_object($xconv_handler) && ($converted_value = @$xconv_handler->convert_encoding($value, $out_charset, $in_charset))) {
        return $converted_value;
    }
    if (XoopsLocale::isMultiByte() && function_exists('mb_convert_encoding')) {
        $converted_value = @mb_convert_encoding($value, $out_charset, $in_charset);
    } elseif (function_exists('iconv')) {
        $converted_value = @iconv($in_charset, $out_charset, $value);
    }
    $value = empty($converted_value) ? $value : $converted_value;
    return $value;
}
Ejemplo n.º 15
0
 /**
  * @param   string   $name       Name of language file to be loaded, without extension
  * @param   mixed    $domain     string: Module dirname; global language file will be loaded if $domain is set to 'global' or not specified
  *                               array:  example; array('Frameworks/moduleclasses/moduleadmin')
  * @param   string   $language   Language to be loaded, current language content will be loaded if not specified
  *
  * @return  boolean
  */
 public static function loadLanguage($name, $domain = '', $language = null)
 {
     if (empty($name)) {
         return false;
     }
     $language = empty($language) ? XoopsLocale::getLegacyLanguage() : $language;
     // expanded domain to multiple categories, e.g. module:system, framework:filter, etc.
     if (empty($domain) || 'global' == $domain) {
         $path = '';
     } else {
         $path = is_array($domain) ? array_shift($domain) : "modules/{$domain}";
     }
     $xoops = Xoops::getInstance();
     $fullPath = $xoops->path("{$path}/language/{$language}/{$name}.php");
     if (!($ret = XoopsLoad::loadFile($fullPath))) {
         $fullPath2 = $xoops->path("{$path}/language/english/{$name}.php");
         $ret = XoopsLoad::loadFile($fullPath2);
     }
     return $ret;
 }
Ejemplo n.º 16
0
/**
 * @return array|bool|string
 */
function b_system_newmembers_show($options)
{
    $xoops = Xoops::getInstance();
    $block = array();
    $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
    $limit = !empty($options[0]) ? $options[0] : 10;
    $criteria->setOrder('DESC');
    $criteria->setSort('user_regdate');
    $criteria->setLimit($limit);
    $member_handler = $xoops->getHandlerMember();
    $newmembers = $member_handler->getUsers($criteria);
    $count = count($newmembers);
    for ($i = 0; $i < $count; ++$i) {
        if ($options[1] == 1) {
            $block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') !== 'blank.gif' ? \XoopsBaseConfig::get('uploads-url') . '/' . $newmembers[$i]->getVar('user_avatar') : '';
        } else {
            $block['users'][$i]['avatar'] = '';
        }
        $block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
        $block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
        $block['users'][$i]['joindate'] = XoopsLocale::formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
    }
    return $block;
}
Ejemplo n.º 17
0
$content_arr = $content_Handler->getPagePublished($start, $nb_limit);
// Assign Template variables
$xoops->tpl()->assign('content_count', $content_count);
$keywords = array();
if ($content_count > 0) {
    //Cleaning the content of $content, they are assign by blocks and mess the output
    $xoops->tpl()->assign('content', array());
    foreach (array_keys($content_arr) as $i) {
        $content_id = $content_arr[$i]->getVar('content_id');
        $content['id'] = $content_id;
        $content['title'] = $content_arr[$i]->getVar('content_title');
        $content['shorttext'] = $content_arr[$i]->getVar('content_shorttext');
        $content['authorid'] = $content_arr[$i]->getVar('content_author');
        $content['author'] = XoopsUser::getUnameFromId($content_arr[$i]->getVar('content_author'));
        $content['date'] = XoopsLocale::formatTimestamp($content_arr[$i]->getVar('content_create'), $helper->getConfig('page_dateformat'));
        $content['time'] = XoopsLocale::formatTimestamp($content_arr[$i]->getVar('content_create'), $helper->getConfig('page_timeformat'));
        $xoops->tpl()->appendByRef('content', $content);
        $keywords[] = $content_arr[$i]->getVar('content_title');
        unset($content);
    }
    // Display Page Navigation
    if ($content_count > $nb_limit) {
        $nav = new XoopsPageNav($content_count, $nb_limit, $start, 'start');
        $xoops->tpl()->assign('nav_menu', $nav->renderNav(4));
    }
} else {
    $xoops->tpl()->assign('error_message', PageLocale::E_NO_CONTENT);
}
// Metas
//description
$xoTheme->addMeta('meta', 'description', strip_tags($helper->getModule()->name()) . ', ' . implode(',', $keywords));
Ejemplo n.º 18
0
 /**
  * @param string $dateFormat
  * @param string $format
  *
  * @return string
  */
 public function datesub($dateFormat = 's', $format = "S")
 {
     return XoopsLocale::formatTimestamp($this->getVar('datesub', $format), $dateFormat);
 }
Ejemplo n.º 19
0
    $tpl->assign('channel_lastbuild', XoopsLocale::formatTimestamp(time(), 'rss'));
    $tpl->assign('channel_webmaster', $xoops->getConfig('adminmail'));
    $tpl->assign('channel_editor', $xoops->getConfig('adminmail'));
    if ($categoryid != -1) {
        $channel_category .= " > " . $categoryObj->getVar('name');
    }
    $tpl->assign('channel_category', htmlspecialchars($channel_category));
    $tpl->assign('channel_generator', $publisher->getModule()->getVar('name'));
    $tpl->assign('channel_language', XoopsLocale::getLangCode());
    $tpl->assign('image_url', \XoopsBaseConfig::get('url') . '/images/logo.gif');
    $dimention = getimagesize(\XoopsBaseConfig::get('root-path') . '/images/logo.gif');
    if (empty($dimention[0])) {
        $width = 140;
        $height = 140;
    } else {
        $width = $dimention[0] > 140 ? 140 : $dimention[0];
        $dimention[1] = $dimention[1] * $width / $dimention[0];
        $height = $dimention[1] > 140 ? $dimention[1] * $dimention[0] / 140 : $dimention[1];
    }
    $tpl->assign('image_width', $width);
    $tpl->assign('image_height', $height);
    $sarray = $publisher->getItemHandler()->getAllPublished(10, 0, $categoryid);
    if (is_array($sarray)) {
        $count = $sarray;
        /* @var $item PublisherItem */
        foreach ($sarray as $item) {
            $tpl->append('items', array('title' => htmlspecialchars($item->title(), ENT_QUOTES), 'link' => $item->getItemUrl(), 'guid' => $item->getItemUrl(), 'pubdate' => XoopsLocale::formatTimestamp($item->getVar('datesub'), 'rss'), 'description' => htmlspecialchars($item->getBlockSummary(300, true), ENT_QUOTES)));
        }
    }
}
$tpl->display('module:publisher/publisher_rss.tpl');
Ejemplo n.º 20
0
$criteria->add(new Criteria('status', 2), 'AND');
$criteria->add(new Criteria('datesub', time(), '<='), 'AND');
$criteria->setSort('datesub');
$criteria->setOrder('DESC');
//Get all articles dates as an array to save memory
$items = $publisher->getItemHandler()->getAll($criteria, array('datesub'), false);
$itemsCount = count($items);
if (!($itemsCount > 0)) {
    $xoops->redirect(\XoopsBaseConfig::get('url'), 2, _MD_PUBLISHER_NO_TOP_PERMISSIONS);
} else {
    $this_year = 0;
    $years = array();
    $months = array();
    $i = 0;
    foreach ($items as $item) {
        $time = XoopsLocale::formatTimestamp($item['datesub'], 'mysql', $useroffset);
        if (preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $time, $datetime)) {
            $this_year = (int) $datetime[1];
            $this_month = (int) $datetime[2];
            if (empty($lastyear)) {
                $lastyear = $this_year;
            }
            if ($lastmonth == 0) {
                $lastmonth = $this_month;
                $months[$lastmonth]['string'] = $months_arr[$lastmonth];
                $months[$lastmonth]['number'] = $lastmonth;
            }
            if ($lastyear != $this_year) {
                $years[$i]['number'] = $lastyear;
                $years[$i]['months'] = $months;
                $months = array();
Ejemplo n.º 21
0
    $description = htmlspecialchars($description, ENT_QUOTES);
    $uname = htmlspecialchars($uid ? $uname : XoopsLocale::GUESTS, ENT_QUOTES);
    // make agents shorter
    if (preg_match('/MSIE\\s+([0-9.]+)/', $agent, $regs)) {
        $agent_short = 'IE ' . $regs[1];
    } else {
        if (stristr($agent, 'Gecko') !== false) {
            $agent_short = strrchr($agent, ' ');
        } else {
            $agent_short = substr($agent, 0, strpos($agent, ' '));
        }
    }
    $agent4disp = htmlspecialchars($agent, ENT_QUOTES);
    $agent_desc = $agent == $agent_short ? $agent4disp : htmlspecialchars($agent_short, ENT_QUOTES) . "<img src='../images/dotdotdot.gif' alt='{$agent4disp}' title='{$agent4disp}' />";
    $log_arr['lid'] = $lid;
    $log_arr['date'] = XoopsLocale::formatTimestamp($timestamp);
    $log_arr['uname'] = $uname;
    $log_arr['ip'] = $ip;
    $log_arr['agent_desc'] = $agent_desc;
    $log_arr['type'] = $type;
    $log_arr['description'] = $description;
    $xoops->tpl()->appendByRef('log', $log_arr);
    unset($table_arr);
}
$xoops->footer();
function protector_ip_cmp($a, $b)
{
    $as = explode('.', $a);
    $aval = @$as[0] * 167777216 + @$as[1] * 65536 + @$as[2] * 256 + @$as[3];
    $bs = explode('.', $b);
    $bval = @$bs[0] * 167777216 + @$bs[1] * 65536 + @$bs[2] * 256 + @$bs[3];
Ejemplo n.º 22
0
 /**
  * Load localization information
  * Folder structure for localization:
  * themes/themefolder/english
  *    - main.php - language definitions
  *    - style.css - localization stylesheet
  *    - script.js - localization script
  *
  * @param string $type language domain (unused?)
  *
  * @return array list of 2 arrays, one
  */
 public function getLocalizationAssets($type = "main")
 {
     $cssAssets = array();
     $jsAssets = array();
     $xoops = \Xoops::getInstance();
     \Xoops\Locale::loadThemeLocale($this);
     $language = \XoopsLocale::getLocale();
     // Load global localization stylesheet if available
     if (\XoopsLoad::fileExists($xoops->path('locale/' . $language . '/style.css'))) {
         $cssAssets[] = $xoops->path('locale/' . $language . '/style.css');
     }
     //$this->addLanguage($type);
     // Load theme localization stylesheet and scripts if available
     if (\XoopsLoad::fileExists($this->path . '/locale/' . $language . '/script.js')) {
         $jsAssets[] = $this->url . '/locale/' . $language . '/script.js';
     }
     if (\XoopsLoad::fileExists($this->path . '/locale/' . $language . '/style.css')) {
         $cssAssets[] = $this->path . '/locale/' . $language . '/style.css';
     }
     return array($cssAssets, $jsAssets);
 }
Ejemplo n.º 23
0
            }
            unset($pm);
        }
        $xoops->redirect("viewpmsg.php", 1, XoopsLocale::S_YOUR_MESSAGES_DELETED);
    }
    $xoops->header('module:system/system_viewpmsg.tpl');
    $criteria = new Criteria('to_userid', $xoops->user->getVar('uid'));
    $criteria->setSort('msg_time');
    $criteria->setOrder('DESC');
    $pm_arr = $pm_handler->getObjects($criteria);
    $total_messages = count($pm_arr);
    $xoops->tpl()->assign('display', true);
    $xoops->tpl()->assign('anonymous', $xoops->getConfig('anonymous'));
    $xoops->tpl()->assign('uid', $xoops->user->getVar("uid"));
    $xoops->tpl()->assign('total_messages', $total_messages);
    $msg_no = 0;
    foreach (array_keys($pm_arr) as $i) {
        $messages['msg_id'] = $pm_arr[$i]->getVar("msg_id");
        $messages['read_msg'] = $pm_arr[$i]->getVar("read_msg");
        $messages['msg_image'] = $pm_arr[$i]->getVar("msg_image");
        $messages['posteruid'] = $pm_arr[$i]->getVar('from_userid');
        $messages['postername'] = XoopsUser::getUnameFromId($pm_arr[$i]->getVar('from_userid'));
        $messages['subject'] = $pm_arr[$i]->getVar("subject");
        $messages['msg_time'] = XoopsLocale::formatTimestamp($pm_arr[$i]->getVar('msg_time'));
        $messages['msg_no'] = $msg_no;
        $xoops->tpl()->append('messages', $messages);
        ++$msg_no;
    }
    $xoops->tpl()->assign('token', $xoops->security()->getTokenHTML());
    $xoops->footer();
}
Ejemplo n.º 24
0
     } else {
         if ($pm_arr[0]->getVar('read_msg') == 0) {
             $pm_handler->setRead($pm_arr[0]);
         }
         $poster = new XoopsUser($pm_arr[0]->getVar("from_userid"));
         if (!is_object($poster)) {
             $xoops->tpl()->assign('poster', false);
             $xoops->tpl()->assign('anonymous', $xoopsConfig['anonymous']);
         } else {
             $xoops->tpl()->assign('poster', $poster);
             $avatar = $xoops->service('avatar')->getAvatarUrl($poster)->getValue();
             $xoops->tpl()->assign('poster_avatar', $avatar);
         }
         $xoops->tpl()->assign('msg_id', $pm_arr[0]->getVar("msg_id"));
         $xoops->tpl()->assign('subject', $pm_arr[0]->getVar("subject"));
         $xoops->tpl()->assign('msg_time', XoopsLocale::formatTimestamp($pm_arr[0]->getVar("msg_time")));
         $xoops->tpl()->assign('msg_image', $pm_arr[0]->getVar("msg_image", "E"));
         $xoops->tpl()->assign('msg_text', $pm_arr[0]->getVar("msg_text"));
         $xoops->tpl()->assign('previous', $start - 1);
         $xoops->tpl()->assign('next', $start + 1);
         $xoops->tpl()->assign('total_messages', $total_messages);
         $xoops->tpl()->assign('read', true);
         $xoops->tpl()->assign('token', $xoops->security()->getTokenHTML());
     }
     break;
 case 'delete':
     $obj = $pm_handler->get($id);
     if (isset($_POST["ok"]) && $_POST["ok"] == 1) {
         if (!$xoops->security()->check()) {
             $xoops->redirect("viewpmsg.php", 3, implode(",", $xoops->security()->getErrors()));
         }
Ejemplo n.º 25
0
     if (!preg_match("/^http[s]*:\\/\\//i", $results[$i]['link'])) {
         $res[$i]['link'] = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $results[$i]['link']);
     } else {
         $res[$i]['link'] = $results[$i]['link'];
     }
     $res[$i]['title'] = $myts->htmlSpecialChars($results[$i]['title']);
     if (isset($queries_pattern)) {
         $res[$i]['title_highligh'] = preg_replace($queries_pattern, "<span class='searchHighlight'>\$1</span>", $myts->htmlSpecialChars($results[$i]['title']));
     } else {
         $res[$i]['title_highligh'] = $myts->htmlSpecialChars($results[$i]['title']);
     }
     if (!empty($results[$i]['uid'])) {
         $res[$i]['uid'] = @(int) $results[$i]['uid'];
         $res[$i]['uname'] = XoopsUser::getUnameFromId($results[$i]['uid'], true);
     }
     $res[$i]['time'] = !empty($results[$i]['time']) ? " (" . XoopsLocale::formatTimestamp((int) $results[$i]['time']) . ")" : "";
     $res[$i]['content'] = empty($results[$i]['content']) ? "" : preg_replace($queries_pattern, "<span class='searchHighlight'>\$1</span>", $results[$i]['content']);
 }
 if (count($res) > 0) {
     $modules_result[$mid]['result'] = $res;
 }
 $search_url = $search->url('index.php?query=' . urlencode(stripslashes(implode(' ', $queries))));
 $search_url .= "&mid={$mid}&action={$action}&andor={$andor}";
 if ($action === 'showallbyuser') {
     $search_url .= "&uid={$uid}";
 }
 if ($start > 0) {
     $prev = $start - 20;
     $search_url_prev = $search_url . "&start={$prev}";
     $modules_result[$mid]['prev'] = htmlspecialchars($search_url_prev);
 }
Ejemplo n.º 26
0
             $users['checkbox_user'] = false;
         } else {
             $users['group'] = system_AdminIcons('xoops/group_2.png');
             //$users['icon'] = '<img src="'.\XoopsBaseConfig::get('url').'/modules/system/images/icons/user.png" alt="'._AM_SYSTEM_USERS_USER.'" title="'._AM_SYSTEM_USERS_USER.'" />';
             $users['checkbox_user'] = true;
         }
         $users['name'] = $user->getVar("uid");
         $users['name'] = $user->getVar("name");
         $users['uname'] = $user->getVar("uname");
         $users['email'] = $user->getVar("email");
         $users['url'] = $user->getVar("url");
         $avatar = $xoops->service('avatar')->getAvatarUrl($user)->getValue();
         $users['user_avatar'] = empty($avatar) ? system_AdminIcons('anonymous.png') : $avatar;
         $users['reg_date'] = XoopsLocale::formatTimestamp($user->getVar("user_regdate"), "m");
         if ($user->getVar("last_login") > 0) {
             $users['last_login'] = XoopsLocale::formatTimestamp($user->getVar("last_login"), "m");
         } else {
             $users['last_login'] = SystemLocale::NEVER_CONNECTED;
         }
         $users['user_level'] = $user->getVar("level");
         $users['user_icq'] = $user->getVar("user_icq");
         $users['user_aim'] = $user->getVar("user_aim");
         $users['user_yim'] = $user->getVar("user_yim");
         $users['user_msnm'] = $user->getVar("user_msnm");
         $users['posts'] = $user->getVar("posts");
         $xoops->tpl()->appendByRef('users', $users);
         $xoops->tpl()->appendByRef('users_popup', $users);
         unset($users, $user);
     }
 } else {
     $xoops->tpl()->assign('users_no_found', true);
Ejemplo n.º 27
0
 /**
  * Send a message to user's email
  *
  * @param XoopsObject|PmMessage $pm
  * @param null|XoopsUser $user
  * @return bool
  */
 public function sendEmail(PmMessage $pm, XoopsUser $user = null)
 {
     $xoops = Xoops::getInstance();
     if (!is_object($user)) {
         $user = $xoops->user;
     }
     $msg = sprintf(_PM_EMAIL_DESC, $user->getVar("uname"));
     $msg .= "\n\n";
     $msg .= XoopsLocale::formatTimestamp($pm->getVar("msg_time"));
     $msg .= "\n";
     $from = new XoopsUser($pm->getVar("from_userid"));
     $to = new XoopsUser($pm->getVar("to_userid"));
     $msg .= sprintf(_PM_EMAIL_FROM, $from->getVar("uname") . " (" . \XoopsBaseConfig::get('url') . "/userinfo.php?uid=" . $pm->getVar("from_userid") . ")");
     $msg .= "\n";
     $msg .= sprintf(_PM_EMAIL_TO, $to->getVar("uname") . " (" . \XoopsBaseConfig::get('url') . "/userinfo.php?uid=" . $pm->getVar("to_userid") . ")");
     $msg .= "\n";
     $msg .= _PM_EMAIL_MESSAGE . ":\n";
     $msg .= "\n" . $pm->getVar("subject") . "\n";
     $msg .= "\n" . strip_tags(str_replace(array("<p>", "</p>", "<br />", "<br />"), "\n", $pm->getVar("msg_text"))) . "\n\n";
     $msg .= "--------------\n";
     $msg .= $xoops->getConfig('sitename') . ": " . \XoopsBaseConfig::get('url') . "\n";
     $xoopsMailer = $xoops->getMailer();
     $xoopsMailer->useMail();
     $xoopsMailer->setToEmails($user->getVar("email"));
     $xoopsMailer->setFromEmail($xoops->getConfig('adminmail'));
     $xoopsMailer->setFromName($xoops->getConfig('sitename'));
     $xoopsMailer->setSubject(sprintf(_PM_EMAIL_SUBJECT, $pm->getVar("subject")));
     $xoopsMailer->setBody($msg);
     return $xoopsMailer->send();
 }
Ejemplo n.º 28
0
}
$xoops->tpl()->assign('display', $total_messages > 0);
$xoops->tpl()->assign('anonymous', $xoops->getConfig('anonymous'));
if (count($pm_arr) > 0) {
    foreach (array_keys($pm_arr) as $i) {
        if (isset($_REQUEST['op']) && $_REQUEST['op'] == "out") {
            $uids[] = $pm_arr[$i]['to_userid'];
        } else {
            $uids[] = $pm_arr[$i]['from_userid'];
        }
    }
    $member_handler = $xoops->getHandlerMember();
    $senders = $member_handler->getUserList(new Criteria('uid', "(" . implode(", ", array_unique($uids)) . ")", "IN"));
    foreach (array_keys($pm_arr) as $i) {
        $message = $pm_arr[$i];
        $message['msg_time'] = XoopsLocale::formatTimestamp($message["msg_time"]);
        if (isset($_REQUEST['op']) && $_REQUEST['op'] == "out") {
            $message['postername'] = $senders[$pm_arr[$i]['to_userid']];
            $message['posteruid'] = $pm_arr[$i]['to_userid'];
        } else {
            $message['postername'] = $senders[$pm_arr[$i]['from_userid']];
            $message['posteruid'] = $pm_arr[$i]['from_userid'];
        }
        $message['msg_no'] = $i;
        $xoops->tpl()->append('messages', $message);
    }
}
$send_button = new Xoops\Form\Button('', 'send', XoopsLocale::A_SEND);
$send_button->setExtra("onclick='javascript:openWithSelfMain(\"" . \XoopsBaseConfig::get('url') . "/modules/pm/pmlite.php?send=1\", \"pmlite\", 750,720);'");
$delete_button = new Xoops\Form\Button('', 'delete_messages', XoopsLocale::A_DELETE, 'submit');
$move_button = new Xoops\Form\Button('', 'move_messages', $_REQUEST['op'] == 'save' ? _PM_UNSAVE : _PM_TOSAVE, 'submit');
Ejemplo n.º 29
0
 /**
  * Render about page
  *
  * @param bool $logo_xoops show logo
  *
  * @return bool|mixed|string
  */
 public function renderAbout($logo_xoops = true)
 {
     $xoops = \Xoops::getInstance();
     $date = explode('/', $this->module->getInfo('release_date'));
     $author = explode(',', $this->module->getInfo('author'));
     $nickname = explode(',', $this->module->getInfo('nickname'));
     $release_date = \XoopsLocale::formatTimestamp(mktime(0, 0, 0, $date[1], $date[2], $date[0]), 's');
     $author_list = '';
     foreach (array_keys($author) as $i) {
         $author_list .= $author[$i];
         if (isset($nickname[$i]) && $nickname[$i] != '') {
             $author_list .= " (" . $nickname[$i] . "), ";
         } else {
             $author_list .= ", ";
         }
     }
     $changelog = '';
     $language = $xoops->getConfig('locale');
     if (!is_file(\XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt")) {
         $language = 'en_US';
     }
     $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt";
     if (is_readable($file)) {
         $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
     } else {
         $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/docs/changelog.txt";
         if (is_readable($file)) {
             $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
         }
     }
     $author_list = substr($author_list, 0, -2);
     $this->module->setInfo('release_date', $release_date);
     $this->module->setInfo('author_list', $author_list);
     if (is_array($this->module->getInfo('paypal'))) {
         $this->module->setInfo('paypal', $this->module->getInfo('paypal'));
     }
     $this->module->setInfo('changelog', $changelog);
     $xoops->tpl()->assign('module', $this->module);
     $this->addInfoBox(\XoopsLocale::MODULE_INFORMATION, 'info', 'id="xo-about"');
     $this->addInfoBoxLine(\XoopsLocale::C_DESCRIPTION . ' ' . $this->module->getInfo("description"), 'info');
     $this->addInfoBoxLine(\XoopsLocale::C_UPDATE_DATE . ' <span class="bold">' . \XoopsLocale::formatTimestamp($this->module->getVar("last_update"), "m") . '</span>', 'info');
     $this->addInfoBoxLine(\XoopsLocale::C_WEBSITE . ' <a class="xo-tooltip" href="http://' . $this->module->getInfo("module_website_url") . '" rel="external" title="' . $this->module->getInfo("module_website_name") . ' - ' . $this->module->getInfo("module_website_url") . '">' . $this->module->getInfo("module_website_name") . '</a>', 'info');
     $xoops->tpl()->assign('xoops_logo', $logo_xoops);
     $xoops->tpl()->assign('xo_admin_box', $this->itemInfoBox);
     return $xoops->tpl()->fetch($this->getTplPath('about'));
 }
Ejemplo n.º 30
0
function buildRssFeedCache($rssurl)
{
    $snoopy = new Snoopy();
    $cnt = 0;
    foreach ($rssurl as $url) {
        if ($snoopy->fetch($url)) {
            $rssdata = $snoopy->results;
            $rss2parser = new XoopsXmlRss2Parser($rssdata);
            if (false != $rss2parser->parse()) {
                $_items = $rss2parser->getItems();
                $count = count($_items);
                for ($i = 0; $i < $count; $i++) {
                    $_items[$i]['title'] = XoopsLocale::convert_encoding($_items[$i]['title'], XoopsLocale::getCharset(), 'UTF-8');
                    $_items[$i]['description'] = XoopsLocale::convert_encoding($_items[$i]['description'], XoopsLocale::getCharset(), 'UTF-8');
                    $items[(string) strtotime($_items[$i]['pubdate']) . "-" . (string) ++$cnt] = $_items[$i];
                }
            } else {
                echo $rss2parser->getErrors();
            }
        }
    }
    krsort($items);
    return $items;
}