/** * * @access public * @return **/ public static function getWidgets() { global $parser; $_chw_data = array(); $widgets = self::findWidgets(); $widget_name = NULL; $addonh = CAT_Helper_Addons::getInstance(); $base = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules'); foreach ($widgets as $widget) { $path = pathinfo(CAT_Helper_Directory::sanitizePath($widget), PATHINFO_DIRNAME); $info = $content = NULL; // check if path is deeper than CAT_PATH/modules/<module> if (count(explode('/', str_ireplace($base . '/', '', $path))) > 1) { $temp = explode('/', str_ireplace($base . '/', '', $path)); $path = $base . '/' . $temp[0]; } if (file_exists($path . '/info.php')) { $info = $addonh->checkInfo($path); } if (file_exists($path . '/languages/' . LANGUAGE . '.php')) { $addonh->lang()->addFile(LANGUAGE . '.php', $path . '/languages/'); } ob_start(); $widget_name = NULL; include $widget; $content = ob_get_contents(); ob_clean(); $_chw_data[$widget] = array_merge(is_array($info) ? $info : array(), array('content' => $content)); if ($widget_name) { $_chw_data[$widget]['module_name'] .= ' - ' . $widget_name; } } return $_chw_data; }
function wysiwyg_search($func_vars) { extract($func_vars, EXTR_PREFIX_ALL, 'func'); // how many lines of excerpt we want to have at most $max_excerpt_num = $func_default_max_excerpt; $divider = "."; $result = false; // we have to get 'content' instead of 'text', because strip_tags() // doesn't remove scripting well. // scripting will be removed later on automatically $query = $func_database->query(sprintf("SELECT content FROM `%smod_wysiwyg` WHERE section_id='%d'", CAT_TABLE_PREFIX, $func_section_id)); if ($query->numRows() > 0) { if ($res = $query->fetchRow()) { if (CAT_Helper_Addons::isModuleInstalled('kit_framework')) { // remove all kitCommands from the content preg_match_all('/(~~)( | )(.){3,512}( | )(~~)/', $res['content'], $matches, PREG_SET_ORDER); foreach ($matches as $match) { $res['content'] = str_replace($match[0], '', $res['content']); } } $mod_vars = array('page_link' => $func_page_link, 'page_link_target' => SEC_ANCHOR . "#section_{$func_section_id}", 'page_title' => $func_page_title, 'page_description' => $func_page_description, 'page_modified_when' => $func_page_modified_when, 'page_modified_by' => $func_page_modified_by, 'text' => $res['content'] . $divider, 'max_excerpt_num' => $max_excerpt_num); if (print_excerpt2($mod_vars, $func_vars)) { $result = true; } } } return $result; }
/** * * @access public * @return **/ public static function get_init_pages() { // frontend pages $pages = CAT_Helper_Page::getPages(); $frontend_pages = array(); foreach ($pages as $page) { $frontend_pages[$page['menu_title']] = 'pages/modify.php?page_id=' . $page['page_id']; } // admin tools $tools = CAT_Helper_Addons::get_addons(NULL, 'module', 'tool'); $admin_tools = array(); foreach ($tools as $tool) { $admin_tools[$tool['name']] = 'admintools/tool.php?tool=' . $tool['directory']; } // backend pages $backend_pages = CAT_Backend::getPages(); return array('backend_pages' => $backend_pages, 'frontend_pages' => $frontend_pages, 'admin_tools' => $admin_tools); }
// ! Get display name of person who last modified the page // ========================================================= $user = $users->get_user_details($results_array['modified_by']); // ================================= // ! Add permissions to $data_dwoo // ================================= $permission['pages'] = $users->checkPermission('Pages', 'pages') ? true : false; $permission['pages_add'] = $users->checkPermission('Pages', 'pages_add') ? true : false; $permission['pages_add_l0'] = $users->checkPermission('Pages', 'pages_add_l0') ? true : false; $permission['pages_modify'] = $users->checkPermission('Pages', 'pages_modify') ? true : false; $permission['pages_delete'] = $users->checkPermission('Pages', 'pages_delete') ? true : false; $permission['pages_settings'] = $users->checkPermission('Pages', 'pages_settings') ? true : false; $permission['pages_intro'] = $users->checkPermission('Pages', 'pages_intro') != true || INTRO_PAGE != 'enabled' ? false : true; // list of all pages for dropdown, sorted by parent->child $pages = CAT_Helper_ListBuilder::sort(CAT_Helper_Page::getPages(CAT_Backend::isBackend()), 0); // ============================================= // ! Add result_array to the template variable // ============================================= $ajax = array('description' => $results_array['description'], 'keywords' => $results_array['keywords'], 'language' => $results_array['language'], 'level' => $results_array['level'], 'menu' => $results_array['menu'], 'menu_title' => htmlspecialchars_decode($results_array['menu_title'], ENT_QUOTES), 'modified_when' => $results_array['modified_when'] != 0 ? CAT_Helper_DateTime::getDate($results_array['modified_when']) : 'Unknown', 'page_id' => $results_array['page_id'], 'page_title' => htmlspecialchars_decode($results_array['page_title'], ENT_QUOTES), 'parent' => $results_array['parent'], 'searching' => $results_array['searching'] == 0 ? false : true, 'short_link' => substr($results_array['link'], strripos($results_array['link'], '/') + 1), 'target' => $results_array['target'], 'template' => $results_array['template'], 'visibility' => $results_array['visibility'], 'display_name' => $user['display_name'], 'username' => $user['username'], 'DISPLAY_MENU_LIST' => MULTIPLE_MENUS != false ? true : false, 'DISPLAY_LANGUAGE_LIST' => PAGE_LANGUAGES != false ? true : false, 'DISPLAY_SEARCHING' => SEARCH != false ? true : false, 'admin_groups' => explode(',', str_replace('_', '', $results_array['admin_groups'])), 'viewing_groups' => explode(',', str_replace('_', '', $results_array['viewing_groups'])), 'parent_list' => $pages, 'PAGE_EXTENSION' => $backend->db()->query("SELECT `value` FROM `:prefix:settings` WHERE name = 'page_extension'")->fetchColumn()); $ajax['variants'] = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Helper_Page::getPageTemplate($results_array['page_id'])); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $ajax['variants'] = $info['module_variants']; array_unshift($ajax['variants'], ''); } $ajax['template_variant'] = CAT_Helper_Page::getPageSettings($results_array['page_id'], 'internal', 'template_variant'); // ==================== // ! Return values // ==================== print json_encode($ajax); exit;
} // validate $path = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/' . $type . '/' . $module . ($type == 'languages' ? '.php' : '')); $info = CAT_Helper_Addons::checkInfo($path); if (!is_array($info) || !count($info)) { $backend->print_error($backend->lang()->translate('Unable to {{ action }} {{ type }} {{ module }}!', array('action' => $action, 'type' => substr($type, 0, -1), 'module' => $path)) . ': <tt>"' . htmlentities(basename($path)) . '/' . $action . '.php"</tt> ' . $backend->lang()->translate('does not exist'), $js_back); } if ($type != 'languages') { // this prints an error page if prerequisites are not met $precheck_errors = CAT_Helper_Addons::preCheckAddon(NULL, $path, false); if ($precheck_errors != '' && !is_bool($precheck_errors)) { $backend->print_error($backend->lang()->translate('Invalid installation file. {{error}}', array('error' => $precheck_errors))); return false; } $admin =& $backend; // Run the modules install // upgrade script if there is one if (file_exists($path . '/' . $action . '.php')) { require $path . '/' . $action . '.php'; } } CAT_Helper_Addons::loadModuleIntoDB($path, $action, $info); switch ($action) { case 'install': case 'upgrade': $backend->print_success(str_replace('deed', 'ded', 'Addon successfully ' . $action . 'ed'), $js_back); break; default: $backend->print_error('Action not supported', $js_back); } // Print admin footer $backend->print_footer();
/** * This function is used to check info.php * Also used for language files * * @access public * @param string Any valid directory(-path) **/ public static function checkInfo($directory) { $self = self::getInstance(); $self->log()->LogDebug(sprintf('checking info.php for $directory [%s]', $directory)); if (is_dir($directory) && file_exists($directory . '/info.php')) { $self->log()->LogDebug('$directory is a directory and info.php found'); // get header info $link = NULL; ini_set('auto_detect_line_endings', true); $file = fopen($directory . '/info.php', 'r'); if ($file) { while ($line = fgets($file)) { if (preg_match('/\\@link\\s+(.*)/i', $line, $matches)) { $link = trim($matches[1]); break; } } fclose($file); } require $directory . '/info.php'; if (isset($module_function) && in_array(strtolower($module_function), self::$module_functions)) { $return_values = array('addon_function' => 'module'); } else { if (isset($template_function) && in_array(strtolower($template_function), self::$template_functions)) { $return_values = array('addon_function' => 'template'); } else { self::$error = 'Invalid info.php - neither $module_function nor $template_function set'; $self->log()->logDebug(self::$error); return false; } } // Check if the file is valid foreach (self::$info_vars_mandatory[$return_values['addon_function']] as $varname) { if (!isset(${$varname})) { self::$error = 'Invalid info.php - mandatory var ' . $varname . ' not set'; $self->log()->logDebug(self::$error); return false; } else { // rename keys $key = str_ireplace(array('template_'), array('module_'), $varname); $return_values[$key] = ${$varname}; } } // add empty keys foreach (self::$info_vars_full[$return_values['addon_function']] as $varname) { $key = str_ireplace(array('template_'), array('module_'), $varname); if (!isset($returnvalues[$key])) { $return_values[$key] = isset(${$varname}) ? ${$varname} : ''; } } // check platform (WB/LEPTON/BC) if (isset($lepton_platform) && !isset($module_platform)) { $return_values['cms_name'] = 'LEPTON'; } if (isset($module_platform)) { if (!self::versionCompare($module_platform, '2.x', '<=')) { $return_values['cms_name'] = 'WebsiteBaker'; } else { $return_values['cms_name'] = 'BlackCat CMS'; } } if (!isset($return_values['cms_name'])) { $return_values['cms_name'] = 'unknown'; } // link to module homepage if ($link) { $return_values['module_link'] = $link; } return $return_values; } elseif (file_exists($directory) && pathinfo($directory, PATHINFO_EXTENSION) == 'php') { $self->log()->LogDebug('$directory is a file and has "php" suffix'); // Check if the file is valid $content = file_get_contents($directory); if (strpos($content, '<?php') === false) { self::$error = 'Invalid language file - missing PHP delimiter'; $self->log()->logDebug(self::$error); return false; } $return_values = array('addon_function' => 'language', 'module_directory' => pathinfo($directory, PATHINFO_FILENAME)); require $directory; foreach (self::$info_vars_mandatory['language'] as $varname) { if (!isset(${$varname})) { self::$error = 'Invalid language file - var ' . $varname . ' not set'; $self->log()->logDebug(self::$error); return false; } else { // rename keys $key = str_ireplace(array('language_'), array('module_'), $varname); $return_values[$key] = ${$varname}; } } $return_values['module_description'] = $language_name; return $return_values; } else { self::$error = 'invalid directory/language file or info.php is missing, check of language file failed'; $self->log()->logDebug(self::$error); return false; } }
/** * Update the module informations in the DB * * @param string Name of the modul-directory * @param bool Optional boolean to run the upgrade-script of the module. * * THIS METHOD WAS MOVED TO CAT_Helper_Addons! * */ function upgrade_module($directory, $upgrade = false) { if (!class_exists('CAT_Helper_Addons')) { @(require_once dirname(__FILE__) . '/CAT/Helper/Addons.php'); } $addons_helper = new CAT_Helper_Addons(); return $addons_helper->upgradeModule($directory, $upgrade); }
* @link http://blackcat-cms.org * @license http://www.gnu.org/licenses/gpl.html * @category CAT_Modules * @package wrapper * */ if (defined('CAT_PATH')) { include CAT_PATH . '/framework/class.secure.php'; } else { $root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // Create table $mod_wrapper = 'CREATE TABLE IF NOT EXISTS `' . CAT_TABLE_PREFIX . 'mod_wrapper` (' . ' `section_id` INT NOT NULL DEFAULT \'0\',' . ' `page_id` INT NOT NULL DEFAULT \'0\',' . ' `url` TEXT NULL,' . ' `height` VARCHAR(50) NOT NULL DEFAULT \'400px\',' . ' `width` VARCHAR(50) NOT NULL DEFAULT \'100%\',' . ' `wtype` VARCHAR(50) NOT NULL DEFAULT \'object\',' . ' PRIMARY KEY ( `section_id` ) ' . ' )'; $database->query($mod_wrapper); // add files to class_secure $addons_helper = new CAT_Helper_Addons(); foreach (array('save.php') as $file) { if (false === $addons_helper->sec_register_file('wrapper', $file)) { error_log("Unable to register file -{$file}-!"); } }
trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $backend = CAT_Backend::getInstance('Pages', 'pages_add', false); $users = CAT_Users::getInstance(); header('Content-type: application/json'); if (!$users->checkPermission('Pages', 'pages_add')) { $ajax = array('message' => $backend->lang()->translate('You do not have the permission to add a page.'), 'success' => false); print json_encode($ajax); exit; } // note: all pages are listed in the dropdown, even hidden / private AND deleted! $dropdown_list = CAT_Helper_ListBuilder::sort(CAT_Helper_Page::getPages(1), 0); // template / variant $template = CAT_Helper_Page::properties($val->sanitizePost('parent_id', 'numeric'), 'template'); $variant = CAT_Helper_Page::getPageSettings($val->sanitizePost('parent_id', 'numeric'), 'internal', 'template_variant'); $variants = array(); $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Helper_Page::getPageTemplate($val->sanitizePost('parent_id', 'numeric'))); if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) { $variants = $info['module_variants']; array_unshift($variants, ''); } // ============================================= // ! Add result_array to the template variable // ============================================= $ajax = array('parent_id' => $val->sanitizePost('parent_id', 'numeric'), 'parent_list' => $dropdown_list, 'template' => $template, 'template_variant' => $variant, 'variants' => $variants, 'target' => '_self', 'success' => true); // ==================== // ! Return values // ==================== print json_encode($ajax); exit;
$tpl_data['PAGES_LIST'] = getPagesList('maintenance_page', CAT_Registry::get('MAINTENANCE_PAGE')); $tpl_data['ERR_PAGES_LIST'] = getPagesList('err_page_404', CAT_Registry::get('ERR_PAGE_404')); break; case 'users': $tpl_data['groups'] = $users->get_groups(CAT_Registry::get('FRONTEND_SIGNUP'), '', false); break; case 'datetime': $tpl_data['languages'] = getLanguages(); $tpl_data['timezones'] = getTimezones(); $tpl_data['charsets'] = getCharsets(); $tpl_data['dateformats'] = getDateformats(); $tpl_data['timeformats'] = getTimeformats(); break; case 'searchblock': $tpl_data['search'] = getSearchSettings(); $tpl_data['search_templates'] = isset($tpl_data['search']['template']) ? CAT_Helper_Addons::get_addons($tpl_data['search']['template'], 'template', 'template') : array(); $s_selected = isset($tpl_data['search']['cfg_search_use_page_id']) ? $tpl_data['search']['cfg_search_use_page_id'] : ''; $tpl_data['PAGES_LIST'] = getPagesList('search_cfg_search_use_page_id', $s_selected, true); break; case 'server': $tpl_data['WORLD_WRITEABLE_SELECTED'] = CAT_Registry::get('STRING_FILE_MODE') == '0666' && CAT_Registry::get('STRING_DIR_MODE') == '0777' ? true : false; break; case 'mail': $tpl_data['CATMAILER_LIBS'] = getMailerLibs(); if (!isset($tpl_data['values']['catmailer_smtp_timeout'])) { $tpl_data['values']['catmailer_smtp_timeout'] = 30; } break; case 'security': $admin =& $backend; require_once CAT_PATH . '/framework/CAT/Helper/Captcha/WB/captcha.php';
} if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $backend = CAT_Backend::getInstance('admintools'); $user = CAT_Users::getInstance(); $lang = CAT_Helper_I18n::getInstance(); // this will redirect to the login page if the permission is not set $user->checkPermission('admintools', 'admintools', false); global $parser; // get tools // ----- TODO: PERMISSIONS ----- $tools = CAT_Helper_Addons::get_addons(0, 'module', 'tool'); if (count($tools)) { foreach ($tools as $tool) { // check if the user is allowed to see this item if (!$user->get_permission($tool['directory'], $tool['type'])) { continue; } // check if a module description exists for the displayed backend language $module_description = false; $icon = false; $language_file = CAT_PATH . '/modules/' . $tool['VALUE'] . '/languages/' . $user->lang()->getLang() . '.php'; if (true === file_exists($language_file)) { require $language_file; } // Check whether icon is available for the admintool if (file_exists(CAT_PATH . '/modules/' . $tool['VALUE'] . '/icon.png')) {
if (is_array($val->sanitizePost('module_permissions'))) { foreach ($val->sanitizePost('module_permissions') as $selected_name) { // Check, whether the activated module is also 1 if (in_array($selected_name, $modlist)) { $modules[] = $selected_name; } } } $modules = sizeof($modules) > 0 ? $modules : $modlist; $module_permissions = implode(',', $modules); // ============================ // ! Get template permissions // ============================ $templates = array(); $template_permissions = ''; $installed_mods = CAT_Helper_Addons::get_addons(NULL, 'template'); $modlist = array(); foreach ($installed_mods as $mod) { array_push($modlist, $mod['directory']); } if (is_array($val->sanitizePost('template_permissions'))) { foreach ($val->sanitizePost('template_permissions') as $selected_name) { if (in_array($selected_name, $modlist)) { $templates[] = $selected_name; } } } if (count($templates)) { $template_permissions = implode(',', $templates); } else { $template_permissions = '';
include CAT_PATH . '/framework/class.secure.php'; } else { $root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $val = CAT_Helper_Validate::getInstance(); $email = $val->sanitizePost('email', NULL, true); $ajax = array(); header('Content-type: application/json'); if (!count(CAT_Helper_Addons::getInstance()->getLibraries('mail'))) { $ajax = array('message' => $val->lang()->translate('Unable to mail login details - no mailer library installed!'), 'success' => false); } else { // Check if the user has already submitted the form, otherwise show it if ($email && $val->sanitize_email($email)) { list($result, $message) = CAT_Users::handleForgot($email); $ajax = array('message' => $message, 'success' => $result); } else { $ajax = array('message' => $val->lang()->translate('You must enter an email address'), 'success' => false); } } print json_encode($ajax); exit;
* @copyright 2010-2011 LEPTON Project * @link http://www.LEPTON-cms.org * @license http://www.gnu.org/licenses/gpl.html * @license_terms please see info.php of this module * * */ // include class.secure.php to protect this file and the whole CMS! if (defined('CAT_PATH')) { include CAT_PATH . '/framework/class.secure.php'; } else { $root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // end include class.secure.php // add files to class_secure $addons_helper = new CAT_Helper_Addons(); foreach (array('save.php') as $file) { if (false === $addons_helper->sec_register_file('wysiwyg', $file)) { error_log("Unable to register file -{$file}-!"); } }
* * @author Black Cat Development * @copyright 2013, Black Cat Development * @link http://blackcat-cms.org * @license http://www.gnu.org/licenses/gpl.html * @category CAT_Modules * @package bcversion_widget * */ if (defined('CAT_PATH')) { include CAT_PATH . '/framework/class.secure.php'; } else { $root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // add files to class_secure $addons_helper = new CAT_Helper_Addons(); foreach (array('widgets/logs.php') as $file) { if (false === $addons_helper->sec_register_file('blackcat', $file)) { error_log("Unable to register file -{$file}-!"); } }
function Dwoo_Plugin_edit_module_css(Dwoo $dwoo, $mod_dir) { CAT_Helper_Addons::getEditModuleCSSForm($mod_dir); }
/** * **/ function getMailerLibs() { $data = array(); $mailer_libs = CAT_Helper_Addons::getInstance()->getLibraries('mail'); if (count($mailer_libs)) { foreach ($mailer_libs as $item) { $data[] = $item; } } return $data; }
* @link http://blackcat-cms.org * @license http://www.gnu.org/licenses/gpl.html * @category CAT_Modules * @package menu_link * */ if (defined('CAT_PATH')) { include CAT_PATH . '/framework/class.secure.php'; } else { $root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $table = CAT_TABLE_PREFIX . "mod_menu_link"; // $database->query("DROP TABLE IF EXISTS `$table`"); $database->query("\n\tCREATE TABLE IF NOT EXISTS `{$table}` (\n\t\t`section_id` INT(11) NOT NULL DEFAULT '0',\n\t\t`page_id` INT(11) NOT NULL DEFAULT '0',\n\t\t`target_page_id` INT(11) NOT NULL DEFAULT '0',\n\t\t`redirect_type` INT NOT NULL DEFAULT '302',\n\t\t`anchor` VARCHAR(255) NOT NULL DEFAULT '0' ,\n\t\t`extern` VARCHAR(255) NOT NULL DEFAULT '' ,\n\t\tPRIMARY KEY (`section_id`)\n\t)\n"); // add files to class_secure $addons_helper = new CAT_Helper_Addons(); foreach (array('save.php') as $file) { if (false === $addons_helper->sec_register_file('menu_link', $file)) { error_log("Unable to register file -{$file}-!"); } }
} } else { $_SESSION['USE_DEFAULT_TIME_FORMAT'] = true; unset($_SESSION['CAT_TIME_FORMAT']); } if ($_SESSION['CAT_DATE_FORMAT'] != '') { if (isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { unset($_SESSION['USE_DEFAULT_DATE_FORMAT']); } } else { $_SESSION['USE_DEFAULT_DATE_FORMAT'] = true; unset($_SESSION['CAT_DATE_FORMAT']); } } if (count($errors) > 0) { $message = implode("<br />", $errors); } else { $message = $user->lang()->translate('Details saved successfully') . "!<br /><br />"; $show_form = false; } } unset($submit_ok); // get available languages, mark currently used $languages = CAT_Helper_Addons::get_addons(isset($language) && $language !== LANGUAGE ? $language : LANGUAGE, 'language'); global $parser; $parser->setPath(CAT_PATH . '/templates/' . DEFAULT_TEMPLATE . '/templates/' . CAT_Registry::get('DEFAULT_THEME_VARIANT')); // if there's a template for this in the current frontend template $parser->setFallbackPath(dirname(__FILE__) . '/templates/default'); // fallback to default dir $parser->output('account_preferences_form', array('show_form' => $show_form, 'languages' => $languages, 'timezones' => CAT_Helper_DateTime::getTimezones(), 'current_tz' => CAT_Helper_DateTime::getTimezone(), 'date_formats' => CAT_Helper_DateTime::getDateFormats(), 'current_df' => CAT_Helper_DateTime::getDefaultDateFormatShort(), 'time_formats' => CAT_Helper_DateTime::getTimeFormats(), 'current_tf' => CAT_Helper_DateTime::getDefaultTimeFormat(), 'PREFERENCES_URL' => PREFERENCES_URL, 'USER_ID' => $user->get_user_id(), 'DISPLAY_NAME' => $user->get_display_name(), 'GET_EMAIL' => $user->get_email(), 'RESULT_MESSAGE' => $message, 'AUTH_MIN_LOGIN_LENGTH' => AUTH_MIN_LOGIN_LENGTH)); unset($_SESSION['result_message']);
$root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $backend = CAT_Backend::getInstance('Settings', 'settings', false); $users = CAT_Users::getInstance(); header('Content-type: application/json'); if (!$users->checkPermission('Settings', 'settings')) { $ajax = array('message' => $backend->lang()->translate("Sorry, but you don't have the permissions for this action"), 'success' => false); print json_encode($ajax); exit; } $tpl = CAT_Helper_Validate::get('_REQUEST', 'template'); // get template info $info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . $tpl); if (!$info || !count($info)) { $ajax = array('message' => CAT_Helper_Addons::getError(), 'success' => false); print json_encode($ajax); exit; } $ajax = array('message' => NULL, 'variants' => isset($info['module_variants']) ? $info['module_variants'] : array(), 'success' => true); print json_encode($ajax); exit;
} // if it's a template... if ($type == 'template') { $contents = file_get_contents($full . '/index.php'); $contents .= "\n\$dwoodata\t= array(); // if you need to set some additional template vars, add them here\nglobal \$page_id;\n\$variant = CAT_Helper_Page::getPageSettings(\$page_id,'internal','template_variant');\nif ( \$variant == '' ) \$variant = DEFAULT_TEMPLATE_VARIANT;\nif ( \$variant == '' || !file_exists(CAT_PATH.'/templates/bootstrap/templates/'.\$variant.'/index.tpl' ) )\n \$variant = 'default';\n\$parser->setPath(CAT_TEMPLATE_DIR.'/templates/'.\$variant);\n\$parser->setFallbackPath(CAT_TEMPLATE_DIR.'/templates/default');\n\$parser->output('index.tpl',\$dwoodata);\n"; file_put_contents($full . '/index.php', $contents); CAT_Helper_Directory::createDirectory($full . '/templates/default'); CAT_Helper_Directory::recursiveCreateIndex($full . '/templates'); } // insert module into DB foreach ($info as $key => $value) { $key = str_replace($pre, 'module_', $key); $info[$key] = $value; } $info['addon_function'] = $type; CAT_Helper_Addons::loadModuleIntoDB($dir, 'install', $info); $success = true; $message = $backend->lang()->translate('Module created successfully!'); printResult(); function printResult() { global $message, $success; $ajax = array('message' => $message, 'success' => $success); print json_encode($ajax); exit; } function writeHeader($fh, $name, $author, $type) { fwrite($fh, '<' . '?' . 'php /**
* @copyright 2013, Black Cat Development * @link http://blackcat-cms.org * @license http://www.gnu.org/licenses/gpl.html * @category CAT_Core * @package CAT_Core * */ require_once dirname(__FILE__) . '/../../config.php'; define('CAT_INSTALL_PROCESS', true); // Try to guess installer URL $installer_uri = (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"] . ($_SERVER['SERVER_PORT'] != 80 && !isset($_SERVER['HTTPS']) ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER["SCRIPT_NAME"]; $installer_uri = dirname($installer_uri); $installer_uri = str_ireplace('update', '', $installer_uri); $lang = CAT_Helper_I18n::getInstance(); $lang->addFile($lang->getLang() . '.php', dirname(__FILE__) . '/../languages'); if (!CAT_Helper_Addons::versionCompare(CAT_VERSION, '0.11.0Beta')) { pre_update_error($lang->translate('You need to have <strong>BlackCat CMS v0.11.0Beta</strong> installed to use the Update.<br />You have <strong>{{version}}</strong> installed.', array('version' => CAT_VERSION))); } // get new version from tag.txt if (file_exists(dirname(__FILE__) . '/../tag.txt')) { $tag = fopen(dirname(__FILE__) . '/../tag.txt', 'r'); list($current_version, $current_build, $current_build) = explode('#', fgets($tag)); fclose($tag); } else { pre_update_error($lang->translate('The file <pre>tag.txt</pre> is missing! Unable to upgrade!')); } if (!CAT_Helper_Validate::getInstance()->sanitizeGet('do')) { update_wizard_header(); echo ' <h1>BlackCat CMS Update Wizard</h1> <h2>' . $lang->translate('Welcome!') . '</h2>
$client = new Zend\Http\Client($current['source'], array('timeout' => $current['timeout'], 'adapter' => 'Zend\\Http\\Client\\Adapter\\Proxy', 'proxy_host' => $current['proxy_host'], 'proxy_port' => $current['proxy_port'])); $client->setHeaders(array('Pragma' => 'no-cache', 'Cache-Control' => 'no-cache')); try { $response = $client->send(); if ($response->getStatusCode() != '200') { $error = "Unable to load source " . "(using Proxy: " . (isset($current['proxy_host']) && $current['proxy_host'] != '' ? 'yes' : 'no') . ")<br />" . "Status: " . $response->getStatus() . " - " . $response->getMessage() . ($debug ? "<br />" . var_dump($client->getLastRequest()) : NULL) . "<br />"; $version = 'unknown'; } else { $version = $response->getBody(); } } catch (Exception $e) { $error = "Unable to load source " . "(using Proxy: " . (isset($current['proxy_host']) && $current['proxy_host'] != '' ? 'yes' : 'no') . ")<br />" . $e->getMessage() . "<br />"; $version = 'unknown'; } if ($version && $version != 'unknown') { if (CAT_Helper_Addons::getInstance()->versionCompare($version, CAT_VERSION, '>')) { $newer = true; } } $fh = @fopen(CAT_Helper_Directory::sanitizePath(dirname(__FILE__) . '/../data/.last'), 'w'); if (is_resource($fh)) { fputs($fh, time() . '|' . $version); fclose($fh); } } else { $version = isset($last_version) && $last_version != '' ? $last_version : $version; } global $parser; $parser->setPath(dirname(__FILE__) . '/../templates/default'); $parser->output('widget.tpl', array('error' => $error, 'version' => $version, 'newer' => $newer, 'last' => CAT_Helper_DateTime::getInstance()->getDate($last) . ' ' . CAT_Helper_DateTime::getInstance()->getTime($last), 'CAT_VERSION' => CAT_VERSION, 'uri' => $_SERVER['SCRIPT_NAME'], 'missing_mailer_libs' => count(CAT_Helper_Addons::getLibraries('mail')), 'missing_wysiwyg' => count(CAT_Helper_Addons::get_addons(NULL, 'module', 'wysiwyg'))));
// no frontend login, no forgot form if (INTRO_PAGE) { die(header('Location: ' . CAT_URL . PAGES_DIRECTORY . '/index.php')); } else { die(header('Location: ' . CAT_URL . '/index.php')); } } $val = CAT_Helper_Validate::getInstance(); $email = $val->sanitizePost('email', NULL, true); $display_form = true; $msg_class = 'info'; global $parser; $parser->setPath(CAT_PATH . '/templates/' . DEFAULT_TEMPLATE . '/templates/' . CAT_Registry::get('DEFAULT_THEME_VARIANT')); // if there's a template for this in the current frontend template $parser->setFallbackPath(dirname(__FILE__) . '/templates/default'); // fallback to default dir // mailer lib installed? if (count(CAT_Helper_Addons::getLibraries('mail')) == 0) { $parser->output('account_forgot_form', array('message_class' => 'highlight', 'display_form' => false, 'message' => $val->lang()->translate('Sorry, but the system is unable to use mail to send your details. Please contact the administrator.'), 'contact' => CAT_Registry::exists('SERVER_EMAIL', false) && CAT_Registry::get('SERVER_EMAIL') != '*****@*****.**' && $val->validate_email(CAT_Registry::get('SERVER_EMAIL')) ? '<br />[ <a href="mailto:' . CAT_Registry::get('SERVER_EMAIL') . '">' . $val->lang()->translate('Send eMail') . '</a> ]' : '')); exit; } // Check if the user has already submitted the form, otherwise show it if ($email && $val->sanitize_email($email)) { list($result, $message) = CAT_Users::handleForgot($email); } else { $email = ''; } if (!isset($message)) { $message = $val->lang()->translate('Please enter your email address below'); } $parser->output('account_forgot_form', array('message_class' => $msg_class, 'email' => $email, 'display_form' => $display_form, 'message' => $message));
} // reload settings $config = wysiwyg_admin_config(); } } if (isset($config['plugins']) && $config['plugins'] != '') { $seen = explode(',', $config['plugins']); foreach ($seen as $item) { $plugins_checked[$item] = 1; } } if (isset($config['filemanager']) && $config['filemanager'] != '') { $filemanager_checked[$config['filemanager']] = true; } $parser->setPath(dirname(__FILE__) . "/templates/default"); $parser->output('tool', array('width_unit_em' => '', 'width_unit_px' => '', 'width_unit_proz' => '', 'height_unit_em' => '', 'height_unit_px' => '', 'height_unit_proz' => '', 'action' => CAT_ADMIN_URL . '/admintools/tool.php?tool=wysiwyg_admin', 'id' => WYSIWYG_EDITOR, 'skins' => $skins, 'toolbars' => $toolbars, 'current_toolbar' => $c->getToolbar($config), 'width' => $width, 'height' => $height, 'current_skin' => $c->getSkin($config), 'preview' => $preview, 'settings' => $settings, 'config' => $config, 'errors' => $errors, 'plugins' => $plugins, 'filemanager' => $filemanager, 'plugins_checked' => $plugins_checked, 'filemanager_checked' => $filemanager_checked, 'htmlpurifier' => CAT_Helper_Addons::isModuleInstalled('lib_htmlpurifier'), 'enable_htmlpurifier' => $enable_htmlpurifier, 'width_unit_' . ($width_unit == '%' ? 'proz' : $width_unit) => 'checked="checked"', 'height_unit_' . ($height_unit == '%' ? 'proz' : $height_unit) => 'checked="checked"')); // get current settings function wysiwyg_admin_config() { global $backend; $query = "SELECT * from `:prefix:mod_wysiwyg_admin_v2` where `editor`='" . WYSIWYG_EDITOR . "'"; $result = $backend->db()->query($query); $config = array(); if ($result->numRows()) { while (false !== ($row = $result->fetch())) { if (substr_count($row['set_value'], '#####')) { $row['set_value'] = explode('#####', $row['set_value']); } $config[$row['set_name']] = $row['set_value']; } }
$file->process(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/blackcatFilter/filter/')); if (!$file->processed) { $upload_error = $file->error; } else { $data['name'] = $file->file_dst_name_body; } // filter must have the same name as the file // the file will be renamed by the upload helper if it already // exists, so we use the destination name here } } if (count($errors) || $upload_error) { $showit = true; } else { $backend->db()->query("INSERT INTO `:prefix:mod_filter` VALUES ( :name, :module, :desc, :code, :active )", array('name' => $data['name'], 'module' => $data['module_name'], 'desc' => $data['description'], 'code' => $data['code'], 'active' => $data['active'])); if ($backend->db()->isError()) { $errors[] = $backend->db()->getError(); } } } // get available filters $filters = array(); $result = $backend->db()->query("SELECT * FROM `:prefix:mod_filter`"); if ($result->numRows()) { while (false !== ($row = $result->fetch())) { $filters[] = $row; } } $parser->setPath(dirname(__FILE__) . '/templates/default'); $parser->output('tool.tpl', array('filters' => $filters, 'showit' => $showit, 'missing' => $errors, 'modules' => CAT_Helper_Addons::get_addons('blackcatFilter', 'module'), 'upload_error' => $upload_error, 'errors' => implode('<br />', $errors) . '<br />' . $upload_error));
$root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // Make sure people are allowed to access this page if (MANAGE_SECTIONS != 'enabled') { header('Location: ' . CAT_ADMIN_URL); exit(0); } $backend = CAT_Backend::getInstance('Pages', 'pages_modify'); $addons = CAT_Helper_Addons::getInstance(); $val = CAT_Helper_Validate::getInstance(); $page_id = $val->get('_REQUEST', 'page_id', 'numeric'); if (!$page_id) { header("Location: index.php"); exit(0); } if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) { $backend->print_error('You do not have permissions to modify this page'); } $page_details = CAT_Helper_Page::properties($page_id); if (!count($page_details)) { $backend->print_error('Page not found'); } // ========================== // ! Set module permissions
} // check tool permission if (!CAT_Users::get_permission($get_tool, 'module')) { header("Location: index.php"); exit(0); } global $parser; $parser->setGlobals('CAT_ADMIN_URL', CAT_ADMIN_URL); // ============================== // ! Check if tool is installed // ============================== if (!CAT_Helper_Addons::isModuleInstalled($get_tool)) { header("Location: index.php"); exit(0); } $tool = CAT_Helper_Addons::getAddonDetails($get_tool); // Set toolname $tpl_data['TOOL_NAME'] = $tool['name']; $parser->setGlobals('TOOL_URL', CAT_ADMIN_URL . '/admintools/tool.php?tool=' . $tool['directory']); // Check if folder of tool exists if (file_exists(CAT_PATH . '/modules/' . $tool['directory'] . '/tool.php')) { // load language file (if any) $langfile = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $tool['directory'] . '/languages/' . LANGUAGE . '.php'); if (file_exists($langfile)) { if (!$backend->lang()->checkFile($langfile, 'LANG', true)) { // old fashioned language file require $langfile; } else { // modern language file $backend->lang()->addFile(LANGUAGE . '.php', CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $tool['directory'] . '/languages')); }
$root = "../"; $level = 1; while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) { $root .= "../"; $level += 1; } if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } // // include snippets // $snippets = CAT_Helper_Addons::get_addons(0, 'module', 'snippet'); foreach ($snippets as $s) { $file = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $s['VALUE'] . '/include.php'); if (file_exists($file)) { include $file; } } /* 'one liners' */ function get_page_link($page_id) { return CAT_Helper_Page::properties($page_id, 'link'); } function language_menu() { global $page_id; return CAT_Page::getInstance($page_id)->getLanguageMenu();
} if (file_exists($root . '/framework/class.secure.php')) { include $root . '/framework/class.secure.php'; } else { trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR); } } $local = array('pages' => 'backend_pages_modify.js', 'access' => 'backend_users_index.js', 'addons' => 'backend_addons.js', 'media' => 'backend_media.js', 'preferences' => 'backend_preferences.js', 'settings' => array('backend_pages_modify.js', 'backend_settings_index.js'), 'login_index' => 'login.js'); $mod_headers = array('backend' => array('meta' => array(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1')), 'css' => array(array('media' => 'screen', 'file' => 'templates/freshcat/css/default/index.css'), array('media' => 'screen', 'file' => 'modules/lib_jquery/plugins/qtip2/qtip2.min.css')), 'jquery' => array(array('core' => true, 'ui' => true, 'all' => array('jquery.highlight', 'jquery.cookies', 'tag-it', 'qtip2', 'jquery.form', 'jquery.livesearch', 'jquery.smarttruncation', 'cattranslate'))), 'js' => array(array('debug.js', 'jquery.fc_set_tab_list.js', 'jquery.fc_toggle_element.js', 'jquery.fc_resize_elements.js', 'jquery.fc_show_popup.js', 'general.js', 'pages_tree.js', 'session.js')))); // get current backend section to add local JS $page = strtolower(CAT_Backend::getInstance()->section_name); if (isset($local[$page])) { if (!is_array($local[$page])) { $local[$page] = array($local[$page]); } $mod_headers['backend']['js'][0] = array_merge($mod_headers['backend']['js'][0], $local[$page]); } if ($page == 'addons') { array_push($mod_headers['backend']['css'], array('file' => 'templates/freshcat/css/default/tabs.css')); if (CAT_Helper_Addons::isModuleInstalled('lib_dropzone')) { $mod_headers['backend']['js'][0][] = '/modules/lib_dropzone/vendor/dropzone.min.js'; array_push($mod_headers['backend']['css'], array('file' => 'modules/lib_dropzone/vendor/dropzone.min.css')); } array_push($mod_headers['backend']['css'], array('file' => 'templates/freshcat/css/default/addons.css')); } // check for custom JS for current backend page if (CAT_Registry::get('DEFAULT_THEME_VARIANT') == 'custom') { if (file_exists(dirname(__FILE__) . '/templates/custom/backend_' . $page . '.js')) { $mod_headers['backend']['js'][0][] = '/custom/backend_' . $page . '.js'; } }