Exemple #1
0
 public function __construct($args)
 {
     if (!extension_loaded('midgard2')) {
         $this->fail("Midgard2 is not installed in your PHP environment.\n");
     } else {
         if (version_compare(mgd_version(), '10.05.4', '<=')) {
             $this->fail('OpenPSA requires midgard 10.05.5 or later (found version: ' . mgd_version() . ')');
         }
     }
     if (!class_exists('midgard_topic')) {
         $iterator = new DirectoryIterator('./schemas');
         foreach ($iterator as $fileinfo) {
             if ($fileinfo->isFile() && strpos($fileinfo->getFilename(), 'xml')) {
                 //@todo: how to determine correct schema dir?
                 $this->_link_file('schemas', $fileinfo->getFilename(), '/usr/share/midgard2/schema');
             }
         }
         $this->output('Schemas linked. Re-run installer to continue');
         exit(0);
     }
     if (empty($argv[1])) {
         $this->_project_name = $this->prompt('Enter project name', 'openpsa');
     } else {
         $this->_project_name = $argv[1];
     }
 }
Exemple #2
0
 /**
  * Starts up the authorization service and connects to various signals
  */
 public function __construct()
 {
     // Note: Signals implementation is not reliable in earlier builds so we won't use it
     if (version_compare(mgd_version(), '1.9.0alpha0+svn2008031408', '>=')) {
         foreach ($_MIDGARD['schema']['types'] as $classname => $null) {
             $this->connect_to_signals($classname);
         }
     }
 }
Exemple #3
0
 public function get_about(array $args)
 {
     midgardmvc_core::get_instance()->authorization->require_user();
     $this->data['versions'] = array('midgardmvc' => midgardmvc_core::get_instance()->componentloader->manifests['midgardmvc_core']['version'], 'midgard' => mgd_version(), 'php' => phpversion());
     $this->data['components'] = array();
     foreach (midgardmvc_core::get_instance()->componentloader->manifests as $component => $manifest) {
         if ($component == 'midgardmvc_core') {
             continue;
         }
         $this->data['components'][$component] = array('name' => $manifest['component'], 'version' => $manifest['version']);
     }
     $this->data['authors'] = midgardmvc_core::get_instance()->componentloader->authors;
     ksort($this->data['authors']);
 }
Exemple #4
0
 private function _user_agent()
 {
     return 'Midgard/' . substr(mgd_version(), 0, 4);
 }
Exemple #5
0
/**
 * Really Simple Discoverability format document for net.nehmer.blog
 *
 * RSD is used by several desktop blogging tools for autoprobing blog capabilities.
 *
 * More information about the format can be found in:
 * http://archipelago.phrasewise.com/rsd
 */
$prefix = midcom::get()->get_host_name() . midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
echo '<?xml version="1.0" ?>';
?>
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd" >
    <service>
        <engineName>Midgard CMS/<?php 
echo substr(mgd_version(), 0, 4);
?>
</engineName>
        <engineLink>http://www.midgard-project.org/</engineLink>
        <homePageLink><?php 
echo htmlspecialchars($prefix);
?>
</homePageLink>
        <apis>
            <api name="MetaWeblog" preferred="true" apiLink="<?php 
echo htmlspecialchars($prefix);
?>
api/metaweblog/" blogID="<?php 
echo $data['content_topic']->guid;
?>
" />
}
if (!defined('MIDGARDMVC_TEST_RUN')) {
    define('MIDGARDMVC_TEST_RUN', false);
}
/**
 * Make sure the URLs not having query string (or midcom-xxx- -method signature)
 * have trailing slash or some extension in the "filename".
 *
 * This makes life much, much better when making static copies for whatever reason
 */
if (isset($_SERVER['REQUEST_URI']) && !preg_match('%\\?|/$|midgardmvc-.+-|/.+\\..+$%', $_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_METHOD'] == 'GET' && !class_exists('MFS\\AppServer\\DaemonicHandler') && !class_exists('MFS_AppServer_DaemonicHandler')) {
    // Note: Midgard MVC is running under a conventional web server. Under Application Server we cannot use header()
    header('HTTP/1.0 301 Moved Permanently');
    header("Location: {$_SERVER['REQUEST_URI']}/");
    header('Content-type: text/html; charset=utf-8');
    // just to be sure, that the browser interprets fallback right
    $url_clean = htmlentities($_SERVER['REQUEST_URI']) . '/';
    echo "301: new location <a href='{$url_clean}'>{$url_clean}</a>";
    exit(0);
}
if (isset($_SERVER['REQUEST_URI']) && function_exists('mgd_version') && !class_exists('MFS\\AppServer\\DaemonicHandler') && !class_exists('MFS_AppServer_DaemonicHandler')) {
    // Advertise the fact that this is a Midgard server
    header('X-Powered-By: Midgard/' . mgd_version());
    // Note: Midgard MVC is running under a conventional web server. Under Application Server we cannot use header()
}
// Load the exception handler
require MIDGARDMVC_ROOT . '/midgardmvc_core/exceptionhandler.php';
// Start up Midgard MVC
require MIDGARDMVC_ROOT . '/midgardmvc_core/component/interface.php';
require MIDGARDMVC_ROOT . '/midgardmvc_core/component/baseclass.php';
require MIDGARDMVC_ROOT . '/midgardmvc_core/interface.php';
Exemple #7
0
echo $message;
?>
  </p>

  <div class="error-exception">
<?php 
if (!empty($this->data['error_exception'])) {
    $e = $this->data['error_exception'];
    echo '<p>' . get_class($e) . ' in ' . $e->getFile() . ', line ' . $e->getLine() . "</p>";
}
$stacktrace = $this->data['error_handler']->get_function_stack();
if (!empty($stacktrace)) {
    echo '<h3>Stacktrace:</h3>';
    echo "<pre>" . implode("\n", $stacktrace) . "</pre>\n";
}
?>
  </div>

  <div class="org_openpsa_softwareinfo">
      <a href="http://www.openpsa.org/">OpenPSA <?php 
echo org_openpsa_core_version::get_version_both();
?>
</a>,
      <a href="http://www.midgard-project.org/">Midgard <?php 
echo mgd_version();
?>
</a>
  </div>

</body>
</html>
Exemple #8
0
 private function _httpd_setup()
 {
     /*
      * First, block all Link prefetching requests as long as
      * MidCOM isn't bulletproofed against this "feature".
      * Ultimately, this is also a matter of performance...
      */
     if (array_key_exists('HTTP_X_MOZ', $_SERVER) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
         $this->header('Cache-Control: no-cache');
         $this->header('Pragma: no-cache');
         $this->header('HTTP/1.0 403 Forbidden');
         echo '403: Forbidden<br><br>Prefetching not allowed.';
         $this->stop_request();
     }
     /*
      * Second, make sure the URLs not having query string (or midcom-xxx- -method signature)
      * have trailing slash or some extension in the "filename".
      *
      * This makes life much, much better when making static copies for whatever reason
      *
      * 2008-09-26: Now also rewrites urls ending in .html to end with trailing slash.
      */
     $redirect_test_uri = (string) $_SERVER['REQUEST_URI'];
     if (!isset($_SERVER['MIDCOM_COMPAT_REDIR']) || (bool) $_SERVER['MIDCOM_COMPAT_REDIR'] !== false) {
         $redirect_test_uri = preg_replace('/\\.html$/', '', $redirect_test_uri);
     }
     if (!preg_match('%\\?|/$|midcom-.+-|/.*\\.[^/]+$%', $redirect_test_uri) && (!isset($_POST) || empty($_POST))) {
         $this->header('HTTP/1.0 301 Moved Permanently');
         $this->header("Location: {$redirect_test_uri}/");
         $redirect_test_uri_clean = htmlentities($redirect_test_uri);
         echo "301: new location <a href='{$redirect_test_uri_clean}/'>{$redirect_test_uri_clean}/</a>";
         $this->stop_request();
     }
     // Advertise the fact that this is a Midgard server
     $this->header('X-Powered-By: Midgard/' . mgd_version());
 }
 private function _process()
 {
     $this->context->create();
     date_default_timezone_set($this->configuration->get('default_timezone'));
     $this->dispatcher->get_midgard_connection()->set_loglevel($this->configuration->get('log_level'));
     // Let dispatcher populate request with the page and other information used
     $request = $this->dispatcher->get_request();
     $request->populate_context();
     if (isset($this->context->page->guid)) {
         // Load per-folder configuration
         $this->configuration->load_instance($this->context->component, $this->context->page);
     }
     $this->log('Midgard MVC', "Serving " . $request->get_method() . " {$this->context->uri} at " . gmdate('r'), 'info');
     // Let injectors do their work
     $this->componentloader = new midgardmvc_core_component_loader();
     $this->componentloader->inject_process();
     // Load the cache service and check for content cache
     self::$instance->context->cache_enabled = false;
     /*
     if (self::$instance->context->cache_enabled)
     {
         $request->generate_identifier();
         $this->cache->register_object($this->context->page);
         $this->cache->content->check($this->context->cache_request_identifier);
     }
     */
     // Show the world this is Midgard
     $this->head->add_meta(array('name' => 'generator', 'content' => "Midgard/" . mgd_version() . " MidgardMVC/{$this->componentloader->manifests['midgardmvc_core']['version']} PHP/" . phpversion()));
     if ($this->configuration->enable_attachment_cache) {
         $classname = $this->configuration->attachment_handler;
         $handler = new $classname();
         $handler->connect_to_signals();
     }
     // Then initialize the component, so it also goes to template stack
     $this->dispatcher->initialize($request);
     try {
         $this->dispatcher->dispatch();
     } catch (midgardmvc_exception_unauthorized $exception) {
         // Pass the exception to authentication handler
         $this->authentication->handle_exception($exception);
     }
     $this->dispatcher->header('Content-Type: ' . $this->context->mimetype);
 }
Exemple #10
0
 /**
  * Populates appropriate metadata into XHTML documents based on metadata information
  * available to MidCOM for the request.
  */
 function populate_meta_head()
 {
     // Populate the request metadata into view
     $request_metadata = $this->get_request_metadata();
     // HTML generator information
     midcom::get('head')->add_meta_head(array('name' => 'generator', 'content' => 'Midgard/' . mgd_version() . ' MidCOM/' . midcom::get_version() . ' PHP/' . phpversion()));
     // PermaLink into machine-detectable format
     midcom::get('head')->add_link_head(array('rel' => 'bookmark', 'href' => $request_metadata['permalink']));
     // Last revision time for the entire page
     if ($request_metadata['lastmodified']) {
         midcom::get('head')->add_meta_head(array('name' => 'lastupdated', 'content' => @gmdate('Y-m-d H:i:s\\Z', $request_metadata['lastmodified'])));
     }
     // If an object has been bound we have more information available
     $view_metadata = $this->get_view_metadata();
     if ($view_metadata) {
         foreach ($GLOBALS['midcom_config']['metadata_head_elements'] as $property => $metatag) {
             $content = $view_metadata->get($property);
             if ($content) {
                 // Handle date fields
                 switch ($property) {
                     case 'published':
                     case 'created':
                     case 'revised':
                     case 'approved':
                     case 'locked':
                         $content = gmdate('Y-m-d', (int) $content);
                         break;
                 }
                 midcom::get('head')->add_meta_head(array('name' => $metatag, 'content' => $content));
             }
         }
         // TODO: Add support for tags here
         if ($GLOBALS['midcom_config']['metadata_opengraph']) {
             $this->_add_opengraph_metadata($view_metadata);
         }
         if ($GLOBALS['midcom_config']['positioning_enable']) {
             // Load the positioning library
             midcom::get('componentloader')->load_library('org.routamc.positioning');
             // Display position metadata
             $object_position = new org_routamc_positioning_object($view_metadata->object);
             $object_position->set_metadata();
         }
     }
 }
Exemple #11
0
 /**
  * Decodes MIME content from $this->body
  */
 function mime_decode($message)
 {
     if (!class_exists('Mail_mimeDecode')) {
         @(include_once 'Mail/mimeDecode.php');
     }
     $this->_message = $message;
     $this->headers['User-Agent'] = 'Midgard/' . substr(mgd_version(), 0, 4);
     $this->headers['X-Originating-Ip'] = '[' . $_SERVER['REMOTE_ADDR'] . ']';
     $this->encoding = $this->_i18n->get_current_charset();
     if (!class_exists('Mail_mimeDecode')) {
         debug_add('Cannot decode without Mail_mimeDecode, aborting', MIDCOM_LOG_ERROR);
         return false;
     }
     // Make sure we only have NL linebreaks
     $this->_message = preg_replace("/\n\r|\r\n|\r/", "\n", $this->_message);
     $this->_check_boundary();
     $args = array();
     $args['include_bodies'] = true;
     $args['decode_bodies'] = true;
     $args['decode_headers'] = true;
     $args['crlf'] = "\n";
     $args['input'] = $this->_message;
     $decoder = new Mail_mimeDecode($this->_message);
     $this->__mime = $decoder->decode($args);
     if (is_a($this->__mime, 'pear_error')) {
         return false;
     }
     // ucwords all header keys
     if (is_array($this->__mime->headers)) {
         reset($this->__mime->headers);
         foreach ($this->__mime->headers as $k => $v) {
             $this->headers[str_replace(" ", "-", ucwords(str_replace("-", " ", $k)))] =& $this->__mime->headers[$k];
         }
     }
     if (!empty($this->__mime->parts) && is_array($this->__mime->parts)) {
         // Start with empty body and append all text parts to it
         $this->body = '';
         reset($this->__mime->parts);
         while (list($k, $part) = each($this->__mime->parts)) {
             $this->_part_decode($this->__mime->parts[$k]);
         }
     } else {
         //No parts, just body
         switch (strtolower($this->__mime->ctype_secondary)) {
             default:
             case "plain":
                 $this->body =& $this->__mime->body;
                 break;
             case "html":
                 $this->html_body =& $this->__mime->body;
                 $this->body = $this->html2text($this->__mime->body);
                 break;
         }
         if (isset($this->__mime->ctype_parameters['charset']) && !$this->__orig_encoding) {
             $this->__orig_encoding = $this->__mime->ctype_parameters['charset'];
         }
     }
     // Charset conversions
     debug_add('calling $this->_charset_convert($this->body, $this->__orig_encoding);');
     $this->body = $this->_charset_convert($this->body, $this->__orig_encoding);
     debug_add('calling $this->_charset_convert($this->html_body, $this->__orig_encoding);');
     $this->html_body = $this->_charset_convert($this->html_body, $this->__orig_encoding);
     foreach ($this->headers as $header => $value) {
         debug_add("calling _charset_convert for header '{$header}'");
         $this->headers[$header] = $this->_charset_convert($value, $this->__orig_encoding);
     }
     foreach ($this->attachments as $key => $data) {
         debug_add("calling _charset_convert for attachment '{$data['name']}'");
         $this->attachments[$key]['name'] = $this->_charset_convert($data['name'], $this->__orig_encoding);
     }
     //Strip whitespace around bodies
     $this->body = ltrim(rtrim($this->body));
     $this->html_body = ltrim(rtrim($this->html_body));
     //TODO Figure if decode was successful or not and return true/false in stead
     return $this->__mime;
 }
?>
                </div>
            </div>
        </div>
        <div id="siteinfo">
            <span class="copyrights">
                <img src="<?php 
echo MIDCOM_STATIC_URL;
?>
/midcom.services.toolbars/images/midgard-logo.png" alt="(M)" />
                <strong><?php 
echo midcom::get('i18n')->get_string('asgard for', 'midgard.admin.asgard');
if (extension_loaded('midgard2')) {
    echo " Midgard2 ";
} else {
    echo " Midgard ";
}
echo preg_replace('/\\.[0-9]+$/', '', mgd_version());
?>
</strong>.
                Copyright &copy; 1998 - <?php 
echo date('Y');
?>
 <a href="http://www.midgard-project.org/" rel="powered">The Midgard Project</a>.
                Midgard is a <a href="http://en.wikipedia.org/wiki/Free_software">free software</a> available under
                <a href="http://www.gnu.org/licenses/lgpl.html" rel="license" about="http://www.midgard-project.org/">GNU Lesser General Public License</a>.<br />&nbsp;
            </span>
        </div>
    </body>
</html>
Exemple #13
0
 public function check_midcom()
 {
     $this->print_header('Framework');
     if (version_compare(mgd_version(), '8.09.9', '<')) {
         $this->println('Midgard Version', self::ERROR, 'Midgard 8.09.9 or greater is required for OpenPSA.');
     } else {
         if (extension_loaded('midgard2') && version_compare(mgd_version(), '10.05.5', '<')) {
             $this->println('Midgard Version', self::ERROR, 'Midgard2 10.05.5 or greater is required for OpenPSA.');
         } else {
             $this->println('Midgard Version', self::OK, mgd_version());
         }
     }
     // Validate the Cache Base Directory.
     if (!is_dir($GLOBALS['midcom_config']['cache_base_directory'])) {
         $this->println('MidCOM cache base directory', self::ERROR, "The configured MidCOM cache base directory ({$GLOBALS['midcom_config']['cache_base_directory']}) does not exist or is not a directory. You have to create it as a directory writable by the Apache user.");
     } else {
         if (!is_writable($GLOBALS['midcom_config']['cache_base_directory'])) {
             $this->println('MidCOM cache base directory', self::ERROR, "The configured MidCOM cache base directory ({$GLOBALS['midcom_config']['cache_base_directory']}) is not writable by the Apache user. You have to create it as a directory writable by the Apache user.");
         } else {
             $this->println('MidCOM cache base directory', self::OK, $GLOBALS['midcom_config']['cache_base_directory']);
         }
     }
     $this->_check_rcs();
 }