/** * @return void */ public function getDump() { $xoops = Xoops::getInstance(); $maintenance = new Maintenance(); parent::__construct('', "form_dump", "dump.php", 'post', true); $dump_tray = new Xoops\Form\ElementTray(_AM_MAINTENANCE_DUMP_TABLES_OR_MODULES, ''); $select_tables1 = new Xoops\Form\Select('', "dump_tables", '', 7, true); $select_tables1->addOptionArray($maintenance->displayTables(true)); $dump_tray->addElement($select_tables1, false); $ele = new Xoops\Form\Select(' ' . _AM_MAINTENANCE_OR . ' ', 'dump_modules', '', 7, true); $module_list = XoopsLists::getModulesList(); $module_handler = $xoops->getHandlerModule(); foreach ($module_list as $file) { if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) { clearstatcache(); $file = trim($file); $module = $module_handler->create(); $module->loadInfo($file); if ($module->getInfo('tables') && $xoops->isActiveModule($file)) { $ele->addOption($module->getInfo('dirname'), $module->getInfo('name')); } unset($module); } } $dump_tray->addElement($ele); $this->addElement($dump_tray); $this->addElement(new Xoops\Form\RadioYesNo(_AM_MAINTENANCE_DUMP_DROP, 'drop', 1)); $this->addElement(new Xoops\Form\Hidden("op", "dump_save")); $this->addElement(new Xoops\Form\Button("", "dump_save", XoopsLocale::A_SUBMIT, "submit")); }
/** * execute the command * * @param InputInterface $input input handler * @param OutputInterface $output output handler * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $xoops = \Xoops::getInstance(); $module = $input->getArgument('module'); if (false === \XoopsLoad::fileExists($xoops->path("modules/{$module}/xoops_version.php"))) { $output->writeln(sprintf('<error>No module named %s found!</error>', $module)); return; } $output->writeln(sprintf('Installing %s', $module)); if (false !== $xoops->getModuleByDirname($module)) { $output->writeln(sprintf('<error>%s module is already installed!</error>', $module)); return; } $xoops->setTpl(new XoopsTpl()); \XoopsLoad::load('module', 'system'); $sysmod = new \SystemModule(); $result = $sysmod->install($module); foreach ($sysmod->trace as $message) { if (is_array($message)) { foreach ($message as $subMessage) { if (!is_array($subMessage)) { $output->writeln(strip_tags($subMessage)); } } } else { $output->writeln(strip_tags($message)); } } if ($result === false) { $output->writeln(sprintf('<error>Install of %s failed!</error>', $module)); } else { $output->writeln(sprintf('<info>Install of %s completed.</info>', $module)); } $xoops->cache()->delete('system'); }
/** * Init the module * * @return null|void */ public function init() { if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/vars.php')) { include_once $hnd_file; } if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/functions.php')) { include_once $hnd_file; } $this->setDirname('xlanguage'); }
/** * xoModuleIcons16 Smarty compiler plug-in * * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @author Andricq Nicolas (AKA MusS) * @since 2.5.2 */ function smarty_compiler_xoModuleIconsBookmarks($argStr, &$smarty) { $xoops = Xoops::getInstance(); if (XoopsLoad::fileExists($xoops->path('media/xoops/images/icons/bookmarks/index.html'))) { $url = $xoops->url('media/xoops/images/icons/bookmarks/' . $argStr); } else { if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/default/' . $argStr))) { $url = $xoops->url('modules/system/images/icons/default/' . $argStr); } else { $url = $xoops->url('modules/system/images/icons/default/xoops/xoops.png'); } } return "\necho '" . addslashes($url) . "';"; }
function XoopsGTicket() { $xoops = Xoops::getInstance(); $language = $xoops->getConfig('language'); // language file if ($language && !strstr($language, '/')) { if (XoopsLoad::fileExists(dirname(__DIR__) . '/language/' . $language . '/gticket_messages.phtml')) { include dirname(__DIR__) . '/language/' . $language . '/gticket_messages.phtml'; } } // default messages if (empty($this->messages)) { $this->messages = array('err_general' => 'GTicket Error', 'err_nostubs' => 'No stubs found', 'err_noticket' => 'No ticket found', 'err_nopair' => 'No valid ticket-stub pair found', 'err_timeout' => 'Time out', 'err_areaorref' => 'Invalid area or referer', 'fmt_prompt4repost' => 'error(s) found:<br /><span style="background-color:red;font-weight:bold;color:white;">%s</span><br />Confirm it.<br />And do you want to post again?', 'btn_repost' => 'repost'); } }
/** * xoModuleIcons16 Smarty compiler plug-in * * @copyright XOOPS Project (http://xoops.org) * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Andricq Nicolas (AKA MusS) * @since 2.5.2 * @version $Id$ */ function smarty_compiler_xoModuleIcons16($params, Smarty $smarty) { $xoops = Xoops::getInstance(); $arg = reset($params); $ico = trim($arg, " '\"\t\n\r\v"); if (XoopsLoad::fileExists($xoops->path('media/xoops/images/icons/16/index.html'))) { $url = $xoops->url('media/xoops/images/icons/16/' . $ico); } else { if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/default/' . $ico))) { $url = $xoops->url('modules/system/images/icons/default/' . $ico); } else { $url = $xoops->url('modules/system/images/icons/default/xoops/xoops2.png'); } } return "<?php echo '" . addslashes($url) . "'; ?>"; }
/** * xoAdminNav Smarty compiler plug-in * * @copyright XOOPS Project (http://xoops.org) * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Andricq Nicolas (AKA MusS) * @since 2.5 * @version $Id$ */ function smarty_compiler_xoAdminNav($argStr, &$smarty) { $xoops = Xoops::getInstance(); $icons = $xoops->getModuleConfig('typebreadcrumb', 'system'); if ($icons == '') { $icons = 'default'; } $url = ''; if (XoopsLoad::fileExists($xoops->path('modules/system/images/breadcrumb/' . $icons . '/index.html'))) { $url = $xoops->url('modules/system/images/breadcrumb/' . $icons . '/' . $argStr); } else { if (XoopsLoad::fileExists($xoops->path('modules/system/images/breadcrumb/default/' . $argStr))) { $url = $xoops->url('modules/system/images/icons/default/' . $argStr); } } return "\necho '" . addslashes($url) . "';"; }
/** * xoAdminIcons Smarty compiler plug-in * * @copyright XOOPS Project (http://xoops.org) * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author Andricq Nicolas (AKA MusS) * @since 2.5 * @version $Id$ */ function smarty_compiler_xoAdminIcons($params, Smarty $smarty) { $xoops = Xoops::getInstance(); $arg = reset($params); $ico = trim($arg, " '\"\t\n\r\v"); $icons = $xoops->getModuleConfig('typeicons', 'system'); if ($icons == '') { $icons = 'default'; } if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/' . $icons . '/index.html'))) { $url = $xoops->url('modules/system/images/icons/' . $icons . '/' . $ico); } else { if (XoopsLoad::fileExists($xoops->path('modules/system/images/icons/default/' . $ico))) { $url = $xoops->url('modules/system/images/icons/default/' . $ico); } else { $url = $xoops->url('modules/system/images/icons/default/xoops/xoops.png'); } } return "<?php echo '" . addslashes($url) . "'; ?>"; }
/** * build a module handler for legacy module * * @param FactorySpec $spec specification for requested handler * * @return XoopsObjectHandler|null */ public function build(FactorySpec $spec) { $handler = null; $name = strtolower($spec->getName()); $dirname = strtolower($spec->getDirname()); $handlerFile = \XoopsBaseConfig::get('root-path') . "/modules/{$dirname}/class/{$name}.php"; if (\XoopsLoad::fileExists($handlerFile)) { include_once $handlerFile; } $class = ucfirst($dirname) . ucfirst($name) . 'Handler'; if (class_exists($class, false)) { $handler = new $class($spec->getFactory()->db()); } if ($handler === null) { if (false === $spec->getOptional()) { throw new NoHandlerException(sprintf('Class not found %s', $class)); } } return $handler; }
/** * Blocks functions * * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @author Kazumi Ono (AKA onokazu) * @package system * @version $Id$ */ function b_system_main_show() { $xoops = Xoops::getInstance(); $block = array(); $block['lang_home'] = XoopsLocale::HOME; $block['lang_close'] = XoopsLocale::A_CLOSE; $module_handler = $xoops->getHandlerModule(); $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); $criteria->add(new Criteria('isactive', 1)); $criteria->add(new Criteria('weight', 0, '>')); $modules = $module_handler->getObjectsArray($criteria, true); $moduleperm_handler = $xoops->getHandlerGroupperm(); $groups = $xoops->getUserGroups(); $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups); /* @var $module XoopsModule */ foreach ($modules as $i => $module) { if (in_array($i, $read_allowed)) { $block['modules'][$i]['name'] = $module->getVar('name'); $block['modules'][$i]['dirname'] = $module->getVar('dirname'); if (XoopsLoad::fileExists($xoops->path('modules/' . $module->getVar('dirname') . '/icons/logo_small.png'))) { $block['modules'][$i]['image'] = $xoops->url('modules/' . $module->getVar('dirname') . '/icons/logo_small.png'); } if ($xoops->isModule() && $i == $xoops->module->getVar('mid')) { $block['modules'][$i]['highlight'] = true; $block['nothome'] = true; } if ($xoops->module && $i == $xoops->module->getVar('mid')) { $block['modules'][$i]['highlight'] = true; $block['nothome'] = true; } /* @var $plugin MenusPluginInterface */ if ($xoops->isModule() && $module->getVar('dirname') == $xoops->module->getVar('dirname') && ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'menus'))) { $sublinks = $plugin->subMenus(); foreach ($sublinks as $sublink) { $block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => \XoopsBaseConfig::get('url') . '/modules/' . $module->getVar('dirname') . '/' . $sublink['url']); } } } } return $block; }
$xoops->tpl()->assign('ignored_queries', $ignored_queries); $modules_result = array(); foreach ($mids as $mid) { $mid = (int) $mid; /* @var $module XoopsModule */ $module = $modules[$mid]; /* @var $plugin SearchPluginInterface */ $plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'search'); $results = $plugin->search($queries, $andor, 5, 0, null); $count = count($results); $mid = $module->getVar('mid'); $res = array(); if (is_array($results) && $count > 0) { $nomatch = false; $modules_result[$mid]['name'] = $module->getVar('name'); if (XoopsLoad::fileExists($image = $xoops->path('modules/' . $module->getVar('dirname') . '/icons/logo_large.png'))) { $modules_result[$mid]['image'] = $xoops->url($image); } else { $modules_result[$mid]['image'] = $xoops->url('images/icons/posticon2.gif'); } $res = array(); for ($i = 0; $i < $count; ++$i) { 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']); $res[$i]['title_highligh'] = preg_replace($queries_pattern, "<span class='searchHighlight'>\$1</span>", $myts->htmlSpecialChars($results[$i]['title'])); if (!empty($results[$i]['uid'])) { $res[$i]['uid'] = (int) $results[$i]['uid'];
function deny_by_htaccess($ip = null) { if (empty($ip)) { $ip = @$_SERVER['REMOTE_ADDR']; } if (empty($ip)) { return false; } if (!function_exists('file_get_contents')) { return false; } $target_htaccess = \XoopsBaseConfig::get('root-path') . '/.htaccess'; $backup_htaccess = \XoopsBaseConfig::get('root-path') . '/uploads/.htaccess.bak'; $ht_body = file_get_contents($target_htaccess); // make backup as uploads/.htaccess.bak automatically if ($ht_body && !XoopsLoad::fileExists($backup_htaccess)) { $fw = fopen($backup_htaccess, "w"); fwrite($fw, $ht_body); fclose($fw); } // if .htaccess is broken, restore from backup if (!$ht_body && XoopsLoad::fileExists($backup_htaccess)) { $ht_body = file_get_contents($backup_htaccess); } // new .htaccess if ($ht_body === false) { $ht_body = ''; } if (preg_match("/^(.*)#PROTECTOR#\\s+(DENY FROM .*)\n#PROTECTOR#\n(.*)\$/si", $ht_body, $regs)) { if (substr($regs[2], -strlen($ip)) == $ip) { return true; } $new_ht_body = $regs[1] . "#PROTECTOR#\n" . $regs[2] . " {$ip}\n#PROTECTOR#\n" . $regs[3]; } else { $new_ht_body = "#PROTECTOR#\nDENY FROM {$ip}\n#PROTECTOR#\n" . $ht_body; } // error_log( "$new_ht_body\n" , 3 , "/tmp/error_log" ) ; $fw = fopen($target_htaccess, "w"); @flock($fw, LOCK_EX); fwrite($fw, $new_ht_body); @flock($fw, LOCK_UN); fclose($fw); return true; }
/** * Return a themable file resource path * * @param string $path file path * * @return string */ public function resourcePath($path) { if (substr($path, 0, 1) === '/') { $path = substr($path, 1); } $xoops_root_path = \XoopsBaseConfig::get('root-path'); //\Xoops::getInstance()->events()->triggerEvent('debug.log', $this); if (\XoopsLoad::fileExists($xoops_root_path . "/{$this->themesPath}/{$this->folderName}/{$path}")) { //\Xoops::getInstance()->events()->triggerEvent('debug.log', "custom theme path {$this->themesPath}/{$this->folderName}/{$path}"); return "{$this->themesPath}/{$this->folderName}/{$path}"; } if (\XoopsLoad::fileExists($xoops_root_path . "/themes/{$this->folderName}/{$path}")) { //\Xoops::getInstance()->events()->triggerEvent('debug.log', "main theme folder themes/{$this->folderName}/{$path}"); return "themes/{$this->folderName}/{$path}"; } //\Xoops::getInstance()->events()->triggerEvent('debug.log', "drop thru {$path}"); return $path; }
function header() { $xoops = Xoops::getInstance(); $xoops->loadLocale('system'); $xoops->theme()->addBaseStylesheetAssets('@jqueryuicss'); $xoops->theme()->addStylesheet('media/xoops/css/moduladmin.css'); $xoops->theme()->addStylesheet(\XoopsBaseConfig::get('adminthemes-url') . '/default/css/style.css'); $xoops->theme()->addBaseScriptAssets('@jquery'); // bootstrap has to come before jquery.ui or dialog close buttons are blank $xoops->theme()->addBaseScriptAssets('@bootstrap'); $xoops->theme()->addBaseScriptAssets('@jqueryui'); $xoops->theme()->addBaseScriptAssets('@jgrowl'); // ddsmoothmenu $xoops->theme()->addScript(\XoopsBaseConfig::get('adminthemes-url') . '/default/js/ddsmoothmenu.js'); $xoops->theme()->addScript(\XoopsBaseConfig::get('adminthemes-url') . '/default/js/tooltip.js'); $quick = array(); $quick[] = array('title' => SystemLocale::CONTROL_PANEL, 'link' => \XoopsBaseConfig::get('url') . '/admin.php'); $quick[] = array('title' => XoopsLocale::HOME_PAGE, 'link' => \XoopsBaseConfig::get('url')); $quick[] = array('title' => DefaultThemeLocale::XOOPS_NEWS, 'link' => \XoopsBaseConfig::get('url') . '/admin.php?xoopsorgnews=1'); $quick[] = array('title' => 'separator'); $quick[] = array('title' => XoopsLocale::A_LOGOUT, 'link' => \XoopsBaseConfig::get('url') . '/user.php?op=logout'); $xoops->tpl()->assign('quick_menu', $quick); XoopsLoad::load('module', 'system'); XoopsLoad::load('extension', 'system'); $system_module = new SystemModule(); $system_extension = new SystemExtension(); $adminmenu = null; include __DIR__ . '/menu.php'; if (!$xoops->isModule() || 'system' == $xoops->module->getVar('dirname', 'n')) { $modpath = \XoopsBaseConfig::get('url') . '/admin.php'; $modname = DefaultThemeLocale::SYSTEM_OPTIONS; $modid = 1; $moddir = 'system'; $mod_options = $adminmenu; foreach (array_keys($mod_options) as $item) { $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? \XoopsBaseConfig::get('url') . '/modules/' . $moddir . '/' . $mod_options[$item]['link'] : $mod_options[$item]['link']; $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : \XoopsBaseConfig::get('adminthemes-url') . '/default/' . $mod_options[$item]['icon']; unset($mod_options[$item]['icon_small']); } } else { $moddir = $xoops->module->getVar('dirname', 'n'); $modpath = \XoopsBaseConfig::get('url') . '/modules/' . $moddir; $modname = $xoops->module->getVar('name'); $modid = $xoops->module->getVar('mid'); $mod_options = $xoops->module->getAdminMenu(); foreach (array_keys($mod_options) as $item) { $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? \XoopsBaseConfig::get('url') . "/modules/{$moddir}/" . $mod_options[$item]['link'] : $mod_options[$item]['link']; if (XoopsLoad::fileExists($xoops->path("/media/xoops/images/icons/32/" . $mod_options[$item]['icon']))) { $mod_options[$item]['icon'] = $xoops->url("/media/xoops/images/icons/32/" . $mod_options[$item]['icon']); } else { $mod_options[$item]['icon'] = $xoops->url("/modules/" . $xoops->module->dirname() . "/icons/32/" . $mod_options[$item]['icon']); } } } $xoops->tpl()->assign('mod_options', $mod_options); $xoops->tpl()->assign('modpath', $modpath); $xoops->tpl()->assign('modname', $modname); $xoops->tpl()->assign('modid', $modid); $xoops->tpl()->assign('moddir', $moddir); // Modules list $module_list = $system_module->getModuleList(); $xoops->tpl()->assign('module_menu', $module_list); unset($module_list); // Extensions list $extension_list = $system_extension->getExtensionList(); $xoops->tpl()->assign('extension_menu', $extension_list); unset($extension_list); $extension_mod = $system_extension->getExtension($moddir); $xoops->tpl()->assign('extension_mod', $extension_mod); // add preferences menu $menu = array(); $OPT = array(); $menu[] = array('link' => \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=preferences', 'title' => XoopsLocale::PREFERENCES, 'absolute' => 1, 'url' => \XoopsBaseConfig::get('url') . '/modules/system/', 'options' => $OPT); $menu[] = array('title' => 'separator'); // Module adminmenu if ($xoops->isModule() && $xoops->module->getVar('dirname') != 'system') { if ($xoops->module->getInfo('system_menu')) { //$xoops->theme()->addStylesheet('modules/system/css/menu.css'); $xoops->module->loadAdminMenu(); // Get menu tab handler /* @var $menu_handler SystemMenuHandler */ $menu_handler = $xoops->getModuleHandler('menu', 'system'); // Define top navigation $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=preferences&op=showmod&mod=" . $xoops->module->getVar('mid', 'e'), XoopsLocale::PREFERENCES); if ($xoops->module->getInfo('extension')) { $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=extensions&op=update&module=" . $xoops->module->getVar('dirname', 'e'), XoopsLocale::A_UPDATE); } else { $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=modulesadmin&op=update&module=" . $xoops->module->getVar('dirname', 'e'), XoopsLocale::A_UPDATE); } if ($xoops->module->getInfo('blocks')) { $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=blocksadmin&op=list&filter=1&selgen=" . $xoops->module->getVar('mid', 'e') . "&selmod=-2&selgrp=-1&selvis=-1", XoopsLocale::BLOCKS); } if ($xoops->module->getInfo('hasMain')) { $menu_handler->addMenuTop(\XoopsBaseConfig::get('url') . "/modules/" . $xoops->module->getVar('dirname', 'e') . "/", SystemLocale::GO_TO_MODULE); } // Define main tab navigation $i = 0; $current = $i; foreach ($xoops->module->adminmenu as $menu) { if (stripos($_SERVER['REQUEST_URI'], $menu['link']) !== false) { $current = $i; } $menu_handler->addMenuTabs($xoops->url('modules/' . $xoops->module->getVar('dirname') . '/' . $menu['link']), $menu['title']); ++$i; } if ($xoops->module->getInfo('help')) { if (stripos($_SERVER['REQUEST_URI'], 'admin/' . $xoops->module->getInfo('help')) !== false) { $current = $i; } $menu_handler->addMenuTabs('../../system/help.php?mid=' . $xoops->module->getVar('mid', 's') . '&' . $xoops->module->getInfo('help'), XoopsLocale::HELP); } // Display navigation tabs $xoops->tpl()->assign('xo_system_menu', $menu_handler->render($current, false)); } } }
function publisher_createLogo($dirname) { if (!extension_loaded("gd")) { return false; } else { $required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox"); foreach ($required_functions as $func) { if (!function_exists($func)) { return false; } } } if (!XoopsLoad::fileExists($imageBase = \XoopsBaseConfig::get('root-path') . "/modules/" . $dirname . "/images/module_logo.png") || !XoopsLoad::fileExists($font = \XoopsBaseConfig::get('root-path') . "/modules/" . $dirname . "/images/VeraBd.ttf")) { return false; } $imageModule = imagecreatefrompng($imageBase); //Erase old text $grey_color = imagecolorallocate($imageModule, 237, 237, 237); imagefilledrectangle($imageModule, 5, 35, 85, 46, $grey_color); // Write text $text_color = imagecolorallocate($imageModule, 0, 0, 0); $space_to_border = (80 - strlen($dirname) * 6.5) / 2; imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $text_color, $font, ucfirst($dirname), array()); // Set transparency color $white = imagecolorallocatealpha($imageModule, 255, 255, 255, 127); imagefill($imageModule, 0, 0, $white); imagecolortransparent($imageModule, $white); imagepng($imageModule, \XoopsBaseConfig::get('root-path') . "/modules/" . $dirname . "/images/module_logo.png"); imagedestroy($imageModule); return true; }
$admin_page->renderBreadcrumb(); $admin_page->addTips(SystemLocale::TIPS_MAIN); $admin_page->renderTips(); $groups = $xoopsUser->getGroups(); $all_ok = false; if (!in_array(FixedGroups::ADMIN, $groups)) { $sysperm_handler = $xoops->getHandlerGroupperm(); $ok_syscats = $sysperm_handler->getItemIds('system_admin', $groups); } else { $all_ok = true; } $admin_dir = \XoopsBaseConfig::get('root-path') . '/modules/system/admin'; $dirlist = XoopsLists::getDirListAsArray($admin_dir); $inactive_section = array('blocksadmin', 'groups', 'modulesadmin', 'preferences', 'tplsets', 'extensions', 'users', 'services'); foreach ($dirlist as $directory) { if (XoopsLoad::fileExists($file = $admin_dir . '/' . $directory . '/xoops_version.php')) { require $file; unset($file); if ($modversion['hasAdmin']) { if ($xoops->getModuleConfig('active_' . $directory)) { $category = isset($modversion['category']) ? (int) $modversion['category'] : 0; if (false != $all_ok || in_array($modversion['category'], $ok_syscats)) { $menu['file'] = $directory; $menu['title'] = trim($modversion['name']); $menu['desc'] = str_replace('<br />', ' ', $modversion['description']); $menu['icon'] = $modversion['image']; $menu['status'] = true; } } else { $category = isset($modversion['category']) ? (int) $modversion['category'] : 0; if (false != $all_ok || in_array($modversion['category'], $ok_syscats)) {
/** * Build Block * * @return array|bool */ public function buildBlock() { $xoops = \Xoops::getInstance(); $block = array(); if (!$this->isCustom()) { // get block display function $show_func = (string) $this->getVar('show_func'); if (!$show_func) { return false; } if (!\XoopsLoad::fileExists($func_file = $xoops->path('modules/' . $this->getVar('dirname') . '/blocks/' . $this->getVar('func_file')))) { return false; } // must get lang files b4 including the file // some modules require it for code that is outside the function $xoops->loadLanguage('blocks', $this->getVar('dirname')); $xoops->loadLocale($this->getVar('dirname')); include_once $func_file; if (function_exists($show_func)) { // execute the function $options = explode('|', $this->getVar('options')); $block = $show_func($options); if (!$block) { return false; } } else { return false; } } else { // it is a custom block, so just return the contents $block['content'] = $this->getContent('s', $this->getVar('c_type')); if (empty($block['content'])) { return false; } } return $block; }
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright 2010-2014 XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package xlanguage * @since 2.6.0 * @author Laurent JEN (Aka DuGris) * @version $Id$ */ $xoops = \Xoops::getInstance(); $helper = \Xoops\Module\Helper::getHelper('xlanguage'); $xlanguage = array(); if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/vars.php')) { include_once $hnd_file; } if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . '/modules/xlanguage/include/functions.php')) { include_once $hnd_file; } $cookie_var = $xoops->registry()->get('XLANGUAGE_LANG_TAG'); $xlanguage['action'] = false; if (!empty($_GET[$xoops->registry()->get('XLANGUAGE_LANG_TAG')])) { $cookie_path = '/'; setcookie($cookie_var, $_GET[$xoops->registry()->get('XLANGUAGE_LANG_TAG')], time() + 3600 * 24 * 30, $cookie_path, '', 0); $xlanguage['lang'] = $_GET[$xoops->registry()->get('XLANGUAGE_LANG_TAG')]; } elseif (!empty($_COOKIE[$cookie_var])) { $xlanguage['lang'] = $_COOKIE[$cookie_var]; } elseif ($lang = xlanguage_detectLang()) { $xlanguage['lang'] = $lang; } else { $xlanguage['lang'] = $helper->getConfig('language'); }
/** * @param string $name * @return void */ function system_loadTemplate($name) { $xoops = Xoops::getInstance(); $path = $xoops->path('modules/' . $xoops->module->getVar('dirname', 'n') . '/templates/admin/' . $name . '.tpl'); if (XoopsLoad::fileExists($path)) { echo $xoops->tpl()->fetch($path); } else { echo "Unable to read " . $name; } }
/** * Render System BreadCrumb */ function render() { $xoops = Xoops::getInstance(); if ($xoops->tpl()) { $xoops->tpl()->assign('xo_sys_breadcrumb', $this->_bread); $xoops->tpl()->assign('xo_sys_help', $this->_help); if ($this->_tips) { if ($xoops->getModuleConfig('usetips', 'system')) { $xoops->tpl()->assign('xo_sys_tips', $this->_tips); } } // Call template if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/system/language/' . $xoops->getConfig('language') . '/help/' . $this->_directory . '.html')) { $xoops->tpl()->assign('help_content', \XoopsBaseConfig::get('root-path') . '/modules/system/language/' . $xoops->getConfig('language') . '/help/' . $this->_directory . '.html'); } else { if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/system/language/english/help/' . $this->_directory . '.html')) { $xoops->tpl()->assign('help_content', \XoopsBaseConfig::get('root-path') . '/modules/system/language/english/help/' . $this->_directory . '.html'); } else { $xoops->tpl()->assign('load_error', 1); } } } else { $out = $menu = '<style type="text/css" media="screen">@import ' . \XoopsBaseConfig::get('url') . '/modules/system/css/menu.css;</style>'; $out .= '<ul id="xo-breadcrumb">'; foreach ($this->_bread as $menu) { if ($menu['home']) { $out .= '<li><a href="' . $menu['link'] . '" title="' . $menu['title'] . '"><img src="images/home.png" alt="' . $menu['title'] . '" class="home" /></a></li>'; } else { if ($menu['link'] != '') { $out .= '<li><a href="' . $menu['link'] . '" title="' . $menu['title'] . '">' . $menu['title'] . '</a></li>'; } else { $out .= '<li>' . $menu['title'] . '</li>'; } } } $out .= '</ul>'; if ($this->_tips) { $out .= '<div class="tips">' . $this->_tips . '</div>'; } echo $out; } }
/** * @param null $name * * @return null */ public function getByName($name = null) { $xoops = Xoops::getInstance(); $name = empty($name) ? $xoops->getConfig('locale') : strtolower($name); $file_config = $xoops->registry()->get('XLANGUAGE_CONFIG_FILE'); if (!XoopsLoad::fileExists($file_config) || !isset($this->cached_config)) { $this->loadConfig(); } if (isset($this->cached_config[$name])) { return $this->cached_config[$name]; } return null; }
$itemObj->setVar('body', "[pagewrap=" . $arrArticle['htmlpage'] . "]"); echo sprintf(" " . _AM_PUBLISHER_IMPORT_ARTICLE_WRAP, $arrArticle['htmlpage']) . "<br/>"; } } } if (!$itemObj->store()) { echo sprintf(" " . _AM_PUBLISHER_IMPORT_ARTICLE_ERROR, $arrArticle['title']) . "<br/>"; continue; } else { // Linkes files $sql = "SELECT * FROM " . $xoopsDB->prefix("xfs_files") . " WHERE articleid=" . $arrArticle['articleid']; $resultFiles = $xoopsDB->query($sql); $allowed_mimetypes = ''; while ($arrFile = $xoopsDB->fetchArray($resultFiles)) { $filename = \XoopsBaseConfig::get('root-path') . "/modules/xfsection/cache/uploaded/" . $arrFile['filerealname']; if (XoopsLoad::fileExists($filename)) { if (copy($filename, PUBLISHER_UPLOADS_PATH . "/" . $arrFile['filerealname'])) { $fileObj = $publisher->getFileHandler()->create(); $fileObj->setVar('name', $arrFile['fileshowname']); $fileObj->setVar('description', $arrFile['filedescript']); $fileObj->setVar('status', _PUBLISHER_STATUS_FILE_ACTIVE); $fileObj->setVar('uid', $arrArticle['uid']); $fileObj->setVar('itemid', $itemObj->getVar('itemid')); $fileObj->setVar('mimetype', $arrFile['minetype']); $fileObj->setVar('datesub', $arrFile['date']); $fileObj->setVar('counter', $arrFile['counter']); $fileObj->setVar('filename', $arrFile['filerealname']); if ($fileObj->store($allowed_mimetypes, true, false)) { echo " " . sprintf(_AM_PUBLISHER_IMPORTED_ARTICLE_FILE, $arrFile['filerealname']) . "<br />"; } }
/** * getInstalledExtensions * * @return array */ public function getInstalledExtensions() { // Get main instance $xoops = Xoops::getInstance(); $module_handler = $xoops->getHandlerModule(); $ret = array(); $i = 0; foreach ($this->modulesList as $file) { if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) { clearstatcache(); $file = trim($file); if (!in_array($file, $this->modulesDirnames)) { /* @var $module XoopsModule */ $module = $module_handler->create(); $module->loadInfo($file); if ($module->getInfo('extension')) { $module->setInfo('mid', $i); $module->setInfo('version', round($module->getInfo('version'), 2)); $ret[] = $module; unset($module); ++$i; } } } } return $ret; }
/** * Loads a query from a file * * @param string $sql_file_path name of file to read * @param bool $force weither to force the query or not * * @return bool */ public function queryFromFile($sql_file_path, $force = false) { if (!XoopsLoad::fileExists($sql_file_path)) { return false; } $queryFunc = (bool) $force ? "queryF" : "query"; $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path))); SqlUtility::splitMySqlFile($pieces, $sql_query); $this->db->connect(); foreach ($pieces as $piece) { $piece = trim($piece); // [0] contains the prefixed query // [4] contains unprefixed table name $prefixed_query = SqlUtility::prefixQuery($piece, $this->db->prefix()); if ($prefixed_query != false) { $table = $this->db->prefix($prefixed_query[4]); if ($prefixed_query[1] == 'CREATE TABLE') { if ($this->db->{$queryFunc}($prefixed_query[0]) != false) { if (!isset($this->s_tables['create'][$table])) { $this->s_tables['create'][$table] = 1; } } else { if (!isset($this->f_tables['create'][$table])) { $this->f_tables['create'][$table] = 1; } } } else { if ($prefixed_query[1] == 'INSERT INTO') { if ($this->db->{$queryFunc}($prefixed_query[0]) != false) { if (!isset($this->s_tables['insert'][$table])) { $this->s_tables['insert'][$table] = 1; } else { $this->s_tables['insert'][$table]++; } } else { if (!isset($this->f_tables['insert'][$table])) { $this->f_tables['insert'][$table] = 1; } else { $this->f_tables['insert'][$table]++; } } } else { if ($prefixed_query[1] == 'ALTER TABLE') { if ($this->db->{$queryFunc}($prefixed_query[0]) != false) { if (!isset($this->s_tables['alter'][$table])) { $this->s_tables['alter'][$table] = 1; } } else { if (!isset($this->s_tables['alter'][$table])) { $this->f_tables['alter'][$table] = 1; } } } else { if ($prefixed_query[1] == 'DROP TABLE') { if ($this->db->{$queryFunc}('DROP TABLE ' . $table) != false) { if (!isset($this->s_tables['drop'][$table])) { $this->s_tables['drop'][$table] = 1; } } else { if (!isset($this->s_tables['drop'][$table])) { $this->f_tables['drop'][$table] = 1; } } } } } } } } return true; }
} } // create block template $btemplates = $tpltpl_handler->find($tplsetname, 'block', null, $moddir); for ($k = 0; $k < count($btemplates); ++$k) { $filename = $btemplates[$k]->getVar('tpl_file'); if ($tplsetname == $tplset) { $physical_file = \XoopsBaseConfig::get('themes-path') . '/' . $_REQUEST['select_theme'] . '/modules/' . $moddir . '/blocks/' . $filename; $btplfile = $tpltpl_handler->get($btemplates[$k]->getVar('tpl_id'), true); if (is_object($btplfile)) { if (!XoopsLoad::fileExists($physical_file) || $_REQUEST['force_generated'] == 1) { if ($select_templates_modules[$l] == $filename) { $open = fopen("" . $physical_file . "", "w+"); if (fwrite($open, "" . utf8_encode(html_entity_decode($btplfile->getVar('tpl_source', 'E'))) . "")) { $text .= '<tr class="' . $class . '"><td align="center">' . XoopsLocale::BLOCKS . '</td><td>' . $physical_file . '</td><td align="center">'; if (XoopsLoad::fileExists($physical_file)) { $text .= '<img width="16" src="' . system_AdminIcons('success.png') . '" /></td></tr>'; } else { $text .= '<img width="16" src="' . system_AdminIcons('cancel.png') . '" /></td></tr>'; } $verif_write = true; } fclose($open); } $class = $class == "even" ? "odd" : "even"; } } } } } $text .= '</table>';
/** * @param string $version * @param string $value * @return string */ public function adminVersion($version, $value = '') { static $tblVersion = array(); if (is_array($tblVersion) && array_key_exists($version . '.' . $value, $tblVersion)) { return $tblVersion[$version . '.' . $value]; } $xoops = Xoops::getInstance(); $path = $xoops->path('modules/system/admin/' . $version . '/xoops_version.php'); if (XoopsLoad::fileExists($path)) { $modversion = array(); include $path; $retvalue = $modversion[$value]; $tblVersion[$version . '.' . $value] = $retvalue; return $retvalue; } return ''; }
function menus_block_edit($options) { //Unique ID if (!$options[4] || isset($_GET['op']) && $_GET['op'] == 'clone') { $options[4] = uniqid(); } $helper = Xoops::getModuleHelper('menus'); $helper->loadLanguage('admin'); $criteria = new CriteriaCompo(); $criteria->setSort('title'); $criteria->setOrder('ASC'); $menus = $helper->getHandlerMenus()->getList($criteria); unset($criteria); if (count($menus) == 0) { $form = "<a href='" . $helper->url('admin/admin_menus.php') . "'>" . _AM_MENUS_MSG_NOMENUS . "</a>"; return $form; } //Menu $form = new Xoops\Form\BlockForm(); $element = new Xoops\Form\Select(_MB_MENUS_SELECT_MENU, 'options[0]', $options[0], 1); $element->addOptionArray($menus); $element->setDescription(_MB_MENUS_SELECT_MENU_DSC); $form->addElement($element); //Skin $temp_skins = XoopsLists::getDirListAsArray(\XoopsBaseConfig::get('root-path') . "/modules/menus/skins/", ""); $skins_options = array(); foreach ($temp_skins as $skin) { if (XoopsLoad::fileExists($helper->path('skins/' . $skin . '/skin_version.php'))) { $skins_options[$skin] = $skin; } } $element = new Xoops\Form\Select(_MB_MENUS_SELECT_SKIN, 'options[1]', $options[1], 1); $element->addOptionArray($skins_options); $element->setDescription(_MB_MENUS_SELECT_SKIN_DSC); $form->addElement($element); //Use skin from,theme $element = new Xoops\Form\RadioYesNo(_MB_MENUS_USE_THEME_SKIN, 'options[2]', $options[2]); $element->setDescription(_MB_MENUS_USE_THEME_SKIN_DSC); $form->addElement($element); //Display method $display_options = array('block' => _MB_MENUS_DISPLAY_METHOD_BLOCK, 'template' => _MB_MENUS_DISPLAY_METHOD_TEMPLATE); $element = new Xoops\Form\Select(_MB_MENUS_DISPLAY_METHOD, 'options[3]', $options[3], 1); $element->addOptionArray($display_options); $element->setDescription(sprintf(_MB_MENUS_DISPLAY_METHOD_DSC, $options[4])); $form->addElement($element); //Unique ID $element = new Xoops\Form\Text(_MB_MENUS_UNIQUEID, 'options[4]', 2, 20, $options[4]); $element->setDescription(_MB_MENUS_UNIQUEID_DSC); $form->addElement($element); return $form->render(); }
/** * Function to get css file for a certain themeset * * @param string $theme theme name * * @return string */ public function getCss($theme = '') { if ($theme == '') { $theme = $this->getConfig('theme_set'); } $userAgent = $this->getEnv('HTTP_USER_AGENT'); if (stristr($userAgent, 'mac')) { $str_css = 'styleMAC.css'; } elseif (preg_match("/MSIE ([0-9]\\.[0-9]{1,2})/i", $userAgent)) { $str_css = 'style.css'; } else { $str_css = 'styleNN.css'; } $xoops_theme_path = \XoopsBaseConfig::get('themes-path'); $xoops_theme_url = \XoopsBaseConfig::get('themes-url'); if (is_dir($xoops_theme_path . '/' . $theme)) { if (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/' . $str_css)) { return $xoops_theme_url . '/' . $theme . '/' . $str_css; } elseif (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/style.css')) { return $xoops_theme_url . '/' . $theme . '/style.css'; } } if (is_dir($xoops_theme_path . '/' . $theme . '/css')) { if (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/css/' . $str_css)) { return $xoops_theme_url . '/' . $theme . '/css/' . $str_css; } elseif (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/css/style.css')) { return $xoops_theme_url . '/' . $theme . '/css/style.css'; } } return ''; }
/** * Render navigation to admin page * * @param string $menu current menu * * @return array */ public function renderNavigation($menu = '') { $xoops = \Xoops::getInstance(); $ret = array(); $this->module->loadAdminMenu(); foreach (array_keys($this->module->adminmenu) as $i) { if ($this->module->adminmenu[$i]['link'] == "admin/" . $menu) { if (\XoopsLoad::fileExists($xoops->path("/media/xoops/images/icons/32/" . $this->module->adminmenu[$i]['icon']))) { $this->module->adminmenu[$i]['icon'] = $xoops->url("/media/xoops/images/icons/32/" . $this->module->adminmenu[$i]['icon']); } else { $this->module->adminmenu[$i]['icon'] = $xoops->url("/modules/" . $xoops->module->dirname() . "/icons/32/" . $this->module->adminmenu[$i]['icon']); } $xoops->tpl()->assign('xo_sys_navigation', $this->module->adminmenu[$i]); $ret[] = $xoops->tpl()->fetch($this->getTplPath('nav')); } } return $ret; }
$groups = $xoops->user->getGroups(); } $all_ok = false; if (!in_array(FixedGroups::ADMIN, $groups)) { $sysperm_handler = $xoops->getHandlerGroupPermission(); $ok_syscats = $sysperm_handler->getItemIds('system_admin', $groups); } else { $all_ok = true; } // include system category definitions include_once $xoops->path('/modules/system/constants.php'); $admin_dir = $xoops->path('/modules/system/admin'); $dirlist = XoopsLists::getDirListAsArray($admin_dir); $index = 0; foreach ($dirlist as $file) { if (XoopsLoad::fileExists($fileinc = $admin_dir . '/' . $file . '/xoops_version.php')) { include $fileinc; unset($fileinc); if ($modversion['hasAdmin']) { if ($xoops->getModuleConfig('active_' . $file, 'system')) { $category = isset($modversion['category']) ? (int) $modversion['category'] : 0; if (false != $all_ok || in_array($modversion['category'], $ok_syscats)) { $adminmenu[$index]['title'] = trim($modversion['name']); $adminmenu[$index]['link'] = 'admin.php?fct=' . $file; $adminmenu[$index]['image'] = $modversion['image']; } } } unset($modversion); } ++$index;