require_once BASE . "subsystems/sharedcore.php"; } $core = $db->selectobject("sharedcore_core", "id=" . $site->core_id); $stat = pathos_sharedcore_setup($core, $site); // If we can setup the basic environment if ($stat == 0) { $site->id = $db->insertObject($site, "sharedcore_site"); // Update extensions table for this site. if (!defined("SYS_INFO")) { require_once BASE . "subsystems/info.php"; } $extension = null; $extension->site_id = $site->id; $extension->locked = 1; $used = array(CORE_EXT_MODULE => array(), CORE_EXT_SUBSYSTEM => array(), CORE_EXT_THEME => array()); foreach (pathos_core_resolveDependencies(null, CORE_EXT_SYSTEM, $core->path) as $d) { if (!in_array($d['name'], $used[$d['type']])) { $extension->name = $d['name']; $extension->type = $d['type']; $db->insertObject($extension, "sharedcore_extension"); $used[$d['type']][] = $d['name']; } } pathos_sharedcore_link($core, $site, $used); // Save database config. $values = array("c" => array("db_engine" => $_POST['db_engine'], "db_name" => $_POST['db_name'], "db_user" => $_POST['db_user'], "db_pass" => $_POST['db_pass'], "db_host" => $_POST['db_host'], "db_port" => $_POST['db_port'], "db_table_prefix" => $_POST['db_table_prefix']), "opts" => array(), "activate" => 1, "configname" => "Default"); if (!defined("SYS_CONFIG")) { require_once BASE . "subsystems/config.php"; } pathos_config_saveConfiguration($values, $site->path); // Install database for base system
function pathos_core_resolveDependencies($ext_name, $ext_type, $path = null) { if ($path == null) { $path = BASE; } $depfile = ''; switch ($ext_type) { case CORE_EXT_SUBSYSTEM: $depfile = $path . 'subsystems/' . $ext_name . '.deps.php'; break; case CORE_EXT_THEME: $depfile = $path . 'themes/' . $ext_name . '/deps.php'; break; case CORE_EXT_MODULE: $depfile = $path . 'modules/' . $ext_name . '/deps.php'; break; case CORE_EXT_SYSTEM: $depfile = $path . 'deps.php'; break; } $deps = array(); if (is_readable($depfile)) { $deps = (include $depfile); foreach ($deps as $info) { $deps = array_merge($deps, pathos_core_resolveDependencies($info['name'], $info['type'])); } } return $deps; }
function pathos_sharedcore_link($core, $site, $extensions = null) { if ($extensions == null) { $extensions = array(CORE_EXT_MODULE => array(), CORE_EXT_THEME => array(), CORE_EXT_SUBSYSTEM => array()); } $deps = pathos_core_resolveDependencies('', CORE_EXT_SYSTEM, $core->path); $prefixes = array(CORE_EXT_MODULE => 'm_', CORE_EXT_THEME => 't_', CORE_EXT_SUBSYSTEM => 's_'); foreach ($extensions as $type => $extens) { $prefix = $prefixes[$type]; foreach ($extens as $e) { $deps = array_merge($deps, pathos_core_resolveDependencies($e, $type, $core->path)); $deps[$prefix . $e] = array('name' => $e, 'type' => $type, 'comment' => ''); } } krsort($deps); // t,s,m $linksrc = $core->path; $linkdest = $site->path; foreach ($deps as $info) { echo 'Linking.' . $info['name'] . ' : ' . $info['type'] . '<br />'; pathos_sharedcore_linkExtension($info['type'], $info['name'], $core->path, $site->path); } foreach (include $linksrc . "manifest.php" as $file => $linkit) { if ($linkit !== 0 && file_exists($linksrc . $file)) { echo 'symlink(' . $linksrc . $file . ',' . $linkdest . $file . ');<br />'; __symlink($linksrc . $file, $linkdest . $file); } } // Cleanup -- essentially, pathos.php needs to be a real file, so that __realpath(__FILE__) calls work properly unlink($linkdest . 'pathos.php'); copy($linksrc . 'pathos.php', $linkdest . 'pathos.php'); return SHAREDCORE_ERR_OK; }