Ejemplo n.º 1
0
 /**
  * Get a handle to the global CMS config. This is mostly values that are
  * defined in config.php
  *
  * @final
  * @return mixed an associative array of configuration values
  */
 function &GetConfig()
 {
     if (!isset($this->config)) {
         $configinstance = cms_config_load(true);
         $this->config =& $configinstance;
     }
     return $this->config;
 }
Ejemplo n.º 2
0
/**
 * Upgrades config.php from the old style
 *
 * @since 0.5
 * @deprecated
 * @ignore
 */
function cms_config_upgrade()
{
    #Get my lazy on and just do some regex magic...
    $newfiledir = dirname(CONFIG_FILE_LOCATION);
    $newfilename = CONFIG_FILE_LOCATION;
    $oldconfiglines = array();
    $oldconfig = cms_config_load();
    if (is_writable($newfilename) || is_writable($newfiledir)) {
        $handle = fopen($newfilename, "r");
        if ($handle) {
            while (!feof($handle)) {
                $oldconfiglines[] = fgets($handle, 4096);
            }
            fclose($handle);
            $handle = fopen($newfilename, "w");
            if ($handle) {
                foreach ($oldconfiglines as $oneline) {
                    /** from some ancient version? */
                    $newline = trim(preg_replace('/\\$this-\\>(\\S+)/', '$config["$1"]', $oneline));
                    /* uploads_url, remove root url */
                    if (preg_match('/\\$config\\[\'uploads_url\'\\]/', $oneline)) {
                        $newline = str_replace($oldconfig['root_url'], '', $oneline);
                    }
                    /* image_uploads_url, remove root url */
                    if (preg_match('/\\$config\\[\'image_uploads_url\'\\]/', $oneline)) {
                        $newline = str_replace($oldconfig['root_url'], '', $oneline);
                    }
                    if ($newline != "?>") {
                        $newline .= "\n";
                    }
                    fwrite($handle, $newline);
                }
                fclose($handle);
                return true;
            }
        }
    }
    return false;
}