Exemplo n.º 1
0
function Dwoo_Plugin_page_title(Dwoo $dwoo, $spacer = ' - ', $template = '[WEBSITE_TITLE][SPACER][PAGE_TITLE]', $mode = true)
{
    $vars = array('[WEBSITE_TITLE]', '[PAGE_TITLE]', '[MENU_TITLE]', '[SPACER]');
    $values = array(CAT_Registry::get('WEBSITE_TITLE'), CAT_Registry::get('PAGE_TITLE'), CAT_Registry::get('MENU_TITLE'), $spacer);
    $temp = str_replace($vars, $values, $template);
    if (true === $mode) {
        return $temp;
    } else {
        echo $temp;
        return true;
    }
}
    }
    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';
    }
}
Exemplo n.º 3
0
    // 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));
Exemplo n.º 4
0
    $salt = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEZ_+-";
    $salt_len = strlen($salt) - 1;
    $i = 0;
    while (++$i <= 7) {
        $num = mt_rand(0, $salt_len);
        $username_fieldname .= $salt[$num];
    }
    $tpl_data['USERNAME_FIELDNAME'] = $username_fieldname;
}
$tpl_data['USERNAME'] = isset($_SESSION['au']['username']) ? $_SESSION['au']['username'] : false;
$tpl_data['PASSWORD'] = isset($_SESSION['au']['password']) ? $_SESSION['au']['password'] : false;
$tpl_data['DISPLAY_NAME'] = isset($_SESSION['au']['display_name']) ? $_SESSION['au']['display_name'] : false;
$tpl_data['EMAIL'] = isset($_SESSION['au']['email']) ? $_SESSION['au']['email'] : false;
$tpl_data['HOME_FOLDERS'] = HOME_FOLDERS;
$tpl_data['INITIAL_PAGE'] = INITIAL_PAGE;
$tpl_data['NEWUSERHINT'] = preg_split('/, /', $backend->lang()->translate('Minimum length for user name: {{ name }} chars, Minimum length for Password: {{ password }} chars!', array('name' => CAT_Registry::get('AUTH_MIN_LOGIN_LENGTH'), 'password' => CAT_Registry::get('AUTH_MIN_PASS_LENGTH'))));
// ============================
// ! Add groups to $tpl_data
// ============================
$tpl_data['groups'] = $users->get_groups();
// ======================================================================================
// ! Only allow the user to add a user to the Administrators group if he belongs to it
// ======================================================================================
$tpl_data['is_admin'] = in_array(1, $users->get_groups_id()) ? true : false;
// Add media folders to home folder list
foreach (directory_list(CAT_PATH . MEDIA_DIRECTORY) as $index => $name) {
    $tpl_data['home_folders'][$index]['NAME'] = str_replace(CAT_PATH, '', $name);
    $tpl_data['home_folders'][$index]['FOLDER'] = str_replace(CAT_PATH . MEDIA_DIRECTORY, '', $name);
}
// initial page selection
$pages = CAT_Helper_Page::getPages();
Exemplo n.º 5
0
     // ! Update time format
     // ======================
     $time_format = $val->sanitizePost('time_format');
     if ($time_format != '') {
         $_SESSION['CAT_TIME_FORMAT'] = $time_format;
         if (isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
             unset($_SESSION['USE_DEFAULT_TIME_FORMAT']);
         }
     } else {
         $_SESSION['USE_DEFAULT_TIME_FORMAT'] = true;
         if (isset($_SESSION['CAT_TIME_FORMAT'])) {
             unset($_SESSION['CAT_TIME_FORMAT']);
         }
     }
     if (defined('WB2COMPAT') && WB2COMPAT === true) {
         $wb2compat_format_map = CAT_Registry::get('WB2COMPAT_FORMAT_MAP');
         $_SESSION['DATE_FORMAT'] = $wb2compat_format_map[$_SESSION['CAT_DATE_FORMAT']];
         $_SESSION['TIME_FORMAT'] = $wb2compat_format_map[$_SESSION['CAT_TIME_FORMAT']];
     }
     // ====================
     // ! Set initial page
     // ====================
     $new_init_page = $val->sanitizePost('init_page_select');
     if ($new_init_page) {
         require_once CAT_PATH . '/modules/initial_page/classes/c_init_page.php';
         $ref = new c_init_page($backend->db());
         $ref->update_user($_SESSION['USER_ID'], $new_init_page);
         unset($ref);
     }
 } else {
     $err_msg = $backend->lang()->translate('invalid database UPDATE call in ') . __FILE__ . '::' . __FUNCTION__ . $backend->lang()->translate('before line ') . __LINE__;
Exemplo n.º 6
0
    exit;
}
if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) {
    $ajax = array('message' => $backend->lang()->translate('You do not have the permission to restore this page.'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// Find out more about the page
$page = CAT_Helper_Page::properties($page_id);
if (!$page) {
    $ajax = array('message' => $backend->lang()->translate('Page not found'), 'success' => false);
    print json_encode($ajax);
    exit;
}
$visibility = $page['visibility'];
if (CAT_Registry::get('PAGE_TRASH') !== 'false') {
    if ($visibility == 'deleted') {
        // Function to change all child pages visibility to deleted
        function restore_subs($parent = 0)
        {
            global $backend;
            // Query pages
            $query_menu = $backend->db()->query(sprintf("SELECT page_id FROM `%spages` WHERE parent = '%d' ORDER BY position ASC", CAT_TABLE_PREFIX, $parent));
            // Check if there are any pages to show
            if ($query_menu->numRows() > 0) {
                // Loop through pages
                while ($page = $query_menu->fetchRow(MYSQL_ASSOC)) {
                    // Update the page visibility to 'deleted'
                    $backend->db()->query(sprintf("UPDATE `%spages` SET visibility = 'public' WHERE page_id = '%d' LIMIT 1", CAT_TABLE_PREFIX, $page['page_id']));
                    // Run this function again for all sub-pages
                    restore_subs($page['page_id']);
Exemplo n.º 7
0
}
// this one is only used for the frontend!
if (!FRONTEND_LOGIN || !FRONTEND_SIGNUP) {
    // no frontend login, no sign up
    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();
$errors = array();
$message = NULL;
$form = true;
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
// check ASP protection
if (ENABLED_ASP && $val->sanitizePost('username') && ($val->sanitizePost('email-address') != '' || $val->sanitizePost('name') != '' || $val->sanitizePost('full_name') != '')) {
    exit(header("Location: " . CAT_URL . PAGES_DIRECTORY . ""));
}
// handle registration
if ($val->sanitizePost('username')) {
    $users = CAT_Users::getInstance();
    $groups_id = FRONTEND_SIGNUP;
    $active = 1;
    $username = strtolower(strip_tags($val->sanitizePost('username', 'scalar', true)));
    $display_name = strip_tags($val->sanitizePost('display_name', 'scalar', true));
    $email = $val->sanitizePost('email', NULL, true);
Exemplo n.º 8
0
/**
 *
 **/
function check_er_level($value, $oldvalue)
{
    $ER_LEVELS = CAT_Registry::get('ER_LEVELS', 'array');
    return isset($value) && array_key_exists($value, $ER_LEVELS) ? intval($value) : $oldvalue;
}
Exemplo n.º 9
0
 /**
  * load headers.inc.php for sections
  *
  * @access private
  * @param  string  $for - frontend | backend
  * @return void
  **/
 private static function _load_sections($for = 'frontend')
 {
     global $page_id;
     // make sure we have a page_id
     if (!$page_id) {
         $page_id = CAT_Helper_Validate::get('_REQUEST', 'page_id', 'numeric');
     }
     if ($page_id && is_numeric($page_id)) {
         $sections = self::getSections($page_id);
         $wysiwyg_seen = false;
         self::$instance->log()->logDebug('sections:', $sections);
         if (is_array($sections) && count($sections)) {
             global $current_section;
             global $wysiwyg_seen;
             foreach ($sections as $block_id => $item) {
                 foreach ($item as $section) {
                     $module = $section['module'];
                     $file = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/headers.inc.php');
                     // find header definition file
                     if (file_exists($file)) {
                         self::$instance->log()->logDebug(sprintf('loading headers.inc.php for module [%s]', $module));
                         $current_section = $section['section_id'];
                         self::_load_headers_inc($file, $for, 'modules/' . $module, $current_section);
                     }
                     array_push(CAT_Helper_Page::$css_search_path, '/modules/' . $module, '/modules/' . $module . '/css');
                     array_push(CAT_Helper_Page::$js_search_path, '/modules/' . $module, '/modules/' . $module . '/js');
                 }
                 // foreach ($sections as $section)
             }
         }
         // if (count($sections))
         // always add WYSIWYG headers, some modules may use show_wysiwyg_editor() later on
         if (!$wysiwyg_seen) {
             if (file_exists(CAT_PATH . '/modules/' . WYSIWYG_EDITOR . '/headers.inc.php')) {
                 self::$instance->log()->logDebug('adding headers.inc.php for wysiwyg');
                 self::_load_headers_inc(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . WYSIWYG_EDITOR . '/headers.inc.php'), $for, CAT_PATH . '/modules/' . WYSIWYG_EDITOR);
             }
             $wysiwyg_seen = true;
         }
         // search
         if ($for == 'frontend' && CAT_Registry::get('SHOW_SEARCH') === true) {
             array_push(CAT_Helper_Page::$js_search_path, '/modules/' . CAT_Registry::get('SEARCH_LIBRARY') . '/templates/custom/', '/modules/' . CAT_Registry::get('SEARCH_LIBRARY') . '/templates/default/');
         }
     }
 }
Exemplo n.º 10
0
    $tpl_data['show_cmd_profile_edit_block'] = true;
} else {
    $tpl_data['show_cmd_profile_edit'] = true;
    $tpl_data['show_cmd_profile_edit_block'] = false;
}
// ============================================================================
// ! read available languages from table addons and assign it to the template
// ============================================================================
$addons = CAT_Helper_Addons::getInstance();
$tpl_data['languages'] = $addons->get_addons(LANGUAGE, 'language', false, 'directory');
// ==================================
// ! Insert default timezone values
// ==================================
$counter = 0;
$timezone_table = CAT_Helper_DateTime::getTimezones();
$user_timezone = isset($_SESSION['TIMEZONE_STRING']) ? $_SESSION['TIMEZONE_STRING'] : CAT_Registry::get('DEFAULT_TIMEZONE_STRING');
foreach ($timezone_table as $title) {
    $tpl_data['timezones'][$counter]['NAME'] = $title;
    $tpl_data['timezones'][$counter]['SELECTED'] = $user_timezone == $title ? true : false;
    $counter++;
}
// ===========================
// ! Insert date format list
// ===========================
$DATE_FORMATS = CAT_Helper_DateTime::getDateFormats();
$USE_DEFAULT = $val->fromSession('USE_DEFAULT_DATE_FORMAT');
$userformat = $val->fromSession('CAT_DATE_FORMAT');
$counter = 0;
foreach ($DATE_FORMATS as $format => $title) {
    $format = str_replace('|', ' ', $format);
    // Add's white-spaces (not able to be stored in array key)
Exemplo n.º 11
0
 /**
  * initializes template search paths for backend
  *
  * @access public
  * @return
  **/
 public static function initPaths()
 {
     global $parser;
     // ===================================
     // ! initialize template search path
     // ===================================
     $parser->setPath(CAT_THEME_PATH . '/templates/default', 'backend');
     $parser->setFallbackPath(CAT_THEME_PATH . '/templates/default', 'backend');
     if (file_exists(CAT_THEME_PATH . '/templates/default')) {
         $parser->setPath(CAT_THEME_PATH . '/templates/default', 'backend');
         if (!CAT_Registry::exists('DEFAULT_THEME_VARIANT') || CAT_Registry::get('DEFAULT_THEME_VARIANT') == '') {
             CAT_Registry::set('DEFAULT_THEME_VARIANT', 'default');
             $parser->setGlobals('DEFAULT_THEME_VARIANT', 'default');
         }
     }
     if (CAT_Registry::get('DEFAULT_THEME_VARIANT') != '' && file_exists(CAT_THEME_PATH . '/templates/' . CAT_Registry::get('DEFAULT_THEME_VARIANT'))) {
         $parser->setPath(CAT_THEME_PATH . '/templates/' . CAT_Registry::get('DEFAULT_THEME_VARIANT'), 'backend');
     }
 }
Exemplo n.º 12
0
    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('Pages', 'pages_modify', false);
$val = CAT_Helper_Validate::getInstance();
$users = CAT_Users::getInstance();
header('Content-type: application/json');
// Make sure people are allowed to access this page
if (!CAT_Registry::exists('MANAGE_SECTIONS') || CAT_Registry::get('MANAGE_SECTIONS') != 'enabled') {
    $ajax = array('message' => $backend->lang()->translate('You cannot modify sections. Please enable "Manage section".'), 'success' => false);
    print json_encode($ajax);
    exit;
}
$delete_section_id = $val->sanitizePost('delete_section_id', 'numeric');
$update_section_id = $val->sanitizePost('update_section_id', 'numeric');
$section_id = $delete_section_id ? $delete_section_id : $update_section_id;
// ===============
// ! Get page id
// ===============
$page_id = CAT_Sections::getPageForSection($section_id);
if (!$page_id) {
    $ajax = array('message' => $backend->lang()->translate('You sent an invalid value.') . ' ' . $backend->lang()->translate('Unable to get page_id for section [{{section}}].', array('section' => $section_id)), 'success' => false);
    print json_encode($ajax);
    exit;
Exemplo n.º 13
0
 /**
  * get all menus of an template
  *
  * @access public
  * @param  mixed $template (default: DEFAULT_TEMPLATE)
  * @param  int   $selected (default: 1)
  * @return void
  */
 public static function get_template_menus($template = DEFAULT_TEMPLATE, $selected = 1)
 {
     if (CAT_Registry::get('MULTIPLE_MENUS') !== false) {
         $template_location = $template != '' ? CAT_PATH . '/templates/' . $template . '/info.php' : CAT_PATH . '/templates/' . CAT_Registry::get('DEFAULT_TEMPLATE') . '/info.php';
         if (file_exists($template_location)) {
             require $template_location;
         }
         if (!isset($menu[1]) || $menu[1] == '') {
             $menu[1] = 'Main';
         }
         foreach ($menu as $number => $name) {
             self::$template_menus[$number] = array('NAME' => $name, 'VALUE' => $number, 'SELECTED' => $selected == $number || $selected == $name ? true : false);
         }
         return self::$template_menus;
     } else {
         return false;
     }
 }
Exemplo n.º 14
0
    $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);
    }
}
$user = CAT_Users::getInstance();
$backend = CAT_Backend::getInstance('Settings', 'settings_advanced');
global $parser;
$tpl_data = array();
// include local functions file
require_once dirname(__FILE__) . '/functions.php';
// template for default tab (SEO settings)
$tpl = 'backend_settings_index_seo';
// add default form
$tpl_data['INDEX'] = $parser->get($tpl, array('values' => getSettingsTable()));
$tpl_data['MAINTENANCE_MODE'] = CAT_Registry::get('MAINTENANCE_MODE');
// ====================
// ! Parse the site
// ====================
$parser->output('backend_settings_index', $tpl_data);
// ======================
// ! Print admin footer
// ======================
$backend->print_footer();
Exemplo n.º 15
0
 /**
  *  Print a message and redirect the user to another page
  *
  *  @access public
  *  @param  mixed   $message     - message string or an array with a couple of messages
  *  @param  string  $redirect    - redirect url; default is "index.php"
  *  @param  boolean $auto_footer - optional flag to 'print' the footer. Default is true.
  *  @param  boolean $auto_exit   - optional flag to call exit() (default) or not
  *  @return void    exit()s
  */
 public static function printMsg($message, $redirect = 'index.php', $auto_footer = true, $auto_exit = true)
 {
     global $parser;
     if (true === is_array($message)) {
         $message = implode("<br />", $message);
     }
     $parser->setPath(CAT_THEME_PATH . '/templates');
     $parser->setFallbackPath(CAT_THEME_PATH . '/templates');
     $parser->output('success', array('MESSAGE' => CAT_Object::lang()->translate($message), 'REDIRECT' => $redirect, 'REDIRECT_TIMER' => CAT_Registry::get('REDIRECT_TIMER')));
     if ($auto_footer == true) {
         $caller = debug_backtrace();
         // remove first item (it's the printMsg() method itself)
         array_shift($caller);
         $caller_class = isset($caller[0]['class']) ? $caller[0]['class'] : NULL;
         if ($caller_class && method_exists($caller_class, "print_footer")) {
             if (is_object($caller_class)) {
                 $caller_class->print_footer();
             } else {
                 $caller_class::print_footer();
             }
         } else {
             //echo "unable to print footer - no such method $caller_class -> print_footer()";
         }
         if ($auto_exit) {
             exit;
         }
     }
 }
Exemplo n.º 16
0
 *
 */
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);
    }
}
// protect
$backend = CAT_Backend::getInstance('Start', 'start', false, false);
if (!CAT_Users::is_authenticated()) {
    exit;
}
// just to be _really_ sure...
// there's no real need to protect this widget, just to handle all widgets...
$pg = CAT_Helper_Page::getInstance();
$widget_name = $pg->lang()->translate('Maintenance mode');
if (CAT_Registry::get('MAINTENANCE_MODE') == true) {
    echo '<span style="color:#c00;font-weight:900;">', '<span class="icon icon-warning" style="font-size:2em;margin-right:5px;"></span>', $pg->lang()->translate('Please note: The system is in maintenance mode!'), '</span><br /><span style="font-style:italic;margin-left:2.5em;font-size:0.9em;">', $pg->lang()->translate('To disable, go to Settings -> System settings -> Maintenance mode -> set to "off".'), '</span>';
} else {
    echo '<span class="icon icon-checkmark" style="font-size:1.2em;margin-right:5px;"></span>', $pg->lang()->translate('Maintenance mode is off.');
}
Exemplo n.º 17
0
 /**
  * check for valid username:
  *
  * + must begin with a char (a-z)
  * + ...followed by at least 2 chars (a-z), numbers (0-9), _ or -
  * + must match min and max username length
  *
  * If USERS_ALLOW_MAILADDRESS is set to true, the username is checked
  * for valid mail address. If it is valid, there will be no check for
  * min. and max. length to avoid problems here.
  *
  * @access public
  * @param  string  $username
  * @return booelan
  *
  **/
 public static function validateUsername($username)
 {
     if (CAT_Registry::exists('USERS_ALLOW_MAILADDRESS')) {
         $allow_mailaddress = CAT_Registry::get('USERS_ALLOW_MAILADDRESS');
     } else {
         $allow_mailaddress = false;
     }
     if (!preg_match('/^[a-z]{1}[a-z0-9_-]{2,}$/i', $username)) {
         if ($allow_mailaddress && CAT_Helper_Validate::getInstance()->sanitize_email($username)) {
             // in case of mail address, we do not check for min and max length!
             return true;
         } else {
             self::setError('Invalid eMail address');
             return false;
         }
         self::setError('Invalid characters in username found');
         return false;
     }
     $min_length = CAT_Registry::exists('AUTH_MIN_LOGIN_LENGTH') ? CAT_Registry::get('AUTH_MIN_LOGIN_LENGTH') : 5;
     $max_length = CAT_Registry::exists('AUTH_MAX_LOGIN_LENGTH') ? CAT_Registry::get('AUTH_MAX_LOGIN_LENGTH') : 50;
     if (strlen($username) < $min_length) {
         self::setError(self::getInstance()->lang()->translate('Username too short (min.: {{ length }})', array('length' => $min_length)));
         return false;
     }
     if (strlen($username) > $max_length) {
         self::setError(self::getInstance()->lang()->translate('Username too long (max.: {{ length }})', array('length' => $max_length)));
         return false;
     }
     return true;
 }
if (!CAT_Helper_Page::getPagePermission($page_id, 'admin')) {
    $backend->print_error('You do not have permissions to modify this page');
}
$tpl_data = array();
include dirname(__FILE__) . '/setglobals.php';
setglobals($page_id);
$tpl_data['CUR_TAB'] = 'seo';
$tpl_data['PAGE_HEADER'] = $backend->lang()->translate('Modify SEO settings');
// get the form
$form = $backend->getForms('pages');
$form->setForm('seo');
if ($form->isSent() && $form->isValid()) {
    $data = $form->getData(1, 1);
    $sql = 'INSERT INTO `:prefix:pages_settings` ( `page_id`, `set_type`, `set_name`, `set_value` ) VALUES ( ?, ?, ?, ?)';
    $sql2 = 'DELETE FROM `:prefix:pages_settings` WHERE `page_id`=?';
    $default_freq = CAT_Registry::get('SITEMAP_UPDATE_FREQ', NULL, 'weekly');
    // delete old settings
    $database->query($sql2, array($page_id));
    // insert new settings
    foreach ($data as $key => $value) {
        // skip setting if default value is set
        if ($key == 'sitemap_priority' && $value == '0.5') {
            continue;
        }
        if ($key == 'sitemap_include' && $value == 'auto') {
            continue;
        }
        if ($key == 'sitemap_update_freq' && $value == $default_freq) {
            continue;
        }
        if ($key == 'update_sitemap') {
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 *   @author          Black Cat Development
 *   @copyright       2015, Black Cat Development
 *   @link            http://blackcat-cms.org
 *   @license         http://www.gnu.org/licenses/gpl.html
 *   @category        CAT_Core
 *   @package         seotool
 *
 */
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);
    }
}
$init = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/templates/' . CAT_Registry::get('DEFAULT_THEME') . '/forms.init.php');
if (file_exists($init)) {
    require $init;
}
$FORMS = array('seo' => array(array('type' => 'legend', 'label' => 'Basic settings'), array('type' => 'hidden', 'name' => 'page_id', 'id' => 'page_id_hidden', 'value' => 0), array('type' => 'text', 'name' => 'page_title', 'label' => 'Page title', 'title' => 'Used for the title attribute. The title should be a nice &quot;human readable&quot; text with about 30 up to 55 characters.', 'class' => 'fc_input_300 important'), array('type' => 'textarea', 'name' => 'description', 'label' => 'Description', 'title' => 'Used for the description META attribute. The description should be a nice &quot;human readable&quot; text with 70 up to 156 characters.', 'class' => 'fc_input_300 important'), array('type' => 'textarea', 'name' => 'keywords', 'label' => 'Keywords', 'title' => 'Used for the keywords META attribute. You should use about 3 (up to 5-6) keywords that occur as often as possible in your page contents.', 'class' => 'fc_input_300'), array('type' => 'text', 'label' => 'Canonical URL', 'name' => 'canonical', 'class' => 'fc_input_300', 'title' => 'A canonical link element is an HTML element that helps to prevent duplicate content issues by specifying the &quot;canonical&quot; or &quot;preferred&quot; version of a web page.'), array('type' => 'text', 'label' => '301 Redirect', 'name' => 'redirect', 'class' => 'fc_input_300'), array('type' => 'submit', 'name' => 'submit1', 'label' => 'Save'), array('type' => 'legend', 'label' => 'Sitemap settings'), array('type' => 'select', 'label' => 'Include in Sitemap', 'name' => 'sitemap_include', 'options' => array('auto' => 'Automatic detection', 'always' => 'Always include', 'never' => 'Never include'), 'selected' => 'auto', 'class' => 'fbleave'), array('type' => 'select', 'label' => 'Sitemap priority', 'name' => 'sitemap_priority', 'options' => array(1 => '1 - Highest priority', '0.9' => '0.9', '0.8' => '0.8', '0.7' => '0.7', '0.6' => '0.6', '0.5' => '0.5 - Default priority', '0.4' => '0.4', '0.3' => '0.3', '0.2' => '0.2', '0.1' => '0.1 - Lowest priority'), 'selected' => '0.5', 'class' => 'fbleave fc_input_300', 'title' => 'The priority of this URL relative to other URLs on your site. This value does not affect how your pages are compared to pages on other sites—it only lets the search engines know which pages you deem most important for the crawlers.'), array('type' => 'select', 'label' => 'Update frequency', 'name' => 'sitemap_update_freq', 'options' => array('always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'), 'selected' => 'weekly', 'class' => 'fbleave'), array('type' => 'checkbox', 'name' => 'update_sitemap', 'label' => 'Update sitemap.xml on save', 'title' => 'If checked, the sitemap.xml will be re-generated after save.'), array('type' => 'submit', 'name' => 'submit2', 'label' => 'Save'), array('type' => 'legend', 'label' => 'Robots settings'), array('type' => 'checkboxgroup', 'name' => 'robots[]', 'label' => 'META Robots', 'title' => 'Allows to set the META attributes "noindex" and "nofollow"', 'options' => array(array('value' => 'noindex', 'label' => 'no index', 'title' => 'set to "on" to set "noindex" attribute'), array('value' => 'nofollow', 'label' => 'no follow', 'title' => 'set to "on" to set "nofollow" attribute'), array('value' => 'noodp', 'label' => 'NO ODP', 'title' => 'Sometimes, if you are listed in DMOZ (ODP), the search engines will display snippets of text about your site taken from them instead of your description meta tag. You can force the search engine to ignore the ODP information by setting this to on.'), array('value' => 'noydir', 'label' => 'NO YDIR', 'title' => 'Same als ODP but information is taken from Yahoo! directory.'), array('value' => 'noarchive', 'label' => 'No Archive', 'title' => 'Prevents the search engines from showing a cached copy of this page.'), array('value' => 'nocache', 'label' => 'No Cache', 'title' => 'Same as noarchive, but only used by MSN/Live.'), array('value' => 'nosnippet', 'label' => 'No Snippet', 'title' => 'Prevents the search engines from showing a snippet of this page in the search results and prevents them from caching the page.'), array('value' => 'notranslate', 'label' => 'No translate', 'title' => 'No translation of this page in search results'), array('value' => 'noimageindex', 'label' => 'No image index', 'title' => 'Do not add images to index')), 'radio_class' => 'fc_checkbox_jq'), array('type' => 'submit', 'name' => 'submit3', 'label' => 'Save')));
Exemplo n.º 20
0
$module_permissions = $val->fromSession('MODULE_PERMISSIONS');
$bcnt = 0;
foreach ($sections as $section) {
    $module = $section['module'];
    // ====================
    // ! Have permission?
    // ====================
    if (array_search($module, $module_permissions) >= 0) {
        // ===================================================
        // ! Include the modules editing script if it exists
        // ===================================================
        if (file_exists(CAT_PATH . '/modules/' . $module . '/modify.php')) {
            // ===========================================
            // ! output block name if blocks are enabled
            // ===========================================
            if (CAT_Registry::get('SECTION_BLOCKS')) {
                $section_id = $section['section_id'];
                $tpl_data['blocks'][$bcnt]['template_blocks'] = $parser->get_template_blocks($current_template, $section['block']);
                $tpl_data['blocks'][$bcnt]['current_block_id'] = $section['block'];
                $tpl_data['blocks'][$bcnt]['current_block_name'] = $parser->get_template_block_name($current_template, $section['block']) . ' (' . $backend->lang()->translate('Block number') . ': ' . $section['block'] . ')';
                $tpl_data['blocks'][$bcnt]['section_id'] = $section['section_id'];
                $tpl_data['blocks'][$bcnt]['module'] = $section['module'];
                $tpl_data['blocks'][$bcnt]['name'] = $section['name'];
                $tpl_data['blocks'][$bcnt]['date_day_from'] = $section['publ_start'] > 0 ? date('d', $section['publ_start']) : '';
                $tpl_data['blocks'][$bcnt]['date_month_from'] = $section['publ_start'] > 0 ? date('m', $section['publ_start']) : '';
                $tpl_data['blocks'][$bcnt]['date_year_from'] = $section['publ_start'] > 0 ? date('Y', $section['publ_start']) : '';
                $tpl_data['blocks'][$bcnt]['date_hour_from'] = $section['publ_start'] > 0 ? date('H', $section['publ_start']) : '';
                $tpl_data['blocks'][$bcnt]['date_minute_from'] = $section['publ_start'] > 0 ? date('i', $section['publ_start']) : '';
                $tpl_data['blocks'][$bcnt]['date_day_to'] = $section['publ_start'] > 0 ? date('d', $section['publ_end']) : '';
                $tpl_data['blocks'][$bcnt]['date_month_to'] = $section['publ_start'] > 0 ? date('m', $section['publ_end']) : '';
                $tpl_data['blocks'][$bcnt]['date_year_to'] = $section['publ_start'] > 0 ? date('Y', $section['publ_end']) : '';
Exemplo n.º 21
0
 /**
  * retrieve allowed Mime types; we use the 'upload_allowed' entry in
  * the settings table combined with the list of known Mime types here
  *
  * @access public
  * @param  string  $filter - optional filter, for example, 'image/*'
  * @return array
  **/
 public static function getAllowedMimeTypes($filter = NULL)
 {
     if (!count(self::$allowed)) {
         $self = self::getInstance();
         if (!count(self::$mimetypes)) {
             self::getMimeTypes();
         }
         $self->log()->LogDebug('getting allowed upload mimetypes from settings');
         if (CAT_Registry::exists('UPLOAD_ALLOWED')) {
             $suffixes = explode(',', CAT_Registry::get('UPLOAD_ALLOWED'));
             $self->log()->logDebug('allowed suffixes:', $suffixes);
             for ($i = 0; $i < count($suffixes); $i++) {
                 $suffix = $suffixes[$i];
                 if (isset(self::$mimetypes[$suffix])) {
                     foreach (array_values(self::$mimetypes[$suffix]) as $type) {
                         if (!in_array($type, self::$allowed)) {
                             self::$allowed[] = $type;
                         }
                         if (!array_key_exists($suffix, self::$suffixes)) {
                             self::$suffixes[$suffix] = $type;
                         }
                     }
                 }
             }
         }
         $self->log()->LogDebug('allowed', self::$allowed);
     }
     if ($filter) {
         $self->log()->LogDebug(sprintf('using filter (preg_match) [~^%s~]', $filter), self::$allowed);
         $temp = array();
         foreach (self::$allowed as $type) {
             if (preg_match('~^' . $filter . '~', $type)) {
                 $temp[] = $type;
             }
         }
         return $temp;
     }
     return self::$allowed;
 }
Exemplo n.º 22
0
     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';
     $captcha = getCaptchaTypes($backend);
     $tpl_data = array_merge($tpl_data, $captcha);
     $tpl_data['useable_captchas'] = $useable_captchas;
     $tpl_data['ttf_image'] = CAT_URL . '/framework/CAT/Helper/Captcha/WB/captchas/ttf_image.png';
     $tpl_data['calc_image'] = CAT_URL . '/framework/CAT/Helper/Captcha/WB/captchas/calc_image.png';
Exemplo n.º 23
0
 /**
  *
  * @access private
  * @param  array   $value -> 'VERSION' => x, 'OPERATOR' => y
  * @return
  **/
 private static function checkCMSVersion($key, $value)
 {
     $check_version = $value['VERSION'];
     switch ($key) {
         case 'WB_VERSION':
             // we support WB 2.8.3
             $this_version = '2.8.3';
             break;
         case 'LEPTON_VERSION':
             // we support LEPTON 1.x
             $this_version = '1.2';
             break;
         default:
             $this_version = CAT_Registry::get('CAT_VERSION');
             break;
     }
     // obtain operator for string comparison if exist
     $operator = isset($value['OPERATOR']) && trim($value['OPERATOR']) != '' ? $value['OPERATOR'] : '>=';
     // compare versions and extract actual status
     $status = self::versionCompare($this_version, $value['VERSION'], $operator);
     $msg = array('check' => sprintf('CMS-%s: ', self::getInstance()->lang()->translate('Version')), 'required' => sprintf('%s %s', htmlentities($operator), $value['VERSION']), 'actual' => $this_version, 'status' => $status);
     return array($status, $msg);
 }
Exemplo n.º 24
0
 /**
  * Init or re-init all the processing variables to their default values
  *
  * This function is called in the constructor, and after each call of {@link process}
  *
  * @access private
  */
 function init()
 {
     // overiddable variables
     $this->file_new_name_body = null;
     // replace the name body
     $this->file_name_body_add = null;
     // append to the name body
     $this->file_name_body_pre = null;
     // prepend to the name body
     $this->file_new_name_ext = null;
     // replace the file extension
     $this->file_safe_name = true;
     // format safely the filename
     $this->file_force_extension = true;
     // forces extension if there isn't one
     $this->file_overwrite = false;
     // allows overwritting if the file already exists
     $this->file_auto_rename = true;
     // auto-rename if the file already exists
     $this->dir_auto_create = true;
     // auto-creates directory if missing
     $this->dir_auto_chmod = true;
     // auto-chmod directory if not writeable
     $this->dir_chmod = 0777;
     // default chmod to use
     $this->no_script = true;
     // turns scripts into test files
     $this->mime_check = true;
     // checks the mime type against the allowed list
     // these are the different MIME detection methods. if one of these method doesn't work on your
     // system, you can deactivate it here; just set it to false
     $this->mime_fileinfo = true;
     // MIME detection with Fileinfo PECL extension
     $this->mime_file = true;
     // MIME detection with UNIX file() command
     $this->mime_magic = false;
     // MIME detection with mime_magic (mime_content_type())
     // get the default max size from php.ini
     $this->file_max_size_raw = trim(ini_get('upload_max_filesize'));
     $this->file_max_size = $this->getsize($this->file_max_size_raw);
     $this->forbidden = array();
     $this->allowed = array();
     $this->mime_types = array();
     $this->mime_default_type = 'application/octet-stream';
     $this->mime_types = CAT_Helper_Mime::getMimeTypes();
     $this->log()->LogDebug('registered mime types', $this->mime_types);
     // allow to override default settings
     if (CAT_Registry::get('UPLOAD_ENABLE_MIMECHECK') == 'false') {
         $this->mime_check = false;
     }
     if (CAT_Registry::get('UPLOAD_MIME_DEFAULT_TYPE') == 'false') {
         $this->mime_default_type = false;
     }
     $this->allowed = CAT_Helper_Mime::getAllowedMimeTypes();
 }
Exemplo n.º 25
0
 /**
  * Create directories recursive
  *
  * @access public
  * @param string   $dir_name - directory to create
  * @param ocatal   $dir_mode - access mode
  * @return boolean result of operation
  *
  * @todo ---check for valid dir name---
  **/
 public static function createDirectory($dir_name, $dir_mode = NULL, $createIndex = false)
 {
     if (!$dir_mode) {
         $dir_mode = CAT_Registry::exists('OCTAL_DIR_MODE') ? CAT_Registry::get('OCTAL_DIR_MODE') : (int) octdec(self::defaultDirMode());
     }
     if ($dir_name != '' && !is_dir($dir_name)) {
         $umask = umask(0);
         mkdir($dir_name, $dir_mode, true);
         umask($umask);
         if ($createIndex) {
             self::recursiveCreateIndex($dir_name);
         }
         return true;
     }
     return false;
 }
Exemplo n.º 26
0
 /**
  *
  * @access public
  * @return
  **/
 public static function print404()
 {
     if (CAT_Registry::defined('ERR_PAGE') && CAT_Registry::get('ERR_PAGE') != '') {
         header('Location: ' . self::$helper->getLink(CAT_Registry::get('ERR_PAGE')));
     } else {
         header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not found');
     }
 }