protected function fetch($name, &$source, &$mtime)
 {
     debug_buffer('start global_content_get_template');
     $gCms = cmsms();
     $config = $gCms->GetConfig();
     $gcbops = $gCms->GetGlobalContentOperations();
     $oneblob = $gcbops->LoadHtmlBlobByName($name);
     if ($oneblob) {
         $text = $oneblob->content;
         $source = $text;
         $mtime = $oneblob->modified_date;
         // So no one can do anything nasty, take out the php smarty tags.  Use a user
         // defined plugin instead.
         if (!(isset($config["use_smarty_php_tags"]) && $config["use_smarty_php_tags"] == true)) {
             $source = preg_replace("/\\{\\/?php\\}/", "", $source);
         }
     } else {
         $source = "<!-- Html blob '" . $name . "' does not exist  -->";
         // put mention into the admin log
         audit('', 'Global Content Block: ' . $name, 'Can not open or does not exist!');
         $mtime = time();
     }
     debug_buffer('end global_content_get_template');
     return true;
 }
Example #2
0
/**
 * A function for auto-loading classes.
 *
 * @since 1.7
 * @param string A class name
 * @return boolean
 */
function __cms_load($filename)
{
    $gCms = cmsms();
    static $_cumulative = 0;
    $mem = memory_get_usage();
    require_once $filename;
    $mem = memory_get_usage() - $mem;
    $_cumulative += $mem;
    debug_buffer("Loading {$filename} = {$mem} bytes for an approximate total of {$_cumulative}");
}
 protected function fetch($name, &$source, &$mtime)
 {
     debug_buffer('', 'CMSModuleDbTemplateResource start' . $name);
     $db = cmsms()->GetDb();
     $tmp = explode(';', $name);
     $query = "SELECT * from " . cms_db_prefix() . "module_templates WHERE module_name = ? and template_name = ?";
     $row = $db->GetRow($query, preg_split('/;/', $name));
     if ($row) {
         $source = $row['content'];
         $mtime = $db->UnixTimeStamp($row['modified_date']);
     }
     debug_buffer('', 'CMSModuleDbTemplateResource end' . $name);
 }
Example #4
0
echo lang('login_info_params');
?>
<span>( <?php 
echo $_SERVER['HTTP_HOST'];
?>
 )</span>
</div>
</div>
<div class="login">
<div class="top"><?php 
echo lang('logintitle');
?>
</div>
		<div id="centerLogin" class="formcontainer">
				<?php 
debug_buffer('Debug in the page is: ' . $error);
if (isset($error) && $error != '') {
    echo '<div class="erroLogin">' . $error . '</div>';
} else {
    if (isset($warningLogin) && $warningLogin != '') {
        echo '<div class="warningLogin">' . $warningLogin . '</div>';
    } else {
        if (isset($acceptLogin) && $acceptLogin != '') {
            echo '<div class="acceptLogin">' . $acceptLogin . '</div>';
        }
    }
}
?>
					<?php 
if ($changepwhash != '') {
    echo '<div class="warningLogin">' . lang('passwordchange') . '</div>';
Example #5
0
$config = $gCms->GetConfig();
$userid = get_userid();
if (isset($USE_THEME) && $USE_THEME == false) {
    //echo '<!-- admin theme disabled -->';
} else {
    debug_buffer('before theme load');
    $themeObject = cms_utils::get_theme_object();
    debug_buffer('after theme load');
    if (isset($headtext) && $headtext != '') {
        $themeObject->set_value('headertext', $headtext);
    }
    // Display notification stuff from modules
    // should be controlled by preferences or something
    $ignoredmodules = explode(',', get_preference($userid, 'ignoredmodules'));
    if (get_site_preference('enablenotifications', 1) && get_preference($userid, 'enablenotifications', 1)) {
        debug_buffer('before notifications');
        if ($data = get_site_preference('__NOTIFICATIONS__')) {
            $data = unserialize($data);
            if (is_array($data) && count($data)) {
                foreach ($data as $item) {
                    $old = $item->html;
                    $regex = '/' . CMS_SECURE_PARAM_NAME . '\\=[0-9a-z]{8}/';
                    $to = CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY];
                    $new = preg_replace($regex, $to, $old);
                    $themeObject->AddNotification($item->priority, $item->name, $item->html);
                }
            }
        }
        // if the install directory still existsx
        // add a priority 1 dashboard item
        if (file_exists(dirname(dirname(__FILE__)) . '/install')) {
 /**
  * PopulateAdminNavigation
  * This method populates a big array containing the Navigation Taxonomy
  * for the admin section. This array is then used to create menus and
  * section main pages. It uses aggregate permissions to hide sections for which
  * the user doesn't have permissions, and highlights the current section so
  * menus can show the user where they are.
  *
  * @param subtitle any info to add to the page title
  * @access private
  * @ignore 
  */
 private function _populate_admin_navigation($subtitle = '')
 {
     if (count($this->_menuItems) > 0) {
         // we have already created the list
         return;
     }
     $config = cmsms()->GetConfig();
     debug_buffer('before populate admin navigation');
     $this->subtitle = $subtitle;
     debug_buffer('before menu items');
     $this->_menuItems = array('main' => array('url' => 'index.php', 'parent' => -1, 'title' => 'CMS', 'description' => '', 'show_in_menu' => true), 'home' => array('url' => 'index.php', 'parent' => 'main', 'title' => $this->_FixSpaces(lang('home')), 'description' => '', 'show_in_menu' => true), 'viewsite' => array('url' => $config['root_url'] . '/index.php', 'parent' => 'main', 'title' => $this->_FixSpaces(lang('viewsite')), 'type' => 'external', 'description' => '', 'show_in_menu' => true, 'target' => '_blank'), 'logout' => array('url' => 'logout.php', 'parent' => 'main', 'title' => $this->_FixSpaces(lang('logout')), 'description' => '', 'show_in_menu' => true), 'content' => array('url' => 'index.php?section=content', 'parent' => -1, 'title' => $this->_FixSpaces(lang('content')), 'description' => lang('contentdescription'), 'show_in_menu' => $this->HasPerm('contentPerms')), 'pages' => array('url' => 'listcontent.php', 'parent' => 'content', 'title' => $this->_FixSpaces(lang('pages')), 'description' => lang('pagesdescription'), 'show_in_menu' => $this->HasPerm('pagePerms')), 'addcontent' => array('url' => 'addcontent.php', 'parent' => 'pages', 'title' => $this->_FixSpaces(lang('addcontent')), 'description' => lang('addcontent'), 'show_in_menu' => false), 'editpage' => array('url' => 'editcontent.php', 'parent' => 'pages', 'title' => $this->_FixSpaces(lang('editpage')), 'description' => lang('editpage'), 'show_in_menu' => false), 'images' => array('url' => 'imagefiles.php', 'parent' => 'content', 'title' => $this->_FixSpaces(lang('imagemanager')), 'description' => lang('imagemanagerdescription'), 'show_in_menu' => $this->HasPerm('filePerms')), 'blobs' => array('url' => 'listhtmlblobs.php', 'parent' => 'content', 'title' => $this->_FixSpaces(lang('htmlblobs')), 'description' => lang('htmlblobdescription'), 'show_in_menu' => $this->HasPerm('htmlPerms')), 'addhtmlblob' => array('url' => 'addhtmlblob.php', 'parent' => 'blobs', 'title' => $this->_FixSpaces(lang('addhtmlblob')), 'description' => lang('addhtmlblob'), 'show_in_menu' => false), 'edithtmlblob' => array('url' => 'edithtmlblob.php', 'parent' => 'blobs', 'title' => $this->_FixSpaces(lang('edithtmlblob')), 'description' => lang('edithtmlblob'), 'show_in_menu' => false), 'layout' => array('url' => 'index.php?section=layout', 'parent' => -1, 'title' => $this->_FixSpaces(lang('layout')), 'description' => lang('layoutdescription'), 'show_in_menu' => $this->HasPerm('layoutPerms')), 'template' => array('url' => 'listtemplates.php', 'parent' => 'layout', 'title' => $this->_FixSpaces(lang('templates')), 'description' => lang('templatesdescription'), 'show_in_menu' => $this->HasPerm('templatePerms')), 'addtemplate' => array('url' => 'addtemplate.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('addtemplate')), 'description' => lang('addtemplate'), 'show_in_menu' => false), 'edittemplate' => array('url' => 'edittemplate.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('edittemplate')), 'description' => lang('edittemplate'), 'show_in_menu' => false), 'currentassociations' => array('url' => 'listcssassoc.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('currentassociations')), 'description' => lang('currentassociations'), 'show_in_menu' => false), 'copytemplate' => array('url' => 'copyemplate.php', 'parent' => 'template', 'title' => $this->_FixSpaces(lang('copytemplate')), 'description' => lang('copytemplate'), 'show_in_menu' => false), 'stylesheets' => array('url' => 'listcss.php', 'parent' => 'layout', 'title' => $this->_FixSpaces(lang('stylesheets')), 'description' => lang('stylesheetsdescription'), 'show_in_menu' => $this->HasPerm('cssPerms') || $this->HasPerm('cssAssocPerms')), 'addcss' => array('url' => 'addcss.php', 'parent' => 'stylesheets', 'title' => $this->_FixSpaces(lang('addstylesheet')), 'description' => lang('addstylesheet'), 'show_in_menu' => false), 'editcss' => array('url' => 'editcss.php', 'parent' => 'stylesheets', 'title' => $this->_FixSpaces(lang('editcss')), 'description' => lang('editcss'), 'show_in_menu' => false), 'templatecss' => array('url' => 'templatecss.php', 'parent' => 'stylesheets', 'title' => $this->_FixSpaces(lang('templatecss')), 'description' => lang('templatecss'), 'show_in_menu' => false), 'usersgroups' => array('url' => 'index.php?section=usersgroups', 'parent' => -1, 'title' => $this->_FixSpaces(lang('usersgroups')), 'description' => lang('usersgroupsdescription'), 'show_in_menu' => $this->HasPerm('usersGroupsPerms')), 'users' => array('url' => 'listusers.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('users')), 'description' => lang('usersdescription'), 'show_in_menu' => $this->HasPerm('userPerms')), 'adduser' => array('url' => 'adduser.php', 'parent' => 'users', 'title' => $this->_FixSpaces(lang('adduser')), 'description' => lang('adduser'), 'show_in_menu' => false), 'edituser' => array('url' => 'edituser.php', 'parent' => 'users', 'title' => $this->_FixSpaces(lang('edituser')), 'description' => lang('edituser'), 'show_in_menu' => false), 'groups' => array('url' => 'listgroups.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('groups')), 'description' => lang('groupsdescription'), 'show_in_menu' => $this->HasPerm('groupPerms')), 'addgroup' => array('url' => 'addgroup.php', 'parent' => 'groups', 'title' => $this->_FixSpaces(lang('addgroup')), 'description' => lang('addgroup'), 'show_in_menu' => false), 'editgroup' => array('url' => 'editgroup.php', 'parent' => 'groups', 'title' => $this->_FixSpaces(lang('editgroup')), 'description' => lang('editgroup'), 'show_in_menu' => false), 'groupmembers' => array('url' => 'changegroupassign.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('groupassignments')), 'description' => lang('groupassignmentdescription'), 'show_in_menu' => $this->HasPerm('groupMemberPerms')), 'groupperms' => array('url' => 'changegroupperm.php', 'parent' => 'usersgroups', 'title' => $this->_FixSpaces(lang('groupperms')), 'description' => lang('grouppermsdescription'), 'show_in_menu' => $this->HasPerm('groupPermPerms')), 'extensions' => array('url' => 'index.php?section=extensions', 'parent' => -1, 'title' => $this->_FixSpaces(lang('extensions')), 'description' => lang('extensionsdescription'), 'show_in_menu' => $this->HasPerm('extensionsPerms')), 'modules' => array('url' => 'listmodules.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('modules')), 'description' => lang('moduledescription'), 'show_in_menu' => $this->HasPerm('modulePerms')), 'tags' => array('url' => 'listtags.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('tags')), 'description' => lang('tagdescription'), 'show_in_menu' => $this->HasPerm('taghelpPerms')), 'usertags' => array('url' => 'listusertags.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('usertags')), 'description' => lang('usertagdescription'), 'show_in_menu' => $this->HasPerm('codeBlockPerms')), 'eventhandlers' => array('url' => 'eventhandlers.php', 'parent' => 'extensions', 'title' => $this->_FixSpaces(lang('eventhandlers')), 'description' => lang('eventhandlerdescription'), 'show_in_menu' => $this->HasPerm('eventPerms')), 'editeventhandler' => array('url' => 'editevent.php', 'parent' => 'eventhandlers', 'title' => $this->_FixSpaces(lang('editeventhandler')), 'description' => lang('editeventshandler'), 'show_in_menu' => false), 'addusertag' => array('url' => 'adduserplugin.php', 'parent' => 'usertags', 'title' => $this->_FixSpaces(lang('addusertag')), 'description' => lang('addusertag'), 'show_in_menu' => false), 'editusertag' => array('url' => 'edituserplugin.php', 'parent' => 'usertags', 'title' => $this->_FixSpaces(lang('editusertag')), 'description' => lang('editusertag'), 'show_in_menu' => false), 'siteadmin' => array('url' => 'index.php?section=siteadmin', 'parent' => -1, 'title' => $this->_FixSpaces(lang('admin')), 'description' => lang('admindescription'), 'show_in_menu' => $this->HasPerm('siteAdminPerms')), 'siteprefs' => array('url' => 'siteprefs.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('globalconfig')), 'description' => lang('preferencesdescription'), 'show_in_menu' => $this->HasPerm('sitePrefPerms')), 'pagedefaults' => array('url' => 'pagedefaults.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('pagedefaults')), 'description' => lang('pagedefaultsdescription'), 'show_in_menu' => $this->HasPerm('sitePrefPerms')), 'systeminfo' => array('url' => 'systeminfo.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('systeminfo')), 'description' => lang('systeminfodescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'systemmaintenance' => array('url' => 'systemmaintenance.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('systemmaintenance')), 'description' => lang('systemmaintenancedescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'checksum' => array('url' => 'checksum.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('system_verification')), 'description' => lang('checksumdescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'adminlog' => array('url' => 'adminlog.php', 'parent' => 'siteadmin', 'title' => $this->_FixSpaces(lang('adminlog')), 'description' => lang('adminlogdescription'), 'show_in_menu' => $this->HasPerm('adminPerms')), 'myprefs' => array('url' => 'index.php?section=myprefs', 'parent' => -1, 'title' => $this->_FixSpaces(lang('myprefs')), 'description' => lang('myprefsdescription'), 'show_in_menu' => true), 'myaccount' => array('url' => 'myaccount.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('myaccount')), 'description' => lang('myaccountdescription'), 'show_in_menu' => true), 'managebookmarks' => array('url' => 'listbookmarks.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('managebookmarks')), 'description' => lang('managebookmarksdescription'), 'show_in_menu' => true), 'addbookmark' => array('url' => 'addbookmark.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('addbookmark')), 'description' => lang('addbookmark'), 'show_in_menu' => false), 'editbookmark' => array('url' => 'editbookmark.php', 'parent' => 'myprefs', 'title' => $this->_FixSpaces(lang('editbookmark')), 'description' => lang('editbookmark'), 'show_in_menu' => false));
     debug_buffer('after menu items');
     // slightly cleaner syntax
     $this->_menuItems['ecommerce'] = array('url' => 'index.php?section=ecommerce', 'parent' => -1, 'title' => $this->_FixSpaces(lang('ecommerce')), 'description' => lang('ecommerce_desc'), 'show_in_menu' => true);
     // adjust all the urls to include the session key
     // and set an icon if we can.
     foreach ($this->_menuItems as $sectionKey => $sectionArray) {
         if (isset($sectionArray['url']) && (!isset($sectionArray['type']) || $sectionArray['type'] != 'external')) {
             $url = $this->_menuItems[$sectionKey]['url'];
             if (strpos($url, '?') !== FALSE) {
                 $url .= '&amp;';
             } else {
                 $url .= '?';
             }
             $url .= CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY];
             $this->_menuItems[$sectionKey]['url'] = $url;
         }
     }
     debug_buffer('before syste modules');
     // add in all of the 'system' modules too
     $gCms = cmsms();
     foreach ($this->_menuItems as $sectionKey => $sectionArray) {
         $tmpArray = $this->_MenuListSectionModules($sectionKey);
         $first = true;
         foreach ($tmpArray as $thisKey => $thisVal) {
             $thisModuleKey = $thisKey;
             $counter = 0;
             // don't clobber existing keys
             if (array_key_exists($thisModuleKey, $this->_menuItems)) {
                 while (array_key_exists($thisModuleKey, $this->_menuItems)) {
                     $thisModuleKey = $thisKey . $counter;
                     $counter++;
                 }
             }
             // if it's a system module...
             if (ModuleOperations::get_instance()->IsSystemModule($thisModuleKey)) {
                 $this->_menuItems[$thisModuleKey] = array('url' => $thisVal['url'], 'parent' => $sectionKey, 'title' => $this->_FixSpaces($thisVal['name']), 'description' => $thisVal['description'], 'show_in_menu' => true);
             }
         }
     }
     debug_buffer('before module menu items');
     // add in all of the modules
     foreach ($this->_menuItems as $sectionKey => $sectionArray) {
         $tmpArray = $this->_MenuListSectionModules($sectionKey);
         $first = true;
         foreach ($tmpArray as $thisKey => $thisVal) {
             $thisModuleKey = $thisKey;
             $counter = 0;
             // don't clobber existing keys
             if (array_key_exists($thisModuleKey, $this->_menuItems)) {
                 while (array_key_exists($thisModuleKey, $this->_menuItems)) {
                     $thisModuleKey = $thisKey . $counter;
                     $counter++;
                 }
                 if ($counter > 0) {
                     continue;
                 }
             }
             $this->_menuItems[$thisModuleKey] = array('url' => $thisVal['url'], 'parent' => $sectionKey, 'title' => $this->_FixSpaces($thisVal['name']), 'description' => $thisVal['description'], 'show_in_menu' => true);
             if ($first) {
                 $this->_menuItems[$thisModuleKey]['firstmodule'] = 1;
                 $first = false;
             } else {
                 $this->_menuItems[$thisModuleKey]['module'] = 1;
             }
         }
     }
     debug_buffer('after module menu items');
     // remove any top level items that don't have children
     $parents = array();
     foreach ($this->_menuItems as $sectionKey => $sectionArray) {
         if ($this->_menuItems[$sectionKey]['parent'] == -1) {
             $parents[] = $sectionKey;
         }
     }
     foreach ($parents as $oneparent) {
         $found = 0;
         foreach ($this->_menuItems as $sectionKey => $sectionArray) {
             if ($sectionArray['parent'] == $oneparent) {
                 $found = 1;
                 break;
             }
         }
         if (!$found) {
             unset($this->_menuItems[$oneparent]);
         }
     }
     // resolve the tree to be doubly-linked,
     // and make sure the selections are selected
     foreach ($this->_menuItems as $sectionKey => $sectionArray) {
         // link the children to the parents; a little clumsy since we can't
         // assume php5-style references in a foreach.
         $this->_menuItems[$sectionKey]['children'] = array();
         foreach ($this->_menuItems as $subsectionKey => $subsectionArray) {
             if ($subsectionArray['parent'] == $sectionKey) {
                 $this->_menuItems[$sectionKey]['children'][] = $subsectionKey;
             }
         }
         // set selected
         if ($this->_script == 'moduleinterface.php') {
             $a = preg_match('/(module|mact)=([^&,]+)/', $this->_query, $matches);
             if ($a > 0 && $matches[2] == $sectionKey) {
                 $this->_menuItems[$sectionKey]['selected'] = true;
                 $this->title .= $sectionArray['title'];
                 if ($sectionArray['parent'] != -1) {
                     $parent = $sectionArray['parent'];
                     while ($parent != -1) {
                         $this->_menuItems[$parent]['selected'] = true;
                         $parent = $this->_menuItems[$parent]['parent'];
                     }
                 }
             } else {
                 $this->_menuItems[$sectionKey]['selected'] = false;
             }
         } else {
             if (strstr($_SERVER['REQUEST_URI'], $sectionArray['url']) !== FALSE && (!isset($sectionArray['type']) || $sectionArray['type'] != 'external')) {
                 $this->_menuItems[$sectionKey]['selected'] = true;
                 $this->title .= $sectionArray['title'];
                 if ($sectionArray['parent'] != -1) {
                     $parent = $sectionArray['parent'];
                     while ($parent != -1) {
                         $this->_menuItems[$parent]['selected'] = true;
                         $parent = $this->_menuItems[$parent]['parent'];
                     }
                 }
             } else {
                 $this->_menuItems[$sectionKey]['selected'] = false;
             }
         }
     }
     // fix subtitle, if any
     if ($subtitle != '') {
         $this->title .= ': ' . $subtitle;
     }
     // generate breadcrumb array
     $count = 0;
     foreach ($this->_menuItems as $key => $menuItem) {
         if ($menuItem['selected']) {
             $this->_breadcrumbs[] = array('title' => $menuItem['title'], 'url' => $menuItem['url']);
             $this->title = $menuItem['title'];
             $count++;
         }
     }
     if ($count > 0) {
         // and fix up the last breadcrumb...
         if ($this->_query != '' && strpos($this->_breadcrumbs[$count - 1]['url'], '&amp;') === false) {
             $this->_query = preg_replace('/\\&/', '&amp;', $this->_query);
             $pos = strpos($this->_breadcrumbs[$count - 1]['url'], '?');
             $tmp = substr($this->_breadcrumbs[$count - 1]['url'], 0, $pos) . '?' . $this->_query;
             $this->_breadcrumbs[$count - 1]['url'] = $tmp;
         }
         unset($this->_breadcrumbs[$count - 1]['url']);
         if ($this->subtitle != '') {
             $this->_breadcrumbs[$count - 1]['title'] .= ': ' . $this->subtitle;
         }
     }
     debug_buffer('after populate admin navigation');
 }
Example #7
0
     echo '<p class="pageback"><a class="pageback" href="' . $thisurl . '">&#171; ' . lang('back') . '</a></p>';
 } else {
     if ($action == 'missingdeps') {
         echo '<div class="pagecontainer">';
         echo '<p class="pageheader">' . lang('depsformodule', array($module)) . '</p>';
         echo '<table cellspacing="0" class="AdminTable">';
         echo '<thead>';
         echo '<tr><th>' . lang('name') . '</th><th>' . lang('minimumversion') . '</th><th>' . lang('installed') . '</th></tr>';
         echo '</thead>';
         echo '<tbody>';
         if (isset($gCms->modules[$module])) {
             $modinstance = $gCms->modules[$module]['object'];
             if (count($modinstance->GetDependencies()) > 0) {
                 $curclass = 'row1';
                 #Now check to see if we can satisfy any deps
                 debug_buffer($modinstance->GetDependencies(), 'deps in module');
                 foreach ($modinstance->GetDependencies() as $onedepkey => $onedepvalue) {
                     echo '<tr class="' . $curclass . '"><td>' . $onedepkey . '</td><td>' . $onedepvalue . '</td><td>';
                     $havedep = false;
                     if (isset($gCms->modules[$onedepkey]) && $gCms->modules[$onedepkey]['installed'] == true && $gCms->modules[$onedepkey]['active'] == true && version_compare($gCms->modules[$onedepkey]['object']->GetVersion(), $onedepvalue) > -1) {
                         $havedep = true;
                     }
                     echo lang($havedep ? 'true' : 'false');
                     echo '</td></tr>';
                     $curclass == "row1" ? $curclass = "row2" : ($curclass = "row1");
                 }
             }
         }
         echo '</tbody>';
         echo '</table>';
         echo '</div>';
Example #8
0
}
$action = "";
if (isset($_GET["action"])) {
    $action = cms_htmlentities($_GET["action"]);
}
$userid = get_userid();
$access = check_permission($userid, "View Tag Help");
//if( !$access ) return;
if (!$access) {
    die('Permission Denied');
    return;
}
#$smarty = new Smarty_CMS($gCms->config);
debug_buffer('before header');
include_once "header.php";
debug_buffer('after header');
if ($action == "showpluginhelp") {
    if (function_exists('smarty_cms_help_function_' . $plugin)) {
        echo '<div class="pagecontainer">';
        // Display the title along with a wiki help link
        $header = '<div class="pageheader">';
        $header .= lang('pluginhelp', array($plugin));
        $wikiUrl = $config['wiki_url'];
        $module_name = $plugin;
        // Turn ModuleName into _Module_Name
        $moduleName = preg_replace('/([A-Z])/', "_\$1", $module_name);
        $moduleName = preg_replace('/_([A-Z])_/', "\$1", $moduleName);
        if ($moduleName[0] == '_') {
            $moduleName = substr($moduleName, 1);
        }
        $wikiUrl .= '/Tags/' . $moduleName;
Example #9
0
                    $this->FillNode($content, $onenode, $nodelist, $gCms, $count, $prevdepth, $prevdepth);
                    $this->GetChildNodes($onenode, $nodelist, $gCms, $prevdepth, $count, $params, $origdepth, $showparents, $deep);
                }
            }
        } else {
            $this->GetChildNodes($rootnode, $nodelist, $gCms, $prevdepth, $count, $params, $origdepth, $showparents, $deep);
        }
    }
    if (count($nodelist) > 0) {
        $smarty =& $this->smarty;
        $smarty->assign('menuparams', $params);
        $smarty->assign('count', count($nodelist));
        $smarty->assign_by_ref('nodelist', $nodelist);
        if ($usefile) {
            echo $this->ProcessTemplate($tpl_name, $mdid, false, $gCms->variables['content_id']);
        } else {
            echo $this->ProcessTemplateFromDatabase($tpl_name, $mdid, false);
        }
    }
}
/*
else
{
	if ($usefile)
		echo $this->ProcessTemplate($tpl_name, $mdid, true, $gCms->variables['content_id']);
	else
		echo $this->ProcessTemplateFromDatabase($tpl_name, $mdid, true, $gCms->variables['content_id']);
}
*/
debug_buffer('', 'End of Menu Manager Display');
Example #10
0
 function &getNodeByID($id)
 {
     $result = null;
     if ($id) {
         debug_buffer('start findNodeByTag');
         $ref = null;
         $result =& $this->findNodeByTag($id, $ref);
         debug_buffer('end findNodeByTag');
     }
     return $result;
 }
 /**
  * Returns an array of all content objects in the system, active or not.
  *
  * @param boolean $loadprops Not implemented
  * @return array The array of content objects
  */
 function &GetAllContent($loadprops = true)
 {
     debug_buffer('get all content...');
     global $gCms;
     $contentcache = array();
     $db =& $gCms->GetDb();
     $query = "SELECT * FROM " . cms_db_prefix() . "content ORDER BY hierarchy";
     $dbresult =& $db->Execute($query);
     $map = array();
     $count = 0;
     while ($dbresult && !$dbresult->EOF) {
         #Make sure the type exists.  If so, instantiate and load
         if (in_array($dbresult->fields['type'], array_keys(ContentOperations::ListContentTypes()))) {
             $contentobj =& ContentOperations::CreateNewContent($dbresult->fields['type']);
             if (isset($contentobj)) {
                 $tmp = $dbresult->FetchRow();
                 $contentobj->LoadFromData($tmp, false);
                 $map[$contentobj->Id()] = $count;
                 $contentcache[] = $contentobj;
                 $count++;
             } else {
                 $dbresult->MoveNext();
             }
         } else {
             $dbresult->MoveNext();
         }
     }
     if ($dbresult) {
         $dbresult->Close();
     }
     for ($i = 0; $i < $count; $i++) {
         if ($contentcache[$i]->ParentId() != -1 && isset($map[$contentcache[$i]->ParentId()])) {
             $contentcache[$map[$contentcache[$i]->ParentId()]]->mChildCount++;
         }
     }
     return $contentcache;
 }
/**
 * Checks to see if the user is logged in.   If not, redirects the browser
 * to the admin login.
 *
 * @since 0.1
 * @param string no_redirect - If true, then don't redirect if not logged in
 * @return boolean
 */
function check_login($no_redirect = false)
{
    $config = cmsms()->GetConfig();
    //Handle a current login if one is in queue in the SESSION
    if (isset($_SESSION['login_user_id'])) {
        debug_buffer("Found login_user_id.  Going to generate the user object.");
        generate_user_object($_SESSION['login_user_id']);
        unset($_SESSION['login_user_id']);
    }
    if (isset($_SESSION['login_cms_language'])) {
        debug_buffer('Setting language to: ' . $_SESSION['login_cms_language']);
        cms_cookies::set('cms_language', $_SESSION['login_cms_language']);
        unset($_SESSION['login_cms_language']);
    }
    if (!isset($_SESSION["cms_admin_user_id"])) {
        debug_buffer('No session found.  Now check for cookies');
        if (isset($_COOKIE["cms_admin_user_id"]) && isset($_COOKIE["cms_passhash"])) {
            debug_buffer('Cookies found, do a passhash check');
            if (check_passhash($_COOKIE["cms_admin_user_id"], $_COOKIE["cms_passhash"])) {
                debug_buffer('passhash check succeeded...  creating session object');
                generate_user_object($_COOKIE["cms_admin_user_id"]);
            } else {
                debug_buffer('passhash check failed...  redirect to login');
                $_SESSION["redirect_url"] = $_SERVER["REQUEST_URI"];
                if (false == $no_redirect) {
                    redirect($config['admin_url'] . "/login.php");
                }
                return false;
            }
        } else {
            debug_buffer('No cookies found.  Redirect to login.');
            $_SESSION["redirect_url"] = $_SERVER["REQUEST_URI"];
            if (false == $no_redirect) {
                redirect($config['admin_url'] . "/login.php");
            }
            return false;
        }
    }
    debug_buffer('Session found.  Moving on...');
    global $CMS_ADMIN_PAGE;
    if ($config['debug'] === false && isset($CMS_ADMIN_PAGE)) {
        if (!isset($_SESSION[CMS_USER_KEY])) {
            // it's not in the session, try to grab something from cookies
            if (isset($_COOKIE[CMS_SECURE_PARAM_NAME])) {
                $_SESSION[CMS_USER_KEY] = $_COOKIE[CMS_SECURE_PARAM_NAME];
            }
        }
        // now we've got to check the request
        // and make sure it matches the session key
        if (!isset($_SESSION[CMS_USER_KEY]) || !isset($_GET[CMS_SECURE_PARAM_NAME]) || !isset($_POST[CMS_SECURE_PARAM_NAME])) {
            $v = '<no$!tgonna!$happen>';
            if (isset($_GET[CMS_SECURE_PARAM_NAME])) {
                $v = $_GET[CMS_SECURE_PARAM_NAME];
            } else {
                if (isset($_POST[CMS_SECURE_PARAM_NAME])) {
                    $v = $_POST[CMS_SECURE_PARAM_NAME];
                }
            }
            if ($v != $_SESSION[CMS_USER_KEY] && !isset($config['stupidly_ignore_xss_vulnerability'])) {
                debug_buffer('Session key mismatch problem... redirect to login');
                if (false == $no_redirect) {
                    redirect($config['admin_url'] . '/login.php');
                }
                return false;
            }
        }
    }
    return true;
}
 /** 
  *  A method to return the timestamp of a global content block.
  *
  *  @access private
  *  @param  string The name of the global content block.
  *  @param  int    (returned) The file timestamp
  *  @param  object The smarty object
  *  @return boolean
  */
 function global_content_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
 {
     debug_buffer('start global_content_get_timestamp');
     $gCms = cmsms();
     $gcbops = $gCms->GetGlobalContentOperations();
     $oneblob = $gcbops->LoadHtmlBlobByName($tpl_name);
     if ($oneblob) {
         $tpl_timestamp = $oneblob->modified_date;
         debug_buffer('end global_content_get_timestamp');
         return true;
     } else {
         return false;
     }
 }
Example #14
0
}
$separator = $gCms->GetContentOperations()->CreateNewContent('separator');
$separator->SetName('&raquo;');
$separator->SetMenuText('&raquo;');
$pagestack = array_reverse($pagestack);
$newstack = array();
$prevdepth = 1;
$curNode = null;
for ($i = 0; $i < count($pagestack) - 1; $i++) {
    $newstack[] = $pagestack[$i];
    $newstack[count($newstack) - 1]->depth = 1;
    $newstack[count($newstack) - 1]->prevdepth = 1;
    $this->FillNode($separator, $curNode, $newstack, $gCms, $count, $prevdepth, 1, $deep, $params);
}
$newstack[] = $pagestack[count($pagestack) - 1];
$newstack[count($newstack) - 1]->depth = 1;
$newstack[count($newstack) - 1]->prevdepth = 1;
unset($pagestack);
// and get ready to display.
$smarty->assign('starttext', $this->Lang('youarehere'));
$smarty->assign('menuparams', $params);
$smarty->assign('count', count($newstack));
$smarty->assign('nodelist', $newstack);
if ($usefile) {
    $txt = $this->ProcessTemplate($tpl_name, '', false, $gCms->variables['content_id']);
} else {
    $txt = $this->ProcessTemplateFromDatabase($tpl_name, '', false);
}
echo $txt;
debug_buffer('', 'End of BreadCrumbs Display');
 private function _load_module($module_name, $force_load = FALSE)
 {
     $config = cmsms()->GetConfig();
     $dir = $config['root_path'] . '/modules';
     $info = $this->_get_module_info();
     if (!isset($info[$module_name]) && !$force_load) {
         debug_buffer("Nothing is known about {$module_name}... cant load it");
         return FALSE;
     }
     if ((!isset($info[$module_name]['active']) || $info[$module_name]['active'] == 0) && !$force_load) {
         debug_buffer('Requested deactivated module ' . $module_name);
         return FALSE;
     }
     global $CMS_INSTALL_PAGE;
     global $CMS_VERSION;
     global $CMS_PREVENT_AUTOINSTALL;
     global $CMS_FORCE_MODULE_LOAD;
     $allow_auto = isset($CMS_PREVENT_AUTOINSTALL) && $CMS_PREVENT_AUTOINSTALL ? 0 : 1;
     $gCms = cmsms();
     // backwards compatibility... set the global.
     if (!class_exists($module_name)) {
         $fname = $dir . "/{$module_name}/{$module_name}.module.php";
         if (!is_file($fname)) {
             debug_buffer("Cannot load {$module_name} because the module file does not exist");
             return FALSE;
         }
         require_once $fname;
     }
     $obj = new $module_name();
     if (!is_object($obj)) {
         // oops, some problem loading.
         debug_buffer("Cannot load {$module_name} ... some problem instantiating the class");
         return FALSE;
     }
     if (version_compare($obj->MinimumCMSVersion(), $CMS_VERSION) == 1) {
         // oops, not compatible.... can't load.
         debug_buffer("Cannot load {$module_name}... It is not compatible with this version of CMSMS");
         unset($obj);
         return FALSE;
     }
     // okay, lessee if we can load the dependants
     if (!isset($config['modules_noloaddependants'])) {
         $deps = $obj->GetDependencies();
         if (is_array($deps) && count($deps)) {
             $res = true;
             foreach ($deps as $name => $ver) {
                 $obj2 = $this->get_module_instance($name);
                 if (!is_object($obj2)) {
                     $res = false;
                     break;
                 }
             }
             if (!$res && !isset($CMS_FORCE_MODULE_LOAD)) {
                 debug_buffer("Cannot load {$module_name}... cannot load it's dependants.");
                 unset($obj);
                 return FALSE;
             }
         }
     }
     if (isset($info[$module_name]) && $info[$module_name]['status'] != 'installed' && (isset($CMS_INSTALL_PAGE) || $this->_is_queued_for_install($module_name))) {
         // not installed, can we auto-install it?
         if ((in_array($module_name, $this->cmssystemmodules) || $obj->AllowAutoInstall() == true || $this->_is_queued_for_install($module_name)) && $allow_auto) {
             $res = $this->_install_module($obj);
             if (!isset($_SESSION['moduleoperations_result'])) {
                 $_SESSION['moduleoperations_result'] = array();
             }
             $_SESSION['moduleoperations_result'][$module_name] = $res;
         } else {
             if (!isset($CMS_FORCE_MODULE_LOAD)) {
                 // nope, can't auto install...
                 unset($obj);
                 return FALSE;
             }
         }
     }
     // check to see if an upgrade is needed.
     allow_admin_lang(TRUE);
     // isn't this ugly.
     if (isset($info[$module_name]) && $info[$module_name]['status'] == 'installed') {
         $dbversion = $info[$module_name]['version'];
         if (version_compare($dbversion, $obj->GetVersion()) == -1) {
             // upgrade is needed
             if (($obj->AllowAutoUpgrade() == TRUE || $this->_is_queued_for_install($module_name)) && $allow_auto) {
                 // we're allowed to upgrade
                 $res = $this->_upgrade_module($obj);
                 if (!isset($_SESSION['moduleoperations_result'])) {
                     $_SESSION['moduleoperations_result'] = array();
                 }
                 if ($res) {
                     return TRUE;
                     //$res2 = array(TRUE,lang('moduleupgraded'));
                 } else {
                     return FALSE;
                     //$res2 = array(FALSE,lang('moduleupgradeerror'));
                 }
                 $_SESSION['moduleoperations_result'][$module_name] = $res2;
                 if (!$res) {
                     // upgrade failed
                     allow_admin_lang(FALSE);
                     // isn't this ugly.
                     debug_buffer("Automatic upgrade of {$module_name} failed");
                     unset($obj);
                     return FALSE;
                 }
             } else {
                 if (!isset($CMS_FORCE_MODULE_LOAD)) {
                     // nope, can't auto upgrade either
                     allow_admin_lang(FALSE);
                     // isn't this ugly.
                     unset($obj);
                     return FALSE;
                 }
             }
         }
     }
     if (isset($info[$module_name]) && $info[$module_name]['status'] == 'installed' || $force_load) {
         $this->_modules[$module_name] = $obj;
         return TRUE;
     }
     return FALSE;
 }
Example #16
0
 protected function Insert()
 {
     $gCms = cmsms();
     global $debug_errors;
     $db = $gCms->GetDb();
     $config = $gCms->GetConfig();
     $result = false;
     #Figure out the item_order
     if ($this->mItemOrder < 1) {
         $query = "SELECT max(item_order) as new_order FROM " . cms_db_prefix() . "content WHERE parent_id = ?";
         $row = $db->Getrow($query, array($this->mParentId));
         if ($row) {
             if ($row['new_order'] < 1) {
                 $this->mItemOrder = 1;
             } else {
                 $this->mItemOrder = $row['new_order'] + 1;
             }
         }
     }
     $newid = $db->GenID(cms_db_prefix() . "content_seq");
     $this->mId = $newid;
     $this->mModifiedDate = $this->mCreationDate = trim($db->DBTimeStamp(time()), "'");
     $query = "INSERT INTO " . $config["db_prefix"] . "content (content_id, content_name, content_alias, type, owner_id, parent_id, template_id, item_order, hierarchy, id_hierarchy, active, default_content, show_in_menu, cachable, secure, page_url, menu_text, markup, metadata, titleattribute, accesskey, tabindex, last_modified_by, create_date, modified_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
     $dbresult = $db->Execute($query, array($newid, $this->mName, $this->mAlias, strtolower($this->mType), $this->mOwner, $this->mParentId, $this->mTemplateId, $this->mItemOrder, $this->mHierarchy, $this->mIdHierarchy, $this->mActive == true ? 1 : 0, $this->mDefaultContent == true ? 1 : 0, $this->mShowInMenu == true ? 1 : 0, $this->mCachable == true ? 1 : 0, $this->mSecure, $this->mURL, $this->mMenuText, $this->mMarkup, $this->mMetadata, $this->mTitleAttribute, $this->mAccessKey, $this->mTabIndex, $this->mLastModifiedBy, $this->mModifiedDate, $this->mCreationDate));
     if (!$dbresult) {
         die($db->sql . '<br/>' . $db->ErrorMsg());
         if ($config["debug"] == true) {
             # :TODO: Translate the error message
             $debug_errors .= "<p>Error inserting content</p>\n";
         }
     }
     if (is_array($this->_props) && count($this->_props)) {
         // :TODO: There might be some error checking there
         debug_buffer('save from ' . __LINE__);
         $this->_save_properties();
     } else {
         if (true == $config["debug"]) {
             # :TODO: Translate the error message
             $debug_errors .= "<p>Error inserting : the content has no properties</p>\n";
         }
     }
     if (isset($this->mAdditionalEditors)) {
         foreach ($this->mAdditionalEditors as $oneeditor) {
             $new_addt_id = $db->GenID(cms_db_prefix() . "additional_users_seq");
             $query = "INSERT INTO " . cms_db_prefix() . "additional_users (additional_users_id, user_id, content_id) VALUES (?,?,?)";
             $db->Execute($query, array($new_addt_id, $oneeditor, $this->Id()));
         }
     }
     if ($this->mURL != '') {
         $route = CmsRoute::new_builder($this->mURL, '__CONTENT__', $this->mId, '', TRUE);
         cms_route_manager::add_static($route);
     }
 }
Example #17
0
 /**
  * fetch method
  * NOTE: Overwrites parent
  *
  * @param mixed $template
  * @param int $cache_id
  * @param mixed $parent
  * @param boolean $display
  * @param boolean $merge_tpl_vars
  * @param boolean $no_output_filter
  * @return mixed
  */
 public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
 {
     $name = $template;
     if (startswith($name, 'string:')) {
         $name = 'string:';
     }
     debug_buffer('', 'Fetch ' . $name . ' start');
     if (is_null($cache_id) || $cache_id === '') {
         $cache_id = $this->_global_cache_id;
     } else {
         if ($cache_id[0] == '|') {
             $cache_id = $this->_global_cache_id . $cache_id;
         }
     }
     $tmp = parent::fetch($template, $cache_id, $compile_id, $parent, $display, false, $no_output_filter);
     debug_buffer('', 'Fetch ' . $name . ' end');
     return $tmp;
 }
Example #18
0
/* not needed
if( !isset($CMS_ADMIN_PAGE) && !isset($CMS_STYLESHEET) && !isset($CMS_INSTALL_PAGE) )
{
  debug_buffer('','Loading Routes');
  cmsms()->set_variable('pageinfo',new PageInfo());
  $contentops = cmsms()->GetContentOperations();
  $contentops->register_routes();
  debug_buffer('','End of Loading Routes');
}
*/
#Load all installed module code
if (!isset($CMS_INSTALL_PAGE)) {
    debug_buffer('', 'Loading Modules');
    $modops = cmsms()->GetModuleOperations();
    $modops->LoadModules(isset($LOAD_ALL_MODULES), !isset($CMS_ADMIN_PAGE));
    debug_buffer('', 'End of Loading Modules');
}
#Setup language stuff.... will auto-detect languages (Launch only to admin at this point)
if (isset($CMS_ADMIN_PAGE)) {
    CmsNlsOperations::set_language();
}
$CMS_LAZYLOAD_MODULES = 1;
// still used ??
#Do auto task stuff.
if (!isset($CMS_INSTALL_PAGE)) {
    CmsRegularTaskHandler::handle_tasks();
}
$smarty->assign('sitename', get_site_preference('sitename', 'CMSMS Site'));
function sanitize_input_array(&$value, $key)
{
    $value = preg_replace('/\\<\\/?script[^\\>]*\\>/i', '', $value);
Example #19
0
     }
 }
 closedir($handle);
 #Check to see if there is already a language in use...
 if (isset($_POST["default_cms_lang"])) {
     $current_language = $_POST["default_cms_lang"];
     if ($current_language == '') {
         setcookie("cms_language", '', time() - 3600);
     } else {
         if (isset($_POST["change_cms_lang"])) {
             setcookie("cms_language", $_POST["change_cms_lang"]);
         }
     }
 } else {
     if (isset($_SESSION['login_cms_language'])) {
         debug_buffer('Setting language to: ' . $_SESSION['login_cms_language']);
         $current_language = $_SESSION['login_cms_language'];
         setcookie('cms_language', $_SESSION['login_cms_language']);
         unset($_SESSION['login_cms_language']);
     } else {
         if (isset($_COOKIE["cms_language"])) {
             $tmp = trim(basename($_COOKIE["cms_language"]));
             $file = dirname(__FILE__) . "/lang/" . $tmp . "/admin.inc.php";
             if (!file_exists($file)) {
                 $file = dirname(__FILE__) . "/lang/ext/" . $tmp . "/admin.inc.php";
                 if (!file_exists($file)) {
                     ${$tmp} = '';
                 }
             }
             $current_language = $tmp;
         }
Example #20
0
 // if the install directory still exists
 // add a priority 1 dashboard item
 if (file_exists(dirname(dirname(__FILE__)) . '/install')) {
     $themeObject->AddNotification(1, 'Core', lang('installdirwarning'));
 }
 // Display a warning if safe mode is enabled
 if (ini_get_boolean('safe_mode') && get_site_preference('disablesafemodewarning', 0) == 0) {
     $themeObject->AddNotification(1, 'Core', lang('warning_safe_mode'));
 }
 // Display a warning sitedownwarning
 $sitedown_message = lang('sitedownwarning', TMP_CACHE_LOCATION . '/SITEDOWN');
 $sitedown_file = TMP_CACHE_LOCATION . '/SITEDOWN';
 if (file_exists($sitedown_file)) {
     $themeObject->AddNotification(1, 'Core', $sitedown_message);
 }
 debug_buffer('after notifications');
 // Display a warning if CMSMS needs upgrading
 $db =& $gCms->GetDb();
 $current_version = $CMS_SCHEMA_VERSION;
 $query = "SELECT version from " . cms_db_prefix() . "version";
 $row = $db->GetRow($query);
 if ($row) {
     $current_version = $row["version"];
 }
 $warning_upgrade = lang('warning_upgrade') . "<br />" . lang('warning_upgrade_info1', $current_version, $CMS_SCHEMA_VERSION) . "<br /> " . lang('warning_upgrade_info2', '<a href="' . $config['root_url'] . '/install/upgrade.php">' . lang('start_upgrade_process') . '</a>');
 if ($current_version < $CMS_SCHEMA_VERSION) {
     $themeObject->AddNotification(1, 'Core', $warning_upgrade);
 }
 // Display an upgrade notification
 // but only do a check once per day
 $timelastchecked = get_site_preference('lastcmsversioncheck', 0);
Example #21
0
 /**
  * Get a handle to the CMS HierarchyManager object. If it does not yet
  * exist, this method will instantiate it.
  *
  * @final
  * @see HierarchyManager
  * @return HierarchyManager handle to the HierarchyManager object
  */
 function &GetHierarchyManager()
 {
     /* Check to see if a HierarchyManager has been instantiated yet,
     	  and, if not, go ahead an create the instance. */
     if (!isset($this->hrinstance)) {
         debug_buffer('', 'Start Loading Hierarchy Manager');
         $contentops =& $this->GetContentOperations();
         $this->hrinstance =& $contentops->GetAllContentAsHierarchy(false, array());
         debug_buffer('', 'End Loading Hierarchy Manager');
     }
     return $this->hrinstance;
 }
Example #22
0
 /**
  * Return a list of modules that have the supplied method.
  *
  * This method will query all available modules, check if the method name exists for that module, and if so, call the method and trap the
  * return value.  
  *
  * @param string method name
  * @param mixed  optional return value.
  * @return array of matching module names
  */
 public function module_list_by_method($method, $returnvalue = TRUE)
 {
     if (empty($method)) {
         return;
     }
     $this->_load_cache();
     if (!isset($this->_data['methods']) || !isset($this->_data['methods'][$method])) {
         debug_buffer('start building module method cache');
         if (!isset($this->_data['methods'])) {
             $this->_data['methods'] = array();
         }
         $installed_modules = ModuleOperations::get_instance()->GetInstalledModules();
         $loaded_modules = ModuleOperations::get_instance()->GetLoadedModules();
         $this->_data['methods'][$method] = array();
         foreach ($installed_modules as $onemodule) {
             $loaded_it = FALSE;
             $object = null;
             if (isset($loaded_modules[$onemodule])) {
                 $object = $loaded_modules[$onemodule];
             } else {
                 $object = ModuleOperations::get_instance()->get_module_instance($onemodule);
                 $loaded_it = TRUE;
             }
             if (!$object) {
                 continue;
             }
             if (!method_exists($object, $method)) {
                 continue;
             }
             // now do the test
             $res = $object->{$method}();
             $this->_data['methods'][$method][$onemodule] = $res;
             // 	    if( $loaded_it )
             // 	      {
             // 			  debug_display('unload '.$onemodule);
             // 			  ModuleOperations::get_instance()->unload_module($onemodule);
             // 	      }
         }
         // store it.
         debug_buffer('done building module method cache');
         $this->_save_cache();
     }
     $res = null;
     if (is_array($this->_data['methods'][$method]) && count($this->_data['methods'][$method])) {
         $res = array();
         foreach ($this->_data['methods'][$method] as $key => $value) {
             if ($value == $returnvalue) {
                 $res[] = $key;
             }
         }
     }
     return $res;
 }
Example #23
0
 /**
  * fetch method
  * NOTE: Overwrites parent
  *
  * @param mixed $template
  * @param int $cache_id
  * @param mixed $parent
  * @param boolean $display
  * @param boolean $merge_tpl_vars
  * @param boolean $no_output_filter
  * @return mixed
  */
 public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
 {
     $name = $template;
     if (startswith($name, 'string:')) {
         $name = 'string:';
     }
     debug_buffer('', 'Fetch ' . $name . ' start');
     if (is_null($cache_id) || $cache_id === '') {
         $cache_id = $this->_global_cache_id;
     } else {
         if ($cache_id[0] == '|') {
             $cache_id = $this->_global_cache_id . $cache_id;
         }
     }
     // send an event before fetching...this allows us to change template stuff.
     if (cmsms()->is_frontend_request()) {
         $parms = array('template' => &$template, 'cache_id' => &$cache_id, 'compile_id' => &$compile_id, 'display' => &$display, 'no_output_filter' => &$no_output_filter);
         Events::SendEvent('Core', 'TemplatePreFetch', $parms);
     }
     $merge_tpl_vars = false;
     // hack
     $tmp = parent::fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter);
     debug_buffer('', 'Fetch ' . $name . ' end');
     return $tmp;
 }
Example #24
0
            audit($username, $username, 'User Login Failed');
            #Now call the event
            Events::SendEvent('Core', 'LoginPost', $username);
        } else {
            debug_buffer($_POST["loginsubmit"]);
        }
    }
}
// Language shizzle
//header("Content-Encoding: " . get_encoding());
header("Content-Language: " . $current_language);
header("Content-Type: text/html; charset=" . get_encoding());
//CHANGED
$theme = get_site_preference('logintheme', 'default');
//echo "theme:$theme";
debug_buffer('debug is:' . $error);
if (file_exists(dirname(__FILE__) . "/themes/{$theme}/login.php")) {
    include dirname(__FILE__) . "/themes/{$theme}/login.php";
} else {
    include dirname(__FILE__) . "/themes/default/login.php";
}
//STOP
?>

<?php 
if (isset($gCms->config) and $gCms->config['debug'] == true) {
    foreach ($gCms->errors as $globalerror) {
        echo $globalerror;
    }
}
# vim:ts=4 sw=4 noet
Example #25
0
function display_content_list($themeObject = null)
{
    $gCms = cmsms();
    global $thisurl;
    global $urlext;
    check_login();
    $userid = get_userid();
    // setup which columns to display.
    $mypages = author_pages($userid);
    $columnstodisplay = array();
    $columnstodisplay['expand'] = 1;
    $columnstodisplay['hier'] = 1;
    $columnstodisplay['page'] = 1;
    $columnstodisplay['alias'] = get_site_preference('listcontent_showalias', 1);
    $columnstodisplay['url'] = get_site_preference('listcontent_showurl', 1);
    $columnstodisplay['template'] = 1;
    $columnstodisplay['friendlyname'] = 1;
    $columnstodisplay['owner'] = 1;
    $columnstodisplay['active'] = check_permission($userid, 'Manage All Content');
    $columnstodisplay['default'] = check_permission($userid, 'Manage All Content');
    $columnstodisplay['move'] = check_permission($userid, 'Manage All Content') || check_permission($userid, 'Reorder Content');
    $columnstodisplay['view'] = 1;
    $columnstodisplay['copy'] = check_permission($userid, 'Add Pages') || check_permission($userid, 'Manage All Content');
    $columnstodisplay['edit'] = 1;
    $columnstodisplay['delete'] = check_permission($userid, 'Remove Pages') || check_permission($userid, 'Manage All Content');
    $columnstodisplay['multiselect'] = check_permission($userid, 'Remove Pages') || check_permission($userid, 'Manage All Content');
    $page = 1;
    if (isset($_GET['page'])) {
        $page = $_GET['page'];
    }
    //$limit = get_preference($userid, 'paging', 0);
    $limit = 0;
    //Took out pagination
    $thelist = '';
    $count = 0;
    $currow = "row1";
    if ($themeObject == null) {
        $themeObject = AdminTheme::GetThemeObject();
    }
    // construct true/false button images
    $image_true = $themeObject->DisplayImage('icons/system/true.gif', lang('true'), '', '', 'systemicon');
    $image_set_false = $themeObject->DisplayImage('icons/system/true.gif', lang('setfalse'), '', '', 'systemicon');
    $image_set_true = $themeObject->DisplayImage('icons/system/false.gif', lang('settrue'), '', '', 'systemicon');
    $expandImg = $themeObject->DisplayImage('icons/system/expand.gif', lang('expand'), '', '', 'systemicon');
    $contractImg = $themeObject->DisplayImage('icons/system/contract.gif', lang('contract'), '', '', 'systemicon');
    $downImg = $themeObject->DisplayImage('icons/system/arrow-d.gif', lang('down'), '', '', 'systemicon');
    $upImg = $themeObject->DisplayImage('icons/system/arrow-u.gif', lang('up'), '', '', 'systemicon');
    $viewImg = $themeObject->DisplayImage('icons/system/view.gif', lang('view'), '', '', 'systemicon');
    $editImg = $themeObject->DisplayImage('icons/system/edit.gif', lang('edit'), '', '', 'systemicon');
    $copyImg = $themeObject->DisplayImage('icons/system/copy.gif', lang('copy'), '', '', 'systemicon');
    $deleteImg = $themeObject->DisplayImage('icons/system/delete.gif', lang('delete'), '', '', 'systemicon');
    #Setup array so we don't load more templates than we need to
    $templateops = TemplateOperations::get_instance()->LoadTemplates();
    #Ditto with users
    $users = array();
    $menupos = array();
    $openedArray = array();
    if (get_preference($userid, 'collapse', '') != '') {
        $tmp = explode('.', get_preference($userid, 'collapse'));
        foreach ($tmp as $thisCol) {
            $colind = substr($thisCol, 0, strpos($thisCol, '='));
            if ($colind != "") {
                $openedArray[] = $colind;
            }
        }
    }
    debug_buffer('At Start of Display Content List');
    $hierarchy = $gCms->GetHierarchyManager();
    $rowcount = 0;
    if ($hierarchy->hasChildren()) {
        $pagelist = array();
        $children = $hierarchy->getChildren(false, true);
        $author_allpages = check_permission($userid, 'Reorder Content') && check_peer_authorship($userid, $children[0]->getId());
        foreach ($children as $child) {
            display_hierarchy($child, $userid, check_modify_all($userid), $users, $menupos, $openedArray, $pagelist, $image_true, $image_set_false, $image_set_true, $upImg, $downImg, $viewImg, $editImg, $copyImg, $deleteImg, $expandImg, $contractImg, $mypages, $page, $columnstodisplay, $author_allpages);
        }
        $rowcount += count($pagelist);
        foreach ($pagelist as $item) {
            $thelist .= $item;
        }
        $thelist .= '</tbody>';
        $thelist .= "</table>\n";
    }
    $headoflist = '';
    $headoflist .= '<div class="pageoverflow"><p class="pageoptions">';
    if (check_permission($userid, 'Add Pages') || check_permission($userid, 'Manage All Content')) {
        $headoflist .= '<a href="addcontent.php' . $urlext . '" class="pageoptions">';
        $headoflist .= $themeObject->DisplayImage('icons/system/newobject.gif', lang('addcontent'), '', '', 'systemicon') . '</a>';
        $headoflist .= ' <a class="pageoptions" href="addcontent.php' . $urlext . '">' . lang("addcontent") . '</a>';
    }
    $headoflist .= '<a style="margin-left: 10px;" href="' . $thisurl . '&amp;expandall=1" onclick="xajax_content_expandall(); return false;">';
    $headoflist .= $themeObject->DisplayImage('icons/system/expandall.gif', lang('expandall'), '', '', 'systemicon') . '</a>';
    $headoflist .= ' <a class="pageoptions" href="' . $thisurl . '&amp;expandall=1" onclick="xajax_content_expandall(); return false;">' . lang("expandall") . '</a>&nbsp;&nbsp;&nbsp;';
    $headoflist .= ' <a href="' . $thisurl . '&amp;collapseall=1" onclick="xajax_content_collapseall(); return false;">';
    $headoflist .= $themeObject->DisplayImage('icons/system/contractall.gif', lang('contractall'), '', '', 'systemicon') . '</a>';
    $headoflist .= ' <a class="pageoptions" href="' . $thisurl . '&amp;collapseall=1" onclick="xajax_content_collapseall(); return false;">' . lang("contractall") . '</a>';
    if (check_permission($userid, 'Manage All Content')) {
        $reorderurl = "ordercontent.php?" . CMS_SECURE_PARAM_NAME . "=" . $_SESSION[CMS_USER_KEY];
        $headoflist .= '&nbsp;&nbsp;&nbsp;<a href="' . $reorderurl . '">';
        $headoflist .= $themeObject->DisplayImage('icons/system/reorder.gif', lang('reorderpages'), '', '', 'systemicon') . '</a>';
        $headoflist .= ' <a class="pageoptions" href="' . $reorderurl . '">' . lang('reorderpages') . '</a>';
    }
    $headoflist .= '</p></div>';
    $headoflist .= '<form action="multicontent.php" method="post">';
    $headoflist .= '<div class="hidden" ><input type="hidden" name="' . CMS_SECURE_PARAM_NAME . '" value="' . $_SESSION[CMS_USER_KEY] . '"/></div>' . "\n";
    $headoflist .= '<table cellspacing="0" class="pagetable">' . "\n";
    $headoflist .= '<thead>';
    $headoflist .= "<tr>\n";
    // setup column titles.
    if ($columnstodisplay['expand']) {
        $headoflist .= "<th>&nbsp;</th>";
    }
    if ($columnstodisplay['hier']) {
        $headoflist .= "<th>&nbsp;</th>";
    }
    if ($columnstodisplay['page']) {
        $str = lang('menutext');
        if (get_site_preference('listcontent_showtitle')) {
            $str = lang('title');
        }
        $headoflist .= '<th scope="col" class="pagew25" title="' . lang('lctitle_page') . '">' . lang('page') . " <em>({$str})</em></th>\n";
    }
    if ($columnstodisplay['alias']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_alias') . '">' . lang('pagealias') . "</th>\n";
    }
    if ($columnstodisplay['url']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_url') . '">' . lang('url') . "</th>\n";
    }
    if ($columnstodisplay['template']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_template') . '">' . lang('template') . "</th>\n";
    }
    if ($columnstodisplay['friendlyname']) {
        $headoflist .= "<th scope=\"col\" >" . lang('type') . "</th>\n";
    }
    if ($columnstodisplay['owner']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_owner') . '">' . lang('owner') . "</th>\n";
    }
    if ($columnstodisplay['active']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_active') . '" class="pagepos">' . lang('active') . "</th>\n";
    }
    if ($columnstodisplay['default']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_default') . '" class="pagepos">' . lang('default') . "</th>\n";
    }
    if ($columnstodisplay['move']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_move') . '" class="move">' . lang('move') . "</th>\n";
    }
    if ($columnstodisplay['view']) {
        $headoflist .= "<th class=\"pageicon\">&nbsp;</th>\n";
    }
    if ($columnstodisplay['copy']) {
        $headoflist .= "<th class=\"pageicon\">&nbsp;</th>\n";
    }
    if ($columnstodisplay['edit']) {
        $headoflist .= "<th class=\"pageicon\">&nbsp;</th>\n";
    }
    if ($columnstodisplay['delete']) {
        $headoflist .= "<th class=\"pageicon\">&nbsp;</th>\n";
    }
    if ($columnstodisplay['multiselect']) {
        $headoflist .= '<th scope="col" title="' . lang('lctitle_multiselect') . '" class="checkbox"><input id="selectall" type="checkbox" onclick="select_all();" /><label for="selectall" class="invisible">' . lang('toggle') . '</label></th>' . "\n";
        // checkbox column
    }
    $headoflist .= "</tr>\n";
    $headoflist .= '</thead>';
    $headoflist .= '<tbody>';
    ob_start();
    $opts = array();
    if (check_permission($userid, 'Remove Pages') || check_permission($userid, 'Manage All Content')) {
        bulkcontentoperations::register_function(lang('delete'), 'delete');
    }
    if (check_permission($userid, 'Manage All Content')) {
        bulkcontentoperations::register_function(lang('active'), 'active');
        bulkcontentoperations::register_function(lang('inactive'), 'inactive');
        bulkcontentoperations::register_function(lang('cachable'), 'setcachable');
        bulkcontentoperations::register_function(lang('noncachable'), 'setnoncachable');
        bulkcontentoperations::register_function(lang('showinmenu'), 'showinmenu');
        bulkcontentoperations::register_function(lang('hidefrommenu'), 'hidefrommenu');
        bulkcontentoperations::register_function(lang('secure'), 'secure');
        bulkcontentoperations::register_function(lang('insecure'), 'insecure');
        bulkcontentoperations::register_function(lang('settemplate'), 'settemplate');
        bulkcontentoperations::register_function(lang('changeowner'), 'changeowner');
    }
    $opts = bulkcontentoperations::get_operation_list();
    if (!empty($opts)) {
        echo '<div class="pageoptions">' . "\n";
        echo '<div style="margin-top: 0; float: right; text-align: right">' . "\n";
        echo '<label for="multiaction">' . lang('selecteditems') . '</label>:&nbsp;&nbsp;';
        echo '<select name="multiaction" id="multiaction">';
        foreach ($opts as $key => $value) {
            echo '<option value="' . $key . '">' . $value . '</option>';
        }
        echo '</select>' . "\n";
        echo '<input type="submit" accesskey="s" value="' . lang('submit') . '"/></div></div>' . "\n";
    }
    /*    } */
    ?>
			<div style="float: left;">
<?php 
    if (check_permission($userid, 'Add Pages') || check_permission($userid, 'Manage All Content')) {
        ?>
			<a href="addcontent.php<?php 
        echo $urlext;
        ?>
" class="pageoptions">
<?php 
        echo $themeObject->DisplayImage('icons/system/newobject.gif', lang('addcontent'), '', '', 'systemicon') . '</a>';
        echo ' <a class="pageoptions" href="addcontent.php' . $urlext . '">' . lang("addcontent");
        ?>
			</a>
<?php 
    }
    ?>
		<a style="margin-left: 10px;" href="'.$thisurl.'&amp;expandall=1" onclick="xajax_content_expandall(); return false;">
<?php 
    echo $themeObject->DisplayImage('icons/system/expandall.gif', lang('expandall'), '', '', 'systemicon') . '</a>';
    echo ' <a class="pageoptions" href="' . $thisurl . '&amp;expandall=1" onclick="xajax_content_expandall(); return false;">' . lang("expandall");
    ?>
			</a>&nbsp;&nbsp;&nbsp;
		<a href="<?php 
    echo $thisurl;
    ?>
&amp;collapseall=1" onclick="xajax_content_collapseall(); return false;">
<?php 
    echo $themeObject->DisplayImage('icons/system/contractall.gif', lang('contractall'), '', '', 'systemicon') . '</a>';
    echo ' <a class="pageoptions" href="' . $thisurl . '&amp;collapseall=1" onclick="xajax_content_collapseall(); return false;">' . lang("contractall") . '</a>';
    if (check_permission($userid, 'Manage All Content')) {
        $image_reorder = $themeObject->DisplayImage('icons/system/reorder.gif', lang('reorderpages'), '', '', 'systemicon');
        $reorderurl = "ordercontent.php?" . CMS_SECURE_PARAM_NAME . "=" . $_SESSION[CMS_USER_KEY];
        echo '&nbsp;&nbsp;&nbsp; <a class="pageoptions" href="' . $reorderurl . '">' . $image_reorder . '</a> <a class="pageoptions" href="' . $reorderurl . '">' . lang('reorderpages') . '</a>';
    }
    ?>
			</div>

			<br />

			<div class="clearb"></div>
<?php 
    $footer = ob_get_contents();
    ob_end_clean();
    return $headoflist . $thelist . $footer . '</form></div>';
}
Example #26
0
             // this content is cachable...  so enable smarty caching of this page data, for this user.
             $smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
         }
     }
     if (!$showtemplate) {
         $smarty->setCaching(false);
         // in smarty 3, we could use eval:{content} I think.
         //$html = $smarty->fetch('eval:{content}')."\n";
         $html = $smarty->fetch('template:notemplate') . "\n";
     } else {
         //debug_display('display content '.$contentobj->Alias().' '.$page);
         debug_buffer('process template top');
         $top = $smarty->fetch('tpl_top:' . $contentobj->TemplateId());
         debug_buffer('process template body');
         $body = $smarty->fetch('tpl_body:' . $contentobj->TemplateId());
         debug_buffer('process template head');
         $head = $smarty->fetch('tpl_head:' . $contentobj->TemplateId());
         $html = $top . $head . $body;
         $trycount = 99;
         // no more iterations.
         //debug_display('display content2 '.$contentobj->Alias().' '.$page);
         //if( $page == 'error404' ) debug_display('html is '.$html);
     }
 } catch (SmartyCompilerException $e) {
     $handlers = ob_list_handlers();
     for ($cnt = 0; $cnt < sizeof($handlers); $cnt++) {
         ob_end_clean();
     }
     echo $smarty->errorConsole($e);
     return;
 } catch (SmartyException $e) {
Example #27
0
            //Change name
            $onetemplate->default = 0;
            //It can't be default
            $result = $onetemplate->Save();
            if ($result) {
                //Copy attached CSS templates as well...
                $db =& $gCms->GetDb();
                $query = "SELECT assoc_css_id, assoc_type, css_name, assoc_order FROM " . cms_db_prefix() . "css_assoc, " . cms_db_prefix() . "css WHERE assoc_to_id = " . $db->qstr($template_id) . " AND assoc_css_id = css_id";
                debug_buffer($query);
                $result2 = $db->Execute($query);
                debug_buffer($result2);
                # if any css was found.
                if ($result2) {
                    while ($row = $result2->FetchRow()) {
                        $query = "INSERT INTO " . cms_db_prefix() . "css_assoc (assoc_to_id,assoc_css_id,assoc_type,create_date,modified_date,assoc_order) VALUES ('" . $onetemplate->id . "','" . $row['assoc_css_id'] . "','" . $row['assoc_type'] . "'," . $db->DBTimeStamp(time()) . "," . $db->DBTimeStamp(time()) . ",'" . $row['assoc_order'] . "')";
                        debug_buffer($query);
                        $db->Execute($query);
                    }
                }
                audit($onetemplate->id, $onetemplate->name, 'Copied Template');
                redirect($from . '&message=' . lang('templatecopied'));
                return;
            } else {
                $error .= "<li>" . lang('errorcopyingtemplate') . "</li>";
            }
        }
    }
}
include_once "header.php";
if (!$access) {
    echo "<div class=\"pageerrorcontainer\"><p class=\"pageerror\">" . lang('noaccessto', array(lang('copytemplate'))) . "</p></div>";
Example #28
0
 /**
  * Trigger an event.
  * This function will call all registered event handlers for the event
  *
  * @param string $modulename The name of the module that is sending the event
  * @param string $eventname The name of the event
  * @param array $params The parameters associated with this event.
  * @return void
  */
 public static function SendEvent($modulename, $eventname, $params = array())
 {
     global $CMS_INSTALL_PAGE;
     if (isset($CMS_INSTALL_PAGE)) {
         return;
     }
     $gCms = cmsms();
     $results = Events::ListEventHandlers($modulename, $eventname);
     if ($results != false) {
         foreach ($results as $row) {
             if (isset($row['tag_name']) && $row['tag_name'] != '') {
                 debug_buffer('calling user tag ' . $row['tag_name'] . ' from event ' . $eventname);
                 $usertagops = $gCms->GetUserTagOperations();
                 $usertagops->CallUserTag($row['tag_name'], $params);
             } else {
                 if (isset($row['module_name']) && $row['module_name'] != '') {
                     // here's a quick check to make sure that we're not calling the module
                     // DoEvent function for an event originated by the same module.
                     if ($row['module_name'] == $modulename) {
                         continue;
                     }
                     // and call the module event handler.
                     $obj =& CMSModule::GetModuleInstance($row['module_name']);
                     if ($obj) {
                         debug_buffer('calling module ' . $row['module_name'] . ' from event ' . $eventname);
                         $obj->DoEvent($modulename, $eventname, $params);
                     }
                 }
             }
         }
     }
 }
 /**
  * Returns an array of all content objects in the system, active or not.
  *
  * @param boolean $loadprops Not implemented
  * @return array The array of content objects
  */
 function &GetAllContent($loadprops = true)
 {
     debug_buffer('get all content...');
     $gCms = cmsms();
     $tree = $gCms->GetHierarchyManager();
     $list = $tree->getFlatList();
     $output = array();
     foreach ($list as &$one) {
         $tmp = $one->GetContent(false, true, true);
         if (is_object($tmp)) {
             $output[] = $tmp;
         }
     }
     debug_buffer('end get all content...');
     return $output;
 }
Example #30
0
/**
 * A function to return the current admin language
 *
 * @internal
 * @return string
 */
function cms_admin_current_language()
{
    global $gCms;
    global $nls;
    $nls = array();
    $lang = array();
    $current_language = '';
    #Read in all current languages...
    if (!count($nls)) {
        $dir = cms_join_path($gCms->config['root_path'], $gCms->config['admin_dir'], '/lang');
        $handle = opendir($dir);
        while (false !== ($file = readdir($handle))) {
            if (is_file("{$dir}/{$file}") && strpos($file, "nls.php") != 0) {
                include "{$dir}/{$file}";
            }
        }
        closedir($handle);
    }
    #Check to see if there is already a language in use...
    if (isset($_POST["default_cms_lang"])) {
        $tmp = basename($_POST['default_cms_lang']);
        if (isset($nls['language'][$tmp]) || isset($nls['alias'][$tmp])) {
            $current_language = $tmp;
            if ($current_language == '') {
                setcookie("cms_language", '', time() - 3600);
            } else {
                if (isset($_POST["change_cms_lang"])) {
                    setcookie("cms_language", basename($_POST["change_cms_lang"]));
                }
            }
        }
    } else {
        if (isset($_SESSION['login_cms_language'])) {
            debug_buffer('Setting language to: ' . $_SESSION['login_cms_language']);
            $current_language = $_SESSION['login_cms_language'];
            setcookie('cms_language', $_SESSION['login_cms_language']);
            unset($_SESSION['login_cms_language']);
        } else {
            if (isset($_COOKIE["cms_language"])) {
                $tmp = trim(basename($_COOKIE["cms_language"]));
                $file = dirname(__FILE__) . "/lang/" . $tmp . "/admin.inc.php";
                if (!file_exists($file)) {
                    $file = dirname(__FILE__) . "/lang/ext/" . $tmp . "/admin.inc.php";
                    if (!file_exists($file)) {
                        ${$tmp} = '';
                    }
                }
                $current_language = $tmp;
            }
        }
    }
    if ($current_language == '') {
        if (isset($gCms->config['locale']) && $gCms->config['locale'] != '') {
            $current_language = $gCms->config['locale'];
        } else {
            #No, take a stab at figuring out the default language...
            #Figure out default language and set it if it exists
            if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
                $alllang = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
                if (strpos($alllang, ";") !== FALSE) {
                    $alllang = substr($alllang, 0, strpos($alllang, ";"));
                }
                $langs = explode(",", $alllang);
                foreach ($langs as $onelang) {
                    #Check to see if lang exists...
                    if (isset($nls['language'][$onelang])) {
                        $current_language = $onelang;
                        setcookie("cms_language", $onelang);
                        break;
                    }
                    #Check to see if alias exists...
                    if (isset($nls['alias'][$onelang])) {
                        $alias = $nls['alias'][$onelang];
                        if (isset($nls['language'][$alias])) {
                            $current_language = $alias;
                            setcookie("cms_language", $alias);
                            break;
                        }
                    }
                }
            }
        }
    }
    return $current_language;
}