function DisplayImage($image, $alt = '', $class = '', $width = '', $height = '')
 {
     $config = cmsms()->GetConfig();
     // check image_directories first
     if (isset($this->_module->_image_directories) && !empty($this->_module->_image_directories)) {
         foreach ($this->_module->_image_directories as $dir) {
             $url = "{$dir}/{$image}";
             $path = cms_join_path($config['root_path'], $url);
             if (is_readable($path)) {
                 if ($this->_module->IsAdminAction()) {
                     $url = "../{$url}";
                 }
                 return $this->_module->CreateImageTag($url, $alt, $width, $height, $class);
             }
         }
     }
     $theme = cmsms()->variables['admintheme'];
     if (is_object($theme)) {
         // we're in the admin
         $txt = $theme->DisplayImage($image, $alt, $width, $height, $class);
     } else {
         // frontend
         $txt = $this->CreateImageTag($image, $alt, $width, $height, $class);
     }
     return $txt;
 }
Example #2
0
/**
 * A function for auto-loading classes.
 *
 * @since 1.7
 * @param string A class name
 * @return boolean
 */
function cms_autoloader($classname)
{
    global $gCms;
    $config = $gCms->GetConfig();
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php");
    if (file_exists($fn)) {
        require_once $fn;
        return;
    }
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php");
    if (file_exists($fn)) {
        require_once $fn;
        return;
    }
    foreach ($gCms->modules as $module => &$data) {
        if (!isset($data['object'])) {
            continue;
        }
        $obj =& $data['object'];
        $fn = cms_join_path($obj->GetModulePath(), 'lib', "class.{$classname}.php");
        if (file_exists($fn)) {
            require_once $fn;
            return;
        }
        $fn = cms_join_path($obj->GetModulePath(), 'lib', "interface.{$classname}.php");
        if (file_exists($fn)) {
            require_once $fn;
            return;
        }
    }
}
Example #3
0
function cge_CGCreateInputSubmit(&$mod, $id, $name, $value = '', $addtext = '', $image = '', $confirmtext = '', $class = '')
{
    $real_image = '';
    if (!empty($image)) {
        $config = cmsms()->GetConfig();
        // check image_directories first
        if (isset($mod->_image_directories) && !empty($mod->_image_directories)) {
            foreach ($mod->_image_directories as $dir) {
                $url = cms_join_path($dir, $image);
                $path = cms_join_path($config['root_path'], $url);
                if (is_readable($path)) {
                    $real_image = $url;
                }
            }
        }
        if (empty($real_image)) {
            $theme = cmsms()->variables['admintheme'];
            if (is_object($theme)) {
                // we're in the admin
                $txt = $theme->DisplayImage($image, $alt, $width, $height, $class);
                $real_image = $theme->imageLink[$image];
            }
        }
        $addtext .= ' title="' . $value . '"';
    }
    if (!empty($class)) {
        $addtext .= ' class="' . $class . '"';
    }
    return $mod->CreateInputSubmit($id, $name, $value, $addtext, $real_image, $confirmtext);
}
Example #4
0
function cms_autoloader($classname)
{
    //if( $classname != 'Smarty_CMS' && $classname != 'Smarty_Parser' && startswith($classname,'Smarty') ) return;
    $config = cmsms()->GetConfig();
    // standard classes
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $lowercase = strtolower($classname);
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$lowercase}.inc.php");
    if (file_exists($fn) && $classname != 'Content') {
        __cms_load($fn);
        return;
    }
    // standard interfaces
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    global $CMS_LAZYLOAD_MODULES;
    global $CMS_INSTALL_PAGE;
    if (!isset($CMS_LAZYLOAD_MODULES) || isset($CMS_INSTALL_PAGE)) {
        return;
    }
    // standard content types
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', 'contenttypes', "{$classname}.inc.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    // module loaded content types
    $contentops = ContentOperations::get_instance();
    if ($contentops) {
        // why would this ever NOT be true.. dunno, but hey.
        $types = $contentops->ListContentTypes();
        if (in_array(strtolower($classname), array_keys($types))) {
            $contentops->LoadContentType(strtolower($classname));
            return;
        }
    }
    $fn = $config['root_path'] . "/modules/{$classname}/{$classname}.module.php";
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $list = ModuleOperations::get_instance()->GetLoadedModules();
    if (is_array($list) && count($list)) {
        foreach (array_keys($list) as $modname) {
            $fn = $config['root_path'] . "/modules/{$modname}/lib/class.{$classname}.php";
            if (file_exists($fn)) {
                __cms_load($fn);
                return;
            }
        }
    }
    // module classes
}
function smarty_modifier_cms_date_format($string, $format = '', $default_date = '')
{
    $gCms = cmsms();
    if ($format == '') {
        $format = get_site_preference('defaultdateformat');
        if ($format == '') {
            $format = '%b %e, %Y';
        }
        if (!isset($gCms->variables['page_id'])) {
            $uid = get_userid(false);
            if ($uid) {
                $tmp = get_preference($uid, 'date_format_string');
                if ($tmp != '') {
                    $format = $tmp;
                }
            }
        }
    }
    $config = $gCms->GetConfig();
    $fn = cms_join_path($config['root_path'], 'lib', 'smarty', 'plugins', 'modifier.date_format.php');
    if (!file_exists($fn)) {
        die;
    }
    require_once $fn;
    return smarty_modifier_date_format($string, $format, $default_date);
}
 /**
  * @ignore
  */
 private static function _load_nls()
 {
     if (!is_array(self::$_nls)) {
         self::$_nls = array();
         $config = cmsms()->GetConfig();
         $nlsdir = cms_join_path($config['root_path'], 'lib', 'nls');
         $langdir = cms_join_path($config['root_path'], $config['admin_dir'], 'lang');
         $files = glob($nlsdir . '/*nls.php');
         if (is_array($files) && count($files)) {
             for ($i = 0; $i < count($files); $i++) {
                 if (!is_file($files[$i])) {
                     continue;
                 }
                 $fn = basename($files[$i]);
                 $tlang = substr($fn, 0, strpos($fn, '.'));
                 if ($tlang != 'en_US' && !file_exists(cms_join_path($langdir, 'ext', $tlang, 'admin.inc.php'))) {
                     continue;
                 }
                 unset($nls);
                 include $files[$i];
                 if (isset($nls)) {
                     $obj = CmsNls::from_array($nls);
                     unset($nls);
                     self::$_nls[$obj->key()] = $obj;
                 }
             }
         }
     }
 }
 function __construct(&$content_obj, &$params = array())
 {
     $params['type'] = 'image';
     parent::__construct($content_obj, $params);
     $config = cmsms()->GetConfig();
     $this->SetBlockProperty('prefix', isset($params['prefix']) ? $params['prefix'] : 'thumb_');
     $this->SetBlockProperty('exclude', isset($params['exclude']) && $this->content_obj->IsFalse($params['exclude']));
     $this->SetBlockProperty('dir', cms_join_path($config['uploads_path'], isset($params['dir']) ? $params['dir'] : get_site_preference('contentimage_path')));
     $this->SetBlockProperty('inputname', isset($params['inputname']) ? $params['inputname'] : $this->GetBlockProperty('id'));
 }
Example #8
0
/**
 * @ignore
 */
function adodb_error($dbtype, $function_performed, $error_number, $error_message, $host, $database, &$connection_obj)
{
    if (file_exists(cms_join_path(dirname(CONFIG_FILE_LOCATION), 'db_error.html'))) {
        include_once cms_join_path(dirname(CONFIG_FILE_LOCATION), 'db_error.html');
        exit;
    } else {
        echo "<strong>Database Connection Failed</strong><br />";
        echo "Error: {$error_message} ({$error_number})<br />";
        echo "Function Performed: {$function_performed}<br />";
    }
}
 function __construct()
 {
     //color-names supported by modern browsers(from http://www.w3schools.com/html/html_colornames.asp)
     $this->colors = array('aliceblue' => '#f0f8ff', 'antiquewhite' => '#faebd7', 'aqua' => '#00ffff', 'aquamarine' => '#7fffd4', 'azure' => '#f0ffff', 'beige' => '#f5f5dc', 'bisque' => '#ffe4c4', 'black' => '#000000', 'blanchedalmond' => '#ffebcd', 'blue' => '#0000ff', 'blueviolet' => '#8a2be2', 'brown' => '#a52a2a', 'burlywood' => '#deb887', 'cadetblue' => '#5f9ea0', 'chartreuse' => '#7fff00', 'chocolate' => '#d2691e', 'coral' => '#ff7f50', 'cornflowerblue' => '#6495ed', 'cornsilk' => '#fff8dc', 'crimson' => '#dc143c', 'cyan' => '#00ffff', 'darkblue' => '#00008b', 'darkcyan' => '#008b8b', 'darkgoldenrod' => '#b8860b', 'darkgray' => '#a9a9a9', 'darkgrey' => '#a9a9a9', 'darkgreen' => '#006400', 'darkkhaki' => '#bdb76b', 'darkmagenta' => '#8b008b', 'darkolivegreen' => '#556b2f', 'darkorange' => '#ff8c00', 'darkorchid' => '#9932cc', 'darkred' => '#8b0000', 'darksalmon' => '#e9967a', 'darkseagreen' => '#8fbc8f', 'darkslateblue' => '#483d8b', 'darkslategray' => '#2f4f4f', 'darkslategrey' => '#2f4f4f', 'darkturquoise' => '#00ced1', 'darkviolet' => '#9400d3', 'deeppink' => '#ff1493', 'deepskyblue' => '#00bfff', 'dimgray' => '#696969', 'dimgrey' => '#696969', 'dodgerblue' => '#1e90ff', 'firebrick' => '#b22222', 'floralwhite' => '#fffaf0', 'forestgreen' => '#228b22', 'fuchsia' => '#ff00ff', 'gainsboro' => '#dcdcdc', 'ghostwhite' => '#f8f8ff', 'gold' => '#ffd700', 'goldenrod' => '#daa520', 'gray' => '#808080', 'grey' => '#808080', 'green' => '#008000', 'greenyellow' => '#adff2f', 'honeydew' => '#f0fff0', 'hotpink' => '#ff69b4', 'indianred' => '#cd5c5c', 'indigo' => '#4b0082', 'ivory' => '#fffff0', 'khaki' => '#f0e68c', 'lavender' => '#e6e6fa', 'lavenderblush' => '#fff0f5', 'lawngreen' => '#7cfc00', 'lemonchiffon' => '#fffacd', 'lightblue' => '#add8e6', 'lightcoral' => '#f08080', 'lightcyan' => '#e0ffff', 'lightgoldenrodyellow' => '#fafad2', 'lightgray' => '#d3d3d3', 'lightgrey' => '#d3d3d3', 'lightgreen' => '#90ee90', 'lightpink' => '#ffb6c1', 'lightsalmon' => '#ffa07a', 'lightseagreen' => '#20b2aa', 'lightskyblue' => '#87cefa', 'lightslategray' => '#778899', 'lightslategrey' => '#778899', 'lightsteelblue' => '#b0c4de', 'lightyellow' => '#ffffe0', 'lime' => '#00ff00', 'limegreen' => '#32cd32', 'linen' => '#faf0e6', 'magenta' => '#ff00ff', 'maroon' => '#800000', 'mediumaquamarine' => '#66cdaa', 'mediumblue' => '#0000cd', 'mediumorchid' => '#ba55d3', 'mediumpurple' => '#9370d8', 'mediumseagreen' => '#3cb371', 'mediumslateblue' => '#7b68ee', 'mediumspringgreen' => '#00fa9a', 'mediumturquoise' => '#48d1cc', 'mediumvioletred' => '#c71585', 'midnightblue' => '#191970', 'mintcream' => '#f5fffa', 'mistyrose' => '#ffe4e1', 'moccasin' => '#ffe4b5', 'navajowhite' => '#ffdead', 'navy' => '#000080', 'oldlace' => '#fdf5e6', 'olive' => '#808000', 'olivedrab' => '#6b8e23', 'orange' => '#ffa500', 'orangered' => '#ff4500', 'orchid' => '#da70d6', 'palegoldenrod' => '#eee8aa', 'palegreen' => '#98fb98', 'paleturquoise' => '#afeeee', 'palevioletred' => '#d87093', 'papayawhip' => '#ffefd5', 'peachpuff' => '#ffdab9', 'peru' => '#cd853f', 'pink' => '#ffc0cb', 'plum' => '#dda0dd', 'powderblue' => '#b0e0e6', 'purple' => '#800080', 'red' => '#ff0000', 'rosybrown' => '#bc8f8f', 'royalblue' => '#4169e1', 'saddlebrown' => '#8b4513', 'salmon' => '#fa8072', 'sandybrown' => '#f4a460', 'seagreen' => '#2e8b57', 'seashell' => '#fff5ee', 'sienna' => '#a0522d', 'silver' => '#c0c0c0', 'skyblue' => '#87ceeb', 'slateblue' => '#6a5acd', 'slategray' => '#708090', 'slategrey' => '#708090', 'snow' => '#fffafa', 'springgreen' => '#00ff7f', 'steelblue' => '#4682b4', 'tan' => '#d2b48c', 'teal' => '#008080', 'thistle' => '#d8bfd8', 'tomato' => '#ff6347', 'turquoise' => '#40e0d0', 'violet' => '#ee82ee', 'wheat' => '#f5deb3', 'white' => '#ffffff', 'whitesmoke' => '#f5f5f5', 'yellow' => '#ffff00', 'yellowgreen' => '#9acd32');
     //some hard-coded default styles
     $this->css = array('.box' => array('height' => '40px', 'width' => '120px', 'margin' => '3px 5px', 'padding' => '2px', 'background-color' => '#fff', 'border-width' => '2px', 'border-color' => '#f00', 'color' => '#000', 'font-size' => '9px'), '.box:nonfirm' => array('border-color' => '#00f', 'background-color' => '#ffcb94'), '.box:firm' => array('border-color' => '#f00', 'background-color' => '#b7e8b1'), '.box:played' => array('border-color' => '#002c8f', 'background-color' => '#bfd6ec'), '.box:winner' => array('border-color' => '#80007f', 'background-color' => '#e5b400', 'color' => '#000'), '.chart' => array('padding' => '10px', 'gapwidth' => '10px', 'background-color' => '#fff7ed', 'font-family' => 'sans', 'minheight' => '526pt', 'minwidth' => '770pt'), '.line' => array('width' => '2px', 'color' => '#008000'));
     //replace defaults from file, if possible
     $csspath = cms_join_path(dirname(dirname(__FILE__)), 'css', 'chart.css');
     if (file_exists($csspath)) {
         self::Parse($csspath);
     }
 }
Example #10
0
function installerShowErrorPage($error, $fragment = '')
{
    include cms_join_path(CMS_INSTALL_BASE, 'templates', 'installer_start.tpl');
    echo '<p class="error">';
    echo $error;
    if (!empty($fragment)) {
        echo ' <a class="external" rel="external" href="' . CMS_INSTALL_HELP_URL . '#' . $fragment . '">?</a>';
    }
    echo '</p>';
    include cms_join_path(CMS_INSTALL_BASE, 'templates', 'installer_end.tpl');
    exit;
}
 /**
  * Constructor
  *
  * @param string $src The source URL
  * @param int  $timelimit The amount of time in minutes before this file must be refreshed.  Default is 24 hours.
  * @param string $dest Optional destination filename.
  */
 public function __construct($src, $timelimit = 0, $dest = '')
 {
     $this->_src_spec = $src;
     if ($timelimit <= 0) {
         $timelimit = 24 * 60;
     }
     $this->_cache_timelimit = $timelimit;
     if (empty($dest)) {
         $bn = 'cgecrf_' . md5($src);
         $dest = cms_join_path(TMP_CACHE_LOCATION, $bn);
     }
     $this->_cache_file = $dest;
 }
Example #12
0
 /**
  * GetInstance method used to access the object
  * @access public
  * @return 
  */
 public static function GetInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
         $rootdir = dirname(dirname(dirname(dirname(__FILE__))));
         $cmsms_cnf_file = cms_join_path($rootdir, 'config.php');
         include $cmsms_cnf_file;
         $file = cms_join_path(dirname(dirname(__FILE__)), 'includes', 'fb_cnf.inc');
         include $file;
         self::$_data = array_merge($config, $fbcfg);
     }
     return self::$_instance;
 }
    /**
    DeleteBracket:
    @mod: reference to Tourney module object
    @bracket_id: single bracket identifier, or array of them
    */
    function DeleteBracket(&$mod, $bracket_id)
    {
        $db = cmsms()->GetDb();
        $pref = cms_db_prefix();
        if (!is_array($bracket_id)) {
            $bracket_id = array($bracket_id);
        }
        foreach ($bracket_id as $bid) {
            $sql = 'SELECT chartcss FROM ' . $pref . 'module_tmt_brackets WHERE bracket_id=?';
            $file = $db->GetOne($sql, array($bid));
            if ($file) {
                $sql = 'SELECT COUNT(*) AS sharers FROM ' . $pref . 'module_tmt_brackets WHERE chartcss=?';
                $num = $db->GetOne($sql, array($file));
                if ($num < 2) {
                    if ($mod->GetPreference('uploads_dir')) {
                        $path = cms_join_path($config['uploads_path'], $mod->GetPreference('uploads_dir'), $file);
                    } else {
                        $path = cms_join_path($config['uploads_path'], $file);
                    }
                    if (is_file($path)) {
                        unlink($path);
                    }
                }
            }
            $file = $mod->ChartImageFile($bid);
            if ($file) {
                unlink($file);
            }
            $sql = 'DELETE FROM ' . $pref . 'module_tmt_tweet WHERE bracket_id=?';
            $db->Execute($sql, array($bid));
            $sql = 'DELETE FROM ' . $pref . 'module_tmt_people WHERE id IN
			 (SELECT team_id FROM ' . $pref . 'module_tmt_teams WHERE bracket_id=?)';
            $db->Execute($sql, array($bid));
            $sql = 'DELETE FROM ' . $pref . 'module_tmt_teams WHERE bracket_id=?';
            $db->Execute($sql, array($bid));
            $sql = 'DELETE FROM ' . $pref . 'module_tmt_matches WHERE bracket_id=?';
            $db->Execute($sql, array($bid));
            $sql = 'DELETE FROM ' . $pref . 'module_tmt_brackets WHERE bracket_id=?';
            $db->Execute($sql, array($bid));
            $bid = $params['bracket_id'];
            $mod->DeleteTemplate('mailout_' . $bid . '_template');
            $mod->DeleteTemplate('mailcancel_' . $bid . '_template');
            $mod->DeleteTemplate('mailrequest_' . $bid . '_template');
            $mod->DeleteTemplate('mailin_' . $bid . '_template');
            $mod->DeleteTemplate('tweetout_' . $bid . '_template');
            $mod->DeleteTemplate('tweetcancel_' . $bid . '_template');
            $mod->DeleteTemplate('tweetrequest_' . $bid . '_template');
            $mod->DeleteTemplate('tweetin_' . $bid . '_template');
            $mod->DeleteTemplate('chart_' . $bid . '_template');
        }
    }
 function assignVariables()
 {
     $values = array();
     $values['sitename'] = isset($_POST['sitename']) ? htmlentities($_POST['sitename'], ENT_QUOTES, 'UTF-8') : 'CMS Made Simple Site';
     $values['db']['dbms'] = isset($_POST['dbms']) ? $_POST['dbms'] : 'mysqli';
     $values['db']['host'] = isset($_POST['host']) ? $_POST['host'] : 'localhost';
     $values['db']['database'] = isset($_POST['database']) ? $_POST['database'] : 'cms';
     $values['db']['username'] = isset($_POST['username']) ? $_POST['username'] : '';
     $values['db']['password'] = isset($_POST['password']) ? $_POST['password'] : '';
     $values['db']['prefix'] = isset($_POST['prefix']) ? $_POST['prefix'] : 'cms_';
     $values['db']['db_port'] = isset($_POST['db_port']) ? $_POST['db_port'] : '';
     // $values['db']['db_socket'] = isset($_POST['db_socket']) ? $_POST['db_socket'] : '';
     if (isset($_SESSION['cms_orig_tz']) && $_SESSION['cms_orig_tz'] != '') {
         $values['timezone'] = $_SESSION['cms_orig_tz'];
         $this->smarty->assign('current_timezone', $_SESSION['cms_orig_tz']);
     }
     if (isset($_POST['timezone'])) {
         $values['timezone'] = $_POST['timezone'];
     }
     $values['umask'] = isset($_POST['umask']) ? $_POST['umask'] : '';
     $values['admininfo']['username'] = $_POST['adminusername'];
     $values['admininfo']['email'] = $_POST['adminemail'];
     if (isset($_POST['adminsalt'])) {
         $values['admininfo']['salt'] = $_POST['adminsalt'];
     }
     $values['admininfo']['password'] = $_POST['adminpassword'];
     $values['email_accountinfo'] = empty($_POST['email_accountinfo']) ? 0 : 1;
     $values['createtables'] = isset($_POST['createtables']) ? 1 : (isset($_POST['sitename']) ? 0 : 1);
     $values['createextra'] = isset($_POST['createextra']) ? 1 : (isset($_POST['sitename']) ? 0 : 1);
     $databases = array(array('name' => 'mysqli', 'title' => 'MySQLi (4.1+)'), array('name' => 'mysql', 'title' => 'MySQL (compatibility)'));
     $dbms_options = array();
     foreach ($databases as $db) {
         $extension = isset($db['extension']) ? $db['extension'] : $db['name'];
         if (extension_loaded($extension)) {
             $dbms_options[] = $db;
         }
     }
     $tmp = timezone_identifiers_list();
     if (is_array($tmp)) {
         $timezones = array();
         $timezones[''] = ilang('none');
         foreach ($tmp as $zone) {
             $timezones[$zone] = $zone;
         }
         $this->smarty->assign('timezones', $timezones);
     }
     $this->smarty->assign('extra_sql', is_file(cms_join_path(CMS_INSTALL_BASE, 'schemas', 'extra.sql')));
     $this->smarty->assign('dbms_options', $dbms_options);
     $this->smarty->assign('values', $values);
     $this->smarty->assign('errors', $this->errors);
 }
 function preContent(&$db)
 {
     $test = new StdClass();
     $test->error = false;
     $test->messages = array();
     $db->SetFetchMode(ADODB_FETCH_ASSOC);
     $current_version = 1;
     $query = "SELECT version from " . cms_db_prefix() . "version";
     $dbresult = $db->Execute($query);
     if (!$dbresult) {
         $test->messages[] = ilang('invalid_query', $query);
         $test->error = true;
     } else {
         while ($row = $dbresult->FetchRow()) {
             $current_version = $row["version"];
         }
         if ($current_version == 1) {
             $test->messages[] = ilang('empty_query', $query);
             $test->error = true;
         }
     }
     if (!$test->error && $current_version < CMS_SCHEMA_VERSION) {
         $test->messages[] = ilang('need_upgrade_schema', $current_version, CMS_SCHEMA_VERSION);
         while ($current_version < CMS_SCHEMA_VERSION) {
             $filename = cms_join_path(CMS_INSTALL_BASE, 'upgrades', "upgrade.{$current_version}.to." . ($current_version + 1) . '.php');
             if (file_exists($filename)) {
                 if ($this->debug) {
                     include $filename;
                 } else {
                     @(include $filename);
                 }
             } else {
                 $test->messages[] = ilang('nofiles') . ": {$filename}";
             }
             $current_version++;
         }
         $test->messages[] = ilang('schema_ok', $current_version);
     } elseif (!$test->error) {
         $test->messages[] = ilang('noneed_upgrade_schema', CMS_SCHEMA_VERSION);
     }
     if (isset($_SESSION['disable_hierarchy'])) {
         // gotta move the hierarchy stuff
         $query = 'UPDATE ' . cms_db_prefix() . 'content SET page_url = content_alias';
         $db->Execute($query);
         set_site_preference('content_autocreate_urls', 1);
         set_site_preference('content_autocreate_flaturls', 1);
         $test->messages[] = ilang('setup_flat_urls');
         unset($_SESSION['disable_hierarchy']);
     }
     $this->smarty->assign('test', $test);
 }
Example #16
0
function cms_autoloader($classname)
{
    $config = cmsms()->GetConfig();
    // standard classes
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $lowercase = strtolower($classname);
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$lowercase}.inc.php");
    if (file_exists($fn) && $classname != 'Content') {
        __cms_load($fn);
        return;
    }
    // standard interfaces
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    // standard content types
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', 'contenttypes', "{$classname}.inc.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    // module loaded content types
    $contentops = cmsms()->GetContentOperations();
    $types = $contentops->ListContentTypes();
    if (in_array(strtolower($classname), array_keys($types))) {
        $contentops->LoadContentType(strtolower($classname));
        return;
    }
    $fn = $config['root_path'] . "/modules/{$classname}/{$classname}.module.php";
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $list = ModuleOperations::get_instance()->GetLoadedModules();
    if (is_array($list) && count($list)) {
        foreach (array_keys($list) as $modname) {
            $fn = $config['root_path'] . "/modules/{$modname}/lib/class.{$classname}.php";
            if (file_exists($fn)) {
                __cms_load($fn);
                return;
            }
        }
    }
    // module classes
}
 public function __construct($src, $timelimit = 0, $dest = '')
 {
     $this->_src_spec = $src;
     if ($timelimit <= 0) {
         $timelimit = 24 * 60;
     }
     $this->_cache_timelimit = $timelimit;
     if (empty($dest)) {
         $bn = 'cache_' . md5($src);
         $config = cmsms()->GetConfig();
         $dest = cms_join_path($config['root_path'], 'tmp', 'cache', $bn);
     }
     $this->_cache_file = $dest;
 }
 function load($options = array())
 {
     // Call the parent class load method (includes necessary files)
     CaptchaLib::load();
     $aFonts = array(cms_join_path($this->getFontPath(), 'FreeSans.ttf'), cms_join_path($this->getFontPath(), 'FreeSerif.ttf'));
     if (!isset($this->object)) {
         $this->object = new PhpCaptcha($aFonts, $options['width'], $options['height']);
         $this->object->DisplayShadow($options['display_shadow'] == '1' ? true : false);
         $this->object->UseColour($options['use_color'] == '1' ? true : false);
         if ($options['owner_text'] != '') {
             $this->object->SetOwnerText($options['owner_text']);
         }
     }
 }
Example #19
0
 /**
  * @ignore
  */
 public static function reset_states()
 {
     $db = \CmsApp::get_instance()->GetDb();
     $query = 'TRUNCATE TABLE ' . CGEXTENSIONS_TABLE_STATES;
     $db->Execute($query);
     $fn = cms_join_path(dirname(__DIR__), 'states.txt');
     $raw_states = @file($fn);
     $query = 'INSERT INTO ' . CGEXTENSIONS_TABLE_STATES . ' (code,name,sorting) VALUES (?,?,?)';
     $n = 1;
     foreach ($raw_states as $one) {
         list($acronym, $state_name) = explode(',', $one);
         $acronym = trim($acronym);
         $state_name = trim($state_name);
         $db->Execute($query, array($acronym, $state_name, $n++));
     }
 }
 /**
  * Constructor
  *
  * @param array The hash of CMSMS config settings
  */
 public function __construct()
 {
     parent::__construct();
     $config = cmsms()->GetConfig();
     $this->setTemplateDir(cms_join_path($config['root_path'], 'tmp', 'templates'));
     $this->setConfigDir(cms_join_path($config['root_path'], 'tmp', 'templates'));
     $this->setCaching(false);
     $this->force_compile = true;
     $this->compile_id = 'parser' . time();
     // register default plugin handler
     $this->registerDefaultPluginHandler(array(&$this, 'defaultPluginHandler'));
     // Register plugins
     $this->registerPlugin('compiler', 'content', array('CMS_Content_Block', 'smarty_compiler_contentblock'), false);
     $this->registerPlugin('compiler', 'content_image', array('CMS_Content_Block', 'smarty_compiler_imageblock'), false);
     $this->registerPlugin('compiler', 'content_module', array('CMS_Content_Block', 'smarty_compiler_moduleblock'), false);
 }
 function __construct(&$content_obj, $params = array())
 {
     $params['block_type'] = 'image';
     parent::__construct($content_obj, $params);
     $config = cmsms()->GetConfig();
     $this->SetProperty('prefix', isset($params['prefix']) ? $params['prefix'] : 'thumb_');
     $this->SetProperty('exclude', !isset($params['exclude']) || ac_utils::IsFalse($params['exclude']));
     $this->SetProperty('dir', cms_join_path($config['uploads_path'], isset($params['dir']) ? $params['dir'] : get_site_preference('contentimage_path')));
     $this->SetProperty('inputname', isset($params['inputname']) ? $params['inputname'] : $this->GetProperty('id'));
     $this->SetProperty('urlonly', isset($params['urlonly']) && ac_utils::IsTrue($params['urlonly']));
     $this->SetProperty('class', isset($params['class']) ? $params['class'] : '');
     $this->SetProperty('alt', isset($params['alt']) ? $params['alt'] : '');
     $this->SetProperty('css_id', isset($params['id']) ? $params['id'] : '');
     $this->SetProperty('width', isset($params['width']) ? $params['width'] : '');
     $this->SetProperty('height', isset($params['height']) ? $params['height'] : '');
     $this->SetProperty('title', isset($params['title']) ? $params['title'] : '');
 }
function delTree($dir)
{
    $files = array_diff(scandir($dir), array('.', '..'));
    if ($files) {
        foreach ($files as $file) {
            $fp = cms_join_path($dir, $file);
            if (is_dir($fp)) {
                if (!delTree($fp)) {
                    return false;
                }
            } else {
                unlink($fp);
            }
        }
        unset($files);
    }
    return rmdir($dir);
}
Example #23
0
function cge_CreateInputSubmit(&$mod, $id, $name, $value = '', $addtext = '', $image = '', $confirmtext = '', $class = '', $alt = '', $elid = '')
{
    $real_image = '';
    if (!empty($image)) {
        $config = cms_config::get_instance();
        // check image_directories first
        if (isset($mod->_image_directories) && !empty($mod->_image_directories)) {
            foreach ($mod->_image_directories as $dir) {
                $url = cms_join_path($dir, $image);
                $path = cms_join_path($config['root_path'], $url);
                if (is_readable($path)) {
                    $real_image = $url;
                }
            }
        }
        $theme = cms_utils::get_theme_object();
        if (empty($real_image)) {
            $path = $config['root_path'] . '/' . $config['admin_dir'] . '/themes/' . $theme->themeName . '/images/';
            if (file_exists($path . $image)) {
                // its a theme image
                $real_image = $config['admin_dir'] . "/themes/" . $theme->themeName . '/images/' . $image;
            }
        }
        if (empty($real_image)) {
            if (is_object($theme)) {
                // we're in the admin
                if (!$alt) {
                    $alt = $value;
                }
                $txt = $theme->DisplayImage($image, $alt, '', '', $class);
                $real_image = $theme->imageLink[$image];
            }
        }
        $addtext .= ' title="' . $value . '"';
    }
    if (!empty($class)) {
        $addtext .= ' class="' . $class . '"';
    }
    return $mod->CreateInputSubmit($id, $name, $value, $addtext, $real_image, $confirmtext);
}
Example #24
0
 public static function handle_upload($itemid, $fieldname, &$error)
 {
     $config = cmsms()->GetConfig();
     $mod = cms_utils::get_module('News');
     $p = cms_join_path($config['uploads_path'], 'news');
     if (!is_dir($p)) {
         $res = @mkdir($p);
         if ($res === FALSE) {
             $error = $mod->Lang('error_mkdir', $p);
             return FALSE;
         }
     }
     $p = cms_join_path($config['uploads_path'], 'news', 'id' . $itemid);
     if (!is_dir($p)) {
         if (@mkdir($p) === FALSE) {
             $error = $mod->Lang('error_mkdir', $p);
             return FALSE;
         }
     }
     if ($_FILES[$fieldname]['size'] > $config['max_upload_size']) {
         $error = $mod->Lang('error_filesize');
         return FALSE;
     }
     $filename = basename($_FILES[$fieldname]['name']);
     $dest = cms_join_path($config['uploads_path'], 'news', 'id' . $itemid, $filename);
     // Get the files extension
     $ext = substr(strrchr($filename, '.'), 1);
     // compare it against the 'allowed extentions'
     $exts = explode(',', $mod->GetPreference('allowed_upload_types', ''));
     if (!in_array($ext, $exts)) {
         $error = $mod->Lang('error_invalidfiletype');
         return FALSE;
     }
     if (@cms_move_uploaded_file($_FILES[$fieldname]['tmp_name'], $dest) === FALSE) {
         $error = $mod->Lang('error_movefile', $dest);
         return FALSE;
     }
     return $filename;
 }
/**
 * Smarty date_format modifier plugin
 *
 * Type:     modifier<br>
 * Name:     cms_date_format<br>
 * Purpose:  format datestamps via strftime<br>
 * Input:<br>
 *          - string: input date string
 *          - format: strftime format for output
 *          - default_date: default date if $string is empty
 *
 * @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
 * @author Monte Ohrt <monte at ohrt dot com>
 * @param string $string       input date string
 * @param string $format       strftime format for output
 * @param string $default_date default date if $string is empty
 * @param string $formatter    either 'strftime' or 'auto'
 * @return string |void
 * @uses smarty_make_timestamp()
 *
 * Modified by Tapio Löytty <*****@*****.**>
 */
function smarty_cms_modifier_cms_date_format($string, $format = '', $default_date = '')
{
    if ($format == '') {
        $format = get_site_preference('defaultdateformat');
        if ($format == '') {
            $format = '%b %e, %Y';
        }
        if (!cmsms()->is_frontend_request()) {
            if ($uid = get_userid(false)) {
                $tmp = get_preference($uid, 'date_format_string');
                if ($tmp != '') {
                    $format = $tmp;
                }
            }
        }
    }
    $fn = cms_join_path(SMARTY_PLUGINS_DIR, 'modifier.date_format.php');
    if (!file_exists($fn)) {
        die;
    }
    require_once $fn;
    return smarty_modifier_date_format($string, $format, $default_date);
}
 function get_file_listing($dir, $excludeprefix = '', $assign = '')
 {
     $gCms = cmsms();
     $smarty = $gCms->GetSmarty();
     $config = $gCms->GetConfig();
     $fileprefix = '';
     if (!empty($excludeprefix)) {
         $fileprefix = $excludeprefix;
     }
     if (startswith($dir, '/')) {
         return;
     }
     $dir = cms_join_path($config['uploads_path'], $dir);
     $list = get_matching_files($dir, '', true, true, $fileprefix, 1);
     if (!empty($assign)) {
         $smarty->assign(trim($assign), $list);
         return;
     }
     return $list;
 }
        if ($s == FALSE) {
            $s = '{$title}' . "\n\n" . $this->Lang('cancelled_email', '{$when}');
        }
        $this->SetTemplate('mailcancel_default_template', $s);
        $fn = cms_join_path(dirname(__FILE__), 'templates', 'email_request.tpl');
        $s = @file_get_contents($fn);
        if ($s == FALSE) {
            $s = '{$title}' . "\n\n" . $this->Lang('title_mid') . '{if $where} {$where}{/if}{if $when} {$when}{/if} {$teams}' . "\n\n" . $this->Lang('tpl_mailresult', '{if $contact}{$contact}{elseif $smsfrom}{$smsfrom}{elseif $owner}{$owner}{else}' . $this->Lang('organisers') . '{/if}');
        }
        $this->SetTemplate('mailrequest_default_template', $s);
        $fn = cms_join_path(dirname(__FILE__), 'templates', 'tweet_cancelled.tpl');
        $s = @file_get_contents($fn);
        if ($s == FALSE) {
            $s = '{$title} ' . mb_strtolower($this->Lang('title_mid')) . ' ' . mb_strtoupper($this->Lang('cancelled')) . '{if $when}, ' . mb_strtoupper($this->Lang('not')) . ' {$when}{elseif $opponent},' . $this->Lang('name_against') . ' {$opponent}{/if}';
        }
        $this->SetTemplate('tweetcancel_default_template', $s);
        $fn = cms_join_path(dirname(__FILE__), 'templates', 'tweet_request.tpl');
        $s = @file_get_contents($fn);
        if ($s == FALSE) {
            $s = '{$title} ' . mb_strtolower($this->Lang('title_mid')) . ' {$where} {$when} {$teams} ' . $this->Lang('tpl_tweetresult', '{if $smsfrom}{$smsfrom}{elseif $contact}{$contact}{elseif $owner}{$owner}{else}' . $this->Lang('organisers') . '{/if}');
        }
        $this->SetTemplate('tweetrequest_default_template', $s);
        $fields = "\n\t\tgroup_id I(2) KEY,\n\t\tname C(128),\n\t\tdisplayorder I(2),\n\t\tflags I(1) DEFAULT 1\n\t";
        $sqlarray = $dict->CreateTableSQL($pref . 'module_tmt_groups', $fields, $taboptarray);
        $dict->ExecuteSQLArray($sqlarray);
        $db->CreateSequence($pref . 'module_tmt_groups_seq');
        // add default group 0
        $sql = 'INSERT INTO ' . $pref . 'module_tmt_groups (group_id,name,displayorder) VALUES (0,?,1)';
        $db->Execute($sql, array($this->Lang('groupdefault')));
        break;
}
 /**
  * Clears the content cache
  *
  * @ignore
  * @internal
  * @access private
  * @return void
  */
 function ClearCache()
 {
     $gCms = cmsms();
     $smarty = $gCms->GetSmarty();
     cms_content_cache::clear();
     unset($gCms->hrinstance);
     $smarty->clear_all_cache();
     $smarty->clear_compiled_tpl();
     if (is_file(TMP_CACHE_LOCATION . '/contentcache.php')) {
         unlink(TMP_CACHE_LOCATION . '/contentcache.php');
     }
     @touch(cms_join_path(TMP_CACHE_LOCATION, 'index.html'));
     @touch(cms_join_path(TMP_TEMPLATES_C_LOCATION, 'index.html'));
 }
 function assignVariables()
 {
     $settings = array('info' => array(), 'required' => array(), 'recommended' => array());
     $safe_mode = ini_get('safe_mode');
     $open_basedir = ini_get('open_basedir');
     /*
      * Info Settings
      */
     $settings['info']['server_software'] = $_SERVER['SERVER_SOFTWARE'];
     $settings['info']['server_api'] = PHP_SAPI;
     $settings['info']['server_os'] = PHP_OS . ' ' . php_uname('r') . ' ' . ilang('on') . ' ' . php_uname('m');
     if (extension_loaded_or('apache2handler')) {
         $settings['info']['mod_security'] = getApacheModules('mod_security') ? ilang('on') : ilang('off');
     }
     /*
      * Required Settings
      */
     list($minimum, $recommended) = getTestValues('php_version');
     $settings['recommended'][] = testIntegerMask(0, ilang('test_error_estrict'), 'error_reporting', E_STRICT, ilang('test_estrict_failed'), true, true, false);
     if (defined('E_DEPRECATED')) {
         $settings['recommended'][] = testIntegerMask(0, ilang('test_error_edeprecated'), 'error_reporting', E_DEPRECATED, ilang('test_edeprecated_failed'), true, true, false);
     }
     $settings['required'][] = testVersionRange(1, ilang('test_check_php', $minimum) . '<br />' . ilang('test_min_recommend', $minimum, $recommended), phpversion(), ilang('test_requires_php_version', phpversion(), $recommended), $minimum, $recommended, false);
     $settings['required'][] = testBoolean(1, ilang('test_check_md5_func'), function_exists('md5'), '', false, false, 'Function_md5_disabled');
     list($minimum, $recommended) = getTestValues('gd_version');
     $settings['required'][] = testGDVersion(1, ilang('test_check_gd'), $minimum, ilang('test_check_gd_failed'), 'min_GD_version');
     $settings['required'][] = testFileWritable(1, ilang('test_check_write') . ' config.php', CONFIG_FILE_LOCATION, ilang('test_may_not_exist'), $this->debug);
     $settings['required'][] = testBoolean(1, ilang('test_check_tempnam'), function_exists('tempnam'), '', false, false, 'Function_tempnam_disabled');
     $settings['required'][] = testBoolean(1, ilang('test_check_magic_quotes_runtime'), 'magic_quotes_runtime', ilang('test_check_magic_quotes_runtime_failed'), true, true, 'magic_quotes_runtime_On');
     $settings['required'][] = testSupportedDatabase(1, ilang('test_check_db_drivers'), false, ilang('test_check_db_drivers_failed'));
     if ('1' != $safe_mode && !isset($_SESSION['allowsafemode'])) {
         $settings['required'][] = testCreateDirAndFile(1, ilang('test_create_dir_and_file'), ilang('info_create_dir_and_file'), $this->debug);
     }
     /*
      * Recommended Settings
      */
     list($minimum, $recommended) = getTestValues('memory_limit');
     $settings['recommended'][] = testRange(0, ilang('test_check_memory') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'memory_limit', ilang('test_check_memory_failed'), $minimum, $recommended, true, true, null, 'memory_limit_range');
     list($minimum, $recommended) = getTestValues('max_execution_time');
     $settings['recommended'][] = testRange(0, ilang('test_check_time_limit') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'max_execution_time', ilang('test_check_time_limit_failed'), $minimum, $recommended, true, false, 0, 'max_execution_time_range');
     $settings['recommended'][] = testBoolean(0, ilang('test_check_register_globals'), 'register_globals', ilang('test_check_register_globals_failed'), true, true, 'register_globals_enabled');
     $settings['recommended'][] = testInteger(0, ilang('test_check_output_buffering'), 'output_buffering', ilang('test_check_output_buffering_failed'), true, true, 'output_buffering_disabled');
     $settings['recommended'][] = testString(0, ilang('test_check_disable_functions'), 'disable_functions', ilang('test_check_disable_functions_failed'), true, 'green', 'yellow', 'disable_functions_not_empty');
     if (!isset($_SESSION['allowsafemode'])) {
         $settings['recommended'][] = testBoolean(0, ilang('test_check_safe_mode'), 'safe_mode', ilang('test_check_safe_mode_failed'), true, true, 'safe_mode_enabled');
     }
     $settings['recommended'][] = testString(0, ilang('test_check_open_basedir'), $open_basedir, ilang('test_check_open_basedir_failed'), false, 'green', 'yellow', 'open_basedir_enabled');
     if (!isset($_SESSION['skipremote'])) {
         $settings['recommended'][] = testRemoteFile(0, ilang('test_remote_url'), '', ilang('test_remote_url_failed'), $this->debug);
     }
     $settings['recommended'][] = testBoolean(0, ilang('test_check_file_upload'), 'file_uploads', ilang('test_check_file_failed'), true, false, 'Function_file_uploads_disabled');
     list($minimum, $recommended) = getTestValues('post_max_size');
     $settings['recommended'][] = testRange(0, ilang('test_check_post_max') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'post_max_size', ilang('test_check_post_max_failed'), $minimum, $recommended, true, true, null, 'min_post_max_size');
     list($minimum, $recommended) = getTestValues('upload_max_filesize');
     $settings['recommended'][] = testRange(0, ilang('test_check_upload_max') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'upload_max_filesize', ilang('test_check_upload_max_failed'), $minimum, $recommended, true, true, null, 'min_upload_max_filesize');
     $f = cms_join_path(CMS_BASE, 'uploads');
     $settings['recommended'][] = testDirWrite(0, ilang('test_check_writable', $f), $f, ilang('test_check_upload_failed'), 0, $this->debug);
     $f = cms_join_path(CMS_BASE, 'uploads' . DIRECTORY_SEPARATOR . 'images');
     $settings['recommended'][] = testDirWrite(0, ilang('test_check_writable', $f), $f, ilang('test_check_images_failed'), 0, $this->debug);
     $f = cms_join_path(CMS_BASE, 'modules');
     $settings['recommended'][] = testDirWrite(0, ilang('test_check_writable', $f), $f, ilang('test_check_modules_failed'), 0, $this->debug);
     $session_save_path = testSessionSavePath('');
     if (empty($session_save_path)) {
         $settings['recommended'][] = testDummy(ilang('test_check_session_save_path'), '', 'yellow', ilang('test_empty_session_save_path'), 'session_save_path_empty', '');
     } elseif (!empty($open_basedir)) {
         $settings['recommended'][] = testDummy(ilang('test_check_session_save_path'), '', 'yellow', ilang('test_open_basedir_session_save_path'), 'No_check_session_save_path_with_open_basedir', '');
     } else {
         $settings['recommended'][] = testDirWrite(0, ilang('test_check_session_save_path'), $session_save_path, ilang('test_check_session_save_path_failed', $session_save_path), 1, $this->debug);
     }
     $settings['recommended'][] = testBoolean(0, 'session.use_cookies', 'session.use_cookies', ilang('session_use_cookies'));
     $settings['recommended'][] = testBoolean(0, ilang('test_check_xml_func'), extension_loaded_or('xml'), ilang('test_check_xml_failed'), false, false, 'Function_xml_disabled');
     $settings['recommended'][] = testBoolean(0, ilang('test_xmlreader_class'), class_exists('XMLReader', false), ilang('test_xmlreader_failed'), false, false, 'class_xmlreader_unavailable');
     $settings['recommended'][] = testBoolean(0, ilang('test_check_file_get_contents'), function_exists('file_get_contents'), ilang('test_check_file_get_contents_failed'), false, false, 'Function_file_get_content_disabled');
     #		$settings['recommended'][] =
     #			testBoolean(0, ilang('test_check_magic_quotes_gpc'),
     #				'magic_quotes_gpc', ilang('test_check_magic_quotes_gpc_failed'), true, true, 'magic_quotes_gpc_On');
     $_log_errors_max_len = ini_get('log_errors_max_len') ? ini_get('log_errors_max_len') . '0' : '99';
     ini_set('log_errors_max_len', $_log_errors_max_len);
     $result = ini_get('log_errors_max_len') == $_log_errors_max_len;
     $settings['recommended'][] = testBoolean(0, ilang('test_check_ini_set'), $result, ilang('test_check_ini_set_failed'), false, false, 'ini_set_disabled');
     // assign settings
     list($this->continueon, $this->special_failed) = testGlobal(array(true, false), true);
     $this->smarty->assign('settings', $settings);
     $this->smarty->assign('special_failed', $this->special_failed);
     if (isset($_SESSION['advanceduser'])) {
         $this->smarty->assign('continueon', true);
     } else {
         $this->smarty->assign('continueon', $this->continueon);
     }
     $this->smarty->assign('phpinfo', getEmbedPhpInfo(INFO_CONFIGURATION | INFO_MODULES));
     $this->smarty->assign('errors', $this->errors);
 }
Example #30
0
function check_checksum_data(&$report)
{
    if (!isset($_FILES['cksumdat']) || empty($_FILES['cksumdat']['name'])) {
        $report = lang('error_nofileuploaded');
        return false;
    } else {
        if ($_FILES['cksumdat']['error'] > 0) {
            $report = lang('error_uploadproblem');
            return false;
        }
    }
    $fh = fopen($_FILES['cksumdat']['tmp_name'], 'r');
    if (!$fh) {
        $report = lang('error_uploadproblem');
        return false;
    }
    global $gCms;
    $config =& $gCms->GetConfig();
    $filenotfound = array();
    $notreadable = 0;
    $md5failed = 0;
    $filesfailed = array();
    while (!feof($fh)) {
        // get a line
        $line = fgets($fh, 4096);
        // strip out comments
        $pos = strpos($line, '#');
        if ($pos) {
            $line = substr($line, 0, $pos);
        }
        // trim the line
        $line = trim($line);
        // skip empty line
        if (empty($line)) {
            continue;
        }
        // split it into fields
        $md5sum = '';
        $file = '';
        if (strstr($line, ' *.') !== FALSE) {
            list($md5sum, $file) = explode(' *.', $line, 2);
        } else {
            list($md5sum, $file) = explode('--:--', $line, 2);
        }
        $md5sum = trim($md5sum);
        $file = trim($file);
        $fn = cms_join_path($config['root_path'], $file);
        if (!file_exists($fn)) {
            $filenotfound[] = $file;
            continue;
        }
        if (is_dir($fn)) {
            continue;
        }
        if (!is_readable($fn)) {
            $notreadable++;
            continue;
        }
        $md5 = md5_file($fn);
        if (!$md5) {
            $md5failed++;
            continue;
        }
        if ($md5sum != $md5) {
            $filesfailed[] = $file;
        }
    }
    fclose($fh);
    if (count($filenotfound) || $notreadable || $md5failed || count($filesfailed)) {
        // build the error report
        $tmp2 = array();
        if (count($filenotfound)) {
            $tmp2[] = sprintf("%d %s", count($filenotfound), lang('files_not_found'));
        }
        if ($notreadable) {
            $tmp2[] = sprintf("%d %s", $notreadable, lang('files_not_readable'));
        }
        if ($md5failed) {
            $tmp2[] = sprintf("%d %s", $md5failed, lang('files_checksum_failed'));
        }
        if (!empty($tmp)) {
            $tmp .= "<br/>";
        }
        $tmp = implode("<br/>", $tmp2);
        if (count($filenotfound)) {
            $tmp .= "<br/>" . lang('files_not_found') . ':';
            $tmp .= "<br/>" . implode("<br/>", $filenotfound) . "<br/>";
        }
        if (count($filesfailed)) {
            $tmp .= "<br/>" . count($filesfailed) . ' ' . lang('files_failed') . ':';
            $tmp .= "<br/>" . implode("<br/>", $filesfailed) . "<br/>";
        }
        $report = $tmp;
        return false;
    }
    return true;
}