Пример #1
0
 /**
  *
  * @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;
 }
Пример #2
0
 /**
  *  Try to get the current version of a given Modul.
  *
  *  @param  string  $modulname: like saved in addons directory
  *  @param  boolean  $source: true reads from database, false from info.php
  *  @return  string  the version as string, if not found returns null
  *
  *  Moved to Addons helper class (though it seems to be never used)
  *
  */
 function get_modul_version($modulname, $source = true)
 {
     return CAT_Helper_Addons::getInstance()->getModuleVersion($modulname, $source);
 }
Пример #3
0
        $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
Пример #4
0
         }
         ${$key} = $val->sanitizePost($key);
         ${$key . '_unit'} = $val->sanitizePost($key . '_unit');
     }
 }
 // check skin
 if ($val->sanitizePost('skin')) {
     if (!in_array($val->sanitizePost('skin'), $skins)) {
         $errors[$key] = $backend->lang()->translate('Invalid skin!');
         continue;
     } else {
         $new_skin = $val->sanitizePost('skin');
     }
 }
 // check HTMLPurifier
 if (CAT_Helper_Addons::getInstance()->isModuleInstalled('lib_htmlpurifier') && $val->sanitizePost(enable_htmlpurifier) && $val->sanitizePost('enable_htmlpurifier') == 'true') {
     $enable_htmlpurifier = true;
 } else {
     $enable_htmlpurifier = false;
 }
 // check toolbar
 if ($val->sanitizePost('toolbar')) {
     if (!in_array($val->sanitizePost('toolbar'), $toolbars)) {
         $errors[$key] = $backend->lang()->translate('Invalid toolbar!');
         continue;
     } else {
         $new_toolbar = $val->sanitizePost('toolbar');
     }
 }
 // check additionals
 if (count($settings)) {
Пример #5
0
    include CAT_PATH . '/modules/lib_zendlite/library.php';
    $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'))));
Пример #6
0
/**
 *
 **/
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;
}
Пример #7
0
    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;
Пример #8
0
/**
 * check the basic prerequisites for the CMS installation; uses
 * precheck.php to do this. Returns the result of preCheckAddon() method
 **/
function show_step_precheck()
{
    global $lang, $parser, $installer_uri;
    $ok = true;
    write2log('> [show_step_precheck()]');
    // precheck.php
    include dirname(__FILE__) . '/../framework/CAT/Helper/Addons.php';
    $addons = CAT_Helper_Addons::getInstance();
    $result = $addons->preCheckAddon(NULL, dirname(__FILE__), false, true);
    $parser->setPath(dirname(__FILE__) . '/templates/default');
    $result = $parser->get('precheck.tpl', array('output' => $result));
    // scan the HTML for errors; this is easier than to extend the methods in
    // the Addons helper
    if (preg_match('~class=\\"fail~i', $result, $match)) {
        $ok = false;
    }
    $install_dir = pathinfo(dirname(__FILE__), PATHINFO_BASENAME);
    // file permissions check
    $dirs = array(array('name' => '', 'ok' => false), array('name' => 'page', 'ok' => false), array('name' => 'media', 'ok' => false), array('name' => 'templates', 'ok' => false), array('name' => 'modules', 'ok' => false), array('name' => 'languages', 'ok' => false), array('name' => 'temp', 'ok' => false));
    foreach ($dirs as $i => $dir) {
        $path = dirname(__FILE__) . '/../' . $dir['name'];
        $dirs[$i]['ok'] = is_writable($path);
        if ($dir['name'] == '') {
            $dirs[$i]['name'] = $lang->translate('CMS root directory');
        } else {
            $dirs[$i]['name'] = '/' . $dirs[$i]['name'] . '/';
        }
        if ($dirs[$i]['ok'] === false) {
            $ok = false;
        }
    }
    // special check for install dir (must be world writable)
    $inst_is_writable = is_writable(dirname(__FILE__));
    //( substr(sprintf('%o', fileperms(dirname(__FILE__))), -1) == 7 ? true : false );
    if (!$inst_is_writable) {
        $ok = false;
    }
    $dirs[] = array('name' => $lang->translate('CMS installation directory') . ' (<tt>' . $install_dir . '</tt>)', 'ok' => $inst_is_writable);
    $output = $parser->get('fperms.tpl', array('dirs' => $dirs, 'ok' => $ok, 'result' => $ok ? $lang->translate('All checks succeeded!') : $lang->translate('Sorry, we encountered some issue(s) that will inhibit the installation. Please check the results above and fix the issue(s) listed there.')));
    write2log('< [show_step_precheck()]');
    return array($ok, $result . $output);
}
Пример #9
0
 /**
  *  Print the admin header
  *
  *  @access public
  *  @return void
  */
 public function print_header()
 {
     global $parser;
     $tpl_data = array();
     $addons = CAT_Helper_Addons::getInstance();
     $user = CAT_Users::getInstance();
     // Connect to database and get website title
     if (!CAT_Registry::exists('WEBSITE_TITLE')) {
         $title = $this->db()->query("SELECT `value` FROM `:prefix:settings` WHERE `name`='website_title'")->fetchColumn();
         CAT_Registry::define('WEBSITE_TITLE', $title, true);
     }
     // check current URL for page tree
     $uri = CAT_Helper_Validate::get('_SERVER', 'SCRIPT_NAME');
     // init template search paths
     self::initPaths();
     // =================================
     // ! Add permissions to $tpl_data
     // =================================
     $tpl_data['permission']['pages'] = $user->checkPermission('pages', 'pages', false);
     $tpl_data['permission']['pages_add'] = $user->checkPermission('pages', 'pages_add', false);
     $tpl_data['permission']['pages_add_l0'] = $user->checkPermission('pages', 'pages_add_l0', false);
     $tpl_data['permission']['pages_modify'] = $user->checkPermission('pages', 'pages_modify', false);
     $tpl_data['permission']['pages_delete'] = $user->checkPermission('pages', 'pages_delete', false);
     $tpl_data['permission']['pages_settings'] = $user->checkPermission('pages', 'pages_settings', false);
     $tpl_data['permission']['pages_intro'] = $user->checkPermission('pages', 'pages_intro', false) != true || INTRO_PAGE != 'enabled' ? false : true;
     if ($tpl_data['permission']['pages'] == true) {
         $tpl_data['DISPLAY_MENU_LIST'] = CAT_Registry::get('MULTIPLE_MENUS') != false ? true : false;
         $tpl_data['DISPLAY_LANGUAGE_LIST'] = CAT_Registry::get('PAGE_LANGUAGES') != false ? true : false;
         $tpl_data['DISPLAY_SEARCHING'] = CAT_Registry::get('SEARCH') != false ? true : false;
         // ==========================
         // ! Get info for pagesTree
         // ==========================
         $pages = CAT_Helper_Page::getPages(true);
         $sections = CAT_Helper_Page::getSections();
         // create LI content for ListBuilder
         foreach ($pages as $i => $page) {
             if (isset($sections[$page['page_id']]) && count($sections[$page['page_id']])) {
                 $page['page_title'] .= "\n" . count($sections[$page['page_id']]) . ' ' . $user->lang()->translate('active sections') . ':';
                 foreach ($sections[$page['page_id']] as $block_id => $section) {
                     foreach ($section as $item) {
                         $page['page_title'] .= "\n" . $item['module'] . ' (ID:' . $item['section_id'] . ')';
                     }
                 }
             }
             $text = $parser->get('backend_pagetree_item', array_merge($page, array('action' => pathinfo($uri, PATHINFO_FILENAME) == 'lang_settings' ? 'lang_settings' : 'modify')));
             $pages[$i]['text'] = $text;
         }
         // list of first level of pages
         $tpl_data['pages'] = CAT_Helper_ListBuilder::getInstance()->config(array('__li_level_css' => true, '__li_id_prefix' => 'pageid_', '__li_css_prefix' => 'fc_page_', '__li_has_child_class' => 'fc_expandable', '__is_open_key' => 'be_tree_is_open', '__li_is_open_class' => 'fc_tree_open', '__li_is_closed_class' => 'fc_tree_close', '__title_key' => 'text'))->tree($pages, 0);
         // number of editable pages (for current user)
         $tpl_data['pages_editable'] = CAT_Helper_Page::getEditable();
         // ==========================================
         // ! Get info for the form to add new pages
         // ==========================================
         $tpl_data['templates'] = $addons->get_addons(CAT_Registry::get('DEFAULT_TEMPLATE'), 'template', 'template');
         $tpl_data['languages'] = $addons->get_addons(CAT_Registry::get('DEFAULT_LANGUAGE'), 'language');
         $tpl_data['modules'] = $addons->get_addons('wysiwyg', 'module', 'page');
         $tpl_data['groups'] = $user->get_groups();
         // ===========================================
         // ! Check and set permissions for templates
         // ===========================================
         foreach ($tpl_data['templates'] as $key => $template) {
             $tpl_data['templates'][$key]['permissions'] = $user->get_permission($template['VALUE'], 'template') ? true : false;
         }
     }
     // =========================
     // ! Add Metadatas to Dwoo
     // =========================
     $tpl_data['META']['CHARSET'] = true === defined('DEFAULT_CHARSET') ? DEFAULT_CHARSET : 'utf-8';
     $tpl_data['META']['LANGUAGE'] = strtolower(CAT_Registry::get('LANGUAGE'));
     $tpl_data['META']['WEBSITE_TITLE'] = WEBSITE_TITLE;
     $tpl_data['CAT_VERSION'] = CAT_Registry::get('CAT_VERSION');
     $tpl_data['CAT_CORE'] = CAT_Registry::get('CAT_CORE');
     $tpl_data['PAGE_EXTENSION'] = CAT_Registry::get('PAGE_EXTENSION');
     $date_search = array('Y', 'j', 'n', 'jS', 'l', 'F');
     $date_replace = array('yy', 'y', 'm', 'd', 'DD', 'MM');
     $tpl_data['DATE_FORMAT'] = str_replace($date_search, $date_replace, CAT_Registry::get('CAT_DATE_FORMAT'));
     $time_search = array('H', 'i', 's', 'g');
     $time_replace = array('hh', 'mm', 'ss', 'h');
     $tpl_data['TIME_FORMAT'] = str_replace($time_search, $time_replace, CAT_Registry::get('TIME_FORMAT'));
     $tpl_data['SESSION'] = session_name();
     $tpl_data['HEAD']['SECTION_NAME'] = $this->lang()->translate(strtoupper(self::$instance->section_name));
     $tpl_data['DISPLAY_NAME'] = $user->get_display_name();
     $tpl_data['USER'] = $user->get_user_details($user->get_user_id());
     // ===================================================================
     // ! Add arrays for main menu, options menu and the Preferences-Button
     // ===================================================================
     $tpl_data['MAIN_MENU'] = array();
     $tpl_data['MAIN_MENU'][0] = array('link' => CAT_ADMIN_URL . '/start/index.php', 'title' => $this->lang()->translate('Start'), 'permission_title' => 'start', 'permission' => $user->checkPermission('start', 'start') ? true : false, 'current' => 'start' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][1] = array('link' => CAT_ADMIN_URL . '/media/index.php', 'title' => $this->lang()->translate('Media'), 'permission_title' => 'media', 'permission' => $user->checkPermission('media', 'media') ? true : false, 'current' => 'media' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][2] = array('link' => CAT_ADMIN_URL . '/settings/index.php', 'title' => $this->lang()->translate('Settings'), 'permission_title' => 'settings', 'permission' => $user->checkPermission('settings', 'settings') ? true : false, 'current' => 'settings' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][3] = array('link' => CAT_ADMIN_URL . '/addons/index.php', 'title' => $this->lang()->translate('Addons'), 'permission_title' => 'addons', 'permission' => $user->checkPermission('addons', 'addons') ? true : false, 'current' => 'addons' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][4] = array('link' => CAT_ADMIN_URL . '/admintools/index.php', 'title' => $this->lang()->translate('Admin-Tools'), 'permission_title' => 'admintools', 'permission' => $user->checkPermission('admintools', 'admintools') ? true : false, 'current' => 'admintools' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][5] = array('link' => CAT_ADMIN_URL . '/users/index.php', 'title' => $this->lang()->translate('Access'), 'permission_title' => 'access', 'permission' => $user->checkPermission('access', 'access') ? true : false, 'current' => 'access' == strtolower($this->section_name) ? true : false);
     // =======================================
     // ! Seperate access-link by permissions
     // =======================================
     if ($user->get_permission('users')) {
         $tpl_data['MAIN_MENU'][5]['link'] = CAT_ADMIN_URL . '/users/index.php';
     } elseif ($user->get_permission('groups')) {
         $tpl_data['MAIN_MENU'][5]['link'] = CAT_ADMIN_URL . '/groups/index.php';
     }
     $tpl_data['PREFERENCES'] = array('link' => CAT_ADMIN_URL . '/preferences/index.php', 'title' => $this->lang()->translate('Preferences'), 'permission_title' => 'preferences', 'permission' => $this->get_link_permission('preferences') ? true : false, 'current' => 'preferences' == strtolower($this->section_name) ? true : false);
     $tpl_data['section_name'] = strtolower($this->section_name);
     $tpl_data['page_id'] = CAT_Helper_Validate::sanitizeGet('page_id', 'numeric') && CAT_Helper_Validate::sanitizeGet('page_id') != '' ? CAT_Helper_Validate::sanitizeGet('page_id') : (CAT_Helper_Validate::sanitizePost('page_id', 'numeric') && CAT_Helper_Validate::sanitizePost('page_id') != '' ? CAT_Helper_Validate::sanitizePost('page_id') : false);
     // ====================
     // ! Parse the header
     // ====================
     $parser->output('header', $tpl_data);
 }